Skip to main content
InSource Solutions

How to use IO Scripting in System Platform

insource_logo_large.jpg                                    TECHNOTE

Description

 

Author

Mike Viteri

Publish Date 8/19/2013

Applies to Software

System Platform

Applies to Version

3.1

Applies to System/Module

Scripting

Article Version

 

Overview

This guide walks though the setup of IO Scripting in System Platform. The Demo Application is attached below under attachments.

Resolution

Introduction:

The benefit of this demo is to show how you can dynamically change your IO input with a script.

Requirements:

Application Server 2012

Intouch 2012

Simulate program

SQL Server 2008

Platform and Engine Deployed.

 

Import the Included Demo Objects.aaPKG file.

 

 

Creating UserDefined Object Template

  • User Defined Template called Tank is Created
  • In the Field Attributes Tab the following attributes are added they are set as:

 

Agitator – Discrete

Start – Discrete

ValveA – Discrete

ValveB – Discrete

Level-Analog

 

  • Make for sure under I/O box, there only three dashes in the box for each field attribute input source.
  • Once the Template is created Save it and Right Click on the Tank template and create a new instance called Tank_001. This will show in unassigned hosts in your galaxy

IO1.jpg

 

Creating a Script on the Tank template on the scripts tab.

 

Script Configuration:

Script Name: InitializeIO

Execute Type: Execute

Expression: me.SetIO == 0

Trigger Type: WhileTrue

Trigger Period: 00:00:02.0000000

 

 

IO2.jpg

 

Script:

Define Variables:

Dim sAttrName as string;

Dim sAttr as string;

Dim sDataSource as string;

Dim indX as indirect;

 

' sDataSource looks Like <IOClientName>.<ScanGroupName>.<ObjectName>.

sDataSource = myArea.IOClientName +"." + myArea.ScanGroupName + "." + me.Tagname + ".";

If (me.InitializeIO.ExecutionCnt >= 2) Then

For Each sAttr In Me._Attributes[]

    sAttrName = "";

    If StringInString( sAttr, ".Input.InputSource", StringLen( sAttr ) - 18, True ) Then

        sAttrName = StringLeft(sAttr, StringLen( sAttr ) - StringLen(".Input.InputSource"));

    ElseIf StringInString( sAttr, ".Output.OutputDest", StringLen( sAttr ) - 18, True ) Then

        sAttrName = StringLeft(sAttr, StringLen( sAttr ) - StringLen(".Output.OutputDest"));

    ElseIf StringInString( sAttr, ".InputSource", StringLen( sAttr ) - 12, True ) Then

        sAttrName = StringLeft(sAttr, StringLen( sAttr ) - StringLen(".InputSource"));

    ElseIf StringInString( sAttr, ".OutputDest", StringLen( sAttr ) - 11, True ) Then

        sAttrName = StringLeft(sAttr, StringLen( sAttr ) - StringLen(".OutputDest"));

    ElseIf StringInString( sAttr, ".Reference", StringLen( sAttr ) - 10, True ) Then

        sAttrName = StringLeft(sAttr, StringLen( sAttr ) - StringLen(".Reference"));

    ElseIf StringInString( sAttr, ".ReferenceSecondary", StringLen( sAttr ) - 20, True ) Then

        sAttrName = StringLeft(sAttr, StringLen( sAttr ) - StringLen(".ReferenceSecondary"));

    EndIf;

 

    If sAttrName <> "" Then

        ''this is an example of what the indX.BindTo will produce a reference to:

        ''FaultResetCmd.Input.InputSource

        indX.BindTo("Me." + sAttr);

        ''this line will assign an input source like:

        ''FaultResetCmd.Input.InputSource = <IOClientName>.<ScanGroupName>.<ObjectName>.<FieldAttrName>

        indX = sDataSource + sAttrName;

    EndIf;

Next;

me.SetIO = True;

Endif;

 

If me.Debug == 1 Then

    Logmessage ("*** Script SetIO Executed for Object " + me.Tagname + " ***");

Endif;

 

 

 

 

Creating Area Object

  • Create an Instance of an Area
  • In the UDAs Tab(see below)

Add string called “IOClientName”, in the box should be the name of your DDESuiteLink object in this example is called “SL”

Add another string called ScanGroupName, the box should have your topic name in this example it is called “PLC1”

 

IO3.jpg

 

Creating DDESUITELINK Object:

Crate an Instance of a DDE/Suitelink object and call it SL

 

To Simulate data for this Demo we are going to use the program Simulate(installed with Intouch).  To activate Simulate, type the word “Simulate” in your run command. Once the software has opened, select “configure” then topic definition.  In topic definition, add a topic name. This topic name will be used throughout the project.  For the example of the demo, the topic is “PLC1”

Step One:

In the “General” Tab in the DDESuiteLink Object

Server node: Type the node name or IP address where Simulate is located. In this example the Simluates located on PC we are using so we call it localhost.(You can also point to another PC on your network.)

Server Name:  Type the application name of the DDE or Suitelink server. In this example the application name is Simulate. (An Example of a real DAServer is DASABCIP)

 

IO4.jpg

 

In the “Topic” Tab

Add your topic name to the list using the blue (+) sign. For our demo, we use PLC1. This is the same name use in the simulate software

Add your tags name to the list for “Associated attributes for PLC1”

  • If you are using Simulate software, please add the tags showing in the screenshot.

The attribute column can be used to create the tagnames and Item reference column is the PLC address name. 

  • Under the Associated Attributes you will need to put your objectname.tagname so for this Demo we will have
  1. Tank_001.Agitator
  2. Tank_001.ValveA
  3. Tank_001.ValveB
  4. Tank_001.Start
  5. Tank_001.Level

 

IO5.jpg

 

Now put the Tank_001 under the AREA_001 and the SL Object under the engine. Then Deploy the Objects. Your Input will now automatically be built and if the simulate is started by using the start tag you should see data in your object viewer.

 

IO6.jpg