读写

读 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. //synchronous read (optional, default false)
  7. "sync": false,
  8. //filter (optional)
  9. "query": {
  10. //tag name substring match (optional)
  11. "name": "data",
  12. //tag description substring match (optional)
  13. "description": "switch"
  14. }
  15. }

响应

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(分页)

POST /api/v2/read/paginate

请求头部

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. //synchronous read (optional, default false)
  7. "sync": false,
  8. //filter (optional)
  9. "query": {
  10. //tag name substring match (optional)
  11. "name": "data",
  12. //tag description substring match (optional)
  13. "description": "switch",
  14. //current page (optional)
  15. "currentPage": 1,
  16. //number of tags per page (optional)
  17. "pageSize": 10,
  18. //response error tags only (optional)
  19. "isError": true
  20. }
  21. }

响应

json

  1. {
  2. "meta": {"currentPage": 1, "pageSize": 10, "total": 1},
  3. "items": [ {
  4. "name": "tag1",
  5. "type": 4,
  6. "address": "1!400001",
  7. "attribute": 8,
  8. "description": "",
  9. "precison": 0,
  10. "decimal": 0,
  11. "bias": 0,
  12. "error": 3002 // "value": 123
  13. } ]
  14. }

注意

当某个点位读数值出错时,显示 error 字段;读取正常时显示 value 字段。

测试读 Tag

POST /api/v2/read/test

请求头部

Content—Type application/json

Authorization Bearer <token>

响应状态

  • 200

请求体

json

  1. {
  2. "driver": "1",
  3. "group": "1",
  4. "tag": "tag1",
  5. "address": "1!400002",
  6. "attribute": 8,
  7. "type": 3,
  8. "precision": 0,
  9. "decimal": 0,
  10. "bias": 0.0
  11. }

响应

json

  1. {
  2. "value": 29540
  3. }

json

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

注意

仅做读取测试,无需实际添加点位。 不适配点位和节点字节序,不计算乘系数,偏移量。

写 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. }