feat(tag): set decimal

This commit is contained in:
fengzero
2022-08-12 02:44:38 +00:00
parent 961635d7af
commit 56a0ecdfff
11 changed files with 127 additions and 20 deletions
+21 -4
View File
@@ -82,6 +82,11 @@ int neu_json_decode_add_tags_req(char *buf, neu_json_add_tags_req_t **result)
.name = "address",
.t = NEU_JSON_STR,
},
{
.name = "decimal",
.t = NEU_JSON_DOUBLE,
.attribute = NEU_JSON_ATTRIBUTE_OPTIONAL,
},
{
.name = "precision",
.t = NEU_JSON_INT,
@@ -103,8 +108,9 @@ int neu_json_decode_add_tags_req(char *buf, neu_json_add_tags_req_t **result)
p_tag->name = tag_elems[1].v.val_str;
p_tag->attribute = tag_elems[2].v.val_int;
p_tag->address = tag_elems[3].v.val_str;
p_tag->precision = tag_elems[4].v.val_int;
p_tag->description = tag_elems[5].v.val_str;
p_tag->decimal = tag_elems[4].v.val_double;
p_tag->precision = tag_elems[5].v.val_int;
p_tag->description = tag_elems[6].v.val_str;
p_tag++;
}
@@ -281,6 +287,11 @@ int neu_json_encode_get_tags_resp(void *json_object, void *param)
.t = NEU_JSON_INT,
.v.val_int = p_tag->precision,
},
{
.name = "decimal",
.t = NEU_JSON_DOUBLE,
.v.val_double = p_tag->decimal,
},
{
.name = "address",
.t = NEU_JSON_STR,
@@ -363,6 +374,11 @@ int neu_json_decode_update_tags_req(char * buf,
.name = "address",
.t = NEU_JSON_STR,
},
{
.name = "decimal",
.t = NEU_JSON_DOUBLE,
.attribute = NEU_JSON_ATTRIBUTE_OPTIONAL,
},
{
.name = "precision",
.t = NEU_JSON_INT,
@@ -384,8 +400,9 @@ int neu_json_decode_update_tags_req(char * buf,
p_tag->name = tag_elems[1].v.val_str;
p_tag->attribute = tag_elems[2].v.val_int;
p_tag->address = tag_elems[3].v.val_str;
p_tag->precision = tag_elems[4].v.val_int;
p_tag->description = tag_elems[5].v.val_str;
p_tag->decimal = tag_elems[4].v.val_double;
p_tag->precision = tag_elems[5].v.val_int;
p_tag->description = tag_elems[6].v.val_str;
p_tag++;
}
+3
View File
@@ -38,6 +38,7 @@ typedef struct {
int64_t type;
int64_t attribute;
int64_t precision;
double decimal;
} neu_json_add_tags_req_tag_t;
typedef struct {
@@ -76,6 +77,7 @@ typedef struct {
int64_t type;
int64_t attribute;
int64_t precision;
double decimal;
} neu_json_get_tags_resp_tag_t;
typedef struct {
@@ -92,6 +94,7 @@ typedef struct {
int64_t type;
int64_t attribute;
int64_t precision;
double decimal;
} neu_json_update_tags_req_tag_t;
typedef struct {