Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/neuron/json/neu_json_scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef struct {
char *node;
char *id;
char *ctx;
int load_index;
} neu_json_scan_tags_req_t;

int neu_json_decode_scan_tags_req(char *buf, neu_json_scan_tags_req_t **result);
Expand Down
3 changes: 3 additions & 0 deletions include/neuron/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ typedef struct neu_req_scan_tags {
char driver[NEU_NODE_NAME_LEN];
char id[NEU_TAG_ADDRESS_LEN];
char ctx[NEU_VALUE_SIZE];
int load_index;
} neu_req_scan_tags_t;

typedef struct {
Expand All @@ -1722,6 +1723,8 @@ typedef struct {
neu_type_e type;
bool is_array;
char ctx[NEU_VALUE_SIZE];
int load_index;
int c_flag;
} neu_resp_scan_tags_t;

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion include/neuron/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ typedef struct neu_plugin_intf_funs {
int n_tag); // create tags by API
int (*del_tags)(neu_plugin_t *plugin, int n_tag);
int (*scan_tags)(neu_plugin_t *plugin, void *req, char *id,
char *ctx);
char *ctx, int load_index);
int (*test_read_tag)(neu_plugin_t *plugin, void *req,
neu_datatag_t tag);
int (*action)(neu_plugin_t *plugin, const char *action);
Expand Down
4 changes: 3 additions & 1 deletion plugins/restful/scan_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ void handle_scan_tags(nng_aio *aio)
strcpy(cmd.ctx, req->ctx);
}

cmd.load_index = req->load_index;

if (0 != neu_plugin_op(plugin, header, &cmd)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
Expand All @@ -73,6 +75,6 @@ void handle_scan_tags_resp(nng_aio *aio, neu_resp_scan_tags_t *resp)
{
char *result = NULL;
neu_json_encode_by_fn(resp, neu_json_encode_scan_tags_resp, &result);
neu_http_ok(aio, result);
neu_http_response(aio, resp->error, result);
free(result);
}
4 changes: 2 additions & 2 deletions src/adapter/driver/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -3394,8 +3394,8 @@ void neu_adapter_driver_scan_tags(neu_adapter_driver_t *driver,
}

neu_req_scan_tags_t *cmd = (neu_req_scan_tags_t *) &req[1];
driver->adapter.module->intf_funs->driver.scan_tags(driver->adapter.plugin,
req, cmd->id, cmd->ctx);
driver->adapter.module->intf_funs->driver.scan_tags(
driver->adapter.plugin, req, cmd->id, cmd->ctx, cmd->load_index);
}

void neu_adapter_driver_test_read_tag(neu_adapter_driver_t *driver,
Expand Down
29 changes: 25 additions & 4 deletions src/parser/neu_json_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ int neu_json_decode_scan_tags_req(char *buf, neu_json_scan_tags_req_t **result)
},
};

neu_json_elem_t req_load_index_elems[] = {
{
.name = "load_index",
.t = NEU_JSON_INT,
},
};

if (0 !=
neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_node_elems),
req_node_elems)) {
Expand All @@ -78,10 +85,14 @@ int neu_json_decode_scan_tags_req(char *buf, neu_json_scan_tags_req_t **result)
neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_ctx_elems),
req_ctx_elems);

req->node = req_node_elems[0].v.val_str;
req->id = req_id_elems[0].v.val_str;
req->ctx = req_ctx_elems[0].v.val_str;
*result = req;
neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_load_index_elems),
req_load_index_elems);

req->node = req_node_elems[0].v.val_str;
req->id = req_id_elems[0].v.val_str;
req->ctx = req_ctx_elems[0].v.val_str;
req->load_index = req_load_index_elems[0].v.val_int;
*result = req;

neu_json_decode_free(json_obj);
return 0;
Expand Down Expand Up @@ -164,6 +175,16 @@ int neu_json_encode_scan_tags_resp(void *json_object, void *param)
.t = NEU_JSON_STR,
.v.val_str = resp->ctx,
},
{
.name = "load_index",
.t = NEU_JSON_INT,
.v.val_int = resp->load_index,
},
{
.name = "completed",
.t = NEU_JSON_INT,
.v.val_int = resp->c_flag,
},
{
.name = "tags",
.t = NEU_JSON_OBJECT,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ int neu_http_response(nng_aio *aio, neu_err_code_e code, char *content)
case NEU_ERR_NODE_SETTING_NOT_FOUND:
case NEU_ERR_PLUGIN_READ_FAILURE:
case NEU_ERR_PLUGIN_WRITE_FAILURE:
case NEU_ERR_PLUGIN_DISCONNECTED:
case NEU_ERR_PLUGIN_TAG_NOT_ALLOW_READ:
case NEU_ERR_PLUGIN_TAG_NOT_ALLOW_WRITE:
case NEU_ERR_LICENSE_EXPIRED:
Expand Down Expand Up @@ -343,6 +342,7 @@ int neu_http_response(nng_aio *aio, neu_err_code_e code, char *content)
case NEU_ERR_NODE_TAGS_TOO_MANY:
case NEU_ERR_NODE_TAGS_INVALID:
case NEU_ERR_NODE_TAGS_TOO_LONG:
case NEU_ERR_PLUGIN_DISCONNECTED:
status = NNG_HTTP_STATUS_BAD_REQUEST;
break;
case NEU_ERR_FILE_NOT_EXIST:
Expand Down
6 changes: 3 additions & 3 deletions tests/ft/neuron/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ def get_nodes_disable_auth(type):


@gen_check
def scan_tags(node, id, ctx=""):
return requests.post(url=config.BASE_URL + "/api/v2/scan/tags", headers={"Authorization": config.default_jwt}, json={"node": node, "id": id, "ctx": ctx})
def scan_tags(node, id, ctx="", load_index=0):
return requests.post(url=config.BASE_URL + "/api/v2/scan/tags", headers={"Authorization": config.default_jwt}, json={"node": node, "id": id, "ctx": ctx, "load_index": load_index})


def otel_start(host, port):
Expand Down Expand Up @@ -587,4 +587,4 @@ def simulator_export(jwt=config.default_jwt):

def simulator_list_tags(jwt=config.default_jwt):
return requests.get(url=config.BASE_URL + "/api/v2/simulator/tags",
headers={"Authorization": jwt})
headers={"Authorization": jwt})