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,171 @@
1
+ // Created from: packages/grenton-api/interfaces/object_satel_input_v1.xml, object name="SatelInput" version="1"
2
+
3
+ import { rawExecutionBuilderFactory } from "../../../core/execution-builder"
4
+ import { RemoteGate } from "../../../core/remote-gate"
5
+
6
+ enum EventType {
7
+ OnChange = 0,
8
+ OnSwitchOn = 1,
9
+ OnSwitchOff = 2
10
+ }
11
+
12
+ enum PropertyType {
13
+ Value = 0,
14
+ Nr = 1
15
+ }
16
+
17
+ enum ValueType {
18
+ Normal = 0,
19
+ Violated = 1
20
+ }
21
+
22
+ declare class SatelInputRaw {
23
+ add_event(event: EventType, callback: () => void): void;
24
+ get(property: PropertyType): any;
25
+ set(property: PropertyType, value: any): void;
26
+ execute(method: number, ...args: any[]): any;
27
+ }
28
+
29
+ interface ISatelInput {
30
+ /**
31
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
32
+ * @param callback
33
+ */
34
+ addOnChange: (callback: () => void) => void
35
+ /**
36
+ * Zdarzenie wywoływane przy ustawieniu Violated na wejściu
37
+ * @param callback
38
+ */
39
+ addOnSwitchOn: (callback: () => void) => void
40
+ /**
41
+ * Zdarzenie wywoływane przy ustawieniu Normal na wejściu
42
+ * @param callback
43
+ */
44
+ addOnSwitchOff: (callback: () => void) => void
45
+ /** Zwraca stan wejścia: 1 - wejście naruszone, 0 - wejście nienaruszone, -1 - stan wejścia nieznany (brak połączenia z centralką) */
46
+ readonly value: ValueType
47
+ /** Parametr definiujący, do którego wejścia odnosi się obiekt */
48
+ nr: number
49
+ }
50
+
51
+ class SatelInput implements ISatelInput {
52
+ private onChangeCallbacks: Array<() => void> = [];
53
+ private onSwitchOnCallbacks: Array<() => void> = [];
54
+ private onSwitchOffCallbacks: Array<() => void> = [];
55
+
56
+ constructor(private raw: SatelInputRaw) {
57
+ this.raw.add_event(EventType.OnChange, () => {
58
+ this.onChangeCallbacks.forEach(callback => { callback(); });
59
+ });
60
+ this.raw.add_event(EventType.OnSwitchOn, () => {
61
+ this.onSwitchOnCallbacks.forEach(callback => { callback(); });
62
+ });
63
+ this.raw.add_event(EventType.OnSwitchOff, () => {
64
+ this.onSwitchOffCallbacks.forEach(callback => { callback(); });
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
70
+ * @param callback
71
+ */
72
+ addOnChange(callback: () => void): void {
73
+ this.onChangeCallbacks.push(callback);
74
+ }
75
+ /**
76
+ * Zdarzenie wywoływane przy ustawieniu Violated na wejściu
77
+ * @param callback
78
+ */
79
+ addOnSwitchOn(callback: () => void): void {
80
+ this.onSwitchOnCallbacks.push(callback);
81
+ }
82
+ /**
83
+ * Zdarzenie wywoływane przy ustawieniu Normal na wejściu
84
+ * @param callback
85
+ */
86
+ addOnSwitchOff(callback: () => void): void {
87
+ this.onSwitchOffCallbacks.push(callback);
88
+ }
89
+ /**
90
+ * Zwraca stan wejścia: 1 - wejście naruszone, 0 - wejście nienaruszone, -1 - stan wejścia nieznany (brak połączenia z centralką)
91
+ * @returns {ValueType}
92
+ */
93
+ get value(): ValueType {
94
+ return this.raw.get(PropertyType.Value);
95
+ }
96
+ /**
97
+ * Parametr definiujący, do którego wejścia odnosi się obiekt
98
+ * @returns {number}
99
+ */
100
+ get nr(): number {
101
+ return this.raw.get(PropertyType.Nr);
102
+ }
103
+ set nr(value: number) {
104
+ this.raw.set(PropertyType.Nr, value);
105
+ }
106
+ }
107
+
108
+ class SatelInputRemote implements ISatelInput {
109
+ constructor(private objectName: string, private gate: RemoteGate) {
110
+
111
+ }
112
+
113
+ /**
114
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
115
+ * @param callback
116
+ */
117
+ addOnChange(_callback: () => void): void {
118
+ // Remote events are not supported
119
+ }
120
+ /**
121
+ * Zdarzenie wywoływane przy ustawieniu Violated na wejściu
122
+ * @param callback
123
+ */
124
+ addOnSwitchOn(_callback: () => void): void {
125
+ // Remote events are not supported
126
+ }
127
+ /**
128
+ * Zdarzenie wywoływane przy ustawieniu Normal na wejściu
129
+ * @param callback
130
+ */
131
+ addOnSwitchOff(_callback: () => void): void {
132
+ // Remote events are not supported
133
+ }
134
+
135
+ /**
136
+ * Zwraca stan wejścia: 1 - wejście naruszone, 0 - wejście nienaruszone, -1 - stan wejścia nieznany (brak połączenia z centralką)
137
+ * @returns {ValueType}
138
+ */
139
+ get value(): ValueType {
140
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
141
+ .get()
142
+ .addParameter(PropertyType.Value)
143
+ .build();
144
+ return this.gate.runScript(cmd!);
145
+ }
146
+
147
+ /**
148
+ * Parametr definiujący, do którego wejścia odnosi się obiekt
149
+ * @returns {number}
150
+ */
151
+ get nr(): number {
152
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
153
+ .get()
154
+ .addParameter(PropertyType.Nr)
155
+ .build();
156
+ return this.gate.runScript(cmd!);
157
+ }
158
+
159
+ set nr(value: number) {
160
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
161
+ .set()
162
+ .addParameter(PropertyType.Nr)
163
+ .addParameter(value)
164
+ .build();
165
+ this.gate.runScript(cmd!);
166
+ }
167
+ }
168
+
169
+ export {
170
+ SatelInput, SatelInputRaw, SatelInputRemote, ValueType
171
+ }
@@ -0,0 +1,240 @@
1
+ // Created from: packages/grenton-api/interfaces/object_satel_output_v1.xml, object name="SatelOutput" version="1"
2
+
3
+ import { rawExecutionBuilderFactory } from "../../../core/execution-builder"
4
+ import { RemoteGate } from "../../../core/remote-gate"
5
+
6
+ enum EventType {
7
+ OnChange = 0,
8
+ OnSwitchOn = 1,
9
+ OnSwitchOff = 2
10
+ }
11
+
12
+ enum PropertyType {
13
+ Value = 0,
14
+ Nr = 1,
15
+ UserPassword = 2
16
+ }
17
+
18
+ enum MethodType {
19
+ SwitchOn = 0,
20
+ SwitchOff = 1
21
+ }
22
+
23
+ enum ValueType {
24
+ Off = 0,
25
+ On = 1
26
+ }
27
+
28
+ declare class SatelOutputRaw {
29
+ add_event(event: EventType, callback: () => void): void;
30
+ get(property: PropertyType): any;
31
+ set(property: PropertyType, value: any): void;
32
+ execute(method: MethodType, ...args: any[]): any;
33
+ }
34
+
35
+ interface ISatelOutput {
36
+ /**
37
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
38
+ * @param callback
39
+ */
40
+ addOnChange: (callback: () => void) => void
41
+ /**
42
+ * Zdarzenie wywoływane przy ustawieniu On na wyjściu
43
+ * @param callback
44
+ */
45
+ addOnSwitchOn: (callback: () => void) => void
46
+ /**
47
+ * Zdarzenie wywoływane przy ustawieniu Off na wyjściu
48
+ * @param callback
49
+ */
50
+ addOnSwitchOff: (callback: () => void) => void
51
+ /** Załącza wyjście */
52
+ switchOn: () => void
53
+ /** Wyłącza wyjście */
54
+ switchOff: () => void
55
+ /** Zwraca stan wyjścia: 1 - wyjście załączone, 0 - wyjście wyłączone, -1 - stan wyjścia nieznany (brak połączenia z centralką) */
56
+ readonly value: ValueType
57
+ /** Parametr definiujący, do którego wyjścia odnosi się obiekt */
58
+ nr: number
59
+ /** Hasło użytkownika, dla _ zastosuje hasło administratora */
60
+ userPassword: string
61
+ }
62
+
63
+ class SatelOutput implements ISatelOutput {
64
+ private onChangeCallbacks: Array<() => void> = [];
65
+ private onSwitchOnCallbacks: Array<() => void> = [];
66
+ private onSwitchOffCallbacks: Array<() => void> = [];
67
+
68
+ constructor(private raw: SatelOutputRaw) {
69
+ this.raw.add_event(EventType.OnChange, () => {
70
+ this.onChangeCallbacks.forEach(callback => { callback(); });
71
+ });
72
+ this.raw.add_event(EventType.OnSwitchOn, () => {
73
+ this.onSwitchOnCallbacks.forEach(callback => { callback(); });
74
+ });
75
+ this.raw.add_event(EventType.OnSwitchOff, () => {
76
+ this.onSwitchOffCallbacks.forEach(callback => { callback(); });
77
+ });
78
+ }
79
+
80
+ /**
81
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
82
+ * @param callback
83
+ */
84
+ addOnChange(callback: () => void): void {
85
+ this.onChangeCallbacks.push(callback);
86
+ }
87
+ /**
88
+ * Zdarzenie wywoływane przy ustawieniu On na wyjściu
89
+ * @param callback
90
+ */
91
+ addOnSwitchOn(callback: () => void): void {
92
+ this.onSwitchOnCallbacks.push(callback);
93
+ }
94
+ /**
95
+ * Zdarzenie wywoływane przy ustawieniu Off na wyjściu
96
+ * @param callback
97
+ */
98
+ addOnSwitchOff(callback: () => void): void {
99
+ this.onSwitchOffCallbacks.push(callback);
100
+ }
101
+ /** Załącza wyjście */
102
+ switchOn(): void {
103
+ this.raw.execute(MethodType.SwitchOn);
104
+ }
105
+ /** Wyłącza wyjście */
106
+ switchOff(): void {
107
+ this.raw.execute(MethodType.SwitchOff);
108
+ }
109
+ /**
110
+ * Zwraca stan wyjścia: 1 - wyjście załączone, 0 - wyjście wyłączone, -1 - stan wyjścia nieznany (brak połączenia z centralką)
111
+ * @returns {ValueType}
112
+ */
113
+ get value(): ValueType {
114
+ return this.raw.get(PropertyType.Value);
115
+ }
116
+ /**
117
+ * Parametr definiujący, do którego wyjścia odnosi się obiekt
118
+ * @returns {number}
119
+ */
120
+ get nr(): number {
121
+ return this.raw.get(PropertyType.Nr);
122
+ }
123
+ set nr(value: number) {
124
+ this.raw.set(PropertyType.Nr, value);
125
+ }
126
+ /**
127
+ * Hasło użytkownika, dla _ zastosuje hasło administratora
128
+ * @returns {string}
129
+ */
130
+ get userPassword(): string {
131
+ return this.raw.get(PropertyType.UserPassword);
132
+ }
133
+ set userPassword(value: string) {
134
+ this.raw.set(PropertyType.UserPassword, value);
135
+ }
136
+ }
137
+
138
+ class SatelOutputRemote implements ISatelOutput {
139
+ constructor(private objectName: string, private gate: RemoteGate) {
140
+
141
+ }
142
+
143
+ /**
144
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
145
+ * @param callback
146
+ */
147
+ addOnChange(_callback: () => void): void {
148
+ // Remote events are not supported
149
+ }
150
+ /**
151
+ * Zdarzenie wywoływane przy ustawieniu On na wyjściu
152
+ * @param callback
153
+ */
154
+ addOnSwitchOn(_callback: () => void): void {
155
+ // Remote events are not supported
156
+ }
157
+ /**
158
+ * Zdarzenie wywoływane przy ustawieniu Off na wyjściu
159
+ * @param callback
160
+ */
161
+ addOnSwitchOff(_callback: () => void): void {
162
+ // Remote events are not supported
163
+ }
164
+
165
+ /** Załącza wyjście */
166
+ switchOn(): void {
167
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
168
+ .execute()
169
+ .addParameter(MethodType.SwitchOn)
170
+ .build();
171
+ this.gate.runScript(cmd!);
172
+ }
173
+
174
+ /** Wyłącza wyjście */
175
+ switchOff(): void {
176
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
177
+ .execute()
178
+ .addParameter(MethodType.SwitchOff)
179
+ .build();
180
+ this.gate.runScript(cmd!);
181
+ }
182
+
183
+ /**
184
+ * Zwraca stan wyjścia: 1 - wyjście załączone, 0 - wyjście wyłączone, -1 - stan wyjścia nieznany (brak połączenia z centralką)
185
+ * @returns {ValueType}
186
+ */
187
+ get value(): ValueType {
188
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
189
+ .get()
190
+ .addParameter(PropertyType.Value)
191
+ .build();
192
+ return this.gate.runScript(cmd!);
193
+ }
194
+
195
+ /**
196
+ * Parametr definiujący, do którego wyjścia odnosi się obiekt
197
+ * @returns {number}
198
+ */
199
+ get nr(): number {
200
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
201
+ .get()
202
+ .addParameter(PropertyType.Nr)
203
+ .build();
204
+ return this.gate.runScript(cmd!);
205
+ }
206
+
207
+ set nr(value: number) {
208
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
209
+ .set()
210
+ .addParameter(PropertyType.Nr)
211
+ .addParameter(value)
212
+ .build();
213
+ this.gate.runScript(cmd!);
214
+ }
215
+
216
+ /**
217
+ * Hasło użytkownika, dla _ zastosuje hasło administratora
218
+ * @returns {string}
219
+ */
220
+ get userPassword(): string {
221
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
222
+ .get()
223
+ .addParameter(PropertyType.UserPassword)
224
+ .build();
225
+ return this.gate.runScript(cmd!);
226
+ }
227
+
228
+ set userPassword(value: string) {
229
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
230
+ .set()
231
+ .addParameter(PropertyType.UserPassword)
232
+ .addParameter(value)
233
+ .build();
234
+ this.gate.runScript(cmd!);
235
+ }
236
+ }
237
+
238
+ export {
239
+ SatelOutput, SatelOutputRaw, SatelOutputRemote, ValueType
240
+ }
@@ -0,0 +1,235 @@
1
+ // Created from: packages/grenton-api/interfaces/object_satel_zone_v1.xml, object name="SatelZone" version="1"
2
+
3
+ import { rawExecutionBuilderFactory } from "../../../core/execution-builder"
4
+ import { RemoteGate } from "../../../core/remote-gate"
5
+
6
+ enum EventType {
7
+ OnChange = 0,
8
+ OnArm = 1,
9
+ OnDisarm = 2
10
+ }
11
+
12
+ enum PropertyType {
13
+ Value = 0,
14
+ Nr = 1,
15
+ UserPassword = 2
16
+ }
17
+
18
+ enum MethodType {
19
+ ArmZone = 0,
20
+ DisarmZone = 1
21
+ }
22
+
23
+ declare class SatelZoneRaw {
24
+ add_event(event: EventType, callback: () => void): void;
25
+ get(property: PropertyType): any;
26
+ set(property: PropertyType, value: any): void;
27
+ execute(method: MethodType, ...args: any[]): any;
28
+ }
29
+
30
+ interface ISatelZone {
31
+ /**
32
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
33
+ * @param callback
34
+ */
35
+ addOnChange: (callback: () => void) => void
36
+ /**
37
+ * Zdarzenie wywoływane przy uzbrojeniu strefy
38
+ * @param callback
39
+ */
40
+ addOnArm: (callback: () => void) => void
41
+ /**
42
+ * Zdarzenie wywoływane przy rozbrojeniu strefy
43
+ * @param callback
44
+ */
45
+ addOnDisarm: (callback: () => void) => void
46
+ /** Uzbraja strefę */
47
+ armZone: () => void
48
+ /** Rozbraja strefę */
49
+ disarmZone: () => void
50
+ /** Zwraca stan strefy: 1 - strefa uzbrojona, 0 - strefa rozbrojona, -1 - stan strefy nieznany (brak połączenia z centralką) */
51
+ readonly value: number
52
+ /** Parametr definiujący, do której strefy odnosi się obiekt */
53
+ nr: number
54
+ /** Hasło użytkownika, dla '_' zastosuje hasło administratora */
55
+ userPassword: string
56
+ }
57
+
58
+ class SatelZone implements ISatelZone {
59
+ private onChangeCallbacks: Array<() => void> = [];
60
+ private onArmCallbacks: Array<() => void> = [];
61
+ private onDisarmCallbacks: Array<() => void> = [];
62
+
63
+ constructor(private raw: SatelZoneRaw) {
64
+ this.raw.add_event(EventType.OnChange, () => {
65
+ this.onChangeCallbacks.forEach(callback => { callback(); });
66
+ });
67
+ this.raw.add_event(EventType.OnArm, () => {
68
+ this.onArmCallbacks.forEach(callback => { callback(); });
69
+ });
70
+ this.raw.add_event(EventType.OnDisarm, () => {
71
+ this.onDisarmCallbacks.forEach(callback => { callback(); });
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
77
+ * @param callback
78
+ */
79
+ addOnChange(callback: () => void): void {
80
+ this.onChangeCallbacks.push(callback);
81
+ }
82
+ /**
83
+ * Zdarzenie wywoływane przy uzbrojeniu strefy
84
+ * @param callback
85
+ */
86
+ addOnArm(callback: () => void): void {
87
+ this.onArmCallbacks.push(callback);
88
+ }
89
+ /**
90
+ * Zdarzenie wywoływane przy rozbrojeniu strefy
91
+ * @param callback
92
+ */
93
+ addOnDisarm(callback: () => void): void {
94
+ this.onDisarmCallbacks.push(callback);
95
+ }
96
+ /** Uzbraja strefę */
97
+ armZone(): void {
98
+ this.raw.execute(MethodType.ArmZone);
99
+ }
100
+ /** Rozbraja strefę */
101
+ disarmZone(): void {
102
+ this.raw.execute(MethodType.DisarmZone);
103
+ }
104
+ /**
105
+ * Zwraca stan strefy: 1 - strefa uzbrojona, 0 - strefa rozbrojona, -1 - stan strefy nieznany (brak połączenia z centralką)
106
+ * @returns {number}
107
+ */
108
+ get value(): number {
109
+ return this.raw.get(PropertyType.Value);
110
+ }
111
+ /**
112
+ * Parametr definiujący, do której strefy odnosi się obiekt
113
+ * @returns {number}
114
+ */
115
+ get nr(): number {
116
+ return this.raw.get(PropertyType.Nr);
117
+ }
118
+ set nr(value: number) {
119
+ this.raw.set(PropertyType.Nr, value);
120
+ }
121
+ /**
122
+ * Hasło użytkownika, dla '_' zastosuje hasło administratora
123
+ * @returns {string}
124
+ */
125
+ get userPassword(): string {
126
+ return this.raw.get(PropertyType.UserPassword);
127
+ }
128
+ set userPassword(value: string) {
129
+ this.raw.set(PropertyType.UserPassword, value);
130
+ }
131
+ }
132
+
133
+ class SatelZoneRemote implements ISatelZone {
134
+ constructor(private objectName: string, private gate: RemoteGate) {
135
+
136
+ }
137
+
138
+ /**
139
+ * Zdarzenie wywoływane przy zmianie stanu (niezależnie od wartości)
140
+ * @param callback
141
+ */
142
+ addOnChange(_callback: () => void): void {
143
+ // Remote events are not supported
144
+ }
145
+ /**
146
+ * Zdarzenie wywoływane przy uzbrojeniu strefy
147
+ * @param callback
148
+ */
149
+ addOnArm(_callback: () => void): void {
150
+ // Remote events are not supported
151
+ }
152
+ /**
153
+ * Zdarzenie wywoływane przy rozbrojeniu strefy
154
+ * @param callback
155
+ */
156
+ addOnDisarm(_callback: () => void): void {
157
+ // Remote events are not supported
158
+ }
159
+
160
+ /** Uzbraja strefę */
161
+ armZone(): void {
162
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
163
+ .execute()
164
+ .addParameter(MethodType.ArmZone)
165
+ .build();
166
+ this.gate.runScript(cmd!);
167
+ }
168
+
169
+ /** Rozbraja strefę */
170
+ disarmZone(): void {
171
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
172
+ .execute()
173
+ .addParameter(MethodType.DisarmZone)
174
+ .build();
175
+ this.gate.runScript(cmd!);
176
+ }
177
+
178
+ /**
179
+ * Zwraca stan strefy: 1 - strefa uzbrojona, 0 - strefa rozbrojona, -1 - stan strefy nieznany (brak połączenia z centralką)
180
+ * @returns {number}
181
+ */
182
+ get value(): number {
183
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
184
+ .get()
185
+ .addParameter(PropertyType.Value)
186
+ .build();
187
+ return this.gate.runScript(cmd!);
188
+ }
189
+
190
+ /**
191
+ * Parametr definiujący, do której strefy odnosi się obiekt
192
+ * @returns {number}
193
+ */
194
+ get nr(): number {
195
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
196
+ .get()
197
+ .addParameter(PropertyType.Nr)
198
+ .build();
199
+ return this.gate.runScript(cmd!);
200
+ }
201
+
202
+ set nr(value: number) {
203
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
204
+ .set()
205
+ .addParameter(PropertyType.Nr)
206
+ .addParameter(value)
207
+ .build();
208
+ this.gate.runScript(cmd!);
209
+ }
210
+
211
+ /**
212
+ * Hasło użytkownika, dla '_' zastosuje hasło administratora
213
+ * @returns {string}
214
+ */
215
+ get userPassword(): string {
216
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
217
+ .get()
218
+ .addParameter(PropertyType.UserPassword)
219
+ .build();
220
+ return this.gate.runScript(cmd!);
221
+ }
222
+
223
+ set userPassword(value: string) {
224
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
225
+ .set()
226
+ .addParameter(PropertyType.UserPassword)
227
+ .addParameter(value)
228
+ .build();
229
+ this.gate.runScript(cmd!);
230
+ }
231
+ }
232
+
233
+ export {
234
+ SatelZone, SatelZoneRaw, SatelZoneRemote
235
+ }