-
Notifications
You must be signed in to change notification settings - Fork 1
/
RFBConnection.m
128 lines (96 loc) · 4.33 KB
/
RFBConnection.m
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
116
117
118
119
120
121
122
123
124
125
126
127
classdef RFBConnection < MBUDPConnection
%RFBCONNECTION Implementation of the functions used to controll the
%Schmid RFB over modbus.
methods(Access=public)
function getBatteryVoltage(obj, responseCB)
obj.requestInputRegisterRead(5000, 2, "single", responseCB)
end
function getBatteryCurrent(obj, responseCB)
obj.requestInputRegisterRead(5004, 2, "single", responseCB)
end
function getAnolytTemp(obj, responseCB)
obj.requestInputRegisterRead(5012, 2, "single", responseCB)
end
function getKatolytTemp(obj, responseCB)
obj.requestInputRegisterRead(5016, 2, "single", responseCB)
end
function getAnolytFlowrate(obj, responseCB)
obj.requestInputRegisterRead(5028, 2, "single", responseCB)
end
function getKatolytFlowrate(obj, responseCB)
obj.requestInputRegisterRead(5032, 2, "single", responseCB)
end
function getOpenCircuitVoltage(obj, responseCB)
obj.requestInputRegisterRead(5068, 2, "single", responseCB)
end
function getBatteryPower(obj, responseCB)
obj.requestInputRegisterRead(5072, 2, "int32", responseCB)
end
function getSOCRelative(obj, responseCB)
obj.requestInputRegisterRead(5076, 2, "single", responseCB)
end
function getConstantPower(obj, responseCB)
obj.requestHoldingRegisterRead(1086, 2, "uint32", responseCB);
end
function getXtenderActive(obj, responseCB)
obj.requestCoilRead(1134, 1, responseCB)
end
function getFlowRateControlActive(obj, responseCB)
obj.requestCoilRead(1138, 1, responseCB)
end
function getACPowerControlActive(obj, responseCB)
obj.requestCoilRead(1142, 1, responseCB)
end
function getAlarmHornActive(obj, responseCB)
obj.requestCoilRead(1146, 1, responseCB)
end
function getCosPhiActive(obj, responseCB)
obj.requestCoilRead(1150, 1, responseCB)
end
function getFlowStochiometryActive(obj, responseCB)
obj.requestCoilRead(1162, 1, responseCB)
end
function getAlarms(obj, responseCB)
boolRespCB = @(boolArray)(responseCB(obj.alarmListFromBoolArray(boolArray)));
obj.requestCoilRead(10000, 66, boolRespCB)
end
function putSOCMax(obj, val, writeSuccessCB)
obj.requestRegisterWrite(1070, val, writeSuccessCB)
end
function getSOCMax(obj, responseCB)
obj.requestHoldingRegisterRead(1070, 1, "uint16", responseCB)
end
function putSOCMin(obj, val, writeSuccessCB)
obj.requestRegisterWrite(1074, val, writeSuccessCB)
end
function getSOCMin(obj, responseCB)
obj.requestHoldingRegisterRead(1074, 1, "uint16", responseCB)
end
function putFlowrateAnolyt(obj, val, writeSuccessCB)
obj.requestMultipleRegisterWrite(1062, 2, single(val),writeSuccessCB)
end
function putConstantPower(obj, val, writeSuccessCB)
obj.requestMultipleRegisterWrite(1086, 2, uint32(val),writeSuccessCB)
end
function putButtonStart(obj, value, writeSuccessCB)
obj.requestCoilWrite(9001, value, writeSuccessCB);
end
function putButtonStop(obj, value, writeSuccessCB)
obj.requestCoilWrite(9002, value, writeSuccessCB);
end
function putButtonReset(obj, value, writeSuccessCB)
obj.requestCoilWrite(9003, value, writeSuccessCB);
end
function putButtonShutdown(obj, value, writeSuccessCB)
obj.requestCoilWrite(9004, value, writeSuccessCB);
end
end
methods(Access=private)
function alarmArr = alarmListFromBoolArray(~, boolArray)
%this automatically checks if the number of boolean values is
%correct
alarms = uint16(boolArray) .* uint16(10000:10065);
alarmArr = alarms(alarms ~= 0);
end
end
end