Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
51cf3df27b
@ -41,11 +41,12 @@ namespace Backend.Controllers
|
||||
{
|
||||
List<Device_value> ds;
|
||||
string url_slot = "slot:/TPE/B1|";
|
||||
string top100 = " top 100 ";
|
||||
string top100 = "";//" top 100 ";
|
||||
webRequestService svc = new webRequestService();
|
||||
string bql = url_slot + "bql:select " + top100 + " * from control:ControlPoint ";
|
||||
//ds = svc.obixQuery("http://192.168.0.136:8080/obix/config/Arena/Program/ObixQuery/query/", bql);
|
||||
ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql);
|
||||
//ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql);
|
||||
ds = svc.obixQuery("http://192.168.0.136:8080/obix/config/Program/ObixQuery/query/", bql);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = ds;
|
||||
|
@ -898,6 +898,9 @@
|
||||
var subSeviceData = []; //每個設備訂閱點位值
|
||||
var floList = []; //每個樓層
|
||||
var elevObj = null; //左側 2D 電梯物件
|
||||
var viewer3DNodeIds = [223, 228, 233];
|
||||
var elev3DBind = {};
|
||||
var elev3DOption = {};
|
||||
var subOrdPath = {
|
||||
"building_tag": pageAct.buiTag,
|
||||
"system_tag": pageAct.sysMainTag,
|
||||
@ -1069,9 +1072,15 @@
|
||||
elevObj.curElevFloor[matchDevice.device_number] = subData["CP"];
|
||||
elevObj.redraw();
|
||||
} else {
|
||||
|
||||
elevObj.setElevFloor(matchDevice.device_number, subData["CP"]);
|
||||
}
|
||||
|
||||
// 左側 3D 電梯 nodeID 與 device_number match
|
||||
if (Object.keys(elev3DBind).indexOf(matchDevice.device_number) == -1) {
|
||||
elev3DBind[matchDevice.device_number] = viewer3DNodeIds[elev3DBind.length];
|
||||
}
|
||||
|
||||
|
||||
elevObj.setEleMovStatus(matchDevice.device_number, subData["RD"] == "UP" ? 1 : subData["RD"] == "DOWN" ? 2 : 0);
|
||||
//現在樓層
|
||||
if (subData["CP"]) {
|
||||
@ -2337,11 +2346,27 @@
|
||||
|
||||
//載入3D模型
|
||||
function load3DModel() {
|
||||
let option = {
|
||||
nodes: [223, 228, 233],
|
||||
element: "#forgeViewer",
|
||||
floorHeight: [
|
||||
{ floor: 1, height: 15 },
|
||||
{ floor: 2, height: 24.5 },
|
||||
{ floor: 3, height: 34 },
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA==', option, () => {
|
||||
console.log($("#forgeViewer"))
|
||||
let elevator = $("#forgeViewer")[0]._elevator3D[0];
|
||||
elevator.obj.setElevatorFloor(3)
|
||||
elevator.obj.movElevator()
|
||||
//setElevatorSpeed(0.2)
|
||||
//setElevatorFloor(2)
|
||||
//requestAnimationFrame(movElevator);
|
||||
});
|
||||
|
||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MFRFU1QlRTMlODAlOTEubndk');
|
||||
setElevatorSpeed(0.2)
|
||||
setElevatorFloor(3)
|
||||
movElevator()
|
||||
}
|
||||
function show3D() {
|
||||
if (isFirstLoad3D) {
|
||||
|
@ -2552,6 +2552,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
/*$('#js-page-content').smartPanel();*/
|
||||
var jwt = localStorage.getItem("JWT-Authorization");
|
||||
var pageAct = {}; //記錄全頁面已選擇項目
|
||||
@ -2563,7 +2564,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
if (location.href.indexOf("ord") != -1) {
|
||||
location.href = "/file/index.html"
|
||||
}
|
||||
|
||||
pageLoading(true)
|
||||
$(function () {
|
||||
// 二次引用 jquery.js
|
||||
// - 在 require 內部程序需要引用 jquery,由於 require 的套件需要依賴 jquery ,就算 HTML 已經引用 jquery, require 也無法參考
|
||||
@ -2741,6 +2742,19 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
|
||||
}
|
||||
|
||||
function pageLoading(isShow = true) {
|
||||
if (isShow) {
|
||||
if ($("body .loading-bg").length == 0) {
|
||||
let background = $(`<div class="loading-bg"></div>`)
|
||||
$("body").append(background);
|
||||
} else {
|
||||
$("body .loading-bg").show();
|
||||
}
|
||||
} else {
|
||||
$("body .loading-bg").hide();
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// ↓ 系統監控 - 共用 Function ↓
|
||||
//==============================================================================
|
||||
|
@ -49,7 +49,7 @@ var elevatorSpeed;
|
||||
// sensorVals[i] = Math.random();
|
||||
// }
|
||||
|
||||
function launchViewer(urn) {
|
||||
function launchViewer(urn, eleOption ,callback) {
|
||||
var options = {
|
||||
env: 'AutodeskProduction',
|
||||
getAccessToken: getForgeToken
|
||||
@ -60,8 +60,14 @@ function launchViewer(urn) {
|
||||
//viewer = new Autodesk.Viewing.Viewer3D(document.getElementById('forgeViewer'));
|
||||
viewer.start();
|
||||
var documentId = 'urn:' + urn;
|
||||
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
|
||||
|
||||
Autodesk.Viewing.Document.load(documentId, function (doc) {
|
||||
onDocumentLoadSuccess(doc, eleOption);
|
||||
}, onDocumentLoadFailure);
|
||||
|
||||
$("#forgeViewer").on("autodesk:loaded", function () {
|
||||
callback ? callback() : "";
|
||||
})
|
||||
|
||||
|
||||
//test
|
||||
@ -118,10 +124,139 @@ function getAllLeafComponents(viewer, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function onDocumentLoadSuccess(doc) {
|
||||
class elevator3D {
|
||||
constructor(option = {}) {
|
||||
this.ele = option.element;
|
||||
this.viewer = option.viewer;
|
||||
this.nodeId = option.nodeId;
|
||||
this.speed = option.speed ?? 0.3;
|
||||
this.fragProxys = [];
|
||||
this.fragProxy = null;
|
||||
this.initCallback = option.inited ?? null;
|
||||
this.movStatus = 0;
|
||||
this.targetFloorZ = 0;
|
||||
this.floorHeight = option.floorHeight ?? [{}];
|
||||
this.init();
|
||||
}
|
||||
|
||||
setTreeFrag = function () {
|
||||
let tree = this.viewer.model.getData().instanceTree;
|
||||
let nodeId = this.nodeId;
|
||||
//tree.enumNodeChildren(nodeId, (node) => {
|
||||
// nodeId = node;
|
||||
// tree.enumNodeFragments(nodeId, (frag) => {
|
||||
// this.fragProxy = this.viewer.impl.getFragmentProxy(this.viewer.model, frag);
|
||||
// this.fragProxy.getAnimTransform();
|
||||
// let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
||||
|
||||
// this.fragProxy.position = fragPosition
|
||||
|
||||
// this.fragProxy.updateAnimTransform()
|
||||
// });
|
||||
//})
|
||||
|
||||
tree.enumNodeFragments(nodeId, (frag) => {
|
||||
let fragProxy = this.viewer.impl.getFragmentProxy(this.viewer.model, frag);
|
||||
this.fragProxy = fragProxy;
|
||||
this.fragProxys.push({ nodeId: nodeId, frag: fragProxy });
|
||||
|
||||
this.fragProxy.getAnimTransform();
|
||||
let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
||||
|
||||
this.fragProxy.position = fragPosition;
|
||||
|
||||
this.fragProxy.updateAnimTransform();
|
||||
},true);
|
||||
|
||||
this.viewer.impl.sceneUpdated(true);
|
||||
if (typeof $(this.ele)[0]._elevator3D == "undefined") {
|
||||
$(this.ele)[0]._elevator3D = [];
|
||||
}
|
||||
$(this.ele)[0]._elevator3D.push({ nodeId: nodeId, obj: this });
|
||||
this.initCallback ? this.initCallback() : "";
|
||||
|
||||
}
|
||||
|
||||
init = function () {
|
||||
this.setTreeFrag();
|
||||
}
|
||||
|
||||
setElevatorFloor = function (floor) {
|
||||
this.targetFloorZ = this.floorHeight.filter(x => x.floor == floor)[0].height;
|
||||
}
|
||||
|
||||
setElevatorSpeed = function (speed) { //0.01 ~ 1
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
movElevator = function () {
|
||||
|
||||
let tree = this.viewer.model.getData().instanceTree;
|
||||
let nodeId = this.nodeId;
|
||||
let fragProxyZ = 0;
|
||||
let movStatus = this.movStatus; // 0=no 1=up 2=down
|
||||
|
||||
|
||||
if (this.fragProxy.position.z > this.targetFloorZ) {
|
||||
movStatus = 2
|
||||
}
|
||||
else if (this.fragProxy.position.z < this.targetFloorZ) {
|
||||
movStatus = 1
|
||||
}
|
||||
|
||||
if (movStatus == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tree.enumNodeFragments(nodeId, (frag) => {
|
||||
this.fragProxy = this.viewer.impl.getFragmentProxy(this.viewer.model, frag);
|
||||
this.fragProxy.getAnimTransform();
|
||||
//let fragPosition = new THREE.Vector3(0, 0, 15);// 一樓0 二樓15 三樓 26
|
||||
if (movStatus == 2) {
|
||||
this.fragProxy.position.z -= this.speed;
|
||||
}
|
||||
else if (movStatus == 1) {
|
||||
this.fragProxy.position.z += this.speed;
|
||||
}
|
||||
|
||||
fragProxyZ = this.fragProxy.position.z;
|
||||
this.fragProxy.updateAnimTransform()
|
||||
|
||||
},true);
|
||||
this.viewer.impl.sceneUpdated(true);
|
||||
|
||||
let movElevator = $(this.ele)[0]._elevator3D.filter(x => x.nodeId == this.nodeId)[0]?.obj.movElevator.bind(this);
|
||||
if (movStatus == 2) {
|
||||
if (fragProxyZ >= this.targetFloorZ) {
|
||||
requestAnimationFrame(() => {
|
||||
movElevator();
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (movStatus == 1) {
|
||||
if (fragProxyZ <= this.targetFloorZ) {
|
||||
requestAnimationFrame(() => {
|
||||
movElevator();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//let fragPosition = new THREE.Vector3(position);// 一樓0 二樓15 三樓 26
|
||||
|
||||
//fragProxy.position = fragPosition;
|
||||
|
||||
//fragProxy.updateAnimTransform();
|
||||
|
||||
//viewer.impl.sceneUpdated(true);
|
||||
}
|
||||
}
|
||||
|
||||
function onDocumentLoadSuccess(doc,eleOption) {
|
||||
var viewables = doc.getRoot().getDefaultGeometry();
|
||||
viewer.loadDocumentNode(doc, viewables).then(i => {
|
||||
// documented loaded, any action?
|
||||
|
||||
});
|
||||
// viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, (args) => {
|
||||
// var currSelection = viewer.getSelection();
|
||||
@ -129,30 +264,48 @@ function onDocumentLoadSuccess(doc) {
|
||||
// domElem.innerText = currSelection[0];
|
||||
// });
|
||||
|
||||
//viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {
|
||||
// var instanceTree = viewer.model.getData().instanceTree;
|
||||
// var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
|
||||
// var domElem = document.getElementById('all_id');
|
||||
// domElem.innerText = allDbIdsStr;
|
||||
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {
|
||||
//var instanceTree = viewer.model.getData().instanceTree;
|
||||
//var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
|
||||
//var domElem = document.getElementById('all_id');
|
||||
//domElem.innerText = allDbIdsStr;
|
||||
let nodes = eleOption.nodes ?? [];
|
||||
let element = eleOption.element ?? "";
|
||||
$(element)[0]._elevator3D = [];
|
||||
$.each(nodes, function (idx, node) {
|
||||
let options = {
|
||||
element: $(element),
|
||||
viewer: viewer,
|
||||
nodeId: node,
|
||||
floorHeight: eleOption.floorHeight ?? [],
|
||||
inited: function () {
|
||||
if (idx == nodes.length - 1) {
|
||||
$(element).trigger("autodesk:loaded");
|
||||
}
|
||||
}
|
||||
}
|
||||
let elevator3DObj = new elevator3D(options);
|
||||
|
||||
// let tree = viewer.model.getData().instanceTree;
|
||||
// let nodeId = 10952;
|
||||
})
|
||||
|
||||
// tree.enumNodeFragments(nodeId, function (frag) {
|
||||
// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||
// fragProxy.getAnimTransform();
|
||||
// let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
||||
//let tree = viewer.model.getData().instanceTree;
|
||||
//let nodeId = 10952;
|
||||
//console.log("tree", tree)
|
||||
//tree.enumNodeFragments(nodeId, function (frag) {
|
||||
// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||
// fragProxy.getAnimTransform();
|
||||
// let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
||||
|
||||
// fragProxy.position = fragPosition
|
||||
// fragProxy.position = fragPosition
|
||||
|
||||
// fragProxy.updateAnimTransform()
|
||||
// fragProxy.updateAnimTransform()
|
||||
//});
|
||||
//viewer.impl.sceneUpdated(true);
|
||||
//$("#forgeViewer").trigger("autodesk:loaded");
|
||||
|
||||
// });
|
||||
// viewer.impl.sceneUpdated(true);
|
||||
});
|
||||
|
||||
//});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function setElevatorFloor(floor) {
|
||||
@ -215,7 +368,7 @@ function movElevator() {
|
||||
requestAnimationFrame(movElevator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//let fragPosition = new THREE.Vector3(position);// 一樓0 二樓15 三樓 26
|
||||
|
||||
|
@ -6,6 +6,15 @@ var varApiUrl = "/api/"; //API路徑
|
||||
var varPathImg = "/Upload/Images/";
|
||||
var varPathFile = "/Upload/Files/";
|
||||
var statusArr = { 1: "啟用", 0: "未啟用", 9: "刪除" };
|
||||
var common = {
|
||||
AddSuc: "新增成功",
|
||||
EditSuc: "編輯成功",
|
||||
DelSuc: "刪除成功",
|
||||
AddErr: "新增失敗,",
|
||||
EditErr: "編輯失敗,",
|
||||
DelErr: "刪除失敗,",
|
||||
SysErr: "系統內部發生錯誤,請聯繫系統管理員"
|
||||
}
|
||||
var objSendData = { Data: null };
|
||||
|
||||
//重新轉址 for Niagara4
|
||||
|
@ -226,3 +226,40 @@ function getOneSystemAlarmStateByBaja(systemPath, callback) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 在單一系統下,取得各個系統的狀態 異常與否
|
||||
* @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
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -34,4 +34,157 @@ function getElectricMeterTotalByBaja(devicePath, timeType, callback) {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得電表即時資料 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()
|
||||
.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
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得電表每小時資料 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:/' + devicePath + '/History/TR_Daily|bql: select * where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0)
|
||||
_ss += '{"timestamp":' + record.get('timestamp') + ', "value":"' + record.get('kwh1') + '"}';
|
||||
else
|
||||
_ss += ',{"timestamp":' + record.get('timestamp') + ', "value":"' + record.get('kwh1') + '"}';
|
||||
_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:/' + devicePath + '/History/TR_Month|bql: select * where timestamp.millis = ' + date_millisecond).get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0)
|
||||
_ss += '{"timestamp":"' + record.get('timestamp') + '", "value":' + record.get('kwh1') + '"}';
|
||||
else
|
||||
_ss += ',{"timestamp":"' + record.get('timestamp') + '", "value":' + record.get('kwh1') + '"}';
|
||||
_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 getElectricMeterWeekDataByBaja(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:/' + devicePath + '/History/TR_Month|bql: select * where timestamp.millis >= ' + startDate_millisecond + ' and timestamp.millis <= ' + endDate_millisecond).get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0)
|
||||
_ss += '{"timestamp":' + record.get('timestamp') + ', "value":"' + record.get('kwh1') + '"}';
|
||||
else
|
||||
_ss += ',{"timestamp":' + record.get('timestamp') + ', "value":"' + record.get('kwh1') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user