CODESYS comes with built-in support for Ironpython
The Ironpython scripts are running inside of the CODESYS IDE, and can be used to automate huge parts of the system. That virtually everything within CODESYS can be automated this way, and that CODESYS can even be started headless, running a python script, makes the system really mighty.
There are many use cases you can think of:
See also CODESYS Help
By default CODESYS doesn't provide you an integrated script editor for Python.
However there is a commercial AddOn available in the CODESYS Store, from 3S - Systems, which integrates well into CODESYS and assists you in writing your CODESYS Python scripts:
If you prefer free alternatives, there are plenty of alternatives available out there. Just to name a few:
Select the "Visual Studio IDE Community" version, install Iron Python support via the installation process
TIP: you can opt to install notepad++ and PyCharm or Visual Studio in tandem as they complement each other well
Visual Studio Code or VS.Net can be an alternative, however, the CFORGE tool is developed using VS.NET, so your mileage may vary.
The output of the script will be written to the message pane.
Instead of manually selecting the script to execute in the IDE, you can also start CODESYS and let it execute a script without the user interface:
Example:
"C:\Program Files (x86)\CODESYS 3.5.16.0\CODESYS\Common\CODESYS.exe" --noUI --profile='CODESYS V3.5 SP16' --runscript='svn-checkout.py'
With --noUI, CODESYS starts without the IDE and the output of the script is forwarded directly to the terminal:
d:\tmp> "C:\Program Files (x86)\CODESYS 3.5.16.0\CODESYS\Common\CODESYS.exe" --noUI --profile='CODESYS V3.5 SP16' --runscript='svn-checkout.py' SVN: Information: [12:16:45] ---------- Scripted SVN Operation ---------- SVN: Information: [12:16:45] UpdateStarted <> SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Camera device SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Camera device\[0] SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\I2C SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Onewire SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Library Manager SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\PLC_PRG SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Task Configuration SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Task Configuration\Main SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Trace SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Trace_Axis SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Visualization SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Visualization Manager SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\Plc Logic\Application\Visualization_1 SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\SPI SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\SoftMotion General Axis Pool SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\SoftMotion General Axis Pool\SM_Drive_RaspiStepper SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\SoftMotion General Axis Pool\SM_Drive_RaspiStepper_1 SVN: Information: [12:16:47] Added CODESYS_Control_for_Raspberry_Pi\[4] SVN: Information: [12:16:47] Added GlobalTextList SVN: Information: [12:16:47] Added Library Manager SVN: Information: [12:16:47] Added Project Settings SVN: Information: [12:16:47] Added Visualization SVN: Information: [12:16:47] Added meta.profile SVN: Information: [12:16:47] Completed at revision: 24 SVN: Information: [12:16:47] Added: 26 SVN: Information: [12:16:48] ---------- Scripted SVN Operation ----------
As of CODESYS version 3.5.14.0, https://help.codesys.com/webapp/idx-scriptingengine;product=ScriptEngine;version=3.5.14.0 offers an exthaustive overview of the various available scripting objects and their possibilities.
cforge heavily uses the scripting API to automate some workflows for developers.