File tree Expand file tree Collapse file tree 3 files changed +115
-0
lines changed
Expand file tree Collapse file tree 3 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ FUNCTION_BLOCK "FB_Messages"
2+ { S7_Optimized_Access := 'TRUE' }
3+ VERSION : 0.1
4+ VAR_INPUT
5+ errorActive : Bool;
6+ warningActive : Bool;
7+ END_VAR
8+
9+ VAR
10+ ALM_Error {InstructionName := 'Program_Alarm'; LibVersion := '1.0'} : Program_Alarm;
11+ ALM_Warning {InstructionName := 'Program_Alarm'; LibVersion := '1.0'} : Program_Alarm;
12+ instance { S7_SetPoint := 'True'} : String[30] := 'Ruehrer F1 Sicherung';
13+ bmk { S7_SetPoint := 'True'} : String[10] := 'B1';
14+ "counter" : UInt;
15+ acknowledgeAlarms : Bool;
16+ test : UInt;
17+ END_VAR
18+
19+ VAR_TEMP
20+ messageTextIdx : UInt;
21+ source : String[10];
22+ ackAlarmsError : Bool;
23+ ackAlarmsStatus : Word;
24+ END_VAR
25+
26+
27+ BEGIN
28+
29+ #messageTextIdx := "MSG_TEST_ERROR";
30+ #source := 'B1';
31+ #ALM_Error(SIG := #errorActive,
32+ SD_1 := #instance,
33+ SD_2 := #bmk,
34+ SD_3 := #messageTextIdx,
35+ SD_4 := #source);
36+
37+ #messageTextIdx := "MSG_TEST_WARNING";
38+ #ALM_Warning(SIG := #warningActive,
39+ SD_1 := #instance,
40+ SD_2 := #bmk,
41+ SD_3 := #messageTextIdx,
42+ SD_4 := #source);
43+
44+
45+ IF #acknowledgeAlarms THEN
46+ #acknowledgeAlarms := FALSE;
47+
48+ Ack_Alarms(MODE := 1,
49+ ERROR=>#ackAlarmsError,
50+ STATUS => #ackAlarmsStatus);
51+
52+ END_IF;
53+
54+
55+
56+ #counter := #counter + 1;
57+ END_FUNCTION_BLOCK
Original file line number Diff line number Diff line change 1+ module github.com/hhirsch/sps-buddy
2+
3+ go 1.23.1
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "bufio"
5+ "fmt"
6+ "os"
7+ "strings"
8+ )
9+
10+ var arguments []string = os .Args
11+ var parserIsInsideVariableBlock bool = false
12+
13+ func handleLine (input string ) {
14+ inputWithoutWhiteSpaces := strings .ReplaceAll (input , " " , "" )
15+ if parserIsInsideVariableBlock {
16+
17+ }
18+
19+ if inputWithoutWhiteSpaces == "VAR_INPUT" ||
20+ inputWithoutWhiteSpaces == "VAR" ||
21+ inputWithoutWhiteSpaces == "VAR_TEMP" {
22+ parserIsInsideVariableBlock = true
23+ return
24+ }
25+
26+ if inputWithoutWhiteSpaces == "END_VAR" {
27+ parserIsInsideVariableBlock = false
28+ }
29+ return
30+ }
31+
32+ func main () {
33+ if len (arguments ) < 2 {
34+ fmt .Printf ("Command needs an argument.\n " )
35+ os .Exit (1 )
36+ }
37+ var fileName string = arguments [1 ]
38+ file , err := os .Open (fileName )
39+ if err != nil {
40+ fmt .Printf ("Error reading file: %s.\n " , err .Error ())
41+ }
42+
43+ scanner := bufio .NewScanner (file )
44+ for scanner .Scan () {
45+ line := scanner .Text ()
46+ handleLine (line )
47+ }
48+
49+ if err := scanner .Err (); err != nil {
50+ fmt .Printf ("Error scanning file: %s.\n " , err .Error ())
51+ }
52+
53+ file .Close ()
54+ os .Exit (0 )
55+ }
You can’t perform that action at this time.
0 commit comments