работает получение параметров от бекенда (проверено SCPC и TDMA)
This commit is contained in:
@@ -16,48 +16,48 @@ typedef boost::property_tree::ptree::path_type json_path;
|
||||
|
||||
static constexpr const char* DEFAULT_QOS_CLASSES = R"({"rt1":[],"rt2":[],"rt3":[],"cd":[]})";
|
||||
|
||||
static int calculateSubnetMask(const std::string& subnet_mask) {
|
||||
int mask = 0;
|
||||
std::istringstream iss(subnet_mask);
|
||||
std::string octet;
|
||||
while (std::getline(iss, octet, '.')) {
|
||||
int octet_value = std::stoi(octet);
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
if (octet_value & (1 << i)) {
|
||||
mask++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
// static int calculateSubnetMask(const std::string& subnet_mask) {
|
||||
// int mask = 0;
|
||||
// std::istringstream iss(subnet_mask);
|
||||
// std::string octet;
|
||||
// while (std::getline(iss, octet, '.')) {
|
||||
// int octet_value = std::stoi(octet);
|
||||
// for (int i = 7; i >= 0; i--) {
|
||||
// if (octet_value & (1 << i)) {
|
||||
// mask++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return mask;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Преобразует строку вида `1.2.3.4/24` в пару строк вида `1.2.3.4` `255.255.255.0`
|
||||
*/
|
||||
std::pair<std::string, std::string> splitIpAndMask(const std::string& input) {
|
||||
auto pos = input.find('/');
|
||||
if (pos == std::string::npos) {
|
||||
// Обработка ошибки: нет символа '/'
|
||||
throw std::runtime_error("address not contains mask");
|
||||
}
|
||||
std::string ip = input.substr(0, pos);
|
||||
const unsigned int mask_int = std::stoul(input.substr(pos + 1));
|
||||
|
||||
if (mask_int > 32) {
|
||||
throw std::runtime_error("invalid mask");
|
||||
}
|
||||
|
||||
std::string mask_binary = std::string(mask_int, '1') + std::string(32 - mask_int, '0');
|
||||
std::string mask_str;
|
||||
|
||||
for (unsigned int i = 0; i < 4; ++i) {
|
||||
std::string octet = mask_binary.substr(i * 8u, 8);
|
||||
int octet_value = std::stoi(octet, nullptr, 2);
|
||||
mask_str += std::to_string(octet_value) + (i < 3 ? "." : "");
|
||||
}
|
||||
|
||||
return std::make_pair(ip, mask_str);
|
||||
}
|
||||
// std::pair<std::string, std::string> splitIpAndMask(const std::string& input) {
|
||||
// auto pos = input.find('/');
|
||||
// if (pos == std::string::npos) {
|
||||
// // Обработка ошибки: нет символа '/'
|
||||
// throw std::runtime_error("address not contains mask");
|
||||
// }
|
||||
// std::string ip = input.substr(0, pos);
|
||||
// const unsigned int mask_int = std::stoul(input.substr(pos + 1));
|
||||
//
|
||||
// if (mask_int > 32) {
|
||||
// throw std::runtime_error("invalid mask");
|
||||
// }
|
||||
//
|
||||
// std::string mask_binary = std::string(mask_int, '1') + std::string(32 - mask_int, '0');
|
||||
// std::string mask_str;
|
||||
//
|
||||
// for (unsigned int i = 0; i < 4; ++i) {
|
||||
// std::string octet = mask_binary.substr(i * 8u, 8);
|
||||
// int octet_value = std::stoi(octet, nullptr, 2);
|
||||
// mask_str += std::to_string(octet_value) + (i < 3 ? "." : "");
|
||||
// }
|
||||
//
|
||||
// return std::make_pair(ip, mask_str);
|
||||
// }
|
||||
|
||||
static inline void rtrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
|
||||
@@ -67,7 +67,8 @@ static inline void rtrim(std::string &s) {
|
||||
|
||||
class TerminalNetworkSettings {
|
||||
public:
|
||||
std::string managementIp, managementGateway, mode, dataIp;
|
||||
std::string managementIp, managementGateway, dataIp;
|
||||
bool isL2 = true;
|
||||
unsigned int dataMtu = 1500;
|
||||
|
||||
TerminalNetworkSettings() = default;
|
||||
@@ -79,7 +80,7 @@ public:
|
||||
void loadDefaults() {
|
||||
managementIp = "0.0.0.0";
|
||||
managementGateway = "";
|
||||
mode = "l2";
|
||||
isL2 = true;
|
||||
dataIp = "0.0.0.0";
|
||||
dataMtu = 1500;
|
||||
}
|
||||
@@ -193,21 +194,22 @@ private:
|
||||
|
||||
void updateNetworkSettings() {
|
||||
TerminalNetworkSettings s;
|
||||
std::string tmp;
|
||||
|
||||
std::lock_guard lock(this->cpApiMutex);
|
||||
logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(addr)", CP_GetNetwork(sid, "addr", &tmp));
|
||||
s.managementIp = tmp + "/";
|
||||
tmp.clear(); logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(mask)", CP_GetNetwork(sid, "mask", &tmp));
|
||||
s.managementIp += std::to_string(calculateSubnetMask(tmp));
|
||||
tmp.clear(); logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(gateway)", CP_GetNetwork(sid, "gateway", &s.managementGateway)); s.managementGateway = tmp;
|
||||
tmp.clear(); logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(mode)", CP_GetNetwork(sid, "mode", &tmp));
|
||||
if (tmp == "tun") {
|
||||
s.mode = "l3";
|
||||
logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(addr)", CP_GetNetwork(sid, "addr", &s.managementIp));
|
||||
// s.managementIp = tmp + "/";
|
||||
// tmp.clear(); logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(mask)", CP_GetNetwork(sid, "mask", &tmp));
|
||||
// s.managementIp += std::to_string(calculateSubnetMask(tmp));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(gateway)", CP_GetNetwork(sid, "gateway", &s.managementGateway));
|
||||
std::string nm; logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(mode)", CP_GetNetwork(sid, "mode", &nm));
|
||||
if (nm == "tun") {
|
||||
s.isL2 = false;
|
||||
logCpApiError("api_driver::TerminalApiDaemon::updateNetworkSettings()->CP_GetNetwork(addr_data)", CP_GetNetwork(sid, "addr_data", &s.dataIp));
|
||||
s.dataIp += "/24";
|
||||
// s.dataIp += "/24";
|
||||
} else {
|
||||
s.mode = "l2";
|
||||
s.dataIp = "0.0.0.0/24";
|
||||
s.isL2 = true;
|
||||
// s.dataIp = "0.0.0.0/24";
|
||||
s.dataIp = "0.0.0.0";
|
||||
}
|
||||
s.dataMtu = 1500;
|
||||
|
||||
@@ -564,41 +566,39 @@ public:
|
||||
}
|
||||
|
||||
void setNetworkSettings(TerminalNetworkSettings& s, bool readback = true) {
|
||||
const auto mang = splitIpAndMask(s.managementIp);
|
||||
std::pair<std::string, std::string> data;
|
||||
bool isL2;
|
||||
if (s.mode == "l2") { isL2 = true; }
|
||||
else if (s.mode == "l3") { isL2 = false; data = splitIpAndMask(s.dataIp); }
|
||||
else { throw std::runtime_error("invalid mode"); }
|
||||
// const auto mang = splitIpAndMask();
|
||||
// std::pair<std::string, std::string> data;
|
||||
// if (!s.isL2) {
|
||||
// data = splitIpAndMask(s.dataIp);
|
||||
// }
|
||||
|
||||
std::lock_guard lock(this->cpApiMutex);
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetDmaDebug(begin_save_config)", CP_SetDmaDebug(sid, "begin_save_config", ""));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(mode)", CP_SetNetwork(sid, "mode", isL2 ? "tap" : "tun"));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(addr)", CP_SetNetwork(sid, "addr", mang.first.c_str()));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(mask)", CP_SetNetwork(sid, "mask", mang.second.c_str()));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(mode)", CP_SetNetwork(sid, "mode", s.isL2 ? "tap" : "tun"));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(addr)", CP_SetNetwork(sid, "addr", s.managementIp.c_str()));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(mask)", CP_SetNetwork(sid, "mask", "255.255.255.0"));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(gateway)", CP_SetNetwork(sid, "gateway", s.managementGateway.c_str()));
|
||||
if (!isL2) {
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(data_addr)", CP_SetNetwork(sid, "data_addr", data.first.c_str()));
|
||||
if (!s.isL2) {
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_SetNetwork(data_addr)", CP_SetNetwork(sid, "data_addr", s.dataIp.c_str()));
|
||||
// TODO маска не устанавливается, потому что в API этого нет
|
||||
}
|
||||
// TODO MTU не устанавливается, потому что в API этого нет
|
||||
|
||||
if (readback) {
|
||||
std::string tmp;
|
||||
s.loadDefaults();
|
||||
s.managementIp.clear();
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_GetNetwork(addr)", CP_GetNetwork(sid, "addr", &s.managementIp));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_GetNetwork(mask)", CP_GetNetwork(sid, "mask", &tmp));
|
||||
s.managementIp += "/";
|
||||
s.managementIp += std::to_string(calculateSubnetMask(tmp));
|
||||
// logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_GetNetwork(mask)", CP_GetNetwork(sid, "mask", &tmp));
|
||||
// s.managementIp += "/";
|
||||
// s.managementIp += std::to_string(calculateSubnetMask(tmp));
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_GetNetwork(gateway)", CP_GetNetwork(sid, "gateway", &s.managementGateway));
|
||||
tmp.clear(); logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_GetNetwork(mode)", CP_GetNetwork(sid, "mode", &tmp));
|
||||
if (tmp == "tun") {
|
||||
s.mode = "l3";
|
||||
std::string nm; logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_GetNetwork(mode)", CP_GetNetwork(sid, "mode", &nm));
|
||||
if (nm == "tun") {
|
||||
s.isL2 = false;
|
||||
logCpApiError("api_driver::TerminalApiDaemon::setNetworkSettings()->CP_GetNetwork(addr_data)", CP_GetNetwork(sid, "addr_data", &s.dataIp));
|
||||
} else {
|
||||
s.mode = "l2";
|
||||
s.dataIp = "0.0.0.0/24";
|
||||
s.isL2 = true;
|
||||
s.dataIp = "0.0.0.0";
|
||||
}
|
||||
s.dataMtu = 1500;
|
||||
{
|
||||
@@ -799,46 +799,59 @@ void api_driver::ApiDriver::resetPacketStatistics() const {
|
||||
this->daemon->resetPacketStatistics();
|
||||
}
|
||||
|
||||
static void generateModcode(std::ostream& out, const char* paramName, uint32_t modcod) {
|
||||
struct _modcodDef {const char* modulation; const char* speed;};
|
||||
const static _modcodDef defs[] = {
|
||||
{.modulation = "DUMMY", .speed = "0"},
|
||||
{.modulation = "QPSK", .speed = "1/4"},
|
||||
{.modulation = "QPSK", .speed = "1/3"},
|
||||
{.modulation = "QPSK", .speed = "2/5"},
|
||||
{.modulation = "QPSK", .speed = "1/2"},
|
||||
{.modulation = "QPSK", .speed = "3/5"},
|
||||
{.modulation = "QPSK", .speed = "2/3"},
|
||||
{.modulation = "QPSK", .speed = "3/4"},
|
||||
{.modulation = "QPSK", .speed = "4/5"},
|
||||
{.modulation = "QPSK", .speed = "5/6"},
|
||||
{.modulation = "QPSK", .speed = "8/9"},
|
||||
{.modulation = "QPSK", .speed = "9/10"},
|
||||
{.modulation = "8PSK", .speed = "3/5"},
|
||||
{.modulation = "8PSK", .speed = "2/3"},
|
||||
{.modulation = "8PSK", .speed = "3/4"},
|
||||
{.modulation = "8PSK", .speed = "5/6"},
|
||||
{.modulation = "8PSK", .speed = "8/9"},
|
||||
{.modulation = "8PSK", .speed = "9/10"},
|
||||
{.modulation = "16APSK", .speed = "2/3"},
|
||||
{.modulation = "16APSK", .speed = "3/4"},
|
||||
{.modulation = "16APSK", .speed = "4/5"},
|
||||
{.modulation = "16APSK", .speed = "5/6"},
|
||||
{.modulation = "16APSK", .speed = "8/9"},
|
||||
{.modulation = "16APSK", .speed = "9/10"},
|
||||
{.modulation = "32APSK", .speed = "3/4"},
|
||||
{.modulation = "32APSK", .speed = "4/5"},
|
||||
{.modulation = "32APSK", .speed = "5/6"},
|
||||
{.modulation = "32APSK", .speed = "8/9"},
|
||||
{.modulation = "32APSK", .speed = "9/10"},
|
||||
};
|
||||
const _modcodDef* d = defs;
|
||||
#ifdef MODEM_IS_SCPC
|
||||
struct ModcodDef_t {const char* modulation; const char* speed;};
|
||||
const static ModcodDef_t defs[] = {
|
||||
{.modulation = "DUMMY", .speed = "0"},
|
||||
{.modulation = "QPSK", .speed = "1/4"},
|
||||
{.modulation = "QPSK", .speed = "1/3"},
|
||||
{.modulation = "QPSK", .speed = "2/5"},
|
||||
{.modulation = "QPSK", .speed = "1/2"},
|
||||
{.modulation = "QPSK", .speed = "3/5"},
|
||||
{.modulation = "QPSK", .speed = "2/3"},
|
||||
{.modulation = "QPSK", .speed = "3/4"},
|
||||
{.modulation = "QPSK", .speed = "4/5"},
|
||||
{.modulation = "QPSK", .speed = "5/6"},
|
||||
{.modulation = "QPSK", .speed = "8/9"},
|
||||
{.modulation = "QPSK", .speed = "9/10"},
|
||||
{.modulation = "8PSK", .speed = "3/5"},
|
||||
{.modulation = "8PSK", .speed = "2/3"},
|
||||
{.modulation = "8PSK", .speed = "3/4"},
|
||||
{.modulation = "8PSK", .speed = "5/6"},
|
||||
{.modulation = "8PSK", .speed = "8/9"},
|
||||
{.modulation = "8PSK", .speed = "9/10"},
|
||||
{.modulation = "16APSK", .speed = "2/3"},
|
||||
{.modulation = "16APSK", .speed = "3/4"},
|
||||
{.modulation = "16APSK", .speed = "4/5"},
|
||||
{.modulation = "16APSK", .speed = "5/6"},
|
||||
{.modulation = "16APSK", .speed = "8/9"},
|
||||
{.modulation = "16APSK", .speed = "9/10"},
|
||||
{.modulation = "32APSK", .speed = "3/4"},
|
||||
{.modulation = "32APSK", .speed = "4/5"},
|
||||
{.modulation = "32APSK", .speed = "5/6"},
|
||||
{.modulation = "32APSK", .speed = "8/9"},
|
||||
{.modulation = "32APSK", .speed = "9/10"},
|
||||
};
|
||||
|
||||
static const char* extractModcodModulation(uint32_t modcod, bool defaultQpsk1_4 = true) {
|
||||
modcod >>= 2;
|
||||
const auto* d = defaultQpsk1_4 ? defs : defs + 1;
|
||||
if (modcod < 28) {
|
||||
d = defs + modcod;
|
||||
}
|
||||
|
||||
return d->modulation;
|
||||
}
|
||||
|
||||
static const char* extractModcodSpeed(uint32_t modcod, bool defaultQpsk1_4 = true) {
|
||||
modcod >>= 2;
|
||||
const auto* d = defaultQpsk1_4 ? defs : defs + 1;
|
||||
if (modcod < 28) {
|
||||
d = defs + modcod;
|
||||
}
|
||||
return d->speed;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string api_driver::ApiDriver::loadSettings() const {
|
||||
if (daemon == nullptr) {
|
||||
return R"({"error": "api daemon not started!"})";
|
||||
@@ -858,91 +871,92 @@ std::string api_driver::ApiDriver::loadSettings() const {
|
||||
daemon->getNetworkSettings(network);
|
||||
|
||||
std::stringstream result;
|
||||
result << "{\n\"txAutoStart\":" << boolAsStr(modSettings.is_save_current_state);
|
||||
#ifdef MODEM_IS_SCPC
|
||||
result << "{\n\"isCinC\":" << boolAsStr(modSettings.is_cinc);
|
||||
result << ",\"txEn\":" << boolAsStr(modSettings.tx_is_on);
|
||||
result << ",\"txModulatorIsTest\":" << boolAsStr(!modSettings.is_carrier);
|
||||
result << ",\"txAutoStart\":" << boolAsStr(modSettings.is_save_current_state);
|
||||
#endif
|
||||
result << ",\"txIsTestInput\":" << boolAsStr(modSettings.is_test_data);
|
||||
result << ",\n\"txAttenuation\":"; writeDouble(result, modSettings.attenuation);
|
||||
result << ",\"txRolloff\":" << static_cast<int>(modSettings.rollof * 100);
|
||||
result << ",\"txCentralFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz);
|
||||
result << ",\"txBaudrate\":" << modSettings.baudrate;
|
||||
result << ",\"txCentralFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz, 3);
|
||||
result << ",\"dvbs2.frameSizeNormal\":" << boolAsStr(!(modSettings.modcod_tx & 2));
|
||||
result << ",\"dvbs2.ccm_modcod\":" << (modSettings.modcod_tx >> 2);
|
||||
result << ",\"txRolloff\":" << static_cast<int>(modSettings.rollof * 100);
|
||||
#ifdef MODEM_IS_SCPC
|
||||
// result << ",\"txGoldan\":" << static_cast<int>(modSettings.qold_seq_is_active); // TODO обновить библиотеку
|
||||
#endif
|
||||
result << ",\"txAttenuation\":"; writeDouble(result, modSettings.attenuation);
|
||||
|
||||
// result << ",\"dvbs2.isPilots\":" << "null";
|
||||
result << ",\n\"dvbIsAcm\":" << boolAsStr(acmSettings.enable);
|
||||
result << ",\"dvbs2.acm_maxModcod\":" << (acmSettings.max_modcod >> 2);
|
||||
result << ",\"dvbs2.acm_minModcod\":" << (acmSettings.min_modcod >> 2);
|
||||
result << ",\"dvbs2.snrReserve\":"; writeDouble(result, acmSettings.snr_treashold_acm);
|
||||
result << ",\"dvbServicePacketPeriod\":" << acmSettings.period_pack;
|
||||
#ifdef MODEM_IS_SCPC
|
||||
result << ",\n\"isCinC\":" << boolAsStr(modSettings.is_cinc);
|
||||
result << ",\n\"dvbServicePacketPeriod\":" << acmSettings.period_pack;
|
||||
result << ",\"dvbIsAcm\":" << boolAsStr(acmSettings.enable);
|
||||
result << ",\"txFrameSizeNormal\":" << boolAsStr((modSettings.modcod_tx & 2) == 0);
|
||||
|
||||
result << ",\n\"acm.en\":" << boolAsStr(acmSettings.enable_auto_atten);
|
||||
result << ",\"acm.maxAttenuation\":"; writeDouble(result, acmSettings.max_attenuation);
|
||||
result << ",\"acm.minAttenuation\":"; writeDouble(result, acmSettings.min_attenuation);
|
||||
result << ",\"acm.requiredSnr\":"; writeDouble(result, acmSettings.snr_treashold);
|
||||
result << R"(,"dvbCcmModulation":")" << extractModcodModulation(modSettings.modcod_tx) << "\"";
|
||||
result << R"(,"dvbCcmSpeed":")" << extractModcodSpeed(modSettings.modcod_tx) << "\"";
|
||||
result << R"(,"dvbAcmMinModulation":")" << extractModcodModulation(acmSettings.min_modcod) << "\"";
|
||||
result << R"(,"dvbAcmMinSpeed":")" << extractModcodSpeed(acmSettings.min_modcod) << "\"";
|
||||
result << R"(,"dvbAcmMaxModulation":")" << extractModcodModulation(acmSettings.max_modcod) << "\"";
|
||||
result << R"(,"dvbAcmMaxSpeed":")" << extractModcodSpeed(acmSettings.max_modcod) << "\"";
|
||||
result << ",\"dvbSnrReserve\":"; writeDouble(result, acmSettings.snr_treashold_acm);
|
||||
|
||||
result << ",\n\"rx.gainMode\":" << (demodSettings.is_aru_on ? "\"auto\"" : "\"manual\"");
|
||||
result << ",\"rx.manualGain\":"; writeDouble(result, demodSettings.gain);
|
||||
result << ",\"rx.spectrumInversion\":" << boolAsStr(demodSettings.is_rvt_iq);
|
||||
result << ",\"rx.rolloff\":" << static_cast<int>(demodSettings.rollof * 100);
|
||||
result << ",\"rx.cymRate\":" << demodSettings.baudrate;
|
||||
result << ",\"rx.centerFreq\":"; writeDouble(result, demodSettings.central_freq_in_kGz);
|
||||
result << ",\n\"aupcEn\":" << boolAsStr(acmSettings.enable_auto_atten);
|
||||
result << ",\"aupcMinAttenuation\":"; writeDouble(result, acmSettings.min_attenuation);
|
||||
result << ",\"aupcMaxAttenuation\":"; writeDouble(result, acmSettings.max_attenuation);
|
||||
result << ",\"aupcRequiredSnr\":"; writeDouble(result, acmSettings.snr_treashold);
|
||||
|
||||
result << ",\n\"cinc.mode\":" << (dpdiSettings.is_delay_window ? "\"delay\"" : "\"positional\"");
|
||||
result << ",\"cinc.searchBandwidth\":" << dpdiSettings.freq_offset; // полоса поиска в кГц
|
||||
result << ",\"cinc.position.station.latitude\":"; writeDouble(result, translateCoordinates(dpdiSettings.latitude_station_grad, dpdiSettings.latitude_station_minute), 6);
|
||||
result << ",\"cinc.position.station.longitude\":"; writeDouble(result, translateCoordinates(dpdiSettings.longitude_station_grad, dpdiSettings.longitude_station_minute), 6);
|
||||
result << ",\"cinc.position.satelliteLongitude\":"; writeDouble(result, translateCoordinates(dpdiSettings.longitude_sattelite_grad, dpdiSettings.longitude_sattelite_minute), 6);
|
||||
result << ",\"cinc.delayMin\":" << dpdiSettings.min_delay;
|
||||
result << ",\"cinc.delayMax\":" << dpdiSettings.max_delay;
|
||||
#else
|
||||
result << "{\n\"tx.txEn\":" << boolAsStr(modSettings.tx_is_on);
|
||||
result << ",\"tx.isTestInputData\":" << boolAsStr(modSettings.is_test_data);
|
||||
result << ",\"tx.cymRate\":" << modSettings.baudrate;
|
||||
result << ",\"tx.centerFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz, 3);
|
||||
result << ",\"tx.attenuation\":"; writeDouble(result, modSettings.attenuation);
|
||||
|
||||
result << ",\n\"rx.gainMode\":" << (demodSettings.is_aru_on ? "\"auto\"" : "\"manual\"");
|
||||
result << ",\"rx.manualGain\":"; writeDouble(result, demodSettings.gain);
|
||||
result << ",\"rx.spectrumInversion\":" << boolAsStr(demodSettings.is_rvt_iq);
|
||||
result << ",\"rx.rolloff\":" << static_cast<int>(demodSettings.rollof * 100);
|
||||
result << ",\"rx.cymRate\":" << demodSettings.baudrate;
|
||||
result << ",\"rx.centerFreq\":"; writeDouble(result, demodSettings.central_freq_in_kGz);
|
||||
result << ",\n\"cincIsPositional\":" << boolAsStr(!dpdiSettings.is_delay_window);
|
||||
result << ",\"cincSearchBandwidth\":" << dpdiSettings.freq_offset; // полоса поиска в кГц
|
||||
result << ",\"cincPositionStationLatitude\":"; writeDouble(result, translateCoordinates(dpdiSettings.latitude_station_grad, dpdiSettings.latitude_station_minute), 6);
|
||||
result << ",\"cincPositionStationLongitude\":"; writeDouble(result, translateCoordinates(dpdiSettings.longitude_station_grad, dpdiSettings.longitude_station_minute), 6);
|
||||
result << ",\"cincPositionSatelliteLongitude\":"; writeDouble(result, translateCoordinates(dpdiSettings.longitude_sattelite_grad, dpdiSettings.longitude_sattelite_minute), 6);
|
||||
result << ",\"cincDelayMin\":" << dpdiSettings.min_delay;
|
||||
result << ",\"cincDelayMax\":" << dpdiSettings.max_delay;
|
||||
#endif
|
||||
|
||||
result << ",\n\"buc.refClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_buc);
|
||||
result << ",\n\"rxAgcEn\":" << boolAsStr(demodSettings.is_aru_on);
|
||||
result << ",\"rxSpectrumInversion\":" << boolAsStr(demodSettings.is_rvt_iq);
|
||||
result << ",\"rxManualGain\":"; writeDouble(result, demodSettings.gain);
|
||||
result << ",\"rxCentralFreq\":"; writeDouble(result, demodSettings.central_freq_in_kGz);
|
||||
result << ",\"rxBaudrate\":" << demodSettings.baudrate;
|
||||
result << ",\"rxRolloff\":" << static_cast<int>(demodSettings.rollof * 100);
|
||||
#ifdef MODEM_IS_SCPC
|
||||
// result << ",\"txGoldan\":" << static_cast<int>(demodSettings.qold_seq_is_active); // TODO обновить библиотеку
|
||||
#endif
|
||||
|
||||
// BUC LNB
|
||||
result << ",\n\"bucRefClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_buc);
|
||||
switch (bucLnb.buc) {
|
||||
case voltage_buc::_24V: result << ",\"buc.powering\":24"; break;
|
||||
case voltage_buc::_48V: result << ",\"buc.powering\":48"; break;
|
||||
case voltage_buc::_24V: result << ",\"bucPowering\":24"; break;
|
||||
#ifdef MODEM_IS_SCPC
|
||||
case voltage_buc::_48V: result << ",\"bucPowering\":48"; break;
|
||||
#endif
|
||||
case voltage_buc::DISABLE:
|
||||
default: result << ",\"buc.powering\":0";
|
||||
default: result << ",\"bucPowering\":0";
|
||||
}
|
||||
|
||||
result << ",\n\"lnb.refClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_lnb);
|
||||
result << ",\"lnbRefClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_lnb);
|
||||
switch (bucLnb.lnb) {
|
||||
case voltage_lnb::_13V: result << ",\"lnb.powering\":13"; break;
|
||||
case voltage_lnb::_18V: result << ",\"lnb.powering\":18"; break;
|
||||
case voltage_lnb::_24V: result << ",\"lnb.powering\":24"; break;
|
||||
case voltage_lnb::_13V: result << ",\"lnbPowering\":13"; break;
|
||||
case voltage_lnb::_18V: result << ",\"lnbPowering\":18"; break;
|
||||
case voltage_lnb::_24V: result << ",\"lnbPowering\":24"; break;
|
||||
case voltage_lnb::DISABLE:
|
||||
default: result << ",\"lnb.powering\":0";
|
||||
default: result << ",\"lnbPowering\":0";
|
||||
}
|
||||
|
||||
result << ",\n\"serviceSettings.refClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_output);
|
||||
result << ",\"serviceSettings.autoStart\":" << boolAsStr(bucLnb.is_save_current_state);
|
||||
result << ",\"srvRefClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_output);
|
||||
result << ",\"bucLnbAutoStart\":" << boolAsStr(bucLnb.is_save_current_state);
|
||||
|
||||
// QoS
|
||||
bool qosEnabled = false; std::string qosClasses;
|
||||
daemon->getQosSettings(qosEnabled, qosClasses);
|
||||
result << ",\n\"qos.enabled\":" << boolAsStr(qosEnabled);
|
||||
result << ",\"qos.profile\":" << qosClasses;
|
||||
result << ",\n\"qosEnabled\":" << boolAsStr(qosEnabled);
|
||||
result << ",\"qosProfile\":" << qosClasses;
|
||||
|
||||
// сеть
|
||||
result << ",\"network.managementIp\":\n" << buildEscapedString(network.managementIp);
|
||||
result << ",\"network.managementGateway\":\n" << buildEscapedString(network.managementGateway);
|
||||
result << ",\"network.mode\":\n" << buildEscapedString(network.mode);
|
||||
result << ",\"network.dataIp\":\n" << buildEscapedString(network.dataIp);
|
||||
result << ",\"network.dataMtu\":\n" << network.dataMtu;
|
||||
result << ",\"netManagementIp\":\n" << buildEscapedString(network.managementIp);
|
||||
result << ",\"netIsL2\":\n" << boolAsStr(network.isL2);
|
||||
result << ",\"netManagementGateway\":\n" << buildEscapedString(network.managementGateway);
|
||||
result << ",\"netDataIp\":\n" << buildEscapedString(network.dataIp);
|
||||
result << ",\"netDataMtu\":\n" << network.dataMtu;
|
||||
|
||||
result << "}";
|
||||
return result.str();
|
||||
@@ -969,11 +983,14 @@ void api_driver::ApiDriver::setRxTxSettings(boost::property_tree::ptree &pt) {
|
||||
demodulator_settings demod{};
|
||||
#ifdef MODEM_IS_SCPC
|
||||
ACM_parameters_serv_ acm{};
|
||||
daemon->getSettings(&mod, &demod, &acm, nullptr, nullptr);
|
||||
#else
|
||||
daemon->getSettings(&mod, &demod, nullptr);
|
||||
#endif
|
||||
|
||||
// для модулятора
|
||||
#ifdef MODEM_IS_SCPC
|
||||
mod.is_cinc = pt.get<bool>(json_path("general.isCinC", '/'));
|
||||
mod.is_cinc = pt.get<bool>("isCinC");
|
||||
mod.tx_is_on = pt.get<bool>(json_path("general.txEn", '/'));
|
||||
auto tmp = pt.get<std::string>(json_path("general.modulatorMode", '/'));
|
||||
if (tmp == "normal") { mod.is_carrier = true; }
|
||||
@@ -1109,7 +1126,7 @@ void api_driver::ApiDriver::setNetworkSettings(boost::property_tree::ptree &pt)
|
||||
TerminalNetworkSettings s;
|
||||
s.managementIp = pt.get<std::string>(json_path("network.managementIp", '/'));
|
||||
s.managementGateway = pt.get<std::string>(json_path("network.managementGateway", '/'));
|
||||
s.mode = pt.get<std::string>(json_path("network.mode", '/'));
|
||||
s.isL2 = pt.get<bool>(json_path("network.mode", '/'));
|
||||
s.dataIp = pt.get<std::string>(json_path("network.dataIp", '/'));
|
||||
s.dataMtu = pt.get<unsigned int>(json_path("network.dataMtu", '/'));
|
||||
|
||||
|
Reference in New Issue
Block a user