Update main.js
This commit is contained in:
parent
2f4f9285fa
commit
5fd7a19241
95
main.js
95
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);
|
||||
|
Loading…
Reference in New Issue
Block a user