示例代码:
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)获取采样历史数据
// float32--0 digital--1 bBool--2 uInt8--3 Int8--4 uInt16--5 Int16--6 nuInt32--7 nInt32--8 nuInt64--9 nInt64--10 fFloat64--11 nTime--12
// var pointIdList = [1002000002, 1002000003,'1002000004 ', '1002000005', '1002000006', '1002000007', '1002000008', '1002000009', '1002000010', '1002000011','1002000012', '1002000013','1002000014'];
var pointIdList = 1002000002;
var dwBeginTime = '2019-07-11 16:40:00';
var dwEndTime = '2019-07-11 16:50:00';
var dwInterval = 1;
var filterFlag = 0;
var filterLow = 11;
var filterHigh = 21;
var get_sample_his_data_object = new Object;
processdb.cmd_request_sample_his_data_by_pointid(pointIdList, dwBeginTime, dwEndTime, dwInterval, filterFlag, filterLow, filterHigh,function(result_code, count){
if(result_code !== 0)
{
console.log('cmd_request_sample_his_data_by_pointid failed. error_code: ', result_code);
return;
}
if(count == 0)
{
console.log('No sample his data.');
return;
}
for(var i = 0; i < count; i++)
{
get_sample_his_data_object = processdb.get_sample_his_data(i);
if(Object.keys(get_sample_his_data_object).length === 0)
{
console.log('No sample his data.');
return;
}
console.log('sample_history_data_by_pointid,记录数:' + i+' ,' + 'nSecond: ' + get_sample_his_data_object.nSecond + ', nMilliSecond: ' + get_sample_his_data_object.nMilliSecond + ', nQuality: ' + get_sample_his_data_object.nQuality + ', nTagType: ' + get_sample_his_data_object.nTagType + ', hValue: ' + get_sample_his_data_object.hValue);
}
});
//(点名)获取采样历史数据
// var pointNameList = ['D1.T1.p1','D1.T1.p2','D1.T1.p3','D1.T1.p4','D1.T1.p5','D1.T1.p6','D1.T1.p7','D1.T1.p8','D1.T1.p9','D1.T1.p10','D1.T1.p11','D1.T1.p12','D1.T1.p13','D1.T1.p14'];
var pointNameList = 'D1.T1.p2';
var get_sample_his_data_object_ = new Object;
processdb.cmd_request_sample_his_data_by_pointname(pointNameList, dwBeginTime, dwEndTime, dwInterval, filterFlag, filterLow, filterHigh,function(result_code, count){
if(result_code !== 0)
{
console.log('cmd_request_sample_his_data_by_pointname failed. error_code: ', result_code);
return;
}
if(count == 0)
{
console.log('No sample his data.');
return;
}
for(var i = 0; i < count; i++)
{
get_sample_his_data_object_ = processdb.get_sample_his_data(i);
console.log('sample_history_data_by_pointname,记录数:' + i+' ,' + 'nSecond: ' + get_sample_his_data_object_.nSecond + ', nMilliSecond: ' + get_sample_his_data_object_.nMilliSecond + ', nQuality: ' + get_sample_his_data_object_.nQuality + ', nTagType: ' + get_sample_his_data_object_.nTagType + ', hValue: ' + get_sample_his_data_object_.hValue);
}
});
});