From 0f846ef8449a744dd59010100b004ac7fa60a2b7 Mon Sep 17 00:00:00 2001 From: Phillip Pietruschka Date: Sun, 14 Jan 2024 19:47:33 +1100 Subject: [PATCH] subscribeFeedbacks on connect crosspoint feedback remove parsing of variable which is not accepted. --- companion/HELP.md | 2 +- src/feedbacks.js | 14 ++++---------- src/main.js | 6 +++--- src/tcp.js | 2 ++ 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/companion/HELP.md b/companion/HELP.md index b27c634..b5beafa 100644 --- a/companion/HELP.md +++ b/companion/HELP.md @@ -31,7 +31,7 @@ The alarms should match the number of configured alarm indexs in your system. Re ## Version History ### Version 1.0.2 -- Minor TCP improvements +- Minor TCP improvements & fixes ### Version 1.0.1 - Update dependencies diff --git a/src/feedbacks.js b/src/feedbacks.js index 9a0bbfa..ae76c8f 100644 --- a/src/feedbacks.js +++ b/src/feedbacks.js @@ -30,17 +30,11 @@ module.exports = async function (self) { callback: ({ options }) => { return self.connections[options.dst] == options.src }, - subscribe: async ({ options }) => { - let cmd = SOM + control.reqInterrogate + appTag.crosspoint + options.dst + paramSep + nullParam - self.addCmdtoQueue(cmd) + subscribe: ({ options }) => { + self.addCmdtoQueue(SOM + control.reqInterrogate + appTag.crosspoint + options.dst + paramSep + nullParam) }, - learn: async (feedback) => { - let dst = parseInt(await self.parseVariablesInString(feedback.options.dst)) - if (isNaN(dst) || dst < 1 || dst > self.config.dst) { - self.log('warn', `an invalid varible has been passed: ${dst}`) - return undefined - } - const source = self.connections[dst] + learn: (feedback) => { + const source = self.connections[feedback.options.dst] return { ...feedback.options, src: source, diff --git a/src/main.js b/src/main.js index f442453..67c3089 100644 --- a/src/main.js +++ b/src/main.js @@ -35,10 +35,10 @@ class NTP_DOT_PROTOCOL extends InstanceBase { this.log('debug', `destroy. ID: ${this.id}`) clearTimeout(this.keepAliveTimer) clearTimeout(this.cmdTimer) - this.keepAliveTimer = null - this.cmdTimer = null + delete this.keepAliveTimer + delete this.cmdTimer if (this.socket) { - await this.sendCommand(EndSession) + this.sendCommand(EndSession) this.socket.destroy() } else { this.updateStatus(InstanceStatus.Disconnected) diff --git a/src/tcp.js b/src/tcp.js index 9fc0c76..7b61323 100644 --- a/src/tcp.js +++ b/src/tcp.js @@ -51,6 +51,8 @@ module.exports = { this.addCmdtoQueue(SOM + control.reqNotification + appTag.alive + 1 + paramSep + 0) //request alarm notifications this.addCmdtoQueue(SOM + control.reqNotification + appTag.alarm + 1 + paramSep + 1) + //make sure all feedbacks are accurate + this.subscribeFeedbacks() return true },