CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

Python script for stopping a running online application
https://forum.codesys.com/viewtopic.php?f=18&t=9914
Page 1 of 1

Author:  Halim [ Thu Aug 01, 2019 12:16 pm ]
Post subject:  Python script for stopping a running online application

Hi.

I could manage to write a script that creates an online application, log-in, and start the PLC as shown in the below function code.
def plc_start():
onlineapp = online.create_online_application(None)
onlineapp.login(0,True)
plc_login()
onlineapp.start()
print("started")

To stop the plc while staying logged in, I need to use the <onlineapp>.stop(). The problem is that I'm not able to keep the declaration of the <onlineapp> to a next run of the script. So, I want to "ask the scriptEngine what online application is existing now"? How could I program for this question knowing that there is nothing as <active_online_application> in the scriptEngine help?

BR,
Halim

Author:  M.Keller [ Tue Aug 06, 2019 7:40 am ]
Post subject:  Re: Python script for stopping a running online application

Hi Halim.

Halim wrote:
To stop the plc while staying logged in, I need to use the <onlineapp>.stop(). The problem is that I'm not able to keep the declaration of the <onlineapp> to a next run of the script. So, I want to "ask the scriptEngine what online application is existing now"? How could I program for this question knowing that there is nothing as <active_online_application> in the scriptEngine help?

ScriptEngine has no need to remember which online application exists because it is not necessary. Just create a new online application and check if it is logged in. If not, login and stop the running app.

BR
Martin

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/