-
Notifications
You must be signed in to change notification settings - Fork 2
/
plc.st
115 lines (99 loc) · 2.02 KB
/
plc.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
TYPE
LOGLEVEL : (CRITICAL, WARNING, INFO, DEBUG) := INFO;
END_TYPE
FUNCTION_BLOCK LOGGER
VAR_INPUT
TRIG : BOOL;
MSG : STRING;
LEVEL : LOGLEVEL := INFO;
END_VAR
VAR
TRIG0 : BOOL;
END_VAR
IF TRIG AND NOT TRIG0 THEN
{{
LogMessage(GetFbVar(LEVEL),(char*)GetFbVar(MSG, .body),GetFbVar(MSG, .len));
}}
END_IF;
TRIG0:=TRIG;
END_FUNCTION_BLOCK
FUNCTION_BLOCK python_eval
VAR_INPUT
TRIG : BOOL;
CODE : STRING;
END_VAR
VAR_OUTPUT
ACK : BOOL;
RESULT : STRING;
END_VAR
VAR
STATE : DWORD;
BUFFER : STRING;
PREBUFFER : STRING;
TRIGM1 : BOOL;
TRIGGED : BOOL;
END_VAR
{extern void __PythonEvalFB(int, PYTHON_EVAL*);__PythonEvalFB(0, data__);}
END_FUNCTION_BLOCK
FUNCTION_BLOCK python_poll
VAR_INPUT
TRIG : BOOL;
CODE : STRING;
END_VAR
VAR_OUTPUT
ACK : BOOL;
RESULT : STRING;
END_VAR
VAR
STATE : DWORD;
BUFFER : STRING;
PREBUFFER : STRING;
TRIGM1 : BOOL;
TRIGGED : BOOL;
END_VAR
{extern void __PythonEvalFB(int, PYTHON_EVAL*);__PythonEvalFB(1,(PYTHON_EVAL*)(void*)data__);}
END_FUNCTION_BLOCK
FUNCTION_BLOCK python_gear
VAR_INPUT
N : UINT;
TRIG : BOOL;
CODE : STRING;
END_VAR
VAR_OUTPUT
ACK : BOOL;
RESULT : STRING;
END_VAR
VAR
py_eval : python_eval;
COUNTER : UINT;
ADD10_OUT : UINT;
EQ13_OUT : BOOL;
SEL15_OUT : UINT;
AND7_OUT : BOOL;
END_VAR
ADD10_OUT := ADD(COUNTER, 1);
EQ13_OUT := EQ(N, ADD10_OUT);
SEL15_OUT := SEL(EQ13_OUT, ADD10_OUT, 0);
COUNTER := SEL15_OUT;
AND7_OUT := AND(EQ13_OUT, TRIG);
py_eval(TRIG := AND7_OUT, CODE := CODE);
ACK := py_eval.ACK;
RESULT := py_eval.RESULT;
END_FUNCTION_BLOCK
PROGRAM DNP3test
VAR
PB1 : BOOL;
PB2 : BOOL;
LED : BOOL;
END_VAR
PB1 := TRUE;
PB2 := NOT(TRUE OR TRUE);
LED := TRUE AND TRUE;
LED := TRUE;
END_PROGRAM
CONFIGURATION Config0
RESOURCE Res0 ON PLC
TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
PROGRAM instance0 WITH task0 : DNP3test;
END_RESOURCE
END_CONFIGURATION