Update main.js
This commit is contained in:
25
main.js
25
main.js
@@ -245,6 +245,17 @@ function pollData() {
|
||||
}
|
||||
|
||||
|
||||
function checkDeviceIds(options, config, deviceIds) {
|
||||
|
||||
for (let i = config.length - 1; i >= 0; i--) {
|
||||
config[i].deviceId = !options.config.multiDeviceId ? options.config.defaultDeviceId : (config[i].deviceId !== undefined ? parseInt(config[i].deviceId, 10) : options.config.defaultDeviceId);
|
||||
if (isNaN(config[i].deviceId)) config[i].deviceId = options.config.defaultDeviceId;
|
||||
if (deviceIds.indexOf(config[i].deviceId) === -1) {
|
||||
deviceIds.push(config[i].deviceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function prepareConfig(config) {
|
||||
let params = config.params;
|
||||
|
||||
@@ -252,12 +263,18 @@ function prepareConfig(config) {
|
||||
config: {
|
||||
type: 'tcp',
|
||||
round: 0,
|
||||
timeout: 5000
|
||||
// defaultDeviceId: (params.deviceId === undefined || params.deviceId === null) ? 1 : (parseInt(params.deviceId, 10) || 0),
|
||||
timeout: 5000,
|
||||
defaultDeviceId: 0,
|
||||
},
|
||||
devices: {}
|
||||
};
|
||||
|
||||
let deviceIds = [];
|
||||
checkDeviceIds(options, config.disInputs, deviceIds);
|
||||
|
||||
deviceIds.sort();
|
||||
|
||||
|
||||
options.objects = objects;
|
||||
|
||||
return options;
|
||||
@@ -269,7 +286,7 @@ function parseConfig(callback) {
|
||||
|
||||
adapter.log.info('初始化: ' + adapter.config.door);
|
||||
|
||||
let options = prepareConfig(adapter.config);
|
||||
// let options = prepareConfig(adapter.config);
|
||||
const params = adapter.config.params;
|
||||
|
||||
|
||||
@@ -295,7 +312,7 @@ function checkObjects(options, regType, regName, regFullName, tasks, newObjects)
|
||||
let regs = options[regType];
|
||||
|
||||
for (let i = 0; regs.length > i; i++) {
|
||||
const id = adapter.namespace + '.' + regs[i].id;
|
||||
const id = adapter.namespace + '.' + regs[i].deviceId;
|
||||
|
||||
adapter.log.info("id=" + id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user