Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Adding a prg to a task via python script

DBaur
2016-09-19
2018-09-17
  • DBaur - 2016-09-19

    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.
    _

     
  • mkeller - 2016-09-19

    Hi DBaur.

    DBaur hat geschrieben:
    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.
    _

    CDS-34234

    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

     
  • PLKM - 2017-05-04

    M.Keller hat geschrieben:
    Hi DBaur.
    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 ?

     
  • mkeller - 2017-05-04

    Hi PLKM.

    PLKM hat geschrieben:
    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

    IMG: Scripting_TaskConfig_Example.PNG

    taskconfig example.py [2.44 KiB]

     
  • PLKM - 2017-05-30

    M.Keller hat geschrieben:
    Hi PLKM.
    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 ?

     
  • mkeller - 2017-06-06

    Hi PLKM.

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

    def printTaskPOUs(pous):
       if pous and len(pous) > 0:
          for pou in pous:
             print("POU: " + pou)
       else:
          print("No POUs")
    
    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

     
  • aritra666 - 2018-09-17

    M.Keller hat geschrieben:
    Hi PLKM.
    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'

     

Log in to post a comment.