数据接口
1.HTTP读服务
1.获取某个组的实时数据
示例路径:
http://192.168.11.241:8080/API/V1/GROUP_DATA
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"GET_GROUP_REAL_DATA","group_name":"AO"}' http://192.168.11.242:8080/API/V1/GROUP_DATA
输出结果:
[
{
"Id": "AO_Tag1",
"val": "0.000000",
"stat": "no",
"info": "Connection timed out",
"count": 0,
"rtime": 1737527500,
"key": "#item#98900"
}
]
错误返回:
[
{
"error": "网关中无此组名相关信息"
}
]
2.获取单个采集标签的历史数据"
需要预期在SQLITE3端配置该标签
示例路径:
http://192.168.11.242:8080/API/V1/HISTORY_DATA
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"GET_POINT_HISTORY","id":"AO_Tag3","start_time":1734019200,"end_time":1734102000,"format":"long"}' http://192.168.11.242:8080/API/V1/HISTORY_DATA
正常输出结果:
[{
"stat": "ok",
"val": "0.000000",
"rtime": 1734019245,
"info": "读取成功"
}, {
"stat": "ok",
"val": "0.000000",
"rtime": 1734055991,
"info": "读取成功"
}]
错误输出:
[
{
"error": "所选点无历史数据"
}
]
- start_time:查询的起始时间,unix时间值
- end_time:查询的起始时间,unix时间值
- format:
- short:更加紧凑的JSON数据格式
- long:适合阅读的JSON数据格式
3.获取所有的信息
示例路径:
http://192.168.11.242:8080/API/V1/ALL_DATA
测试命令:
curl -k -H "Content-Type: application/json" -X GET -d '{"type":"GET_GROUP_REAL_DATA","format":"long"}' http://192.168.11.242:8080/API/V1/ALL_DATA
正确返回:
[
{
"Id": "_Tag1",
"val": "0.000000",
"stat": "no",
"info": "对端无响应:Connection timed out",
"count": 0,
"rtime": 1740036216,
"key": "#item#98649"
},
{
"Id": "_Tag2",
"val": "0.000000",
"stat": "no",
"info": "对端无响应:Connection timed out",
"count": 0,
"rtime": 1740036216,
"key": "#item#98650"
}
]
错误返回:
[
{
"error": "具体的错误原因"
}
]
format:
- short:更加紧凑的JSON数据格式
- long:适合阅读的JSON数据格式
2.HTTP写服务
接口路径:
http://192.168.11.242:8082/API/V1/WRITE
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"Type":"write","Id":"Group1_A3","Setv":"1"}' http://192.168.11.242:8082/API/V1/WRITE
正确返回:
[
{
"status": "ok"
}
]
错误返回:
[
{
"status": "no",
"error": "请求ID不存在内部对象表中"
}
]
- 默认不开放HTTP写接口,用户在确认内网环境安全可靠时,可将此接口放开(此接口无权限校验)
- Id字段:由"组名_点名"组成,如组名是Group1,点名是Tag1,下发时Id字段的值是Group1_Tag
3.HTTP日志查询
1.查询所有日志
- 任务端的执行日志
- 其他端的执行记录
接口路径:
http://192.168.11.242:8083/API/V1/ALL_LOG
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"start_time":"1736784000","end_time":"1736866800","format":"short"}' http://192.168.11.242:8083/API/V1/ALL_LOG
正确返回:
[
{
"time": "2025/01/14 10:22:24",
"plan": "Plan1",
"act": "动作3",
"cond_type": "single",
"check_id": "WR(short)_Tag4",
"cond_status_type": "null",
"cond_val_type": "readv",
"cond_val_judge": "less_than_or_equal",
"cond_val_setv": "3000.000000",
"cur_val_v": "66.000000",
"cond_time_en": "disabled",
"exe_type": "point",
"exe_id": "WR(short)_Tag8",
"exe_val": "8881",
"exe_status": "ok",
"exe_msg": ""
},
{
"src": "ALink",
"id": "Group1_Tag1",
"setv": "888.000000",
"exe_status": "ok",
"reason": "",
"time": 1736859600,
"time_str": "2025/01/14 21:00:00"
}
]
错误返回:
[
{
"status": "no",
"error": "查询起始和终止时间跨度超过24小时"
}
]
2.仅查询告警日志
接口路径:
http://192.168.11.242:8083/API/V1/GET_ALARM
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"start_time":"1736784000","end_time":"1736866800","format":"short"}' http://192.168.11.242:8083/API/V1/GET_ALARM
正确返回:
[
{
"id": "WR(integer)_Tag58",
"type": "alarm",
"specific": "max_limit",
"level": "3",
"limitv": "7000.000000",
"val": "9999.000000",
"time_str": "2025/01/14 10:22:21",
"status_info": ""
},
{
"id": "WR(integer)_Tag59",
"type": "alarm",
"specific": "max_limit",
"level": "3",
"limitv": "7000.000000",
"val": "9999.000000",
"time_str": "2025/01/14 10:22:21",
"status_info": ""
}
]
错误返回:
[
{
"status": "no",
"error": "查询起始和终止时间跨度超过24小时"
}
]
3.获取任务端执行日志
接口路径:
http://192.168.11.242:8083/API/V1/GET_PLAN
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"start_time":"1736784000","end_time":"1736866800","format":"short"}' http://192.168.11.242:8083/API/V1/GET_PLAN
正确返回:
[
{
"time": "2025/01/14 10:22:24",
"plan": "Plan3",
"act": "动作1",
"cond_type": "single",
"check_id": "HR(short)_Tag1",
"cond_status_type": "success",
"cond_status_judge": "greater_than",
"cond_status_setv": "5",
"cur_status_v": "31",
"cond_val_type": "readv",
"cond_val_judge": "equal",
"cond_val_setv": "123.000000",
"cur_val_v": "123.000000",
"cond_time_en": "disabled",
"exe_type": "point",
"exe_id": "HR(short)_Tag2",
"exe_val": "7777",
"exe_status": "ok",
"exe_msg": ""
}
]
错误返回:
[
{
"status": "no",
"error": "缺少字段:end_time"
}
]
4.HTTP状态接口
1.查询转发端应用的状态
接口路径:
http://192.168.11.242:8084/status_monitor
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"get_trans_status","app":"http_client"}' http://192.168.11.242:8084/status_monitor
正确返回:
{
"result": "ok",
"drive_status": "no",
"real_status": "no",
"return_exe_status": "no",
"query_exe_status": "no"
}
错误返回:
{
"result": "app字段值:不符合约定"
}
- app字段有以下可选值:
- http_client
- mysql
- sqlserver
- postgresql
- redis
- history
- MQTT_Client
- ALink
2.查看转发端日志
接口路径:
http://192.168.11.242:8084/status_monitor
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"get_trans_log","app":"http_client"}' http://192.168.11.242:8084/status_monitor
正确返回:
[
"2025/02/18/12:30:05|HTTP_exec|警告,将错误信息返回给远程HTTP服务器失败,code:7,err:Couldn't connect to server",
"2025/02/18/12:32:05|HTTP_exec|警告,(控制接口)GET获取对端数据失败,code:7,err:Couldn't connect to server",
]
错误返回:
{
"result": "app字段值:不符合约定"
}
app字段有以下可选值:
- http_client
- mysql
- sqlserver
- postgresql
- redis
- history
- MQTT_Client
- ALink
3.查询采集端日志
接口路径:
http://192.168.11.242:8084/status_monitor
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"collcet_monitor_log","app":"CJT/188-2004"}' http://192.168.11.242:8084/status_monitor
正确返回:
[
"2025/01/12/13:54:12|CJT188|程序启动成功"
]
错误返回:
{
"result": "app字段值:不符合约定"
}
- app字段有以下可选值:
- CJT/188-2004
- DLT 645/1997
- DLT 645/2007
- DLT 698.45/2017
- Modbus TCP
- Modbus RTU
4.查看告警、任务、邮件端、从站的运行日志
接口路径:
http://192.168.11.242:8084/status_monitor
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"other_monitor_log","app":"plan"}' http://192.168.11.242:8084/status_monitor
正确返回:
[
"2025/01/12/13:54:35|plan|程序启动成功"
]
错误返回:
{
"result": "app字段值:不符合约定"
}
- app字段有以下可选值:
- plan
- Modbus Slave
- alarm
5.控制接口
1.网关硬件在线匹配
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_mate_ip"}' http://192.168.11.242:8084/user_api
正确返回:
{
"result": "yes,isme"
}
错误返回:
{
"result": "type字段值:不符合约定"
}
2.设置网关时间
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_set_time","date":"2024-11-11","time":"11:11:11"}' http://192.168.11.242:8084/user_api
正确返回:
{
"result": "同步完成"
}
错误返回:
{
"result": "命令管道打开失败或获取管道结果失败:No child processes"
}
3.查看NTP设置
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_get_ntpdate_set"}' http://192.168.11.242:8084/user_api
正确返回:
{
"result": "ok",
"ntp": "time.windows.com",
"cycle": "1"
}
错误返回:
{
"result": "type字段值:不符合约定"
}
4.设置NTP服务
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_set_ntpdate","ntp":"xxxx","cycle":30}' http://192.168.11.242:8084/user_api
正确返回:
{
"result": "ntp set ok"
}
错误返回:
{
"result": "cycle字段值:不符合约定"
}
5.查看NTP服务运行状态
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_get_ntpdate_status"}' http://192.168.11.242:8084/user_api
正确返回:
6.获取有线网口的配置
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_get_wired_net","data":"eth0"}' http://192.168.11.242:8084/user_api
正确返回:
{
"result": "ok",
"ip": "192.168.11.242",
"mask": "255.255.255.0",
"gateway": "192.168.11.1",
"dns1": "114.114.114.114",
"dns2": "114.114.115.115",
"mac": "64:52:77:38:00:81"
}
错误返回:
{
"result": "网卡编号不符合约定"
}
7.获取4G信息
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_get_4g_net"}' http://192.168.11.242:8084/user_api
8.调用ping测试
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_ping_test","ip":"192.168.11.241"}' http://192.168.11.242:8084/user_api
9.调用端口可达测试
接口路径:
http://192.168.11.242:8084/user_api
测试命令:
curl -k -H "Content-Type: application/json" -X POST -d '{"type":"user_telnet_test","ip":"192.168.11.241","port":"9999"}' http://192.168.11.242:8084/user_api
正确返回:
{
"result": "端口可达"
}
-