Commit 3cd63bef authored by Giuseppe Carboni's avatar Giuseppe Carboni
Browse files

Fixed a couple bugs in SRTMinorServoBoss component

parent 4fdb3d45
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include <Cplusplus11Helper.h>
#include <IRA>
#include <ComponentErrors.h>
#include <iostream>

/**
 * The following templates are useful if you want to check if a given type for the SRTMinorServoAnswerMap is accepted
@@ -43,18 +44,12 @@ struct DB_type
};

template <typename T>
T getCDBValue(maci::ContainerServices* container_services, const std::string& field, const std::string& component="")
{
    return getCDBValue<T>(container_services, field.c_str(), component.c_str());
}

template <typename T>
T getCDBValue(maci::ContainerServices* container_services, const char* field, const char* component="")
T getCDBValue(maci::ContainerServices* container_services, const std::string& field, const std::string component = "")
{
    using C = typename DB_type<T>::type;

    C temp;
    if(IRA::CIRATools::getDBValue(container_services, field, temp, "alma/", component))
    if(IRA::CIRATools::getDBValue(container_services, field.c_str(), temp, "alma/", component.c_str()))
    {
        if constexpr(std::is_same_v<T, std::vector<double>>)
        {
@@ -71,13 +66,13 @@ T getCDBValue(maci::ContainerServices* container_services, const char* field, co
                catch(std::invalid_argument& ia)
                {
                    _EXCPT(ComponentErrors::CDBAccessExImpl, ex, "SRTMinorServoUtils::getCDBValue()");
                    ex.setFieldName(field);
                    ex.setFieldName(field.c_str());
                    throw ex.getComponentErrorsEx();
                }
                catch(std::out_of_range& oor)
                {
                    _EXCPT(ComponentErrors::ValueOutofRangeExImpl, ex, "SRTMinorServoUtils::getCDBValue()");
                    ex.setValueName(field);
                    ex.setValueName(field.c_str());
                    ex.setValueLimit(token.find('-') == std::string::npos ? std::numeric_limits<double>::max() : std::numeric_limits<double>::min());
                    throw ex.getComponentErrorsEx();
                }
@@ -98,7 +93,7 @@ T getCDBValue(maci::ContainerServices* container_services, const char* field, co
    else
    {
        _EXCPT(ComponentErrors::CDBAccessExImpl, ex, "SRTMinorServoUtils::getCDBValue()");
        ex.setFieldName(field);
        ex.setFieldName(field.c_str());
        throw ex.getComponentErrorsEx();  // Maybe throw the plain ex
    }
}
+5 −7
Original line number Diff line number Diff line
@@ -35,17 +35,15 @@ void SRTMinorServoStatusThread::runLoop()
    AUTO_TRACE("SRTMinorServoStatusThread::runLoop()");

    ACS::Time t0 = getTimeStamp();
    unsigned long sleep_time;
    unsigned long sleep_time = 10000000;

    // Update the sleep time in order to not drift away by adding latency
    if(m_core.status())
    // Check the status only if the properties are already being monitored by the Boss component.
    // This is necessary since this thread might start before the start of the properties monitoring.
    if(m_core.m_component.isPropertiesMonitoringActive() && m_core.status())
    {
        // Update the sleep time in order to not drift away by adding latency
        sleep_time = std::max(m_sleep_time - (getTimeStamp() - t0), (long unsigned int)0);
    }
    else
    {
        sleep_time = 10000000;
    }

    publish();