Added "label" to device model
This commit is contained in:
@@ -1,6 +1,44 @@
|
||||
const dbcontroller = require('../db');
|
||||
const util = require('../util');
|
||||
|
||||
const deviceUsesPrograms = function(device) {
|
||||
switch (device.msn.slice(0,2).toUpperCase() || 'xx') {
|
||||
case '1F':
|
||||
case '20':
|
||||
case '51':
|
||||
case '53':
|
||||
case '55':
|
||||
case '5A':
|
||||
case '7A': return false;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (device.programs != undefined) { return true; }
|
||||
if (device.programs == undefined && device.slots == undefined) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const deviceUsesSlots = function(device) {
|
||||
switch (device.msn.slice(0,2).toUpperCase() || 'xx') {
|
||||
case '1F':
|
||||
case '20':
|
||||
case '51':
|
||||
case '53':
|
||||
case '55':
|
||||
case '5A':
|
||||
case '7A': return true;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (device.slots != undefined) { return true; }
|
||||
if (device.programs == undefined && device.slots == undefined) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const postRequestToDo = async function (msn, body) {
|
||||
try {
|
||||
await dbcontroller.addDevice(body, null)
|
||||
@@ -30,23 +68,23 @@ const getRequestToDo = async function (msn) {
|
||||
var todo = { serialNumber : msn }
|
||||
|
||||
///// Programs
|
||||
if (device.programs != undefined) {
|
||||
if (child.programmingTimestamp != undefined && deviceUsesPrograms(child)) {
|
||||
timestamp = child.programmingTimestamp || -1
|
||||
if (timestamp < device.programs.timestamp) { todo.programs = 1 }
|
||||
if ((device.programs == undefined) || (timestamp < device.programs.timestamp)) { todo.programs = 1 }
|
||||
else if (timestamp > device.programs.timestamp) { todo.programs = 2 }
|
||||
}
|
||||
|
||||
///// Configuration
|
||||
if (device.configuration != undefined) {
|
||||
if (child.configurationTimestamp != undefined) {
|
||||
timestamp = child.configurationTimestamp || child.relayConfigurationTimestamp || -1
|
||||
if (timestamp < device.configuration.timestamp) { todo.configuration = 1 }
|
||||
if ((device.configuration == undefined) || (timestamp < device.configuration.timestamp)) { todo.configuration = 1 }
|
||||
else if (timestamp > device.configuration.timestamp) { todo.configuration = 2 }
|
||||
}
|
||||
|
||||
///// Slots
|
||||
if (device.slots != undefined) {
|
||||
if (child.programmingTimestamp != undefined && deviceUsesSlots(child)) {
|
||||
timestamp = child.programmingTimestamp || -1
|
||||
if (timestamp < device.slots.timestamp) { todo.slots = 1 }
|
||||
if ((device.slots == undefined) || (timestamp < device.slots.timestamp)) { todo.slots = 1 }
|
||||
else if (timestamp > device.slots.timestamp) { todo.slots = 2 }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user