куча изменений, но зато теперь сохраняются настройки QoS и есть алгоритм сохранения параметров в API

This commit is contained in:
2024-11-11 17:35:25 +03:00
parent 435f215118
commit cb9d412c8e
10 changed files with 398 additions and 77 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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();

View File

@@ -390,7 +390,9 @@ enum class cmd_type
get_modulator_settings = 37,
get_demodulator_settings = 38,
set_lnb_buc_settings = 39,
get_lnb_buc_settings = 40
get_lnb_buc_settings = 40,
set_qos_settings_json = 41,
get_qos_settings_json = 42
};
struct cmd_lbq_params
@@ -565,7 +567,15 @@ struct cmd_get_acm_param
archive(enable, max_attenuation, max_modcod, min_attenuation, min_modcod, snr_treashold, enable_auto_atten, snr_treashold_acm, period_pack);
}
};
struct cmd_qos_settings{
std::string json_string;
bool is_enable;
template<class Archive>
void serialize(Archive & archive)
{
archive(json_string, is_enable);
}
};
struct cmd_set_qos_settings
{
std::string node;

View File

@@ -1,6 +1,7 @@
#ifndef __CONTROL_PROTO_COMMANDS__
#define __CONTROL_PROTO_COMMANDS__
#include <stdint.h>
#include <iostream>
#include <string>
@@ -175,6 +176,8 @@ struct buc_lnb_settings
EXTERNC CP_Result CP_SetBUC_LNB_settings(TSID sid, buc_lnb_settings &settings);
EXTERNC CP_Result CP_GetBUC_LNB_settings(TSID sid, buc_lnb_settings &settings);
EXTERNC CP_Result CP_SetQoSSettings(TSID sid, const std::string &qos_settings_json, bool is_enable);
EXTERNC CP_Result CP_GetQoSSettings(TSID sid, std::string &qos_settings_json, bool &is_enable);
EXTERNC CP_Result CP_GetModulatorParams(TSID sid, const char *modulator_param, uint32_t *value);