Skip to content

Commit 24e3d7f

Browse files
committed
bugfixes in EnableAdv2 +doc adjustments
1 parent 9de3b0c commit 24e3d7f

File tree

6 files changed

+98
-147
lines changed

6 files changed

+98
-147
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# ignore all files as long asd ST is not supported by linguist https://github.com/github/linguist
1+
# ignore all files as long as ST is not supported by linguist https://github.com/github/linguist
22
** linguist-vendored

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ These vscode snippets gives you a head-start in content creation for your very o
88

99
## About: PLCopen
1010

11+
<br/>
12+
13+
<center><img src="doc/img/plcopen.png" width="120"></center>
14+
15+
<br/>
16+
1117
*"The PLCopen organization has defined a standard for Motion Control blocks. This standard can be generalized in that way, that it can be applied to all asynchronous blocks. Asynchronous means in this context, that the execution of the function inside the block extends over multiple (more than one) execution cycles of the PLC, e.g. for communication, closed loop control or motion control applications."*
1218
<br/>
1319
<br/>
@@ -156,9 +162,17 @@ Thanks for your interest in contributing. Anybody is free to report bugs, improv
156162
## Markdownlint-cli
157163

158164
This workspace will be checked by the [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) tool in the CI workflow automatically.
159-
To avoid, that the CI workflow fails because of the markdown linter, you can check and auto-fix all markdown files locally using the following command:
165+
To avoid, that the CI workflow fails because of the markdown linter, you can install and auto-check/fix all markdown files locally using the following commands in your project cli.
166+
167+
Install:
160168

161-
```sh
169+
```bash
170+
npm install -g markdownlint-cli
171+
```
172+
173+
Auto-Fix all:
174+
175+
```bash
162176
markdownlint **/*.md --fix
163177
```
164178

apax.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: '@simatic-ax/plcopen-snippets'
33
version: 0.0.0-placeholder
44
author: Siemens AG
55
# Description will be displayed in the apax extension
6-
description: This package contains PLCopen block templates as vscode snippets
6+
description: This package contains PLCopen block templates as axcode snippets
77
for ST programming in SIMATIC AX
88
type: generic
99
#URL to the repository

doc/img/plcopen.png

29.3 KB
Loading

snippets/FbEnableAdv2.json

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -83,42 +83,42 @@
8383
"${C:",
8484
" tempEnable := enable; // Work with temporary value / create process image",
8585
" ",
86-
" IF (tempEnable = TRUE) AND (s_tatus = STATUS_NO_CALL) THEN // Enable FB",
86+
" IF (tempEnable = TRUE) AND (_status = STATUS_NO_CALL) THEN // Enable FB",
8787
" // First call; initialize FB",
88-
" s_alid := TRUE;",
89-
" s_usy := TRUE;",
90-
" s_ommandAborted := FALSE;",
91-
" s_rror := FALSE;",
92-
" s_rrorUserCleared := FALSE;",
93-
" s_rrorAutoCleared := FALSE;",
94-
" s_tatus := STATUS_FIRST_CALL;",
95-
" s_ubfunctionStatus := SUB_STATUS_NO_ERROR;",
96-
" s_berrorState := 0;",
97-
" diagnostics := s_mptyDiagnostics;",
98-
" s_isablingCompleted := FALSE;",
88+
" _valid := TRUE;",
89+
" _busy := TRUE;",
90+
" _commandAborted := FALSE;",
91+
" _error := FALSE;",
92+
" _errorUserCleared := FALSE;",
93+
" _errorAutoCleared := FALSE;",
94+
" _status := STATUS_FIRST_CALL;",
95+
" _subfunctionStatus := SUB_STATUS_NO_ERROR;",
96+
" _fberrorState := 0;",
97+
" diagnostics := _emptyDiagnostics;",
98+
" _disablingCompleted := FALSE;",
9999
" // State machine - start functionality",
100-
" s_bstate := FbStates#ENABLING;",
100+
" _fbstate := FbStates#ENABLING;",
101101
" ",
102102
" // TODO: Initialize functionality: reset of variables, diagnostics, etc.",
103103
" ",
104104
" // TODO: Initialize functionality: call subordinated FBs with FALSE",
105105
" // instFB(execute := FALSE);",
106106
" ",
107-
" ELSIF (tempEnable = FALSE) AND (s_nableOld = TRUE) THEN // Disable FB ",
108-
" s_bstate := FbStates#DISABLING;",
107+
" ELSIF (tempEnable = FALSE) AND (_enableOld = TRUE) THEN // Disable FB ",
108+
" _fbstate := FbStates#DISABLING;",
109109
" ",
110-
" ELSIF (s_tatus = STATUS_FIRST_CALL) THEN // Set status identifier of subsequent call",
111-
" s_tatus := STATUS_SUBSEQUENT_CALL;",
110+
" ELSIF (_status = STATUS_FIRST_CALL) THEN // Set status identifier of subsequent call",
111+
" _status := STATUS_SUBSEQUENT_CALL;",
112112
" END_IF;",
113113
" ",
114114
" // Edge detection 'enable' input",
115-
" s_nableOld := tempEnable;",
115+
" _enableOld := tempEnable;",
116116
" ",
117-
" IF (s_tatus = STATUS_NO_CALL) THEN // Nothing to do -> End here to reduce system load",
117+
" IF (_status = STATUS_NO_CALL) THEN // Nothing to do -> End here to reduce system load",
118118
" RETURN;",
119119
" END_IF;",
120120
" ",
121-
" CASE s_bstate OF // State machine of FB",
121+
" CASE _fbstate OF // State machine of FB",
122122
" FbStates#NO_PROCESSING:",
123123
" // No processing active (Note: this state must always be present and left empty)",
124124
" ;",
@@ -128,26 +128,26 @@
128128
" // Call subordinated FB or functionality",
129129
" // instFB(execute := TRUE);",
130130
" // IF (instFB.done = TRUE) THEN // Subsidiary FB finished successfully",
131-
" // // Continue processing with next state e.g. s_bstate := FbStates#PROCESSING;",
131+
" // // Continue processing with next state e.g. _fbstate := FbStates#PROCESSING;",
132132
" //",
133133
" // ELSIF (instFB.error = TRUE) THEN // Error occurred in subordinated FB",
134134
" // // If the error occurred needs separate handling (e.g. close connection)",
135135
" // // please set the error output only when this error handling completed successfully",
136-
" // s_tatus := ERR_XYZ; // Set correct status that identifies error clearly",
137-
" // s_ubfunctionStatus := instFB.status // Status or return value of called FBs, FCs and system blocks",
138-
" // s_berrorState := s_bstate; // Set error state number for diagnostic ",
139-
" // s_rrorAutoCleared OR s_rrorUserCleared // Set error type",
136+
" // _status := ERR_XYZ; // Set correct status that identifies error clearly",
137+
" // _subfunctionStatus := instFB.status // Status or return value of called FBs, FCs and system blocks",
138+
" // _fberrorState := _fbstate; // Set error state number for diagnostic ",
139+
" // _errorAutoCleared OR _errorUserCleared // Set error type",
140140
" // // TODO: Error handling",
141141
" // ELSIF (instFB.commandAborted = TRUE) THEN // Commanded functionality has been aborted by another command",
142142
" // // Set block status",
143-
" // s_tatus := STATUS_COMMAND_ABORTED;",
143+
" // _status := STATUS_COMMAND_ABORTED;",
144144
" // // if that must be reported external",
145-
" // // s_ubfunctionStatus := instFB.status // Status or return value of called FBs, FCs and system blocks",
146-
" // // s_berrorState := s_bstate; // Set error state number for diagnostic ",
145+
" // // _subfunctionStatus := instFB.status // Status or return value of called FBs, FCs and system blocks",
146+
" // // _fberrorState := _fbstate; // Set error state number for diagnostic ",
147147
" // // TODO: Error handling",
148148
" // END_IF;",
149149
" //",
150-
" // // TODO: Set s_rrorAutoCleared := FALSE if autocleared is acknowledged",
150+
" // // TODO: Set _errorAutoCleared := FALSE if autocleared is acknowledged",
151151
" ;",
152152
" ",
153153
" FbStates#PROCESSING: // Processing active",
@@ -157,82 +157,82 @@
157157
" ",
158158
" FbStates#DISABLING: // Disabling active",
159159
" // TODO: Disabling, e.g. closing connections, etc.",
160-
" // When disabling is complete the bit s_isablingCompleted must be set",
161-
" s_isablingCompleted := TRUE;",
160+
" // When disabling is complete the bit _disablingCompleted must be set",
161+
" _disablingCompleted := TRUE;",
162162
" ",
163163
" ELSE // Undefined state in state machine reached",
164-
" s_tatus := ERR_UNDEFINED_STATE;",
165-
" s_rrorUserCleared := TRUE;",
164+
" _status := ERR_UNDEFINED_STATE;",
165+
" _errorUserCleared := TRUE;",
166166
" END_CASE;",
167167
" ",
168168
" // Write outputs",
169-
" IF (s_isablingCompleted = TRUE) THEN",
169+
" IF (_disablingCompleted = TRUE) THEN",
170170
" // Reset outputs if disabling completed",
171-
" s_alid := FALSE;",
172-
" s_usy := FALSE;",
173-
" s_ommandAborted := FALSE;",
174-
" s_rror := FALSE;",
175-
" s_rrorUserCleared := FALSE;",
176-
" s_rrorAutoCleared := FALSE;",
177-
" s_tatus := STATUS_NO_CALL;",
171+
" _valid := FALSE;",
172+
" _ubsy := FALSE;",
173+
" _commandAborted := FALSE;",
174+
" _error := FALSE;",
175+
" _errorUserCleared := FALSE;",
176+
" _errorAutoCleared := FALSE;",
177+
" _status := STATUS_NO_CALL;",
178178
" // TODO: Reset application specific outputs",
179179
" // ",
180180
" ",
181-
" ELSIF (s_rrorUserCleared = TRUE) AND (s_rror = FALSE) THEN",
181+
" ELSIF (_errorUserCleared = TRUE) AND (_error = FALSE) THEN",
182182
" // Error can only be cleared by user; rising edge at enable input is needed to continue ",
183-
" s_alid := FALSE;",
184-
" s_usy := FALSE;",
185-
" s_ommandAborted := FALSE;",
186-
" s_rror := TRUE;",
183+
" _valid := FALSE;",
184+
" _busy := FALSE;",
185+
" _commandAborted := FALSE;",
186+
" _error := TRUE;",
187187
" // Write diagnostics",
188-
" //diagnostics := s_iagnostic;",
189-
" diagnostics.Status := s_tatus;",
190-
" diagnostics.SubfunctionStatus := s_ubfunctionStatus;",
191-
" diagnostics.StateNumber := s_berrorState;",
188+
" //diagnostics := _diagnostic;",
189+
" diagnostics.Status := _status;",
190+
" diagnostics.SubfunctionStatus := _subfunctionStatus;",
191+
" diagnostics.StateNumber := _fberrorState;",
192192
" // execution aborted --> set state no processing",
193-
" s_bstate := FbStates#NO_PROCESSING;",
193+
" _fbstate := FbStates#NO_PROCESSING;",
194194
" ",
195-
" ELSIF (s_rrorAutoCleared = TRUE) AND (s_rror = FALSE) THEN",
195+
" ELSIF (_errorAutoCleared = TRUE) AND (_error = FALSE) THEN",
196196
" // Error can be reset by FB automatically",
197-
" s_alid := FALSE;",
198-
" s_usy := TRUE;",
199-
" s_ommandAborted := FALSE;",
200-
" s_rror := TRUE;",
197+
" _valid := FALSE;",
198+
" _busy := TRUE;",
199+
" _commandAborted := FALSE;",
200+
" _error := TRUE;",
201201
" // Write diagnostics",
202-
" diagnostics.Status := s_tatus;",
203-
" diagnostics.SubfunctionStatus := s_ubfunctionStatus;",
204-
" diagnostics.StateNumber := s_berrorState;",
202+
" diagnostics.Status := _status;",
203+
" diagnostics.SubfunctionStatus := _subfunctionStatus;",
204+
" diagnostics.StateNumber := _fberrorState;",
205205
" // TODO: Handling of autocleared error",
206206
" // ",
207207
" ",
208-
" ELSIF (s_tatus = STATUS_COMMAND_ABORTED) AND (s_ommandAborted = FALSE) THEN",
208+
" ELSIF (_status = STATUS_COMMAND_ABORTED) AND (_commandAborted = FALSE) THEN",
209209
" // Commanded functionality has been aborted by another command",
210-
" s_alid := FALSE;",
211-
" s_usy := FALSE;",
212-
" s_ommandAborted := TRUE;",
213-
" s_rror := FALSE;",
210+
" _valid := FALSE;",
211+
" _busy := FALSE;",
212+
" _commandAborted := TRUE;",
213+
" _error := FALSE;",
214214
" // Write diagnostics",
215-
" diagnostics.Status := s_tatus;",
216-
" diagnostics.SubfunctionStatus := s_ubfunctionStatus;",
217-
" diagnostics.StateNumber := s_berrorState;",
215+
" diagnostics.Status := _status;",
216+
" diagnostics.SubfunctionStatus := _subfunctionStatus;",
217+
" diagnostics.StateNumber := _fberrorState;",
218218
" // execution aborted --> set state no processing",
219-
" s_bstate := FbStates#NO_PROCESSING;",
219+
" _fbstate := FbStates#NO_PROCESSING;",
220220
" ",
221-
" ELSIF (s_rrorAutoCleared = FALSE) AND (s_rrorUserCleared = FALSE) AND (s_ommandAborted = FALSE) AND (s_rror = TRUE) THEN",
221+
" ELSIF (_errorAutoCleared = FALSE) AND (_errorUserCleared = FALSE) AND (_commandAborted = FALSE) AND (_error = TRUE) THEN",
222222
" // If autocleared error is acknowledged",
223-
" s_alid := TRUE;",
224-
" s_usy := TRUE;",
225-
" s_ommandAborted := FALSE;",
226-
" s_rror := FALSE;",
223+
" _valid := TRUE;",
224+
" _busy := TRUE;",
225+
" _commandAborted := FALSE;",
226+
" _error := FALSE;",
227227
" // TODO: remove this line if more detailed status information is used instead of 'STATUS_SUBSEQUENT_CALL'",
228-
" s_tatus := STATUS_SUBSEQUENT_CALL;",
228+
" _status := STATUS_SUBSEQUENT_CALL;",
229229
" END_IF;",
230230
" ",
231-
" valid := s_alid;",
232-
" busy := s_usy;",
233-
" commandAborted := s_ommandAborted;",
234-
" error := s_rror;",
235-
" status := s_tatus;",
231+
" valid := _valid;",
232+
" busy := _busy;",
233+
" commandAborted := _commandAborted;",
234+
" error := _error;",
235+
" status := _status;",
236236
" // TODO: Write application specific static values to outputs",
237237
"}",
238238

src/MySource.st

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,5 @@
11
NAMESPACE MyNamespace
22

3-
FUNCTION MyNewBlock
4-
// TODO please personalize block(name)
5-
6-
VAR_INPUT
7-
8-
END_VAR
9-
10-
VAR_OUTPUT
11-
error : BOOL; // TRUE: An error occurred during the execution of the FC
12-
status : WORD; // WORD#16#0000 - WORD#16#7FFF: Status of the FB, WORD#16#8000 - WORD#16#FFFF: Error identification
13-
subfunctionStatus : WORD; // Status or return value of called FCs and system blocks
14-
END_VAR
15-
16-
VAR_TEMP
17-
tempStatus : WORD; // temp value for output 'status'
18-
tempSubfunctionStatus : WORD; // temp value for output 'subfunctionStatus'
19-
END_VAR
20-
21-
VAR CONSTANT
22-
STATUS_FINISHED_NO_ERROR : WORD := WORD#16#0000; // NO error - execution finished without errors
23-
SUB_STATUS_NO_ERROR : WORD := WORD#16#0000; // NO error occured in subfunction call
24-
ERR_UNDEFINED : WORD := WORD#16#8000; // Error: due to an undefined case
25-
ERR_IN_BLOCK_OPERATION : WORD := WORD#16#8001; // Error: Wrong operation of the function block
26-
ERR_PARAMETRIZATION : WORD := WORD#16#8200; // Error: during parameterization
27-
ERR_PROCESSING_EXTERN : WORD := WORD#16#8400; // Error: when processing from outside (e. g. wrong I/O signals, axis not referenced)
28-
ERR_PROCESSING_INTERN : WORD := WORD#16#8600; // Error: when processing internally (e. g. when calling a system function)
29-
ERR_AREA_RESERVED : WORD := WORD#16#8800; // Error: Reserved area
30-
ERR_USER_DEFINED_CLASSES : WORD := WORD#16#9000; // Error: User-defined error classes
31-
END_VAR
3+
// DummyBlock for tests while dev
324

33-
//===============================================================================
34-
// (company) / (c)Copyright (year)
35-
//-------------------------------------------------------------------------------
36-
// Title: (Title of this Block)
37-
// Comment/Function: (that is implemented in the block)
38-
// Library/Family: (that the source is dedicated to)
39-
// Author: (department / person in charge / contact)
40-
// Tested with: (test system with version)
41-
// Engineering: SIMATIC AX (SDK version)
42-
// Restrictions: (OB types, etc.)
43-
// Requirements: (hardware, technological package, memory needed, etc.)
44-
//-------------------------------------------------------------------------------
45-
// Change log table:
46-
// Version | Date | Expert in charge | Changes applied
47-
//----------|------------|------------------------|------------------------------
48-
// 01.00.00 | yyyy-mm-dd | (name of expert) | First released version
49-
//===============================================================================
50-
51-
52-
// TODO: Initialize functionality: reset of variables, diagnostics, etc.
53-
//
54-
tempStatus := STATUS_FINISHED_NO_ERROR;
55-
tempSubfunctionStatus := SUB_STATUS_NO_ERROR;
56-
57-
// TODO: Use this region for application specific code
58-
//
59-
60-
// TODO: Write application specific temp values to outputs
61-
//
62-
error := tempStatus.%X15;
63-
status := tempStatus;
64-
subfunctionStatus := tempSubfunctionStatus;
65-
66-
END_FUNCTION
67-
685
END_NAMESPACE

0 commit comments

Comments
 (0)