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)获取统计历史数据
    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);
        }
    });
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值