@things-factory/integration-modbus 4.3.653 → 4.3.671

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-modbus",
3
- "version": "4.3.653",
3
+ "version": "4.3.671",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -22,10 +22,10 @@
22
22
  "clean": "npm run clean:server"
23
23
  },
24
24
  "dependencies": {
25
- "@things-factory/integration-base": "^4.3.653",
25
+ "@things-factory/integration-base": "^4.3.671",
26
26
  "jsmodbus": "^4.0.2",
27
27
  "p-queue": "^6.4.0",
28
28
  "serialport": "^11.0.0"
29
29
  },
30
- "gitHead": "ce1e4e0517cf3b2e513e3adda3061d3406e38a16"
30
+ "gitHead": "ef524cb207378186ec71917d9a8546363d4300b2"
31
31
  }
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./modbus-tcp-server");
4
- require("./modbus-tcp");
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/connector/index.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAC5B,wBAAqB"}
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ModbusTCPServer = void 0;
30
- const integration_base_1 = require("@things-factory/integration-base");
31
- const net_1 = __importDefault(require("net"));
32
- const modbus = __importStar(require("jsmodbus"));
33
- class ModbusTCPServer {
34
- async ready(connectionConfigs) {
35
- await Promise.all(connectionConfigs.map(this.connect));
36
- integration_base_1.ConnectionManager.logger.info('modbus-tcp-servers are ready');
37
- }
38
- async connect(config) {
39
- var [host = '0.0.0.0', port = 502] = config.endpoint.split(':');
40
- const netServer = new net_1.default.Server();
41
- const server = new modbus.server.TCP(netServer);
42
- netServer.on('error', console.error);
43
- netServer.listen(port, host);
44
- /* default client connection */
45
- const clientSocket = new net_1.default.Socket();
46
- const client = new modbus.client.TCP(clientSocket);
47
- clientSocket.on('error', console.error);
48
- clientSocket.connect({ host: 'localhost', port });
49
- client['__server__'] = server;
50
- integration_base_1.ConnectionManager.addConnectionInstance(config, client);
51
- integration_base_1.ConnectionManager.logger.info(`modbus-tcp-server connection(${config.name}:${config.endpoint}) is connected`);
52
- }
53
- async disconnect(connection) {
54
- var client = integration_base_1.ConnectionManager.removeConnectionInstance(connection);
55
- var server = client['__server__'];
56
- client.socket.end();
57
- server && server._server.close();
58
- integration_base_1.ConnectionManager.logger.info(`modbus-tcp-server connection(${connection.name}) is disconnected`);
59
- }
60
- get parameterSpec() {
61
- return [];
62
- }
63
- }
64
- exports.ModbusTCPServer = ModbusTCPServer;
65
- integration_base_1.ConnectionManager.registerConnector('modbus-tcp-server', new ModbusTCPServer());
66
- //# sourceMappingURL=modbus-tcp-server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modbus-tcp-server.js","sourceRoot":"","sources":["../../../server/engine/connector/modbus-tcp-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAA2F;AAC3F,8CAAqB;AACrB,iDAAkC;AAElC,MAAa,eAAe;IAC1B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA;IAC/D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAM;QAClB,IAAI,CAAC,IAAI,GAAG,SAAS,EAAE,IAAI,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/D,MAAM,SAAS,GAAG,IAAI,aAAG,CAAC,MAAM,EAAE,CAAA;QAElC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAE/C,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QACpC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAE5B,+BAA+B;QAC/B,MAAM,YAAY,GAAG,IAAI,aAAG,CAAC,MAAM,EAAE,CAAA;QACrC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAClD,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QACvC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QAEjD,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAA;QAE7B,oCAAiB,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAEvD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,gBAAgB,CAAC,CAAA;IAC/G,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAsB;QACrC,IAAI,MAAM,GAAG,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QACnE,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;QAEjC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QACnB,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QAEhC,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AA3CD,0CA2CC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA"}
@@ -1,161 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ModbusTCPConnector = void 0;
30
- const integration_base_1 = require("@things-factory/integration-base");
31
- const net_1 = __importDefault(require("net"));
32
- const modbus = __importStar(require("jsmodbus"));
33
- const p_queue_1 = __importDefault(require("p-queue"));
34
- const utils_1 = require("@things-factory/utils");
35
- class ModbusTCPConnector {
36
- async ready(connectionConfigs) {
37
- await Promise.all(connectionConfigs.map(this.connect));
38
- integration_base_1.ConnectionManager.logger.info('modbus-tcp connections are ready');
39
- }
40
- async connect(config) {
41
- var [host, port = 502] = config.endpoint.split(':');
42
- var { params } = config;
43
- var clientSocket = new net_1.default.Socket();
44
- var client = new modbus.client.TCP(clientSocket);
45
- clientSocket.on('error', console.error);
46
- clientSocket.connect({ host, port });
47
- var queue = new p_queue_1.default({ concurrency: 1 });
48
- var keepalive = params.keepalive;
49
- integration_base_1.ConnectionManager.addConnectionInstance(config, {
50
- readModBus: async function (objectType, address, quantity, { logger }) {
51
- return await queue.add(async () => {
52
- while (true) {
53
- try {
54
- var response;
55
- switch (objectType) {
56
- case 'descrete input':
57
- response = await client.readDiscreteInputs(address, quantity);
58
- break;
59
- case 'input register':
60
- response = await client.readInputRegisters(address, quantity);
61
- break;
62
- case 'holding register':
63
- response = await client.readHoldingRegisters(address, quantity);
64
- break;
65
- default:
66
- response = await client.readCoils(address, quantity);
67
- }
68
- var data = response && response.response._body.valuesAsArray.slice(0, quantity);
69
- logger.info(`${JSON.stringify(data)}`);
70
- return {
71
- data
72
- };
73
- }
74
- catch (e) {
75
- logger.error('readModBus command failed.');
76
- logger.error(e);
77
- if (keepalive) {
78
- clientSocket && clientSocket.destroy();
79
- clientSocket = new net_1.default.Socket();
80
- client = new modbus.client.TCP(clientSocket);
81
- clientSocket.on('error', console.error);
82
- clientSocket.connect({ host, port });
83
- await (0, utils_1.sleep)(1000);
84
- }
85
- else {
86
- throw e;
87
- }
88
- }
89
- }
90
- });
91
- },
92
- writeSingleModBus: async function (objectType, address, value, { logger }) {
93
- return await queue.add(async () => {
94
- while (true) {
95
- try {
96
- var response;
97
- switch (objectType) {
98
- case 'holding register':
99
- await client.writeSingleRegister(address, parseInt(value));
100
- response = await client.readHoldingRegisters(address, 1);
101
- break;
102
- default:
103
- await client.writeSingleCoil(address, !!Number(value));
104
- response = await client.readCoils(address, 1);
105
- }
106
- var data = response && response.response._body.valuesAsArray[0];
107
- logger.info(data);
108
- return {
109
- data
110
- };
111
- }
112
- catch (e) {
113
- logger.error('writeSingleModBus command failed.');
114
- logger.error(e);
115
- if (keepalive) {
116
- clientSocket && clientSocket.destroy();
117
- clientSocket = new net_1.default.Socket();
118
- client = new modbus.client.TCP(clientSocket);
119
- clientSocket.on('error', console.error);
120
- clientSocket.connect({ host, port });
121
- await (0, utils_1.sleep)(1000);
122
- }
123
- else {
124
- throw e;
125
- }
126
- }
127
- }
128
- });
129
- },
130
- close: function () {
131
- queue.clear();
132
- keepalive = false;
133
- clientSocket.destroy();
134
- }
135
- });
136
- integration_base_1.ConnectionManager.logger.info(`modbus-tcp connection(${config.name}:${config.endpoint}) is connected`);
137
- }
138
- async disconnect(connection) {
139
- var { close } = integration_base_1.ConnectionManager.removeConnectionInstance(connection);
140
- close();
141
- integration_base_1.ConnectionManager.logger.info(`modbus-tcp connection(${connection.name}) is disconnected`);
142
- }
143
- get parameterSpec() {
144
- return [
145
- {
146
- type: 'checkbox',
147
- name: 'keepalive',
148
- label: 'keepalive'
149
- }
150
- ];
151
- }
152
- get taskPrefixes() {
153
- return ['modbus'];
154
- }
155
- get help() {
156
- return 'integration/connector/modbus-tcp';
157
- }
158
- }
159
- exports.ModbusTCPConnector = ModbusTCPConnector;
160
- integration_base_1.ConnectionManager.registerConnector('modbus-tcp', new ModbusTCPConnector());
161
- //# sourceMappingURL=modbus-tcp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modbus-tcp.js","sourceRoot":"","sources":["../../../server/engine/connector/modbus-tcp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAA2F;AAC3F,8CAAqB;AACrB,iDAAkC;AAClC,sDAA4B;AAC5B,iDAA6C;AAE7C,MAAa,kBAAkB;IAC7B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;IACnE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAM;QAClB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnD,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;QAEvB,IAAI,YAAY,GAAG,IAAI,aAAG,CAAC,MAAM,EAAE,CAAA;QACnC,IAAI,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAEhD,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QACvC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAEpC,IAAI,KAAK,GAAG,IAAI,iBAAM,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAA;QAC1C,IAAI,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QAEhC,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gBACjB,KAAK,EAAE,WAAW;aACnB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,kCAAkC,CAAA;IAC3C,CAAC;CACF;AA7ID,gDA6IC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,IAAI,kBAAkB,EAAE,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./connector");
4
- require("./task");
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;AAAA,uBAAoB;AACpB,kBAAe"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./modbus-read");
4
- require("./modbus-write-single");
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,iCAA8B"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const integration_base_1 = require("@things-factory/integration-base");
4
- async function modbusRead(step, { logger, domain }) {
5
- var { connection, params: { objectType = 'coil', address, quantity = 1 } } = step;
6
- var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
7
- if (!client) {
8
- throw new Error(`no connection : ${connection}`);
9
- }
10
- // NOTICE: Keep the previous codes to track the changes before applying keepalive
11
- // var response
12
- // switch (objectType) {
13
- // case 'descrete input':
14
- // response = await client.readCoils(address, quantity)
15
- // break
16
- // case 'input register':
17
- // response = await client.readDiscreteInputs(address, quantity)
18
- // break
19
- // case 'holding register':
20
- // response = await client.readHoldingRegisters(address, quantity)
21
- // break
22
- // default:
23
- // response = await client.readCoils(address, quantity)
24
- // }
25
- // var data = response && response.response._body.valuesAsArray.slice(0, quantity)
26
- // logger.info(`${JSON.stringify(data)}`)
27
- // return {
28
- // data
29
- // }
30
- var { readModBus } = client;
31
- var content = await readModBus(objectType, address, quantity, { logger });
32
- return content;
33
- }
34
- modbusRead.parameterSpec = [
35
- {
36
- type: 'select',
37
- name: 'objectType',
38
- label: 'object-type',
39
- property: {
40
- options: ['', 'coil', 'descrete input', 'input register', 'holding register']
41
- }
42
- },
43
- {
44
- type: 'number',
45
- name: 'address',
46
- label: 'address'
47
- },
48
- {
49
- type: 'number',
50
- name: 'quantity',
51
- label: 'quantity'
52
- }
53
- ];
54
- integration_base_1.TaskRegistry.registerTaskHandler('modbus-read', modbusRead);
55
- //# sourceMappingURL=modbus-read.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modbus-read.js","sourceRoot":"","sources":["../../../server/engine/task/modbus-read.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAElF,KAAK,UAAU,UAAU,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IAChD,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,UAAU,GAAG,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,CAAC,EAAE,EACvD,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,iFAAiF;IACjF,iBAAiB;IAEjB,0BAA0B;IAC1B,6BAA6B;IAC7B,6DAA6D;IAC7D,cAAc;IACd,6BAA6B;IAC7B,sEAAsE;IACtE,cAAc;IACd,+BAA+B;IAC/B,wEAAwE;IACxE,cAAc;IACd,eAAe;IACf,6DAA6D;IAC7D,MAAM;IAEN,oFAAoF;IACpF,2CAA2C;IAE3C,aAAa;IACb,WAAW;IACX,MAAM;IAEN,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;IAC3B,IAAI,OAAO,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IACzE,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,UAAU,CAAC,aAAa,GAAG;IACzB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC;SAC9E;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;CACF,CAAA;AAED,+BAAY,CAAC,mBAAmB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const integration_base_1 = require("@things-factory/integration-base");
4
- async function modbusWriteSingle(step, { logger, domain }) {
5
- var { connection, params: { objectType = 'coil', address, value } } = step;
6
- var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
7
- if (!client) {
8
- throw new Error(`no connection : ${connection}`);
9
- }
10
- // NOTICE: Keep the previous codes to track the changes before applying keepalive
11
- // var response
12
- // switch (objectType) {
13
- // case 'holding register':
14
- // await client.writeSingleRegister(address, parseInt(value))
15
- // response = await client.readHoldingRegisters(address, 1)
16
- // break
17
- // default:
18
- // await client.writeSingleCoil(address, !!value)
19
- // response = await client.readCoils(address, 1)
20
- // }
21
- // var data = response && response.response._body.valuesAsArray[0]
22
- // logger.info(data)
23
- // return {
24
- // data
25
- // }
26
- var { writeSingleModBus } = client;
27
- var content = await writeSingleModBus(objectType, address, value, { logger });
28
- return content;
29
- }
30
- modbusWriteSingle.parameterSpec = [
31
- {
32
- type: 'select',
33
- name: 'objectType',
34
- label: 'object-type',
35
- property: {
36
- options: ['', 'coil', 'holding register']
37
- }
38
- },
39
- {
40
- type: 'number',
41
- name: 'address',
42
- label: 'address'
43
- },
44
- {
45
- type: 'number',
46
- name: 'value',
47
- label: 'value'
48
- }
49
- ];
50
- integration_base_1.TaskRegistry.registerTaskHandler('modbus-write-single', modbusWriteSingle);
51
- //# sourceMappingURL=modbus-write-single.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modbus-write-single.js","sourceRoot":"","sources":["../../../server/engine/task/modbus-write-single.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAElF,KAAK,UAAU,iBAAiB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IACvD,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,UAAU,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAChD,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,iFAAiF;IACjF,iBAAiB;IAEjB,0BAA0B;IAC1B,+BAA+B;IAC/B,mEAAmE;IACnE,iEAAiE;IACjE,cAAc;IACd,eAAe;IACf,uDAAuD;IACvD,sDAAsD;IACtD,MAAM;IAEN,oEAAoE;IACpE,sBAAsB;IAEtB,aAAa;IACb,WAAW;IACX,MAAM;IAEN,IAAI,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAA;IAClC,IAAI,OAAO,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7E,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,iBAAiB,CAAC,aAAa,GAAG;IAChC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,kBAAkB,CAAC;SAC1C;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;CACF,CAAA;AAED,+BAAY,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./engine");
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;AAAA,oBAAiB"}