WINCC VBS调试,诊断功能,ADO

来源:互联网 发布:简品花果茶淘宝 编辑:程序博客网 时间:2024/06/03 18:31

Introduction

One way to debug VBScript run-time is simple usingHMIRuntime.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 withMicrosoft_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 startMicrosoft_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 startMDE for debugging instance 'PDLRT'. And that is the thing we need.

Working inMicrosoft 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 tocopy 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 ofHowTo 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. 
原创粉丝点击