Developer Portal Community

    Showing results for 
    Search instead for 
    Did you mean: 

    Pause chain or object execution

    Pause chain or object execution

    Long-established Member

    In current project there is a safety light grid controlling valve terminal ouputs voltage. One part of the machine is loading mechanism, which runs all the time and loads components when it is necessary. During this operation about 6 mechanical movements are executed in one sequence.

    During the cycle, operator puts some parts into the machine and iterrupts signal from safety light grid which producess error mesages from BasMove objects because of missing air pressure at valve terminal.

    I would like to suppress these messages when the light grid is interrupted, but I do not how to do that correctly. Is it possible to pause chain or object execution when the grid inactive?

    2 REPLIES 2

    Community Moderator
    Community Moderator

    You can pause a chain with _env.ChainControl:=OpconChainControl.PAUSE (and implement OnChainPause with return value OK to continue chain).

    But once an object command is started, it cannot be paused. Therefore the chain pause doesn't help you.

    The only solution that comes into my mind: if the light grid is interrupted, the BasMoves must be canceled (e.g. implement the method CmdHandlerUnit._manageLightGrid). I would suggest to use BasMove.Unit.Execute:=FALSE to cancel only the BasMoves that are already running. BasMove.Unit.Cancel:=TRUE would cancel also the ones that are currently not running.

    Very important is the waiting step in your chains: You cannot use the default implemention with CheckUnitDone or ExecuteUnit. You must explicitly check for ExecState=CANCEL (or ExecState=READY which will be reached after cancel) and then jump back to the start step (or just set Execute again to repeat the command).

    When repeating the command, you could get a PreStartCheck error if the cylinder is not in a defined end position. You can prevent this error with one of these settings:

    • Set ParCmd.PreStartCheck:=FALSE (like in homing chain). With this setting the command is started even if the cylinder is not in a defined position.
      You should set PreStartCheck:=FALSE only in case of homing or repeating a command, not during normal operation.
      PS: In case of a timeout error PreStartCheck is automatically ignored by the BasMove object when the next command is executed. But in your case you won't get a timeout error. For any other repeating commands like in your case you must handle PreStartCheck manually.
    • Set CpStudio parameter ResetOutputOnCancel to NO. With this setting the output stays TRUE. After releasing the light grid the output is still set and the cylinder will continue its movement (also the command is not running anymore).
      Depending on the valve type (deaerated or locked air), the cylinder size/force and the station dimension (can someone go into the station?), setting ResetOutputOnCancel to NO is not a good recommendation due to safety risks.

    Long-established Member

    Steffen, thank you for sharing your ideas 👍! I will try to implement it and later I will post there some result or example.