int32_t vrs_send_tag_create(const uint8_t session_id, const uint8_t prio, const uint32_t node_id, const uint16_t taggroup_id, const uint8_t data_type, const uint8_t count, const uint16_t type) { struct Generic_Cmd *tag_create_cmd = v_tag_create_create(node_id, taggroup_id, -1, data_type, count, type); return vc_send_command(session_id, prio, tag_create_cmd); }
/** * \brief This function add TagCreate command to the queue of the session */ int vs_tag_send_create(struct VSEntitySubscriber *tg_subscriber, struct VSNode *node, struct VSTagGroup *tg, struct VSTag *tag) { struct Generic_Cmd *tag_create; struct VSEntityFollower *tag_follower; /* Check if this tag is in created/creating state */ if(!(tag->state == ENTITY_CREATING || tag->state == ENTITY_CREATED)) { v_print_log(VRS_PRINT_DEBUG_MSG, "This tag: %d in node: %d and tg: %d, is in %d state\n", tag->id, node->id, tg->id, tag->state); return 0; } /* Check if this command, has not been already sent */ tag_follower = tag->tag_folls.first; while(tag_follower != NULL) { if(tag_follower->node_sub->session == tg_subscriber->node_sub->session) { return 0; } tag_follower = tag_follower->next; } /* Create new Tag_Create command */ tag_create = v_tag_create_create(node->id, tg->id, tag->id, tag->data_type, tag->count, tag->custom_type); /* Put command to the outgoing queue */ if(tag_create == NULL) { return 0; } if(v_out_queue_push_tail(tg_subscriber->node_sub->session->out_queue, 0, tg_subscriber->node_sub->prio, tag_create) == 0) { return -1; } else { tag_follower = (struct VSEntityFollower*)calloc(1, sizeof(struct VSEntityFollower)); tag_follower->node_sub = tg_subscriber->node_sub; tag_follower->state = ENTITY_CREATING; v_list_add_tail(&tag->tag_folls, tag_follower); return 1; } return 0; }