示例代码:
var processdb = require("processDB");
processdb.connect(8301, 'localhost');
processdb.login('root', 'root',function(result_code){
if(result_code !== 0){
console.log('login failed. error_code: ', result_code);
return;
}
//(点id)获取统计历史数据
var pointId = 1001000001;
var dwBeginTime = '2019-07-11 13:00:00';
var dwEndTime = '2019-07-11 23:00:00';
var dwInterval = 60;
var filterFlag = 0;
var filterLow = 11;
var filterHigh = 21;
var get_stat_his_data_by_pointid_object = new Object;
processdb.cmd_request_stat_his_data_by_pointid(pointId, dwBeginTime, dwEndTime, dwInterval, filterFlag, filterLow, filterHigh, function(result_code, count){
if(result_code !== 0)
{
console.log('cmd_request_stat_his_data_by_pointid failed. error_code: ', result_code);
return;
}
if(count == 0){
console.log('No stat his data.');
return;
}
for(var m = 0;m < count;m++)
{
get_stat_his_data_by_pointid_object = processdb.get_stat_his_data_by_pointid(m);
if(Object.keys(get_stat_his_data_by_pointid_object).length === 0){
console.log('No stat his data.');
return;
}
console.log('stat_history_data_by_pointid,记录数:' + m +' ,' + 'tmTag: ' + get_stat_his_data_by_pointid_object.tmTag + ', nQuality: ' + get_stat_his_data_by_pointid_object.nQuality + ', dSum: ' + get_stat_his_data_by_pointid_object.dSum + ', dMax: ' + get_stat_his_data_by_pointid_object.dMax + ', dMin: ' + get_stat_his_data_by_pointid_object.dMin + ', nCount: ' + get_stat_his_data_by_pointid_object.nCount + ', nDuration: ' + get_stat_his_data_by_pointid_object.nDuration);
}
});
//(点名)获取统计历史数据
var pointName = 'D1.T1.p1';
var get_stat_his_data_by_pointname_object = new Object;
processdb.cmd_request_stat_his_data_by_pointname(pointName, dwBeginTime, dwEndTime, dwInterval, filterFlag, filterLow, filterHigh, function(result_code, count){
if(result_code !== 0)
{
console.log('cmd_request_stat_his_data_by_pointname failed. error_code: ', result_code);
return;
}
if(count == 0){
console.log('No stat his data.');
return;
}
for(var m = 0;m < count;m++)
{
get_stat_his_data_by_pointname_object = processdb.get_stat_his_data_by_pointid(m);
if(Object.keys(get_stat_his_data_by_pointname_object).length === 0){
console.log('No stat his data.');
return;
}
console.log('stat_history_data_by_pointname,记录数:' + m +' ,' + 'tmTag: ' + get_stat_his_data_by_pointname_object.tmTag + ', nQuality: ' + get_stat_his_data_by_pointname_object.nQuality + ', dSum: ' + get_stat_his_data_by_pointname_object.dSum + ', dMax: ' + get_stat_his_data_by_pointname_object.dMax + ', dMin: ' + get_stat_his_data_by_pointname_object.dMin + ', nCount: ' + get_stat_his_data_by_pointname_object.nCount + ', nDuration: ' + get_stat_his_data_by_pointname_object.nDuration);
}
});
});