@things-factory/integration-melsec 9.0.24 → 9.0.25
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/dist-server/engine/task/melsec-read-coil.js +1 -1
- package/dist-server/engine/task/melsec-read-coil.js.map +1 -1
- package/dist-server/engine/task/melsec-read-word.js +1 -1
- package/dist-server/engine/task/melsec-read-word.js.map +1 -1
- package/dist-server/engine/task/melsec-wait-coil.js +1 -1
- package/dist-server/engine/task/melsec-wait-coil.js.map +1 -1
- package/dist-server/engine/task/melsec-write-coil.js +1 -1
- package/dist-server/engine/task/melsec-write-coil.js.map +1 -1
- package/dist-server/engine/task/melsec-write-word.js +1 -1
- package/dist-server/engine/task/melsec-write-word.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -4,7 +4,7 @@ const integration_base_1 = require("@things-factory/integration-base");
|
|
|
4
4
|
const melsec_plc_1 = require("../connector/melsec-plc");
|
|
5
5
|
async function MelsecReadCoil(step, { logger, domain }) {
|
|
6
6
|
var { connection: connectionName, params: { plcAddress: address, readLength: readLength } } = step;
|
|
7
|
-
var connection = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
7
|
+
var connection = await integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
8
8
|
if (!connection) {
|
|
9
9
|
throw new Error(`connection '${connectionName}' is not established.`);
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melsec-read-coil.js","sourceRoot":"","sources":["../../../server/engine/task/melsec-read-coil.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAClF,wDAA4D;AAE5D,KAAK,UAAU,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IACpD,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EA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uD;IACvD,qCAAqC;IACrC,IAAI,OAAO,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA,CAAC,2CAA2C;IAEpG,kCAAkC;IAClC,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QAEpC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACpB,MAAM,CAAC,IAAI,CAAC,sCAAsC,IAAI,EAAE,CAAC,CAAA;QAEzD,OAAO;YACL,IAAI;SACL,CAAA;IACH,CAAC;SAAM,CAAC;QACN,QAAQ;QACR,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;KACrB;CACF,CAAA;AAED,cAAc,CAAC,IAAI,GAAG,mCAAmC,CAAA;AAEzD,+BAAY,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\nimport { MelsecPLCConnector } from '../connector/melsec-plc'\n\nasync function MelsecReadCoil(step, { logger, domain }) {\n var {\n connection: connectionName,\n params: { plcAddress: address, readLength: readLength }\n } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw new Error(`connection '${connectionName}' is not established.`)\n }\n\n var { request } = connection\n\n var deviceCode = address.substring(0, 1) + '*'\n var af_address = Number(address.substring(1)).toString()\n var len = af_address.length\n for (var i = 0; i < 6 - len; i++) {\n af_address = '0' + af_address\n }\n var readStartDevice = af_address\n var sendMessage = MelsecPLCConnector.getReadCoilCommand(deviceCode, readStartDevice, readLength)\n\n // Request : 500000FF03FF000018000004010001M*0001000001\n // Response : D00000FF03FF00000500000\n var content = await request(sendMessage, 23, { logger }) // (22 + readLength)에서 현재 readLength는 1로 고정\n\n // TODO readLength가 1이 아닐때 데이터 처리.\n if (content.substring(17, 18) == '5') {\n var data = content.substring(22, 23)\n\n logger.info(content)\n logger.info(`received response is ok. received: ${data}`)\n\n return {\n data\n }\n } else {\n // error\n throw new Error('response not applicable')\n }\n}\n\nMelsecReadCoil.parameterSpec = [\n {\n type: 'string',\n name: 'plcAddress',\n label: 'plc_address'\n },\n {\n type: 'number',\n name: 'readLength',\n label: 'read_length'\n }\n]\n\nMelsecReadCoil.help = 'integration/task/melsec-read-coil'\n\nTaskRegistry.registerTaskHandler('melsec-read-coil', MelsecReadCoil)\n"]}
|
|
@@ -4,7 +4,7 @@ const integration_base_1 = require("@things-factory/integration-base");
|
|
|
4
4
|
const melsec_plc_1 = require("../connector/melsec-plc");
|
|
5
5
|
async function MelsecReadWord(step, { logger, domain }) {
|
|
6
6
|
var { connection: connectionName, params: { plcAddress: address, signed = false } } = step;
|
|
7
|
-
var connection = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
7
|
+
var connection = await integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
8
8
|
if (!connection) {
|
|
9
9
|
throw new Error(`connection '${connectionName}' is not established.`);
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melsec-read-word.js","sourceRoot":"","sources":["../../../server/engine/task/melsec-read-word.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAClF,wDAA4D;AAE5D,KAAK,UAAU,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IACpD,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,E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AAU,EAAE,eAAe,CAAC,CAAA;IAEpF,uDAAuD;IACvD,wCAAwC;IACxC,IAAI,OAAO,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IAExD,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACzC,IAAI,IAAI,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAElC,IAAI,MAAM,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,IAAI,IAAI,OAAO,CAAA;IACjB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpB,MAAM,CAAC,IAAI,CAAC,sCAAsC,IAAI,EAAE,CAAC,CAAA;IAEzD,OAAO;QACL,IAAI;KACL,CAAA;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,QAAQ;KAChB;CACF,CAAA;AAED,cAAc,CAAC,IAAI,GAAG,mCAAmC,CAAA;AAEzD,+BAAY,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\nimport { MelsecPLCConnector } from '../connector/melsec-plc'\n\nasync function MelsecReadWord(step, { logger, domain }) {\n var {\n connection: connectionName,\n params: { plcAddress: address, signed = false }\n } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw new Error(`connection '${connectionName}' is not established.`)\n }\n\n var { request } = connection\n\n var deviceCode = address.substring(0, 1) + '*'\n var af_address = Number(address.substring(1)).toString()\n var len = af_address.length\n for (var i = 0; i < 6 - len; i++) {\n af_address = '0' + af_address\n }\n var readStartDevice = af_address\n var sendMessage = MelsecPLCConnector.getReadWordCommand(deviceCode, readStartDevice)\n\n // Request : 500000FF03FF000018000004010000D*0001010001\n // Response : D00000FF03FF000008000003E9\n var content = await request(sendMessage, 26, { logger })\n\n var wordValue = content.substring(22, 26)\n var data = parseInt(wordValue, 16)\n\n if (signed && (data & 0x8000) > 0) {\n data -= 0x10000\n }\n\n logger.info(content)\n logger.info(`received response is ok. received: ${data}`)\n\n return {\n data\n }\n}\n\nMelsecReadWord.parameterSpec = [\n {\n type: 'string',\n name: 'plcAddress',\n label: 'plc_address'\n },\n {\n type: 'checkbox',\n name: 'signed',\n label: 'signed'\n }\n]\n\nMelsecReadWord.help = 'integration/task/melsec-read-word'\n\nTaskRegistry.registerTaskHandler('melsec-read-word', MelsecReadWord)\n"]}
|
|
@@ -5,7 +5,7 @@ const utils_1 = require("@things-factory/utils");
|
|
|
5
5
|
const melsec_plc_1 = require("../connector/melsec-plc");
|
|
6
6
|
async function MelsecWaitForCoil(step, { logger, root, domain }) {
|
|
7
7
|
var { connection: connectionName, params: { plcAddress: address, value, waitTerm = 50 } } = step;
|
|
8
|
-
var connection = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
8
|
+
var connection = await integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
9
9
|
if (!connection) {
|
|
10
10
|
throw new Error(`connection '${connectionName}' is not established.`);
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melsec-wait-coil.js","sourceRoot":"","sources":["../../../server/engine/task/melsec-wait-coil.ts"],"names":[],"mappings":";;AAAA,uEAAmH;AACnH,iDAA6C;AAE7C,wDAA4D;AAE5D,KAAK,UAAU,iBAAiB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAW;IACtE,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EA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AG;IAChC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,eAAe;QAC5B,KAAK,EAAE,WAAW;KACnB;CACF,CAAA;AAED,iBAAiB,CAAC,IAAI,GAAG,mCAAmC,CAAA;AAE5D,+BAAY,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["import { ConnectionManager, Context, ScenarioInstanceStatus, TaskRegistry } from '@things-factory/integration-base'\nimport { sleep } from '@things-factory/utils'\n\nimport { MelsecPLCConnector } from '../connector/melsec-plc'\n\nasync function MelsecWaitForCoil(step, { logger, root, domain }: Context) {\n var {\n connection: connectionName,\n params: { plcAddress: address, value, waitTerm = 50 }\n } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw new Error(`connection '${connectionName}' is not established.`)\n }\n\n var { request } = connection\n\n var deviceCode = address.substring(0, 1) + '*'\n var af_address = Number(address.substring(1)).toString()\n var len = af_address.length\n for (var i = 0; i < 6 - len; i++) {\n af_address = '0' + af_address\n }\n var readStartDevice = af_address\n var sendMessage = MelsecPLCConnector.getReadCoilCommand(deviceCode, readStartDevice, undefined)\n\n while (true) {\n let state = root.getState()\n if (state == ScenarioInstanceStatus.STARTED /* STARTED */) {\n var content = await request(sendMessage, 23, { logger })\n\n if (content.substring(17, 18) == '5') {\n var coilValue = content.substring(22, 23)\n\n if (value == coilValue) {\n logger.info('received response is ok. required: %s, received: %s', value, coilValue)\n\n return {\n data: coilValue\n }\n } else {\n logger.info('received response, but not accepted. required: %s, received: %s', value, coilValue)\n await sleep(waitTerm)\n continue\n }\n } else {\n // error\n throw new Error('response not applicable')\n }\n } else if (state == ScenarioInstanceStatus.STOPPED /* PAUSED */) {\n await sleep(waitTerm)\n } else {\n throw new Error('scenario stopped unexpectedly')\n }\n }\n}\n\nMelsecWaitForCoil.parameterSpec = [\n {\n type: 'string',\n name: 'plcAddress',\n label: 'plc_address'\n },\n {\n type: 'string',\n name: 'value',\n label: 'expected_value'\n },\n {\n type: 'number',\n name: 'waitTerm',\n placeholder: 'milli-seconds',\n label: 'wait_term'\n }\n]\n\nMelsecWaitForCoil.help = 'integration/task/melsec-wait-coil'\n\nTaskRegistry.registerTaskHandler('melsec-wait-coil', MelsecWaitForCoil)\n"]}
|
|
@@ -5,7 +5,7 @@ const melsec_plc_1 = require("../connector/melsec-plc");
|
|
|
5
5
|
const utils_1 = require("@things-factory/utils");
|
|
6
6
|
async function MelsecWriteCoil(step, { logger, domain }) {
|
|
7
7
|
var { connection: connectionName, params: { plcAddress: address, value, writeLength = 1, autoReset, delay = 50 } } = step;
|
|
8
|
-
var connection = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
8
|
+
var connection = await integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
9
9
|
if (!connection) {
|
|
10
10
|
throw new Error(`connection '${connectionName}' is not established.`);
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melsec-write-coil.js","sourceRoot":"","sources":["../../../server/engine/task/melsec-write-coil.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAClF,wDAA4D;AAE5D,iDAA6C;AAE7C,KAAK,UAAU,eAAe,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IACrD,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,EAAE,EAC/E,GAAG,IAAI,CAAA;IAER,IAAI,UAAU,GAAG,oCAAiB,CAAC,2BAA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AAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,cAAc;KACtB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,8BAA8B;QAC3C,KAAK,EAAE,aAAa;KACrB;CACF,CAAA;AAED,eAAe,CAAC,IAAI,GAAG,oCAAoC,CAAA;AAE3D,+BAAY,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\nimport { MelsecPLCConnector } from '../connector/melsec-plc'\n\nimport { sleep } from '@things-factory/utils'\n\nasync function MelsecWriteCoil(step, { logger, domain }) {\n var {\n connection: connectionName,\n params: { plcAddress: address, value, writeLength = 1, autoReset, delay = 50 }\n } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw new Error(`connection '${connectionName}' is not established.`)\n }\n\n var { request } = connection\n\n var w_address = address\n var w_value = value\n var deviceCode = w_address.substring(0, 1) + '*'\n\n var af_address = Number(w_address.substring(1)).toString()\n var len = af_address.length\n for (var i = 0; i < 6 - len; i++) {\n af_address = '0' + af_address\n }\n var writeStartDevice = af_address\n\n if (w_value == 1) {\n var writeCoilValue = '1'\n } else {\n var writeCoilValue = '0'\n }\n\n await doRequest(request, deviceCode, writeStartDevice, writeCoilValue, writeLength, logger)\n\n if (autoReset) {\n await sleep(delay)\n\n await doRequest(request, deviceCode, writeStartDevice, Number(!Number(writeCoilValue)), writeLength, logger)\n }\n\n return {\n data: writeCoilValue\n }\n}\n\nasync function doRequest(request, deviceCode, writeStartDevice, writeCoilValue, writeLength, logger) {\n var sendMessage = MelsecPLCConnector.getWriteCoilCommand(deviceCode, writeStartDevice, writeCoilValue, writeLength)\n // Request : 500000FF03FF000019000014010001M*00033300011\n // Response : D00000FF03FF0000040000\n var content = await request(sendMessage, 22, { logger })\n\n // TODO writeLength 1이 아닐때 데이터 처리.\n if (content.substring(17, 18) == '4') {\n // ok\n return {\n data: writeCoilValue\n }\n } else {\n // error\n throw new Error('response not applicable')\n }\n}\n\nMelsecWriteCoil.parameterSpec = [\n {\n type: 'string',\n name: 'plcAddress',\n placeholder: 'M0,Y1,..',\n label: 'plc_address'\n },\n {\n type: 'number',\n name: 'writeLength',\n label: 'write_length'\n },\n {\n type: 'number',\n name: 'value',\n label: 'value'\n },\n {\n type: 'checkbox',\n name: 'autoReset',\n label: 'auto_reset'\n },\n {\n type: 'number',\n name: 'delay',\n placeholder: 'milisecodes, default is 50ms',\n label: 'reset_delay'\n }\n]\n\nMelsecWriteCoil.help = 'integration/task/melsec-write-coil'\n\nTaskRegistry.registerTaskHandler('melsec-write-coil', MelsecWriteCoil)\n"]}
|
|
@@ -5,7 +5,7 @@ const utils_1 = require("@things-factory/utils");
|
|
|
5
5
|
const melsec_plc_1 = require("../connector/melsec-plc");
|
|
6
6
|
async function MelsecWriteWord(step, { data, logger, domain }) {
|
|
7
7
|
var { connection: connectionName, params: { plcAddress: address, accessor, value } } = step;
|
|
8
|
-
var connection = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
8
|
+
var connection = await integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
9
9
|
if (!connection) {
|
|
10
10
|
throw new Error(`connection '${connectionName}' is not established.`);
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melsec-write-word.js","sourceRoot":"","sources":["../../../server/engine/task/melsec-write-word.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAClF,iDAA8C;AAC9C,wDAA4D;AAE5D,KAAK,UAAU,eAAe,C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GAAG,+BAAkB,CAAC,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAA;IACtG,IAAI,OAAO,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IAExD,MAAM,CAAC,IAAI,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAA;IAE5C,OAAO;QACL,IAAI,EAAE,cAAc;KACrB,CAAA;AACH,CAAC;AAED,eAAe,CAAC,aAAa,GAAG;IAC9B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,UAAU;QACvB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;CACF,CAAA;AAED,eAAe,CAAC,IAAI,GAAG,oCAAoC,CAAA;AAE3D,+BAAY,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\nimport { access } from '@things-factory/utils'\nimport { MelsecPLCConnector } from '../connector/melsec-plc'\n\nasync function MelsecWriteWord(step, { data, logger, domain }) {\n var {\n connection: connectionName,\n params: { plcAddress: address, accessor, value }\n } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw new Error(`connection '${connectionName}' is not established.`)\n }\n\n var { request } = connection\n\n var w_address = address\n var deviceCode = w_address.substring(0, 1) + '*'\n\n var af_address = Number(w_address.substring(1)).toString()\n var len = af_address.length\n for (var i = 0; i < 6 - len; i++) {\n af_address = '0' + af_address\n }\n var writeStartDevice = af_address\n\n value = accessor ? access(accessor, data) : value\n if (isNaN(value)) {\n throw new Error(`invalid number value : ${value}`)\n }\n\n var valueDefine = Number(value).toString(16)\n var writeWordValue = ''\n\n if (valueDefine.length == 1) {\n writeWordValue = '000' + Number(value).toString(16)\n } else if (valueDefine.length == 2) {\n writeWordValue = '00' + Number(value).toString(16)\n } else if (valueDefine.length == 3) {\n writeWordValue = '0' + Number(value).toString(16)\n } else if (valueDefine.length == 4) {\n writeWordValue = Number(value).toString(16)\n }\n\n // Request : 500000FF03FF00001C000014010000D*00010000010001\n // Response : D00000FF03FF0000040000\n logger.info(`will send request value: ${value}:${writeWordValue}`)\n\n var sendMessage = MelsecPLCConnector.getWriteWordCommand(deviceCode, writeStartDevice, writeWordValue)\n var content = await request(sendMessage, 22, { logger })\n\n logger.info(`received response: ${content}`)\n\n return {\n data: writeWordValue\n }\n}\n\nMelsecWriteWord.parameterSpec = [\n {\n type: 'string',\n name: 'plcAddress',\n placeholder: 'M0,Y1,..',\n label: 'plc_address'\n },\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'number',\n name: 'value',\n label: 'value'\n }\n]\n\nMelsecWriteWord.help = 'integration/task/melsec-write-word'\n\nTaskRegistry.registerTaskHandler('melsec-write-word', MelsecWriteWord)\n"]}
|