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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rpaczkow
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# grenton-ts
|
|
2
|
+
|
|
3
|
+
TypeScript API library for [Grenton](https://grenton.com) smart home hardware modules. Provides type-safe wrappers around the low-level Grenton hardware interfaces, making it easier to interact with Grenton devices in TypeScript projects.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Grenton devices expose a raw Lua-based API. This library wraps those raw interfaces with typed TypeScript classes, giving you:
|
|
8
|
+
|
|
9
|
+
- **Typed properties** with getters/setters
|
|
10
|
+
- **Typed events** with callback registration
|
|
11
|
+
- **Typed methods** for executing device commands
|
|
12
|
+
- **Remote variants** for cross-gate (CLU-to-CLU) communication
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Each hardware module directory contains firmware-versioned subdirectories (e.g. `fv03_02`) so multiple firmware versions of the same module can coexist.
|
|
17
|
+
|
|
18
|
+
## Architecture
|
|
19
|
+
|
|
20
|
+
Every module follows the same three-layer pattern:
|
|
21
|
+
|
|
22
|
+
### 1. Raw Interface (`*Raw`)
|
|
23
|
+
|
|
24
|
+
A `declare class` mirroring the low-level hardware API:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
declare class RollerShutterRaw {
|
|
28
|
+
add_event(event: EventType, callback: () => void): void;
|
|
29
|
+
get(property: PropertyType): any;
|
|
30
|
+
set(property: PropertyType, value: any): void;
|
|
31
|
+
execute(method: MethodType, ...args: any[]): any;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Wrapper Class
|
|
36
|
+
|
|
37
|
+
A high-level class that takes the raw interface in its constructor and exposes typed methods, properties, and event registration:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { RollerShutter, RollerShutterRaw } from './roller-shutter-din-3/fv03_02/roller-shutter';
|
|
41
|
+
|
|
42
|
+
const shutter = new RollerShutter(rawRollerShutter);
|
|
43
|
+
|
|
44
|
+
// Events
|
|
45
|
+
shutter.addOnPositionChange(() => {
|
|
46
|
+
console.log('Position:', shutter.position);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Methods
|
|
50
|
+
shutter.moveUp(5000); // move up for 5 seconds
|
|
51
|
+
shutter.setPosition(50); // set to 50% open
|
|
52
|
+
|
|
53
|
+
// Properties
|
|
54
|
+
logInfo(shutter.state); // StateType enum value
|
|
55
|
+
logInfo(shutter.position); // number (0–100)
|
|
56
|
+
shutter.maxTime = 30000; // read/write property
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 3. Remote Variant (`*Remote`)
|
|
60
|
+
|
|
61
|
+
For controlling devices on a different CLU via `RemoteGate`. Uses `rawExecutionBuilderFactory` to build command strings sent over the gate. Remote events are not supported.
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { RollerShutterRemote } from './roller-shutter-din-3/fv03_02/roller-shutter';
|
|
65
|
+
import { RemoteGate } from './core/remote-gate';
|
|
66
|
+
|
|
67
|
+
const gate = new RemoteGate(rawRemoteGate);
|
|
68
|
+
const shutter = new RollerShutterRemote('ROLLER_SHUTTER_1', gate);
|
|
69
|
+
|
|
70
|
+
shutter.moveUp(5000);
|
|
71
|
+
shutter.setPosition(75);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## Build
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm run build # compile TypeScript → dist/
|
|
79
|
+
npm run watch # watch mode
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Requires Node.js with TypeScript 5.x (`devDependency`). Compiled output goes to `dist/`.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { rawExecutionBuilderFactory } from "../../core/execution-builder"
|
|
2
|
+
import { RemoteGate } from "../../core/remote-gate"
|
|
3
|
+
|
|
4
|
+
enum EventType {
|
|
5
|
+
OnValueChange = 0,
|
|
6
|
+
OnValueLower = 1,
|
|
7
|
+
OnValueRise = 2,
|
|
8
|
+
OnOutOfRange = 3,
|
|
9
|
+
OnSwitchOn = 4,
|
|
10
|
+
OnSwitchOff = 5,
|
|
11
|
+
OnInRange = 6
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
enum PropertyType {
|
|
15
|
+
Value = 0,
|
|
16
|
+
ValuesPercent = 1,
|
|
17
|
+
Scale = 2,
|
|
18
|
+
Sensivity = 3,
|
|
19
|
+
RawValue = 4,
|
|
20
|
+
MinValue = 5,
|
|
21
|
+
MaxValue = 6
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
enum MethodType {}
|
|
25
|
+
|
|
26
|
+
declare class AnalogInRaw {
|
|
27
|
+
add_event(event: EventType, callback: () => void): void
|
|
28
|
+
set(property: PropertyType, value: any): void
|
|
29
|
+
get(property: PropertyType): any
|
|
30
|
+
execute(method: MethodType, ...args: any[]): void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface IAnalogIn {
|
|
34
|
+
addOnValueChange: (callback: () => void) => void
|
|
35
|
+
addOnValueLower: (callback: () => void) => void
|
|
36
|
+
addOnValueRise: (callback: () => void) => void
|
|
37
|
+
addOnOutOfRange: (callback: () => void) => void
|
|
38
|
+
addOnSwitchOn: (callback: () => void) => void
|
|
39
|
+
addOnSwitchOff: (callback: () => void) => void
|
|
40
|
+
addOnInRange: (callback: () => void) => void
|
|
41
|
+
readonly rawValue: number
|
|
42
|
+
readonly value: number
|
|
43
|
+
readonly valuePercent: number
|
|
44
|
+
scale: number
|
|
45
|
+
sensivity: number
|
|
46
|
+
minValue: number
|
|
47
|
+
maxValue: number
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class AnalogIn implements IAnalogIn{
|
|
51
|
+
private onValueChangeCallbacks: Array<() => void> = [];
|
|
52
|
+
private onValueLowerCallbacks: Array<() => void> = [];
|
|
53
|
+
private onValueRiseCallbacks: Array<() => void> = [];
|
|
54
|
+
private onOutOfRangeCallbacks: Array<() => void> = [];
|
|
55
|
+
private onSwitchOnCallbacks: Array<() => void> = [];
|
|
56
|
+
private onSwitchOffCallbacks: Array<() => void> = [];
|
|
57
|
+
private onInRangeCallbacks: Array<() => void> = [];
|
|
58
|
+
|
|
59
|
+
constructor(private ain: AnalogInRaw) {
|
|
60
|
+
this.ain.add_event(EventType.OnValueChange, () => {
|
|
61
|
+
this.onValueChangeCallbacks.forEach(callback => {
|
|
62
|
+
callback();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
this.ain.add_event(EventType.OnValueLower, () => {
|
|
67
|
+
this.onValueLowerCallbacks.forEach(callback => {
|
|
68
|
+
callback();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
this.ain.add_event(EventType.OnValueRise, () => {
|
|
73
|
+
this.onValueRiseCallbacks.forEach(callback => {
|
|
74
|
+
callback();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
this.ain.add_event(EventType.OnOutOfRange, () => {
|
|
79
|
+
this.onOutOfRangeCallbacks.forEach(callback => {
|
|
80
|
+
callback();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
this.ain.add_event(EventType.OnSwitchOn, () => {
|
|
85
|
+
this.onSwitchOnCallbacks.forEach(callback => {
|
|
86
|
+
callback();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
this.ain.add_event(EventType.OnSwitchOff, () => {
|
|
91
|
+
this.onSwitchOffCallbacks.forEach(callback => {
|
|
92
|
+
callback();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
this.ain.add_event(EventType.OnInRange, () => {
|
|
97
|
+
this.onInRangeCallbacks.forEach(callback => {
|
|
98
|
+
callback();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
addOnValueChange(callback: () => void): void {
|
|
104
|
+
this.onValueChangeCallbacks.push(callback);
|
|
105
|
+
}
|
|
106
|
+
addOnValueLower(callback: () => void): void {
|
|
107
|
+
this.onValueLowerCallbacks.push(callback);
|
|
108
|
+
}
|
|
109
|
+
addOnValueRise(callback: () => void): void {
|
|
110
|
+
this.onValueRiseCallbacks.push(callback);
|
|
111
|
+
}
|
|
112
|
+
addOnOutOfRange(callback: () => void): void {
|
|
113
|
+
this.onOutOfRangeCallbacks.push(callback);
|
|
114
|
+
}
|
|
115
|
+
addOnSwitchOn(callback: () => void): void {
|
|
116
|
+
this.onSwitchOnCallbacks.push(callback);
|
|
117
|
+
}
|
|
118
|
+
addOnSwitchOff(callback: () => void): void {
|
|
119
|
+
this.onSwitchOffCallbacks.push(callback);
|
|
120
|
+
}
|
|
121
|
+
addOnInRange(callback: () => void): void {
|
|
122
|
+
this.onInRangeCallbacks.push(callback);
|
|
123
|
+
}
|
|
124
|
+
get rawValue(): number{
|
|
125
|
+
return this.ain.get(PropertyType.RawValue)
|
|
126
|
+
}
|
|
127
|
+
get value(): number{
|
|
128
|
+
return this.ain.get(PropertyType.Value)
|
|
129
|
+
}
|
|
130
|
+
get valuePercent(): number{
|
|
131
|
+
return this.ain.get(PropertyType.ValuesPercent)
|
|
132
|
+
}
|
|
133
|
+
get scale(): number{
|
|
134
|
+
return this.ain.get(PropertyType.Scale)
|
|
135
|
+
}
|
|
136
|
+
set scale(value: number){
|
|
137
|
+
this.ain.set(PropertyType.Scale, value)
|
|
138
|
+
}
|
|
139
|
+
get sensivity(): number{
|
|
140
|
+
return this.ain.get(PropertyType.Sensivity)
|
|
141
|
+
}
|
|
142
|
+
set sensivity(value: number){
|
|
143
|
+
this.ain.set(PropertyType.Sensivity, value)
|
|
144
|
+
}
|
|
145
|
+
get minValue(): number{
|
|
146
|
+
return this.ain.get(PropertyType.MinValue)
|
|
147
|
+
}
|
|
148
|
+
set minValue(value: number){
|
|
149
|
+
this.ain.set(PropertyType.MinValue, value)
|
|
150
|
+
}
|
|
151
|
+
get maxValue(): number{
|
|
152
|
+
return this.ain.get(PropertyType.MaxValue)
|
|
153
|
+
}
|
|
154
|
+
set maxValue(value: number){
|
|
155
|
+
this.ain.set(PropertyType.MaxValue, value)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class AnalogInRemote implements IAnalogIn {
|
|
160
|
+
constructor(private objectName: string, private gate: RemoteGate){
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
addOnValueChange(_callback: () => void): void {
|
|
165
|
+
// Remote events are not supported
|
|
166
|
+
}
|
|
167
|
+
addOnValueLower(_callback: () => void): void {
|
|
168
|
+
// Remote events are not supported
|
|
169
|
+
}
|
|
170
|
+
addOnValueRise(_callback: () => void): void {
|
|
171
|
+
// Remote events are not supported
|
|
172
|
+
}
|
|
173
|
+
addOnOutOfRange(_callback: () => void): void {
|
|
174
|
+
// Remote events are not supported
|
|
175
|
+
}
|
|
176
|
+
addOnSwitchOn(_callback: () => void): void {
|
|
177
|
+
// Remote events are not supported
|
|
178
|
+
}
|
|
179
|
+
addOnSwitchOff(_callback: () => void): void {
|
|
180
|
+
// Remote events are not supported
|
|
181
|
+
}
|
|
182
|
+
addOnInRange(_callback: () => void): void {
|
|
183
|
+
// Remote events are not supported
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
get rawValue(): number {
|
|
187
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
188
|
+
.get()
|
|
189
|
+
.addParameter(PropertyType.RawValue)
|
|
190
|
+
.build();
|
|
191
|
+
|
|
192
|
+
return this.gate.runScript(cmd!);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
get value(): number {
|
|
196
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
197
|
+
.get()
|
|
198
|
+
.addParameter(PropertyType.Value)
|
|
199
|
+
.build();
|
|
200
|
+
return this.gate.runScript(cmd!);
|
|
201
|
+
}
|
|
202
|
+
get valuePercent(): number {
|
|
203
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
204
|
+
.get()
|
|
205
|
+
.addParameter(PropertyType.ValuesPercent)
|
|
206
|
+
.build();
|
|
207
|
+
return this.gate.runScript(cmd!);
|
|
208
|
+
}
|
|
209
|
+
get scale(): number {
|
|
210
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
211
|
+
.get()
|
|
212
|
+
.addParameter(PropertyType.Scale)
|
|
213
|
+
.build();
|
|
214
|
+
return this.gate.runScript(cmd!);
|
|
215
|
+
}
|
|
216
|
+
set scale(value: number) {
|
|
217
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
218
|
+
.set()
|
|
219
|
+
.addParameter(PropertyType.Scale)
|
|
220
|
+
.addParameter(value)
|
|
221
|
+
.build();
|
|
222
|
+
this.gate.runScript(cmd!);
|
|
223
|
+
}
|
|
224
|
+
get sensivity(): number {
|
|
225
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
226
|
+
.get()
|
|
227
|
+
.addParameter(PropertyType.Sensivity)
|
|
228
|
+
.build();
|
|
229
|
+
return this.gate.runScript(cmd!);
|
|
230
|
+
}
|
|
231
|
+
set sensivity(value: number) {
|
|
232
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
233
|
+
.set()
|
|
234
|
+
.addParameter(PropertyType.Sensivity)
|
|
235
|
+
.addParameter(value)
|
|
236
|
+
.build();
|
|
237
|
+
this.gate.runScript(cmd!);
|
|
238
|
+
}
|
|
239
|
+
get minValue(): number {
|
|
240
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
241
|
+
.get()
|
|
242
|
+
.addParameter(PropertyType.MinValue)
|
|
243
|
+
.build();
|
|
244
|
+
return this.gate.runScript(cmd!);
|
|
245
|
+
}
|
|
246
|
+
set minValue(value: number) {
|
|
247
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
248
|
+
.set()
|
|
249
|
+
.addParameter(PropertyType.MinValue)
|
|
250
|
+
.addParameter(value)
|
|
251
|
+
.build();
|
|
252
|
+
this.gate.runScript(cmd!);
|
|
253
|
+
}
|
|
254
|
+
get maxValue(): number {
|
|
255
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
256
|
+
.get()
|
|
257
|
+
.addParameter(PropertyType.MaxValue)
|
|
258
|
+
.build();
|
|
259
|
+
return this.gate.runScript(cmd!);
|
|
260
|
+
}
|
|
261
|
+
set maxValue(value: number) {
|
|
262
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
263
|
+
.set()
|
|
264
|
+
.addParameter(PropertyType.MaxValue)
|
|
265
|
+
.addParameter(value)
|
|
266
|
+
.build();
|
|
267
|
+
this.gate.runScript(cmd!);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export { AnalogIn, AnalogInRaw, AnalogInRemote}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// Created from: packages/grenton-api/interfaces/object_calendar_v1.xml, object name="Calendar" version="1"
|
|
2
|
+
|
|
3
|
+
import { rawExecutionBuilderFactory } from "../../../core/execution-builder"
|
|
4
|
+
import { RemoteGate } from "../../../core/remote-gate"
|
|
5
|
+
|
|
6
|
+
enum EventType {
|
|
7
|
+
OnCalendar = 0,
|
|
8
|
+
OnStart = 1,
|
|
9
|
+
OnStop = 2,
|
|
10
|
+
OnCancel = 3
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
enum PropertyType {
|
|
14
|
+
Rule = 0,
|
|
15
|
+
SinceLastRun = 1,
|
|
16
|
+
ToNextRun = 2,
|
|
17
|
+
State = 3
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum MethodType {
|
|
21
|
+
Start = 0,
|
|
22
|
+
Stop = 1,
|
|
23
|
+
CancelNext = 3
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
enum StateType {
|
|
27
|
+
Off = 0,
|
|
28
|
+
On = 1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class CalendarRaw {
|
|
32
|
+
add_event(event: EventType, callback: () => void): void;
|
|
33
|
+
get(property: PropertyType): any;
|
|
34
|
+
set(property: PropertyType, value: any): void;
|
|
35
|
+
execute(method: MethodType, ...args: any[]): any;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ICalendar {
|
|
39
|
+
/**
|
|
40
|
+
* Zdarzenie wywoływane w momencie wywołania akcji kalendarza
|
|
41
|
+
* @param callback
|
|
42
|
+
*/
|
|
43
|
+
addOnCalendar: (callback: () => void) => void
|
|
44
|
+
/**
|
|
45
|
+
* Zdarzenie wywoływane w momencie wznowienia pracy kalendarza
|
|
46
|
+
* @param callback
|
|
47
|
+
*/
|
|
48
|
+
addOnStart: (callback: () => void) => void
|
|
49
|
+
/**
|
|
50
|
+
* Zdarzenie wywoływane w momencie zablokowania pracy kalendarza
|
|
51
|
+
* @param callback
|
|
52
|
+
*/
|
|
53
|
+
addOnStop: (callback: () => void) => void
|
|
54
|
+
/**
|
|
55
|
+
* Zdarzenie wywoływane w momencie anulowania najbliższych akcji
|
|
56
|
+
* @param callback
|
|
57
|
+
*/
|
|
58
|
+
addOnCancel: (callback: () => void) => void
|
|
59
|
+
/** Przełączenie w stan aktywny (State=1) */
|
|
60
|
+
start: () => void
|
|
61
|
+
/** Przełączenie w stan zatrzymania (State=0) */
|
|
62
|
+
stop: () => void
|
|
63
|
+
/** Anulowanie wywołania wskazanej liczby najbliższych akcji kalendarza */
|
|
64
|
+
cancelNext: (count?: number) => void
|
|
65
|
+
/** Reguła kalendarza w formacie CRON lub ERROR w przypadku wprowadzenia błędnej reguły */
|
|
66
|
+
rule: string
|
|
67
|
+
/** Czas w minutach od ostatniego spełnienia warunku reguły */
|
|
68
|
+
readonly sinceLastRun: number
|
|
69
|
+
/** Czas w minutach do następnego wywołania akcji kalendarza */
|
|
70
|
+
readonly toNextRun: number
|
|
71
|
+
/** Stan działania kalendarza: 1 - kalendarz aktywny, 0 - kalendarz nieaktywny */
|
|
72
|
+
readonly state: StateType
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
class Calendar implements ICalendar {
|
|
76
|
+
private onCalendarCallbacks: Array<() => void> = [];
|
|
77
|
+
private onStartCallbacks: Array<() => void> = [];
|
|
78
|
+
private onStopCallbacks: Array<() => void> = [];
|
|
79
|
+
private onCancelCallbacks: Array<() => void> = [];
|
|
80
|
+
|
|
81
|
+
constructor(private raw: CalendarRaw) {
|
|
82
|
+
this.raw.add_event(EventType.OnCalendar, () => {
|
|
83
|
+
this.onCalendarCallbacks.forEach(callback => {
|
|
84
|
+
callback();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
this.raw.add_event(EventType.OnStart, () => {
|
|
89
|
+
this.onStartCallbacks.forEach(callback => {
|
|
90
|
+
callback();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
this.raw.add_event(EventType.OnStop, () => {
|
|
95
|
+
this.onStopCallbacks.forEach(callback => {
|
|
96
|
+
callback();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
this.raw.add_event(EventType.OnCancel, () => {
|
|
101
|
+
this.onCancelCallbacks.forEach(callback => {
|
|
102
|
+
callback();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Zdarzenie wywoływane w momencie wywołania akcji kalendarza
|
|
109
|
+
* @param callback
|
|
110
|
+
*/
|
|
111
|
+
addOnCalendar(callback: () => void): void {
|
|
112
|
+
this.onCalendarCallbacks.push(callback);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Zdarzenie wywoływane w momencie wznowienia pracy kalendarza
|
|
116
|
+
* @param callback
|
|
117
|
+
*/
|
|
118
|
+
addOnStart(callback: () => void): void {
|
|
119
|
+
this.onStartCallbacks.push(callback);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Zdarzenie wywoływane w momencie zablokowania pracy kalendarza
|
|
123
|
+
* @param callback
|
|
124
|
+
*/
|
|
125
|
+
addOnStop(callback: () => void): void {
|
|
126
|
+
this.onStopCallbacks.push(callback);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Zdarzenie wywoływane w momencie anulowania najbliższych akcji
|
|
130
|
+
* @param callback
|
|
131
|
+
*/
|
|
132
|
+
addOnCancel(callback: () => void): void {
|
|
133
|
+
this.onCancelCallbacks.push(callback);
|
|
134
|
+
}
|
|
135
|
+
/** Przełączenie w stan aktywny (State=1) */
|
|
136
|
+
start(): void {
|
|
137
|
+
this.raw.execute(MethodType.Start);
|
|
138
|
+
}
|
|
139
|
+
/** Przełączenie w stan zatrzymania (State=0) */
|
|
140
|
+
stop(): void {
|
|
141
|
+
this.raw.execute(MethodType.Stop);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Anulowanie wywołania wskazanej liczby najbliższych akcji kalendarza
|
|
145
|
+
* @param count
|
|
146
|
+
*/
|
|
147
|
+
cancelNext(count: number = 1): void {
|
|
148
|
+
this.raw.execute(MethodType.CancelNext, count);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Reguła kalendarza w formacie CRON lub ERROR w przypadku wprowadzenia błędnej reguły
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
get rule(): string {
|
|
155
|
+
return this.raw.get(PropertyType.Rule);
|
|
156
|
+
}
|
|
157
|
+
set rule(value: string) {
|
|
158
|
+
this.raw.set(PropertyType.Rule, value);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Czas w minutach od ostatniego spełnienia warunku reguły
|
|
162
|
+
* @returns {number}
|
|
163
|
+
*/
|
|
164
|
+
get sinceLastRun(): number {
|
|
165
|
+
return this.raw.get(PropertyType.SinceLastRun);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Czas w minutach do następnego wywołania akcji kalendarza
|
|
169
|
+
* @returns {number}
|
|
170
|
+
*/
|
|
171
|
+
get toNextRun(): number {
|
|
172
|
+
return this.raw.get(PropertyType.ToNextRun);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Stan działania kalendarza: 1 - kalendarz aktywny, 0 - kalendarz nieaktywny
|
|
176
|
+
* @returns {StateType}
|
|
177
|
+
*/
|
|
178
|
+
get state(): StateType {
|
|
179
|
+
return this.raw.get(PropertyType.State);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
class CalendarRemote implements ICalendar {
|
|
184
|
+
constructor(private objectName: string, private gate: RemoteGate) {
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Zdarzenie wywoływane w momencie wywołania akcji kalendarza
|
|
190
|
+
* @param callback
|
|
191
|
+
*/
|
|
192
|
+
addOnCalendar(_callback: () => void): void {
|
|
193
|
+
// Remote events are not supported
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Zdarzenie wywoływane w momencie wznowienia pracy kalendarza
|
|
197
|
+
* @param callback
|
|
198
|
+
*/
|
|
199
|
+
addOnStart(_callback: () => void): void {
|
|
200
|
+
// Remote events are not supported
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Zdarzenie wywoływane w momencie zablokowania pracy kalendarza
|
|
204
|
+
* @param callback
|
|
205
|
+
*/
|
|
206
|
+
addOnStop(_callback: () => void): void {
|
|
207
|
+
// Remote events are not supported
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Zdarzenie wywoływane w momencie anulowania najbliższych akcji
|
|
211
|
+
* @param callback
|
|
212
|
+
*/
|
|
213
|
+
addOnCancel(_callback: () => void): void {
|
|
214
|
+
// Remote events are not supported
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Przełączenie w stan aktywny (State=1) */
|
|
218
|
+
start(): void {
|
|
219
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
220
|
+
.execute()
|
|
221
|
+
.addParameter(MethodType.Start)
|
|
222
|
+
.build();
|
|
223
|
+
this.gate.runScript(cmd!);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Przełączenie w stan zatrzymania (State=0) */
|
|
227
|
+
stop(): void {
|
|
228
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
229
|
+
.execute()
|
|
230
|
+
.addParameter(MethodType.Stop)
|
|
231
|
+
.build();
|
|
232
|
+
this.gate.runScript(cmd!);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Anulowanie wywołania wskazanej liczby najbliższych akcji kalendarza
|
|
237
|
+
* @param count
|
|
238
|
+
*/
|
|
239
|
+
cancelNext(count: number = 1): void {
|
|
240
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
241
|
+
.execute()
|
|
242
|
+
.addParameter(MethodType.CancelNext)
|
|
243
|
+
.addParameter(count)
|
|
244
|
+
.build();
|
|
245
|
+
this.gate.runScript(cmd!);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Reguła kalendarza w formacie CRON lub ERROR w przypadku wprowadzenia błędnej reguły
|
|
250
|
+
* @returns {string}
|
|
251
|
+
*/
|
|
252
|
+
get rule(): string {
|
|
253
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
254
|
+
.get()
|
|
255
|
+
.addParameter(PropertyType.Rule)
|
|
256
|
+
.build();
|
|
257
|
+
return this.gate.runScript(cmd!);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
set rule(value: string) {
|
|
261
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
262
|
+
.set()
|
|
263
|
+
.addParameter(PropertyType.Rule)
|
|
264
|
+
.addParameter(value)
|
|
265
|
+
.build();
|
|
266
|
+
this.gate.runScript(cmd!);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Czas w minutach od ostatniego spełnienia warunku reguły
|
|
271
|
+
* @returns {number}
|
|
272
|
+
*/
|
|
273
|
+
get sinceLastRun(): number {
|
|
274
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
275
|
+
.get()
|
|
276
|
+
.addParameter(PropertyType.SinceLastRun)
|
|
277
|
+
.build();
|
|
278
|
+
return this.gate.runScript(cmd!);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Czas w minutach do następnego wywołania akcji kalendarza
|
|
283
|
+
* @returns {number}
|
|
284
|
+
*/
|
|
285
|
+
get toNextRun(): number {
|
|
286
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
287
|
+
.get()
|
|
288
|
+
.addParameter(PropertyType.ToNextRun)
|
|
289
|
+
.build();
|
|
290
|
+
return this.gate.runScript(cmd!);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Stan działania kalendarza: 1 - kalendarz aktywny, 0 - kalendarz nieaktywny
|
|
295
|
+
* @returns {StateType}
|
|
296
|
+
*/
|
|
297
|
+
get state(): StateType {
|
|
298
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
299
|
+
.get()
|
|
300
|
+
.addParameter(PropertyType.State)
|
|
301
|
+
.build();
|
|
302
|
+
return this.gate.runScript(cmd!);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export {
|
|
307
|
+
Calendar, CalendarRaw, CalendarRemote, StateType
|
|
308
|
+
}
|