×
Siemens Industry Online Support
Siemens AG
Entry type: Application example Entry ID: 8803993, Entry date: 10/15/2001
(0)
Rate

error diagnostics and testing of the connection between a VB application and WinLC

  • Entry
  • Associated product(s)

QUESTION:
How can I evaluate the error information that is generated in the case of connection faults to WinLC and how can I test the connection?

ANSWER:
If a connection from your VB program to WinLC could not be set up, you have the option of evaluating the error information that is returned and displaying it on the user interface.

Proceed as follows:

  1. Create a Visual Basic dialog.
  2. Insert the "S7 Data" control element into this dialog. If this control element is not available in your toolbox, right-click the toolbox and select "Components" in the menu that opens. In the ensuing dialog go to the "Controls" tab and click the check mark in front of "Siemens SIMATIC Data Control" and then click "Accept". Now the icon for the S7 Data Control appears in your toolbox.
  3. Insert control elements in your dialog which you can use to output error information. These can be "static texts" or "text boxes" for example.
  4. Program the "S7Data1_ConnectionError" function. This function is called by Visual Basic as soon as a connection error occurs. With static texts you use the "Caption" property to assign a parameter transferred by the function, for example with the instruction: "lblOutVariable.Caption = VarName".

To test an existing connection you can output or display WinLC process variables on your VB user interface.

Proceed as follows:

  1. Insert the relevant control elements into your dialog, e.g. text box and slider.
  2. Link each of these objects to a process variable. You do this via the S7 Data Control. Open the Properties dialog of the "S7 Data Control" with a right-click. In the "Connections" tab you will see a list of all the controls available in the dialog. Click the property of the object to which you want to assign a process variable and enter the process variable in the "Assigned Variable" field. Normally for the Slider Control you select the "Value" property, and the "Text" property for the text box. The value of the selected variable is then displayed by the object concerned during runtime of the program.

Important:
Generally you must make sure that you correctly preset the name of the Control Engine. For this you go to the Properties dialog of the S7 Data Control, select the "Engine" tab and in the "Control Engine" field you enter the string "WinAC\default".

The following dialog is used in the sample program provided below:

Connection_01.gif  

If an connection error occurs, the error information is output in the "Error Diagnosis" field.

The download contains the program described above. The project has been created with Microsoft Visual Basic V6.0 SP 4.

 con_nection.exe

Copy the "con_nection.exe" file into a separate directory and then start it with a double-click. The VB project unpacks automatically with all the associated files. You can then use Visual Basic to open and edit the unpacked project.

Keywords:
Connection diagnosis, Test routines

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.