2022-11-28 23:35:14 +08:00
|
|
|
|
/**
|
|
|
|
|
* 取得電表總計資料 by baja
|
|
|
|
|
* @param {any} devicePath
|
|
|
|
|
* @param {any} timeType
|
|
|
|
|
* @param {any} callback
|
|
|
|
|
*/
|
|
|
|
|
function getElectricMeterTotalByBaja(devicePath, timeType, callback) {
|
|
|
|
|
var _result = "";
|
|
|
|
|
var _ss = "";
|
|
|
|
|
var _index = 0;
|
|
|
|
|
|
|
|
|
|
require(['baja!'], function (baja) {
|
|
|
|
|
console.log('transform:slot:/' + devicePath + '/History/' + timeType);
|
|
|
|
|
baja.Ord.make('transform:slot:/' + devicePath + '/History/' + timeType).get()
|
|
|
|
|
.then(function (table) {
|
|
|
|
|
return table.cursor({
|
|
|
|
|
each: function (record) {
|
|
|
|
|
if (_index == 0)
|
|
|
|
|
_ss += '{"timestamp":"' + record.get('timestamp') + '", "MP1":' + record.get('MP1') + '"}';
|
|
|
|
|
else
|
|
|
|
|
_ss += ',{"timestamp":"' + record.get('timestamp') + '", "MP1":' + record.get('MP1') + '"}';
|
|
|
|
|
_index++;
|
|
|
|
|
},
|
|
|
|
|
after: function () {
|
|
|
|
|
_result += '{' + '"count": ' + _index + ', "data":[';
|
|
|
|
|
_result += _ss;
|
|
|
|
|
_result += ']}';
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
|
callback(_result);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
limit: -1,
|
|
|
|
|
offset: 0
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2022-12-01 01:41:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 取得電表即時資料 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
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2022-11-28 23:35:14 +08:00
|
|
|
|
}
|