How to multi-threading on ScriptWorX2006/2010

You can use multi-thread on ScriptWorX 2006 or 2010 to run each script. This article will show the example to writing value to OPC tags separately by using each designer and script.

Keys

– Create each designer for each script. This will make all script free from each other as multi-threading.

– Use trigger to control each script.

 

Create script

Open ScriptWorX 2006 from Start > Programs > ICONICS GENESIS32 > ScriptWorX32 > ScriptWorX 2006 or 2010. In this example, I add new designer “opcwrite1” into existing project. You can also creating new project. And create new script “opcwrite” into designer. As figure below, I use trigger “Every Sec” to control script. You can browse or create a new trigger as well.

image

 

Click Apply and  Edit VBA Code.

In VBA editor, select Tool > Reference. Then choose GenClientWrapper using for read/write OPC tag.

image

click OK.

At sub opcwrite, enter script to send random value to OPC tags FLOAT1, FLOAT2, FLOAT3, FLOAT4 by for loop as shown. Those opc tags are in ICONICS OPC Simulator.

 image

 

Now get back to create new Designer on ScriptWorX2006 / 2010 again for another thread.

Right-click on project, select  New > Designer/Thread.

 

image

 

Name new designer as  opcwrite2. then Apply.

 

image

 

Create new  Script “opcwrite2” into new designer.  Then apply same trigger. Click Apply and Edit VBA code.

image

 

Writing code to send random values to more opc tags, FLOAT5 toFLOAT8.

 

image

 

Save and get back to configuration.

Start runtime. 

 

image

 

Monitor all opc tags using GraphWorX or OPC DataSpy.

 

image

 

By this way, ScriptWorX will working in Multi-Thread.

Advertisements
This entry was posted in Tips. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s