Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any example of using to TcCommand understand it? #15

Open
runtimevic opened this issue May 1, 2024 · 1 comment
Open

Is there any example of using to TcCommand understand it? #15

runtimevic opened this issue May 1, 2024 · 1 comment

Comments

@runtimevic
Copy link

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

@Joshpolansky
Copy link
Member

Joshpolansky commented May 6, 2024

Hi Victor! Thanks for your interest. These Tc Libraries are still in very early development, so things are changing fast and not yet documented.

The gist of this library is to make an easy interface so that every component can be interacted with like a PLCOpen function block.

At it's core it has a model like this:

MoveUp.Command := myComponent.command.moveup;
MoveUp.Execute := TRUE;
MoveUp();

Will ensure that the user has a consistent interface with => MoveUp.Busy, MoveUp.Done, MoveUp.Error, MoveUp.Aborted

The components implement the commands something like:

IF THIS^.command.moveup.consume THEN
    //Start executing the command
END_IF

IF commandIsComplete THEN
    THIS^.command.moveup.finished();
ELSIF commandIsError THEN
    THIS^.command.moveup.error(ErrorID);
END_IF

There is also a concept that is more OOP that looks like:

IF  startMove THEN
 startMove := FALSE;
 myComponent1.moveUp( position1, velocity, PlcopenStatus);
 myComponent2.moveUp( position2, velocity, PlcopenStatus);
END_IF

IF PlcOpenStatus.busy.. done.. error THEN

END_IF

The above method allows for method calls where the status is passed in and all the commands can be treated as a single command when checking the status. This still guarantees that the status follows the PLCOpen function block behavior.

There is a bit more complexity than this, but it give the general concept.

The Twincat version is based on our B&R ATN library but it does have more of an OOP vibe. You can find those docs here for more context:

https://loupeteam.github.io/LoupeDocs/libraries/atn/usage/commands.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants