map/docs/datacollect/README.md
2024-07-03 17:12:41 +08:00

219 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 数据采集
## 采集配置说明
采集程序配置存放在: `/das/conf/collector.json`
如果系统配置更新将生成配置更新文件: `/das/conf/collector.json.update`
配置文件内容如下:
```json
{
//版本号
"version": 101,
//配置创建时间(毫秒值)
"createTime": 1235235623433,
//节点ID
"nodeId": "nx10928234",
//链路列表
"links" : [
{
//链路ID
"linkId": "1235123",
//链路名称
"linkName": "1#风机",
//协议号
"protocol": 1,
//协议参数
"params": {},
"devices": ["11234131","1234123"]
}
],
//物模型信息
"equipments": [
{
//设备ID
"id": "11234131",
//属性列表
"attrs":[
{
//属性名
"name": "Ia",
//属性类型
"type": "yc",
//属性参数
"params": {
//上界
"upBound": 9999,
//下界
"lowBound": 0,
//基值, default: 0
"base": 0,
//系数, default: 1
"coef": 1
}
},
{
"name": "Switch01",
"type": "yx",
"params": {
//是否取反,default: 0
"invert": 0
}
}
],
//服务列表
"services": [
{
//服务名
"name": "start",
//服务类型
"type": "yk",
//服务参数
"params": {
}
}
]
}
]
}
```
## 采集程序与系统交互通道
采集程序与系统间采用Websocket方式通讯 访问系统服务器端口: 7790
报文格式为`json`, 字符集: `utf-8`
### 通道建立
采集程序建立连接时需要带上自身节点ID连接URL如下所示:
`ws://127.0.0.1:7790/gate/{nodeId}`
PS: 同一节点只允许建立一条连接。
## 通讯报文
### 报文格式
```json
{
//命令
"cmd": "heartbeat",
//命令ID
"cmdId": "123123",
//发送时间(毫秒)
"time": 123123123123,
//数据体
"data": {}
}
```
### 节点心跳报文
?> 方向: `采集程序` -> `系统`
**命令:** `heartbeat`
**数据体:**
```json
{
//心跳生存时间(毫秒)
"ttl": 30000,
//终端状态, 0 - 离线, 1 - 在线
"status": 0,
//通讯链路监控信息
"links": [
{
//通讯链路IRN
"linkId": 3444,
//通讯链路状态
"online": true
},
{
"linkId": 123,
"online": false
}
]
}
```
### 设备初始数据上报
当采集设备第一次采集到设备完整数据时,需要向系统上报设备初始数据。
?> 方向: `采集程序` -> `系统`
**命令:** `initDeviceData`
**数据体:**
```json
{
//设备ID
"12351235213":{
//设备完整初始数据
"Ia": 123.1,
"Ib": 122.1,
"Ic": 123.1,
"Ua": 220.3,
"Ub": 221.4,
"Uc": 223.1,
"Switch01": 1
},
"12351235214":{
//设备完整初始数据
"Ia": 122.1,
"Ib": 123.1,
"Ic": 121.1,
"Ua": 224.3,
"Ub": 223.4,
"Uc": 223.1,
"Switch01": 0
}
}
````
### 模拟量上报
?> 方向: `采集程序` -> `系统`
**命令:** `analogData`
**数据体:**
```json
{
//key为设备ID
"1123451235": {
//key为属性名
"Ia": 123.1,
"Ib": 122.1,
"Ic": 123.1
},
"351235123" : {
"P" : 1213.1,
"Q" : 123.1
}
}
```
### 状态量上报
?> 方向: `采集程序` -> `系统`
**命令:** `discreteData`
**数据体:**
```json
{
//key为设备ID
"1123451235": {
//key为属性名
"Switch01": 1
},
}
```