From d8d4b64bb7a848c42bc0935c3cc20a926490cf84 Mon Sep 17 00:00:00 2001 From: Giuseppe Carboni Date: Fri, 17 May 2024 13:32:13 +0000 Subject: [PATCH] Fix #866, focus offsets are now applied when not tracking the elev. Also, fixed an issue with the Python customlogger --- .../IRALibrary/src/IRAPy/customlogging.py | 1 + SRT/CDB/alma/MINORSERVO/GFR/GFR.xml | 1 + SRT/CDB/alma/MINORSERVO/M3R/M3R.xml | 1 + SRT/CDB/alma/MINORSERVO/PFP/PFP.xml | 1 + SRT/CDB/alma/MINORSERVO/SRP/SRP.xml | 1 + .../CDB/alma/MINORSERVO/GFR/GFR.xml | 1 + .../CDB/alma/MINORSERVO/M3R/M3R.xml | 1 + .../CDB/alma/MINORSERVO/PFP/PFP.xml | 1 + .../CDB/alma/MINORSERVO/SRP/SRP.xml | 1 + .../idl/SRTMinorServo.idl | 6 ++++ .../config/CDB/schemas/SRTMinorServo.xsd | 1 + .../SRTMinorServo/include/SRTMinorServoImpl.h | 19 +++++++++- .../src/SRTBaseMinorServoImpl.cpp | 28 ++++++++++++++- .../src/SRTMinorServoBossCore.cpp | 36 +++++++++++++++++-- 14 files changed, 95 insertions(+), 4 deletions(-) diff --git a/Common/Libraries/IRALibrary/src/IRAPy/customlogging.py b/Common/Libraries/IRALibrary/src/IRAPy/customlogging.py index 3cd47d96d..8bd0b8e82 100644 --- a/Common/Libraries/IRALibrary/src/IRAPy/customlogging.py +++ b/Common/Libraries/IRALibrary/src/IRAPy/customlogging.py @@ -2,6 +2,7 @@ This module is intended to extend the ACS Logging module in our python code. """ import logging +logging._srcfile = None import sys from Acspy.Common import Log from ACSLog import ACS_LOG_CRITICAL diff --git a/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml b/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml index 75f01dc18..656043cef 100644 --- a/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml +++ b/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml @@ -27,6 +27,7 @@ + diff --git a/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml b/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml index 83ebde14b..abf4e296e 100644 --- a/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml +++ b/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml @@ -27,6 +27,7 @@ + diff --git a/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml b/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml index 6fdbf0722..3d22653f9 100644 --- a/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml +++ b/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml @@ -28,6 +28,7 @@ + diff --git a/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml b/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml index 6dbe537fe..693ae9163 100644 --- a/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml +++ b/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml @@ -28,6 +28,7 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml b/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml index 75f01dc18..656043cef 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml @@ -27,6 +27,7 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml b/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml index 83ebde14b..abf4e296e 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml @@ -27,6 +27,7 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml b/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml index 6fdbf0722..3d22653f9 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml @@ -28,6 +28,7 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml b/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml index 6dbe537fe..693ae9163 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml @@ -28,6 +28,7 @@ + diff --git a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl index 5c3eb142a..f6680cf78 100644 --- a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl +++ b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl @@ -82,6 +82,12 @@ module MinorServo */ readonly attribute ACS::ROdoubleSeq virtual_system_offsets; + /** + * This property returns the latest virtual positions commanded with a preset command. + * Offsets are not taken into account since they are added by the LDO system. + */ + readonly attribute ACS::ROdoubleSeq commanded_virtual_positions; + /** * This property indicates whether the servo is in use in the current configuration */ diff --git a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd index d3f3d966f..c6e235928 100644 --- a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd +++ b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd @@ -54,6 +54,7 @@ + diff --git a/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h b/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h index 2a43122df..a286b5395 100644 --- a/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h +++ b/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h @@ -100,7 +100,7 @@ public: * if the resulting position summing the offsets would go outside the accepted range of the servo, * if there has been a communication error or if the command was not accepted. */ - void preset(const ACS::doubleSeq& coordinates); + void preset(const ACS::doubleSeq& virtual_coords); /** * Asks the servo system to load the commanded configuration table. @@ -270,6 +270,12 @@ public: */ virtual ACS::ROdoubleSeq_ptr virtual_system_offsets(); + /** + * Returns a reference to the commanded_virtual_positions property implementation of the IDL interface. + * @return pointer to the read-only double sequence property commanded_virtual_positions. + */ + virtual ACS::ROdoubleSeq_ptr commanded_virtual_positions(); + /** * Returns a reference to the in_use property implementation of the IDL interface. * @return pointer to the read-only boolean property in_use. @@ -342,6 +348,11 @@ private: * Units of the virtual axes of the servo system. */ const std::vector m_virtual_axes_units; + + /** + * Latest commanded virtual positions. It only takes into account the preset command. + */ + std::vector m_commanded_virtual_positions; protected: /** * Dictionary containing the last status retrieved form the servo system. @@ -468,6 +479,11 @@ private: */ baci::SmartPropertyPointer m_virtual_system_offsets_ptr; + /** + * Pointer to the commanded_virtual_positions property. + */ + baci::SmartPropertyPointer m_commanded_virtual_positions_ptr; + /** * Pointer to the in_use property. */ @@ -538,6 +554,7 @@ protected: virtual ACS::ROdoubleSeq_ptr virtual_offsets() { return SRTBaseMinorServoImpl::virtual_offsets(); }\ virtual ACS::ROdoubleSeq_ptr virtual_user_offsets() { return SRTBaseMinorServoImpl::virtual_user_offsets(); }\ virtual ACS::ROdoubleSeq_ptr virtual_system_offsets() { return SRTBaseMinorServoImpl::virtual_system_offsets(); }\ + virtual ACS::ROdoubleSeq_ptr commanded_virtual_positions() { return SRTBaseMinorServoImpl::commanded_virtual_positions(); }\ virtual Management::ROTBoolean_ptr in_use() { return SRTBaseMinorServoImpl::in_use(); }\ virtual ACS::ROstring_ptr current_setup() { return SRTBaseMinorServoImpl::current_setup(); } diff --git a/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp b/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp index df2e50b72..dea56af00 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp @@ -41,6 +41,7 @@ SRTBaseMinorServoImpl::SRTBaseMinorServoImpl(const ACE_CString& component_name, m_virtual_offsets_ptr(this), m_virtual_user_offsets_ptr(this), m_virtual_system_offsets_ptr(this), + m_commanded_virtual_positions_ptr(this), m_in_use_ptr(this), m_current_setup_ptr(this), m_current_lookup_table(), @@ -85,6 +86,8 @@ void SRTBaseMinorServoImpl::initialize() new MSGenericDevIO>(m_user_offsets), true); m_virtual_system_offsets_ptr = new baci::ROdoubleSeq((m_component_name + ":virtual_system_offsets").c_str(), getComponent(), new MSGenericDevIO>(m_system_offsets), true); + m_commanded_virtual_positions_ptr = new baci::ROdoubleSeq((m_component_name + ":commanded_virtual_positions").c_str(), getComponent(), + new MSGenericDevIO>(m_commanded_virtual_positions), true); m_in_use_ptr = new ROEnumImpl((m_component_name + ":in_use").c_str(), getComponent(), new MSGenericDevIO>(m_in_use), true); m_current_setup_ptr = new baci::ROstring((m_component_name + ":current_setup").c_str(), getComponent(), @@ -190,12 +193,28 @@ void SRTBaseMinorServoImpl::stop() } } -void SRTBaseMinorServoImpl::preset(const ACS::doubleSeq& virtual_coordinates) +void SRTBaseMinorServoImpl::preset(const ACS::doubleSeq& virtual_coords) { AUTO_TRACE(m_servo_name + "::preset()"); checkLineStatus(); + ACS::doubleSeq virtual_coordinates; + virtual_coordinates.length(virtual_coords.length()); + std::copy(virtual_coords.begin(), virtual_coords.end(), virtual_coordinates.begin()); + + if(virtual_coordinates.length() == 0) + { + // It means we want to command the latest coordinates again, to apply the offset in the LDO servo system + // We execute the copy only if we already commanded a set of coordinates, otherwise we let the flow go to the next + // if which will raise regardless + if(!m_commanded_virtual_positions.empty()) + { + virtual_coordinates.length(m_commanded_virtual_positions.size()); + std::copy(m_commanded_virtual_positions.begin(), m_commanded_virtual_positions.end(), virtual_coordinates.begin()); + } + } + if(virtual_coordinates.length() != m_virtual_axes) { _EXCPT(MinorServoErrors::PositioningErrorExImpl, ex, (m_servo_name + "::preset()").c_str()); @@ -226,6 +245,12 @@ void SRTBaseMinorServoImpl::preset(const ACS::doubleSeq& virtual_coordinates) ex.log(LM_DEBUG); throw ex.getMinorServoErrorsEx(); } + + if(m_commanded_virtual_positions.empty()) + { + m_commanded_virtual_positions.resize(m_virtual_axes); + } + std::copy(coordinates.begin(), coordinates.end(), m_commanded_virtual_positions.begin()); } bool SRTBaseMinorServoImpl::setup(const char* configuration_name) @@ -807,5 +832,6 @@ GET_PROPERTY_REFERENCE(ACS::ROdoubleSeq, SRTBaseMinorServoImpl, m_virtual_positi GET_PROPERTY_REFERENCE(ACS::ROdoubleSeq, SRTBaseMinorServoImpl, m_virtual_offsets_ptr, virtual_offsets); GET_PROPERTY_REFERENCE(ACS::ROdoubleSeq, SRTBaseMinorServoImpl, m_virtual_user_offsets_ptr, virtual_user_offsets); GET_PROPERTY_REFERENCE(ACS::ROdoubleSeq, SRTBaseMinorServoImpl, m_virtual_system_offsets_ptr, virtual_system_offsets); +GET_PROPERTY_REFERENCE(ACS::ROdoubleSeq, SRTBaseMinorServoImpl, m_commanded_virtual_positions_ptr, commanded_virtual_positions); GET_PROPERTY_REFERENCE(Management::ROTBoolean, SRTBaseMinorServoImpl, m_in_use_ptr, in_use); GET_PROPERTY_REFERENCE(ACS::ROstring, SRTBaseMinorServoImpl, m_current_setup_ptr, current_setup); diff --git a/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp b/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp index 7c4052822..c529b0b0c 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp @@ -135,7 +135,6 @@ bool SRTMinorServoBossCore::status() { if(std::all_of(m_current_tracking_servos.begin(), m_current_tracking_servos.end(), [](const std::pair& servo) -> bool { - ACSErr::Completion_var comp; return servo.second->isTracking(); })) { @@ -194,6 +193,7 @@ void SRTMinorServoBossCore::setup(std::string commanded_setup) { cmd_configuration = DiscosConfigurationNameTable.at(commanded_setup); commanded_configuration = cmd_configuration.first; + if(m_as_configuration.load() == Management::MNG_TRUE && cmd_configuration.second) { commanded_setup += "_ASACTIVE"; @@ -586,7 +586,12 @@ void SRTMinorServoBossCore::clearUserOffsets(std::string servo_name) { for(const auto& [servo_name, servo] : m_current_servos) { - servo->clearUserOffsets(); + servo->clearUserOffsets(); + if(motion_status == MOTION_STATUS_CONFIGURED) + { + // We are not tracking but we need to update the servo position to load the offsets + servo->preset(ACS::doubleSeq()); + } } return; } @@ -602,6 +607,11 @@ void SRTMinorServoBossCore::clearUserOffsets(std::string servo_name) { auto servo = m_current_servos.at(servo_name); servo->clearUserOffsets(); + if(motion_status == MOTION_STATUS_CONFIGURED) + { + // We are not tracking but we need to update the servo position to load the offsets + servo->preset(ACS::doubleSeq()); + } } catch(std::out_of_range& oor) { @@ -658,6 +668,12 @@ void SRTMinorServoBossCore::setUserOffset(std::string servo_axis_name, double of ACS_LOG(LM_FULL_INFO, "setServoOffset", (LM_NOTICE, ("SETTING '" + servo_name + "' '" + axis_name + "' OFFSET TO " + std::to_string(offset)).c_str())); } servo->setUserOffset(axis_name.c_str(), offset); + + if(m_motion_status.load() == MOTION_STATUS_CONFIGURED) + { + // We are not tracking but we need to update the servo position to load the offsets + servo->preset(ACS::doubleSeq()); + } } catch(std::out_of_range& oor) { @@ -724,6 +740,11 @@ void SRTMinorServoBossCore::clearSystemOffsets(std::string servo_name) for(const auto& [servo_name, servo] : m_current_servos) { servo->clearSystemOffsets(); + if(motion_status == MOTION_STATUS_CONFIGURED) + { + // We are not tracking but we need to update the servo position to load the offsets + servo->preset(ACS::doubleSeq()); + } } return; } @@ -739,6 +760,11 @@ void SRTMinorServoBossCore::clearSystemOffsets(std::string servo_name) { auto servo = m_current_servos.at(servo_name); servo->clearSystemOffsets(); + if(motion_status == MOTION_STATUS_CONFIGURED) + { + // We are not tracking but we need to update the servo position to load the offsets + servo->preset(ACS::doubleSeq()); + } } catch(std::out_of_range& oor) { @@ -791,6 +817,12 @@ void SRTMinorServoBossCore::setSystemOffset(std::string servo_axis_name, double { auto servo = m_current_servos.at(servo_name); servo->setSystemOffset(axis_name.c_str(), offset); + + if(m_motion_status.load() == MOTION_STATUS_CONFIGURED) + { + // We are not tracking but we need to update the servo position to load the offsets + servo->preset(ACS::doubleSeq()); + } } catch(std::out_of_range& oor) { -- GitLab