куча изменений, но зато теперь сохраняются настройки QoS и есть алгоритм сохранения параметров в API
This commit is contained in:
37
dependencies/control_system/client/main.cpp
vendored
37
dependencies/control_system/client/main.cpp
vendored
@@ -6,6 +6,42 @@ std::shared_mutex mtx;
|
||||
TSID sid_counter { 0 };
|
||||
std::map<TSID, std::unique_ptr<system_client>> clients;
|
||||
|
||||
EXTERNC CP_Result CP_SetQoSSettings(TSID sid, const std::string &qos_settings_json, bool is_enable){
|
||||
std::shared_lock lock(mtx);
|
||||
try
|
||||
{
|
||||
if (clients.find(sid) == clients.end())
|
||||
return ERROR;
|
||||
auto resp = clients[sid]->send_set_qos_settings_json(qos_settings_json, is_enable);
|
||||
if (resp == response_type::error)
|
||||
return ERROR;
|
||||
return OK;
|
||||
}
|
||||
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
EXTERNC CP_Result CP_GetQoSSettings(TSID sid, std::string &qos_settings_json, bool &is_enable){
|
||||
std::shared_lock lock(mtx);
|
||||
try
|
||||
{
|
||||
if (clients.find(sid) == clients.end())
|
||||
return ERROR;
|
||||
|
||||
auto resp = clients[sid]->send_get_qos_settings_json(qos_settings_json, is_enable);
|
||||
if (resp == response_type::error)
|
||||
return ERROR;
|
||||
return OK;
|
||||
}
|
||||
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
EXTERNC CP_Result CP_SetBUC_LNB_settings(TSID sid, buc_lnb_settings &settings){
|
||||
std::shared_lock lock(mtx);
|
||||
@@ -25,6 +61,7 @@ EXTERNC CP_Result CP_SetBUC_LNB_settings(TSID sid, buc_lnb_settings &settings){
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
EXTERNC CP_Result CP_GetBUC_LNB_settings(TSID sid, buc_lnb_settings &settings){
|
||||
std::shared_lock lock(mtx);
|
||||
try
|
||||
|
@@ -433,6 +433,16 @@ void system_client::data_received(const std::vector<uint8_t> & data)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cmd_type::get_qos_settings_json:
|
||||
{
|
||||
if (cmd.rsp == response_type::ok)
|
||||
{
|
||||
cmd_qos_settings value;
|
||||
iarchive(value);
|
||||
data_from_serv = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -705,6 +715,40 @@ response_type system_client::send_get_qos_params(std::string &node, const name_c
|
||||
return result;
|
||||
}
|
||||
|
||||
response_type system_client::send_set_qos_settings_json(const std::string &json_string, bool is_enable){
|
||||
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||
uint32_t curr_id { ++cmd_id };
|
||||
cmd_header cmd_qos_header{curr_id, cmd_type::set_qos_settings_json};
|
||||
cmd_qos_settings qos_settings{json_string, is_enable};
|
||||
|
||||
send_to_socket(cmd_qos_header, qos_settings);
|
||||
|
||||
std::any data_to_serv;
|
||||
|
||||
auto result = wait_for_response(curr_id, cmd_type::set_qos_settings, data_to_serv);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
response_type system_client::send_get_qos_settings_json(std::string &json_string, bool &is_enable){
|
||||
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||
uint32_t curr_id { ++cmd_id };
|
||||
cmd_header cmd_qos_header{curr_id, cmd_type::get_qos_settings_json};
|
||||
cmd_qos_settings qos_settings{json_string, is_enable};
|
||||
|
||||
send_to_socket(cmd_qos_header, qos_settings);
|
||||
|
||||
std::any data_from_serv;
|
||||
|
||||
auto result = wait_for_response(curr_id, cmd_type::get_qos_settings_json, data_from_serv);
|
||||
if (data_from_serv.has_value())
|
||||
{
|
||||
json_string = std::any_cast<cmd_qos_settings>(data_from_serv).json_string;
|
||||
is_enable = std::any_cast<cmd_qos_settings>(data_from_serv).is_enable;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
response_type system_client::send_set_10g_config(const cmd_10g_config & _10g_config, std::string &value)
|
||||
{
|
||||
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||
|
@@ -70,6 +70,8 @@ public:
|
||||
response_type send_set_qos_params(const std::string &node, const name_classes_qos & class_qos);
|
||||
response_type send_get_qos_params(std::string &node, const name_classes_qos & class_qos);
|
||||
|
||||
response_type send_set_qos_settings_json(const std::string &json_string, bool is_enable);
|
||||
response_type send_get_qos_settings_json(std::string &json_string, bool &is_enable);
|
||||
|
||||
void set_stdout_callback(std::function<void(const char *, uint32_t)> cb);
|
||||
void abort();
|
||||
|
Reference in New Issue
Block a user