读写

读 Tag

POST /api/v2/read

请求头部

Content—Type application/json

Authorization Bearer <token>

响应状态

  • 200

请求体

json

  1. {
  2. //node name (required)
  3. "node": "modbus-tcp-1",
  4. //group name (required)
  5. "group": "config_modbus_tcp_sample_2"
  6. //tag name substring match (optional)
  7. "name": "hold_bit",
  8. //tag description substring match (optional)
  9. "desc": "switch",
  10. //synchronous read (optional, default false)
  11. "sync": false
  12. }

响应

json

  1. {
  2. "tags": [
  3. {
  4. //tag nmae
  5. "name": "data1",
  6. //tag value
  7. "value": 1,
  8. },
  9. {
  10. "name": "data2",
  11. "error": 2014
  12. },
  13. {
  14. "name": "data3",
  15. "value": true,
  16. }
  17. ]
  18. }

注意

当某个点位读数值出错时,将显示 error 字段,不再显示 value 字段。

写 Tag

写一个 Tag

POST /api/v2/write

请求头部

Content-Type application/json

Authorization Bearer <token>

响应状态

  • 200 OK

请求体

json

  1. {
  2. "node": "modbus-tcp-1",
  3. "group": "config_modbus_tcp_sample_2",
  4. "tag": "tag1",
  5. "value": 1234
  6. }

响应

json

  1. {
  2. "error": 0
  3. }

写多个 Tag

POST /api/v2/write/tags

注意

多点位写入,目前仅支持Mitsubishi 3E, Beckhoff ADS, Modbus TCP, Modbus RTU, Siemens S7 ISOTCP, Omron FINS TCP, OPC UA, BACnet/IP 驱动。

请求头部

Content-Type application/json

Authorization Bearer <token>

响应状态

  • 200 OK

请求体

json

  1. {
  2. "node": "modbus-tcp-1",
  3. "group": "group1",
  4. "tags": [
  5. {
  6. "tag": "tag1",
  7. "value": 123
  8. },
  9. {
  10. "tag": "tag2",
  11. "value": 1233
  12. },
  13. {
  14. "tag": "tag3",
  15. "value": 7788
  16. },
  17. {
  18. "tag": "tag4",
  19. "value": 1
  20. },
  21. {
  22. "tag": "tag5",
  23. "value": "asdfda"
  24. }
  25. ]
  26. }

响应

json

  1. {
  2. "error": 0
  3. }