Merge pull request #324 from fengzeroz/main

remove commented code
This commit is contained in:
fengzeroz
2022-03-14 10:27:25 +08:00
committed by GitHub
-165
View File
@@ -86,13 +86,11 @@ static const char *const manager_url = "inproc://neu_manager";
// definition for plugin lib names
#if defined(__APPLE__)
#define WEBSERVER_PLUGIN_LIB_NAME "libplugin-webserver-proxy.dylib"
#define MQTT_PLUGIN_LIB_NAME "libplugin-mqtt.dylib"
#define MODBUS_TCP_PLUGIN_LIB_NAME "libplugin-modbus-tcp.dylib"
#else
#define WEBSERVER_PLUGIN_LIB_NAME "libplugin-webserver-proxy.so"
#define MQTT_PLUGIN_LIB_NAME "libplugin-mqtt.so"
#define MODBUS_TCP_PLUGIN_LIB_NAME "libplugin-modbus-tcp.so"
@@ -731,23 +729,6 @@ static int sub_grp_config_with_pipe(neu_taggrp_config_t *grp_config,
return sub_pipes->size == 1 ? 1 : 0;
}
// static int sub_grp_config_with_adapter(neu_manager_t * manager,
// neu_taggrp_config_t * grp_config,
// adapter_reg_entity_t *reg_entity)
//{
// manager_bind_info_t *bind_info;
// bind_info = &manager->bind_info;
// nng_mtx_lock(bind_info->mtx);
//// wait manager bind the adapter
// while (reg_entity->bind_count == 0) {
// nng_cv_wait(reg_entity->cv);
//}
// nng_mtx_unlock(bind_info->mtx);
// return sub_grp_config_with_pipe(grp_config, reg_entity->adapter_pipe);
//}
static int unsub_grp_config_with_pipe(neu_taggrp_config_t *grp_config,
nng_pipe sub_pipe)
{
@@ -771,23 +752,6 @@ static int unsub_grp_config_with_pipe(neu_taggrp_config_t *grp_config,
return sub_pipes->size == 0 ? 1 : 0;
}
// static int unsub_grp_config_with_adapter(neu_manager_t * manager,
// neu_taggrp_config_t * grp_config,
// adapter_reg_entity_t *reg_entity)
//{
// manager_bind_info_t *bind_info;
// bind_info = &manager->bind_info;
// nng_mtx_lock(bind_info->mtx);
//// wait manager bind the adapter
// while (reg_entity->bind_count == 0) {
// nng_cv_wait(reg_entity->cv);
//}
// nng_mtx_unlock(bind_info->mtx);
// return unsub_grp_config_with_pipe(grp_config, reg_entity->adapter_pipe);
//}
static int add_grp_config_to_adapter(adapter_reg_entity_t *reg_entity,
neu_taggrp_config_t * grp_config)
{
@@ -804,116 +768,6 @@ static int add_grp_config_to_adapter(adapter_reg_entity_t *reg_entity,
return rv;
}
/*
static int manager_add_config_by_name(neu_manager_t * manager,
config_add_cmd_t *cmd)
{
int rv = 0;
adapter_reg_entity_t *reg_entity;
nng_mtx_lock(manager->adapters_mtx);
reg_entity =
find_reg_adapter_by_name(&manager->reg_adapters, cmd->src_adapter_name);
if (reg_entity == NULL) {
log_error("Can't find matched src registered adapter");
rv = -1;
goto add_config_by_name_exit;
}
rv = add_grp_config_to_adapter(reg_entity, cmd->grp_config);
add_config_by_name_exit:
nng_mtx_unlock(manager->adapters_mtx);
return rv;
}
*/
// static void add_default_grp_configs(neu_manager_t *manager)
//{
// uint32_t i;
// config_add_cmd_t * config_add_cmd;
// neu_taggrp_config_t * grp_config;
// adapter_reg_entity_t *src_reg_entity;
// adapter_reg_entity_t *sub_reg_entity;
// size_t msg_size;
// nng_msg *out_msg;
// int need_send;
// int rv;
// for (i = 0; i < DEFAULT_GROUP_CONFIG_COUNT; i++) {
// config_add_cmd = &default_config_add_cmds[i];
// grp_config = neu_taggrp_cfg_new(config_add_cmd->config_name);
// neu_taggrp_cfg_set_interval(grp_config, config_add_cmd->read_interval);
// config_add_cmd->grp_config = grp_config;
// src_reg_entity = find_reg_adapter_by_name(
//&manager->reg_adapters, config_add_cmd->src_adapter_name);
// sub_reg_entity = find_reg_adapter_by_name(
//&manager->reg_adapters, config_add_cmd->sub_adapter_name);
// add_grp_config_to_adapter(src_reg_entity, grp_config);
// neu_adapter_add_sub_grp_config(sub_reg_entity->adapter,
// neu_manager_adapter_id_to_node_id(
// manager, src_reg_entity->adapter_id),
// grp_config);
// need_send =
// sub_grp_config_with_adapter(manager, grp_config, sub_reg_entity);
///* Send the subscribe node message to driver
//*/
// msg_size = msg_inplace_data_get_size(sizeof(subscribe_node_cmd_t));
// rv = nng_msg_alloc(&out_msg, msg_size);
// if (rv == 0 && need_send == 1) {
// message_t * msg_ptr;
// subscribe_node_cmd_t *out_cmd_ptr;
// msg_ptr = (message_t *) nng_msg_body(out_msg);
// msg_inplace_data_init(msg_ptr, MSG_CMD_SUBSCRIBE_NODE,
// sizeof(subscribe_node_cmd_t));
// out_cmd_ptr = msg_get_buf_ptr(msg_ptr);
// out_cmd_ptr->grp_config = grp_config;
// out_cmd_ptr->sender_id = 0;
// out_cmd_ptr->dst_node_id = neu_manager_adapter_id_to_node_id(
// manager, src_reg_entity->adapter_id);
// nng_msg_set_pipe(out_msg, src_reg_entity->adapter_pipe);
// log_info("Send subscribe driver command to driver pipe: %d",
// src_reg_entity->adapter_pipe);
// nng_sendmsg(manager->bind_info.mng_sock, out_msg, 0);
//}
//}
// return;
//}
// static void remove_default_grp_configs(neu_manager_t *manager)
//{
// uint32_t i;
// config_add_cmd_t * config_add_cmd;
// neu_taggrp_config_t * grp_config;
// adapter_reg_entity_t *src_reg_entity;
// adapter_reg_entity_t *sub_reg_entity;
// for (i = 0; i < DEFAULT_GROUP_CONFIG_COUNT; i++) {
// config_add_cmd = &default_config_add_cmds[i];
// grp_config = config_add_cmd->grp_config;
// nng_mtx_lock(manager->adapters_mtx);
// src_reg_entity = find_reg_adapter_by_name(
//&manager->reg_adapters, config_add_cmd->src_adapter_name);
// sub_reg_entity = find_reg_adapter_by_name(
//&manager->reg_adapters, config_add_cmd->sub_adapter_name);
// neu_adapter_del_sub_grp_config(sub_reg_entity->adapter,
// neu_manager_adapter_id_to_node_id(
// manager, src_reg_entity->adapter_id),
// grp_config);
// unsub_grp_config_with_adapter(manager, grp_config, sub_reg_entity);
// neu_datatag_mng_del_grp_config(src_reg_entity->datatag_manager,
// config_add_cmd->config_name);
// nng_mtx_unlock(manager->adapters_mtx);
///* The neuron manager should be shutdown, so there is no need to
//* send the unsubscribe node message to driver.
//*/
//}
// return;
//}
static int dispatch_databuf_to_adapters(neu_manager_t * manager,
neuron_trans_data_t *neu_trans_data)
{
@@ -922,25 +776,6 @@ static int dispatch_databuf_to_adapters(neu_manager_t * manager,
manager_bind_info_t *manager_bind = &manager->bind_info;
assert(neu_trans_data->grp_config != NULL);
// if (neu_trans_data->grp_config == NULL) {
// nng_pipe msg_pipe;
// adapter_reg_entity_t *reg_entity;
// sub_pipes = vector_new(DEFAULT_ADAPTER_REG_COUNT, sizeof(nng_pipe));
// nng_mtx_lock(manager->adapters_mtx);
// reg_entity = find_reg_adapter_by_name(&manager->reg_adapters,
// SAMPLE_APP_ADAPTER_NAME);
// msg_pipe = reg_entity->adapter_pipe;
// vector_push_back(sub_pipes, &msg_pipe);
// reg_entity =
// find_reg_adapter_by_name(&manager->reg_adapters, MQTT_ADAPTER_NAME);
// msg_pipe = reg_entity->adapter_pipe;
// vector_push_back(sub_pipes, &msg_pipe);
// nng_mtx_unlock(manager->adapters_mtx);
//} else {
//}
sub_pipes =
(vector_t *) neu_taggrp_cfg_ref_subpipes(neu_trans_data->grp_config);