WINCC VBS调试,诊断功能,ADO

Introduction

One way to debug VBScript run-time is simple using HMIRuntime.Trace metod. For example in this way:

Public Function LogErr () 
' log current error using HMIRuntime.Trace 
Dim s 
        s = "" 
        If (Err.Number<>0) Then  
                s = "Error # " & CStr(Err.Number) & " " & Err.Description & " " & Err.Source & vbCrLf 
                HMIRuntime.Trace s 
                Err.Clear    ' Clear the error 
        End If 
        LogErr =End Function

But much more powerfull is using script debuging with Microsoft_Development_Environment. So you can use breakpoints, step-by-step code execution, inspect and modify variables, check call_stack and some more.

Details

Allow debuging

  • Check VBS debug options in WinCC Computer Properties Dialog.

Start Runtime

  • During runtime activation an 'Runtime error' Dialog box appear. Yes will start Microsoft_Development_Environment (MDE) for debugging instance 'GlobalScript Runtime'. But there are no any sources at this view, and for now I don't know how to use it. So we say No.

  • After activating Runtime the same Dialog appears again. But in this case Yes will start MDE for debugging instance 'PDLRT'. And that is the thing we need.

Working in Microsoft Development Environment

  • Say No for 'Open project' Dialog - we have'nt project.
  • Open Running_Documents Debug Window.

In this window listed sources for all currently visible pictures. They named like 'PdlName.pdl_Events'. If a picture is invisible - its source is'nt listed there, but will be automatically added when picture become visiblity. But, and it is very nice, even if source is hidden for now, editor still save breakpoints in it, so when picture will open, source already contains breakpoints, and we can debug picture OnOpen event. :)

Each source contain complite run-time code for each Picture, and combined from all code relative to Picture:

  • global modules called from local picture sources;
  • local picture event handlers and triggers.
This approach well described in WinCC documentation (at least 100 times:) Unfortunally approach to copy global modules into each picture causes that any data in global modules are not global over all runtime, but has isolated instance in each picture. So global modules can'nt hold global data, and how to implement this - is one of HowTo question.

  • Click over source name for open it.
  • Set any numbers of breakpoints you need.
  • Switch to Runtime and make action (or event) you want to debug.
  • Switch to MDE. Script execution now stopped at breakpoint.
  • You can perform standart debuging actions: step into, step over, run to cursor and so on.

  • Use Immediate Debug Window
When script run-time in step mode execution (after breakpoint) Immediate Window provide an single-line VBS interpretator in context (variables) of current function. So we can:
  • inspect variables and object properties,
  • modify variables with single-line VBS instructions.

Not a big deal, but much better than nothing :)

And one moment:

  • It is'nt good idea to stop script execution. This will totally break script runtime in WinCC session, and you will need to completly restart WinCC runtime for continue normal operation. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值