采集数据查询接口说明

接口使用application/json数据方式进行传输

地址为ip:port/aciton/test?

一、采集数据查询相关接口

1、按照变量ID(varid)查询采集信息

  • 参数列表:

    1)cmd=dc_get_redis

    2)var_ids变量ID,格式形如 12334,234,323 多个ID中间使用,分隔。

    3)dc_loc_id 采集地点编号必须

{
    "cmd": "dc_get_redis",
    "var_ids": "2589,2590",
    "dc_loc_id":"1067"
}
  • 返回值:
{
    "code": "1",
    "help": [
        {
            "var_id": "2589",
            "var_name": "hj_alarm_hjbr",
            "value": "15730",
            "pick_time": "2021-03-26 13:01:05",
            "is_warn": "0",
            "eqpt_id": "1224"
        },
        {
            "var_id": "2590",
            "var_name": "hj_alarm_emerg",
            "value": "15685",
            "pick_time": "2021-03-26 13:01:05",
            "is_warn": "0",
            "eqpt_id": "1224"
        }
    ]
}

2、按站点编号(dc_loc_id)查询采集信息

方法一:

  • 参数列表:

    1)cmd=dc_get_by_dc_loc_id

    2)dc_loc_id 站点编号。

{
    "cmd": "dc_get_by_dc_loc_id_redis",
    "dc_loc_id":"1067"
}
  • 返回值:
{
    "code": "1",
    "help": [
        {
            "var_id": "2589",
            "var_name": "hj_alarm_hjbr",
            "value": "15915",
            "pick_time": "2021-03-26 13:03:51",
            "is_warn": "0",
            "eqpt_id": "1224"
        },
        {
            "var_id": "2590",
            "var_name": "hj_alarm_emerg",
            "value": "15870",
            "pick_time": "2021-03-26 13:03:51",
            "is_warn": "0",
            "eqpt_id": "1224"
        },
        {
            "var_id": "5577",
            "var_name": "cy_mode_lx",
            "value": "15915",
            "pick_time": "2021-03-26 13:03:51",
            "is_warn": "0",
            "eqpt_id": "1224"
        }
    ]
}

方法二:

  • 参数列表:

    1)cmd=dc_get_by_dc_loc_id

    2)file文件名称

    3)dc_loc_id 站点编号

{
    "file": "tsdb_query_tech",
    "cmd": "query_dc_loc_var",
    "dc_loc_id": "1086"
}
  • 返回值:
{
    "code": "1",
    "error": "",
    "help": [
        {
            "eqpt_id_main": "1335",
            "dc_loc_id": "1086",
            "dc_dev_model_name": "通用Modbus",
            "var_id": "5007",
            "dc_dev_id": "1228",
            "dc_addr_map_id": "272",
            "offset_addr": "0",
            "start_addr": "0",
            "value_type": "0",
            "data_type": "7",
            "var_name": "ls_temp",
            "read_write_type": "0",
            "get_cycle": "1000",
            "lua_str": "",
            "is_real_var": "0",
            "max_value": "650.00",
            "min_value": "550.00",
            "infectant_id": "0",
            "enable_lua": "0",
            "cmd_str": "",
            "cmd_str_type": "0",
            "m_max_value": "",
            "m_min_value": "",
            "read_func_code": "3",
            "byte_code": "0",
            "value": "",
            "create_time": "2021-03-24 18:42:38",
            "creator": "sysadmin",
            "modified_time": "2021-04-09 16:02:42",
            "modified_by": "sysadmin",
            "pick_order": "100",
            "end_addr": "0",
            "opc_device": "",
            "opc_group": "",
            "opc_tags": "",
            "arg_1": "",
            "arg_2": "",
            "arg_3": "",
            "arg_4": "",
            "arg_5": "",
            "enable": "0",
            "group_id": "0",
            "cmd_len": "0",
            "cmd_wait_time": "",
            "dc_addr_map_name": "D",
            "group_name": "",
            "group_desc": "",
            "var_std_id": "1158",
            "dc_var_type_id": "",
            "timestamp": "",
            "quality": "",
            "update_count": "",
            "var_value": "",
            "good_reads": "",
            "good_writes": "",
            "failed_reads": "",
            "failed_writes": "",
            "var_control_type": "0",
            "dc_dev_var_code": "1338-ls_temp-5185",
            "dc_dev_code": "DEVC1228",
            "dc_addr_map_code": "dam_[TYSB]_[TouchNet]_[TN]_[TYModbus]_[D]",
            "operate_type": "0",
            "data_bits": "2",
            "arg_6": "",
            "arg_7": "",
            "arg_8": "",
            "arg_9": "",
            "arg_10": "",
            "var_busi_func_code": "",
            "write_func_code": "6",
            "eqpt_id": "1335",
            "record_change_value": "0",
            "write_value": "",
            "dev_addr": "",
            "is_show": "1",
            "cycle_report_time": "60000",
            "cycle_report_type": "1",
            "change_report_type": "1",
            "no_save_db": "0",
            "cmd_str_sub": "",
            "is_main": "",
            "var_group": "",
            "is_key_tech": "0",
            "calc_rate": "1",
            "min_var_id": "",
            "max_var_id": "",
            "is_mq": "1",
            "ethernet_data_block": "",
            "ethernet_tags": "",
            "is_trigger_read": "",
            "warn_lua": ""
        },
        {
            "eqpt_id_main": "1335",
            "dc_loc_id": "1086",
            "dc_dev_model_name": "通用Modbus",
            "var_id": "5233",
            "dc_dev_id": "1228",
            "dc_addr_map_id": "272",
            "offset_addr": "15",
            "start_addr": "15",
            "value_type": "0",
            "data_type": "7",
            "var_name": "EQPT_STATE_WORK",
            "read_write_type": "0",
            "get_cycle": "1000",
            "lua_str": "",
            "is_real_var": "0",
            "max_value": "",
            "min_value": "",
            "infectant_id": "0",
            "enable_lua": "0",
            "cmd_str": "",
            "cmd_str_type": "0",
            "m_max_value": "",
            "m_min_value": "",
            "read_func_code": "3",
            "byte_code": "0",
            "value": "",
            "create_time": "2021-04-15 15:13:42",
            "creator": "sysadmin",
            "modified_time": "2021-04-15 16:49:34",
            "modified_by": "sysadmin",
            "pick_order": "100",
            "end_addr": "15",
            "opc_device": "",
            "opc_group": "",
            "opc_tags": "",
            "arg_1": "",
            "arg_2": "",
            "arg_3": "",
            "arg_4": "",
            "arg_5": "",
            "enable": "0",
            "group_id": "0",
            "cmd_len": "0",
            "cmd_wait_time": "",
            "dc_addr_map_name": "D",
            "group_name": "",
            "group_desc": "",
            "var_std_id": "1172",
            "dc_var_type_id": "",
            "timestamp": "",
            "quality": "",
            "update_count": "",
            "var_value": "",
            "good_reads": "",
            "good_writes": "",
            "failed_reads": "",
            "failed_writes": "",
            "var_control_type": "0",
            "dc_dev_var_code": "1346-EQPT_STATE_WORK-5354",
            "dc_dev_code": "DEVC1228",
            "dc_addr_map_code": "dam_[TYSB]_[TouchNet]_[TN]_[TYModbus]_[D]",
            "operate_type": "0",
            "data_bits": "2",
            "arg_6": "",
            "arg_7": "",
            "arg_8": "",
            "arg_9": "",
            "arg_10": "",
            "var_busi_func_code": "eqpt_state",
            "write_func_code": "6",
            "eqpt_id": "1335",
            "record_change_value": "0",
            "write_value": "",
            "dev_addr": "",
            "is_show": "1",
            "cycle_report_time": "60000",
            "cycle_report_type": "1",
            "change_report_type": "1",
            "no_save_db": "0",
            "cmd_str_sub": "",
            "is_main": "",
            "var_group": "",
            "is_key_tech": "0",
            "calc_rate": "1",
            "min_var_id": "",
            "max_var_id": "",
            "is_mq": "1",
            "ethernet_data_block": "",
            "ethernet_tags": "",
            "is_trigger_read": "",
            "warn_lua": ""
        }
    ]
}

3、按设备编号(eqpt_id)查询采集信息

  • 参数列表:

    1)cmd=dc_get_by_dc_loc_id

    2)file文件名

    3)eqpt_id设备编号

{
    "file": "tsdb_query_tech",
    "cmd": "query_eqpt_var",
    "eqpt_id": "1335"
}
  • 返回值:
{
    "code": "1",
    "error": "",
    "help": [
        {
            "dev_eqpt_id": "1335",
            "dc_loc_id": "1086",
            "dc_dev_model_name": "通用Modbus",
            "var_id": "5441",
            "dc_dev_id": "1228",
            "dc_addr_map_id": "272",
            "offset_addr": "13",
            "start_addr": "13",
            "value_type": "0",
            "data_type": "7",
            "var_name": "cycle_time",
            "read_write_type": "0",
            "get_cycle": "1000",
            "lua_str": "",
            "is_real_var": "0",
            "max_value": "",
            "min_value": "",
            "infectant_id": "0",
            "enable_lua": "0",
            "cmd_str": "",
            "cmd_str_type": "0",
            "m_max_value": "",
            "m_min_value": "",
            "read_func_code": "3",
            "byte_code": "0",
            "value": "",
            "create_time": "2021-04-15 17:25:39",
            "creator": "sysadmin",
            "modified_time": "2021-04-15 17:26:09",
            "modified_by": "sysadmin",
            "pick_order": "100",
            "end_addr": "13",
            "opc_device": "",
            "opc_group": "",
            "opc_tags": "",
            "arg_1": "",
            "arg_2": "",
            "arg_3": "",
            "arg_4": "",
            "arg_5": "",
            "enable": "0",
            "group_id": "0",
            "cmd_len": "0",
            "cmd_wait_time": "",
            "dc_addr_map_name": "D",
            "group_name": "",
            "group_desc": "",
            "var_std_id": "3124",
            "dc_var_type_id": "",
            "timestamp": "",
            "quality": "",
            "update_count": "",
            "var_value": "",
            "good_reads": "",
            "good_writes": "",
            "failed_reads": "",
            "failed_writes": "",
            "var_control_type": "0",
            "dc_dev_var_code": "1346-cycle_time-5446",
            "dc_dev_code": "DEVC1228",
            "dc_addr_map_code": "dam_[TYSB]_[TouchNet]_[TN]_[TYModbus]_[D]",
            "operate_type": "0",
            "data_bits": "2",
            "arg_6": "",
            "arg_7": "",
            "arg_8": "",
            "arg_9": "",
            "arg_10": "",
            "var_busi_func_code": "beat_real",
            "write_func_code": "6",
            "eqpt_id": "1335",
            "record_change_value": "0",
            "write_value": "",
            "dev_addr": "",
            "is_show": "1",
            "cycle_report_time": "60000",
            "cycle_report_type": "1",
            "change_report_type": "1",
            "no_save_db": "0",
            "cmd_str_sub": "",
            "is_main": "",
            "var_group": "",
            "is_key_tech": "0",
            "calc_rate": "1",
            "min_var_id": "",
            "max_var_id": "",
            "is_mq": "1",
            "ethernet_data_block": "",
            "ethernet_tags": "",
            "is_trigger_read": "",
            "warn_lua": ""
        },
        {
            "dev_eqpt_id": "1335",
            "dc_loc_id": "1086",
            "dc_dev_model_name": "通用Modbus",
            "var_id": "5007",
            "dc_dev_id": "1228",
            "dc_addr_map_id": "272",
            "offset_addr": "0",
            "start_addr": "0",
            "value_type": "0",
            "data_type": "7",
            "var_name": "ls_temp",
            "read_write_type": "0",
            "get_cycle": "1000",
            "lua_str": "",
            "is_real_var": "0",
            "max_value": "650.00",
            "min_value": "550.00",
            "infectant_id": "0",
            "enable_lua": "0",
            "cmd_str": "",
            "cmd_str_type": "0",
            "m_max_value": "",
            "m_min_value": "",
            "read_func_code": "3",
            "byte_code": "0",
            "value": "",
            "create_time": "2021-03-24 18:42:38",
            "creator": "sysadmin",
            "modified_time": "2021-04-09 16:02:42",
            "modified_by": "sysadmin",
            "pick_order": "100",
            "end_addr": "0",
            "opc_device": "",
            "opc_group": "",
            "opc_tags": "",
            "arg_1": "",
            "arg_2": "",
            "arg_3": "",
            "arg_4": "",
            "arg_5": "",
            "enable": "0",
            "group_id": "0",
            "cmd_len": "0",
            "cmd_wait_time": "",
            "dc_addr_map_name": "D",
            "group_name": "",
            "group_desc": "",
            "var_std_id": "1158",
            "dc_var_type_id": "",
            "timestamp": "",
            "quality": "",
            "update_count": "",
            "var_value": "",
            "good_reads": "",
            "good_writes": "",
            "failed_reads": "",
            "failed_writes": "",
            "var_control_type": "0",
            "dc_dev_var_code": "1338-ls_temp-5185",
            "dc_dev_code": "DEVC1228",
            "dc_addr_map_code": "dam_[TYSB]_[TouchNet]_[TN]_[TYModbus]_[D]",
            "operate_type": "0",
            "data_bits": "2",
            "arg_6": "",
            "arg_7": "",
            "arg_8": "",
            "arg_9": "",
            "arg_10": "",
            "var_busi_func_code": "",
            "write_func_code": "6",
            "eqpt_id": "1335",
            "record_change_value": "0",
            "write_value": "",
            "dev_addr": "",
            "is_show": "1",
            "cycle_report_time": "60000",
            "cycle_report_type": "1",
            "change_report_type": "1",
            "no_save_db": "0",
            "cmd_str_sub": "",
            "is_main": "",
            "var_group": "",
            "is_key_tech": "0",
            "calc_rate": "1",
            "min_var_id": "",
            "max_var_id": "",
            "is_mq": "1",
            "ethernet_data_block": "",
            "ethernet_tags": "",
            "is_trigger_read": "",
            "warn_lua": ""
        }
    ]
}

二、客户端接口

1、按采集变量编号(var_ids)进行查询采集信息

  • 调用示例
local it = CIntent();
it:set('dc_loc_id','1067');
it:set('var_ids','2589,2590');
local sOut = CTNString();
db:commandStr('dc_get_redis',it:toString(),sOut);

local help = CSelectHelp();
help:fromString(sOut:get());
  • 返回结果(为help数据类型,下方例子为转换json格式输出后的样式)
{
    "help": [
        {
            "var_id": "2589",
            "var_name": "hj_alarm_hjbr",
            "value": "16129",
            "pick_time": "2021-03-26 13:07:01",
            "is_warn": "0",
            "eqpt_id": "1224"
        },
        {
            "var_id": "2590",
            "var_name": "hj_alarm_emerg",
            "value": "16084",
            "pick_time": "2021-03-26 13:07:01",
            "is_warn": "0",
            "eqpt_id": "1224"
        }
    ]
}

2、按站点编号(dc_loc_id)查询采集变量信息(客户端)

  • 调用示例
local it = CIntent();
it:set('dc_loc_id','1067');
local sOut = CTNString();
db:commandStr('dc_get_by_dc_loc_id_redis',it:toString(),sOut);

local help = CSelectHelp();
help:fromString(sOut:get());
help:dump();
  • 返回结果(为help数据类型,下方例子为转换json格式输出后的样式)
{
    "help": [
        {
            "var_id": "2589",
            "var_name": "hj_alarm_hjbr",
            "value": "16223",
            "pick_time": "2021-03-26 13:08:25",
            "is_warn": "0",
            "eqpt_id": "1224"
        },
        {
            "var_id": "2590",
            "var_name": "hj_alarm_emerg",
            "value": "16178",
            "pick_time": "2021-03-26 13:08:25",
            "is_warn": "0",
            "eqpt_id": "1224"
        },
        {
            "var_id": "5577",
            "var_name": "cy_mode_lx",
            "value": "16223",
            "pick_time": "2021-03-26 13:08:25",
            "is_warn": "0",
            "eqpt_id": "1224"
        }
    ]
}

三、服务端接口

1、查询该采集站点下采集变量信息

参数含义:

1067:采集地点编号

2589,2590:采集变量编号

  • 调用示例
local help = CSelectHelp();
serv:dc_get_redis('1067','2589,2590',help);
outIt:setHelp('help',help);
  • 返回结果(服务端直接根据)
{
    "code": "-1",
    "error": "",
    "help": [
        {
            "var_id": "2589",
            "var_name": "hj_alarm_hjbr",
            "value": "14128",
            "pick_time": "2021-03-26 12:37:13",
            "is_warn": "0",
            "eqpt_id": "1224"
        },
        {
            "var_id": "2590",
            "var_name": "hj_alarm_emerg",
            "value": "14083",
            "pick_time": "2021-03-26 12:37:13",
            "is_warn": "0",
            "eqpt_id": "1224"
        }
    ]
}

2、实时查询设备状态

参数含义:

1224:设备编号

  • 调用示例
local help = CSelectHelp();
tnsys:dc_get_eqpt_state('1224',help);
outIt:setHelp('help',help);
  • 返回结果
{
    "code": "-1",
    "error": "",
    "help": [
        {
            "eqpt_cur_state": "1",
            "start_time": "2021-03-10 22:06:21",
            "update_time": "2021-03-26 12:37:50",
            "eqpt_id": "1224"
        }
    ]
}

5、实时查询设备加工数

参数含义:

1223:设备编号

  • 调用示例
local ivalue = tnsys:dc_get_eqpt_danum('1223');
print('i value = ' .. ivalue);

6、实时查询设备状态(支持多个使用“,”隔开)

参数含义:

1223,1224:设备编号

  • 调用示例
local help = CSelectHelp();
tnsys:dc_get_eqpt_state('1223,1224',help);
help:dump();
  • 返回结果
{
    "code": "-1",
    "error": "",
    "help": [
        {
            "eqpt_cur_state": "1",
            "start_time": "2021-03-10 22:06:21",
            "update_time": "2021-03-26 12:43:56",
            "eqpt_id": "1224"
        }
    ]
}

四、调用服务端传参查询

1、查询网关状态

需要存放脚本 dc_query_loc_status.lua

参数含义:

cmd:调用参数

file:调用文件名

dc_loc_ids:采集地点编号

  • 调用示例
{
    "cmd": "query_status",
    "file": "dc_query_loc_status",
    "dc_loc_ids":"1067,1068"
}
  • 返回结果
{
    "code": "1",
    "error": "",
    "help": [
        {
            "dc_loc_id": "1067",
            "ip": "192.168.1.20,87.73.78.45,79.69.67.68,70.55.71.84",
            "time": "2021-03-26 13:04:41",
            "status": "在线",
            "create_time": "2021-03-26 13:04:42"
        },
        {
            "dc_loc_id": "",
            "ip": "",
            "time": "",
            "status": "在线",
            "create_time": ""
        }
    ],
    "help_dev": [
        {
            "dc_loc_id": "1067",
            "dc_dev_id": "1097",
            "status": "运行中",
            "driver": "Modbus",
            "error": ""
        }
    ]
}
Copyright © TouchNet 2015 all right reserved,powered by Gitbook最后修订时间: 2022-06-21 09:21:04

results matching ""

    No results matching ""