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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/dist/analog-din/fv02_01/analog-in.ts +271 -0
  4. package/dist/clu/calendar/v1/calendar.ts +308 -0
  5. package/dist/clu/clu-zwave-2/fv515_03/clu-zwave-2.ts +1302 -0
  6. package/dist/clu/event-scheduler/v1/event-scheduler.ts +537 -0
  7. package/dist/clu/multi-fan-ac-thermostat/v1/multi-fan-ac-thermostat.ts +1163 -0
  8. package/dist/clu/pid-controller/v1/pid-controller.ts +536 -0
  9. package/dist/clu/presence-sensor/v1/presence-sensor.ts +313 -0
  10. package/dist/clu/presence-sensor/v2/presence-sensor.ts +470 -0
  11. package/dist/clu/push/v1/push.ts +261 -0
  12. package/dist/clu/scheduler/v1/scheduler.ts +304 -0
  13. package/dist/clu/statistics/v1/statistics.ts +413 -0
  14. package/dist/clu/statistics-pulse/v1/statistics-pulse.ts +218 -0
  15. package/dist/clu/sunrise-sunset-calendar/v1/sunrise-sunset-calendar.ts +389 -0
  16. package/dist/clu/sunrise-sunset-calendar/v2/sunrise-sunset-calendar.ts +659 -0
  17. package/dist/clu/sunrise-sunset-calendar/v3/sunrise-sunset-calendar.ts +659 -0
  18. package/dist/clu/thermostat/v1/thermostat.ts +768 -0
  19. package/dist/clu/thermostat/v2/thermostat.ts +861 -0
  20. package/dist/clu/timer/v1/timer.ts +369 -0
  21. package/dist/core/execution-builder.ts +55 -0
  22. package/dist/core/remote-gate.ts +17 -0
  23. package/dist/digital-in-din/fv02_01/din.ts +310 -0
  24. package/dist/examples/light_turned_on_by_calendar/Clu_OnInit.ts +26 -0
  25. package/dist/examples/light_turned_on_by_presence_sensor/Clu_OnInit.ts +35 -0
  26. package/dist/examples/light_turned_on_by_switch/Clu_OnInit.ts +16 -0
  27. package/dist/gate/cool-master/v1/cool-master.ts +782 -0
  28. package/dist/gate/cool-master-net/v1/cool-master-net.ts +334 -0
  29. package/dist/gate/denon-marantz-avr/v1/denon-marantz-avr.ts +724 -0
  30. package/dist/gate/heos/v1/heos.ts +1224 -0
  31. package/dist/gate/http/fv1000_03/clu-gate-http.ts +405 -0
  32. package/dist/gate/http/fv1000_03_hv1/clu-gate-http.ts +352 -0
  33. package/dist/gate/http/fv1100_03/clu-gate-http.ts +589 -0
  34. package/dist/gate/http/fv1110_03/clu-gate-http.ts +589 -0
  35. package/dist/gate/http/fv1300_03/clu-gate-http.ts +589 -0
  36. package/dist/gate/http/fv1400_03/clu-gate-http.ts +677 -0
  37. package/dist/gate/http-listener/v1/http-listener.ts +299 -0
  38. package/dist/gate/http-listener/v2/http-listener.ts +325 -0
  39. package/dist/gate/http-request/v1/http-request.ts +645 -0
  40. package/dist/gate/http-request/v2/http-request.ts +709 -0
  41. package/dist/gate/input/v1/input.ts +171 -0
  42. package/dist/gate/jablotron/v1/jablotron.ts +100 -0
  43. package/dist/gate/jablotron-device/v1/jablotron-device.ts +171 -0
  44. package/dist/gate/jablotron-output/v1/jablotron-output.ts +240 -0
  45. package/dist/gate/jablotron-section/v1/jablotron-section.ts +260 -0
  46. package/dist/gate/modbus/v1/modbus.ts +609 -0
  47. package/dist/gate/modbus/v2/modbus.ts +690 -0
  48. package/dist/gate/modbus-client/v1/modbus-client.ts +827 -0
  49. package/dist/gate/modbus-rtu/v1/modbus-rtu.ts +911 -0
  50. package/dist/gate/modbus-server/v1/modbus-server.ts +405 -0
  51. package/dist/gate/modbus-slave-config-rtu/v1/modbus-slave-config-rtu.ts +160 -0
  52. package/dist/gate/modbus-slave-rtu/v1/modbus-slave-rtu.ts +371 -0
  53. package/dist/gate/modbus-value/v1/modbus-value.ts +856 -0
  54. package/dist/gate/music-cast/v1/music-cast.ts +1298 -0
  55. package/dist/gate/output/v1/output.ts +240 -0
  56. package/dist/gate/satel/v1/satel.ts +359 -0
  57. package/dist/gate/satel-input/v1/satel-input.ts +171 -0
  58. package/dist/gate/satel-output/v1/satel-output.ts +240 -0
  59. package/dist/gate/satel-zone/v1/satel-zone.ts +235 -0
  60. package/dist/gate/sonos/v1/sonos.ts +934 -0
  61. package/dist/gate/timer/v2/timer.ts +253 -0
  62. package/dist/gate/zone/v1/zone.ts +235 -0
  63. package/dist/io-module-din-8/fv02_02/din.ts +354 -0
  64. package/dist/io-module-din-8/fv02_02/dout.ts +360 -0
  65. package/dist/one-wire/fv01_10/onew-sensor.ts +269 -0
  66. package/dist/one-wire/fv01_28/onew-sensor.ts +269 -0
  67. package/dist/one-wire/fv02_28/onew-sensor.ts +350 -0
  68. package/dist/one-wire/fv03_28/onew-sensor.ts +435 -0
  69. package/dist/relay-din-2/fv02_02/dout.ts +544 -0
  70. package/dist/relay-din-4/fv01_02/dout.ts +340 -0
  71. package/dist/relay-din-4/fv02_02/dout.ts +368 -0
  72. package/dist/roller-shutter-din-3/fv03_02/roller-shutter.ts +1078 -0
  73. package/dist/smart-panel-fm-4/fv03_03/panel-button.ts +550 -0
  74. package/dist/smart-panel-fm-4/fv03_03/panel-sens-light.ts +238 -0
  75. package/dist/smart-panel-fm-4/fv03_03/panel-sens-temp.ts +239 -0
  76. package/dist/smart-panel-fm-4/fv03_03/panel.ts +700 -0
  77. package/dist/smart-panel-fm-4/fv04_03/panel-button.ts +567 -0
  78. package/dist/smart-panel-fm-4/fv04_03/panel-page.ts +516 -0
  79. package/dist/smart-panel-fm-4/fv04_03/panel-sens-light.ts +238 -0
  80. package/dist/smart-panel-fm-4/fv04_03/panel-sens-temp.ts +239 -0
  81. package/dist/smart-panel-fm-4/fv04_03/panel.ts +1026 -0
  82. package/dist/smart-panel-fm-4/fv05_03/panel-button.ts +567 -0
  83. package/dist/smart-panel-fm-4/fv05_03/panel-page.ts +620 -0
  84. package/dist/smart-panel-fm-4/fv05_03/panel-sens-light.ts +238 -0
  85. package/dist/smart-panel-fm-4/fv05_03/panel-sens-temp.ts +266 -0
  86. package/dist/smart-panel-fm-4/fv05_03/panel.ts +1109 -0
  87. package/dist/smart-panel-fm-4/fv06_03/panel-button.ts +567 -0
  88. package/dist/smart-panel-fm-4/fv06_03/panel-page.ts +877 -0
  89. package/dist/smart-panel-fm-4/fv06_03/panel-sens-light.ts +238 -0
  90. package/dist/smart-panel-fm-4/fv06_03/panel-sens-temp.ts +297 -0
  91. package/dist/smart-panel-fm-4/fv06_03/panel.ts +1138 -0
  92. package/dist/smart-panel-fm-4/fv07_03/panel-button.ts +567 -0
  93. package/dist/smart-panel-fm-4/fv07_03/panel-page.ts +864 -0
  94. package/dist/smart-panel-fm-4/fv07_03/panel-sens-light.ts +238 -0
  95. package/dist/smart-panel-fm-4/fv07_03/panel-sens-temp.ts +297 -0
  96. package/dist/smart-panel-fm-4/fv07_03/panel.ts +1135 -0
  97. package/dist/touch-panel-fm-4/fv01_02/panel-button.ts +418 -0
  98. package/dist/touch-panel-fm-4/fv01_02/panel-sens-light.ts +238 -0
  99. package/dist/touch-panel-fm-4/fv01_02/panel-sens-temp.ts +257 -0
  100. package/dist/touch-panel-fm-4/fv01_02/panel.ts +75 -0
  101. package/dist/touch-panel-fm-4/fv01_02/power-supply-voltage.ts +322 -0
  102. package/dist/touch-panel-fm-8/fv01_02/panel-button.ts +418 -0
  103. package/dist/touch-panel-fm-8/fv01_02/panel-sens-light.ts +238 -0
  104. package/dist/touch-panel-fm-8/fv01_02/panel-sens-temp.ts +270 -0
  105. package/dist/touch-panel-fm-8/fv01_02/panel.ts +75 -0
  106. package/dist/touch-panel-fm-8/fv01_02/power-supply-voltage.ts +322 -0
  107. package/package.json +16 -0
@@ -0,0 +1,418 @@
1
+ // Created from: packages/grenton-api/interfaces/module_2_0_TOUCH_PANEL_FM_8_fv01_02.xml, object name="BUTTON" version="01.02"
2
+
3
+ import { rawExecutionBuilderFactory } from "../../core/execution-builder"
4
+ import { RemoteGate } from "../../core/remote-gate"
5
+
6
+ enum EventType {
7
+ OnValueChange = 0,
8
+ OnSwitchOn = 1,
9
+ OnSwitchOff = 2,
10
+ OnShortPress = 3,
11
+ OnLongPress = 4,
12
+ OnHold = 5,
13
+ OnClick = 6,
14
+ }
15
+
16
+ enum PropertyType {
17
+ Value = 0,
18
+ Mode = 1,
19
+ HoldDelay = 2,
20
+ HoldInterval = 3,
21
+ DistributedLogicGroup = 4,
22
+ }
23
+
24
+ enum MethodType {
25
+ ShowOK = 0,
26
+ ShowError = 0,
27
+ LedSwitchOn = 1,
28
+ LedSwitchOff = 2,
29
+ }
30
+
31
+ enum ModeType {
32
+ Monostable = 0,
33
+ Bistable = 1,
34
+ Locked = 2,
35
+ }
36
+
37
+ declare class ButtonRaw {
38
+ add_event(event: EventType, callback: () => void): void;
39
+ get(property: PropertyType): any;
40
+ set(property: PropertyType, value: any): void;
41
+ execute(method: number, ...args: any[]): any;
42
+ }
43
+
44
+ interface IButton {
45
+ /**
46
+ * Zdarzenie wywoływane w przypadku zmiany stanu na przeciwny
47
+ * @param callback
48
+ */
49
+ addOnValueChange: (callback: () => void) => void
50
+ /**
51
+ * Zdarzenie wywoływane w momencie ustawienia stanu wysokiego na wejściu
52
+ * @param callback
53
+ */
54
+ addOnSwitchOn: (callback: () => void) => void
55
+ /**
56
+ * Zdarzenie wywoływane w momencie ustawienia stanu niskiego na wejściu
57
+ * @param callback
58
+ */
59
+ addOnSwitchOff: (callback: () => void) => void
60
+ /**
61
+ * Zdarzenie wywoływane po naciśnięciu przycisku na okres 500 ms - 2000 ms
62
+ * @param callback
63
+ */
64
+ addOnShortPress: (callback: () => void) => void
65
+ /**
66
+ * Zdarzenie wywoływane po naciśnięciu przycisku na okres dłuższy niż 2000 ms
67
+ * @param callback
68
+ */
69
+ addOnLongPress: (callback: () => void) => void
70
+ /**
71
+ * Zdarzenie wywoływane gdy wejście jest w stanie wysokim, pierwszy raz po upłynięciu czasu HoldDelay, a następnie cyklicznie co wartość HoldInterval
72
+ * @param callback
73
+ */
74
+ addOnHold: (callback: () => void) => void
75
+ /**
76
+ * Zdarzenie wywoływane po naciśnięciu przycisku na czas krótszy niż 500 ms
77
+ * @param callback
78
+ */
79
+ addOnClick: (callback: () => void) => void
80
+ /** Powoduje miganie zielonej diody na przycisku przez 2 sekundy (częstotliwość 500 ms). Czerwona dioda przycisku pozostaje zgaszona */
81
+ showOK: () => void
82
+ /** Powoduje miganie czerwonej diody na przycisku przez 2 sekundy (częstotliwość 500 ms) */
83
+ showError: () => void
84
+ /** Załącza zieloną diodę na przycisku */
85
+ ledSwitchOn: () => void
86
+ /** Wyłącza zieloną diodę na przycisku */
87
+ ledSwitchOff: () => void
88
+ /** Zwraca stan wejścia jako 0 lub 1 */
89
+ readonly value: boolean
90
+ /** Zwraca ustawiony tryb działania przycisku (0 - monostabilny (Monostable), 1 - bistabilny (Bistable), 2 - zablokowany (Locked)) */
91
+ readonly mode: ModeType
92
+ /**
93
+ * Ustawia tryb działania przycisku (0 - monostabilny (Monostable), 1 - bistabilny (Bistable), 2 - zablokowany (Locked))
94
+ * @param {ModeType} value
95
+ */
96
+ setMode: (value: ModeType) => void
97
+ /** Czas w milisekundach, po jakim po wciśnięciu i przytrzymaniu przycisku wyzwalane jest zdarzenie OnHold (domyślnie 1000 ms) */
98
+ readonly holdDelay: number
99
+ /**
100
+ * Ustawia wartość HoldDelay
101
+ * @param {number} value
102
+ */
103
+ setHoldDelay: (value: number) => void
104
+ /** Odstęp cykliczny w milisekundach, po jakim podczas trzymania przycisku wyzwalane są kolejne zdarzenia OnHold */
105
+ readonly holdInterval: number
106
+ /**
107
+ * Ustawia wartość HoldInterval
108
+ * @param {number} value
109
+ */
110
+ setHoldInterval: (value: number) => void
111
+ /** Grupa Distributed Logic - grupa broadcastowa dla rozproszonej logiki */
112
+ distributedLogicGroup: number
113
+ }
114
+
115
+ class ButtonRemote implements IButton {
116
+ constructor(private objectName: string, private gate: RemoteGate) {
117
+ }
118
+
119
+ addOnValueChange(_callback: () => void): void {
120
+ // Remote events are not supported
121
+ }
122
+ addOnSwitchOn(_callback: () => void): void {
123
+ // Remote events are not supported
124
+ }
125
+ addOnSwitchOff(_callback: () => void): void {
126
+ // Remote events are not supported
127
+ }
128
+ addOnShortPress(_callback: () => void): void {
129
+ // Remote events are not supported
130
+ }
131
+ addOnLongPress(_callback: () => void): void {
132
+ // Remote events are not supported
133
+ }
134
+ addOnHold(_callback: () => void): void {
135
+ // Remote events are not supported
136
+ }
137
+ addOnClick(_callback: () => void): void {
138
+ // Remote events are not supported
139
+ }
140
+
141
+ /** Powoduje miganie zielonej diody na przycisku przez 2 sekundy (częstotliwość 500 ms). Czerwona dioda przycisku pozostaje zgaszona */
142
+ showOK(): void {
143
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
144
+ .execute()
145
+ .addParameter(MethodType.ShowOK)
146
+ .addParameter(0)
147
+ .build();
148
+ this.gate.runScript(cmd!);
149
+ }
150
+
151
+ /** Powoduje miganie czerwonej diody na przycisku przez 2 sekundy (częstotliwość 500 ms) */
152
+ showError(): void {
153
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
154
+ .execute()
155
+ .addParameter(MethodType.ShowError)
156
+ .addParameter(1)
157
+ .build();
158
+ this.gate.runScript(cmd!);
159
+ }
160
+
161
+ /** Załącza zieloną diodę na przycisku */
162
+ ledSwitchOn(): void {
163
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
164
+ .execute()
165
+ .addParameter(MethodType.LedSwitchOn)
166
+ .addParameter(2)
167
+ .build();
168
+ this.gate.runScript(cmd!);
169
+ }
170
+
171
+ /** Wyłącza zieloną diodę na przycisku */
172
+ ledSwitchOff(): void {
173
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
174
+ .execute()
175
+ .addParameter(MethodType.LedSwitchOff)
176
+ .addParameter(4)
177
+ .build();
178
+ this.gate.runScript(cmd!);
179
+ }
180
+
181
+ /** Zwraca stan wejścia jako 0 lub 1 */
182
+ get value(): boolean {
183
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
184
+ .get()
185
+ .addParameter(PropertyType.Value)
186
+ .build();
187
+ return this.gate.runScript(cmd!) === 1;
188
+ }
189
+
190
+ /** Zwraca ustawiony tryb działania przycisku (0 - monostabilny (Monostable), 1 - bistabilny (Bistable), 2 - zablokowany (Locked)) */
191
+ get mode(): ModeType {
192
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
193
+ .get()
194
+ .addParameter(PropertyType.Mode)
195
+ .build();
196
+ return this.gate.runScript(cmd!);
197
+ }
198
+
199
+ /**
200
+ * Ustawia tryb działania przycisku (0 - monostabilny (Monostable), 1 - bistabilny (Bistable), 2 - zablokowany (Locked))
201
+ * @param {ModeType} value
202
+ */
203
+ setMode(value: ModeType): void {
204
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
205
+ .set()
206
+ .addParameter(PropertyType.Mode)
207
+ .addParameter(value)
208
+ .build();
209
+ this.gate.runScript(cmd!);
210
+ }
211
+
212
+ /** Czas w milisekundach, po jakim po wciśnięciu i przytrzymaniu przycisku wyzwalane jest zdarzenie OnHold (domyślnie 1000 ms) */
213
+ get holdDelay(): number {
214
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
215
+ .get()
216
+ .addParameter(PropertyType.HoldDelay)
217
+ .build();
218
+ return this.gate.runScript(cmd!);
219
+ }
220
+
221
+ /**
222
+ * Ustawia wartość HoldDelay
223
+ * @param {number} value
224
+ */
225
+ setHoldDelay(value: number): void {
226
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
227
+ .set()
228
+ .addParameter(PropertyType.HoldDelay)
229
+ .addParameter(value)
230
+ .build();
231
+ this.gate.runScript(cmd!);
232
+ }
233
+
234
+ /** Odstęp cykliczny w milisekundach, po jakim podczas trzymania przycisku wyzwalane są kolejne zdarzenia OnHold */
235
+ get holdInterval(): number {
236
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
237
+ .get()
238
+ .addParameter(PropertyType.HoldInterval)
239
+ .build();
240
+ return this.gate.runScript(cmd!);
241
+ }
242
+
243
+ /**
244
+ * Ustawia wartość HoldInterval
245
+ * @param {number} value
246
+ */
247
+ setHoldInterval(value: number): void {
248
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
249
+ .set()
250
+ .addParameter(PropertyType.HoldInterval)
251
+ .addParameter(value)
252
+ .build();
253
+ this.gate.runScript(cmd!);
254
+ }
255
+
256
+ /** Grupa Distributed Logic - grupa broadcastowa dla rozproszonej logiki */
257
+ get distributedLogicGroup(): number {
258
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
259
+ .get()
260
+ .addParameter(PropertyType.DistributedLogicGroup)
261
+ .build();
262
+ return this.gate.runScript(cmd!);
263
+ }
264
+ set distributedLogicGroup(value: number) {
265
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
266
+ .set()
267
+ .addParameter(PropertyType.DistributedLogicGroup)
268
+ .addParameter(value)
269
+ .build();
270
+ this.gate.runScript(cmd!);
271
+ }
272
+ }
273
+
274
+ class Button implements IButton {
275
+ private onValueChangeCallbacks: Array<() => void> = [];
276
+ private onSwitchOnCallbacks: Array<() => void> = [];
277
+ private onSwitchOffCallbacks: Array<() => void> = [];
278
+ private onShortPressCallbacks: Array<() => void> = [];
279
+ private onLongPressCallbacks: Array<() => void> = [];
280
+ private onHoldCallbacks: Array<() => void> = [];
281
+ private onClickCallbacks: Array<() => void> = [];
282
+
283
+ constructor(private raw: ButtonRaw) {
284
+ this.raw.add_event(EventType.OnValueChange, () => {
285
+ this.onValueChangeCallbacks.forEach(callback => { callback(); });
286
+ });
287
+ this.raw.add_event(EventType.OnSwitchOn, () => {
288
+ this.onSwitchOnCallbacks.forEach(callback => { callback(); });
289
+ });
290
+ this.raw.add_event(EventType.OnSwitchOff, () => {
291
+ this.onSwitchOffCallbacks.forEach(callback => { callback(); });
292
+ });
293
+ this.raw.add_event(EventType.OnShortPress, () => {
294
+ this.onShortPressCallbacks.forEach(callback => { callback(); });
295
+ });
296
+ this.raw.add_event(EventType.OnLongPress, () => {
297
+ this.onLongPressCallbacks.forEach(callback => { callback(); });
298
+ });
299
+ this.raw.add_event(EventType.OnHold, () => {
300
+ this.onHoldCallbacks.forEach(callback => { callback(); });
301
+ });
302
+ this.raw.add_event(EventType.OnClick, () => {
303
+ this.onClickCallbacks.forEach(callback => { callback(); });
304
+ });
305
+ }
306
+
307
+ /**
308
+ * Zdarzenie wywoływane w przypadku zmiany stanu na przeciwny
309
+ * @param callback
310
+ */
311
+ addOnValueChange(callback: () => void): void {
312
+ this.onValueChangeCallbacks.push(callback);
313
+ }
314
+ /**
315
+ * Zdarzenie wywoływane w momencie ustawienia stanu wysokiego na wejściu
316
+ * @param callback
317
+ */
318
+ addOnSwitchOn(callback: () => void): void {
319
+ this.onSwitchOnCallbacks.push(callback);
320
+ }
321
+ /**
322
+ * Zdarzenie wywoływane w momencie ustawienia stanu niskiego na wejściu
323
+ * @param callback
324
+ */
325
+ addOnSwitchOff(callback: () => void): void {
326
+ this.onSwitchOffCallbacks.push(callback);
327
+ }
328
+ /**
329
+ * Zdarzenie wywoływane po naciśnięciu przycisku na okres 500 ms - 2000 ms
330
+ * @param callback
331
+ */
332
+ addOnShortPress(callback: () => void): void {
333
+ this.onShortPressCallbacks.push(callback);
334
+ }
335
+ /**
336
+ * Zdarzenie wywoływane po naciśnięciu przycisku na okres dłuższy niż 2000 ms
337
+ * @param callback
338
+ */
339
+ addOnLongPress(callback: () => void): void {
340
+ this.onLongPressCallbacks.push(callback);
341
+ }
342
+ /**
343
+ * Zdarzenie wywoływane gdy wejście jest w stanie wysokim, pierwszy raz po upłynięciu czasu HoldDelay, a następnie cyklicznie co wartość HoldInterval
344
+ * @param callback
345
+ */
346
+ addOnHold(callback: () => void): void {
347
+ this.onHoldCallbacks.push(callback);
348
+ }
349
+ /**
350
+ * Zdarzenie wywoływane po naciśnięciu przycisku na czas krótszy niż 500 ms
351
+ * @param callback
352
+ */
353
+ addOnClick(callback: () => void): void {
354
+ this.onClickCallbacks.push(callback);
355
+ }
356
+ /** Powoduje miganie zielonej diody na przycisku przez 2 sekundy (częstotliwość 500 ms). Czerwona dioda przycisku pozostaje zgaszona */
357
+ showOK(): void {
358
+ this.raw.execute(MethodType.ShowOK, 0);
359
+ }
360
+ /** Powoduje miganie czerwonej diody na przycisku przez 2 sekundy (częstotliwość 500 ms) */
361
+ showError(): void {
362
+ this.raw.execute(MethodType.ShowError, 1);
363
+ }
364
+ /** Załącza zieloną diodę na przycisku */
365
+ ledSwitchOn(): void {
366
+ this.raw.execute(MethodType.LedSwitchOn, 2);
367
+ }
368
+ /** Wyłącza zieloną diodę na przycisku */
369
+ ledSwitchOff(): void {
370
+ this.raw.execute(MethodType.LedSwitchOff, 4);
371
+ }
372
+ /** Zwraca stan wejścia jako 0 lub 1 */
373
+ get value(): boolean {
374
+ return this.raw.get(PropertyType.Value) === 1;
375
+ }
376
+ /** Zwraca ustawiony tryb działania przycisku (0 - monostabilny (Monostable), 1 - bistabilny (Bistable), 2 - zablokowany (Locked)) */
377
+ get mode(): ModeType {
378
+ return this.raw.get(PropertyType.Mode);
379
+ }
380
+ /**
381
+ * Ustawia tryb działania przycisku (0 - monostabilny (Monostable), 1 - bistabilny (Bistable), 2 - zablokowany (Locked))
382
+ * @param {ModeType} value
383
+ */
384
+ setMode(value: ModeType): void {
385
+ this.raw.set(PropertyType.Mode, value);
386
+ }
387
+ /** Czas w milisekundach, po jakim po wciśnięciu i przytrzymaniu przycisku wyzwalane jest zdarzenie OnHold (domyślnie 1000 ms) */
388
+ get holdDelay(): number {
389
+ return this.raw.get(PropertyType.HoldDelay);
390
+ }
391
+ /**
392
+ * Ustawia wartość HoldDelay
393
+ * @param {number} value
394
+ */
395
+ setHoldDelay(value: number): void {
396
+ this.raw.set(PropertyType.HoldDelay, value);
397
+ }
398
+ /** Odstęp cykliczny w milisekundach, po jakim podczas trzymania przycisku wyzwalane są kolejne zdarzenia OnHold */
399
+ get holdInterval(): number {
400
+ return this.raw.get(PropertyType.HoldInterval);
401
+ }
402
+ /**
403
+ * Ustawia wartość HoldInterval
404
+ * @param {number} value
405
+ */
406
+ setHoldInterval(value: number): void {
407
+ this.raw.set(PropertyType.HoldInterval, value);
408
+ }
409
+ /** Grupa Distributed Logic - grupa broadcastowa dla rozproszonej logiki */
410
+ get distributedLogicGroup(): number {
411
+ return this.raw.get(PropertyType.DistributedLogicGroup);
412
+ }
413
+ set distributedLogicGroup(value: number) {
414
+ this.raw.set(PropertyType.DistributedLogicGroup, value);
415
+ }
416
+ }
417
+
418
+ export { Button, ButtonRaw, ButtonRemote, ModeType }
@@ -0,0 +1,238 @@
1
+ // Created from: packages/grenton-api/interfaces/module_2_0_TOUCH_PANEL_FM_8_fv01_02.xml, object name="PANELSENSLIGHT" version="01.02"
2
+
3
+ import { rawExecutionBuilderFactory } from "../../core/execution-builder"
4
+ import { RemoteGate } from "../../core/remote-gate"
5
+
6
+ enum EventType {
7
+ OnValueChange = 0,
8
+ OnValueRise = 1,
9
+ OnValueLower = 2,
10
+ OnOutOfRange = 3,
11
+ }
12
+
13
+ enum PropertyType {
14
+ Value = 0,
15
+ Threshold = 1,
16
+ Sensitivity = 2,
17
+ MinValue = 3,
18
+ MaxValue = 4,
19
+ }
20
+
21
+ declare class PanelSensLightRaw {
22
+ add_event(event: EventType, callback: () => void): void;
23
+ get(property: PropertyType): any;
24
+ set(property: PropertyType, value: any): void;
25
+ }
26
+
27
+ interface IPanelSensLight {
28
+ /**
29
+ * Zdarzenie wywoływane w przypadku zmiany wartości cechy Value
30
+ * @param callback
31
+ */
32
+ addOnValueChange: (callback: () => void) => void
33
+ /**
34
+ * Zdarzenie wywoływane przy zmianie wartości na wyższą (zbocze narastające)
35
+ * @param callback
36
+ */
37
+ addOnValueRise: (callback: () => void) => void
38
+ /**
39
+ * Zdarzenie wywoływane przy zmianie wartości na niższą (zbocze opadające)
40
+ * @param callback
41
+ */
42
+ addOnValueLower: (callback: () => void) => void
43
+ /**
44
+ * Zdarzenie wywoływane, gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
45
+ * @param callback
46
+ */
47
+ addOnOutOfRange: (callback: () => void) => void
48
+ /** Wartość wejścia w zakresie od 0 do 100 % */
49
+ readonly value: number
50
+ /** Wielkość histerezy (dokładność 0.1%) określająca czułość, przy której następuje wygenerowanie zdarzeń: OnValueChange, OnValueLower, OnValueRise */
51
+ threshold: number
52
+ /** Czas (w ms), dla którego próbkowane wartości są uśredniane */
53
+ sensitivity: number
54
+ /** Minimalna wartość cechy Value, której przekroczenie wywołuje zdarzenie OnOutOfRange */
55
+ minValue: number
56
+ /** Maksymalna wartość cechy Value, której przekroczenie wywołuje zdarzenie OnOutOfRange */
57
+ maxValue: number
58
+ }
59
+
60
+ class PanelSensLightRemote implements IPanelSensLight {
61
+ constructor(private objectName: string, private gate: RemoteGate) {
62
+ }
63
+
64
+ addOnValueChange(_callback: () => void): void {
65
+ // Remote events are not supported
66
+ }
67
+ addOnValueRise(_callback: () => void): void {
68
+ // Remote events are not supported
69
+ }
70
+ addOnValueLower(_callback: () => void): void {
71
+ // Remote events are not supported
72
+ }
73
+ addOnOutOfRange(_callback: () => void): void {
74
+ // Remote events are not supported
75
+ }
76
+
77
+ /** Wartość wejścia w zakresie od 0 do 100 % */
78
+ get value(): number {
79
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
80
+ .get()
81
+ .addParameter(PropertyType.Value)
82
+ .build();
83
+ return this.gate.runScript(cmd!);
84
+ }
85
+
86
+ /** Wielkość histerezy (dokładność 0.1%) określająca czułość, przy której następuje wygenerowanie zdarzeń: OnValueChange, OnValueLower, OnValueRise */
87
+ get threshold(): number {
88
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
89
+ .get()
90
+ .addParameter(PropertyType.Threshold)
91
+ .build();
92
+ return this.gate.runScript(cmd!);
93
+ }
94
+ set threshold(value: number) {
95
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
96
+ .set()
97
+ .addParameter(PropertyType.Threshold)
98
+ .addParameter(value)
99
+ .build();
100
+ this.gate.runScript(cmd!);
101
+ }
102
+
103
+ /** Czas (w ms), dla którego próbkowane wartości są uśredniane */
104
+ get sensitivity(): number {
105
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
106
+ .get()
107
+ .addParameter(PropertyType.Sensitivity)
108
+ .build();
109
+ return this.gate.runScript(cmd!);
110
+ }
111
+ set sensitivity(value: number) {
112
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
113
+ .set()
114
+ .addParameter(PropertyType.Sensitivity)
115
+ .addParameter(value)
116
+ .build();
117
+ this.gate.runScript(cmd!);
118
+ }
119
+
120
+ /** Minimalna wartość cechy Value, której przekroczenie wywołuje zdarzenie OnOutOfRange */
121
+ get minValue(): number {
122
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
123
+ .get()
124
+ .addParameter(PropertyType.MinValue)
125
+ .build();
126
+ return this.gate.runScript(cmd!);
127
+ }
128
+ set minValue(value: number) {
129
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
130
+ .set()
131
+ .addParameter(PropertyType.MinValue)
132
+ .addParameter(value)
133
+ .build();
134
+ this.gate.runScript(cmd!);
135
+ }
136
+
137
+ /** Maksymalna wartość cechy Value, której przekroczenie wywołuje zdarzenie OnOutOfRange */
138
+ get maxValue(): number {
139
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
140
+ .get()
141
+ .addParameter(PropertyType.MaxValue)
142
+ .build();
143
+ return this.gate.runScript(cmd!);
144
+ }
145
+ set maxValue(value: number) {
146
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
147
+ .set()
148
+ .addParameter(PropertyType.MaxValue)
149
+ .addParameter(value)
150
+ .build();
151
+ this.gate.runScript(cmd!);
152
+ }
153
+ }
154
+
155
+ class PanelSensLight implements IPanelSensLight {
156
+ private onValueChangeCallbacks: Array<() => void> = [];
157
+ private onValueRiseCallbacks: Array<() => void> = [];
158
+ private onValueLowerCallbacks: Array<() => void> = [];
159
+ private onOutOfRangeCallbacks: Array<() => void> = [];
160
+
161
+ constructor(private raw: PanelSensLightRaw) {
162
+ this.raw.add_event(EventType.OnValueChange, () => {
163
+ this.onValueChangeCallbacks.forEach(callback => { callback(); });
164
+ });
165
+ this.raw.add_event(EventType.OnValueRise, () => {
166
+ this.onValueRiseCallbacks.forEach(callback => { callback(); });
167
+ });
168
+ this.raw.add_event(EventType.OnValueLower, () => {
169
+ this.onValueLowerCallbacks.forEach(callback => { callback(); });
170
+ });
171
+ this.raw.add_event(EventType.OnOutOfRange, () => {
172
+ this.onOutOfRangeCallbacks.forEach(callback => { callback(); });
173
+ });
174
+ }
175
+
176
+ /**
177
+ * Zdarzenie wywoływane w przypadku zmiany wartości cechy Value
178
+ * @param callback
179
+ */
180
+ addOnValueChange(callback: () => void): void {
181
+ this.onValueChangeCallbacks.push(callback);
182
+ }
183
+ /**
184
+ * Zdarzenie wywoływane przy zmianie wartości na wyższą (zbocze narastające)
185
+ * @param callback
186
+ */
187
+ addOnValueRise(callback: () => void): void {
188
+ this.onValueRiseCallbacks.push(callback);
189
+ }
190
+ /**
191
+ * Zdarzenie wywoływane przy zmianie wartości na niższą (zbocze opadające)
192
+ * @param callback
193
+ */
194
+ addOnValueLower(callback: () => void): void {
195
+ this.onValueLowerCallbacks.push(callback);
196
+ }
197
+ /**
198
+ * Zdarzenie wywoływane, gdy wartość na wejściu znajduje się poza wyznaczonym zakresem (MinValue - MaxValue)
199
+ * @param callback
200
+ */
201
+ addOnOutOfRange(callback: () => void): void {
202
+ this.onOutOfRangeCallbacks.push(callback);
203
+ }
204
+ /** Wartość wejścia w zakresie od 0 do 100 % */
205
+ get value(): number {
206
+ return this.raw.get(PropertyType.Value);
207
+ }
208
+ /** Wielkość histerezy (dokładność 0.1%) określająca czułość, przy której następuje wygenerowanie zdarzeń: OnValueChange, OnValueLower, OnValueRise */
209
+ get threshold(): number {
210
+ return this.raw.get(PropertyType.Threshold);
211
+ }
212
+ set threshold(value: number) {
213
+ this.raw.set(PropertyType.Threshold, value);
214
+ }
215
+ /** Czas (w ms), dla którego próbkowane wartości są uśredniane */
216
+ get sensitivity(): number {
217
+ return this.raw.get(PropertyType.Sensitivity);
218
+ }
219
+ set sensitivity(value: number) {
220
+ this.raw.set(PropertyType.Sensitivity, value);
221
+ }
222
+ /** Minimalna wartość cechy Value, której przekroczenie wywołuje zdarzenie OnOutOfRange */
223
+ get minValue(): number {
224
+ return this.raw.get(PropertyType.MinValue);
225
+ }
226
+ set minValue(value: number) {
227
+ this.raw.set(PropertyType.MinValue, value);
228
+ }
229
+ /** Maksymalna wartość cechy Value, której przekroczenie wywołuje zdarzenie OnOutOfRange */
230
+ get maxValue(): number {
231
+ return this.raw.get(PropertyType.MaxValue);
232
+ }
233
+ set maxValue(value: number) {
234
+ this.raw.set(PropertyType.MaxValue, value);
235
+ }
236
+ }
237
+
238
+ export { PanelSensLight, PanelSensLightRaw, PanelSensLightRemote }