Skip to content
Closed
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
Binary file not shown.
71 changes: 2 additions & 69 deletions TwinCat/Mbc.Tc3.Pcs/Mbc_Tc3_Pcs/Command/CommandBase.TcPOU
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.6">
<POU Name="CommandBase" Id="{ada50c45-e2a4-0e1e-2882-6555ee7dd9e0}" SpecialFunc="None">
<Declaration><![CDATA[(*---------------------------------------------------------------------------
Copyright (c) 2018 BY mbc engineering GmbH, CH-6015 Luzern
Expand Down Expand Up @@ -38,7 +38,7 @@ VAR
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[// Starting Case
stHandshake.bBusy S= bInit := (stHandshake.bExecute AND NOT stHandshake.bBusy);
stHandshake.bBusy S= bInit := (stHandshake.bExecute AND NOT stHandshake.bBusy AND stHandshake.bEnabled);
IF bInit THEN
stHandshake.nResultCode := E_CommandResultCode.Init;
Init();
Expand Down Expand Up @@ -164,72 +164,5 @@ METHOD PROTECTED Task : BOOL
Task := TRUE;]]></ST>
</Implementation>
</Method>
<LineIds Name="CommandBase">
<LineId Id="94" Count="0" />
<LineId Id="9" Count="0" />
</LineIds>
<LineIds Name="CommandBase.CalculateProgress">
<LineId Id="5" Count="2" />
</LineIds>
<LineIds Name="CommandBase.Call">
<LineId Id="40" Count="0" />
<LineId Id="56" Count="0" />
<LineId Id="62" Count="0" />
<LineId Id="71" Count="0" />
<LineId Id="64" Count="1" />
<LineId Id="63" Count="0" />
<LineId Id="13" Count="1" />
<LineId Id="29" Count="0" />
<LineId Id="19" Count="0" />
<LineId Id="81" Count="2" />
<LineId Id="85" Count="0" />
<LineId Id="80" Count="0" />
<LineId Id="41" Count="0" />
<LineId Id="20" Count="1" />
<LineId Id="45" Count="0" />
<LineId Id="67" Count="0" />
<LineId Id="77" Count="0" />
<LineId Id="69" Count="1" />
<LineId Id="27" Count="0" />
<LineId Id="88" Count="0" />
<LineId Id="87" Count="0" />
<LineId Id="89" Count="2" />
<LineId Id="94" Count="0" />
<LineId Id="93" Count="0" />
</LineIds>
<LineIds Name="CommandBase.Cancelled">
<LineId Id="15" Count="1" />
</LineIds>
<LineIds Name="CommandBase.Done">
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="CommandBase.Finish">
<LineId Id="13" Count="0" />
<LineId Id="8" Count="0" />
</LineIds>
<LineIds Name="CommandBase.Init">
<LineId Id="6" Count="0" />
<LineId Id="5" Count="0" />
<LineId Id="7" Count="0" />
</LineIds>
<LineIds Name="CommandBase.Progress.Get">
<LineId Id="2" Count="1" />
</LineIds>
<LineIds Name="CommandBase.Progress.Set">
<LineId Id="2" Count="0" />
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="CommandBase.SubTask.Get">
<LineId Id="2" Count="0" />
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="CommandBase.SubTask.Set">
<LineId Id="2" Count="0" />
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="CommandBase.Task">
<LineId Id="10" Count="0" />
<LineId Id="5" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.6">
<DUT Name="ST_CommandBaseHandshake" Id="{32bcade6-9e18-0fb5-177f-7513fed5a572}">
<Declaration><![CDATA[(*---------------------------------------------------------------------------
Copyright (c) 2018 BY mbc engineering GmbH, CH-6015 Luzern
Expand All @@ -8,11 +8,12 @@
// Strukture for communication with PCS in the ``CommandBase`` class
TYPE ST_CommandBaseHandshake :
STRUCT
bExecute : BOOL; // Will be set to true from the PCS to start the command. When the operation is finished, the PLC will it set to false. On a long running Task, the PCS can reset to false for Abort the operation.
bBusy : BOOL; // Is True when the command is executing.
nResultCode : UINT; // Shows the operation result code of the commando state. Default Values see 'CommandResultCode' Enum Type. It is possible to set other codes!
nProgress : BYTE; // Shows the optional calculated progress. The value is depend on the command implementation. (default can be 0..100%). Only necessary on long running operations.
nSubTask : UINT; // Shows the optional state of long running Command Execution. It is possible to set it on own need.
bExecute : BOOL; // Will be set to true from the PCS to start the command. When the operation is finished, the PLC will it set to false. On a long running Task, the PCS can reset to false for Abort the operation.
bBusy : BOOL; // Is True when the command is executing.
bEnabled : BOOL := TRUE; // Enables a command. Only PLC writes this flag. PCS only reads this flag.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wenn ich das richtig verstehe, soll die PLC die Ausführung verhindern können, Also gehört das Enable nicht in die Handshake Struktur, welche für die Kommunikation zwischen PCS und PLC dient.

bEnable per Default auf true zu setzten finde ich dan auch sehr untypisch.

Wenn wir davon ausgehen das auf PLC Seite eine Ausführung verhindert werden kann. Ist es notwendig das ein entsprechender Statuscode als Antwort an den Auslöser auf PCS Seite zurückgegeben wird. So kann entsprechend auf das Verhalten reagiert werden.

Ich würde eine zusätzliche Basis Klasse bevorzugen welche von CommandBase ableitet um keinen breaking change zu erhalten. Diese könnte eine sehr schnelle Antwort zurückgeben, wenn Execute = True && !bEnabled

Mein Vorschlag wäre

FUNCTION_BLOCK PUBLIC EnablerCommandBase IMPLEMENTS ICommand
VAR_IN	
  bEnable : BOOL;
END_VAR
END_VAR

@stegm was denkst du davon?

nResultCode : UINT; // Shows the operation result code of the commando state. Default Values see 'CommandResultCode' Enum Type. It is possible to set other codes!
nProgress : BYTE; // Shows the optional calculated progress. The value is depend on the command implementation. (default can be 0..100%). Only necessary on long running operations.
nSubTask : UINT; // Shows the optional state of long running Command Execution. It is possible to set it on own need.
END_STRUCT
END_TYPE
]]></Declaration>
Expand Down
2 changes: 1 addition & 1 deletion TwinCat/Mbc.Tc3.Pcs/Mbc_Tc3_Pcs/Mbc_Tc3_Pcs.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<DefaultNamespace>Mbc_Tc3_Pcs</DefaultNamespace>
<Author>mbc engineering GmbH</Author>
<DocFormat>reStructuredText</DocFormat>
<ProjectVersion>1.2.1.0</ProjectVersion>
<ProjectVersion>1.2.1.1</ProjectVersion>
<Description>Copyright mbc engineering GmbH

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
7 changes: 4 additions & 3 deletions TwinCat/Mbc.Tc3.Pcs/Mbc_Tc3_Pcs/Version/Global_Version.TcGVL
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.6">
<GVL Name="Global_Version" Id="{b04f62c3-23a7-0bc4-3d46-52acd3064e70}">
<Declaration><![CDATA[{attribute 'TcGenerated'}
{attribute 'no-analysis'}
{attribute 'linkalways'}
// This function has been automatically generated from the project information.
VAR_GLOBAL CONSTANT
{attribute 'const_non_replaced'}
{attribute 'linkalways'}
stLibVersion_MBC_TC3_PCS_Library : ST_LibVersion := (iMajor := 1, iMinor := 2, iBuild := 1, iRevision := 0, sVersion := '1.2.1.0');
stLibVersion_MBC_TC3_PCS_Library : ST_LibVersion := (iMajor := 1, iMinor := 2, iBuild := 1, iRevision := 1, nFlags := 0, sVersion := '1.2.1.1');
END_VAR
]]></Declaration>
</GVL>
Expand Down
4 changes: 4 additions & 0 deletions TwinCat/Mbc.Tc3.Pcs/Mbc_Tc3_Pcs/docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ The following types of changes exist:
- **Fixed** for any bug fixes.
- **Security** in case of vulnerabilities.

## [1.2.1.1] - 28.05.2021
### Added
- It is now possible to enable or disable commands with the `stHandshake.bEnabled`

## [1.2.0] - 01.06.2018
### Changed
- The `CommandBase` Public Method `Abort` is renamed to Protected Method `Cancelled`
Expand Down
1 change: 1 addition & 0 deletions TwinCat/Mbc.Tc3.Pcs/Mbc_Tc3_Pcs/docs/CommandBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ In the structure `ST_CommandBaseHandshake` is used to communicate with the PCS.
|---------------|----------|-----|-----|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `bExecute` | BOOL | RW | RW | Will be set to true from the PCS to start the command. When the operation is finished, the PLC will it set to false. On a long running Task, the PCS can reset to false for Abort the operation. The state will change to `Cancelled`. |
| `bBusy` | BOOL | RW | R | Is True when the command is executing. |
| `bEnabled` | BOOL | RW | R | Will be set from PLC. Enables or disables a command. Variable will be initialized as True. To disable a command it explicit has to set False from PLC. |
| `nResultCode` | UINT | RW | R | Shows the operation result code of the commando state. Default Values see `CommandResultCode` Enum Type. It is possible to set other codes! |
| `nProgress` | BYTE | RW | R | Shows the optional calculated progress. The value is depend on the command implementation. (default can be 0..100%). Only necessary on long running operations. |
| `nSubTask` | UINT | RW | R | Shows the optional state of long running Command Execution. It is possible to set it on own need. |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.10">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.6">
<POU Name="TriggerCommand" Id="{d02418d5-5cd7-0a17-16e2-bc96f2eeb812}" SpecialFunc="None">
<Declaration><![CDATA[// Command that detect the execution AND generates one cycle TRUE on the output Q
FUNCTION_BLOCK PUBLIC TriggerCommand EXTENDS CommandBase
VAR_INPUT
bEnabled :BOOL := TRUE;
END_VAR
VAR_OUTPUT
Q : BOOL;
Expand All @@ -13,7 +14,10 @@ VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// OO-Class
<ST><![CDATA[//Enables command
stHandshake.bEnabled := bEnabled;

// OO-Class
SUPER^();]]></ST>
</Implementation>
<Method Name="Init" Id="{fefad13b-36f4-09af-2cda-4ebdb7042fe2}">
Expand Down Expand Up @@ -42,19 +46,5 @@ Q := bInit;
bInit := FALSE;]]></ST>
</Implementation>
</Method>
<LineIds Name="TriggerCommand">
<LineId Id="20" Count="0" />
<LineId Id="9" Count="0" />
</LineIds>
<LineIds Name="TriggerCommand.Init">
<LineId Id="6" Count="0" />
</LineIds>
<LineIds Name="TriggerCommand.Task">
<LineId Id="17" Count="0" />
<LineId Id="21" Count="4" />
<LineId Id="29" Count="2" />
<LineId Id="26" Count="1" />
<LineId Id="4" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
9 changes: 3 additions & 6 deletions TwinCat/Samples/Mbc.Tc3.Pcs.Samples/SPS/POUs/MAIN.TcPOU
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.10">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.6">
<POU Name="MAIN" Id="{12ac386e-9f2f-456d-9446-322109fb7ee0}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM MAIN
VAR
Expand All @@ -9,13 +9,10 @@ END_VAR
<Implementation>
<ST><![CDATA[counter := counter + 1;

Commands.fbStartCommand1.bEnabled := TRUE;

PRG_Commands();
]]></ST>
</Implementation>
<LineIds Name="MAIN">
<LineId Id="141" Count="1" />
<LineId Id="130" Count="0" />
<LineId Id="121" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.