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

Feature/rc1 #10

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sequencer/Sequencer/TcSequencer.tsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4024.53">
<Project ProjectGUID="{F6F7C937-218D-4551-B982-43F369B598A4}" Target64Bit="true" ShowHideConfigurations="#x3c7">
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4024.55">
<Project ProjectGUID="{F6F7C937-218D-4551-B982-43F369B598A4}" TargetNetId="1.0.0.209.1.1" Target64Bit="true" ShowHideConfigurations="#x3c7">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to remove this NetID?

<System>
<Settings MaxCpus="20" NonWinCpus="2"/>
<Tasks>
Expand Down
12 changes: 12 additions & 0 deletions Sequencer/Sequencer/TcSequencer/DUTs/SequenceCommand.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="SequenceCommand" Id="{5f5128e9-4988-0cd7-37c1-c51312994c6b}">
<Declaration><![CDATA[TYPE SequenceCommand :
STRUCT
Start : PLCopenCommand;
Stop : PLCopenCommand;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
3 changes: 0 additions & 3 deletions Sequencer/Sequencer/TcSequencer/DUTs/SequenceType.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
isAbort : BOOL;
isError : BOOL;

stepHandler : IStepManager;
activeTasks : PLCopenCallGroup;

errorHandled : BOOL;

END_STRUCT
Expand Down
22 changes: 22 additions & 0 deletions Sequencer/Sequencer/TcSequencer/Example/ExampleProg1.TcPOU
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="ExampleProg1" Id="{ef79d040-ac9a-075e-0ecb-cf80cda435b7}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM ExampleProg1
VAR

Cylinder1 : Mock_EM := (TimeUp:= T#3S, TimeDown:= T#3S);
Cylinder2 : Mock_EM := (TimeUp:= T#1S, TimeDown:= T#1S);
Cylinder3 : Mock_EM := (TimeUp:= T#8S, TimeDown:= T#1S);
Seq1 : ExampleSeq1(0) := (em1:=Cylinder1, em2:=Cylinder2, em3:=Cylinder3);
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Cylinder1();
Cylinder2();
Cylinder3();

Seq1();
]]></ST>
</Implementation>
</POU>
</TcPlcObject>
56 changes: 56 additions & 0 deletions Sequencer/Sequencer/TcSequencer/Example/ExampleSeq1.TcPOU
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="ExampleSeq1" Id="{0b7420e2-7bee-0073-13f1-581e54ae5023}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK ExampleSeq1 EXTENDS Sequencer
VAR_INPUT
em1 : IMOCK_EM;
em2 : IMOCK_EM;
em3 : IMOCK_EM;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[CASE DoStep() OF

0:
IF OnEntry() THEN
RequestStep( 1 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we see if STweep will standardize spaces around parameters automatically? This is inconsistent.

END_IF

1:
IF OnEntry() THEN
em1.MoveDown(THIS^);
END_IF

OnSuccess(2);
2:

IF OnEntry() THEN
em1.MoveUp(THIS^);
em2.MoveUp(THIS^);
em3.MoveUp(THIS^);
END_IF

OnSuccess(3);

3:

IF OnEntry() THEN
em1.MoveDown(THIS^);
em2.MoveDown(THIS^);
em3.MoveUp(THIS^);
END_IF


IF OnSuccess(-1) THEN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment to explain the significance of -1 would be helpful. Otherwise it may be interpreted as an error state.

In fact, could we make an ENUM for these? OnSuccess(SEQ_COMPLETE), for example?


SequenceComplete();

END_IF

END_CASE

IF OnError(-1) THEN
SequenceError(-1, 'General error');
END_IF]]></ST>
</Implementation>
</POU>
</TcPlcObject>
23 changes: 23 additions & 0 deletions Sequencer/Sequencer/TcSequencer/Example/IMOCK_EM.TcIO
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<Itf Name="IMOCK_EM" Id="{ef49eb67-0dd3-08ee-1676-40a85245db25}">
<Declaration><![CDATA[INTERFACE IMOCK_EM
]]></Declaration>
<Method Name="MoveDown" Id="{c1097bb8-4cd7-0965-2bad-c28e059eadf2}">
<Declaration><![CDATA[
METHOD MoveDown : BOOL
VAR_INPUT
Status : IPLCopenCall;
END_VAR
]]></Declaration>
</Method>
<Method Name="MoveUp" Id="{b592d131-cbee-0403-212c-bb26ab20fc93}">
<Declaration><![CDATA[
METHOD MoveUp : BOOL
VAR_INPUT
Status : IPLCopenCall;
END_VAR
]]></Declaration>
</Method>
</Itf>
</TcPlcObject>
86 changes: 86 additions & 0 deletions Sequencer/Sequencer/TcSequencer/Example/Mock_EM.TcPOU
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="Mock_EM" Id="{2fbe5d7f-06dd-041a-2d03-5fb4cef27abb}" SpecialFunc="None">
<Declaration><![CDATA[
FUNCTION_BLOCK Mock_EM IMPLEMENTS IMOCK_EM
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the only place where _'s are used in the name. Is there significance to IMOCK being all-caps?

VAR_INPUT
TimeUp : TIME;
TimeDown : TIME;
END_VAR
VAR
_MoveUp : PLCopenCommand;
_MoveDown : PLCopenCommand;
_HeightGroup : PLCopenExclusiveGroup := (commands := [_MoveUp, _MoveDown, 18(0)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the significance of 18(0) here? I'm surprised to see that as valid syntax, but perhaps I'm missing something.

t : TON;
Up : BOOL;
Down : BOOL;
Up_ : BOOL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the distinction between Up_ and Up? This could be confusing to new users in the example without a comment.

END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[
IF _MoveDown.Consume THEN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being a user-facing example, this code could benefit from a few brief comments.


t(IN := FALSE);
t(IN := TRUE, PT := TimeDown);
Up_ := FALSE;
Up := FALSE;
Down := FALSE;

END_IF

IF _MoveUp.Consume THEN

t(IN := FALSE);
t(IN := TRUE, PT := TimeUp);
Up_ := TRUE;
Up := FALSE;
Down := FALSE;

END_IF

t();

IF t.Q THEN

t(IN := FALSE);

IF Up_ THEN
Up := TRUE;
_MoveUp.Finished();
ELSE
Down := TRUE;
_MoveDown.Finished();
END_IF

END_IF
]]></ST>
</Implementation>
<Method Name="MoveDown" Id="{85d33885-fdbf-0e70-0029-961e4e4e3914}">
<Declaration><![CDATA[
METHOD MoveDown : BOOL
VAR_INPUT
Status : IPLCopenCall;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[
Status.Start(_MoveDown);
]]></ST>
</Implementation>
</Method>
<Method Name="MoveUp" Id="{e89b83fa-e799-0cf1-2121-19445f61c4de}">
<Declaration><![CDATA[
METHOD MoveUp : BOOL
VAR_INPUT
Status : IPLCopenCall;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[
Status.Start(_MoveUp);
]]></ST>
</Implementation>
</Method>
</POU>
</TcPlcObject>
10 changes: 9 additions & 1 deletion Sequencer/Sequencer/TcSequencer/Interfaces/ISequence.TcIO
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,22 @@ END_VAR
<Method Name="SequenceError" Id="{efd40ff7-83f9-47af-a16c-c4732fe53c27}" FolderPath="StateControl\">
<Declaration><![CDATA[METHOD SequenceError : BOOL
VAR_INPUT
ErrorCode : DINT;
ErrorCode : INT;
ErrorMessage : STRING;
END_VAR
]]></Declaration>
</Method>
<Method Name="SetStepManager" Id="{5efbbda1-bc0e-472d-a818-288d5222df56}">
<Declaration><![CDATA[METHOD SetStepManager : BOOL
VAR_INPUT
manager : IStepManager;
END_VAR
]]></Declaration>
</Method>
<Method Name="StartSequence" Id="{1cd7451d-fc48-48da-b2a6-3f2d996e06ee}">
<Declaration><![CDATA[METHOD StartSequence : BOOL
VAR_INPUT
Status : IPLCopenCaller;
END_VAR
]]></Declaration>
</Method>
Expand Down
42 changes: 22 additions & 20 deletions Sequencer/Sequencer/TcSequencer/Interfaces/IStepManager.TcIO
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,44 @@
<Itf Name="IStepManager" Id="{89c191eb-450f-4144-a19d-873d9f6fc237}">
<Declaration><![CDATA[INTERFACE IStepManager
// Copyright (c) 2024 Loupe (https://loupe.team), provided under the MIT License.]]></Declaration>
<Method Name="_RequestStep" Id="{484e6cd7-60ba-4268-b695-64585da66145}">
<Declaration><![CDATA[METHOD _RequestStep : BOOL
<Property Name="CurrentStepImpl" Id="{f549aba3-dc6c-45db-ae21-2b43a54633f2}">
<Declaration><![CDATA[PROPERTY CurrentStepImpl : ENUM]]></Declaration>
<Get Name="Get" Id="{e53bfbc9-86ad-48ac-b648-09cfbdc36fb7}">
<Declaration><![CDATA[]]></Declaration>
</Get>
</Property>
<Property Name="RequestNumberImpl" Id="{48610b89-952c-4a85-87b0-3a800ad674d5}">
<Declaration><![CDATA[PROPERTY RequestNumberImpl : DINT]]></Declaration>
<Get Name="Get" Id="{562ca9eb-e252-47f1-9d0d-9ab9f5f5f405}">
<Declaration><![CDATA[]]></Declaration>
</Get>
</Property>
<Method Name="RequestStepImpl" Id="{484e6cd7-60ba-4268-b695-64585da66145}">
<Declaration><![CDATA[METHOD RequestStepImpl : BOOL
VAR_INPUT
nextStep : ENUM;
END_VAR
]]></Declaration>
</Method>
<Method Name="_Reset" Id="{c44b696d-696b-4673-a947-9ec390e7c67e}">
<Declaration><![CDATA[METHOD _Reset : BOOL
<Method Name="ResetImpl" Id="{c44b696d-696b-4673-a947-9ec390e7c67e}">
<Declaration><![CDATA[METHOD ResetImpl : BOOL
VAR_INPUT
END_VAR
]]></Declaration>
</Method>
<Method Name="_SequenceComplete" Id="{f41bcaea-5de9-45b2-807e-ba3bb516ac9c}">
<Declaration><![CDATA[METHOD _SequenceComplete : BOOL
<Method Name="SequenceCompleteImpl" Id="{f41bcaea-5de9-45b2-807e-ba3bb516ac9c}">
<Declaration><![CDATA[METHOD SequenceCompleteImpl : BOOL
VAR_INPUT
END_VAR
]]></Declaration>
</Method>
<Method Name="_SequenceError" Id="{346d84e2-d277-4231-a765-0b63457bf8e8}">
<Declaration><![CDATA[METHOD _SequenceError : BOOL
<Method Name="SequenceErrorImpl" Id="{346d84e2-d277-4231-a765-0b63457bf8e8}">
<Declaration><![CDATA[METHOD SequenceErrorImpl : BOOL
VAR_INPUT
ErrorCode : INT;
ErrorMessage : STRING;
END_VAR
]]></Declaration>
</Method>
<Property Name="CurrentStep" Id="{f549aba3-dc6c-45db-ae21-2b43a54633f2}">
<Declaration><![CDATA[PROPERTY CurrentStep : ENUM]]></Declaration>
<Get Name="Get" Id="{e53bfbc9-86ad-48ac-b648-09cfbdc36fb7}">
<Declaration><![CDATA[]]></Declaration>
</Get>
</Property>
<Property Name="RequestNumber" Id="{48610b89-952c-4a85-87b0-3a800ad674d5}">
<Declaration><![CDATA[PROPERTY RequestNumber : DINT]]></Declaration>
<Get Name="Get" Id="{562ca9eb-e252-47f1-9d0d-9ab9f5f5f405}">
<Declaration><![CDATA[]]></Declaration>
</Get>
</Property>
</Itf>
</TcPlcObject>
Loading