stephb9959
2023-05-26 14:02:13 -07:00
parent 4a1e4d9cba
commit 39f012a429
29 changed files with 157 additions and 112 deletions

View File

@@ -6,14 +6,14 @@
// Arilia Wireless Inc.
//
#include <Poco/Net/SSLManager.h>
#include <framework/UI_WebSocketClientServer.h>
#include "Daemon.h"
#include "SimStats.h"
#include "SimulationCoordinator.h"
#include "StorageService.h"
#include "Poco/Net/SSLManager.h"
#include "UI_Owls_WebSocketNotifications.h"
#include "framework/UI_WebSocketClientServer.h"
namespace OpenWifi {
class Daemon *Daemon::instance_ = nullptr;

View File

@@ -8,9 +8,10 @@
#pragma once
#include <framework/MicroService.h>
#include <framework/MicroServiceNames.h>
#include "Dashboard.h"
#include "framework/MicroService.h"
#include "framework/MicroServiceNames.h"
namespace OpenWifi {

View File

@@ -2,8 +2,8 @@
// Created by stephane bourque on 2021-07-21.
//
#include "Dashboard.h"
#include "framework/utils.h"
#include <framework/utils.h>
#include <Dashboard.h>
namespace OpenWifi {
void OWLSDashboard::Create() {

View File

@@ -2,11 +2,10 @@
// Created by stephane bourque on 2021-07-21.
//
#ifndef UCENTRALGW_DASHBOARD_H
#define UCENTRALGW_DASHBOARD_H
#pragma once
#include "RESTObjects/RESTAPI_OWLSobjects.h"
#include "framework/OpenWifiTypes.h"
#include <framework/OpenWifiTypes.h>
#include <RESTObjects/RESTAPI_OWLSobjects.h>
namespace OpenWifi {
class OWLSDashboard {
@@ -21,4 +20,3 @@ namespace OpenWifi {
};
} // namespace OpenWifi
#endif // UCENTRALGW_DASHBOARD_H

View File

@@ -5,6 +5,7 @@
#pragma once
#include <framework/MicroServiceFuncs.h>
#include "OWLS_utils.h"
namespace OpenWifi {

View File

@@ -2,16 +2,17 @@
// Created by stephane bourque on 2023-04-12.
//
#include <fmt/format.h>
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {
/*
void Connect(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner) {
if(!Runner->Running()) {
@@ -58,5 +59,5 @@ namespace OpenWifi::OWLSClientEvents {
OWLSClientEvents::Disconnect(ClientGuard,Client, Runner, "Error occurred during connection", true);
}
}
*/
}

View File

@@ -1,13 +1,11 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {

View File

@@ -1,19 +1,20 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
#include "OWLS_utils.h"
namespace OpenWifi::OWLSClientEvents {
void Disconnect(std::lock_guard<std::mutex> &ClientGuard, const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner, const std::string &Reason, bool Reconnect) {
void Disconnect(std::lock_guard<std::mutex> &ClientGuard, const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner,
const std::string &Reason, bool Reconnect) {
if(Client->Valid_) {
Client->Disconnect(ClientGuard);

View File

@@ -2,14 +2,13 @@
// Created by stephane bourque on 2023-04-12.
//
#include <fmt/format.h>
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {
@@ -88,8 +87,9 @@ namespace OpenWifi::OWLSClientEvents {
Client->Reactor_.addEventHandler(
*Client->WS_, Poco::NObserver<SimulationRunner, Poco::Net::ShutdownNotification>(
*Runner, &SimulationRunner::OnSocketShutdown));
Runner->Scheduler().in(std::chrono::seconds(1), Connect, Client, Runner);
SimStats()->Connect(Runner->Id());
// Runner->Scheduler().in(std::chrono::seconds(1), Connect, Client, Runner);
Connect(ClientGuard, Client, Runner);
// SimStats()->Connect(Runner->Id());
Client->Logger_.information(fmt::format("connecting({}): connected.", Client->SerialNumber_));
} catch (const Poco::Exception &E) {
Client->Logger_.warning(
@@ -104,4 +104,54 @@ namespace OpenWifi::OWLSClientEvents {
Runner->Scheduler().in(std::chrono::seconds(60), Reconnect, Client, Runner);
}
}
}
void Connect(std::lock_guard<std::mutex> & ClientGuard, const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner) {
if(!Runner->Running()) {
return;
}
// std::lock_guard ClientGuard(Client->Mutex_);
if(Client->Valid_) {
try {
Runner->Report().ev_connect++;
Poco::JSON::Object ConnectMessage, Params, TmpCapabilities, Capabilities, MacAddr;
auto LabelMac = Utils::SerialNumberToInt(Client->SerialNumber_);
Params.set("serial", Client->SerialNumber_);
Params.set("uuid", Client->UUID_);
Params.set("firmware", Client->Firmware_);
MacAddr.set("wan", Client->SerialNumber_);
MacAddr.set("lan", Utils::SerialToMAC(Utils::IntToSerialNumber(LabelMac + 1)));
TmpCapabilities = *SimulationCoordinator()->GetSimCapabilitiesPtr();
TmpCapabilities.set("label_macaddr", Client->SerialNumber_);
TmpCapabilities.set("macaddr", MacAddr);
Params.set("capabilities", TmpCapabilities);
OWLSutils::MakeHeader(ConnectMessage,"connect",Params);
if (Client->SendObject(ConnectMessage)) {
Client->Reset();
Runner->Scheduler().in(std::chrono::seconds(Client->StatisticsInterval_),
OWLSClientEvents::State, Client, Runner);
Runner->Scheduler().in(std::chrono::seconds(Client->HealthInterval_),
OWLSClientEvents::HealthCheck, Client, Runner);
Runner->Scheduler().in(std::chrono::seconds(MicroServiceRandom(120, 200)),
OWLSClientEvents::Log, Client, Runner, 1, "Device started");
Runner->Scheduler().in(std::chrono::seconds(60 * 4),
OWLSClientEvents::WSPing, Client, Runner);
Runner->Scheduler().in(std::chrono::seconds(30),
OWLSClientEvents::Update, Client, Runner);
Client->Logger_.information(fmt::format("connect({}): completed.", Client->SerialNumber_));
SimStats()->Connect(Runner->Id());
return;
}
} catch (const Poco::Exception &E) {
Client->Logger().log(E);
}
OWLSClientEvents::Disconnect(ClientGuard,Client, Runner, "Error occurred during connection", true);
}
}
}

View File

@@ -1,13 +1,11 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {

View File

@@ -1,13 +1,11 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {

View File

@@ -1,13 +1,11 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {

View File

@@ -1,13 +1,12 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {

View File

@@ -2,13 +2,11 @@
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
#include "OWLS_utils.h"

View File

@@ -2,12 +2,12 @@
// Created by stephane bourque on 2023-04-12.
//
#include <fmt/format.h>
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSdefinitions.h"
#include "OWLSclientEvents.h"

View File

@@ -1,10 +1,11 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {

View File

@@ -1,13 +1,11 @@
//
// Created by stephane bourque on 2023-04-12.
//
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimulationCoordinator.h"
#include <fmt/format.h>
#include "SimStats.h"
#include <Poco/NObserver.h>
#include "OWLSclient.h"
#include "SimulationRunner.h"
#include "SimStats.h"
#include "OWLSclientEvents.h"
namespace OpenWifi::OWLSClientEvents {

View File

@@ -5,6 +5,7 @@
#pragma once
#include <random>
#include <framework/MicroServiceFuncs.h>
#include <framework/ow_constants.h>

View File

@@ -7,19 +7,19 @@
#include <thread>
#include <tuple>
#include "OWLS_utils.h"
#include <fmt/format.h>
#include <Poco/NObserver.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/URI.h>
#include "Poco/NObserver.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/URI.h"
#include "OWLSclient.h"
#include "OWLSdefinitions.h"
#include "framework/MicroServiceFuncs.h"
#include "OWLS_utils.h"
#include "OWLSclient.h"
#include "OWLSdefinitions.h"
#include "SimStats.h"
#include "SimulationCoordinator.h"
#include "fmt/format.h"
using namespace std::chrono_literals;

View File

@@ -9,20 +9,21 @@
#include <random>
#include <tuple>
#include "Poco/AutoPtr.h"
#include "Poco/JSON/Object.h"
#include "Poco/Logger.h"
#include "Poco/Net/SocketNotification.h"
#include "Poco/Net/SocketReactor.h"
#include "Poco/Net/WebSocket.h"
#include "Poco/Thread.h"
#include <fmt/format.h>
#include <Poco/AutoPtr.h>
#include <Poco/JSON/Object.h>
#include <Poco/Logger.h>
#include <Poco/Net/SocketNotification.h>
#include <Poco/Net/SocketReactor.h>
#include <Poco/Net/WebSocket.h>
#include <Poco/Thread.h>
#include "framework/utils.h"
#include "OWLSdefinitions.h"
#include "OWLSdefinitions.h"
#include "MockElements.h"
#include "OWLSclientEvents.h"
#include <fmt/format.h>
namespace OpenWifi {
@@ -96,7 +97,8 @@ namespace OpenWifi {
friend void OWLSClientEvents::EstablishConnection(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
friend void OWLSClientEvents::Reconnect(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
friend void OWLSClientEvents::Connect(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
// friend void OWLSClientEvents::Connect(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
friend void OWLSClientEvents::Connect(std::lock_guard<std::mutex> & ClientGuard, const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
friend void OWLSClientEvents::Log(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner, std::uint64_t Severity, const std::string & LogLine);
friend void OWLSClientEvents::State(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
friend void OWLSClientEvents::HealthCheck(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);

View File

@@ -14,7 +14,7 @@ namespace OpenWifi {
namespace OpenWifi::OWLSClientEvents {
void EstablishConnection(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
void Reconnect(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
void Connect(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
void Connect(std::lock_guard<std::mutex> & ClientGuard, const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
void State(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
void HealthCheck(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner);
void Log(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner, std::uint64_t Severity, const std::string & LogLine);

View File

@@ -4,9 +4,8 @@
#pragma once
#include "framework/SubSystemServer.h"
#include "framework/utils.h"
#include <framework/SubSystemServer.h>
#include <framework/utils.h>
#include <RESTObjects/RESTAPI_OWLSobjects.h>
#include <RESTObjects/RESTAPI_SecurityObjects.h>

View File

@@ -2,15 +2,16 @@
// Created by stephane bourque on 2021-11-03.
//
#include <fmt/format.h>
#include <Poco/JSON/Parser.h>
#include <framework/MicroServiceFuncs.h>
#include <framework/utils.h>
#include "SimulationCoordinator.h"
#include "SimStats.h"
#include "StorageService.h"
#include "fmt/format.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
#include <Poco/JSON/Parser.h>
namespace OpenWifi {

View File

@@ -7,11 +7,12 @@
#include <chrono>
#include <random>
#include "RESTObjects/RESTAPI_OWLSobjects.h"
#include "SimulationRunner.h"
#include "framework/SubSystemServer.h"
#include <framework/SubSystemServer.h>
#include <RESTObjects/RESTAPI_OWLSobjects.h>
#include <RESTObjects/RESTAPI_SecurityObjects.h>
#include "SimulationRunner.h"
namespace OpenWifi {
struct SimulationRecord {

View File

@@ -5,17 +5,18 @@
#include <thread>
#include <chrono>
#include "SimStats.h"
#include "SimulationRunner.h"
#include "fmt/format.h"
#include "UI_Owls_WebSocketNotifications.h"
#include <fmt/format.h>
#include <Poco/Logger.h>
#include <Poco/Net/NetException.h>
#include <Poco/Net/SSLException.h>
#include <Poco/NObserver.h>
#include "SimStats.h"
#include "SimulationRunner.h"
#include "UI_Owls_WebSocketNotifications.h"
namespace OpenWifi {
void SimulationRunner::Start() {
std::random_device rd;

View File

@@ -10,13 +10,13 @@
#include <Poco/Thread.h>
#include <Poco/Environment.h>
#include "OWLSclient.h"
#include <RESTObjects/RESTAPI_OWLSobjects.h>
#include "CensusReport.h"
#include <libs/Scheduler.h>
#include <RESTObjects/RESTAPI_SecurityObjects.h>
#include "OWLSclient.h"
#include "CensusReport.h"
namespace OpenWifi {
class SimulationRunner {
@@ -49,7 +49,6 @@ namespace OpenWifi {
}
void ProcessCommand(std::lock_guard<std::mutex> &G, const std::shared_ptr<OWLSclient> &Client, Poco::JSON::Object::Ptr Vars);
// Poco::Net::SocketReactor & Reactor() { return Reactor_; }
inline auto & Scheduler() { return Scheduler_; }
inline bool Running() { return Running_; }

View File

@@ -8,9 +8,9 @@
#pragma once
#include "framework/StorageClass.h"
#include "storage/storage_results.h"
#include "storage/storage_simulations.h"
#include <framework/StorageClass.h>
#include <storage/storage_results.h>
#include <storage/storage_simulations.h>
namespace OpenWifi {

View File

@@ -2,8 +2,9 @@
// Created by stephane bourque on 2022-10-30.
//
#include "UI_Owls_WebSocketNotifications.h"
#include "framework/UI_WebSocketClientServer.h"
#include <framework/UI_WebSocketClientServer.h>
#include <UI_Owls_WebSocketNotifications.h>
namespace OpenWifi::OWLSNotifications {

View File

@@ -4,8 +4,8 @@
#pragma once
#include "RESTObjects/RESTAPI_OWLSobjects.h"
#include "framework/UI_WebSocketClientNotifications.h"
#include <framework/UI_WebSocketClientNotifications.h>
#include <RESTObjects/RESTAPI_OWLSobjects.h>
namespace OpenWifi::OWLSNotifications {