исправил тестовое состояние, исправил логику работы TDMA-морды, мелкие исправления в именовании параметров
This commit is contained in:
parent
6464cda437
commit
8813488df8
@ -18,14 +18,10 @@
|
|||||||
{"widget": "h3", "label": "Настройки передатчика"},
|
{"widget": "h3", "label": "Настройки передатчика"},
|
||||||
{"widget": "checkbox", "label": "Включить передатчик", "name": "txEn"},
|
{"widget": "checkbox", "label": "Включить передатчик", "name": "txEn"},
|
||||||
{
|
{
|
||||||
"widget": "select", "label": "Входные данные", "name": "txIsTestInput",
|
"widget": "select", "label": "Режим работы модулятора", "name": "txModulatorIsTest",
|
||||||
"values": [
|
"values": [{"label": "Нормальный", "value": "false"}, {"label": "Тест (CW)", "value": "true"}]
|
||||||
{"label": "SCPC", "value": "false"},
|
|
||||||
{"label": "Тест", "value": "true"}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{"widget": "number", "label": "Центральная частота, КГц", "name": "txCentralFreq", "min": 900000, "step": 0.01, "v_show": "paramRxrx.txIsTestInput"},
|
{"widget": "number", "label": "Центральная частота, КГц", "name": "txCentralFreq", "min": 900000, "step": 0.01, "v_show": "paramRxtx.txModulatorIsTest"},
|
||||||
{"widget": "number", "label": "Символьная скорость, Бод", "name": "txBaudrate", "min": 0, "step": 1, "v_show": "paramRxrx.txIsTestInput"},
|
|
||||||
{"widget": "number", "label": "Ослабление, дБ", "name": "txAttenuation", "min": 0, "step": 1}
|
{"widget": "number", "label": "Ослабление, дБ", "name": "txAttenuation", "min": 0, "step": 1}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -30,10 +30,10 @@ http::auth::jwt::Jwt http::auth::jwt::Jwt::fromCookies(const std::string &cookie
|
|||||||
const auto auth = pc.at("auth");
|
const auto auth = pc.at("auth");
|
||||||
std::string::size_type firstDot = std::string::npos;
|
std::string::size_type firstDot = std::string::npos;
|
||||||
std::string::size_type secondDot = std::string::npos;
|
std::string::size_type secondDot = std::string::npos;
|
||||||
for (size_t i = 0; i < auth.size(); i++) {
|
for (std::string::size_type i = 0; i < auth.size(); i++) {
|
||||||
if (auth[i] == '.') {
|
if (auth[i] == '.') {
|
||||||
if (firstDot == std::string::npos) { firstDot = static_cast<int>(i); }
|
if (firstDot == std::string::npos) { firstDot = i; }
|
||||||
else if (secondDot == std::string::npos) { secondDot = static_cast<int>(i); }
|
else if (secondDot == std::string::npos) { secondDot = i; }
|
||||||
else {
|
else {
|
||||||
// так быть не должно
|
// так быть не должно
|
||||||
return t;
|
return t;
|
||||||
|
25
src/main.cpp
25
src/main.cpp
@ -28,25 +28,6 @@ constexpr const char* REBOOT_COMMAND = "web-action reboot";
|
|||||||
constexpr const char* UPGRADE_COMMAND = "web-action upgrade";
|
constexpr const char* UPGRADE_COMMAND = "web-action upgrade";
|
||||||
|
|
||||||
|
|
||||||
static std::vector<char> loadFile(const std::string& path) {
|
|
||||||
std::ifstream is(path, std::ios::in | std::ios::binary);
|
|
||||||
if (!is) {
|
|
||||||
throw std::runtime_error("File not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<char> content;
|
|
||||||
for (;;) {
|
|
||||||
char buf[512];
|
|
||||||
auto len = is.read(buf, sizeof(buf)).gcount();
|
|
||||||
if (len <= 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
content.insert(content.end(), buf, buf + len);
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace mime_types = http::server::mime_types;
|
namespace mime_types = http::server::mime_types;
|
||||||
|
|
||||||
void init_logging() {
|
void init_logging() {
|
||||||
@ -515,9 +496,9 @@ int main(int argc, char *argv[]) {
|
|||||||
s->run();
|
s->run();
|
||||||
|
|
||||||
} else if (strcmp(argv[1], "ssl") == 0) {
|
} else if (strcmp(argv[1], "ssl") == 0) {
|
||||||
const auto cert = loadFile("cert.pem");
|
std::vector<char> cert; http::resource::loadFile("cert.pem", cert);
|
||||||
const auto key = loadFile("key.pem");
|
std::vector<char> key; http::resource::loadFile("key.pem", key);
|
||||||
const auto dh = loadFile("dh.pem");
|
std::vector<char> dh; http::resource::loadFile("dh.pem", dh);
|
||||||
|
|
||||||
auto ctx = std::make_shared<ssl::context>(ssl::context::tlsv12);
|
auto ctx = std::make_shared<ssl::context>(ssl::context::tlsv12);
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
static void loadFile(const std::string& path, std::vector<char>& content) {
|
void http::resource::loadFile(const std::string& path, std::vector<char>& content) {
|
||||||
std::ifstream is(path, std::ios::in | std::ios::binary);
|
std::ifstream is(path, std::ios::in | std::ios::binary);
|
||||||
if (!is) {
|
if (!is) {
|
||||||
throw std::runtime_error("File not found");
|
throw std::runtime_error("File not found " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
content.clear();
|
content.clear();
|
||||||
|
@ -62,6 +62,8 @@ namespace http::resource {
|
|||||||
|
|
||||||
~GenericResource() override;
|
~GenericResource() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void loadFile(const std::string& path, std::vector<char>& content);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //RESOURCE_H
|
#endif //RESOURCE_H
|
||||||
|
@ -469,6 +469,15 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool isTest() {
|
||||||
|
std::shared_lock lock(this->settingsMutex);
|
||||||
|
return !modSettings.is_carrier
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
|| this->modSettings.is_test_data
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
void getNetworkSettings(TerminalNetworkSettings& dest) {
|
void getNetworkSettings(TerminalNetworkSettings& dest) {
|
||||||
std::shared_lock lock(this->networkSettingsMutex);
|
std::shared_lock lock(this->networkSettingsMutex);
|
||||||
dest = this->networkSettings;
|
dest = this->networkSettings;
|
||||||
@ -690,6 +699,7 @@ std::string api_driver::ApiDriver::loadTerminalState() const {
|
|||||||
std::stringstream result;
|
std::stringstream result;
|
||||||
|
|
||||||
result << "{\n\"initState\":" << buildEscapedString(daemon->getDeviceInitState());
|
result << "{\n\"initState\":" << buildEscapedString(daemon->getDeviceInitState());
|
||||||
|
result << ",\n\"testState\":" << boolAsStr(daemon->isTest());
|
||||||
|
|
||||||
modulator_state modulator{};
|
modulator_state modulator{};
|
||||||
demodulator_state demodulator{};
|
demodulator_state demodulator{};
|
||||||
@ -873,15 +883,15 @@ std::string api_driver::ApiDriver::loadSettings() const {
|
|||||||
|
|
||||||
std::stringstream result;
|
std::stringstream result;
|
||||||
result << "{\n\"txAutoStart\":" << boolAsStr(modSettings.is_save_current_state);
|
result << "{\n\"txAutoStart\":" << boolAsStr(modSettings.is_save_current_state);
|
||||||
#ifdef MODEM_IS_SCPC
|
|
||||||
result << ",\"txEn\":" << boolAsStr(modSettings.tx_is_on);
|
result << ",\"txEn\":" << boolAsStr(modSettings.tx_is_on);
|
||||||
result << ",\"txModulatorIsTest\":" << boolAsStr(!modSettings.is_carrier);
|
#ifdef MODEM_IS_SCPC
|
||||||
#endif
|
|
||||||
result << ",\"txIsTestInput\":" << boolAsStr(modSettings.is_test_data);
|
result << ",\"txIsTestInput\":" << boolAsStr(modSettings.is_test_data);
|
||||||
|
#endif
|
||||||
|
result << ",\"txModulatorIsTest\":" << boolAsStr(!modSettings.is_carrier);
|
||||||
result << ",\"txCentralFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz);
|
result << ",\"txCentralFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz);
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
result << ",\"txBaudrate\":" << modSettings.baudrate;
|
result << ",\"txBaudrate\":" << modSettings.baudrate;
|
||||||
result << ",\"txRolloff\":" << static_cast<int>(modSettings.rollof);
|
result << ",\"txRolloff\":" << static_cast<int>(modSettings.rollof);
|
||||||
#ifdef MODEM_IS_SCPC
|
|
||||||
result << ",\"txGoldan\":" << static_cast<int>(modSettings.gold_seq_is_active);
|
result << ",\"txGoldan\":" << static_cast<int>(modSettings.gold_seq_is_active);
|
||||||
#endif
|
#endif
|
||||||
result << ",\"txAttenuation\":"; writeDouble(result, modSettings.attenuation);
|
result << ",\"txAttenuation\":"; writeDouble(result, modSettings.attenuation);
|
||||||
@ -1017,13 +1027,13 @@ void api_driver::ApiDriver::setRxTxSettings(boost::property_tree::ptree &pt) {
|
|||||||
mod.tx_is_on = pt.get<bool>("txEn");
|
mod.tx_is_on = pt.get<bool>("txEn");
|
||||||
#ifdef MODEM_IS_SCPC
|
#ifdef MODEM_IS_SCPC
|
||||||
mod.is_save_current_state = pt.get<bool>("txAutoStart");
|
mod.is_save_current_state = pt.get<bool>("txAutoStart");
|
||||||
mod.is_carrier = !pt.get<bool>("txModulatorIsTest");
|
|
||||||
#endif
|
|
||||||
mod.is_test_data = pt.get<bool>("txIsTestInput");
|
mod.is_test_data = pt.get<bool>("txIsTestInput");
|
||||||
|
#endif
|
||||||
|
mod.is_carrier = !pt.get<bool>("txModulatorIsTest");
|
||||||
mod.central_freq_in_kGz = pt.get<double>("txCentralFreq");
|
mod.central_freq_in_kGz = pt.get<double>("txCentralFreq");
|
||||||
mod.baudrate = pt.get<uint32_t>("txBaudrate");
|
|
||||||
mod.rollof = pt.get<int>("txRolloff");
|
|
||||||
#ifdef MODEM_IS_SCPC
|
#ifdef MODEM_IS_SCPC
|
||||||
|
mod.baudrate = pt.get<uint32_t>("txBaudrate");
|
||||||
|
mod.rollof = pt.get<unsigned int>("txRolloff");
|
||||||
mod.gold_seq_is_active = pt.get<bool>("txGoldan");
|
mod.gold_seq_is_active = pt.get<bool>("txGoldan");
|
||||||
#endif
|
#endif
|
||||||
mod.attenuation = pt.get<double>("txAttenuation");
|
mod.attenuation = pt.get<double>("txAttenuation");
|
||||||
@ -1036,10 +1046,10 @@ void api_driver::ApiDriver::setRxTxSettings(boost::property_tree::ptree &pt) {
|
|||||||
// демодулятор
|
// демодулятор
|
||||||
demod.is_aru_on = pt.get<bool>("rxAgcEn");
|
demod.is_aru_on = pt.get<bool>("rxAgcEn");
|
||||||
demod.gain = pt.get<double>("rxManualGain");
|
demod.gain = pt.get<double>("rxManualGain");
|
||||||
demod.is_rvt_iq = pt.get<bool>("aupcEn");
|
demod.is_rvt_iq = pt.get<bool>("rxSpectrumInversion");
|
||||||
demod.central_freq_in_kGz = pt.get<double>("rxCentralFreq");
|
demod.central_freq_in_kGz = pt.get<double>("rxCentralFreq");
|
||||||
demod.baudrate = pt.get<uint32_t>("rxBaudrate");
|
demod.baudrate = pt.get<uint32_t>("rxBaudrate");
|
||||||
demod.rollof = pt.get<int>("rxRolloff");
|
demod.rollof = pt.get<unsigned int>("rxRolloff");
|
||||||
#ifdef MODEM_IS_SCPC
|
#ifdef MODEM_IS_SCPC
|
||||||
demod.gold_seq_is_active = pt.get<bool>("rxGoldan");
|
demod.gold_seq_is_active = pt.get<bool>("rxGoldan");
|
||||||
#endif
|
#endif
|
||||||
|
@ -121,14 +121,13 @@
|
|||||||
<span class="toggle-input"><input type="checkbox" v-model="paramRxtx.txEn" /><span class="slider"></span></span>
|
<span class="toggle-input"><input type="checkbox" v-model="paramRxtx.txEn" /><span class="slider"></span></span>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>Входные данные</span>
|
<span>Режим работы модулятора</span>
|
||||||
<select v-model="paramRxtx.txIsTestInput">
|
<select v-model="paramRxtx.txModulatorIsTest">
|
||||||
<option :value="false">SCPC</option>
|
<option :value="false">Нормальный</option>
|
||||||
<option :value="true">Тест</option>
|
<option :value="true">Тест (CW)</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label v-show="paramRxrx.txIsTestInput"><span>Центральная частота, КГц</span><input type="number" v-model="paramRxtx.txCentralFreq" min="900000" step="0.01"/></label>
|
<label v-show="paramRxtx.txModulatorIsTest"><span>Центральная частота, КГц</span><input type="number" v-model="paramRxtx.txCentralFreq" min="900000" step="0.01"/></label>
|
||||||
<label v-show="paramRxrx.txIsTestInput"><span>Символьная скорость, Бод</span><input type="number" v-model="paramRxtx.txBaudrate" step="1"/></label>
|
|
||||||
<label><span>Ослабление, дБ</span><input type="number" v-model="paramRxtx.txAttenuation" step="1"/></label>
|
<label><span>Ослабление, дБ</span><input type="number" v-model="paramRxtx.txAttenuation" step="1"/></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="settings-set-container">
|
<div class="settings-set-container">
|
||||||
@ -292,9 +291,8 @@
|
|||||||
// ========== include from 'common/all-params-data.js.j2'
|
// ========== include from 'common/all-params-data.js.j2'
|
||||||
paramRxtx: {
|
paramRxtx: {
|
||||||
txEn: false,
|
txEn: false,
|
||||||
txIsTestInput: false,
|
txModulatorIsTest: false,
|
||||||
txCentralFreq: 900000,
|
txCentralFreq: 900000,
|
||||||
txBaudrate: 0,
|
|
||||||
txAttenuation: 0,
|
txAttenuation: 0,
|
||||||
rxAgcEn: true,
|
rxAgcEn: true,
|
||||||
rxManualGain: -40,
|
rxManualGain: -40,
|
||||||
@ -422,9 +420,8 @@
|
|||||||
|
|
||||||
let query = {
|
let query = {
|
||||||
"txEn": this.paramRxtx.txEn,
|
"txEn": this.paramRxtx.txEn,
|
||||||
"txIsTestInput": this.paramRxtx.txIsTestInput,
|
"txModulatorIsTest": this.paramRxtx.txModulatorIsTest,
|
||||||
"txCentralFreq": this.paramRxtx.txCentralFreq,
|
"txCentralFreq": this.paramRxtx.txCentralFreq,
|
||||||
"txBaudrate": this.paramRxtx.txBaudrate,
|
|
||||||
"txAttenuation": this.paramRxtx.txAttenuation,
|
"txAttenuation": this.paramRxtx.txAttenuation,
|
||||||
"rxAgcEn": this.paramRxtx.rxAgcEn,
|
"rxAgcEn": this.paramRxtx.rxAgcEn,
|
||||||
"rxManualGain": this.paramRxtx.rxManualGain,
|
"rxManualGain": this.paramRxtx.rxManualGain,
|
||||||
@ -480,9 +477,8 @@
|
|||||||
updateRxtxSettings(vals) {
|
updateRxtxSettings(vals) {
|
||||||
this.submitStatus.rxtx = false
|
this.submitStatus.rxtx = false
|
||||||
this.paramRxtx.txEn = vals["settings"]["txEn"]
|
this.paramRxtx.txEn = vals["settings"]["txEn"]
|
||||||
this.paramRxtx.txIsTestInput = vals["settings"]["txIsTestInput"]
|
this.paramRxtx.txModulatorIsTest = vals["settings"]["txModulatorIsTest"]
|
||||||
this.paramRxtx.txCentralFreq = vals["settings"]["txCentralFreq"]
|
this.paramRxtx.txCentralFreq = vals["settings"]["txCentralFreq"]
|
||||||
this.paramRxtx.txBaudrate = vals["settings"]["txBaudrate"]
|
|
||||||
this.paramRxtx.txAttenuation = vals["settings"]["txAttenuation"]
|
this.paramRxtx.txAttenuation = vals["settings"]["txAttenuation"]
|
||||||
this.paramRxtx.rxAgcEn = vals["settings"]["rxAgcEn"]
|
this.paramRxtx.rxAgcEn = vals["settings"]["rxAgcEn"]
|
||||||
this.paramRxtx.rxManualGain = vals["settings"]["rxManualGain"]
|
this.paramRxtx.rxManualGain = vals["settings"]["rxManualGain"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user