ProcessDB实时/时序数据库——JavaScript_API查询点位历史时序数据

示例代码:

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);
        }
    });
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值