mirror of
https://github.com/Telecominfraproject/wlan-cloud-owls.git
synced 2026-01-27 02:22:44 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -562,6 +562,23 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
|
||||
void OWLSclient::UNsupportedCommand(std::shared_ptr<OWLSclient> 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 {
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace OpenWifi {
|
||||
void DoUpgrade(std::shared_ptr<OWLSclient> Client, uint64_t Id, const Poco::JSON::Object::Ptr Params);
|
||||
void DoFactory(std::shared_ptr<OWLSclient> Client, uint64_t Id, const Poco::JSON::Object::Ptr Params);
|
||||
void DoLEDs(std::shared_ptr<OWLSclient> Client, uint64_t Id, const Poco::JSON::Object::Ptr Params);
|
||||
void UNsupportedCommand(std::shared_ptr<OWLSclient> Client, uint64_t Id, const std::string &Method);
|
||||
|
||||
using interface_location_t = std::tuple<ap_interface_types, std::string, radio_bands>;
|
||||
using associations_map_t = std::map<interface_location_t, MockAssociations>;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user