mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
Merge pull request #784 from fengzeroz/v2.2
update tag & negative multiplication
This commit is contained in:
+16
-16
@@ -72,15 +72,15 @@ Update tag, it should return success.
|
||||
${len} = Get Length ${res}[tags]
|
||||
Should Be Equal As Integers ${len} 2
|
||||
|
||||
Should Be Equal As Strings ${res}[tags][1][name] tag1
|
||||
Should Be Equal As Strings ${res}[tags][1][address] 1!400002
|
||||
Should Be Equal As Strings ${res}[tags][1][attribute] ${TAG_ATTRIBUTE_RW}
|
||||
Should Be Equal As Strings ${res}[tags][1][type] ${TAG_TYPE_INT32}
|
||||
|
||||
Should Be Equal As Strings ${res}[tags][0][name] tag2
|
||||
Should Be Equal As Strings ${res}[tags][0][address] 1!00001
|
||||
Should Be Equal As Strings ${res}[tags][0][name] tag1
|
||||
Should Be Equal As Strings ${res}[tags][0][address] 1!400002
|
||||
Should Be Equal As Strings ${res}[tags][0][attribute] ${TAG_ATTRIBUTE_RW}
|
||||
Should Be Equal As Strings ${res}[tags][0][type] ${TAG_TYPE_BIT}
|
||||
Should Be Equal As Strings ${res}[tags][0][type] ${TAG_TYPE_INT32}
|
||||
|
||||
Should Be Equal As Strings ${res}[tags][1][name] tag2
|
||||
Should Be Equal As Strings ${res}[tags][1][address] 1!00001
|
||||
Should Be Equal As Strings ${res}[tags][1][attribute] ${TAG_ATTRIBUTE_RW}
|
||||
Should Be Equal As Strings ${res}[tags][1][type] ${TAG_TYPE_BIT}
|
||||
|
||||
Delete tag from non-existent group, it should return success
|
||||
${res}= Del Tags modbus-node group1 "tag1"
|
||||
@@ -100,15 +100,15 @@ Update non-existent tag, it should return failure.
|
||||
${len} = Get Length ${res}[tags]
|
||||
Should Be Equal As Integers ${len} 2
|
||||
|
||||
Should Be Equal As Strings ${res}[tags][1][name] tag1
|
||||
Should Be Equal As Strings ${res}[tags][1][address] 1!400002
|
||||
Should Be Equal As Strings ${res}[tags][1][attribute] ${TAG_ATTRIBUTE_RW}
|
||||
Should Be Equal As Strings ${res}[tags][1][type] ${TAG_TYPE_INT32}
|
||||
|
||||
Should Be Equal As Strings ${res}[tags][0][name] tag2
|
||||
Should Be Equal As Strings ${res}[tags][0][address] 1!00001
|
||||
Should Be Equal As Strings ${res}[tags][0][name] tag1
|
||||
Should Be Equal As Strings ${res}[tags][0][address] 1!400002
|
||||
Should Be Equal As Strings ${res}[tags][0][attribute] ${TAG_ATTRIBUTE_RW}
|
||||
Should Be Equal As Strings ${res}[tags][0][type] ${TAG_TYPE_BIT}
|
||||
Should Be Equal As Strings ${res}[tags][0][type] ${TAG_TYPE_INT32}
|
||||
|
||||
Should Be Equal As Strings ${res}[tags][1][name] tag2
|
||||
Should Be Equal As Strings ${res}[tags][1][address] 1!00001
|
||||
Should Be Equal As Strings ${res}[tags][1][attribute] ${TAG_ATTRIBUTE_RW}
|
||||
Should Be Equal As Strings ${res}[tags][1][type] ${TAG_TYPE_BIT}
|
||||
|
||||
Delete tags, it should return success
|
||||
Del Tags modbus-node group "tag1","tag2"
|
||||
|
||||
@@ -862,21 +862,33 @@ static int read_report_group(int64_t timestamp, int64_t timeout,
|
||||
datas[index].value.type = NEU_TYPE_DOUBLE;
|
||||
switch (tag->type) {
|
||||
case NEU_TYPE_INT8:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i8 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT8:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u8 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_INT16:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i16 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT16:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u16 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_INT32:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i32 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT32:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u32 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_INT64:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i64 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT64:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u64 * tag->decimal;
|
||||
@@ -988,21 +1000,33 @@ static void read_group(int64_t timestamp, int64_t timeout,
|
||||
datas[index].value.type = NEU_TYPE_DOUBLE;
|
||||
switch (tag->type) {
|
||||
case NEU_TYPE_INT8:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i8 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT8:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u8 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_INT16:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i16 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT16:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u16 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_INT32:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i32 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT32:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u32 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_INT64:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.i64 * tag->decimal;
|
||||
break;
|
||||
case NEU_TYPE_UINT64:
|
||||
datas[index].value.value.d64 =
|
||||
(double) datas[index].value.value.u64 * tag->decimal;
|
||||
|
||||
+8
-17
@@ -142,28 +142,19 @@ int neu_group_update_tag(neu_group_t *group, neu_datatag_t *tag)
|
||||
|
||||
HASH_FIND_STR(group->tags, tag->name, el);
|
||||
if (el != NULL) {
|
||||
HASH_DEL(group->tags, el);
|
||||
free(el->name);
|
||||
free(el->tag->name);
|
||||
free(el->tag->address);
|
||||
free(el->tag->description);
|
||||
free(el->tag);
|
||||
free(el);
|
||||
el->tag->address = strdup(tag->address);
|
||||
|
||||
el = calloc(1, sizeof(tag_elem_t));
|
||||
el->name = strdup(tag->name);
|
||||
el->tag = calloc(1, sizeof(neu_datatag_t));
|
||||
el->tag->name = strdup(tag->name);
|
||||
el->tag->address = strdup(tag->address);
|
||||
free(el->tag->description);
|
||||
el->tag->description = strdup(tag->description);
|
||||
el->tag->type = tag->type;
|
||||
el->tag->attribute = tag->attribute;
|
||||
el->tag->precision = tag->precision;
|
||||
el->tag->decimal = tag->decimal;
|
||||
el->tag->option = tag->option;
|
||||
|
||||
el->tag->type = tag->type;
|
||||
el->tag->attribute = tag->attribute;
|
||||
el->tag->precision = tag->precision;
|
||||
el->tag->decimal = tag->decimal;
|
||||
el->tag->option = tag->option;
|
||||
memcpy(el->tag->meta, tag->meta, sizeof(tag->meta));
|
||||
|
||||
HASH_ADD_STR(group->tags, name, el);
|
||||
update_timestamp(group);
|
||||
ret = NEU_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user