loupedeck-commander 1.2.0 → 1.2.2

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.
@@ -1,46 +1,47 @@
1
- import { exec } from 'child_process'
2
- import { BaseIf } from './baseif.mjs'
3
-
4
- /**
5
- * Our Special-Handler just used the Default - and adds Vibration after triggers through Button-Releases
6
- */
7
- export class SHELLif extends BaseIf {
8
- async call (cmd, options = {}) {
9
- cmd = super.call(cmd, options)
10
- return await this.sh(cmd)
11
- }
12
-
13
- async stop(){
14
- console.log("Stopping SHELLif")
15
- }
16
-
17
- Check(options) {
18
- var res= super.Check(options)
19
- if (res <0)
20
- return res
21
- }
22
-
23
- /**
24
- * Run a Shell command in ASYNC mode
25
- * @param {*} cmd
26
- * @returns
27
- */
28
- async sh (cmd) {
29
- if (this.options.verbose)
30
- console.log('ShellIf call', cmd)
31
-
32
- return new Promise(function (resolve, reject) {
33
- exec(cmd, (err, stdout, stderr) => {
34
- if (stdout.length>0)
35
- console.log(`SHELLif Out: ${stdout}`)
36
- if (stderr.length>0)
37
- console.log(`SHELLif Err: ${stderr}`)
38
- if (err) {
39
- reject(err)
40
- } else {
41
- resolve({ stdout, stderr })
42
- }
43
- })
44
- })
45
- }
46
- }
1
+ import { exec } from 'child_process'
2
+ //import { exec } from 'node:child_process'
3
+ import { BaseIf } from './baseif.mjs'
4
+
5
+ /**
6
+ * Our Special-Handler just used the Default - and adds Vibration after triggers through Button-Releases
7
+ */
8
+ export class SHELLif extends BaseIf {
9
+ async call (cmd, options = {}) {
10
+ cmd = super.call(cmd, options)
11
+ return await this.sh(cmd)
12
+ }
13
+
14
+ async stop(){
15
+ this.LogInfo("SHELLif: Stopping")
16
+ }
17
+
18
+ Check(options) {
19
+ var res= super.Check(options)
20
+ if (res <0)
21
+ return res
22
+ }
23
+
24
+ /**
25
+ * Run a Shell command in ASYNC mode
26
+ * @param {*} cmd
27
+ * @returns
28
+ */
29
+ async sh (cmd) {
30
+ let self = this;
31
+ this.LogDebug(`ShellIf: runCmd: ${cmd}\n`)
32
+
33
+ return new Promise(function (resolve, reject) {
34
+ exec(cmd, (err, stdout, stderr) => {
35
+ if (stdout.length>0)
36
+ self.LogInfo(`SHELLif Out: ${stdout}`)
37
+ if (stderr.length>0)
38
+ self.LogError(`SHELLif Err: ${stderr}`)
39
+ if (err) {
40
+ reject(err)
41
+ } else {
42
+ resolve({ stdout, stderr })
43
+ }
44
+ })
45
+ })
46
+ }
47
+ }
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
- {
2
- "name": "loupedeck-commander",
3
- "version": "1.2.0",
4
- "description": "A system to ease working with LoupeDeck devices using CMD-line interfaces",
5
- "main": "index.mjs",
6
- "scripts": {
7
- "test": "node test.mjs",
8
- "start": "node index.mjs"
9
- },
10
- "dependencies": {
11
- "canvas": "^2.11.2",
12
- "loupedeck": "^6.0.1",
13
- "mkdirp": "^3.0.1",
14
- "node-opcua": "^2.138.1",
15
- "string-template": "^1.0.0"
16
- },
17
- "author": "Thomas Schneider",
18
- "license": "MIT",
19
- "repository": {
20
- "type": "git",
21
- "url": "git@gitlab.com:keckxde/loupedeck-commander.git"
22
- },
23
- "bugs": {
24
- "url": "https://gitlab.com/keckxde/loupedeck-commander/-/issues"
25
- },
26
- "devDependencies": {
27
- "eslint": "^9.8.0"
28
- }
29
- }
1
+ {
2
+ "name": "loupedeck-commander",
3
+ "version": "1.2.2",
4
+ "description": "A system to ease working with LoupeDeck devices using CMD-line, OPC/UA or HTTP-client interfaces",
5
+ "main": "index.mjs",
6
+ "scripts": {
7
+ "test": "node test.mjs",
8
+ "start": "node index.mjs"
9
+ },
10
+ "dependencies": {
11
+ "canvas": "^2.11.2",
12
+ "loupedeck": "^6.0.1",
13
+ "mkdirp": "^3.0.1",
14
+ "node-opcua": "^2.138.1",
15
+ "string-template": "^1.0.0"
16
+ },
17
+ "author": "Thomas Schneider",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git@gitlab.com:keckxde/loupedeck-commander.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://gitlab.com/keckxde/loupedeck-commander/-/issues"
25
+ },
26
+ "devDependencies": {
27
+ "eslint": "^9.8.0"
28
+ }
29
+ }
package/profile-1.json CHANGED
@@ -1,90 +1,281 @@
1
- {
2
- "profile": "sample",
3
- "parameters": {
4
- "hostname": "localhost",
5
- "user": "httpuser",
6
- "password": "httppasswd",
7
- "verbose" : false,
8
- "endpointurl": "opc.tcp://localhost:4840",
9
- "nodeid" : "ns=4;s=Is{simnbr}.Kvm.in.Source",
10
- "value" : "kvm-transmitter-1",
11
- "simnbr": "1"
12
- },
13
- "description": "",
14
- "config": {},
15
- "touch": {
16
- "left": {},
17
- "right": {},
18
- "center": {
19
- "0": {
20
- "states": {
21
- "off": {
22
- "color": "#aaaaaa",
23
- "image": "icons/home.png",
24
- "cmd": "echo \"{id} {state}\""
25
- },
26
- "on": {
27
- "color": "#11ff11",
28
- "image": "icons/home.png",
29
- "cmd": "echo \"{id} {state}\""
30
- }
31
- },
32
- "group": "kvm1"
33
- },
34
- "1": {
35
- "states": {
36
- "off": {
37
- "color": "#aaaaaa",
38
- "image": "icons/bulb.png",
39
- "http": "http://{user}:{password}@{hostname}:7778/control/connections"
40
- },
41
- "on": {
42
- "color": "#11ff11",
43
- "image": "icons/bulb.png",
44
- "http": "http://{hostname}:7778/control/connections",
45
- "opcua": "write",
46
- "nodeid": "ns=4;s=Is{simnbr}.Kvm.in.Source",
47
- "value": "{key}"
48
- }
49
- },
50
- "group": "kvm1"
51
- },
52
- "2": {
53
- "states": {
54
- "off": {
55
- "color": "#aaaaaa",
56
- "image": "icons/mountain.png"
57
- },
58
- "on": {
59
- "color": "#11ff11",
60
- "image": "icons/mountain.png",
61
- "opcua": "write",
62
- "nodeid": "ns=4;s=Is{simnbr}.Kvm.in.Source",
63
- "value": "{key}"
64
- }
65
- },
66
- "group": "kvm1"
67
- }
68
- },
69
- "knob": {}
70
- },
71
- "knobs": {
72
- "left": {},
73
- "right": {}
74
- },
75
- "buttons": {
76
- "1": {
77
- "states": {
78
- "off": {
79
- "color": "#aaaaaa",
80
- "cmd": "echo \"{id} {state}\""
81
- },
82
- "on": {
83
- "color": "#11ff11",
84
- "cmd": "echo \"{id} {state}\""
85
- }
86
- },
87
- "group": "kvm1"
88
- }
89
- }
1
+ {
2
+ "profile": "sample",
3
+ "parameters": {
4
+ "hostname": "localhost",
5
+ "user": "httpuser",
6
+ "password": "httppasswd",
7
+ "verbose" : false,
8
+ "endpointurl": "opc.tcp://localhost:4840",
9
+ "nodeid" : "ns=0;s=OpcUaNode-{customarg}",
10
+ "value" : "value",
11
+ "customarg": "1"
12
+ },
13
+ "description": "",
14
+ "config": {},
15
+ "touch": {
16
+ "left": {},
17
+ "right": {},
18
+ "center": {
19
+ "0": {
20
+ "states": {
21
+ "off": {
22
+ "color": "#aaaaaa",
23
+ "image": "icons/home.png",
24
+ "cmd": "echo \"{id} {state}\""
25
+ },
26
+ "on": {
27
+ "color": "#11ff11",
28
+ "image": "icons/home.png",
29
+ "cmd": "echo \"{id} {state}\""
30
+ }
31
+ },
32
+ "text" : "A",
33
+ "group": "group1"
34
+ },
35
+ "1": {
36
+ "states": {
37
+ "off": {
38
+ "color": "#aaaaaa",
39
+ "image": "icons/bulb.png"
40
+ },
41
+ "on": {
42
+ "color": "#11ff11",
43
+ "image": "icons/bulb.png",
44
+ "http": "http://{user}:{password}@{hostname}:7778/control/connections",
45
+ "value": "{key}"
46
+ }
47
+ },
48
+ "text" : "B",
49
+ "group": "group1"
50
+ },
51
+ "2": {
52
+ "states": {
53
+ "off": {
54
+ "color": "#aaaaaa",
55
+ "image": "icons/mountain.png"
56
+ },
57
+ "on": {
58
+ "color": "#11ff11",
59
+ "image": "icons/mountain.png",
60
+ "opcua": "ns=0;s=Node{simnbr}",
61
+ "value": "{key}"
62
+ }
63
+ },
64
+ "text" : "C",
65
+ "group": "group1"
66
+ },
67
+ "8": {
68
+ "states": {
69
+ "off": {
70
+ "color": "#aaaaaa",
71
+ "cmd": "echo \"{id} {state} {event} {value}\"",
72
+ "value": "custom-value-{key}" },
73
+ "on": {
74
+ "color": "#11ff11",
75
+ "cmd": "echo \"{id} {state} {event} {value}\"",
76
+ "value": "custom-value-{key}"
77
+ }
78
+ },
79
+ "text" : "HELLO",
80
+ "group": "group2"
81
+ },
82
+ "9": {
83
+ "states": {
84
+ "off": {
85
+ "color": "#bbbbbb",
86
+ "cmd": "echo \"{id} {state} {event} {value}\"",
87
+ "value": "custom-value-{key}" },
88
+ "on": {
89
+ "color": "#33ff33",
90
+ "cmd": "echo \"{id} {state} {event} {value}\"",
91
+ "value": "custom-value-{key}"
92
+ }
93
+ },
94
+ "text" : "YOU",
95
+ "group": "group2"
96
+ }
97
+
98
+
99
+ }
100
+ },
101
+ "buttons": {
102
+ "knobTL": {
103
+ "states": {
104
+ "off": {
105
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
106
+ },
107
+ "on": {
108
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
109
+ }
110
+ }
111
+ },
112
+ "knobCL": {
113
+ "states": {
114
+ "off": {
115
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
116
+ },
117
+ "on": {
118
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
119
+ }
120
+ }
121
+ },
122
+ "knobBL": {
123
+ "states": {
124
+ "off": {
125
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
126
+ },
127
+ "on": {
128
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
129
+ }
130
+ }
131
+ },
132
+ "knobTR": {
133
+ "states": {
134
+ "off": {
135
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
136
+ },
137
+ "on": {
138
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
139
+ }
140
+ }
141
+ },
142
+ "knobCR": {
143
+ "states": {
144
+ "off": {
145
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
146
+ },
147
+ "on": {
148
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
149
+ }
150
+ }
151
+ },
152
+ "knobBR": {
153
+ "states": {
154
+ "off": {
155
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
156
+ },
157
+ "on": {
158
+ "cmd": "echo \"{id} {state} Val: {value} Event: {event}\""
159
+ }
160
+ }
161
+ },
162
+ "0": {
163
+ "states": {
164
+ "off": {
165
+ "color": "#aaaaaa",
166
+ "cmd": "echo \"{id} {state} {event}\""
167
+ },
168
+ "med": {
169
+ "color": "ff11ff",
170
+ "cmd": "echo \"{id} {state} {event}\""
171
+ },
172
+ "on": {
173
+ "color": "#11ff11",
174
+ "cmd": "echo \"{id} {state} {event}\""
175
+ }
176
+ },
177
+ "group": "group1"
178
+ },
179
+ "1": {
180
+ "states": {
181
+ "off": {
182
+ "color": "#aaaaaa",
183
+ "cmd": "echo \"{id} {state} {event}\""
184
+ },
185
+ "med": {
186
+ "color": "ff11ff",
187
+ "cmd": "echo \"{id} {state} {event}\""
188
+ },
189
+ "on": {
190
+ "color": "#11ff11",
191
+ "cmd": "echo \"{id} {state} {event}\""
192
+ }
193
+ },
194
+ "group": "group1"
195
+ },
196
+ "2": {
197
+ "states": {
198
+ "off": {
199
+ "color": "#aaaaaa",
200
+ "cmd": "echo \"{id} {key} {state} {event}\"",
201
+ "filter": "released" },
202
+ "on": {
203
+ "color": "#11ff11",
204
+ "cmd": "echo \"{id} {key} {state} {event}\"",
205
+ "filter": "released"
206
+ }
207
+ },
208
+ "group": "group1"
209
+ },
210
+ "3": {
211
+ "states": {
212
+ "off": {
213
+ "color": "#aaaaaa",
214
+ "cmd": "echo \"{id} {key} {state} {event}\"",
215
+ "filter": "released" },
216
+ "on": {
217
+ "color": "#11ff11",
218
+ "cmd": "echo \"{id} {key} {state} {event}\"",
219
+ "filter": "released"
220
+ }
221
+ },
222
+ "group": "group1"
223
+ },
224
+ "4": {
225
+ "states": {
226
+ "off": {
227
+ "color": "#aaaaaa",
228
+ "cmd": "echo \"{id} {key} {state} {event}\"",
229
+ "filter": "released" },
230
+ "on": {
231
+ "color": "#11ff11",
232
+ "cmd": "echo \"{id} {key} {state} {event}\"",
233
+ "filter": "released"
234
+ }
235
+ },
236
+ "group": "group1"
237
+ },
238
+ "5": {
239
+ "states": {
240
+ "off": {
241
+ "color": "#aaaaaa",
242
+ "cmd": "echo \"{id} {key} {state} {event}\"",
243
+ "filter": "released" },
244
+ "on": {
245
+ "color": "#11ff11",
246
+ "cmd": "echo \"{id} {key} {state} {event}\"",
247
+ "filter": "released"
248
+ }
249
+ },
250
+ "group": "group1"
251
+ },
252
+ "6": {
253
+ "states": {
254
+ "off": {
255
+ "color": "#aaaaaa",
256
+ "cmd": "echo \"{id} {key} {state} {event}\"",
257
+ "filter": "released" },
258
+ "on": {
259
+ "color": "#11ff11",
260
+ "cmd": "echo \"{id} {key} {state} {event}\"",
261
+ "filter": "released"
262
+ }
263
+ },
264
+ "group": "group1"
265
+ },
266
+ "7": {
267
+ "states": {
268
+ "off": {
269
+ "color": "#aaaaaa",
270
+ "cmd": "echo \"{id} {key} {state} {event}\"",
271
+ "filter": "released" },
272
+ "on": {
273
+ "color": "#11ff11",
274
+ "cmd": "echo \"{id} {key} {state} {event}\"",
275
+ "filter": "released"
276
+ }
277
+ },
278
+ "group": "group1"
279
+ }
280
+ }
90
281
  }
package/test.mjs CHANGED
@@ -1,23 +1,23 @@
1
- import { BaseLoupeDeckHandler } from './common/BaseLoupeDeckHandler.mjs'
2
- //import { BaseLoupeDeckHandler } from 'loupedeck-commander'
3
-
4
- const handler = new BaseLoupeDeckHandler('config-test.json')
5
-
6
- /**
7
- * Stop the handlers when a signal like SIGINT or SIGTERM arrive
8
- * @param {*} signal
9
- */
10
- const stopHandler = async(signal) => {
11
- console.log(`Receiving ${signal} => Stopping processes.`)
12
- await handler.stop()
13
- }
14
-
15
- // Initiating the signal handlers:
16
- // see https://www.tutorialspoint.com/unix/unix-signals-traps.htm
17
- process.on('SIGINT', async (signal) => { stopHandler(signal) })
18
- process.on('SIGTERM', async (signal) => { stopHandler(signal) })
19
-
20
-
21
- await handler.start()
22
-
1
+ import { BaseLoupeDeckHandler } from './common/BaseLoupeDeckHandler.mjs'
2
+ //import { BaseLoupeDeckHandler } from 'loupedeck-commander'
3
+
4
+ const handler = new BaseLoupeDeckHandler('config.json')
5
+
6
+ /**
7
+ * Stop the handlers when a signal like SIGINT or SIGTERM arrive
8
+ * @param {*} signal
9
+ */
10
+ const stopHandler = async(signal) => {
11
+ console.log(`Receiving ${signal} => Stopping processes.`)
12
+ await handler.stop()
13
+ }
14
+
15
+ // Initiating the signal handlers:
16
+ // see https://www.tutorialspoint.com/unix/unix-signals-traps.htm
17
+ process.on('SIGINT', async (signal) => { stopHandler(signal) })
18
+ process.on('SIGTERM', async (signal) => { stopHandler(signal) })
19
+
20
+
21
+ await handler.start()
22
+
23
23
  await new Promise((resolve) => process.once("SIGINT", resolve));
package/config-test.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "application": "TEST",
3
- "profiles": [
4
- {
5
- "name": "profile1",
6
- "file": "profile-2.json"
7
- }
8
- ]
9
- }
@@ -1,31 +0,0 @@
1
- import * as opcuaif from '../interfaces/opcuaif.mjs'
2
-
3
-
4
- var opcuainterface = new opcuaif.OPCUAIf()
5
- import {
6
- DataType
7
- } from "node-opcua";
8
-
9
- var call = {
10
-
11
- }
12
-
13
- var option = {
14
- "id" : "touch-0",
15
- "key" : "1",
16
- "state" : "off",
17
- "min": "0",
18
- "max": "0",
19
- "color": "0",
20
- "image": "0",
21
- "endpointurl": "opc.tcp://localhost:4840",
22
- "nodeid": "ns=4;s=Is{key}.Kvm.in.Source",
23
- "value": "{key}"
24
- }
25
-
26
- await opcuainterface.call(call,option)
27
- await opcuainterface.Subscribe("ns=4;s=Is1.Kvm.out.Source")
28
- await opcuainterface.Subscribe("ns=4;s=Is1.Kvm.out.Turret")
29
- await opcuainterface.Write("ns=4;s=Is1.Kvm.out.Turret",1,DataType.Int16)
30
- await opcuainterface.Write("ns=4;s=Is1.Kvm.out.Source","hello",DataType.String)
31
- //await opcuainterface.Write("ns=4;s=Is1.Kvm.state",2,DataType.Int32)