From 5fd7a192413b47c07f2ced63fa36683f2dfd2f5c Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 8 Nov 2018 09:47:24 +0800 Subject: [PATCH] Update main.js --- main.js | 95 +++------------------------------------------------------ 1 file changed, 5 insertions(+), 90 deletions(-) diff --git a/main.js b/main.js index 7ee0ed7..a1a4377 100644 --- a/main.js +++ b/main.js @@ -209,6 +209,7 @@ function processTasks(tasks, callback) { function prepareConfig(config) { let params = config.params; + params.slave = parseInt(params.slave, 10) || 0; // required in stop let options = { @@ -229,11 +230,6 @@ function prepareConfig(config) { let deviceIds = []; - //checkDeviceIds(options, config.disInputs, deviceIds); - //checkDeviceIds(options, config.coils, deviceIds); - //checkDeviceIds(options, config.inputRegs, deviceIds); - //checkDeviceIds(options, config.holdingRegs, deviceIds); - deviceIds.sort(); // settings for master if (!options.config.slave) { @@ -252,93 +248,10 @@ function prepareConfig(config) { }; } - for (let d = 0; d < deviceIds.length; d++) { - let deviceId = deviceIds[d]; - options.devices[deviceId] = {}; - let device = options.devices[deviceId]; - if (options.config.slave) { - device.disInputs = { - fullIds: [], - changed: true, - addressHigh: 0, - addressLow: 0, - values: [], - mapping: {}, - offset: parseInt(params.disInputsOffset, 10) - }; - - device.coils = { - fullIds: [], - changed: true, - addressHigh: 0, - addressLow: 0, - values: [], - mapping: {}, - offset: parseInt(params.coilsOffset, 10) - }; - - device.inputRegs = { - fullIds: [], - changed: true, - addressHigh: 0, - addressLow: 0, - values: [], - mapping: {}, - offset: parseInt(params.inputRegsOffset, 10) - }; - - device.holdingRegs = { - fullIds: [], - changed: true, - addressHigh: 0, - addressLow: 0, - values: [], - mapping: {}, - offset: parseInt(params.holdingRegsOffset, 10) - }; - } else { - device.disInputs = { - deviceId: deviceId, - addressLow: 0, - length: 0, - config: [], - blocks: [], - offset: parseInt(params.disInputsOffset, 10) - }; - - device.coils = { - deviceId: deviceId, - addressLow: 0, - length: 0, - config: [], - blocks: [], - cyclicWrite: [], // only holdingRegs and coils - offset: parseInt(params.coilsOffset, 10) - }; - - device.inputRegs = { - deviceId: deviceId, - addressLow: 0, - length: 0, - config: [], - blocks: [], - offset: parseInt(params.inputRegsOffset, 10) - }; - - device.holdingRegs = { - deviceId: deviceId, - addressLow: 0, - length: 0, - config: [], - blocks: [], - cyclicWrite: [], // only holdingRegs and coils - offset: parseInt(params.holdingRegsOffset, 10) - }; - } - } - options.objects = objects; + adapter.log.warn('objects=' + objects); + return options; } @@ -566,6 +479,8 @@ function parseConfig(callback) { let tasks = []; + adapter.log.warn('options.devices=' + options.devices); + for (let _deviceId in options.devices) { adapter.log.warn('_deviceId=' + _deviceId);