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

Adding a prg to a task via python script
https://forum.codesys.com/viewtopic.php?f=18&t=7219
Page 1 of 1

Author:  DBaur [ Mon Sep 19, 2016 8:00 am ]
Post subject:  Adding a prg to a task via python script

Hi support team,

is it possible to add a POU (e.g. prg_myCalls) call via python script to a dadicated task "task03" within the task configuration?

Thanks in advance.
_

Author:  M.Keller [ Mon Sep 19, 2016 9:50 am ]
Post subject:  Re: Adding a prg to a task via python script

Hi DBaur.

DBaur wrote:
Hi support team,

is it possible to add a POU (e.g. prg_myCalls) call via python script to a dadicated task "task03" within the task configuration?

Thanks in advance.
_

There is no Scripting API for creating and manipulating the task configuration at the moment, but it is already listed in our Jira tracker CDS-34234. It is requested for CODESYS V3.5 SP10 so maybe it will be released with the SP10 release.

If you really need it now, you could export the task configuration with PLCopenXML, change the configuration in the XML and import it.

BR
Martin

Author:  PLKM [ Thu May 04, 2017 7:39 am ]
Post subject:  Re: Adding a prg to a task via python script

M.Keller wrote:
Hi DBaur.

DBaur wrote:
Hi support team,

is it possible to add a POU (e.g. prg_myCalls) call via python script to a dadicated task "task03" within the task configuration?

Thanks in advance.
_

There is no Scripting API for creating and manipulating the task configuration at the moment, but it is already listed in our Jira tracker CDS-34234. It is requested for CODESYS V3.5 SP10 so maybe it will be released with the SP10 release.

If you really need it now, you could export the task configuration with PLCopenXML, change the configuration in the XML and import it.

BR
Martin


In the JIRA ticket the resolution is fixed for SP 10, but i can't find anything in the online help. Could you provide me an example for adding and manipulating tasks ?

Author:  M.Keller [ Thu May 04, 2017 10:05 am ]
Post subject:  Re: Adding a prg to a task via python script

Hi PLKM.

PLKM wrote:
In the JIRA ticket the resolution is fixed for SP 10, but i can't find anything in the online help. Could you provide me an example for adding and manipulating tasks ?

It seems the Scripting API documentation was not updated.

I attached an example which prints the tasks of the application "Application" and create a set of task below the application "App" which has no task configuration. See screenshot.

BR
Martin

Author:  PLKM [ Tue May 30, 2017 12:56 pm ]
Post subject:  Re: Adding a prg to a task via python script

M.Keller wrote:
Hi PLKM.

PLKM wrote:
In the JIRA ticket the resolution is fixed for SP 10, but i can't find anything in the online help. Could you provide me an example for adding and manipulating tasks ?

It seems the Scripting API documentation was not updated.

I attached an example which prints the tasks of the application "Application" and create a set of task below the application "App" which has no task configuration. See screenshot.

BR
Martin


Hi Martin,

thank you for the example. But the part of adding/getting POUs within the tasks is missing. Could you provide the method ?

Author:  M.Keller [ Tue Jun 06, 2017 1:29 pm ]
Post subject:  Re: Adding a prg to a task via python script

Hi PLKM.

PLKM wrote:
But the part of adding/getting POUs within the tasks is missing. Could you provide the method ?

Code:
def printTaskPOUs(pous):
   if pous and len(pous) > 0:
      for pou in pous:
         print("POU: " + pou)
   else:
      print("No POUs")

Code:
print("Add to two POUs ...")
task.pous.add("MyPRG")
task.pous.add("MyPRG2")
printTaskPOUs(task.pous)

print("Insert POU 'PLC_PRG' at the top ...")
task.pous.insert(0, "PLC_PRG")
printTaskPOUs(task.pous)

BR
Martin

Author:  aritra666 [ Mon Sep 17, 2018 9:05 am ]
Post subject:  Re: Adding a prg to a task via python script

M.Keller wrote:
Hi PLKM.

PLKM wrote:
In the JIRA ticket the resolution is fixed for SP 10, but i can't find anything in the online help. Could you provide me an example for adding and manipulating tasks ?

It seems the Scripting API documentation was not updated.

I attached an example which prints the tasks of the application "Application" and create a set of task below the application "App" which has no task configuration. See screenshot.

BR
Martin



The given code is not running... It shows the following error:

'ScriptObject' object has no attribute 'create_task_configuration'

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