Visual Components' Community

New Thinking for Factory Simulation
Welcome to Visual Components' Community Sign in | Help
in Search

Call different subroutines depending of a condition

Last post ti, loka 7 2008 10:04 by RicardoVelez. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • pe, loka 3 2008 13:06

    Call different subroutines depending of a condition

    There is no direct way to call a subroutine depending of a condition in a RSL program. This can however be done with a Python script.

    You need to get a trigger in the python script and then call RSL subroutine from the Python script.

    In this example the Python will get a Component Signal (which is transferring the actual component handle to the script) and then the script will call a subroutine in the RSL program which (in this example) has the same name as the component.

    Note also that preventing the RSL program to start with the simulation and running the Main sequence, you need to select the RSL behaviour and set it to action mode.

    ActionMode = True


    Here is the example of the Python script:

    def OnRun():

       comp = getComponent()
       rsl = comp.findBehaviour("RSL")

       while True:

         triggerCondition(lambda: getTrigger() == signal )
         name = signal.Value.Name

         rsl.callRoutine(name)

     

    Ricardo Velez
    Research and Development Manager
  • ti, loka 7 2008 8:13 In reply to

    Re: Call different subroutines depending of a condition

    We have to put the python script under the root node of the features right?Now, i know how to use the action mode. Thanks:)

    "ENGINEERING THE NEXT BREAKTHRU"
  • ti, loka 7 2008 10:04 In reply to

    Re: Call different subroutines depending of a condition

    It is recommended to put the Python script under the component root, although it will work the same wherever the script is. It is just easier to find it under the component root node.
    Ricardo Velez
    Research and Development Manager
Page 1 of 1 (3 items)