ibms-dome/Frontend/js/n4js/elevatorbaja.js

78 lines
3.5 KiB
JavaScript
Raw Normal View History


function getElevatorInfoByBaja(path, callback) {
var _result = "";
var _ss = '{';
var _index = 0;
//
require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|station:|slot:/" + path + "|bql:select name, displayName, out, out.value, slotPath, parent.name as 'device_number' from control:ControlPoint where name = 'CP' or name = 'RD' or name = 'DS' or name = 'ST' or name = 'LOAD' or name = 'MID' or name = 'HAND' or name = 'IND' or name = 'MD' or name = 'DNO'").get()
.then(function (table) {
return table.cursor({
each: function (record) {
var item = null;
var value = null;
if (record.get('name') == "CP") {
item = "floor";
value = record.get('out').get('value');
}
else if (record.get('name') == "RD") { //UP or DOWN
item = "direction";
value = record.get('out').get('value');
}
else if (record.get('name') == "DS") {
item = "door_state";
value = record.get('out').get('value') == true ? "OPEN" : "CLOSE";
}
else if (record.get('name') == "ST") {
item = "running_status";
value = record.get('out').get('value');
}
else if (record.get('name') == "LOAD") {
item = "loading";
value = record.get('out').get('value');
}
else if (record.get('name') == "MID") {
item = "maintenance";
value = record.get('out').get('value');
}
else if (record.get('name') == "HAND") {
item = "manual";
value = record.get('out').get('value');
}
else if (record.get('name') == "IND") {
item = "independent";
value = record.get('out').get('value');
}
else if (record.get('name') == "MD") {
item = "vip";
value = record.get('out').get('value');
}
else if (record.get('name') == "DNO") {
item = "automatic";
value = record.get('out').get('value');
}
if (item != null && item != "") {
if (_index == 0)
_ss += '{"item":"' + item + '", "value":"' + value + '"}';
else
_ss += ',{"item":"' + item + '", "value":"' + value + '"}';
_index++;
}
},
after: function () {
_result += '{' + '"count": ' + _index + ', "data":[';
_result += _ss;
_result += ']}';
if (typeof callback === 'function') {
callback(_result);
}
}
});
});
});
}