CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Oct 19, 2018 4:54 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Dec 03, 2015 2:14 pm 
Offline

Joined: Fri Nov 06, 2015 12:10 pm
Posts: 34
How can I set values for testing with a Test Manager Python script?
See the screen copy below this question.

The next software is used: Codesys V3.5 SP7 Patch 2 and Test Manager 4.0.1.1.


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Dec 04, 2015 9:23 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 232
Hi Bakkertje.

Quote:
How can I set values for testing with a Test Manager Python script?

What do you mean?

If you want to set the value of a script variable you use an ASSIGNMENT. You can use it again if you want to change the value. For example, you want to call the same test script but with different values.

If you want to set the value of an IEC variable on the PLC, you have to use one of the commands from TestManager.Monitoring or use the Scripting API in a test action with the command ExecuteScript from TestManager.Scripting.

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Fri Dec 04, 2015 10:02 am 
Offline

Joined: Fri Nov 06, 2015 12:10 pm
Posts: 34
Hi Martin,

Thanks for your reply.
With the "CompareVariableList" I can compare more variables in one time. That gives a good overview.
And with the "WriteVariable" I can set one variable value. Is there a way to set more variable values with one command?


Top
   
PostPosted: Fri Dec 04, 2015 10:15 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 232
Hi Bakkertje.

Bakkertje wrote:
And with the "WriteVariable" I can set one variable value. Is there a way to set more variable values with one command?


You can use the Scripting API to prepare your values and send them to the PLC together. For example:
Code:
onlineApp = online.create_online_application()

onlineApp.set_prepared_value("PLC_PRG.iVal1", iSetValue1)
onlineApp.set_prepared_value("PLC_PRG.iVal2", iSetValue2)

globalVars = executionContext.GlobalVariables
onlineApp.set_prepared_value("PLC_PRG.iVal2", globalVars["g_var1"])

onlineApp.write_prepared_values()

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Fri Dec 04, 2015 12:29 pm 
Offline

Joined: Fri Nov 06, 2015 12:10 pm
Posts: 34
Hi Martin,

Thanks, this is useful.
I only have to convert the value to s string type with str() and it works.

Code:
onlineApp.set_prepared_value("PLC_PRG.iVal1", str(iSetValue1))


Top
   
PostPosted: Fri Dec 04, 2015 1:36 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 232
Hi Bakkertje,

you are absolutely right. I forgot to look at the API documentation. If you can't be sure that all the variables contain only strings the "str()" is necessary.

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited