diff --git a/docs/json-api/neu_json_rw.json b/docs/json-api/neu_json_rw.json index b7bd516f..e460c6e5 100644 --- a/docs/json-api/neu_json_rw.json +++ b/docs/json-api/neu_json_rw.json @@ -3,14 +3,17 @@ "tags": [ { "id": 1, + "error": 2014, "value": 123 }, { "id": 2, + "error": 0, "value": 2.2 }, { "id": 3, + "error": 0, "value": true } ] diff --git a/ft/modbus_tcp_test.robot b/ft/modbus_tcp_test.robot index 345af64e..b8575e73 100644 --- a/ft/modbus_tcp_test.robot +++ b/ft/modbus_tcp_test.robot @@ -5,434 +5,435 @@ Suite Teardown Stop All Processes *** Variables *** ${test_node_id} -${group} config_modbus_tcp_sample_2 +${group} config_modbus_tcp_sample_2 -${tag_bit} {"name": "tag_bit", "address": "1!000001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} -${tag_int16} {"name": "tag_int16", "address": "1!400001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT16}} -${tag_uint16} {"name": "tag_uint16", "address": "1!400002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} -${tag_int32} {"name": "tag_int32", "address": "1!400003", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} -${tag_uint32} {"name": "tag_uint32", "address": "1!400005", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT32}} -${tag_float} {"name": "tag_float", "address": "1!400007", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} +${tag_bit} {"name": "tag_bit", "address": "1!000001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} +${tag_int16} {"name": "tag_int16", "address": "1!400001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT16}} +${tag_uint16} {"name": "tag_uint16", "address": "1!400002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} +${tag_int32} {"name": "tag_int32", "address": "1!400003", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} +${tag_uint32} {"name": "tag_uint32", "address": "1!400005", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT32}} +${tag_float} {"name": "tag_float", "address": "1!400007", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} -${tag1_bit} {"name": "tag1", "address": "1!100001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} -${tag2_bit} {"name": "tag2", "address": "1!100002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} -${tag1_int16} {"name": "tag1", "address": "1!301021", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} -${tag2_int16} {"name": "tag2", "address": "1!301022", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} -${tag1_uint16} {"name": "tag1", "address": "1!301019", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} -${tag2_uint16} {"name": "tag2", "address": "1!301020", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} -${tag1_int32} {"name": "tag1", "address": "1!301010", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT32}} -${tag2_int32} {"name": "tag2", "address": "1!301011", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT32}} -${tag1_uint32} {"name": "tag1", "address": "1!301017", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} -${tag2_uint32} {"name": "tag2", "address": "1!301018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} -${tag1_float} {"name": "tag1", "address": "1!300009", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} -${tag2_float} {"name": "tag2", "address": "1!300008", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} +${tag1_bit} {"name": "tag1", "address": "1!100001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} +${tag2_bit} {"name": "tag2", "address": "1!100002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} +${tag1_int16} {"name": "tag1", "address": "1!301021", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} +${tag2_int16} {"name": "tag2", "address": "1!301022", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} +${tag1_uint16} {"name": "tag1", "address": "1!301019", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} +${tag2_uint16} {"name": "tag2", "address": "1!301020", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} +${tag1_int32} {"name": "tag1", "address": "1!301010", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT32}} +${tag2_int32} {"name": "tag2", "address": "1!301011", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT32}} +${tag1_uint32} {"name": "tag1", "address": "1!301017", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} +${tag2_uint32} {"name": "tag2", "address": "1!301018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} +${tag1_float} {"name": "tag1", "address": "1!300009", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} +${tag2_float} {"name": "tag2", "address": "1!300008", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} *** Test Cases *** Read unsubscribed point, it should return failure - ${res} = Add Tags ${test_node_id} xxgrp ${tag_int16} - Sleep 1s 500ms + Skip If Not Http API + ${res} = Add Tags ${test_node_id} xxgrp ${tag_int16} + Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} xxgrp - Check Response Status ${res} 404 - Check Error Code ${res} ${ERR_GRP_NOT_SUBSCRIBE} + ${res} = Read Tags ${test_node_id} xxgrp + Check Response Status ${res} 200 + Integer $.tags[0].error ${ERR_GRP_NOT_SUBSCRIBE} - ${res} = Del Group Config ${test_node_id} xxgrp - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + ${res} = Del Group Config ${test_node_id} xxgrp + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} Read/Write a point in the hold reg or coil area, and the data as bit/int16/uint16/int32/uint32/float type, it should return success - [Template] Read Write A Point In The hold/coil Reg Area Should Success - ${test_node_id} ${group} ${tag_bit} coil bit 1 - ${test_node_id} ${group} ${tag_int16} hold reg int16 123 - ${test_node_id} ${group} ${tag_uint16} hold reg uint16 456 - ${test_node_id} ${group} ${tag_int32} hold reg int32 66778899 - ${test_node_id} ${group} ${tag_uint32} hold reg int32 667788995 - ${test_node_id} ${group} ${tag_float} hold reg float 11.22 + [Template] Read Write A Point In The hold/coil Reg Area Should Success + ${test_node_id} ${group} ${tag_bit} coil bit 1 + ${test_node_id} ${group} ${tag_int16} hold reg int16 123 + ${test_node_id} ${group} ${tag_uint16} hold reg uint16 456 + ${test_node_id} ${group} ${tag_int32} hold reg int32 66778899 + ${test_node_id} ${group} ${tag_uint32} hold reg int32 667788995 + ${test_node_id} ${group} ${tag_float} hold reg float 11.22 Read a point in the input or input reg area, and the data as bit/int16/uint16/int32/uint32/float type, it should return success - [Template] Read A Point In The Input Or Input Reg Area Should Return Success - ${test_node_id} ${group} input bit ${tag1_bit} 0 ${tag2_bit} 1 - ${test_node_id} ${group} input reg int16 ${tag1_int16} 1020 ${tag2_int16} 1021 - ${test_node_id} ${group} input reg uint16 ${tag1_uint16} 1018 ${tag2_uint16} 1019 - ${test_node_id} ${group} input reg int32 ${tag1_int32} 66126834 ${tag2_int32} 66191360 - ${test_node_id} ${group} input reg uint32 ${tag1_uint32} 66585593 ${tag2_uint32} 66650112 - ${test_node_id} ${group} input reg float ${tag1_float} 7.346839692639297e-40 ${tag2_float} 6.428596834936531e-40 + [Template] Read A Point In The Input Or Input Reg Area Should Return Success + ${test_node_id} ${group} input bit ${tag1_bit} 0 ${tag2_bit} 1 + ${test_node_id} ${group} input reg int16 ${tag1_int16} 1020 ${tag2_int16} 1021 + ${test_node_id} ${group} input reg uint16 ${tag1_uint16} 1018 ${tag2_uint16} 1019 + ${test_node_id} ${group} input reg int32 ${tag1_int32} 66126834 ${tag2_int32} 66191360 + ${test_node_id} ${group} input reg uint32 ${tag1_uint32} 66585593 ${tag2_uint32} 66650112 + ${test_node_id} ${group} input reg float ${tag1_float} 7.346839692639297e-40 ${tag2_float} 6.428596834936531e-40 Read multiple points in the coil area, the point address includes continuous and non-continuous, and the data as bit type, it should return success - ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!000001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!000002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!000010", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!000012", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!000107", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!000108", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!001022", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!001020", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!000001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!000002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!000010", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!000012", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!000107", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!000108", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!001022", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!001020", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - Should Not Be Equal As Integers ${tag1_id} -1 - Should Not Be Equal As Integers ${tag2_id} -1 - Should Not Be Equal As Integers ${tag3_id} -1 - Should Not Be Equal As Integers ${tag4_id} -1 - Should Not Be Equal As Integers ${tag5_id} -1 - Should Not Be Equal As Integers ${tag6_id} -1 - Should Not Be Equal As Integers ${tag7_id} -1 - Should Not Be Equal As Integers ${tag8_id} -1 + Should Not Be Equal As Integers ${tag1_id} -1 + Should Not Be Equal As Integers ${tag2_id} -1 + Should Not Be Equal As Integers ${tag3_id} -1 + Should Not Be Equal As Integers ${tag4_id} -1 + Should Not Be Equal As Integers ${tag5_id} -1 + Should Not Be Equal As Integers ${tag6_id} -1 + Should Not Be Equal As Integers ${tag7_id} -1 + Should Not Be Equal As Integers ${tag8_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag7_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag7_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 - Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag4_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag5_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag7_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag4_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag5_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag7_id}, "value": 1} - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag7_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag7_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 - [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} + [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} Read multiple points in the input area, the point address includes continuous and non-continuous, and the data as bit type, it should return success - ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!100001", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!100002", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!100010", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!100012", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!100107", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!100108", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!101022", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!101020", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!100001", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!100002", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!100010", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!100012", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!100107", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!100108", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!101022", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!101020", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - Should Not Be Equal As Integers ${tag1_id} -1 - Should Not Be Equal As Integers ${tag2_id} -1 - Should Not Be Equal As Integers ${tag3_id} -1 - Should Not Be Equal As Integers ${tag4_id} -1 - Should Not Be Equal As Integers ${tag5_id} -1 - Should Not Be Equal As Integers ${tag6_id} -1 - Should Not Be Equal As Integers ${tag7_id} -1 - Should Not Be Equal As Integers ${tag8_id} -1 + Should Not Be Equal As Integers ${tag1_id} -1 + Should Not Be Equal As Integers ${tag2_id} -1 + Should Not Be Equal As Integers ${tag3_id} -1 + Should Not Be Equal As Integers ${tag4_id} -1 + Should Not Be Equal As Integers ${tag5_id} -1 + Should Not Be Equal As Integers ${tag6_id} -1 + Should Not Be Equal As Integers ${tag7_id} -1 + Should Not Be Equal As Integers ${tag8_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag7_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag8_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag7_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag8_id} 1 - [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} + [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} Read multiple points in the input reg area, the point address includes continuous and non-continuous, and the data includes int16/uint16/int32/uint32/float type, it should return success - ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!300001", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} - ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!300002", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} - ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!300010", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} - ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!300012", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} - ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!300107", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT32}} - ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!300110", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} - ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!301018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} - ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!301020", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} + ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!300001", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} + ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!300002", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} + ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!300010", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} + ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!300012", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT16}} + ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!300107", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT32}} + ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!300110", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} + ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!301018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} + ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!301020", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} - Should Not Be Equal As Integers ${tag1_id} -1 - Should Not Be Equal As Integers ${tag2_id} -1 - Should Not Be Equal As Integers ${tag3_id} -1 - Should Not Be Equal As Integers ${tag4_id} -1 - Should Not Be Equal As Integers ${tag5_id} -1 - Should Not Be Equal As Integers ${tag6_id} -1 - Should Not Be Equal As Integers ${tag7_id} -1 - Should Not Be Equal As Integers ${tag8_id} -1 + Should Not Be Equal As Integers ${tag1_id} -1 + Should Not Be Equal As Integers ${tag2_id} -1 + Should Not Be Equal As Integers ${tag3_id} -1 + Should Not Be Equal As Integers ${tag4_id} -1 + Should Not Be Equal As Integers ${tag5_id} -1 + Should Not Be Equal As Integers ${tag6_id} -1 + Should Not Be Equal As Integers ${tag7_id} -1 + Should Not Be Equal As Integers ${tag8_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 9 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 11 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 6946923 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 7143534 - Compare Tag Value As Int ${res}[tags] ${tag7_id} 66651130 - Compare Tag Value As Float ${res}[tags] ${tag8_id} 1.475336887045722e-36 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 9 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 11 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 6946923 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 7143534 + Compare Tag Value As Int ${res}[tags] ${tag7_id} 66651130 + Compare Tag Value As Float ${res}[tags] ${tag8_id} 1.475336887045722e-36 - [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} + [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} Read multiple points in the hold reg area, the point address includes continuous and non-continuous, and the data includes int16/uint16/int32/uint32/float type, it should return success - ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!400001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT16}} - ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!400002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT16}} - ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!400010", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} - ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!400012", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} - ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!400107", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} - ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!400110", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT32}} - ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!401018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT32}} - ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!401020", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} + ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!400001", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT16}} + ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!400002", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT16}} + ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!400010", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} + ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!400012", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} + ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!400107", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} + ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!400110", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT32}} + ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!401018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT32}} + ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!401020", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} - Should Not Be Equal As Integers ${tag1_id} -1 - Should Not Be Equal As Integers ${tag2_id} -1 - Should Not Be Equal As Integers ${tag3_id} -1 - Should Not Be Equal As Integers ${tag4_id} -1 - Should Not Be Equal As Integers ${tag5_id} -1 - Should Not Be Equal As Integers ${tag6_id} -1 - Should Not Be Equal As Integers ${tag7_id} -1 - Should Not Be Equal As Integers ${tag8_id} -1 + Should Not Be Equal As Integers ${tag1_id} -1 + Should Not Be Equal As Integers ${tag2_id} -1 + Should Not Be Equal As Integers ${tag3_id} -1 + Should Not Be Equal As Integers ${tag4_id} -1 + Should Not Be Equal As Integers ${tag5_id} -1 + Should Not Be Equal As Integers ${tag6_id} -1 + Should Not Be Equal As Integers ${tag7_id} -1 + Should Not Be Equal As Integers ${tag8_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 123 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 456 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag7_id} 0 - Compare Tag Value As Float ${res}[tags] ${tag8_id} 0.0 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 123 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 456 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag7_id} 0 + Compare Tag Value As Float ${res}[tags] ${tag8_id} 0.0 - Write Tags ${test_node_id} ${group} {"id": ${tag1_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 2} - Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 10} - Write Tags ${test_node_id} ${group} {"id": ${tag4_id}, "value": 12} - Write Tags ${test_node_id} ${group} {"id": ${tag5_id}, "value": 6946924} - Write Tags ${test_node_id} ${group} {"id": ${tag6_id}, "value": 7143536} - Write Tags ${test_node_id} ${group} {"id": ${tag7_id}, "value": 66651131} - Write Tags ${test_node_id} ${group} {"id": ${tag8_id}, "value": 11.234} + Write Tags ${test_node_id} ${group} {"id": ${tag1_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 2} + Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 10} + Write Tags ${test_node_id} ${group} {"id": ${tag4_id}, "value": 12} + Write Tags ${test_node_id} ${group} {"id": ${tag5_id}, "value": 6946924} + Write Tags ${test_node_id} ${group} {"id": ${tag6_id}, "value": 7143536} + Write Tags ${test_node_id} ${group} {"id": ${tag7_id}, "value": 66651131} + Write Tags ${test_node_id} ${group} {"id": ${tag8_id}, "value": 11.234} - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 2 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 10 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 12 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 6946924 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 7143536 - Compare Tag Value As Int ${res}[tags] ${tag7_id} 66651131 - Compare Tag Value As Float ${res}[tags] ${tag8_id} 11.234 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 2 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 10 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 12 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 6946924 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 7143536 + Compare Tag Value As Int ${res}[tags] ${tag7_id} 66651131 + Compare Tag Value As Float ${res}[tags] ${tag8_id} 11.234 - [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} + [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id} Read multiple points belonging to different areas(coil/input/input reg/hold reg), the point address includes continuous and non-continuous, and the data include bit/int16/uint16/int32/uint32/float type, it should return success - ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!000008", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!000009", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!000011", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!100008", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!300008", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} - ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!300009", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} - ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!300012", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} - ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!400009", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} - ${tag9_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag9", "address": "1!400020", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} - ${tag10_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag10", "address": "1!400015", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} + ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!000008", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "1!000009", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "1!000011", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "1!100008", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "1!300008", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} + ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "1!300009", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} + ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "1!300012", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} + ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "1!400009", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} + ${tag9_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag9", "address": "1!400020", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} + ${tag10_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag10", "address": "1!400015", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} - Should Not Be Equal As Integers ${tag1_id} -1 - Should Not Be Equal As Integers ${tag2_id} -1 - Should Not Be Equal As Integers ${tag3_id} -1 - Should Not Be Equal As Integers ${tag4_id} -1 - Should Not Be Equal As Integers ${tag5_id} -1 - Should Not Be Equal As Integers ${tag6_id} -1 - Should Not Be Equal As Integers ${tag7_id} -1 - Should Not Be Equal As Integers ${tag8_id} -1 - Should Not Be Equal As Integers ${tag9_id} -1 - Should Not Be Equal As Integers ${tag10_id} -1 + Should Not Be Equal As Integers ${tag1_id} -1 + Should Not Be Equal As Integers ${tag2_id} -1 + Should Not Be Equal As Integers ${tag3_id} -1 + Should Not Be Equal As Integers ${tag4_id} -1 + Should Not Be Equal As Integers ${tag5_id} -1 + Should Not Be Equal As Integers ${tag6_id} -1 + Should Not Be Equal As Integers ${tag7_id} -1 + Should Not Be Equal As Integers ${tag8_id} -1 + Should Not Be Equal As Integers ${tag9_id} -1 + Should Not Be Equal As Integers ${tag10_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 7 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 524297 - Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.010207273319475e-39 - Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag9_id} 0 - Compare Tag Value As Float ${res}[tags] ${tag10_id} 0.0 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 7 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 524297 + Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.010207273319475e-39 + Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag9_id} 0 + Compare Tag Value As Float ${res}[tags] ${tag10_id} 0.0 - Write Tags ${test_node_id} ${group} {"id": ${tag1_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag8_id}, "value": 62225} - Write Tags ${test_node_id} ${group} {"id": ${tag9_id}, "value": 66651134} - Write Tags ${test_node_id} ${group} {"id": ${tag10_id}, "value": 11.123} + Write Tags ${test_node_id} ${group} {"id": ${tag1_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag8_id}, "value": 62225} + Write Tags ${test_node_id} ${group} {"id": ${tag9_id}, "value": 66651134} + Write Tags ${test_node_id} ${group} {"id": ${tag10_id}, "value": 11.123} - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 7 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 524297 - Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.010207273319475e-39 - Compare Tag Value As Int ${res}[tags] ${tag8_id} 62225 - Compare Tag Value As Int ${res}[tags] ${tag9_id} 66651134 - Compare Tag Value As Float ${res}[tags] ${tag10_id} 11.123 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 7 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 524297 + Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.010207273319475e-39 + Compare Tag Value As Int ${res}[tags] ${tag8_id} 62225 + Compare Tag Value As Int ${res}[tags] ${tag9_id} 66651134 + Compare Tag Value As Float ${res}[tags] ${tag10_id} 11.123 - [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id},${tag9_id},${tag10_id} + [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id},${tag9_id},${tag10_id} Read multiple points belonging to different areas(coil/input/input reg/hold reg) and different sites, the point address includes continuous and non-continuous, and the data include int16/uint16/int32/uint32/float type, it should return success - ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!000018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "2!000018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "3!000021", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "4!100018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} - ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "5!300018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} - ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "6!300018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} - ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "7!300022", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} - ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "8!400018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} - ${tag9_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag9", "address": "9!400040", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} - ${tag10_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag10", "address": "10!400022", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} + ${tag1_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag1", "address": "1!000018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag2_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag2", "address": "2!000018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag3_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag3", "address": "3!000021", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag4_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag4", "address": "4!100018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_BIT}} + ${tag5_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag5", "address": "5!300018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_INT16}} + ${tag6_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag6", "address": "6!300018", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_UINT32}} + ${tag7_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag7", "address": "7!300022", "attribute": ${TAG_ATTRIBUTE_READ}, "type": ${TAG_DATA_TYPE_FLOAT}} + ${tag8_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag8", "address": "8!400018", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_UINT16}} + ${tag9_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag9", "address": "9!400040", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_INT32}} + ${tag10_id} = Add Tag And Return ID ${test_node_id} ${group} {"name": "tag10", "address": "10!400022", "attribute": ${TAG_ATTRIBUTE_RW}, "type": ${TAG_DATA_TYPE_FLOAT}} - Should Not Be Equal As Integers ${tag1_id} -1 - Should Not Be Equal As Integers ${tag2_id} -1 - Should Not Be Equal As Integers ${tag3_id} -1 - Should Not Be Equal As Integers ${tag4_id} -1 - Should Not Be Equal As Integers ${tag5_id} -1 - Should Not Be Equal As Integers ${tag6_id} -1 - Should Not Be Equal As Integers ${tag7_id} -1 - Should Not Be Equal As Integers ${tag8_id} -1 - Should Not Be Equal As Integers ${tag9_id} -1 - Should Not Be Equal As Integers ${tag10_id} -1 + Should Not Be Equal As Integers ${tag1_id} -1 + Should Not Be Equal As Integers ${tag2_id} -1 + Should Not Be Equal As Integers ${tag3_id} -1 + Should Not Be Equal As Integers ${tag4_id} -1 + Should Not Be Equal As Integers ${tag5_id} -1 + Should Not Be Equal As Integers ${tag6_id} -1 + Should Not Be Equal As Integers ${tag7_id} -1 + Should Not Be Equal As Integers ${tag8_id} -1 + Should Not Be Equal As Integers ${tag9_id} -1 + Should Not Be Equal As Integers ${tag10_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 17 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 1114130 - Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.928576247884031e-39 - Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 - Compare Tag Value As Int ${res}[tags] ${tag9_id} 0 - Compare Tag Value As Float ${res}[tags] ${tag10_id} 0.0 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 17 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 1114130 + Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.928576247884031e-39 + Compare Tag Value As Int ${res}[tags] ${tag8_id} 0 + Compare Tag Value As Int ${res}[tags] ${tag9_id} 0 + Compare Tag Value As Float ${res}[tags] ${tag10_id} 0.0 - Write Tags ${test_node_id} ${group} {"id": ${tag1_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 1} - Write Tags ${test_node_id} ${group} {"id": ${tag8_id}, "value": 62226} - Write Tags ${test_node_id} ${group} {"id": ${tag9_id}, "value": 66651136} - Write Tags ${test_node_id} ${group} {"id": ${tag10_id}, "value": 11.789} + Write Tags ${test_node_id} ${group} {"id": ${tag1_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag2_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag3_id}, "value": 1} + Write Tags ${test_node_id} ${group} {"id": ${tag8_id}, "value": 62226} + Write Tags ${test_node_id} ${group} {"id": ${tag9_id}, "value": 66651136} + Write Tags ${test_node_id} ${group} {"id": ${tag10_id}, "value": 11.789} - Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} ${group} + Sleep 1s 500ms + ${res} = Read Tags ${test_node_id} ${group} - Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 - Compare Tag Value As Int ${res}[tags] ${tag5_id} 17 - Compare Tag Value As Int ${res}[tags] ${tag6_id} 1114130 - Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.928576247884031e-39 - Compare Tag Value As Int ${res}[tags] ${tag8_id} 62226 - Compare Tag Value As Int ${res}[tags] ${tag9_id} 66651136 - Compare Tag Value As Float ${res}[tags] ${tag10_id} 11.789 + Compare Tag Value As Int ${res}[tags] ${tag1_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag2_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag3_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag4_id} 1 + Compare Tag Value As Int ${res}[tags] ${tag5_id} 17 + Compare Tag Value As Int ${res}[tags] ${tag6_id} 1114130 + Compare Tag Value As Float ${res}[tags] ${tag7_id} 1.928576247884031e-39 + Compare Tag Value As Int ${res}[tags] ${tag8_id} 62226 + Compare Tag Value As Int ${res}[tags] ${tag9_id} 66651136 + Compare Tag Value As Float ${res}[tags] ${tag10_id} 11.789 - [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id},${tag9_id},${tag10_id} + [Teardown] Del Tags ${test_node_id} ${group} ${tag1_id},${tag2_id},${tag3_id},${tag4_id},${tag5_id},${tag6_id},${tag7_id},${tag8_id},${tag9_id},${tag10_id} *** Keywords *** Neuron Context Ready - Import Neuron API Resource + Import Neuron API Resource - Start Simulator ${MODBUS_TCP_SERVER_SIMULATOR} ${SIMULATOR_DIR} - Neuron Ready + Start Simulator ${MODBUS_TCP_SERVER_SIMULATOR} ${SIMULATOR_DIR} + Neuron Ready - LOGIN + LOGIN - ${id} = Get Node ID ${NODE_DRIVER} modbus-tcp-adapter + ${id} = Get Node ID ${NODE_DRIVER} modbus-tcp-adapter - Set Global Variable ${test_node_id} ${id} + Set Global Variable ${test_node_id} ${id} - Node Setting ${test_node_id} ${MODBUS_TCP_CONFIG} - Update Group Config ${test_node_id} ${group} 300 + Node Setting ${test_node_id} ${MODBUS_TCP_CONFIG} + Update Group Config ${test_node_id} ${group} 300 Stop All Processes - LOGOUT + LOGOUT - Stop Neuron remove_persistence_data=True - sleep 1s - Terminate All Processes kill=false + Stop Neuron remove_persistence_data=True + sleep 1s + Terminate All Processes kill=false Read Write A Point In The hold/coil Reg Area Should Success - [Arguments] ${node_id} ${group} ${tag} ${area} ${type} ${value} - Log Read a point in the ${area} reg area, and the data as ${type}, it should return success - Log To Console Read a point in the ${area} reg area, and the data as ${type}, it should return success + [Arguments] ${node_id} ${group} ${tag} ${area} ${type} ${value} + Log Read a point in the ${area} reg area, and the data as ${type}, it should return success + Log To Console Read a point in the ${area} reg area, and the data as ${type}, it should return success - IF "${type}" == "float" - ${cmp} = Set Variable Compare Tag Value As Float - ELSE - ${cmp} = Set Variable Compare Tag Value As Int - END + IF "${type}" == "float" + ${cmp} = Set Variable Compare Tag Value As Float + ELSE + ${cmp} = Set Variable Compare Tag Value As Int + END - ${tag_id} = Add Tag And Return ID ${node_id} ${group} ${tag} - Should Not Be Equal As Integers ${tag_id} -1 + ${tag_id} = Add Tag And Return ID ${node_id} ${group} ${tag} + Should Not Be Equal As Integers ${tag_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${node_id} ${group} - Check Response Status ${res} 200 + Sleep 1s 500ms + ${res} = Read Tags ${node_id} ${group} + Check Response Status ${res} 200 #Check Error Code ${res} ${ERR_SUCCESS} - Run Keyword ${cmp} ${res}[tags] ${tag_id} 0 + Run Keyword ${cmp} ${res}[tags] ${tag_id} 0 - ${res} = Write Tags ${node_id} ${group} {"id": ${tag_id}, "value": ${value}} + ${res} = Write Tags ${node_id} ${group} {"id": ${tag_id}, "value": ${value}} - Sleep 1s 500ms - ${res} = Read Tags ${node_id} ${group} - Check Response Status ${res} 200 + Sleep 1s 500ms + ${res} = Read Tags ${node_id} ${group} + Check Response Status ${res} 200 #Check Error Code ${res} ${ERR_SUCCESS} - Run Keyword ${cmp} ${res}[tags] ${tag_id} ${value} + Run Keyword ${cmp} ${res}[tags] ${tag_id} ${value} - [Teardown] Del Tags ${node_id} ${group} ${tag_id} + [Teardown] Del Tags ${node_id} ${group} ${tag_id} Read A Point In The Input Or Input Reg Area Should Return Success - [Arguments] ${node_id} ${group} ${area} ${type} ${tag1} ${value1} ${tag2} ${value2} - Log Read a point in the ${area} area, and the data as ${type}, it should return success - Log To Console Read a point in the ${area} area, and the data as ${type}, it should return success + [Arguments] ${node_id} ${group} ${area} ${type} ${tag1} ${value1} ${tag2} ${value2} + Log Read a point in the ${area} area, and the data as ${type}, it should return success + Log To Console Read a point in the ${area} area, and the data as ${type}, it should return success - IF "${type}" == "float" - ${cmp} = Set Variable Compare Tag Value As Float - ELSE - ${cmp} = Set Variable Compare Tag Value As Int - END + IF "${type}" == "float" + ${cmp} = Set Variable Compare Tag Value As Float + ELSE + ${cmp} = Set Variable Compare Tag Value As Int + END - ${tag1_id} = Add Tag And Return ID ${node_id} ${group} ${tag1} - Should Not Be Equal As Integers ${tag1_id} -1 + ${tag1_id} = Add Tag And Return ID ${node_id} ${group} ${tag1} + Should Not Be Equal As Integers ${tag1_id} -1 - ${tag2_id} = Add Tag And Return ID ${node_id} ${group} ${tag2} - Should Not Be Equal As Integers ${tag2_id} -1 + ${tag2_id} = Add Tag And Return ID ${node_id} ${group} ${tag2} + Should Not Be Equal As Integers ${tag2_id} -1 - Sleep 1s 500ms - ${res} = Read Tags ${node_id} ${group} - Check Response Status ${res} 200 + Sleep 1s 500ms + ${res} = Read Tags ${node_id} ${group} + Check Response Status ${res} 200 #Check Error Code ${res} ${ERR_SUCCESS} - Run Keyword ${cmp} ${res}[tags] ${tag1_id} ${value1} - Run Keyword ${cmp} ${res}[tags] ${tag2_id} ${value2} + Run Keyword ${cmp} ${res}[tags] ${tag1_id} ${value1} + Run Keyword ${cmp} ${res}[tags] ${tag2_id} ${value2} - [Teardown] Del Tags ${node_id} ${group} ${tag1_id},${tag2_id} + [Teardown] Del Tags ${node_id} ${group} ${tag1_id},${tag2_id} Del Tags Check - [Arguments] ${node_id} ${group} ${tag_id} - ${res} = Del Tags ${node_id} ${group} ${tag_id} - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + [Arguments] ${node_id} ${group} ${tag_id} + ${res} = Del Tags ${node_id} ${group} ${tag_id} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} diff --git a/include/json/neu_json_rw.h b/include/json/neu_json_rw.h index 7144f664..3d3e573f 100644 --- a/include/json/neu_json_rw.h +++ b/include/json/neu_json_rw.h @@ -33,6 +33,7 @@ extern "C" { typedef struct { int64_t id; + int32_t error; enum neu_json_type t; union neu_json_value value; } neu_json_read_resp_tag_t; diff --git a/include/neu_errcodes.h b/include/neu_errcodes.h index 81bc84c8..00aa3bc4 100644 --- a/include/neu_errcodes.h +++ b/include/neu_errcodes.h @@ -94,11 +94,11 @@ typedef enum { NEU_ERR_PLUGIN_LIBRARY_INFO_INVALID = 2021, NEU_ERR_PLUGIN_LIBRARY_NAME_CONFLICT = 2022, - NEU_ERR_DEVICE_READ_FAILURE = 3000, - NEU_ERR_DEVICE_WRITE_FAILURE = 3001, - NEU_ERR_DEVICE_DISCONNECTED = 3002, - NEU_ERR_DEVICE_TAG_CANNOT_READ = 3003, - NEU_ERR_DEVICE_TAG_CANNOT_WRITE = 3004, + NEU_ERR_DEVICE_READ_FAILURE = 3000, + NEU_ERR_DEVICE_WRITE_FAILURE = 3001, + NEU_ERR_DEVICE_DISCONNECTED = 3002, + NEU_ERR_DEVICE_TAG_NOT_ALLOW_READ = 3003, + NEU_ERR_DEVICE_TAG_NOT_ALLOW_WRITE = 3004, NEU_ERR_DEVICE_OPCUA_ABNORMALITY = 3100, NEU_ERR_DEVICE_OPCUA_TAG_TYPE_NOT_MATCH = 3101, diff --git a/plugins/modbus/modbus_tcp.c b/plugins/modbus/modbus_tcp.c index caaae29d..a266ffad 100644 --- a/plugins/modbus/modbus_tcp.c +++ b/plugins/modbus/modbus_tcp.c @@ -173,197 +173,129 @@ setup_read_resp_data_value(neu_datatag_table_t * tag_table, neu_taggrp_config_t * grp_config, modbus_point_context_t *point_ctx) { - neu_data_val_t * resp_val = NULL; - int read_count = 0; - modbus_data_t data_tags = { 0 }; - vector_t * ids = neu_taggrp_cfg_get_datatag_ids(grp_config); - neu_fixed_array_t *array_resp = NULL; - int index = 1; - neu_data_val_t * val_error_resp = neu_dvalue_new(NEU_DTYPE_ERRORCODE); - neu_int_val_t int_val_resp = { 0 }; - neu_err_code_e error = NEU_ERR_SUCCESS; - - read_count = neu_plugin_tag_count_by_attribute(grp_config, tag_table, - NEU_ATTRIBUTE_READ); - - resp_val = neu_dvalue_unit_new(); - if (resp_val == NULL) { - log_error("Failed to allocate data value for response tags"); - neu_dvalue_free(val_error_resp); - return NULL; - } - - array_resp = neu_fixed_array_new(read_count + 1, sizeof(neu_int_val_t)); - if (array_resp == NULL) { - log_error("Failed to allocate array for response tags"); - neu_dvalue_free(resp_val); - neu_dvalue_free(val_error_resp); - return NULL; - } + vector_t * ids = neu_taggrp_cfg_get_datatag_ids(grp_config); + neu_data_val_t *resp_val = neu_datatag_pack_create(ids->size); + int index = -1; VECTOR_FOR_EACH(ids, iter_id) { - neu_datatag_id_t *id = (neu_datatag_id_t *) iterator_get(&iter_id); - neu_datatag_t * tag = neu_datatag_tbl_get(tag_table, *id); - int result = 0; - neu_int_val_t int_val = { 0 }; + neu_datatag_id_t *id = (neu_datatag_id_t *) iterator_get(&iter_id); + neu_datatag_t * tag = neu_datatag_tbl_get(tag_table, *id); + modbus_data_t data_tags = { 0 }; + + index += 1; if (tag == NULL) { // The tag had been deleted by other node + neu_err_code_e error = NEU_ERR_TAG_NOT_EXIST; + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_ERRORCODE, *id, + (void *) &error); continue; } - if ((tag->attribute & NEU_ATTRIBUTE_READ) == NEU_ATTRIBUTE_READ) { + if ((tag->attribute & NEU_ATTRIBUTE_READ) != NEU_ATTRIBUTE_READ) { + neu_err_code_e error = NEU_ERR_DEVICE_TAG_NOT_ALLOW_READ; + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_ERRORCODE, *id, + (void *) &error); + continue; + } + + switch (tag->type) { + case NEU_DTYPE_UINT32: + case NEU_DTYPE_INT32: + case NEU_DTYPE_FLOAT: + data_tags.type = MODBUS_B32; + break; + case NEU_DTYPE_UINT16: + case NEU_DTYPE_INT16: + data_tags.type = MODBUS_B16; + break; + case NEU_DTYPE_BIT: + data_tags.type = MODBUS_B8; + break; + default: + break; + } + if (modbus_point_find(point_ctx, tag->addr_str, &data_tags) == -1) { + log_error("Failed to find modbus point %s", tag->addr_str); + + neu_err_code_e error = NEU_ERR_TAG_NOT_EXIST; + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_ERRORCODE, *id, + (void *) &error); + continue; + } + + switch (data_tags.type) { + case MODBUS_B8: { + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_BIT, *id, + (void *) &data_tags.val.val_u8); + break; + } + case MODBUS_B16: switch (tag->type) { - case NEU_DTYPE_UINT32: - case NEU_DTYPE_INT32: - case NEU_DTYPE_FLOAT: - data_tags.type = MODBUS_B32; + case NEU_DTYPE_INT16: { + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_INT16, *id, + (void *) &data_tags.val.val_u16); break; - case NEU_DTYPE_UINT16: - case NEU_DTYPE_INT16: - data_tags.type = MODBUS_B16; - break; - case NEU_DTYPE_BIT: - data_tags.type = MODBUS_B8; + } + case NEU_DTYPE_UINT16: { + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_UINT16, *id, + (void *) &data_tags.val.val_u16); break; + } default: break; } - result = modbus_point_find(point_ctx, tag->addr_str, &data_tags); - if (result == -1) { - neu_data_val_t *val_error = neu_dvalue_new(NEU_DTYPE_ERRORCODE); - - log_error("Failed to find modbus point %s", tag->addr_str); - neu_dvalue_set_errorcode(val_error, result); - neu_int_val_init(&int_val, tag->id, val_error); - neu_fixed_array_set(array_resp, index, (void *) &int_val); - - error = NEU_ERR_TAG_NOT_EXIST; - } else { - switch (data_tags.type) { - case MODBUS_B8: { - neu_data_val_t *val_bit = neu_dvalue_new(NEU_DTYPE_BIT); - neu_dvalue_set_bit(val_bit, data_tags.val.val_u8); - neu_int_val_init(&int_val, tag->id, val_bit); - neu_fixed_array_set(array_resp, index, (void *) &int_val); - break; - } - case MODBUS_B16: - switch (tag->type) { - case NEU_DTYPE_INT16: { - neu_data_val_t *val_i16 = - neu_dvalue_new(NEU_DTYPE_INT16); - neu_dvalue_set_int16(val_i16, data_tags.val.val_u16); - neu_int_val_init(&int_val, tag->id, val_i16); - neu_fixed_array_set(array_resp, index, - (void *) &int_val); - break; - } - case NEU_DTYPE_UINT16: { - neu_data_val_t *val_ui16 = - neu_dvalue_new(NEU_DTYPE_UINT16); - neu_dvalue_set_uint16(val_ui16, data_tags.val.val_u16); - neu_int_val_init(&int_val, tag->id, val_ui16); - neu_fixed_array_set(array_resp, index, - (void *) &int_val); - break; - } - default: - break; - } - break; - case MODBUS_B32: - switch (tag->type) { - case NEU_DTYPE_INT32: { - neu_data_val_t *val_i32 = - neu_dvalue_new(NEU_DTYPE_INT32); - neu_dvalue_set_int32(val_i32, data_tags.val.val_u32); - neu_int_val_init(&int_val, tag->id, val_i32); - neu_fixed_array_set(array_resp, index, - (void *) &int_val); - break; - } - case NEU_DTYPE_UINT32: { - neu_data_val_t *val_ui32 = - neu_dvalue_new(NEU_DTYPE_UINT32); - neu_dvalue_set_uint32(val_ui32, data_tags.val.val_u32); - neu_int_val_init(&int_val, tag->id, val_ui32); - neu_fixed_array_set(array_resp, index, - (void *) &int_val); - break; - } - case NEU_DTYPE_FLOAT: { - neu_data_val_t *val_float = - neu_dvalue_new(NEU_DTYPE_FLOAT); - neu_dvalue_set_float(val_float, data_tags.val.val_f32); - neu_int_val_init(&int_val, tag->id, val_float); - neu_fixed_array_set(array_resp, index, - (void *) &int_val); - break; - } - default: - break; - } - } + break; + case MODBUS_B32: + switch (tag->type) { + case NEU_DTYPE_INT32: { + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_INT32, *id, + (void *) &data_tags.val.val_u32); + break; + } + case NEU_DTYPE_UINT32: { + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_UINT32, *id, + (void *) &data_tags.val.val_u32); + break; + } + case NEU_DTYPE_FLOAT: { + neu_datatag_pack_add(resp_val, index, NEU_DTYPE_FLOAT, *id, + (void *) &data_tags.val.val_f32); + break; + } + default: + break; } } - index += 1; } - neu_dvalue_set_errorcode(val_error_resp, error); - neu_int_val_init(&int_val_resp, 0, val_error_resp); - neu_fixed_array_set(array_resp, 0, (void *) &int_val_resp); - - neu_dvalue_init_move_array(resp_val, NEU_DTYPE_INT_VAL, array_resp); - return resp_val; } static neu_data_val_t *setup_write_resp_data_value(neu_data_val_t *write_val, neu_plugin_t * plugin) { - neu_fixed_array_t *array_req = NULL; - neu_fixed_array_t *array_resp = NULL; - neu_data_val_t * resp_val = NULL; - neu_data_val_t * val_error_resp = neu_dvalue_new(NEU_DTYPE_ERRORCODE); - neu_int_val_t int_val_resp = { 0 }; - neu_err_code_e error = NEU_ERR_SUCCESS; + neu_err_code_e error = NEU_ERR_SUCCESS; + neu_fixed_array_t *array_req = NULL; neu_dvalue_get_ref_array(write_val, &array_req); - resp_val = neu_dvalue_unit_new(); - if (resp_val == NULL) { - log_error("Failed to allocate data value for response write data"); - neu_dvalue_free(val_error_resp); - return NULL; - } - - array_resp = neu_fixed_array_new(array_req->length, sizeof(neu_int_val_t)); - if (array_resp == NULL) { - log_error("Failed to allocate array for response write data"); - neu_dvalue_free(resp_val); - neu_dvalue_free(val_error_resp); - return NULL; - } + neu_data_val_t *resp_val = neu_datatag_pack_create(array_req->length); for (uint32_t i = 0; i < array_req->length; i++) { neu_int_val_t *int_val = neu_fixed_array_get(array_req, i); neu_dtype_e val_type = neu_value_type_in_dtype(neu_dvalue_get_type(int_val->val)); - modbus_data_t data = { 0 }; - neu_int_val_t iv; - neu_data_val_t *val_error = neu_dvalue_new(NEU_DTYPE_ERRORCODE); - neu_datatag_t * tag = + modbus_data_t data = { 0 }; + neu_datatag_t *tag = neu_datatag_tbl_get(plugin->tag_table, int_val->key); if (tag == NULL) { // The tag had been deleted by other node error = NEU_ERR_TAG_NOT_EXIST; - neu_dvalue_set_errorcode(val_error, error); - - neu_int_val_init(&iv, int_val->key, val_error); - neu_fixed_array_set(array_resp, i, (void *) &iv); + neu_datatag_pack_add(resp_val, i, NEU_DTYPE_ERRORCODE, int_val->key, + (void *) &error); continue; } @@ -413,22 +345,14 @@ static neu_data_val_t *setup_write_resp_data_value(neu_data_val_t *write_val, break; } - neu_dvalue_set_errorcode(val_error, error); + if (error == -1) { + error = NEU_ERR_DEVICE_WRITE_FAILURE; + } - neu_int_val_init(&iv, int_val->key, val_error); - neu_fixed_array_set(array_resp, i, (void *) &iv); + neu_datatag_pack_add(resp_val, i, NEU_DTYPE_ERRORCODE, int_val->key, + (void *) &error); } - if (error == -1) { - error = NEU_ERR_DEVICE_WRITE_FAILURE; - } - - neu_dvalue_set_errorcode(val_error_resp, error); - neu_int_val_init(&int_val_resp, 0, val_error_resp); - neu_fixed_array_set(array_resp, 0, (void *) &int_val_resp); - - neu_dvalue_init_move_array(resp_val, NEU_DTYPE_INT_VAL, array_resp); - return resp_val; } @@ -615,18 +539,20 @@ static int modbus_tcp_request(neu_plugin_t *plugin, neu_request_t *req) } pthread_mutex_unlock(&plugin->mtx); if (data_resp.data_val == NULL) { - neu_data_val_t *val_error = neu_dvalue_new(NEU_DTYPE_ERRORCODE); - neu_data_val_t *array_resp = neu_dvalue_unit_new(); - ; - neu_int_val_t val = { 0 }; - neu_fixed_array_t *array = - neu_fixed_array_new(1, sizeof(neu_int_val_t)); + vector_t *ids = + neu_taggrp_cfg_get_datatag_ids(read_req->grp_config); + data_resp.data_val = neu_datatag_pack_create(ids->size); + int32_t error = NEU_ERR_GRP_NOT_SUBSCRIBE; + int index = 0; - neu_dvalue_set_errorcode(val_error, NEU_ERR_GRP_NOT_SUBSCRIBE); - neu_int_val_init(&val, 0, val_error); - neu_fixed_array_set(array, 0, (void *) &val); - neu_dvalue_init_move_array(array_resp, NEU_DTYPE_INT_VAL, array); - data_resp.data_val = array_resp; + VECTOR_FOR_EACH(ids, iter) + { + neu_datatag_id_t *id = (neu_datatag_id_t *) iterator_get(&iter); + neu_datatag_pack_add(data_resp.data_val, index, + NEU_DTYPE_ERRORCODE, *id, (void *) &error); + + index += 1; + } } data_resp.grp_config = read_req->grp_config; resp.req_id = req->req_id; diff --git a/plugins/mqtt/command/read_write.c b/plugins/mqtt/command/read_write.c index f34964db..184b0c73 100644 --- a/plugins/mqtt/command/read_write.c +++ b/plugins/mqtt/command/read_write.c @@ -43,127 +43,128 @@ static int wrap_read_response_json_object(neu_fixed_array_t * array, { neu_int_val_t * int_val; neu_data_val_t *val; - int length = array->length; - json->n_tag = length - 1; + json->n_tag = array->length; if (0 == json->n_tag) { return -1; } json->tags = (neu_json_read_resp_tag_t *) calloc( - length - 1, sizeof(neu_json_read_resp_tag_t)); + array->length, sizeof(neu_json_read_resp_tag_t)); - for (int i = 1; i < length; i++) { + for (uint32_t i = 0; i < array->length; i++) { int_val = neu_fixed_array_get(array, i); val = int_val->val; neu_dtype_e type = neu_dvalue_get_value_type(val); - json->tags[i - 1].id = int_val->key; + json->tags[i].id = int_val->key; + json->tags[i].error = NEU_ERR_SUCCESS; switch (type) { case NEU_DTYPE_ERRORCODE: { int32_t value; neu_dvalue_get_errorcode(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; + json->tags[i].error = value; break; } case NEU_DTYPE_BYTE: { uint8_t value; neu_dvalue_get_uint8(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_INT8: { int8_t value; neu_dvalue_get_int8(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_INT16: { int16_t value; neu_dvalue_get_int16(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_INT32: { int32_t value; neu_dvalue_get_int32(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_INT64: { int64_t value; neu_dvalue_get_int64(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_UINT8: { uint8_t value; neu_dvalue_get_uint8(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_UINT16: { uint16_t value; neu_dvalue_get_uint16(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_UINT32: { uint32_t value; neu_dvalue_get_uint32(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_UINT64: { uint64_t value; neu_dvalue_get_uint64(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; break; } case NEU_DTYPE_FLOAT: { float value; neu_dvalue_get_float(val, &value); - json->tags[i - 1].t = NEU_JSON_FLOAT; - json->tags[i - 1].value.val_float = value; + json->tags[i].t = NEU_JSON_FLOAT; + json->tags[i].value.val_float = value; break; } case NEU_DTYPE_DOUBLE: { double value; neu_dvalue_get_double(val, &value); - json->tags[i - 1].t = NEU_JSON_DOUBLE; - json->tags[i - 1].value.val_double = value; + json->tags[i].t = NEU_JSON_DOUBLE; + json->tags[i].value.val_double = value; break; } case NEU_DTYPE_BOOL: { bool value; neu_dvalue_get_bool(val, &value); - json->tags[i - 1].t = NEU_JSON_BOOL; - json->tags[i - 1].value.val_bool = value; + json->tags[i].t = NEU_JSON_BOOL; + json->tags[i].value.val_bool = value; break; } case NEU_DTYPE_BIT: { uint8_t value; neu_dvalue_get_bit(val, &value); - json->tags[i - 1].t = NEU_JSON_BIT; - json->tags[i - 1].value.val_bit = value; + json->tags[i].t = NEU_JSON_BIT; + json->tags[i].value.val_bit = value; break; } case NEU_DTYPE_CSTR: { char *value; neu_dvalue_get_ref_cstr(val, &value); - json->tags[i - 1].t = NEU_JSON_STR; - json->tags[i - 1].value.val_str = value; + json->tags[i].t = NEU_JSON_STR; + json->tags[i].value.val_str = value; break; } default: @@ -204,22 +205,7 @@ char *command_read_once_response(neu_plugin_t * plugin, return NULL; } - neu_int_val_t * int_val; - neu_data_val_t *val_err; - int32_t errcode = 0; - char * json_str = NULL; - - int_val = neu_fixed_array_get(array, 0); - val_err = int_val->val; - neu_dvalue_get_errorcode(val_err, &errcode); - - if (0 != errcode) { - neu_json_error_resp_t error = { errcode }; - neu_json_encode_with_mqtt(&error, neu_json_encode_error_resp, - parse_header, neu_json_encode_mqtt_resp, - &json_str); - return json_str; - } + char *json_str = NULL; neu_json_read_resp_t json; memset(&json, 0, sizeof(neu_json_read_resp_t)); @@ -339,22 +325,21 @@ static int wrap_write_response_json_object(neu_fixed_array_t * array, { neu_int_val_t * int_val; neu_data_val_t *val; - int length = array->length; - json->n_tag = length - 1; + json->n_tag = array->length; json->tags = (neu_json_read_resp_tag_t *) calloc( - length - 1, sizeof(neu_json_read_resp_tag_t)); + array->length, sizeof(neu_json_read_resp_tag_t)); - for (int i = 1; i < length; i++) { + for (uint32_t i = 0; i < array->length; i++) { int_val = neu_fixed_array_get(array, i); val = int_val->val; - json->tags[i - 1].id = int_val->key; + json->tags[i].id = int_val->key; int32_t value; neu_dvalue_get_errorcode(val, &value); - json->tags[i - 1].t = NEU_JSON_INT; - json->tags[i - 1].value.val_int = value; + json->tags[i].t = NEU_JSON_INT; + json->tags[i].value.val_int = value; } return 0; @@ -382,14 +367,6 @@ char *command_write_response(neu_plugin_t * plugin, neu_fixed_array_t *array; neu_dvalue_get_ref_array(resp_val, &array); - neu_int_val_t * int_val; - neu_data_val_t *val_err; - int32_t error; - - int_val = neu_fixed_array_get(array, 0); - val_err = int_val->val; - neu_dvalue_get_errorcode(val_err, &error); - neu_json_read_resp_t json; wrap_write_response_json_object(array, &json); diff --git a/plugins/restful/rw_handle.c b/plugins/restful/rw_handle.c index fa75340d..d5b5521c 100644 --- a/plugins/restful/rw_handle.c +++ b/plugins/restful/rw_handle.c @@ -174,136 +174,134 @@ void handle_read_resp(void *cmd_resp) neu_json_read_resp_t api_res = { 0 }; char * result = NULL; neu_int_val_t * iv = NULL; - int32_t error = 0; log_info("read resp id: %d, ctx: %p", req->req_id, ctx); assert(ctx != NULL); neu_dvalue_get_ref_array(resp->data_val, &array); - iv = (neu_int_val_t *) neu_fixed_array_get(array, 0); - assert(iv->key == 0); - assert(neu_dvalue_get_value_type(iv->val) == NEU_DTYPE_ERRORCODE); - - neu_dvalue_get_errorcode(iv->val, &error); - if (error != 0) { - NEU_JSON_RESPONSE_ERROR( - error, { http_response(ctx->aio, error_code.error, result_error); }) - free(ctx); - return; - } - - api_res.n_tag = array->length - 1; + api_res.n_tag = array->length; api_res.tags = calloc(api_res.n_tag, sizeof(neu_json_read_resp_tag_t)); - for (size_t i = 1; i < array->length; i++) { + for (size_t i = 0; i < array->length; i++) { iv = (neu_int_val_t *) neu_fixed_array_get(array, i); - api_res.tags[i - 1].id = iv->key; + api_res.tags[i].id = iv->key; + api_res.tags[i].error = NEU_ERR_SUCCESS; switch (neu_dvalue_get_value_type(iv->val)) { + case NEU_DTYPE_ERRORCODE: { + int32_t error = NEU_ERR_SUCCESS; + + neu_dvalue_get_errorcode(iv->val, &error); + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = error; + api_res.tags[i].error = error; + + break; + } case NEU_DTYPE_BIT: { uint8_t bit = 0; neu_dvalue_get_bit(iv->val, &bit); - api_res.tags[i - 1].t = NEU_JSON_BIT; - api_res.tags[i - 1].value.val_bit = bit; + api_res.tags[i].t = NEU_JSON_BIT; + api_res.tags[i].value.val_bit = bit; break; } case NEU_DTYPE_INT8: { int8_t i8 = 0; neu_dvalue_get_int8(iv->val, &i8); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = i8; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = i8; break; } case NEU_DTYPE_UINT8: { uint8_t u8 = 0; neu_dvalue_get_uint8(iv->val, &u8); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = u8; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = u8; break; } case NEU_DTYPE_BOOL: { bool b = true; neu_dvalue_get_bool(iv->val, &b); - api_res.tags[i - 1].t = NEU_JSON_BOOL; - api_res.tags[i - 1].value.val_bool = b; + api_res.tags[i].t = NEU_JSON_BOOL; + api_res.tags[i].value.val_bool = b; break; } case NEU_DTYPE_UINT16: { uint16_t u16 = 0; neu_dvalue_get_uint16(iv->val, &u16); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = u16; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = u16; break; } case NEU_DTYPE_INT16: { int16_t i16 = 0; neu_dvalue_get_int16(iv->val, &i16); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = i16; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = i16; break; } case NEU_DTYPE_INT32: { int32_t i32 = 0; neu_dvalue_get_int32(iv->val, &i32); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = i32; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = i32; break; } case NEU_DTYPE_UINT32: { uint32_t u32 = 0; neu_dvalue_get_uint32(iv->val, &u32); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = u32; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = u32; break; } case NEU_DTYPE_INT64: { int64_t i64 = 0; neu_dvalue_get_int64(iv->val, &i64); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = i64; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = i64; break; } case NEU_DTYPE_UINT64: { uint64_t u64 = 0; neu_dvalue_get_uint64(iv->val, &u64); - api_res.tags[i - 1].t = NEU_JSON_INT; - api_res.tags[i - 1].value.val_int = u64; + api_res.tags[i].t = NEU_JSON_INT; + api_res.tags[i].value.val_int = u64; break; } case NEU_DTYPE_FLOAT: { float f32 = 0; neu_dvalue_get_float(iv->val, &f32); - api_res.tags[i - 1].t = NEU_JSON_FLOAT; - api_res.tags[i - 1].value.val_float = f32; + api_res.tags[i].t = NEU_JSON_FLOAT; + api_res.tags[i].value.val_float = f32; break; } case NEU_DTYPE_DOUBLE: { double d64 = 0; neu_dvalue_get_double(iv->val, &d64); - api_res.tags[i - 1].t = NEU_JSON_DOUBLE; - api_res.tags[i - 1].value.val_double = d64; + api_res.tags[i].t = NEU_JSON_DOUBLE; + api_res.tags[i].value.val_double = d64; break; } case NEU_DTYPE_CSTR: { char *cstr = NULL; neu_dvalue_get_ref_cstr(iv->val, &cstr); - api_res.tags[i - 1].t = NEU_JSON_STR; - api_res.tags[i - 1].value.val_str = cstr; + api_res.tags[i].t = NEU_JSON_STR; + api_res.tags[i].value.val_str = cstr; } default: break; @@ -330,7 +328,6 @@ void handle_write_resp(void *cmd_resp) neu_dvalue_get_ref_array(resp->data_val, &array); iv = (neu_int_val_t *) neu_fixed_array_get(array, 0); - assert(iv->key == 0); assert(neu_dvalue_get_value_type(iv->val) == NEU_DTYPE_ERRORCODE); neu_dvalue_get_errorcode(iv->val, &error); diff --git a/src/base/neu_tag.c b/src/base/neu_tag.c index e7b1512c..95acad0e 100644 --- a/src/base/neu_tag.c +++ b/src/base/neu_tag.c @@ -206,6 +206,10 @@ int neu_datatag_pack_add(neu_data_val_t *val, uint16_t index, neu_dtype_e type, tv = neu_dvalue_new(NEU_DTYPE_ERRORCODE); neu_dvalue_set_errorcode(tv, *(int32_t *) data); break; + case NEU_DTYPE_BIT: + tv = neu_dvalue_new(NEU_DTYPE_BIT); + neu_dvalue_set_bit(tv, *(uint8_t *) data); + break; case NEU_DTYPE_INT8: tv = neu_dvalue_new(NEU_DTYPE_INT8); neu_dvalue_set_int8(tv, *(int8_t *) data); diff --git a/src/parser/neu_json_rw.c b/src/parser/neu_json_rw.c index 9aa08c1d..3bf091b0 100644 --- a/src/parser/neu_json_rw.c +++ b/src/parser/neu_json_rw.c @@ -42,11 +42,17 @@ int neu_json_encode_read_resp(void *json_object, void *param) .t = p_tag->t, .v = p_tag->value, }, + { + .name = "error", + .t = NEU_JSON_INT, + .v.val_int = p_tag->error, + }, { .name = "id", .t = NEU_JSON_INT, .v.val_int = p_tag->id, } }; + tag_array = neu_json_encode_array(tag_array, tag_elems, NEU_JSON_ELEM_SIZE(tag_elems)); p_tag++; diff --git a/tests/json_rw_test.cc b/tests/json_rw_test.cc index 67a8c114..c0caf476 100644 --- a/tests/json_rw_test.cc +++ b/tests/json_rw_test.cc @@ -29,8 +29,9 @@ TEST(JsonAPITest, ReadReqDecode) TEST(JsonAPITest, ReadResEncode) { - char *buf = (char *) "{\"tags\": [{\"value\": 123, \"id\": 1}, {\"value\": " - "11.123456789, \"id\": 2}]}"; + char *buf = + (char *) "{\"tags\": [{\"value\": 123, \"error\": 0, \"id\": 1}, " + "{\"value\": 11.123456789, \"error\": 0, \"id\": 2}]}"; char * result = NULL; neu_json_read_resp_t res = { .n_tag = 2,