grenton-ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/analog-din/fv02_01/analog-in.ts +271 -0
- package/dist/clu/calendar/v1/calendar.ts +308 -0
- package/dist/clu/clu-zwave-2/fv515_03/clu-zwave-2.ts +1302 -0
- package/dist/clu/event-scheduler/v1/event-scheduler.ts +537 -0
- package/dist/clu/multi-fan-ac-thermostat/v1/multi-fan-ac-thermostat.ts +1163 -0
- package/dist/clu/pid-controller/v1/pid-controller.ts +536 -0
- package/dist/clu/presence-sensor/v1/presence-sensor.ts +313 -0
- package/dist/clu/presence-sensor/v2/presence-sensor.ts +470 -0
- package/dist/clu/push/v1/push.ts +261 -0
- package/dist/clu/scheduler/v1/scheduler.ts +304 -0
- package/dist/clu/statistics/v1/statistics.ts +413 -0
- package/dist/clu/statistics-pulse/v1/statistics-pulse.ts +218 -0
- package/dist/clu/sunrise-sunset-calendar/v1/sunrise-sunset-calendar.ts +389 -0
- package/dist/clu/sunrise-sunset-calendar/v2/sunrise-sunset-calendar.ts +659 -0
- package/dist/clu/sunrise-sunset-calendar/v3/sunrise-sunset-calendar.ts +659 -0
- package/dist/clu/thermostat/v1/thermostat.ts +768 -0
- package/dist/clu/thermostat/v2/thermostat.ts +861 -0
- package/dist/clu/timer/v1/timer.ts +369 -0
- package/dist/core/execution-builder.ts +55 -0
- package/dist/core/remote-gate.ts +17 -0
- package/dist/digital-in-din/fv02_01/din.ts +310 -0
- package/dist/examples/light_turned_on_by_calendar/Clu_OnInit.ts +26 -0
- package/dist/examples/light_turned_on_by_presence_sensor/Clu_OnInit.ts +35 -0
- package/dist/examples/light_turned_on_by_switch/Clu_OnInit.ts +16 -0
- package/dist/gate/cool-master/v1/cool-master.ts +782 -0
- package/dist/gate/cool-master-net/v1/cool-master-net.ts +334 -0
- package/dist/gate/denon-marantz-avr/v1/denon-marantz-avr.ts +724 -0
- package/dist/gate/heos/v1/heos.ts +1224 -0
- package/dist/gate/http/fv1000_03/clu-gate-http.ts +405 -0
- package/dist/gate/http/fv1000_03_hv1/clu-gate-http.ts +352 -0
- package/dist/gate/http/fv1100_03/clu-gate-http.ts +589 -0
- package/dist/gate/http/fv1110_03/clu-gate-http.ts +589 -0
- package/dist/gate/http/fv1300_03/clu-gate-http.ts +589 -0
- package/dist/gate/http/fv1400_03/clu-gate-http.ts +677 -0
- package/dist/gate/http-listener/v1/http-listener.ts +299 -0
- package/dist/gate/http-listener/v2/http-listener.ts +325 -0
- package/dist/gate/http-request/v1/http-request.ts +645 -0
- package/dist/gate/http-request/v2/http-request.ts +709 -0
- package/dist/gate/input/v1/input.ts +171 -0
- package/dist/gate/jablotron/v1/jablotron.ts +100 -0
- package/dist/gate/jablotron-device/v1/jablotron-device.ts +171 -0
- package/dist/gate/jablotron-output/v1/jablotron-output.ts +240 -0
- package/dist/gate/jablotron-section/v1/jablotron-section.ts +260 -0
- package/dist/gate/modbus/v1/modbus.ts +609 -0
- package/dist/gate/modbus/v2/modbus.ts +690 -0
- package/dist/gate/modbus-client/v1/modbus-client.ts +827 -0
- package/dist/gate/modbus-rtu/v1/modbus-rtu.ts +911 -0
- package/dist/gate/modbus-server/v1/modbus-server.ts +405 -0
- package/dist/gate/modbus-slave-config-rtu/v1/modbus-slave-config-rtu.ts +160 -0
- package/dist/gate/modbus-slave-rtu/v1/modbus-slave-rtu.ts +371 -0
- package/dist/gate/modbus-value/v1/modbus-value.ts +856 -0
- package/dist/gate/music-cast/v1/music-cast.ts +1298 -0
- package/dist/gate/output/v1/output.ts +240 -0
- package/dist/gate/satel/v1/satel.ts +359 -0
- package/dist/gate/satel-input/v1/satel-input.ts +171 -0
- package/dist/gate/satel-output/v1/satel-output.ts +240 -0
- package/dist/gate/satel-zone/v1/satel-zone.ts +235 -0
- package/dist/gate/sonos/v1/sonos.ts +934 -0
- package/dist/gate/timer/v2/timer.ts +253 -0
- package/dist/gate/zone/v1/zone.ts +235 -0
- package/dist/io-module-din-8/fv02_02/din.ts +354 -0
- package/dist/io-module-din-8/fv02_02/dout.ts +360 -0
- package/dist/one-wire/fv01_10/onew-sensor.ts +269 -0
- package/dist/one-wire/fv01_28/onew-sensor.ts +269 -0
- package/dist/one-wire/fv02_28/onew-sensor.ts +350 -0
- package/dist/one-wire/fv03_28/onew-sensor.ts +435 -0
- package/dist/relay-din-2/fv02_02/dout.ts +544 -0
- package/dist/relay-din-4/fv01_02/dout.ts +340 -0
- package/dist/relay-din-4/fv02_02/dout.ts +368 -0
- package/dist/roller-shutter-din-3/fv03_02/roller-shutter.ts +1078 -0
- package/dist/smart-panel-fm-4/fv03_03/panel-button.ts +550 -0
- package/dist/smart-panel-fm-4/fv03_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv03_03/panel-sens-temp.ts +239 -0
- package/dist/smart-panel-fm-4/fv03_03/panel.ts +700 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-page.ts +516 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-sens-temp.ts +239 -0
- package/dist/smart-panel-fm-4/fv04_03/panel.ts +1026 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-page.ts +620 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-sens-temp.ts +266 -0
- package/dist/smart-panel-fm-4/fv05_03/panel.ts +1109 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-page.ts +877 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-sens-temp.ts +297 -0
- package/dist/smart-panel-fm-4/fv06_03/panel.ts +1138 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-page.ts +864 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-sens-temp.ts +297 -0
- package/dist/smart-panel-fm-4/fv07_03/panel.ts +1135 -0
- package/dist/touch-panel-fm-4/fv01_02/panel-button.ts +418 -0
- package/dist/touch-panel-fm-4/fv01_02/panel-sens-light.ts +238 -0
- package/dist/touch-panel-fm-4/fv01_02/panel-sens-temp.ts +257 -0
- package/dist/touch-panel-fm-4/fv01_02/panel.ts +75 -0
- package/dist/touch-panel-fm-4/fv01_02/power-supply-voltage.ts +322 -0
- package/dist/touch-panel-fm-8/fv01_02/panel-button.ts +418 -0
- package/dist/touch-panel-fm-8/fv01_02/panel-sens-light.ts +238 -0
- package/dist/touch-panel-fm-8/fv01_02/panel-sens-temp.ts +270 -0
- package/dist/touch-panel-fm-8/fv01_02/panel.ts +75 -0
- package/dist/touch-panel-fm-8/fv01_02/power-supply-voltage.ts +322 -0
- package/package.json +16 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// Created from: packages/grenton-api/interfaces/module_one_wire_fv01_10.xml, object name="ONEW_SENSOR" version="01" typeId="10"
|
|
2
|
+
|
|
3
|
+
import { rawExecutionBuilderFactory } from "../../core/execution-builder"
|
|
4
|
+
import { RemoteGate } from "../../core/remote-gate"
|
|
5
|
+
|
|
6
|
+
enum EventType {
|
|
7
|
+
OnChange = 0,
|
|
8
|
+
OnRise = 1,
|
|
9
|
+
OnLower = 2,
|
|
10
|
+
OnOutOfRange = 3
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
enum PropertyType {
|
|
14
|
+
Value = 0,
|
|
15
|
+
Threshold = 1,
|
|
16
|
+
MinValue = 2,
|
|
17
|
+
MaxValue = 3
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum MethodType {}
|
|
21
|
+
|
|
22
|
+
declare class OnewSensorRaw {
|
|
23
|
+
add_event(event: EventType, callback: () => void): void;
|
|
24
|
+
get(property: PropertyType): any;
|
|
25
|
+
set(property: PropertyType, value: any): void;
|
|
26
|
+
execute(method: MethodType, ...args: any[]): any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface IOnewSensor {
|
|
30
|
+
/**
|
|
31
|
+
* Zdarzenie wywoływane przy zmianie wartości wyjścia
|
|
32
|
+
* @param callback
|
|
33
|
+
*/
|
|
34
|
+
addOnChange: (callback: () => void) => void
|
|
35
|
+
/**
|
|
36
|
+
* Zdarzenie wywoływane po przekroczeniu górnego progu histerezy (zbocze rosnące)
|
|
37
|
+
* @param callback
|
|
38
|
+
*/
|
|
39
|
+
addOnRise: (callback: () => void) => void
|
|
40
|
+
/**
|
|
41
|
+
* Zdarzenie wywoływane po przekroczeniu dolnego progu histerezy (zbocze opadające)
|
|
42
|
+
* @param callback
|
|
43
|
+
*/
|
|
44
|
+
addOnLower: (callback: () => void) => void
|
|
45
|
+
/**
|
|
46
|
+
* Zdarzenie wywoływane gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
|
|
47
|
+
* @param callback
|
|
48
|
+
*/
|
|
49
|
+
addOnOutOfRange: (callback: () => void) => void
|
|
50
|
+
/** Wartość wejścia */
|
|
51
|
+
readonly value: number
|
|
52
|
+
/** Wielkość histerezy (dokładność 0.1 °C lub 0.1%), określajaca czułość przy której następuje wygenerowanie zdarzeń: OnChange, OnLower, OnRise */
|
|
53
|
+
threshold: number
|
|
54
|
+
/** Wartość minimalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange */
|
|
55
|
+
minValue: number
|
|
56
|
+
/** Wartość maksymalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange */
|
|
57
|
+
maxValue: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class OnewSensor implements IOnewSensor {
|
|
61
|
+
private onChangeCallbacks: Array<() => void> = [];
|
|
62
|
+
private onRiseCallbacks: Array<() => void> = [];
|
|
63
|
+
private onLowerCallbacks: Array<() => void> = [];
|
|
64
|
+
private onOutOfRangeCallbacks: Array<() => void> = [];
|
|
65
|
+
|
|
66
|
+
constructor(private raw: OnewSensorRaw) {
|
|
67
|
+
this.raw.add_event(EventType.OnChange, () => {
|
|
68
|
+
this.onChangeCallbacks.forEach(callback => {
|
|
69
|
+
callback();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
this.raw.add_event(EventType.OnRise, () => {
|
|
74
|
+
this.onRiseCallbacks.forEach(callback => {
|
|
75
|
+
callback();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
this.raw.add_event(EventType.OnLower, () => {
|
|
80
|
+
this.onLowerCallbacks.forEach(callback => {
|
|
81
|
+
callback();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this.raw.add_event(EventType.OnOutOfRange, () => {
|
|
86
|
+
this.onOutOfRangeCallbacks.forEach(callback => {
|
|
87
|
+
callback();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Zdarzenie wywoływane przy zmianie wartości wyjścia
|
|
94
|
+
* @param callback
|
|
95
|
+
*/
|
|
96
|
+
addOnChange(callback: () => void): void {
|
|
97
|
+
this.onChangeCallbacks.push(callback);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Zdarzenie wywoływane po przekroczeniu górnego progu histerezy (zbocze rosnące)
|
|
101
|
+
* @param callback
|
|
102
|
+
*/
|
|
103
|
+
addOnRise(callback: () => void): void {
|
|
104
|
+
this.onRiseCallbacks.push(callback);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Zdarzenie wywoływane po przekroczeniu dolnego progu histerezy (zbocze opadające)
|
|
108
|
+
* @param callback
|
|
109
|
+
*/
|
|
110
|
+
addOnLower(callback: () => void): void {
|
|
111
|
+
this.onLowerCallbacks.push(callback);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Zdarzenie wywoływane gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
|
|
115
|
+
* @param callback
|
|
116
|
+
*/
|
|
117
|
+
addOnOutOfRange(callback: () => void): void {
|
|
118
|
+
this.onOutOfRangeCallbacks.push(callback);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Wartość wejścia
|
|
122
|
+
* @returns {number}
|
|
123
|
+
*/
|
|
124
|
+
get value(): number {
|
|
125
|
+
return this.raw.get(PropertyType.Value);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Wielkość histerezy (dokładność 0.1 °C lub 0.1%), określajaca czułość przy której następuje wygenerowanie zdarzeń: OnChange, OnLower, OnRise
|
|
129
|
+
* @returns {number}
|
|
130
|
+
*/
|
|
131
|
+
get threshold(): number {
|
|
132
|
+
return this.raw.get(PropertyType.Threshold);
|
|
133
|
+
}
|
|
134
|
+
set threshold(value: number) {
|
|
135
|
+
this.raw.set(PropertyType.Threshold, value);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Wartość minimalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
139
|
+
* @returns {number}
|
|
140
|
+
*/
|
|
141
|
+
get minValue(): number {
|
|
142
|
+
return this.raw.get(PropertyType.MinValue);
|
|
143
|
+
}
|
|
144
|
+
set minValue(value: number) {
|
|
145
|
+
this.raw.set(PropertyType.MinValue, value);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Wartość maksymalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
149
|
+
* @returns {number}
|
|
150
|
+
*/
|
|
151
|
+
get maxValue(): number {
|
|
152
|
+
return this.raw.get(PropertyType.MaxValue);
|
|
153
|
+
}
|
|
154
|
+
set maxValue(value: number) {
|
|
155
|
+
this.raw.set(PropertyType.MaxValue, value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class OnewSensorRemote implements IOnewSensor {
|
|
160
|
+
constructor(private objectName: string, private gate: RemoteGate) {
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Zdarzenie wywoływane przy zmianie wartości wyjścia
|
|
166
|
+
* @param callback
|
|
167
|
+
*/
|
|
168
|
+
addOnChange(_callback: () => void): void {
|
|
169
|
+
// Remote events are not supported
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Zdarzenie wywoływane po przekroczeniu górnego progu histerezy (zbocze rosnące)
|
|
173
|
+
* @param callback
|
|
174
|
+
*/
|
|
175
|
+
addOnRise(_callback: () => void): void {
|
|
176
|
+
// Remote events are not supported
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Zdarzenie wywoływane po przekroczeniu dolnego progu histerezy (zbocze opadające)
|
|
180
|
+
* @param callback
|
|
181
|
+
*/
|
|
182
|
+
addOnLower(_callback: () => void): void {
|
|
183
|
+
// Remote events are not supported
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Zdarzenie wywoływane gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
|
|
187
|
+
* @param callback
|
|
188
|
+
*/
|
|
189
|
+
addOnOutOfRange(_callback: () => void): void {
|
|
190
|
+
// Remote events are not supported
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Wartość wejścia
|
|
195
|
+
* @returns {number}
|
|
196
|
+
*/
|
|
197
|
+
get value(): number {
|
|
198
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
199
|
+
.get()
|
|
200
|
+
.addParameter(PropertyType.Value)
|
|
201
|
+
.build();
|
|
202
|
+
return this.gate.runScript(cmd!);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Wielkość histerezy (dokładność 0.1 °C lub 0.1%), określajaca czułość przy której następuje wygenerowanie zdarzeń: OnChange, OnLower, OnRise
|
|
207
|
+
* @returns {number}
|
|
208
|
+
*/
|
|
209
|
+
get threshold(): number {
|
|
210
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
211
|
+
.get()
|
|
212
|
+
.addParameter(PropertyType.Threshold)
|
|
213
|
+
.build();
|
|
214
|
+
return this.gate.runScript(cmd!);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
set threshold(value: number) {
|
|
218
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
219
|
+
.set()
|
|
220
|
+
.addParameter(PropertyType.Threshold)
|
|
221
|
+
.addParameter(value)
|
|
222
|
+
.build();
|
|
223
|
+
this.gate.runScript(cmd!);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Wartość minimalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
228
|
+
* @returns {number}
|
|
229
|
+
*/
|
|
230
|
+
get minValue(): number {
|
|
231
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
232
|
+
.get()
|
|
233
|
+
.addParameter(PropertyType.MinValue)
|
|
234
|
+
.build();
|
|
235
|
+
return this.gate.runScript(cmd!);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
set minValue(value: number) {
|
|
239
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
240
|
+
.set()
|
|
241
|
+
.addParameter(PropertyType.MinValue)
|
|
242
|
+
.addParameter(value)
|
|
243
|
+
.build();
|
|
244
|
+
this.gate.runScript(cmd!);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Wartość maksymalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
249
|
+
* @returns {number}
|
|
250
|
+
*/
|
|
251
|
+
get maxValue(): number {
|
|
252
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
253
|
+
.get()
|
|
254
|
+
.addParameter(PropertyType.MaxValue)
|
|
255
|
+
.build();
|
|
256
|
+
return this.gate.runScript(cmd!);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
set maxValue(value: number) {
|
|
260
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
261
|
+
.set()
|
|
262
|
+
.addParameter(PropertyType.MaxValue)
|
|
263
|
+
.addParameter(value)
|
|
264
|
+
.build();
|
|
265
|
+
this.gate.runScript(cmd!);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export { OnewSensor, OnewSensorRaw, OnewSensorRemote }
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// Created from: packages/grenton-api/interfaces/module_one_wire_fv01_28.xml, object name="ONEW_SENSOR" version="01" typeId="28"
|
|
2
|
+
|
|
3
|
+
import { rawExecutionBuilderFactory } from "../../core/execution-builder"
|
|
4
|
+
import { RemoteGate } from "../../core/remote-gate"
|
|
5
|
+
|
|
6
|
+
enum EventType {
|
|
7
|
+
OnChange = 0,
|
|
8
|
+
OnRise = 1,
|
|
9
|
+
OnLower = 2,
|
|
10
|
+
OnOutOfRange = 3
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
enum PropertyType {
|
|
14
|
+
Value = 0,
|
|
15
|
+
Threshold = 1,
|
|
16
|
+
MinValue = 2,
|
|
17
|
+
MaxValue = 3
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum MethodType {}
|
|
21
|
+
|
|
22
|
+
declare class OnewSensorRaw {
|
|
23
|
+
add_event(event: EventType, callback: () => void): void;
|
|
24
|
+
get(property: PropertyType): any;
|
|
25
|
+
set(property: PropertyType, value: any): void;
|
|
26
|
+
execute(method: MethodType, ...args: any[]): any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface IOnewSensor {
|
|
30
|
+
/**
|
|
31
|
+
* Zdarzenie wywoływane przy zmianie wartości wyjścia
|
|
32
|
+
* @param callback
|
|
33
|
+
*/
|
|
34
|
+
addOnChange: (callback: () => void) => void
|
|
35
|
+
/**
|
|
36
|
+
* Zdarzenie wywoływane po przekroczeniu górnego progu histerezy (zbocze rosnące)
|
|
37
|
+
* @param callback
|
|
38
|
+
*/
|
|
39
|
+
addOnRise: (callback: () => void) => void
|
|
40
|
+
/**
|
|
41
|
+
* Zdarzenie wywoływane po przekroczeniu dolnego progu histerezy (zbocze opadające)
|
|
42
|
+
* @param callback
|
|
43
|
+
*/
|
|
44
|
+
addOnLower: (callback: () => void) => void
|
|
45
|
+
/**
|
|
46
|
+
* Zdarzenie wywoływane gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
|
|
47
|
+
* @param callback
|
|
48
|
+
*/
|
|
49
|
+
addOnOutOfRange: (callback: () => void) => void
|
|
50
|
+
/** Wartość wejścia */
|
|
51
|
+
readonly value: number
|
|
52
|
+
/** Wielkość histerezy (dokładność 0.1 °C lub 0.1%), określajaca czułość przy której następuje wygenerowanie zdarzeń: OnChange, OnLower, OnRise */
|
|
53
|
+
threshold: number
|
|
54
|
+
/** Wartość minimalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange */
|
|
55
|
+
minValue: number
|
|
56
|
+
/** Wartość maksymalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange */
|
|
57
|
+
maxValue: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class OnewSensor implements IOnewSensor {
|
|
61
|
+
private onChangeCallbacks: Array<() => void> = [];
|
|
62
|
+
private onRiseCallbacks: Array<() => void> = [];
|
|
63
|
+
private onLowerCallbacks: Array<() => void> = [];
|
|
64
|
+
private onOutOfRangeCallbacks: Array<() => void> = [];
|
|
65
|
+
|
|
66
|
+
constructor(private raw: OnewSensorRaw) {
|
|
67
|
+
this.raw.add_event(EventType.OnChange, () => {
|
|
68
|
+
this.onChangeCallbacks.forEach(callback => {
|
|
69
|
+
callback();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
this.raw.add_event(EventType.OnRise, () => {
|
|
74
|
+
this.onRiseCallbacks.forEach(callback => {
|
|
75
|
+
callback();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
this.raw.add_event(EventType.OnLower, () => {
|
|
80
|
+
this.onLowerCallbacks.forEach(callback => {
|
|
81
|
+
callback();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this.raw.add_event(EventType.OnOutOfRange, () => {
|
|
86
|
+
this.onOutOfRangeCallbacks.forEach(callback => {
|
|
87
|
+
callback();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Zdarzenie wywoływane przy zmianie wartości wyjścia
|
|
94
|
+
* @param callback
|
|
95
|
+
*/
|
|
96
|
+
addOnChange(callback: () => void): void {
|
|
97
|
+
this.onChangeCallbacks.push(callback);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Zdarzenie wywoływane po przekroczeniu górnego progu histerezy (zbocze rosnące)
|
|
101
|
+
* @param callback
|
|
102
|
+
*/
|
|
103
|
+
addOnRise(callback: () => void): void {
|
|
104
|
+
this.onRiseCallbacks.push(callback);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Zdarzenie wywoływane po przekroczeniu dolnego progu histerezy (zbocze opadające)
|
|
108
|
+
* @param callback
|
|
109
|
+
*/
|
|
110
|
+
addOnLower(callback: () => void): void {
|
|
111
|
+
this.onLowerCallbacks.push(callback);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Zdarzenie wywoływane gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
|
|
115
|
+
* @param callback
|
|
116
|
+
*/
|
|
117
|
+
addOnOutOfRange(callback: () => void): void {
|
|
118
|
+
this.onOutOfRangeCallbacks.push(callback);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Wartość wejścia
|
|
122
|
+
* @returns {number}
|
|
123
|
+
*/
|
|
124
|
+
get value(): number {
|
|
125
|
+
return this.raw.get(PropertyType.Value);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Wielkość histerezy (dokładność 0.1 °C lub 0.1%), określajaca czułość przy której następuje wygenerowanie zdarzeń: OnChange, OnLower, OnRise
|
|
129
|
+
* @returns {number}
|
|
130
|
+
*/
|
|
131
|
+
get threshold(): number {
|
|
132
|
+
return this.raw.get(PropertyType.Threshold);
|
|
133
|
+
}
|
|
134
|
+
set threshold(value: number) {
|
|
135
|
+
this.raw.set(PropertyType.Threshold, value);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Wartość minimalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
139
|
+
* @returns {number}
|
|
140
|
+
*/
|
|
141
|
+
get minValue(): number {
|
|
142
|
+
return this.raw.get(PropertyType.MinValue);
|
|
143
|
+
}
|
|
144
|
+
set minValue(value: number) {
|
|
145
|
+
this.raw.set(PropertyType.MinValue, value);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Wartość maksymalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
149
|
+
* @returns {number}
|
|
150
|
+
*/
|
|
151
|
+
get maxValue(): number {
|
|
152
|
+
return this.raw.get(PropertyType.MaxValue);
|
|
153
|
+
}
|
|
154
|
+
set maxValue(value: number) {
|
|
155
|
+
this.raw.set(PropertyType.MaxValue, value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class OnewSensorRemote implements IOnewSensor {
|
|
160
|
+
constructor(private objectName: string, private gate: RemoteGate) {
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Zdarzenie wywoływane przy zmianie wartości wyjścia
|
|
166
|
+
* @param callback
|
|
167
|
+
*/
|
|
168
|
+
addOnChange(_callback: () => void): void {
|
|
169
|
+
// Remote events are not supported
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Zdarzenie wywoływane po przekroczeniu górnego progu histerezy (zbocze rosnące)
|
|
173
|
+
* @param callback
|
|
174
|
+
*/
|
|
175
|
+
addOnRise(_callback: () => void): void {
|
|
176
|
+
// Remote events are not supported
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Zdarzenie wywoływane po przekroczeniu dolnego progu histerezy (zbocze opadające)
|
|
180
|
+
* @param callback
|
|
181
|
+
*/
|
|
182
|
+
addOnLower(_callback: () => void): void {
|
|
183
|
+
// Remote events are not supported
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Zdarzenie wywoływane gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
|
|
187
|
+
* @param callback
|
|
188
|
+
*/
|
|
189
|
+
addOnOutOfRange(_callback: () => void): void {
|
|
190
|
+
// Remote events are not supported
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Wartość wejścia
|
|
195
|
+
* @returns {number}
|
|
196
|
+
*/
|
|
197
|
+
get value(): number {
|
|
198
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
199
|
+
.get()
|
|
200
|
+
.addParameter(PropertyType.Value)
|
|
201
|
+
.build();
|
|
202
|
+
return this.gate.runScript(cmd!);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Wielkość histerezy (dokładność 0.1 °C lub 0.1%), określajaca czułość przy której następuje wygenerowanie zdarzeń: OnChange, OnLower, OnRise
|
|
207
|
+
* @returns {number}
|
|
208
|
+
*/
|
|
209
|
+
get threshold(): number {
|
|
210
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
211
|
+
.get()
|
|
212
|
+
.addParameter(PropertyType.Threshold)
|
|
213
|
+
.build();
|
|
214
|
+
return this.gate.runScript(cmd!);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
set threshold(value: number) {
|
|
218
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
219
|
+
.set()
|
|
220
|
+
.addParameter(PropertyType.Threshold)
|
|
221
|
+
.addParameter(value)
|
|
222
|
+
.build();
|
|
223
|
+
this.gate.runScript(cmd!);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Wartość minimalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
228
|
+
* @returns {number}
|
|
229
|
+
*/
|
|
230
|
+
get minValue(): number {
|
|
231
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
232
|
+
.get()
|
|
233
|
+
.addParameter(PropertyType.MinValue)
|
|
234
|
+
.build();
|
|
235
|
+
return this.gate.runScript(cmd!);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
set minValue(value: number) {
|
|
239
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
240
|
+
.set()
|
|
241
|
+
.addParameter(PropertyType.MinValue)
|
|
242
|
+
.addParameter(value)
|
|
243
|
+
.build();
|
|
244
|
+
this.gate.runScript(cmd!);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Wartość maksymalna po przekroczeniu której generowane jest zdarzenie OnOutOfRange
|
|
249
|
+
* @returns {number}
|
|
250
|
+
*/
|
|
251
|
+
get maxValue(): number {
|
|
252
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
253
|
+
.get()
|
|
254
|
+
.addParameter(PropertyType.MaxValue)
|
|
255
|
+
.build();
|
|
256
|
+
return this.gate.runScript(cmd!);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
set maxValue(value: number) {
|
|
260
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
261
|
+
.set()
|
|
262
|
+
.addParameter(PropertyType.MaxValue)
|
|
263
|
+
.addParameter(value)
|
|
264
|
+
.build();
|
|
265
|
+
this.gate.runScript(cmd!);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export { OnewSensor, OnewSensorRaw, OnewSensorRemote }
|