ADD: add functionality to delete and add new entities
This commit is contained in:
@@ -31,7 +31,7 @@ COPY build/libs/SimCore/libs/geographiclib/src/libGeographicLib.so.23 /usr/lib/
|
|||||||
COPY build/libs/KubeControl/libs/yaml-cpp/libyaml-cpp.so.0.8 /usr/lib/
|
COPY build/libs/KubeControl/libs/yaml-cpp/libyaml-cpp.so.0.8 /usr/lib/
|
||||||
COPY build/libs/KubeControl/libs/curlpp/libcurlpp.so.1 /usr/lib/
|
COPY build/libs/KubeControl/libs/curlpp/libcurlpp.so.1 /usr/lib/
|
||||||
# COPY build/libs/EntityLibrary/libs/SimCore/libs/crossguid/libcrossguid.so.0 /usr/lib/
|
# COPY build/libs/EntityLibrary/libs/SimCore/libs/crossguid/libcrossguid.so.0 /usr/lib/
|
||||||
# COPY build/libs/SimCore/libs/crossguid/libcrossguid.so.0 /usr/lib/
|
COPY build/libs/SimCore/libs/crossguid/libcrossguid.so.0 /usr/lib/
|
||||||
COPY build/libs/ixwebsocket/libixwebsocket.so.0.1.0 /usr/lib/
|
COPY build/libs/ixwebsocket/libixwebsocket.so.0.1.0 /usr/lib/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ cd build/
|
|||||||
make -j8
|
make -j8
|
||||||
cd ..
|
cd ..
|
||||||
TAG="kmaster.ti.unibw-hamburg.de:30808/simcontrol:latest"
|
TAG="kmaster.ti.unibw-hamburg.de:30808/simcontrol:latest"
|
||||||
# sudo buildah bud --pull -f "Dockerfile" -t ${TAG}
|
sudo buildah bud --pull -f "Dockerfile" -t ${TAG}
|
||||||
# buildah push ${TAG}
|
sudo buildah push ${TAG}
|
||||||
docker build --pull --rm -f "Dockerfile" -t ${TAG} "."
|
# docker build --pull --rm -f "Dockerfile" -t ${TAG} "."
|
||||||
docker image push ${TAG}
|
# docker image push ${TAG}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "DirectCommunicationServer.hpp"
|
#include "DirectCommunicationServer.hpp"
|
||||||
#include "SimControl/Tracklist.hpp"
|
#include "SimControl/Tracklist.hpp"
|
||||||
#include "SimCore/Identifier.hpp"
|
#include "SimCore/Identifier.hpp"
|
||||||
|
#include "SimCore/Position.hpp"
|
||||||
#include "WHISPER/InternalUDPListener.hpp"
|
#include "WHISPER/InternalUDPListener.hpp"
|
||||||
#include "crossguid/guid.hpp"
|
#include "crossguid/guid.hpp"
|
||||||
#include "ixwebsocket/IXConnectionState.h"
|
#include "ixwebsocket/IXConnectionState.h"
|
||||||
@@ -55,6 +56,7 @@ class SimControl{
|
|||||||
|
|
||||||
|
|
||||||
void startShip(std::string name);
|
void startShip(std::string name);
|
||||||
|
void startNewShip(std::string Name, std::string lat, std::string lon, std::string height , std::string course, std::string speed);
|
||||||
void updateShip(nlohmann::json request);
|
void updateShip(nlohmann::json request);
|
||||||
void deleteShip(nlohmann::json request);
|
void deleteShip(nlohmann::json request);
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ namespace SimControl
|
|||||||
void addTrack(std::shared_ptr<SimCore::SimTrack> Track);
|
void addTrack(std::shared_ptr<SimCore::SimTrack> Track);
|
||||||
std::shared_ptr<SimCore::SimTrack> getTrack(SimCore::Identifier);
|
std::shared_ptr<SimCore::SimTrack> getTrack(SimCore::Identifier);
|
||||||
|
|
||||||
|
void deleteTrack(std::string ID);
|
||||||
|
void deleteTrack(SimCore::Identifier);
|
||||||
std::shared_ptr<SimCore::SimTrack> getTrackBySringID(std::string ID);
|
std::shared_ptr<SimCore::SimTrack> getTrackBySringID(std::string ID);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Submodule libs/OrderLibrary updated: 836cee9d6c...f4f98191bf
Submodule libs/SimCore updated: e879a12f26...49dd5e295f
Submodule libs/ixwebsocket updated: ed5b1a0895...f29906c72f
@@ -210,8 +210,18 @@ namespace SimControl {
|
|||||||
}else if (j["Data"] == "Entity")
|
}else if (j["Data"] == "Entity")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(j["Type"] == "Update")
|
||||||
|
{
|
||||||
updateShip(j);
|
updateShip(j);
|
||||||
|
}else if(j["Type"] == "New")
|
||||||
|
{
|
||||||
|
|
||||||
|
startNewShip( j["Name"], j["Position"][0], j["Position"][1], j["Height"] , j["Course"], j["Speed"]);
|
||||||
|
|
||||||
|
}else if(j["Type"] == "Delete")
|
||||||
|
{
|
||||||
|
deleteShip(j);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -254,6 +264,43 @@ namespace SimControl {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SimControl::startNewShip(std::string Name, std::string lat, std::string lon, std::string height , std::string course, std::string speed)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
std::string uuid = xg::newGuid().str();
|
||||||
|
kubecontrol::KubePod ShipPod1("controller",uuid,"ship","ship:latest",Namespace_);
|
||||||
|
|
||||||
|
nlohmann::json vars;
|
||||||
|
vars["ENTITY_ID"] = uuid;
|
||||||
|
vars["ENTITY_NAME"] = Name;
|
||||||
|
vars["POSITION"]["LAT"] = lat;
|
||||||
|
vars["POSITION"]["LON"] = lon;
|
||||||
|
vars["POSITION"]["Height"] = height;
|
||||||
|
vars["COURSE"] = course;
|
||||||
|
vars["SPEED"] = speed;
|
||||||
|
vars["GROUNDTRUTH_PORT"] = std::to_string(this->GroundTruthPort_);
|
||||||
|
vars["GROUNDTRUTH_ADDR"] = this->GroundTruthAddr_;
|
||||||
|
vars["COMMAND_PORT"] = CommandPort_;
|
||||||
|
|
||||||
|
ShipPod1.setEnvironmentVar("ENTITY_ID", uuid);
|
||||||
|
ShipPod1.setEnvironmentVar("ENTITY_NAME", Name);
|
||||||
|
ShipPod1.setEnvironmentVar("POS_LAT", "\""+ lat + "\"");
|
||||||
|
ShipPod1.setEnvironmentVar("POS_LONG", "\""+ lon + "\"");
|
||||||
|
ShipPod1.setEnvironmentVar("POS_HEIGHT", "\""+ height + "\"");
|
||||||
|
ShipPod1.setEnvironmentVar("GROUNDTRUTH_PORT", "\""+std::to_string(this->GroundTruthPort_)+"\"");
|
||||||
|
ShipPod1.setEnvironmentVar("GROUNDTRUTH_ADDR", "\""+this->GroundTruthAddr_+"\"");
|
||||||
|
ShipPod1.setEnvironmentVar("COMMAND_PORT", "\""+CommandPort_+"\"");
|
||||||
|
ShipPod1.setEnvironmentVar("CONFIG", vars.dump());
|
||||||
|
|
||||||
|
ShipPod1.createYAML();
|
||||||
|
PodController_->startPod(ShipPod1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SimControl::updateShip(nlohmann::json request)
|
void SimControl::updateShip(nlohmann::json request)
|
||||||
{
|
{
|
||||||
// if (j["Type"] == ) {
|
// if (j["Type"] == ) {
|
||||||
@@ -275,10 +322,10 @@ namespace SimControl {
|
|||||||
{
|
{
|
||||||
LOG_S(INFO)<<"setting new position";
|
LOG_S(INFO)<<"setting new position";
|
||||||
SimCore::Position pos;
|
SimCore::Position pos;
|
||||||
LOG_S(INFO)<<"LAT: "<<request["Position"][0].get<double>();
|
LOG_S(INFO)<<"LAT: "<<request["Position"][0].get<std::string>();
|
||||||
LOG_S(INFO)<<"LON: "<<request["Position"][1].get<double>();
|
LOG_S(INFO)<<"LON: "<<request["Position"][1].get<std::string>();
|
||||||
|
|
||||||
pos.setGeodesicPos(request["Position"][0].get<double>(),request["Position"][1].get<double>(), request["Height"].get<double>());
|
pos.setGeodesicPos(std::stod(request["Position"][0].get<std::string>()),std::stod(request["Position"][1].get<std::string>()), std::stod(request["Height"].get<std::string>()));
|
||||||
moveOrder.setPosition(pos);
|
moveOrder.setPosition(pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -296,7 +343,23 @@ namespace SimControl {
|
|||||||
|
|
||||||
void SimControl::deleteShip(nlohmann::json request)
|
void SimControl::deleteShip(nlohmann::json request)
|
||||||
{
|
{
|
||||||
|
LOG_S(INFO)<<"REQUEST: "<<request;
|
||||||
|
PodController_->checkPodsHierarchy();
|
||||||
|
|
||||||
|
auto info = PodController_->getPodsInfo(request["ID"].get<std::string>());
|
||||||
|
if(info != nullptr)
|
||||||
|
{
|
||||||
|
LOG_S(INFO)<<"PODS Info: " <<info->ToJson();
|
||||||
|
DirectCommunication::DirectCommunicationClient client(std::stoi(CommandPort_),info->Ip);
|
||||||
|
SimCore::Control control(this->ID_,SimCore::ControlType::SHUT_DOWN,"Bye");
|
||||||
|
client.sendMessage(control.buildMessage().serialize());
|
||||||
|
client.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||||
|
|
||||||
|
PodController_->stopPod(request["ID"]);
|
||||||
|
Tracklist_->deleteTrack(request["ID"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimControl::startWebApp()
|
void SimControl::startWebApp()
|
||||||
|
|||||||
@@ -39,6 +39,20 @@ namespace SimControl
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackList::deleteTrack(std::string ID)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
auto it = TrackStore_.find(ID);
|
||||||
|
TrackStore_.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackList::deleteTrack(SimCore::Identifier ID)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
auto it = TrackStore_.find(ID.getUUID());
|
||||||
|
TrackStore_.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackList::getJsonTRackList(nlohmann::json &message)
|
void TrackList::getJsonTRackList(nlohmann::json &message)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user