即時功率、即時契約容量占比 顯示

This commit is contained in:
koko 2025-04-25 17:38:19 +08:00
parent ea133b022f
commit 7c5ced0604

View File

@ -205,7 +205,7 @@ class subscriptionDevices {
_this.changeCallback(modify_target_device, true); //第2參數用在平面圖刷新畫面 _this.changeCallback(modify_target_device, true); //第2參數用在平面圖刷新畫面
baja.Ord.make( baja.Ord.make(
`local:|foxs:${port}|station:|` + `local:|foxs:${port}|station:|` +
this.getDisplay("slotPath") this.getDisplay("slotPath")
) )
.get() .get()
.then(function (component) { .then(function (component) {
@ -340,7 +340,7 @@ class subscriptionDevices {
$("#sub-end").html(subFinish.toISOString()); $("#sub-end").html(subFinish.toISOString());
$("#sub-time").html( $("#sub-time").html(
(subFinish.getTime() - subStart.getTime()) / 1000 + (subFinish.getTime() - subStart.getTime()) / 1000 +
"sec" "sec"
); );
// console.log("訂閱完成時間", (subFinish.getTime() - subStart.getTime()) / 1000 + "sec"); // console.log("訂閱完成時間", (subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
}); });
@ -945,10 +945,11 @@ function BajaSubscribeElectricmeterByBql(
if (prop.getName() === "out") { if (prop.getName() === "out") {
var out_value = this.getOutDisplay(); var out_value = this.getOutDisplay();
var target_device_number = this.$parent var target_device_number = this.$parent
.getDisplayName() .getName()
.split("_") .split("_")
.slice(0, 5) .slice(0, 5)
.join("_"); .join("_");
var point_name = this.getDisplayName(); var point_name = this.getDisplayName();
//依據Facets判斷回傳的內容值為何 //依據Facets判斷回傳的內容值為何
@ -1001,117 +1002,121 @@ function BajaSubscribeElectricmeterByBql(
); );
//使用bql語法 //使用bql語法
console.log( console.log(
`local:|foxs:${port}|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint` `local:|foxs:${port}|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint`
); );
baja.Ord.make( baja.Ord.make(
`local:|foxs:${port}|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint` `local:|foxs:${port}|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint`
).get(function (table) { )
var tableStart, tableFinish; .get()
var subStart, subFinish; .then(function (table) {
var component_index = 0; console.log('table',table);
var total_component_index = 0;
var totalTargetDevice = [];
var readBqlFinish = new Date(Date.now());
//console.log("讀取路徑完成-花費時間", (readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec");
table.cursor({
before: function () {
totalTargetDevice = [];
tableStart = new Date(Date.now());
$("#table-start-timestamp").html(tableStart.toISOString());
render_start = new Date(Date.now());
},
each: function (item, index) {
if (index < 1) {
subStart = new Date(Date.now());
$("#sub-start").html(subStart.toISOString());
}
$("#sub-number").html(index + 1);
total_component_index = index;
var target_device_number_split = var tableStart, tableFinish;
this.getDisplay("slotPath").split("/"); var subStart, subFinish;
var target_device_number = target_device_number_split[8]; var component_index = 0;
//console.log(target_device_number); var total_component_index = 0;
var point_name = this.getDisplay("name"); var totalTargetDevice = [];
var facets = this.getDisplay("facets"); var readBqlFinish = new Date(Date.now());
//console.log("讀取路徑完成-花費時間", (readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec");
table.cursor({
before: function () {
totalTargetDevice = [];
tableStart = new Date(Date.now());
$("#table-start-timestamp").html(tableStart.toISOString());
render_start = new Date(Date.now());
},
each: function (item, index) {
if (index < 1) {
subStart = new Date(Date.now());
$("#sub-start").html(subStart.toISOString());
}
$("#sub-number").html(index + 1);
total_component_index = index;
//依據Facets判斷回傳的內容值為何 var target_device_number_split =
var facets_split = facets.split(","); this.getDisplay("slotPath").split("/");
var facets_arr = []; var target_device_number = target_device_number_split[8];
facets_split.forEach(function (item, index) { //console.log(target_device_number);
facets_arr.push(item.split("=")); var point_name = this.getDisplay("name");
}); var facets = this.getDisplay("facets");
facets = facets_arr.reduce( //依據Facets判斷回傳的內容值為何
(obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), var facets_split = facets.split(",");
{} var facets_arr = [];
); facets_split.forEach(function (item, index) {
facets_arr.push(item.split("="));
var point_out_split = this.getDisplay("out").split(" ");
let key = Object.keys(facets).find(
(k) => facets[k] === point_out_split[0]
);
if (key == undefined) {
key = point_out_split[0];
}
var modify_target_device = {
device_number: target_device_number ? target_device_number : null,
//"device_number_full": this.getDisplay("slotPath").split("slot:")[1].split('/').slice(1, -1).join("_"),
point_name: point_name ? point_name : null,
value: key,
};
totalTargetDevice.push(modify_target_device);
//取得component當下就更新設備點位
if (
baja_subscribe_electricmeter_callback_func != undefined &&
baja_subscribe_electricmeter_callback_func != null
) {
baja_subscribe_electricmeter_callback_func(modify_target_device);
}
baja.Ord.make(
`local:|foxs:${port}|station:|` + this.getDisplay("slotPath")
)
.get()
.then(function (component) {
component_index++;
//var target_device_number = component.$parent.getDisplayName().split('_').slice(0, 5).join('_');
//var point_name = component.getDisplayName();
sub.subscribe({
comps: component,
});
tolSubList.push(sub);
subFinish = new Date(Date.now());
$("#sub-end").html(subFinish.toISOString());
$("#sub-time").html(
(subFinish.getTime() - subStart.getTime()) / 1000 + "sec"
);
// console.log("訂閱完成時間", (subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
}); });
},
after: function () { facets = facets_arr.reduce(
tableFinish = new Date(Date.now()); (obj, cur) => ({ ...obj, [cur[0]]: cur[1] }),
if (callback !== null) { {}
callback(totalTargetDevice); );
}
if ( var point_out_split = this.getDisplay("out").split(" ");
baja_subscribe_end_electricmeter_callback_func != undefined &&
baja_subscribe_end_electricmeter_callback_func != null let key = Object.keys(facets).find(
) { (k) => facets[k] === point_out_split[0]
baja_subscribe_end_electricmeter_callback_func(totalTargetDevice); );
}
endPageLoading ? endPageLoading() : ""; if (key == undefined) {
//console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); key = point_out_split[0];
}, }
limit: -1,
offset: 0, var modify_target_device = {
device_number: target_device_number ? target_device_number : null,
//"device_number_full": this.getDisplay("slotPath").split("slot:")[1].split('/').slice(1, -1).join("_"),
point_name: point_name ? point_name : null,
value: key,
};
totalTargetDevice.push(modify_target_device);
//取得component當下就更新設備點位
if (
baja_subscribe_electricmeter_callback_func != undefined &&
baja_subscribe_electricmeter_callback_func != null
) {
baja_subscribe_electricmeter_callback_func(modify_target_device);
}
baja.Ord.make(
`local:|foxs:${port}|station:|` + this.getDisplay("slotPath")
)
.get()
.then(function (component) {
component_index++;
//var target_device_number = component.$parent.getDisplayName().split('_').slice(0, 5).join('_');
//var point_name = component.getDisplayName();
sub.subscribe({
comps: component,
});
tolSubList.push(sub);
subFinish = new Date(Date.now());
$("#sub-end").html(subFinish.toISOString());
$("#sub-time").html(
(subFinish.getTime() - subStart.getTime()) / 1000 + "sec"
);
// console.log("訂閱完成時間", (subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
});
},
after: function () {
tableFinish = new Date(Date.now());
if (callback !== null) {
callback(totalTargetDevice);
}
if (
baja_subscribe_end_electricmeter_callback_func != undefined &&
baja_subscribe_end_electricmeter_callback_func != null
) {
baja_subscribe_end_electricmeter_callback_func(totalTargetDevice);
}
endPageLoading ? endPageLoading() : "";
//console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec");
},
limit: -1,
offset: 0,
});
}); });
});
}); });
} }