ADD: default grid scenario

This commit is contained in:
Henry Winkel
2023-11-06 17:48:55 +01:00
parent d151808609
commit c68f458178
3 changed files with 92 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ RUN apt-get upgrade
####### DEBUG packete
RUN apt-get -y install tcpdump nano netcat-openbsd
RUN apt-get -y install tcpdump nano netcat-openbsd htop
########

View File

@@ -60,6 +60,13 @@ class SimControl{
void updateShip(nlohmann::json request);
void deleteShip(nlohmann::json request);
void saveScenario();
void loadScenario(std::string ID);
void deleteScenario(std::string ID);
void generateSampleScneario();
void startWebApp();
void startWebsocketServer();

View File

@@ -1,6 +1,7 @@
#include <Orders/MoveOrder.hpp>
#include <SimCore/Identifier.hpp>
#include "DirectCommunicationServer.hpp"
#include "GeographicLib/Geodesic.hpp"
#include "SimControl/Tracklist.hpp"
#include "SimCore/Messages/Control.hpp"
#include "SimCore/Messages/SimTrack.hpp"
@@ -180,11 +181,11 @@ namespace SimControl {
// The uri the client did connect to.
LOG_S(INFO) << "Uri: " << msg->openInfo.uri ;
LOG_S(INFO) << "Headers:" ;
for (auto it : msg->openInfo.headers)
{
LOG_S(INFO)<< "\t" << it.first << ": " << it.second;
}
// LOG_S(INFO) << "Headers:" ;
// for (auto it : msg->openInfo.headers)
// {
// LOG_S(INFO)<< "\t" << it.first << ": " << it.second;
// }
}
else if (msg->type == ix::WebSocketMessageType::Message)
{
@@ -225,6 +226,29 @@ namespace SimControl {
}else if (j["Data"] == "Scenario")
{
if(j["Type"] == "Save")
{
}else if(j["Type"] == "Load")
{
}else if(j["Type"] == "Delete")
{
}else if(j["Type"] == "AutoRaster")
{
this->generateSampleScneario();
}
}else if (j["Data"] == "TEST")
{
nlohmann::json response;
response["Message"] = "Hello world";
websocket.send(response.dump());
}
@@ -267,7 +291,7 @@ namespace SimControl {
void SimControl::startNewShip(std::string Name, std::string lat, std::string lon, std::string height , std::string course, std::string speed)
{
LOG_S(INFO)<< "start New Ship";
std::string uuid = xg::newGuid().str();
kubecontrol::KubePod ShipPod1("controller",uuid,"ship","ship:latest",Namespace_);
@@ -303,6 +327,8 @@ namespace SimControl {
void SimControl::updateShip(nlohmann::json request)
{
LOG_S(INFO)<< "Update Ship: "<< request["ID"];
// if (j["Type"] == ) {
// statements
// }
@@ -375,6 +401,57 @@ namespace SimControl {
}
void SimControl::saveScenario()
{
}
void SimControl::loadScenario(std::string ID)
{
}
void SimControl::deleteScenario(std::string ID)
{
}
void SimControl::generateSampleScneario()
{
GeographicLib::Geodesic geod(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
double lat = 54, lon = 1;
int counter = 0;
double distance = 10000;
int rasterSize = 10;
for (int i = 0; i < rasterSize; i++ )
{
double lonTmp = lon;
for (int a = 0; a < rasterSize; a++)
{
std::string name = "test";
name += std::to_string(counter);
double lat2, lon2;
geod.Direct(lat, lonTmp, 90, distance, lat2, lon2);
SimControl::startNewShip(name, std::to_string(lat2), std::to_string(lon2), "0", "0", "0");
lonTmp = lon2;
counter ++;
}
double lat2, lon2;
geod.Direct(lat, lon, 0, distance, lat2, lon2);
lat = lat2;
}
}
void SimControl::MainFunction_()