loupeteam / TcSequencer

A sequencing system for Beckhoff.
MIT License
5 stars 0 forks source link

Is there any example of using to TcSequencer understand it? #9

Open runtimevic opened 5 months ago

runtimevic commented 5 months ago

Hello, Is there any example of using to TcSequencer understand it? thanks Víctor.

Joshpolansky commented 4 months ago

Hi Victor! Similar to the Commando library, these Tc Libraries are still in very early development, so things are changing fast and not yet documented.

This library is an extension of the TcCommando concept but has two extensions.

The concept is that you have a sequence object that has a similar (ideal the same) interface as a Command from commando. The difference is that instead of just a bool (checked with consume) it has a state machine with a nice api.

//Calling the sequence
MoveUp.Command := myComponent.command.moveup;
MoveUp.Execute := TRUE;
MoveUp();
//moveup gets implemented as a state machine
CASE moveup.doStep() OF
   0: 
       IF moveup.onEntry()  THEN
          //Start an action          
          axis1.move(moveup); //<-Start move on axis 1 and 2 with the same sequence as the status object
          axis2.move(moveup); 
       END_IF

       IF moveup.onsuccess( nextstep ) THEN <-- when the moves are complete go to nextstep
           //Optional code to run on success
       END_IF

       IF moveup.onerror( errorstep ) THEN
           //Optional code to run when leaving the step
       END_IF

       IF moveup.onexit( ) THEN
           //Optional code to run when leaving the step
       END_IF

    nextstep: 
       //When we are done tell the sequencer
       moveup.sequenceComplete(); -> status.done

   errorstep
       //If there was an error report it
       moveup.sequenceError(); -> status.busy

END_IF

This library also supports integration with TcPiper which is our distributed packML state machine. If it is integrated with Piper, then piper acts as the step manager to coordinate the steps in the sequence as substate.

You can find more information about piper here:

https://loupeteam.github.io/LoupeDocs/libraries/piper.html https://loupeteam.github.io/LoupeDocs/styleguide/projectstructure/piperguide.html

We have TcPiper in development too, which very similar to our B&R implementation of Piper, but with a more OOP design,