FIX: fixed closing issue
This commit is contained in:
Submodule libs/whisper-com updated: 49bdb28535...f7d57ccbb8
@@ -26,32 +26,30 @@ namespace SimCore {
|
||||
GroundTruthUDPService_ = std::make_shared<WHISPER::InternalUDPService>(OwnID.getNumber(),WHISPER::SENSOR,8000,SimCore::UtilFunctions::implode(ip,'.'),ownIP);
|
||||
ParentUDPService_ = std::make_shared<WHISPER::InternalUDPService>(OwnID.getNumber(),WHISPER::SENSOR,ParentPort,ParentIPAddress_,ownIP);
|
||||
|
||||
ReloadCharacteristicts();
|
||||
|
||||
};
|
||||
|
||||
|
||||
Sensor::~Sensor(){
|
||||
// this->stop();
|
||||
if (ReceivingGroundThruthIsRunnung && sendCalculatedDataIsRunnung && CalculationIsRunnung) {
|
||||
this->stop();
|
||||
|
||||
while (!this->incommingGroundThruthMessages.unique()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
|
||||
this->incommingGroundThruthMessages.reset();
|
||||
|
||||
while (!this->outgoingGroundThruthMessages.unique()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
this->outgoingGroundThruthMessages.reset();
|
||||
|
||||
|
||||
GroundTruthUDPService_->disconnect();
|
||||
// GroundTruthUDPService_->disconnect();
|
||||
while (!this->GroundTruthUDPService_.unique()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
this->GroundTruthUDPService_.reset();
|
||||
|
||||
|
||||
LOG_S(INFO)<<"groundThruth is closed";
|
||||
ParentUDPService_->disconnect();
|
||||
while (!this->ParentUDPService_.unique()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
@@ -59,19 +57,22 @@ namespace SimCore {
|
||||
this->ParentUDPService_.reset();
|
||||
|
||||
|
||||
|
||||
LOG_S(INFO)<<"all destructed";
|
||||
|
||||
}
|
||||
|
||||
void Sensor::start(){
|
||||
ReloadCharacteristicts();
|
||||
|
||||
|
||||
stopReceivingGroundThruth = false;
|
||||
receiveGroundTruthThread = std::thread(&Sensor::receivingData,this);
|
||||
|
||||
// stopsendCalculatedData = false;
|
||||
// sendCalculatedDataThread = std::thread(&Sensor::sendingData,this);
|
||||
stopsendCalculatedData = false;
|
||||
sendCalculatedDataThread = std::thread(&Sensor::sendingData,this);
|
||||
|
||||
// stopCalculationData = false;
|
||||
// sensorCalculationThread = std::thread(&Sensor::SensorCalculations,this);
|
||||
stopCalculationData = false;
|
||||
sensorCalculationThread = std::thread(&Sensor::SensorCalculations,this);
|
||||
}
|
||||
|
||||
void Sensor::stop() {
|
||||
@@ -79,7 +80,7 @@ namespace SimCore {
|
||||
|
||||
while (ReceivingGroundThruthIsRunnung == true ) {
|
||||
stopReceivingGroundThruth = true;
|
||||
LOG_S(INFO)<<"waiting for receiving thread thread";
|
||||
LOG_S(INFO)<<"waiting for groundthruth thread thread";
|
||||
if (receiveGroundTruthThread.joinable() == true ) {
|
||||
receiveGroundTruthThread.join();
|
||||
}
|
||||
@@ -87,7 +88,7 @@ namespace SimCore {
|
||||
|
||||
while (sendCalculatedDataIsRunnung == true ) {
|
||||
stopsendCalculatedData = true;
|
||||
LOG_S(INFO)<<"waiting for receiving thread thread";
|
||||
LOG_S(INFO)<<"waiting for parent sending thread thread";
|
||||
if (sendCalculatedDataThread.joinable() == true ) {
|
||||
sendCalculatedDataThread.join();
|
||||
}
|
||||
@@ -95,11 +96,13 @@ namespace SimCore {
|
||||
|
||||
while (CalculationIsRunnung == true ) {
|
||||
stopCalculationData = true;
|
||||
LOG_S(INFO)<<"waiting for receiving thread thread";
|
||||
LOG_S(INFO)<<"waiting for calculation thread thread";
|
||||
if (sensorCalculationThread.joinable() == true ) {
|
||||
|
||||
sensorCalculationThread.join();
|
||||
}
|
||||
}
|
||||
LOG_S(INFO)<<"all stopped";
|
||||
|
||||
}
|
||||
|
||||
@@ -107,27 +110,27 @@ namespace SimCore {
|
||||
void Sensor::receivingData()
|
||||
{
|
||||
this->ReceivingGroundThruthIsRunnung = true;
|
||||
// GroundTruthUDPService_->connect(incommingGroundThruthMessages);
|
||||
// GroundTruthUDPService_->subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]);
|
||||
GroundTruthUDPService_->connect(incommingGroundThruthMessages);
|
||||
GroundTruthUDPService_->subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]);
|
||||
|
||||
// while (stopReceivingGroundThruth == false) {
|
||||
// if (incommingGroundThruthMessages->size() > 0) {
|
||||
// WHISPER::Message msg;
|
||||
// incommingGroundThruthMessages->get(msg);
|
||||
// if (msg.msgType_ == WHISPER::MsgType::RAW_TRACK) {
|
||||
// auto Track = SimCore::Track(msg.serialize());
|
||||
// incommingTrackMessages->addElement(Track);
|
||||
// }
|
||||
// }
|
||||
while (stopReceivingGroundThruth == false) {
|
||||
if (incommingGroundThruthMessages->size() > 0) {
|
||||
WHISPER::Message msg;
|
||||
incommingGroundThruthMessages->get(msg);
|
||||
if (msg.msgType_ == WHISPER::MsgType::RAW_TRACK) {
|
||||
auto Track = SimCore::Track(msg.serialize());
|
||||
incommingTrackMessages->addElement(Track);
|
||||
}
|
||||
}
|
||||
|
||||
// if (outgoingGroundThruthMessages->size() > 0) {
|
||||
// WHISPER::Message msg;
|
||||
// outgoingGroundThruthMessages->get(msg);
|
||||
// GroundTruthUDPService_->publish(msg.serialize(), WHISPER::MsgTopicsMap[(WHISPER::MsgTopics)msg.topic_]);
|
||||
// }
|
||||
if (outgoingGroundThruthMessages->size() > 0) {
|
||||
WHISPER::Message msg;
|
||||
outgoingGroundThruthMessages->get(msg);
|
||||
GroundTruthUDPService_->publish(msg.serialize(), WHISPER::MsgTopicsMap[(WHISPER::MsgTopics)msg.topic_]);
|
||||
}
|
||||
|
||||
// }
|
||||
// GroundTruthUDPService_->disconnect();
|
||||
}
|
||||
GroundTruthUDPService_->disconnect();
|
||||
this->ReceivingGroundThruthIsRunnung = false;
|
||||
}
|
||||
|
||||
@@ -165,16 +168,18 @@ namespace SimCore {
|
||||
|
||||
while (!stopCalculationData) {
|
||||
specificSensorCalculations();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
||||
}
|
||||
LOG_S(INFO)<<"calculation is stopt";
|
||||
|
||||
CalculationIsRunnung = false;
|
||||
}
|
||||
|
||||
void Sensor::ReloadCharacteristicts()
|
||||
{
|
||||
LOG_S(INFO)<<"loading specs";
|
||||
|
||||
// specificReloadCharacteristicts();
|
||||
specificReloadCharacteristicts();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user