Commit 7f7ebd71 authored by Giuseppe Carboni's avatar Giuseppe Carboni
Browse files

Merge branch 'srt-new-minor-servos' of https://github.com/discos/discos into srt-new-minor-servos

parents e1450f7b d1d00f36
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
#include <enumpropROImpl.h>
#include <SRTMinorServoBossS.h>
#include <SRTMinorServoS.h>
#include <AntennaBossC.h>
#include <AntennaProxy.h>
#include <ManagmentDefinitionsS.h>
#include <thread>
#include <chrono>
@@ -310,7 +310,7 @@ private:
    /**
     * Pointer to the AntennaBoss component.
     */
    Antenna::AntennaBoss_var m_antennaBoss;
    Antenna::AntennaBoss_proxy m_antennaBoss;

    /**
     * SRTMinorServoGeneralStatus object containing the status read from the PLC.
+12 −19
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ SRTMinorServoBossCore::SRTMinorServoBossCore(SRTMinorServoBossImpl& component) :
    m_park_thread(nullptr),
    m_tracking_thread(nullptr),
    m_scan_thread(nullptr),
    m_antennaBoss(Antenna::AntennaBoss::_nil()),
    m_antennaBoss("IDL:alma/Antenna/AntennaBoss:1.0", m_component.getContainerServices()),
    m_status(),
    m_motion_status(MOTION_STATUS_UNCONFIGURED),
    m_commanded_setup("Unknown"),
@@ -146,6 +146,14 @@ bool SRTMinorServoBossCore::status()
            m_tracking.store(Management::MNG_FALSE);
        }
    }
    else if(motion_status == MOTION_STATUS_CONFIGURED)
    {
        m_tracking.store(Management::MNG_TRUE);
    }
    else
    {
        m_tracking.store(Management::MNG_FALSE);
    }

    return true;
}
@@ -1162,33 +1170,18 @@ void SRTMinorServoBossCore::closeScan(ACS::Time& close_time)
double SRTMinorServoBossCore::getElevation(const ACS::Time& acs_time)
{
    AUTO_TRACE("SRTMinorServoBossCore::getElevation()");
    // TODO automatically try to get a new reference if the AntennaBoss component were to be deallocated
    // What happens if we lose the reference? m_antennaBoss will not be _nil but getRawCoordinates will behave unexpectedly

    // Retrieve the AntennaBoss component if it was not initialized yet
    double azimuth, elevation;

    try
    {
        if(CORBA::is_nil(m_antennaBoss))
        {
            m_antennaBoss = m_component.getContainerServices()->getComponent<Antenna::AntennaBoss>("ANTENNA/Boss");
        }

        double azimuth, elevation;
        m_antennaBoss->getRawCoordinates(acs_time, azimuth, elevation);
        elevation *= DR2D;
        // If the antennaBoss didn't command any movement to the telescope yet we get an elevation of 0°
        // We don't want to track an elevation of 0°, especially when DISCOS just started
        // There is a high chance the antenna is still at around 90° of elevation
        // We "initialize" the tracking to an elevation of 45°
        return elevation == 0.0 ? 45.0 : elevation;
    }
    catch(maciErrType::CannotGetComponentExImpl& impl)
    catch(ComponentErrors::CouldntGetComponentExImpl& ex)
    {
        m_antennaBoss = Antenna::AntennaBoss::_nil();
        _EXCPT(ComponentErrors::CouldntGetComponentExImpl, ex, "SRTMinorServoBossCore::getElevation()");
        ex.setComponentName("ANTENNA/Boss");
        ex.addData("Reason", "Cannot get the ANTENNA/Boss component");
        ex.log(LM_DEBUG);
        throw ex.getComponentErrorsEx();
    }
}