loupedeck-commander 1.2.9 → 1.2.11
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/common/ApplicationConfig.mjs +1 -1
- package/common/BaseLoupeDeckHandler.mjs +9 -4
- package/common/touchbuttons.mjs +38 -26
- package/common/utils.mjs +0 -0
- package/config.json +4 -0
- package/interfaces/opcuaif.mjs +17 -16
- package/package.json +1 -1
- package/profile-1.json +5 -3
|
@@ -83,10 +83,12 @@ export class BaseLoupeDeckHandler {
|
|
|
83
83
|
try {
|
|
84
84
|
console.info(`Closing Device`)
|
|
85
85
|
this.stopping = true
|
|
86
|
-
|
|
86
|
+
|
|
87
|
+
/* if (this.device){
|
|
87
88
|
this.device.vibrate(HAPTIC.DESCEND_MED)
|
|
88
89
|
await new Promise(resolve => setTimeout(resolve, 250))
|
|
89
90
|
}
|
|
91
|
+
*/
|
|
90
92
|
if (this.device){
|
|
91
93
|
this.device.setBrightness(0)
|
|
92
94
|
await new Promise(resolve => setTimeout(resolve, 250))
|
|
@@ -97,11 +99,14 @@ export class BaseLoupeDeckHandler {
|
|
|
97
99
|
await new Promise(resolve => setTimeout(resolve, 2000))
|
|
98
100
|
console.info(`Device Closed`)
|
|
99
101
|
}
|
|
100
|
-
|
|
101
102
|
console.info(`Stopping interfaces`)
|
|
102
103
|
await StopInterfaces()
|
|
103
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
104
|
-
|
|
104
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
105
|
+
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.info(`e`,e)
|
|
108
|
+
|
|
109
|
+
}
|
|
105
110
|
|
|
106
111
|
process.exit()
|
|
107
112
|
|
package/common/touchbuttons.mjs
CHANGED
|
@@ -331,7 +331,8 @@ export class Button {
|
|
|
331
331
|
ctx.font = '20px Verdana'
|
|
332
332
|
ctx.textBaseline = 'top';
|
|
333
333
|
ctx.textAlign = 'left';
|
|
334
|
-
|
|
334
|
+
let dynamicText = format(this.text, this.getParams(elem))
|
|
335
|
+
ctx.fillText(dynamicText,x+6,y+6)
|
|
335
336
|
}
|
|
336
337
|
}
|
|
337
338
|
|
|
@@ -382,7 +383,8 @@ export class Button {
|
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
released () {
|
|
385
|
-
|
|
386
|
+
let elem = this.getCurrentElement()
|
|
387
|
+
if (!elem) { return false }
|
|
386
388
|
this.timeStampReleased = Date.now()
|
|
387
389
|
this.timeHold = this.timeStampReleased - this.timeStampPressed
|
|
388
390
|
|
|
@@ -456,10 +458,13 @@ export class Button {
|
|
|
456
458
|
state : key,
|
|
457
459
|
...state
|
|
458
460
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
if (state && state.value !== undefined){
|
|
462
|
+
let strVal = state.value.toString()
|
|
463
|
+
let val1 = format(strVal,params)
|
|
464
|
+
if (val1 === val?.toString()){
|
|
465
|
+
this.#index = i;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
463
468
|
}
|
|
464
469
|
//break;
|
|
465
470
|
}
|
|
@@ -490,26 +495,7 @@ export class Button {
|
|
|
490
495
|
return false
|
|
491
496
|
}
|
|
492
497
|
|
|
493
|
-
|
|
494
|
-
const elem = this.getCurrentElement()
|
|
495
|
-
// Only continue, if we have an element:
|
|
496
|
-
if (!elem) {
|
|
497
|
-
return
|
|
498
|
-
}
|
|
499
|
-
// Filter for Event Type:
|
|
500
|
-
if (elem.filter && elem.filter != this.#event){
|
|
501
|
-
return
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if (elem.profile !== undefined) {
|
|
505
|
-
profileEmitter.emit("profileChanged", elem.profile)
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Only continue, if we have an element, that contains some kind of command:
|
|
509
|
-
if (!elem.cmd && !elem.http && !elem.opcua) {
|
|
510
|
-
return
|
|
511
|
-
}
|
|
512
|
-
|
|
498
|
+
getParams(elem){
|
|
513
499
|
// Call an action - include dynamic parameters
|
|
514
500
|
// and also all attributes of elem + global config
|
|
515
501
|
const params = {
|
|
@@ -519,6 +505,9 @@ export class Button {
|
|
|
519
505
|
id: this.id,
|
|
520
506
|
key: this.key,
|
|
521
507
|
event: this.#event,
|
|
508
|
+
pressed : this.#event == "pressed",
|
|
509
|
+
released : this.#event == "released",
|
|
510
|
+
rotated : this.#event == "rotated",
|
|
522
511
|
state: this.#keys[this.#index],
|
|
523
512
|
min: this.#min,
|
|
524
513
|
max: this.#max,
|
|
@@ -529,7 +518,30 @@ export class Button {
|
|
|
529
518
|
if (params.value === undefined)
|
|
530
519
|
params.value = this.#value
|
|
531
520
|
|
|
521
|
+
return params
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
async runCommand () {
|
|
525
|
+
const elem = this.getCurrentElement()
|
|
526
|
+
// Only continue, if we have an element:
|
|
527
|
+
if (!elem) {
|
|
528
|
+
return
|
|
529
|
+
}
|
|
530
|
+
// Filter for Event Type:
|
|
531
|
+
if (elem.filter && elem.filter != this.#event){
|
|
532
|
+
return
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (elem.profile !== undefined) {
|
|
536
|
+
profileEmitter.emit("profileChanged", elem.profile)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Only continue, if we have an element, that contains some kind of command:
|
|
540
|
+
if (!elem.cmd && !elem.http && !elem.opcua) {
|
|
541
|
+
return
|
|
542
|
+
}
|
|
532
543
|
|
|
544
|
+
let params = this.getParams(elem)
|
|
533
545
|
let res = ''
|
|
534
546
|
if ('cmd' in elem) {
|
|
535
547
|
if (shellinterface){
|
package/common/utils.mjs
CHANGED
|
File without changes
|
package/config.json
CHANGED
package/interfaces/opcuaif.mjs
CHANGED
|
@@ -39,19 +39,12 @@ export class OPCUAIf extends BaseIf {
|
|
|
39
39
|
buttons
|
|
40
40
|
constructor() {
|
|
41
41
|
super()
|
|
42
|
-
|
|
43
|
-
this.LogInfo(`OPCUAIf Constructed`);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
async stop() {
|
|
47
45
|
if (!this.#client)
|
|
48
46
|
return
|
|
49
|
-
|
|
50
|
-
this.LogInfo(`OPCUAIf Stopping\n`)
|
|
51
|
-
await this.#client.closeSession(this.#session, true)
|
|
52
|
-
await this.#client.disconnect()
|
|
53
|
-
this.#connected = false
|
|
54
|
-
this.#client = null
|
|
47
|
+
await this.Disconnect()
|
|
55
48
|
this.LogInfo(`OPCUAIf Stopped\n`)
|
|
56
49
|
}
|
|
57
50
|
|
|
@@ -91,8 +84,10 @@ export class OPCUAIf extends BaseIf {
|
|
|
91
84
|
const elem = field[key]
|
|
92
85
|
// groupnode
|
|
93
86
|
if (elem.nodeid) {
|
|
94
|
-
|
|
95
|
-
let
|
|
87
|
+
options["key"] = key
|
|
88
|
+
let formattedNodeId = this.formatString(elem.nodeid, options)
|
|
89
|
+
let monitoredItemId = await this.Subscribe(formattedNodeId)
|
|
90
|
+
console.log("Subscribe to",formattedNodeId)
|
|
96
91
|
this.buttons[monitoredItemId] = i
|
|
97
92
|
}
|
|
98
93
|
// statenode
|
|
@@ -221,17 +216,22 @@ export class OPCUAIf extends BaseIf {
|
|
|
221
216
|
|
|
222
217
|
async Disconnect() {
|
|
223
218
|
if (this.#client) {
|
|
224
|
-
this
|
|
225
|
-
|
|
219
|
+
if (this.#session)
|
|
220
|
+
await this.#client.closeSession(this.#session,true)
|
|
221
|
+
this.#session = undefined
|
|
222
|
+
this.#client = undefined
|
|
226
223
|
this.LogInfo(`OPCUAIf: Disconnected\n`);
|
|
227
224
|
}
|
|
228
225
|
}
|
|
229
226
|
async Connect(url) {
|
|
230
227
|
let self = this
|
|
228
|
+
if (this.#client){
|
|
229
|
+
await this.Disconnect()
|
|
230
|
+
}
|
|
231
|
+
|
|
231
232
|
this.#client = OPCUAClient.create({
|
|
232
233
|
applicationName: "NodeOPCUA-Client",
|
|
233
|
-
|
|
234
|
-
endpointMustExist: false,
|
|
234
|
+
endpointMustExist: true,
|
|
235
235
|
// keepSessionAlive: true,
|
|
236
236
|
requestedSessionTimeout: 60 * 1000,
|
|
237
237
|
securityMode: MessageSecurityMode.None,
|
|
@@ -245,10 +245,11 @@ export class OPCUAIf extends BaseIf {
|
|
|
245
245
|
defaultSecureTokenLifetime: 20000,
|
|
246
246
|
tokenRenewalInterval: 1000
|
|
247
247
|
});
|
|
248
|
+
|
|
248
249
|
|
|
249
250
|
this.#client.on("backoff", (retry, delay) => {
|
|
250
|
-
if ((retry % 10) == 0)
|
|
251
|
-
|
|
251
|
+
//if ((retry % 10) == 0)
|
|
252
|
+
// self.LogInfo(`OPCUAIf Try Reconnection ${retry} next attempt in ${delay}ms ${self.#endpointurl}\n`);
|
|
252
253
|
});
|
|
253
254
|
|
|
254
255
|
this.#client.on("connection_lost", () => {
|
package/package.json
CHANGED
package/profile-1.json
CHANGED
|
@@ -24,14 +24,16 @@
|
|
|
24
24
|
"off": {
|
|
25
25
|
"color": "#000099",
|
|
26
26
|
"image": "icons/home.png",
|
|
27
|
-
"cmd": "echo \"{id} {state}\""
|
|
27
|
+
"cmd": "echo \"{id} {state} {pressed}\""
|
|
28
28
|
},
|
|
29
29
|
"on": {
|
|
30
30
|
"color": "#00ff00",
|
|
31
31
|
"image": "icons/home.png",
|
|
32
|
-
"cmd": "echo \"{id} {state}\""
|
|
32
|
+
"cmd": "echo \"{id} {state} {pressed}\""
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
+
"minPressed" : 10000,
|
|
36
|
+
"text" : "{released}",
|
|
35
37
|
"group": ""
|
|
36
38
|
},
|
|
37
39
|
"2": {
|
|
@@ -265,6 +267,6 @@
|
|
|
265
267
|
"endpointurl": "opc.tcp://{hostname}:4840",
|
|
266
268
|
"publishingInterval" : 200,
|
|
267
269
|
"nodeid" : "ns=0;s=nodeID",
|
|
268
|
-
"verbose":
|
|
270
|
+
"verbose": false
|
|
269
271
|
}
|
|
270
272
|
}
|