-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch_test.bcsctrl
More file actions
61 lines (57 loc) · 1.79 KB
/
Copy pathswitch_test.bcsctrl
File metadata and controls
61 lines (57 loc) · 1.79 KB
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
// A test file for switch statement code generation
control SwitchTestController {
enum OperationMode {
IDLE,
HEATING,
COOLING,
ERROR
}
functionblock SwitchFB {
inputs {
var iMode: OperationMode;
var iTemperature: REAL;
}
outputs {
var oHeatingValue: REAL;
var oCoolingValue: REAL;
var oStatusMessage: STRING;
}
locals {
var adjustedTemp: REAL;
}
logic {
adjustedTemp = iTemperature * 1.05;
switch (iMode) {
case OperationMode.IDLE {
oHeatingValue = 0.0;
oCoolingValue = 0.0;
oStatusMessage = "System idle";
}
case OperationMode.HEATING {
oHeatingValue = adjustedTemp;
oCoolingValue = 0.0;
oStatusMessage = "Heating active";
}
case OperationMode.COOLING {
oHeatingValue = 0.0;
oCoolingValue = adjustedTemp;
oStatusMessage = "Cooling active";
}
default {
oHeatingValue = 0.0;
oCoolingValue = 0.0;
oStatusMessage = "Error state";
}
}
}
}
unit TestSwitch {
var mode: OperationMode = OperationMode.HEATING;
var temperature: REAL = 22.5;
var heatingValue: REAL;
var coolingValue: REAL;
var statusMsg: STRING;
use SwitchFB(iMode: mode, iTemperature: temperature) ->
{ oHeatingValue: heatingValue, oCoolingValue: coolingValue, oStatusMessage: statusMsg };
}
}