Hi Support COdesys,
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 :
{"name 'projects' is not defined"}
script on python:ReadVariable.py
from __future__ import print_function; import # close open project if necessary: if projects.primary: projects.primary.close() # opens project proj = projects.open(r"C:\Testing Integration\Untitled1.project") # set "Ampel.project" to active application app = proj.active_application onlineapp = online.create_online_application(app) # login to device onlineapp.login(OnlineChangeOption.Try, True) # set status of application to "run", if not in "run" if not onlineapp.application_state == ApplicationState.run: onlineapp.start() # wait 1 second system.delay(1000) def TagsCall(*Tags): value1 = onlineapp.read_value(Tags[0]) value2 = onlineapp.read_value(Tags[1]) value3 = onlineapp.read_value(Tags[2]) TagsCall("POU.GVL.v1Real","POU.GVL.v2Real","POU.GVL.v3Real") # log out from device and close "Ampel.project" onlineapp.logout() proj.close()
script on Visual Studio 2015 :
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using IronPython.Hosting; using Microsoft.Scripting.Hosting; using IronPython.Modules; using IronPython.Runtime; using IronPython.Compiler; using IronPython.Zlib; using IronPython.SQLite; namespace Codesys_Adapter { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { var ipy = Python.CreateRuntime(); dynamic test = ipy.UseFile(@"..\\..\ReadVariable.py"); test.start_element(); Console.ReadLine(); } } }
can you help me to suggestion best practice or step by step document to integrated to Visual Studio 2015.
regards
Adam
Can you please repost this question in the forum?
https://forge.codesys.com/forge/talk/