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_input_v1.xml, object name="Input" 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 InputRaw {
23
+ add_event(event: EventType, callback: () => void): void;
24
+ get(property: PropertyType): any;
25
+ set(property: PropertyType, value: any): void;
26
+ execute(method: never, ...args: any[]): any;
27
+ }
28
+
29
+ interface IInput {
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 Input implements IInput {
52
+ private onChangeCallbacks: Array<() => void> = [];
53
+ private onSwitchOnCallbacks: Array<() => void> = [];
54
+ private onSwitchOffCallbacks: Array<() => void> = [];
55
+
56
+ constructor(private raw: InputRaw) {
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 InputRemote implements IInput {
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
+ Input, InputRaw, InputRemote, ValueType
171
+ }
@@ -0,0 +1,100 @@
1
+ // Created from: packages/grenton-api/interfaces/object_jablotron_v1.xml, object name="Jablotron" version="1"
2
+
3
+ import { rawExecutionBuilderFactory } from "../../../core/execution-builder"
4
+ import { RemoteGate } from "../../../core/remote-gate"
5
+
6
+ enum PropertyType {
7
+ AdminCode = 0,
8
+ UpdatePeriod = 1
9
+ }
10
+
11
+ declare class JablotronRaw {
12
+ get(property: PropertyType): any;
13
+ set(property: PropertyType, value: any): void;
14
+ execute(method: never, ...args: any[]): any;
15
+ }
16
+
17
+ interface IJablotron {
18
+ /** Kod dostępu administratora */
19
+ adminCode: string
20
+ /** Okres aktualizacji stanu centralki */
21
+ updatePeriod: number
22
+ }
23
+
24
+ class Jablotron implements IJablotron {
25
+ constructor(private raw: JablotronRaw) {
26
+ }
27
+
28
+ /**
29
+ * Kod dostępu administratora
30
+ * @returns {string}
31
+ */
32
+ get adminCode(): string {
33
+ return this.raw.get(PropertyType.AdminCode);
34
+ }
35
+ set adminCode(value: string) {
36
+ this.raw.set(PropertyType.AdminCode, value);
37
+ }
38
+ /**
39
+ * Okres aktualizacji stanu centralki
40
+ * @returns {number}
41
+ */
42
+ get updatePeriod(): number {
43
+ return this.raw.get(PropertyType.UpdatePeriod);
44
+ }
45
+ set updatePeriod(value: number) {
46
+ this.raw.set(PropertyType.UpdatePeriod, value);
47
+ }
48
+ }
49
+
50
+ class JablotronRemote implements IJablotron {
51
+ constructor(private objectName: string, private gate: RemoteGate) {
52
+
53
+ }
54
+
55
+ /**
56
+ * Kod dostępu administratora
57
+ * @returns {string}
58
+ */
59
+ get adminCode(): string {
60
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
61
+ .get()
62
+ .addParameter(PropertyType.AdminCode)
63
+ .build();
64
+ return this.gate.runScript(cmd!);
65
+ }
66
+
67
+ set adminCode(value: string) {
68
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
69
+ .set()
70
+ .addParameter(PropertyType.AdminCode)
71
+ .addParameter(value)
72
+ .build();
73
+ this.gate.runScript(cmd!);
74
+ }
75
+
76
+ /**
77
+ * Okres aktualizacji stanu centralki
78
+ * @returns {number}
79
+ */
80
+ get updatePeriod(): number {
81
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
82
+ .get()
83
+ .addParameter(PropertyType.UpdatePeriod)
84
+ .build();
85
+ return this.gate.runScript(cmd!);
86
+ }
87
+
88
+ set updatePeriod(value: number) {
89
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
90
+ .set()
91
+ .addParameter(PropertyType.UpdatePeriod)
92
+ .addParameter(value)
93
+ .build();
94
+ this.gate.runScript(cmd!);
95
+ }
96
+ }
97
+
98
+ export {
99
+ Jablotron, JablotronRaw, JablotronRemote
100
+ }
@@ -0,0 +1,171 @@
1
+ // Created from: packages/grenton-api/interfaces/object_jablotron_device_v1.xml, object name="JablotronDevice" 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 JablotronDeviceRaw {
23
+ add_event(event: EventType, callback: () => void): void;
24
+ get(property: PropertyType): any;
25
+ set(property: PropertyType, value: any): void;
26
+ execute(method: never, ...args: any[]): any;
27
+ }
28
+
29
+ interface IJablotronDevice {
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 JablotronDevice implements IJablotronDevice {
52
+ private onChangeCallbacks: Array<() => void> = [];
53
+ private onSwitchOnCallbacks: Array<() => void> = [];
54
+ private onSwitchOffCallbacks: Array<() => void> = [];
55
+
56
+ constructor(private raw: JablotronDeviceRaw) {
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 JablotronDeviceRemote implements IJablotronDevice {
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
+ JablotronDevice, JablotronDeviceRaw, JablotronDeviceRemote, ValueType
171
+ }
@@ -0,0 +1,240 @@
1
+ // Created from: packages/grenton-api/interfaces/object_jablotron_output_v1.xml, object name="JablotronOutput" 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
+ State = 0,
14
+ Nr = 1,
15
+ AccessCode = 2
16
+ }
17
+
18
+ enum MethodType {
19
+ SwitchOn = 0,
20
+ SwitchOff = 1
21
+ }
22
+
23
+ enum StateType {
24
+ Off = 0,
25
+ On = 1
26
+ }
27
+
28
+ declare class JablotronOutputRaw {
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 IJablotronOutput {
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 state: StateType
57
+ /** Parametr definiujący, do którego wyjścia odnosi się obiekt */
58
+ nr: number
59
+ /** Kod dostępu, dla * zastosuje kod administratora */
60
+ accessCode: string
61
+ }
62
+
63
+ class JablotronOutput implements IJablotronOutput {
64
+ private onChangeCallbacks: Array<() => void> = [];
65
+ private onSwitchOnCallbacks: Array<() => void> = [];
66
+ private onSwitchOffCallbacks: Array<() => void> = [];
67
+
68
+ constructor(private raw: JablotronOutputRaw) {
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 {StateType}
112
+ */
113
+ get state(): StateType {
114
+ return this.raw.get(PropertyType.State);
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
+ * Kod dostępu, dla * zastosuje kod administratora
128
+ * @returns {string}
129
+ */
130
+ get accessCode(): string {
131
+ return this.raw.get(PropertyType.AccessCode);
132
+ }
133
+ set accessCode(value: string) {
134
+ this.raw.set(PropertyType.AccessCode, value);
135
+ }
136
+ }
137
+
138
+ class JablotronOutputRemote implements IJablotronOutput {
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 {StateType}
186
+ */
187
+ get state(): StateType {
188
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
189
+ .get()
190
+ .addParameter(PropertyType.State)
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
+ * Kod dostępu, dla * zastosuje kod administratora
218
+ * @returns {string}
219
+ */
220
+ get accessCode(): string {
221
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
222
+ .get()
223
+ .addParameter(PropertyType.AccessCode)
224
+ .build();
225
+ return this.gate.runScript(cmd!);
226
+ }
227
+
228
+ set accessCode(value: string) {
229
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
230
+ .set()
231
+ .addParameter(PropertyType.AccessCode)
232
+ .addParameter(value)
233
+ .build();
234
+ this.gate.runScript(cmd!);
235
+ }
236
+ }
237
+
238
+ export {
239
+ JablotronOutput, JablotronOutputRaw, JablotronOutputRemote, StateType
240
+ }