добавил кучу всего в вебе
This commit is contained in:
30
src/main.cpp
30
src/main.cpp
@@ -80,6 +80,7 @@ static void initResources(http::server::Server& s, std::shared_ptr<api_driver::A
|
||||
s.resources.emplace_back(std::make_unique<http::resource::StaticFileResource>("/images/krokodil_vzryvaetsya_hd.gif", "static/krokodil.gif", mime_types::image_gif));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::resource::StaticFileResource>("/style.css", "static/style.css", mime_types::text_css));
|
||||
s.resources.emplace_back(std::make_unique<http::resource::StaticFileResource>("/fields.css", "static/fields.css", mime_types::text_css));
|
||||
s.resources.emplace_back(std::make_unique<http::resource::StaticFileResource>("/js/vue.js", "static/js/vue.js", mime_types::javascript));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/api/statistics", [](const auto& req, auto& rep) {
|
||||
@@ -94,7 +95,7 @@ static void initResources(http::server::Server& s, std::shared_ptr<api_driver::A
|
||||
rep.content.insert(rep.content.end(), json, json + strlen(json));
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/api/mainStatistics", [api](const auto& req, auto& rep) {
|
||||
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/api/get/statistics", [api](const auto& req, auto& rep) {
|
||||
if (req.method != "GET") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
@@ -107,6 +108,33 @@ static void initResources(http::server::Server& s, std::shared_ptr<api_driver::A
|
||||
result += "}";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/api/resetPacketStatistics", [api](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
api->resetPacketStatistics();
|
||||
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.clear();
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
const std::string result = R"({"status":"ok")";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/api/get/settings", [api](const auto& req, auto& rep) {
|
||||
if (req.method != "GET") {
|
||||
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)});
|
||||
std::string result = R"({"settings":)";
|
||||
result += api->loadSettings();
|
||||
result += "}";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@@ -181,26 +181,8 @@ std::string api_driver::ApiDriver::loadTerminalState() {
|
||||
|
||||
CP_GetDemodulatorParams(sid, "dummy_cnt", &tmpu32);
|
||||
result << ",\"rx.packetsDummy\":" << tmpu32;
|
||||
|
||||
// auto reset_btn = m_lay->addWidget(std::make_unique<Wt::WPushButton>("Обновить"), 3, 0);
|
||||
// reset_btn->setMaximumSize(95, 50);
|
||||
// reset_btn->clicked().connect([=]
|
||||
// {
|
||||
// std::string var = "";
|
||||
// CP_GetDmaDebug(sid, "reset_cnt_rx", &var);
|
||||
// });
|
||||
}
|
||||
|
||||
/*
|
||||
stat_cinc: {
|
||||
occ: '?',
|
||||
correlator: '?',
|
||||
correlatorFails: '?',
|
||||
freqErr: '?', freqErrAcc: '?',
|
||||
channelDelay: '?'
|
||||
},
|
||||
*/
|
||||
|
||||
// формируем структуру для CinC
|
||||
{
|
||||
std::string tmps;
|
||||
@@ -256,4 +238,13 @@ std::string api_driver::ApiDriver::loadTerminalState() {
|
||||
}
|
||||
|
||||
|
||||
void api_driver::ApiDriver::resetPacketStatistics() const {
|
||||
std::string tmp;
|
||||
CP_GetDmaDebug(sid, "reset_cnt_rx", &tmp);
|
||||
}
|
||||
|
||||
std::string api_driver::ApiDriver::loadSettings() {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
api_driver::ApiDriver::~ApiDriver() = default;
|
||||
|
@@ -20,10 +20,11 @@ namespace api_driver {
|
||||
std::string loadTerminalState();
|
||||
|
||||
/**
|
||||
* Запросить статистику модулятора, демодулятора, CicC и температурные датчики
|
||||
* @return
|
||||
* Сбросить статистику пакетов
|
||||
*/
|
||||
std::string loadDeviceStatistics();
|
||||
void resetPacketStatistics() const;
|
||||
|
||||
std::string loadSettings();
|
||||
|
||||
~ApiDriver();
|
||||
|
||||
|
Reference in New Issue
Block a user