сделал чтение настроек, удалил пару рудиментов

This commit is contained in:
2024-11-07 13:59:20 +03:00
parent eaee827261
commit 4a293e10f6
7 changed files with 283 additions and 85 deletions

View File

@@ -6,6 +6,46 @@ std::shared_mutex mtx;
TSID sid_counter { 0 };
std::map<TSID, std::unique_ptr<system_client>> clients;
EXTERNC CP_Result CP_SetBUC_LNB_settings(TSID sid, buc_lnb_settings &settings){
std::shared_lock lock(mtx);
try
{
if (clients.find(sid) == clients.end())
return ERROR;
auto settings_ = reinterpret_cast<buc_lnb_settings_com&>(settings);
auto resp = clients[sid]->send_set_buc_lnb_settings(settings_);
if (resp == response_type::error)
return ERROR;
return OK;
}
catch(const std::exception& e)
{
return ERROR;
}
}
EXTERNC CP_Result CP_GetBUC_LNB_settings(TSID sid, buc_lnb_settings &settings){
std::shared_lock lock(mtx);
try
{
if (clients.find(sid) == clients.end())
return ERROR;
buc_lnb_settings_com settings_com;
auto resp = clients[sid]->send_get_buc_lnb_settings(settings_com);
if (resp == response_type::error)
return ERROR;
settings = reinterpret_cast<buc_lnb_settings&>(settings_com);
return OK;
}
catch(const std::exception& e)
{
return ERROR;
}
}
EXTERNC CP_Result CP_SetModulatorSettings(TSID sid, modulator_settings& settings){
std::shared_lock lock(mtx);
try

View File

@@ -337,6 +337,17 @@ void system_client::data_received(const std::vector<uint8_t> & data)
break;
}
case cmd_type::get_lnb_buc_settings:
{
if(cmd.rsp == response_type::ok)
{
cmd_lnb_buc_settings value;
iarchive(value);
data_from_serv = value;
}
break;
}
case cmd_type::get_demodulator_settings:
{
if(cmd.rsp == response_type::ok)
@@ -801,7 +812,6 @@ response_type system_client::send_get_demodulator_settings(demodulator_settings_
cmd_header cmd_dpdi_header{curr_id, cmd_type::get_demodulator_settings};
cmd_demodulator_settings demodulator;
send_to_socket(cmd_dpdi_header, demodulator);
std::cout << "END GET_DEMODULATOR SETTINGS SEND TO SOCKET" << std::endl;
std::any data_from_serv;
auto result = wait_for_response(curr_id, cmd_type::get_demodulator_settings, data_from_serv);
@@ -841,6 +851,39 @@ response_type system_client::send_get_modulator_state(modulator_state_com &modul
return result;
}
response_type system_client::send_set_buc_lnb_settings(buc_lnb_settings_com &settings){
std::scoped_lock lock(cmd_in_progress_mtx);
uint32_t curr_id { ++cmd_id };
cmd_header cmd_acm_header{curr_id, cmd_type::set_lnb_buc_settings};
cmd_lnb_buc_settings settings_;
settings_.buc_lnb = settings;
send_to_socket(cmd_acm_header, settings_);
std::any data_to_serv;
auto result = wait_for_response(curr_id, cmd_type::set_lnb_buc_settings, data_to_serv);
return result;
}
response_type system_client::send_get_buc_lnb_settings(buc_lnb_settings_com &settings){
std::scoped_lock lock(cmd_in_progress_mtx);
uint32_t curr_id { ++cmd_id };
cmd_header cmd_buc_lnb_header{curr_id, cmd_type::get_lnb_buc_settings};
cmd_lnb_buc_settings lnb_buc;
send_to_socket(cmd_buc_lnb_header, lnb_buc);
std::any data_from_serv;
auto result = wait_for_response(curr_id, cmd_type::get_lnb_buc_settings, data_from_serv);
if (data_from_serv.has_value())
settings = std::any_cast<cmd_lnb_buc_settings>(data_from_serv).buc_lnb;
return result;
}
response_type system_client::send_get_device_state(device_state_com &device_state ){
std::scoped_lock lock(cmd_in_progress_mtx);
uint32_t curr_id { ++cmd_id };

View File

@@ -59,6 +59,8 @@ public:
response_type send_get_modulator_settings(modulator_settings_com &settings);
response_type send_get_demodulator_settings(demodulator_settings_com &settings);
response_type send_set_buc_lnb_settings(buc_lnb_settings_com &settings);
response_type send_get_buc_lnb_settings(buc_lnb_settings_com &settings);
response_type send_set_dpdi_params(dpdi_parameters &dpdi_params);
response_type send_get_dpdi_params(dpdi_parameters &dpdi_params);