Python code is now called natively from Symplify scripts

Symplify scripts adds native support for Python

Starting with Symplify 3.8, the script engine now supports native Python calls. This means operations that are currently not available in our script engine can be performed with the world’s most popular scripting language without any extra development. Complex string operations, advanced signal processing or any communication with web services or MRP can be added to your ATS at run-time without requiring the application to be recompiled.

Previously, any function not supported by the script engine had to be integrated directly into the LabVIEW code and interface with through Tags. This process was very simple and flexible during the initial development but we listened to our clients expressing that it was harder for their software engineer to quickly add measurements or publishing results with the evolution of the prototypes.

The way the new function work is simple, as can be seen in the example below. Any code between <Python> and </Python> is written to a new file on disk and passed as an argument to the Python interpreter (executable through command line.) Python can then read and write any Tags in the Symplify application.

The example below shows what the integration of Python into Symplify script engine look like:

Exported from Notepad++
'--------------- '[--- Other code before this ---] 'Monitor Charging '--------------------------------------- RESET TIMER VARIABLES ------------------------------------------ 'Reset Timeout Status Variable Timeout_Status_Var = 0 'Reset Elapsed Time variable ElapsedTime_Var = 0 'Set Timeout Timeout_Var = 240 'Set Start_Time_Var to System Relative Current Time Start_Time_Var = _SYS_Relative_Current_Time_ '-------------------------------------------------------------------------------------------------------- end if <Python> # Below script will # - Connect to SYN TCP server # - Read Tag1 value # - Increment value by 1 # - Write updated value to Tag1 # - Repeat above steps by x times # - Disconnect SYN TCP server from SymplifyRemoteInterface import * from time import * SY = SymplifyRemoteInterface() SY.connect('127.0.0.1', 16701) if SY.connect('127.0.0.1', 16701): response = SY.W('Tag1', 0) print(response) StartTime = time() print(StartTime) for i in range(1000): response = SY.R('Tag1') response = SY.W('Tag1', float(response) + 1) print(response) # response = SY.set_str_tag('TagZ', 'hello') # print(response) # print(SY.get_str_tag('TagA')) SY.SysLogMsg('Test message ...') FinishTime = time() print(FinishTime) print(FinishTime-StartTime) # Below is an example of exception handling with reporting to Symplify over TCP. try: file = open('testfile.txt', 'r') print(file.read()) except IOError: SY.SysLogMsg('Python IOError - Attempted to read a file that does not exist...') SY.disconnect() </Python> '---------------------------------- INITIAL LOW CURRENT CHARGE ------------------------------------------ If (Timeout_Var == 0) Concatenate_Tags (Example_Tag, "Just a String on line 44.") 'Add to system log SysLog(Example_Tag) Sleep(0.1) Example_DBL_Tag = 0 Do While Example_DBL_Tag < 15 Example_DBL_Tag = Example_DBL_Tag + 1 Sleep(1) Loop End If '[--- More code after this ---]

Try Symplify for your ATS application today

Synovus Resources

Fill the form below to access all our resources. We won't ask you again later.
  • By submitting this form you allow us to send you monthly updates on our services and news.