ThingsBoard对接模拟OPCUA-server

 2024-06-22    0 条评论    362 浏览

thingsboard

官网地址

https://thingsboard.io/docs/iot-gateway/config/opc-ua/

模拟服务

参考官网说明,使用 prosys-opc-ua-simulation-server

image-20240528144550560

配置文件

配置文件样例(参考)

{
  "server": {
    "name": "OPC-UA Default Server",
    "url": "192.168.241.129:4840/freeopcua/server/",
    "timeoutInMillis": 5000,
    "scanPeriodInMillis": 5000,
    "disableSubscriptions":false,
    "subCheckPeriodInMillis": 100,
    "showMap": false,
    "security": "Basic128Rsa15",
    "identity": {
      "type": "anonymous"
    },
    "mapping": [
      {
        "deviceNodePattern": "Root\\.Objects\\.Device1",
        "deviceNamePattern": "Device ${Root\\.Objects\\.Device1\\.serialNumber}",
        "attributes": [
          {
            "key": "CertificateNumber",
            "path": "${ns=2;i=5}"
          }
        ],
        "timeseries": [
          {
            "key": "temperature °C",
            "path": "${Root\\.Objects\\.Device1\\.TemperatureAndHumiditySensor\\.Temperature}"
          },
          {
            "key": "batteryLevel",
            "path": "${Battery\\.batteryLevel}"
          }
        ],
        "rpc_methods": [
          {
            "method": "multiply",
            "arguments": [2, 4]
          }
        ],
        "attributes_updates": [
          {
            "attributeOnThingsBoard": "deviceName",
            "attributeOnDevice": "Root\\.Objects\\.Device1\\.serialNumber"
          }
        ]
      }
    ]
  }
}

GPS数据

模拟GPS服务

这里使用Prosys OPC UA软件模拟

image-20240528161619840

接收GPS配置文件

{
  "server": {
    "name": "OPC-UA GPS Server",
    "url": "192.168.2.253:53530/OPCUA/SimulationServer",
    "timeoutInMillis": 5000,
    "scanPeriodInMillis": 5000,
    "disableSubscriptions": false,
    "subCheckPeriodInMillis": 100,
    "showMap": true,
    "security": "Basic128Rsa15",
    "identity": {
      "type": "anonymous"
    },
    "mapping": [
      {
        "deviceNodePattern": "Root\\.Objects\\.Simulation",
        "deviceNamePattern": "OPC-UA GPS",
        "deviceTypePattern": "default",
        "attributes": [],
        "timeseries": [
          {
            "key": "longitude",
            "path": "${ns=3;i=1010}"
          },
          {
            "key": "latitude",
            "path": "${ns=3;i=1011}"
          }
        ],
        "rpc_methods": [],
        "attributes_updates": []
      }
    ]
  },
  "logLevel": "INFO",
  "name": "GPS",
  "enableRemoteLogging": false,
  "id": "37acf200-ce5d-43f5-b76c-ada2d03d0dbdgps"
}

ThingsBoard网关配置

注意,连接器名称不能出现空格,否则状态会error

image-20240528161713651

配置仪表盘测试

GPS需要实时变化才能在地图显示变化,但是又不能跨度太大,否则地图界面无法快速渲染

这里模拟GPS服务将参数设置为北京

经度:39.91、维度116.4~116.41

image-20240528161853942

选择腾讯地图,默认中文汉化

image-20240528162343313