currently i have trying to collecting value from global variable from codesys.
1st time i have tried create script python to reading value and execute from codesys, result is value able to read.
2nd time i have tried create 1 application from C#.Net visual studio 2015, have error coming, error is like on below :
script on python:ReadVariable.py
from future import print_function;
proj = projects.open(r"C:\Testing Integration\Untitled1.project")
app = proj.active_application
onlineapp = online.create_online_application(app)
if not onlineapp.application_state == ApplicationState.run:
value1 = onlineapp.read_value(Tags)
value2 = onlineapp.read_value(Tags)
value3 = onlineapp.read_value(Tags)
script on Visual Studio 2015 :
static class Program
The python script you created will only work inside the CODESYS IDE or any other software which is based on the CODESYS Automation Platform because the modules used for accessing the IDE and the PLC are only available there.
What is your use case for running the python script inside your own C# application?
yes, i just calling the py script from C#.Net.
As I said before you can use our Scripting API only inside the CODESYS IDE or any other software which is based on the CODESYS Automation Platform.
So again, what is your use case for running the python script inside your own C# application?
PLC handler would be the default works with all CODESYS communication API. Details at Link
OPC UA is available in many runtimes, so I would find a C# OPC UA client if your controller supports this. Eg Link 2
Also, you can use one of the fieldbusses that your controller supports, and find a corresponding library for C#.
Alternatively, there are some communication libraries that may be appropriate for your use cases. Net Based Services library can send some TCP or UDP packets, you can also purchase the MQTT library for CODESYS for a more IIoT approach, and find an MQTT library for C#, and find an MQTT broker.
My answer is quite generic, but if you answer Martin, you may get a more tailored response from him.
Log in to post a comment.