[Frontend] 修改baja,刪除無用的函式
This commit is contained in:
parent
22e68815a6
commit
a443c06001
@ -242,15 +242,11 @@ function getOneSystemStateByBaja(systemPath, callback) {
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
//if (_index == 0)
|
||||
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
//else
|
||||
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
_ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += '{' + '"count": ' + _index + ', "system":"' + systemPath + '", "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
|
@ -42,8 +42,6 @@ function MyBaja() {
|
||||
* 使用者透過BQL指定路徑去訂閱設備點位
|
||||
*/
|
||||
function BajaSubscribeDevicesByBql() {
|
||||
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log("進入Function 準備執行BQL訂閱");
|
||||
var init_start = new Date(Date.now());
|
||||
@ -224,294 +222,3 @@ function BajaSubscribeDevicesByBql() {
|
||||
});
|
||||
}
|
||||
|
||||
function getElevatorInfoByBaja(path, callback) {
|
||||
var _result = "";
|
||||
var _ss = '{';
|
||||
var _index = 0;
|
||||
//
|
||||
require(['baja!'], function (baja) {
|
||||
baja.Ord.make("local:|foxs:|station:|slot:/TPE/B1/ELEV/EL/R2F/NA/ELEV1/N1|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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// baja.Ord.make('ip:greencloud.fic.com.tw|foxs:|station:|slot:/Arena/H/F3|bql:select name, displayname, slotPath, out.value, out from control:ControlPoint')
|
||||
// // baja.Ord.make('ip:greencloud.fic.com.tw|foxs:|station:|slot:/Arena/H/E1/B1F/TestData/H_E1_B1F_TestData_Data|bql:select slotPath,out.value from control:NumericWritable')
|
||||
// .get(
|
||||
// function (table) {
|
||||
// var tableStart, tableFinish;
|
||||
// var subStart, subFinish;
|
||||
// var readBqlFinish = new Date(Date.now());
|
||||
// $("#readPath-finish-timestamp").html(readBqlFinish.toISOString());
|
||||
// $("#readPath-finish-time").html((readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec");
|
||||
|
||||
// table.cursor({
|
||||
// before: function () {
|
||||
// tableStart = new Date(Date.now());
|
||||
// $("#table-start-timestamp").html(tableStart.toISOString());
|
||||
|
||||
// subStart = new Date(Date.now());
|
||||
// $("#sub-start-timestamp").html(subStart.toISOString());
|
||||
|
||||
// render_start = new Date(Date.now());
|
||||
// },
|
||||
// each: function (item, index) {
|
||||
|
||||
// // console.log("local:|foxs:|station:|" + this.getDisplay("slotPath"));
|
||||
// baja.Ord.make("local:|foxs:|station:|" + this.getDisplay("slotPath"))
|
||||
// .get()
|
||||
// .then(function (component) {
|
||||
// //紀錄 未render前花費約5秒
|
||||
// $("#render-points").append(`
|
||||
// <div>
|
||||
// <label>${component.getDisplayName()}</label>
|
||||
// <div id="${component.getDisplayName()}-value" style="text-align: center;">${component.getOutDisplay()}</div>
|
||||
// </div>
|
||||
// `);
|
||||
|
||||
// sub.subscribe({
|
||||
// comps: component,
|
||||
// });
|
||||
|
||||
// $("#sub-point-name").html(component.getDisplayName());
|
||||
|
||||
// subFinish = new Date(Date.now());
|
||||
// $("#sub-finish-timestamp").html(subFinish.toISOString()); $("#sub-finish-timestamp").html(subFinish.toISOString());
|
||||
// $("#sub-time").html((subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
|
||||
// });
|
||||
// },
|
||||
// after: function () {
|
||||
// tableFinish = new Date(Date.now());
|
||||
// $("#table-finish-timestamp").html(tableFinish.toISOString());
|
||||
// $("#table-time").html((tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec");
|
||||
// },
|
||||
// limit: -1,
|
||||
// offset: 0
|
||||
// });
|
||||
// })
|
||||
|
||||
|
||||
//測試
|
||||
/**
|
||||
* 取得電表即時資料 by baja
|
||||
* @param {any} devicePath
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getElectricMeterNoweDataByBaja(devicePath, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {//TPE/B1/EE/E4/R2F/NA/WHT/N1
|
||||
console.log('local:|foxs:|station:|slot:/' + devicePath + '|bql:select name, out, out.value from control:ControlPoint');
|
||||
//baja.Ord.make('local:|foxs:|station:|slot:/' + devicePath + '|bql:select name, out, out.value from control:ControlPoint').get()
|
||||
baja.Ord.make('local:|foxs:|station:|slot:/TPE/B1/EE/E4/R2F/NA/WHT/N1|bql:select name, out, out.value from control:ControlPoint').get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0)
|
||||
_ss += '{"name":"' + record.get('name') + '", "value":' + record.get('out').get('value') + '"}';
|
||||
else
|
||||
_ss += ',{"name":"' + record.get('name') + '", "value":' + record.get('out').get('value') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得電表 單日kwh by baja
|
||||
* @param {any} devicePath
|
||||
* @param {any} date_millisecond
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getElectricMeterOneDayKwhByBaja(devicePath, date_millisecond, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {//TPE/B1/EE/E4/R2F/NA/WHT/N1
|
||||
console.log('transform:slot:/' + devicePath + '/History/TR_Month|bql: select * where timestamp.millis = ' + date_millisecond);
|
||||
baja.Ord.make('transform:slot:/TPE/B1/EE/E4/R2F/NA/WHT/N1/History/TR_Month|bql: select * where timestamp.millis <= 1667404799000').get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0) {
|
||||
//_ss += '{"timestamp":"' + record.get('timestamp') + '", "kwh1":' + record.get('kwh1') + '"}';
|
||||
_ss += '{"timestamp":"' + record.get('timestamp') + '"}';
|
||||
}
|
||||
else {
|
||||
//_ss += ',{"timestamp":"' + record.get('timestamp') + '", "kwh1":' + record.get('kwh1') + '"}';
|
||||
_ss += ',{"timestamp":"' + record.get('timestamp') + '"}';
|
||||
}
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得電表每小時資料 by baja
|
||||
* @param {any} devicePath
|
||||
* @param {any} startDate_millisecond
|
||||
* @param {any} endDate_millisecond
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getElectricMeterHourDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {//TPE/B1/EE/E4/R2F/NA/WHT/N1
|
||||
console.log('transform:slot:/' + devicePath + '/History/TR_Daily|bql: select * where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond);
|
||||
baja.Ord.make('transform:slot:/TPE/B1/EE/E4/R2F/NA/WHT/N1/History/TR_Daily|bql: select timestamp, kwh1 where timestamp.millis >= 1667232000000 and timestamp.millis <= 1667404799000').get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0)
|
||||
_ss += '{"kwh1":' + record.get('kwh1') + ', "timestamp":"' + record.get('timestamp') + '"}';
|
||||
else
|
||||
_ss += ',{"kwh1":' + record.get('kwh1') + ', "timestamp":"' + record.get('timestamp') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 在單一系統下,取得各個系統的狀態 異常與否
|
||||
* @param {any} systemPath
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getOneSystemStateByBaja(systemPath, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
baja.Ord.make("local:|foxs:|alarm:|bql:select top 1 alarmData, alarmData.sourceName, sourceState where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
//if (_index == 0)
|
||||
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
//else
|
||||
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
_ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
|
||||
|
||||
/**
|
||||
* 取得電梯資料 by baja
|
||||
* @param {any} path
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getElevatorInfoByBaja(path, callback) {
|
||||
var _result = "";
|
||||
var _ss = '{';
|
||||
|
Loading…
Reference in New Issue
Block a user