If it is possible to run CodeSys Script Language in Python 2.7,3.3 and IronPython IDLE/Console? If yes, how to get started?
For example what is a correct function, (correct me if I am wrong), need to import?
For the CODESYS Script Language, the IronPython interpreter is embedded within the CODESYS process and the "Automation Platform" framework. The CODESYS specific functions are directly provided by the host, and there is no separate module you can import from an external python interpreter.
It is certainly doable to start CODESYS from IronPython - you would need to initialize the Automation Platform and CODESYS from within the script, and then use the ScriptEngine to execute code. If your company bought the "Automation Platform" license, can download the brandabelling sample
from the Developer Network - the C# code there illustrates how to get CODESYS running.
For a normal CPython script (whether 2.7 or 3.3), you would first need to start up a .NET Framework via the .NET Hosting API (probably using cTypes or COM), then start the Automation Platform and CODESYS within the .NET Framework, and then use the ScriptEngine to get a Script Scope. As an additional hurdle, the IronPython and CPython script scopes are very different beasts, you would need to use COM
or Python for .NET
to interact with the IronPython and .NET objects.
Whether all that is worth the hassle is another question.
Maybe you can get a similar experience using another approach: You could try to use Python Remoting (or some other RPC implementation of your choice). In CODESYS, you start a remote server, and then you connect there via the "normal" python script. I did not test this myself, but it may work for you.
I wish to write a value into a FBD instance via RAMPHANDLE(is a Output) via Python script continuously,I thought the command should be...
rDCInput = input variable from a FBD
But, I have no idea where to accommodate the RAMPHANDLE via a CodeSys scripting command.
I'm not exactly sure what you want to accomplish there.
writes the value once, and you need a second parameter with the actual value. You can of course read the RAMPHANDLE variable via monitoring, and write the value back in a loop, but you should be aware that each read/write cycle has the overhead of monitoring cycle time (usually 200ms) and network latency, so this may not really work for you, depending on your task cycle time and fieldbus reliability.
If your test needs reliable timing, you should instrument your application or FB via IEC code which handles the test logic, and then execute it (maybe using the IEC Unit Test functionality of the test manager).
Check out the CODESYS store: http://store.codesys.com/CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions