добавил изменение параметров dpdi (CinC)
This commit is contained in:
55
src/main.cpp
55
src/main.cpp
@@ -267,6 +267,61 @@ public:
|
||||
}
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/cinc", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.clear();
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
|
||||
try {
|
||||
std::stringstream ss;
|
||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
||||
boost::property_tree::ptree pt;
|
||||
read_json(ss, pt);
|
||||
|
||||
api->setCincSettings(pt);
|
||||
|
||||
std::string result = R"({"status":"ok","settings":)";
|
||||
result += api->loadSettings();
|
||||
result += "}";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
} catch (std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/cinc): Can't set CinC settings: " << e.what();
|
||||
const std::string result = R"({"status":"error"})";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/rxtx", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.clear();
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
|
||||
try {
|
||||
std::stringstream ss;
|
||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
||||
boost::property_tree::ptree pt;
|
||||
read_json(ss, pt);
|
||||
|
||||
api->setRxTxSettings(pt);
|
||||
|
||||
std::string result = R"({"status":"ok","settings":)";
|
||||
result += api->loadSettings();
|
||||
result += "}";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
} catch (std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/rxtx): Can't set RX/TX settings: " << e.what();
|
||||
const std::string result = R"({"status":"error"})";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
~ServerResources() = default;
|
||||
|
@@ -208,10 +208,24 @@ public:
|
||||
json = this->qosClassesJson;
|
||||
}
|
||||
|
||||
void setStrringsRxTx(bool readback = true) {}
|
||||
void setStrringsCinc(bool readback = true) {}
|
||||
void setSettingsRxTx(bool readback = true) {}
|
||||
|
||||
void setStrringsBucLnb(const buc_lnb_settings& bucLnb, bool readback = true) {
|
||||
void setSettingsCinc(const DPDI_parmeters& s, bool readback = true) {
|
||||
DPDI_parmeters tmp = s;
|
||||
std::lock_guard lock(this->cpApiMutex);
|
||||
CP_SetDmaDebug(sid, "begin_save_config", "");
|
||||
CP_SetDpdiParams(sid, tmp);
|
||||
if (readback) {
|
||||
CP_GetDpdiParams(this->sid, &tmp);
|
||||
{
|
||||
std::lock_guard lock2{this->settingsMutex};
|
||||
this->dpdiSettings = tmp;
|
||||
}
|
||||
}
|
||||
CP_SetDmaDebug(sid, "save_config", "");
|
||||
}
|
||||
|
||||
void setSettingsBucLnb(const buc_lnb_settings& bucLnb, bool readback = true) {
|
||||
buc_lnb_settings tmp = bucLnb;
|
||||
std::lock_guard lock(this->cpApiMutex);
|
||||
CP_SetDmaDebug(sid, "begin_save_config", "");
|
||||
@@ -505,6 +519,32 @@ void api_driver::ApiDriver::setRxTxSettings(boost::property_tree::ptree &pt) {
|
||||
}
|
||||
|
||||
void api_driver::ApiDriver::setCincSettings(boost::property_tree::ptree &pt) {
|
||||
DPDI_parmeters s{};
|
||||
|
||||
//result << ",\n\"cinc.mode\":" << (dpdiSettings.is_delay_window ? "\"delay\"" : "\"positional\"");
|
||||
auto tmp = pt.get<std::string>(json_path("cinc.mode", '/'));
|
||||
if (tmp == "delay") { s.is_delay_window = true; }
|
||||
else if (tmp == "positional") { s.is_delay_window = false; }
|
||||
else {
|
||||
throw std::runtime_error("Wrong CinC mode: " + tmp);
|
||||
}
|
||||
|
||||
auto ctmp = translateCoordinates(pt.get<double>(json_path("cinc.position.station.latitude", '/')));
|
||||
s.latitude_station_grad = std::get<0>(ctmp);
|
||||
s.latitude_station_minute = std::get<1>(ctmp);
|
||||
|
||||
ctmp = translateCoordinates(pt.get<double>(json_path("cinc.position.station.longitude", '/')));
|
||||
s.longitude_station_grad = std::get<0>(ctmp);
|
||||
s.longitude_station_minute = std::get<1>(ctmp);
|
||||
|
||||
ctmp = translateCoordinates(pt.get<double>(json_path("cinc.position.satelliteLongitude", '/')));
|
||||
s.longitude_sattelite_grad = std::get<0>(ctmp);
|
||||
s.longitude_sattelite_minute = std::get<1>(ctmp);
|
||||
|
||||
s.max_delay = pt.get<int>(json_path("cinc.delayMax", '/'));
|
||||
s.min_delay = pt.get<int>(json_path("cinc.delayMin", '/'));
|
||||
|
||||
this->daemon->setSettingsCinc(s);
|
||||
}
|
||||
|
||||
void api_driver::ApiDriver::setBucLnbSettings(boost::property_tree::ptree &pt) {
|
||||
@@ -536,7 +576,7 @@ void api_driver::ApiDriver::setBucLnbSettings(boost::property_tree::ptree &pt) {
|
||||
s.is_ref_10MHz_output = pt.get<bool>(json_path("serviceSettings.refClk10M", '/'));
|
||||
s.is_save_current_state = pt.get<bool>(json_path("serviceSettings.autoStart", '/'));
|
||||
|
||||
this->daemon->setStrringsBucLnb(s);
|
||||
this->daemon->setSettingsBucLnb(s);
|
||||
}
|
||||
|
||||
void api_driver::ApiDriver::setQosSettings(boost::property_tree::ptree &pt) {
|
||||
|
Reference in New Issue
Block a user