From ecdef5912e096b2f261f4d759a7e89bc2e41069b Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 18 Apr 2023 14:30:41 -0700 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-12378 Signed-off-by: stephb9959 --- src/OWLSclient.cpp | 17 +++++++++++++++++ src/OWLSclient.h | 1 + src/SimulationCoordinator.cpp | 12 +++++------- src/SimulationRunner.cpp | 1 + 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/OWLSclient.cpp b/src/OWLSclient.cpp index 68112f5..413f1c4 100644 --- a/src/OWLSclient.cpp +++ b/src/OWLSclient.cpp @@ -562,6 +562,23 @@ namespace OpenWifi { } } + void OWLSclient::UNsupportedCommand(std::shared_ptr Client, uint64_t Id, + const std::string & Method) { + try { + Poco::JSON::Object Answer, Result, Status; + Status.set("error", 1); + Status.set("text", "Command not supported"); + Result.set("serial", Client->SerialNumber_); + Result.set("status", Status); + OWLSutils::MakeRPCHeader(Answer, Id, Result); + poco_information(Logger_,fmt::format("UNSUPPORTED({}): command {} not allowed for simulated devices.", + SerialNumber_, Method)); + SendObject(Answer); + } catch(const Poco::Exception &E) { + + } + } + bool OWLSclient::Send(const std::string &Cmd) { try { diff --git a/src/OWLSclient.h b/src/OWLSclient.h index fd4afc3..0ae32fd 100644 --- a/src/OWLSclient.h +++ b/src/OWLSclient.h @@ -53,6 +53,7 @@ namespace OpenWifi { void DoUpgrade(std::shared_ptr Client, uint64_t Id, const Poco::JSON::Object::Ptr Params); void DoFactory(std::shared_ptr Client, uint64_t Id, const Poco::JSON::Object::Ptr Params); void DoLEDs(std::shared_ptr Client, uint64_t Id, const Poco::JSON::Object::Ptr Params); + void UNsupportedCommand(std::shared_ptr Client, uint64_t Id, const std::string &Method); using interface_location_t = std::tuple; using associations_map_t = std::map; diff --git a/src/SimulationCoordinator.cpp b/src/SimulationCoordinator.cpp index 472370a..f35481d 100644 --- a/src/SimulationCoordinator.cpp +++ b/src/SimulationCoordinator.cpp @@ -6,7 +6,6 @@ #include "SimStats.h" #include "StorageService.h" -#include "Poco/Environment.h" #include "fmt/format.h" #include "framework/MicroServiceFuncs.h" #include "framework/utils.h" @@ -50,23 +49,21 @@ namespace OpenWifi { void SimulationCoordinator::run() { Running_ = true; while (Running_) { - Poco::Thread::trySleep(10000); + Poco::Thread::trySleep(20000); if (!Running_) break; uint64_t Now = Utils::Now(); std::lock_guard G(Mutex_); - std::cout << "Checking sims..." << std::endl; - for(auto it = Simulations_.begin(); it!=end(Simulations_); ) { const auto &id = it->first; const auto &simulation = it->second; - std::cout << "Checking sims...: " << simulation->Details.simulationLength << std::endl; if (simulation->Details.simulationLength != 0 && (Now - SimStats()->GetStartTime(id)) > simulation->Details.simulationLength) { + poco_information(Logger(),fmt::format("Simulation'{}' ({}) just completed.", simulation->Details.name, + simulation->Runner.Id())); std::string Error; - std::cout << "Sim is done: " << simulation->Details.name << std::endl; simulation->Runner.Stop(); SimStats()->EndSim(id); OWLSObjects::SimulationStatus S; @@ -75,7 +72,8 @@ namespace OpenWifi { SimStats()->RemoveSim(id); it = Simulations_.erase(it); } else { - std::cout << "Sim is good: " << simulation->Details.name << std::endl; + poco_information(Logger(),fmt::format("Simulation'{}' ({}) still running.", simulation->Details.name, + simulation->Runner.Id())); ++it; } } diff --git a/src/SimulationRunner.cpp b/src/SimulationRunner.cpp index 20c06f2..48736d0 100644 --- a/src/SimulationRunner.cpp +++ b/src/SimulationRunner.cpp @@ -207,6 +207,7 @@ namespace OpenWifi { Client->DoLEDs(Client, Id, Params); } else { Logger_.warning(fmt::format("COMMAND({}): unknown method '{}'", Client->SerialNumber_, Method)); + Client->UNsupportedCommand(Client, Id, Method); } }