Loading SRT/Libraries/SRTMinorServoLibrary/include/SRTMinorServoContainers.h +19 −2 Original line number Diff line number Diff line Loading @@ -425,7 +425,7 @@ namespace MinorServo SRTMinorServoAnswerMap(const SRTMinorServoAnswerMap& other) : m_mutex() { std::unique_lock<std::shared_mutex> lockThis(m_mutex, std::defer_lock); std::unique_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::shared_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::lock(lockThis, lockOther); static_cast<std::map <std::string, std::variant<long, double, std::string>>&>(*this) = static_cast<const std::map<std::string, std::variant<long, double, std::string>>&>(other); } Loading @@ -439,7 +439,7 @@ namespace MinorServo if(this != &other) { std::unique_lock<std::shared_mutex> lockThis(m_mutex, std::defer_lock); std::unique_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::shared_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::lock(lockThis, lockOther); static_cast<std::map <std::string, std::variant<long, double, std::string>>&>(*this) = static_cast<const std::map<std::string, std::variant<long, double, std::string>>&>(other); } Loading @@ -447,6 +447,23 @@ namespace MinorServo return *this; } /** * Update operator. It merges the current object with the elements of another object * @param other the SRTMinorServoAnswerMap which values have to be copied inside the current object */ SRTMinorServoAnswerMap& operator+=(const SRTMinorServoAnswerMap& other) { std::unique_lock<std::shared_mutex> lockThis(m_mutex, std::defer_lock); std::shared_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::lock(lockThis, lockOther); for(const auto& entry : other) { this->operator[](entry.first) = entry.second; } return *this; } /** * Equality operator, only check the std::map and avoid comparing the mutexes, which will obviously be different * @param other the SRTMinorServoAnswerMap object to compare the current object with Loading SRT/Libraries/SRTMinorServoLibrary/src/SRTMinorServoSocket.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -179,7 +179,7 @@ SRTMinorServoAnswerMap SRTMinorServoSocket::sendCommand(std::string command, std SRTMinorServoAnswerMap map_answer = SRTMinorServoCommandLibrary::parseAnswer(answer); if(map) { map->get() = map_answer; map->get() += map_answer; } return map_answer; Loading SRT/Libraries/SRTMinorServoLibrary/tests/SRTMinorServoCommandLibraryTest.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -61,8 +61,14 @@ TEST(SRTMinorServoCommandLibraryTest, parseAnswer) args.put("OUTPUT", "GOOD"); args.put("TIMESTAMP", 1665743366.654321); EXPECT_EQ(SRTMinorServoCommandLibrary::parseAnswer(answer), args); EXPECT_EQ(args.getTimestamp(), 138850361666543210); EXPECT_TRUE(args.checkOutput()); SRTMinorServoAnswerMap other; other.put("OTHER", 123456); args += other; EXPECT_EQ(args.get<int>("OTHER"), 123456); EXPECT_EQ(args.getTimestamp(), 138850361666543210); EXPECT_TRUE(args.checkOutput()); // Complete correct answer answer = "OUTPUT:GOOD,1665743366.123456,CURRENT_CONFIG=21|SIMULATION_ENABLED=34|PLC_TIME=78|PLC_VERSION=69|CONTROL=14|POWER=38|EMERGENCY=69|ENABLED=51|OPERATIVE_MODE=94\r\n"; Loading SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,8 @@ SRTMinorServoBossCore::SRTMinorServoBossCore(SRTMinorServoBossImpl& component) : m_socket_connected(m_socket.isConnected() ? Management::MNG_TRUE : Management::MNG_FALSE), m_servos{ //{ "PFP", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/PFP") }, { "SRP", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/SRP") } //{ "GFR", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/GFR") }, { "SRP", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/SRP") }, { "GFR", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/GFR") } //{ "M3R", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/M3R") } }, m_tracking_servos{ Loading Loading
SRT/Libraries/SRTMinorServoLibrary/include/SRTMinorServoContainers.h +19 −2 Original line number Diff line number Diff line Loading @@ -425,7 +425,7 @@ namespace MinorServo SRTMinorServoAnswerMap(const SRTMinorServoAnswerMap& other) : m_mutex() { std::unique_lock<std::shared_mutex> lockThis(m_mutex, std::defer_lock); std::unique_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::shared_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::lock(lockThis, lockOther); static_cast<std::map <std::string, std::variant<long, double, std::string>>&>(*this) = static_cast<const std::map<std::string, std::variant<long, double, std::string>>&>(other); } Loading @@ -439,7 +439,7 @@ namespace MinorServo if(this != &other) { std::unique_lock<std::shared_mutex> lockThis(m_mutex, std::defer_lock); std::unique_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::shared_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::lock(lockThis, lockOther); static_cast<std::map <std::string, std::variant<long, double, std::string>>&>(*this) = static_cast<const std::map<std::string, std::variant<long, double, std::string>>&>(other); } Loading @@ -447,6 +447,23 @@ namespace MinorServo return *this; } /** * Update operator. It merges the current object with the elements of another object * @param other the SRTMinorServoAnswerMap which values have to be copied inside the current object */ SRTMinorServoAnswerMap& operator+=(const SRTMinorServoAnswerMap& other) { std::unique_lock<std::shared_mutex> lockThis(m_mutex, std::defer_lock); std::shared_lock<std::shared_mutex> lockOther(other.m_mutex, std::defer_lock); std::lock(lockThis, lockOther); for(const auto& entry : other) { this->operator[](entry.first) = entry.second; } return *this; } /** * Equality operator, only check the std::map and avoid comparing the mutexes, which will obviously be different * @param other the SRTMinorServoAnswerMap object to compare the current object with Loading
SRT/Libraries/SRTMinorServoLibrary/src/SRTMinorServoSocket.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -179,7 +179,7 @@ SRTMinorServoAnswerMap SRTMinorServoSocket::sendCommand(std::string command, std SRTMinorServoAnswerMap map_answer = SRTMinorServoCommandLibrary::parseAnswer(answer); if(map) { map->get() = map_answer; map->get() += map_answer; } return map_answer; Loading
SRT/Libraries/SRTMinorServoLibrary/tests/SRTMinorServoCommandLibraryTest.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -61,8 +61,14 @@ TEST(SRTMinorServoCommandLibraryTest, parseAnswer) args.put("OUTPUT", "GOOD"); args.put("TIMESTAMP", 1665743366.654321); EXPECT_EQ(SRTMinorServoCommandLibrary::parseAnswer(answer), args); EXPECT_EQ(args.getTimestamp(), 138850361666543210); EXPECT_TRUE(args.checkOutput()); SRTMinorServoAnswerMap other; other.put("OTHER", 123456); args += other; EXPECT_EQ(args.get<int>("OTHER"), 123456); EXPECT_EQ(args.getTimestamp(), 138850361666543210); EXPECT_TRUE(args.checkOutput()); // Complete correct answer answer = "OUTPUT:GOOD,1665743366.123456,CURRENT_CONFIG=21|SIMULATION_ENABLED=34|PLC_TIME=78|PLC_VERSION=69|CONTROL=14|POWER=38|EMERGENCY=69|ENABLED=51|OPERATIVE_MODE=94\r\n"; Loading
SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,8 @@ SRTMinorServoBossCore::SRTMinorServoBossCore(SRTMinorServoBossImpl& component) : m_socket_connected(m_socket.isConnected() ? Management::MNG_TRUE : Management::MNG_FALSE), m_servos{ //{ "PFP", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/PFP") }, { "SRP", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/SRP") } //{ "GFR", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/GFR") }, { "SRP", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/SRP") }, { "GFR", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/GFR") } //{ "M3R", m_component.getContainerServices()->getComponent<SRTBaseMinorServo>("MINORSERVO/M3R") } }, m_tracking_servos{ Loading