Commit 7697e174 authored by Giuseppe Carboni's avatar Giuseppe Carboni
Browse files

Added some log for the SRTMinorServoAnswerMap

parent 2eb7d19a
Loading
Loading
Loading
Loading
+27 −8
Original line number Diff line number Diff line
@@ -492,6 +492,8 @@ namespace MinorServo

            std::shared_lock<std::shared_mutex> lock(m_mutex);

            try
            {
                if constexpr(std::is_integral_v<T>)
                {
                    return (T)std::get<long>(this->at(key));
@@ -505,6 +507,13 @@ namespace MinorServo
                    return (T)std::get<std::string>(this->at(key)).c_str();
                }
            }
            catch(std::out_of_range& ex)
            {
                std::cout << "PLAIN ANSWER:" << std::endl;
                std::cout << this->getPlainAnswer() << std::endl;
                throw ex;
            }
        }

        /**
         * put method. The template parameter is automatically deducted from the 'value' argument. Stores the given 'value' associated with key 'key'
@@ -591,6 +600,16 @@ namespace MinorServo
            return IRA::CIRATools::UNIXEpoch2ACSTime(this->get<double>("TIMESTAMP"));
        }

        /**
         * This method returns the plain answer received from the socket. Useful for log purposes.
         * @return a std::string containing the plain answer received from the socket.
         */
        const std::string getPlainAnswer() const
        {
            std::shared_lock<std::shared_mutex> lock(m_mutex);
            return this->get<std::string>("PLAIN_ANSWER");
        }

    protected:
        /**
         * Shared mutex to control read and write accesses. Multiple reading access are permitted and will only block writing access. Writing access will block all accesses
+2 −0
Original line number Diff line number Diff line
@@ -172,5 +172,7 @@ SRTMinorServoAnswerMap SRTMinorServoCommandLibrary::parseAnswer(const std::strin
        args.clear();
    }

    args.put("PLAIN_ANSWER", original_answer);

    return args;
}
+1 −1
Original line number Diff line number Diff line
@@ -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;