You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
292 lines
7.1 KiB
292 lines
7.1 KiB
3 years ago
|
## 部署启动
|
||
|
|
||
|
### EDGE
|
||
|
|
||
|
**设备型号**:ok-3399C
|
||
|
|
||
|
**系统**:ubuntu-18.02
|
||
|
|
||
|
**默认用户**:forlinx / forlinx
|
||
|
|
||
|
**网络**: 通过netplan (apply)设置网络地址
|
||
|
|
||
|
**基础服务:**
|
||
|
|
||
|
+ influxdb
|
||
|
|
||
|
数据库。安装方法参见https://portal.influxdata.com/downloads/
|
||
|
|
||
|
启动数据库: influxd http://localip:8086/ (设置用户密码 admin/admin123)
|
||
|
|
||
|
获取全局Token (后续edge配置使用)
|
||
|
|
||
|
**启动EDGE**
|
||
|
|
||
|
`edge.conf`
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"msg.mqtt.center": "10.8.30.236:1883", -- 服务端MQTT服务地址
|
||
|
"serial_no": "001", -- 测试设备序列号
|
||
|
"influx.token": "rBqy73hzOc1Fk5xxofGjqy5bKSmHBVLQouRBkt8eaXUmhum9c4m5nEMWVkG83ihR8CQjWbzTaLvUMoFp0xegYw==", -- influ操作token
|
||
|
"db.type":"file",
|
||
|
"db.dir":"../../resources/test",
|
||
|
"log.file":true,
|
||
|
"log.file.loc":"runtime/logs/log"
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```shell
|
||
|
# 启动主程序
|
||
|
chmod +x ./edge
|
||
|
./edge
|
||
|
```
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
### SERVER
|
||
|
|
||
|
**基础服务**
|
||
|
|
||
|
+ Emqx
|
||
|
|
||
|
启动MQTT代理服务, emqx start
|
||
|
|
||
|
+ Prometheus
|
||
|
|
||
|
配置抓取设备指标
|
||
|
|
||
|
```yaml
|
||
|
scrape_configs:
|
||
|
- job_name: "edge-server"
|
||
|
static_configs:
|
||
|
- targets: ["localhost:19202"]
|
||
|
# 调试使用(抓取内网设备上的监控指标)
|
||
|
- job_name: "dac"
|
||
|
static_configs:
|
||
|
- targets: ["10.8.30.244:19201"]
|
||
|
```
|
||
|
|
||
|
默认UI地址: http://localhost:9090/
|
||
|
|
||
|
+ Grafana
|
||
|
|
||
|
配合Prometheus显示EDGE状态和性能指标。
|
||
|
|
||
|
+ 其他
|
||
|
|
||
|
+ 连接测试Iota数据库 `postgres://postgres:postgres@10.8.30.156:5432/iota20211206?sslmode=disable`
|
||
|
+ 部署以太网站 http://10.8.30.38/
|
||
|
+ Postman调试工具
|
||
|
|
||
|
|
||
|
|
||
|
**启动SERVER**
|
||
|
|
||
|
配置`server.conf`
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"msg.mqtt.center": "10.8.30.236:1883", -- MQTT Broker地址
|
||
|
"web.url":":8088", -- WEB接口地址
|
||
|
"db.type": "postgres",
|
||
|
"db.conn": "postgres://postgres:postgres@10.8.30.156:5432/iota20211206?sslmode=disable", -- 以太数据库地址
|
||
|
"log.file":true,
|
||
|
"log.file.loc":"runtime/logs/log"
|
||
|
}
|
||
|
```
|
||
|
|
||
|
启动Server.
|
||
|
|
||
|
|
||
|
|
||
|
## 功能演示
|
||
|
|
||
|
|
||
|
|
||
|
### 平台新增边缘网关
|
||
|
|
||
|
目前已经实现CRUD API
|
||
|
|
||
|
**新增设备:**
|
||
|
|
||
|
URL:Post http://localhost:8088/edges
|
||
|
|
||
|
BODY:
|
||
|
|
||
|
```json
|
||
|
{"serial_no":"002","name":"DEMO-2","hardware":{"name":"FS-EDGE-01"},"software":{"ver":"0.2.1"}}
|
||
|
```
|
||
|
|
||
|
RET: 200
|
||
|
|
||
|
> 平台serial_no设置必须和设备端SerialNo匹配,才能进行设备控制
|
||
|
|
||
|
|
||
|
|
||
|
**查询当前所有设备**:
|
||
|
|
||
|
URL: GET localhost:8088/edges
|
||
|
|
||
|
RET:
|
||
|
|
||
|
```json
|
||
|
{"001":{"serial_no":"001","name":"DEMO-WW","hardware":{"name":"FS-EDGE-01"},"software":{"ver":"0.2.1"},"set_ver":"1","config_ver":"9"},"002":{"serial_no":"002","name":"DEMO-2","properties":{"hb":"true"},"hardware":{"name":"FS-EDGE-01"},"software":{"ver":"0.2.1"},"set_ver":"0","config_ver":"0"}}
|
||
|
```
|
||
|
|
||
|
|
||
|
|
||
|
其他: **修改PUT** 和 **删除 DELETE**
|
||
|
|
||
|
|
||
|
|
||
|
### 网关在线状态和性能在线统计
|
||
|
|
||
|
通过网关心跳数据上报,Prometheus抓取,可通过Grafana查看:
|
||
|
|
||
|
![image-20220121162513190](imgs/EDGE-V0.1调试手册/image-20220121162513190.png)
|
||
|
|
||
|
其中心跳数据格式如下:
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"time": 1642734937400741643, -- 当前数据的设备时间(用于校时)
|
||
|
"ver": {
|
||
|
"pv": "v0.0.1" -- 当前配置版本(包括设备配置和采集配置)
|
||
|
},
|
||
|
"machine": {
|
||
|
"mt": 3845, -- 总内存
|
||
|
"mf": 2616, -- 空闲内存
|
||
|
"mp": 10.074738688877986, -- 内存使用比
|
||
|
"dt": 12031, -- 总磁盘
|
||
|
"df": 7320, -- 剩余磁盘空间
|
||
|
"dp": 36, -- 磁盘使用率
|
||
|
"u": 7547, -- 系统启动时长
|
||
|
"pform": "ubuntu", -- 系统信息
|
||
|
"pver": "18.04", -- 系统版本
|
||
|
"load1": 0.09, -- 1分钟内平均负载
|
||
|
"load5": 0.02, -- 5分钟内平均负载
|
||
|
"load15": 0.01 -- 15分钟内平均负载
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
|
||
|
|
||
|
### 绑定结构物到网关
|
||
|
|
||
|
在以太(测试环境)建立结构物,我们这里模拟的一个振弦采集的场景,如下
|
||
|
|
||
|
![image-20220121135940527](imgs/EDGE-V0.1调试手册/image-20220121135940527.png)
|
||
|
|
||
|
下发该结构物到边缘网关
|
||
|
|
||
|
URL:Post http://llocalhost:8088/edge/002/things
|
||
|
|
||
|
BODY:
|
||
|
|
||
|
```json
|
||
|
["f73d1b17-f2d5-46dd-9dd1-ebbb66b11854"]
|
||
|
```
|
||
|
|
||
|
RET: 200
|
||
|
|
||
|
> 获取指定网关绑定的结构物 GET http://llocalhost:8088/edge/002/things
|
||
|
|
||
|
|
||
|
|
||
|
下发后,边缘网关自动更新配置(如果未在线,会在下次上下后更新配置),并重启
|
||
|
|
||
|
![image-20220121152314499](imgs/EDGE-V0.1调试手册/image-20220121152314499.png)
|
||
|
|
||
|
|
||
|
|
||
|
模拟DTU设备上线到边缘网关,
|
||
|
|
||
|
<img src="imgs/EDGE-V0.1调试手册/image-20220121152705457.png" width=600 align=left/>
|
||
|
|
||
|
|
||
|
|
||
|
随后边缘网关按照配置的采集规则进行采集,目前可以通过边缘端InfluxDB的Web UI查看数据:
|
||
|
|
||
|
![image-20220121163903101](imgs/EDGE-V0.1调试手册/image-20220121163903101.png)
|
||
|
|
||
|
采集的数据会通过MQTT消息发送到服务端,见下节(采集数据实时预览)。
|
||
|
|
||
|
同事,在平台更改采集配置(部署)后,通过 POST http://localhost:8088/edge/002/sync 可以触发网关进行配置同步。
|
||
|
|
||
|
|
||
|
|
||
|
### 采集数据实时预览
|
||
|
|
||
|
DAC采集的数据会实时推送到服务器MQTT上,服务端进行**入库**操作,并支持WebSocket像前端接口**推送**。
|
||
|
|
||
|
ws地址:ws://localhost:8088/edge/ws/{device}
|
||
|
|
||
|
实时数据预览界面:http://localhost:8088/edge/rt/{device}
|
||
|
|
||
|
![image-20220121162951692](imgs/EDGE-V0.1调试手册/image-20220121162951692.png)
|
||
|
|
||
|
|
||
|
|
||
|
### 绑定包含振动设备的结构物
|
||
|
|
||
|
新建包含振动设备的结构物,测试如下:
|
||
|
|
||
|
![image-20220121163144291](imgs/EDGE-V0.1调试手册/image-20220121163144291.png)
|
||
|
|
||
|
同上,执行结构物绑定网关操作。
|
||
|
|
||
|
|
||
|
|
||
|
模拟振动设备连接到网关,通过日志可以看到网关开始采集振动传感器:
|
||
|
|
||
|
![image-20220121164158554](imgs/EDGE-V0.1调试手册/image-20220121164158554.png)
|
||
|
|
||
|
振动数据存储在本地,通过数据库的定时聚集功能(CQ),生成分钟级聚集数据。查看实时数据如下:
|
||
|
|
||
|
![image-20220121164306992](imgs/EDGE-V0.1调试手册/image-20220121164306992.png)
|
||
|
|
||
|
|
||
|
|
||
|
### 动态数据实时预览
|
||
|
|
||
|
振动的实时数据**默认不会**直接推送到平台。
|
||
|
|
||
|
前端打开振动设备实时数据界面,将发布WS订阅,此时会通知设备开始上报数据(类似视频推流服务的实现),之后类似普通数据的处理方式。
|
||
|
|
||
|
实时数据刷新界面如下:
|
||
|
|
||
|
![image-20220121164715214](imgs/EDGE-V0.1调试手册/image-20220121164715214.png)
|
||
|
|
||
|
WS订阅退出后,会通知设备关闭实时推流(节约流量、性能和服务端存储)。
|
||
|
|
||
|
后面会实现云端保存最近一段播放历史、设备上的历史数据回放功能。
|
||
|
|
||
|
|
||
|
|
||
|
### 作单机振动采集软件使用
|
||
|
|
||
|
包含振动采集的配置、采集、计算、存储、转发功能。可以替换某些场景下本地工控机上的DAAS软件。
|
||
|
|
||
|
> 注:云端工作模式,访问设备上的Vib界面,可以查看配置,但是不能进行修改。
|
||
|
|
||
|
|
||
|
|
||
|
振动设备配置:http://10.8.30.244:8828/vib
|
||
|
|
||
|
![image-20220121165041737](imgs/EDGE-V0.1调试手册/image-20220121165041737.png)
|
||
|
|
||
|
振动通道配置:
|
||
|
|
||
|
![image-20220121165146403](imgs/EDGE-V0.1调试手册/image-20220121165146403.png)
|
||
|
|
||
|
IP设置:
|
||
|
|
||
|
![image-20220121165230596](imgs/EDGE-V0.1调试手册/image-20220121165230596.png)
|
||
|
|
||
|
网关侧实时数据预览:
|
||
|
|
||
|
![image-20220121165302506](imgs/EDGE-V0.1调试手册/image-20220121165302506.png)
|