From d90015c3c02d7d36f13b54875cc6b6d39443fde6 Mon Sep 17 00:00:00 2001 From: Andrea Orlati Date: Tue, 4 Jan 2022 16:17:40 +0000 Subject: [PATCH] fix issue #655: feature implemented but a test is required before merging into the repository --- CHANGELOG.md | 1 + Medicina/CDB/alma/ANTENNA/Mount/Mount.xml | 1 + .../CDB/alma/ANTENNA/Mount/Mount.xml | 1 + .../config/CDB/schemas/MedicinaMount.xsd | 2 ++ .../MedicinaMount/include/Configuration.h | 10 ++++--- .../include/MedicinaMountSocket.h | 21 +++++++++++++-- .../MedicinaMount/src/Configuration.cpp | 7 ++++- .../MedicinaMount/src/MedicinaMountSocket.cpp | 27 +++++++++++++++++-- .../MedicinaMount/src/MedicinaMountThread.cpp | 1 + Noto/CDB/alma/ANTENNA/Mount/Mount.xml | 1 + .../CDB/alma/ANTENNA/Mount/Mount.xml | 1 + 11 files changed, 65 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b8b90a97..94fe46883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/ ## [next release] ## Added + issue 655 - ACU Component for Noto and Medicina is now capble to prevent seldom mode changes coming from ACU reset ## Fixed issue #448 - Added Sky Offsets to calibration tool client issue #585 - Fixed misshandled schedule with NULL as backend (Dry Run) diff --git a/Medicina/CDB/alma/ANTENNA/Mount/Mount.xml b/Medicina/CDB/alma/ANTENNA/Mount/Mount.xml index 0dca04b5f..60cdd2868 100644 --- a/Medicina/CDB/alma/ANTENNA/Mount/Mount.xml +++ b/Medicina/CDB/alma/ANTENNA/Mount/Mount.xml @@ -15,6 +15,7 @@ ControlThreadPeriod="200000" RepetitionCacheTime="2000000" RepetitionExpireTime="5000000" + CheckMode="false" CheckOscillation="true" OscillationThreshold="0.01" OscillationAlarmDuration="2000000" diff --git a/Medicina/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml b/Medicina/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml index 0dca04b5f..60cdd2868 100644 --- a/Medicina/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml +++ b/Medicina/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml @@ -15,6 +15,7 @@ ControlThreadPeriod="200000" RepetitionCacheTime="2000000" RepetitionExpireTime="5000000" + CheckMode="false" CheckOscillation="true" OscillationThreshold="0.01" OscillationAlarmDuration="2000000" diff --git a/Medicina/Servers/MedicinaMount/config/CDB/schemas/MedicinaMount.xsd b/Medicina/Servers/MedicinaMount/config/CDB/schemas/MedicinaMount.xsd index 7dbd34735..8b6d4af50 100644 --- a/Medicina/Servers/MedicinaMount/config/CDB/schemas/MedicinaMount.xsd +++ b/Medicina/Servers/MedicinaMount/config/CDB/schemas/MedicinaMount.xsd @@ -101,6 +101,8 @@ + + diff --git a/Medicina/Servers/MedicinaMount/include/Configuration.h b/Medicina/Servers/MedicinaMount/include/Configuration.h index dcee4e1e1..84d00bdb1 100644 --- a/Medicina/Servers/MedicinaMount/include/Configuration.h +++ b/Medicina/Servers/MedicinaMount/include/Configuration.h @@ -99,9 +99,12 @@ public: /** Gets the number of times the oscillation has to be hit before an oscillation is declared*/ inline DWORD oscillationNumberThreashold() const { return m_dwoscNumberThreshold; } - /** Flag that indicates whether the oscillation chek must performed or not. */ + /** Flag that indicates whether the oscillation check must performed or not. */ inline bool checkForOscillation() const { return m_checkOsc; } + /** Flag that indicates whether the ACU check mode must performed or not. */ + inline bool checkForMode() const { return m_checkMode; } + /** * This member function is used to configure component by reading the configuration parameter from the CDB. * This must be the first call before using any other function of this class. @@ -139,9 +142,9 @@ private: DWORD m_dwcontrolThreadPeriod; /** This is the precision (degree) of the antenna */ //double m_dtrackingPrecision; - /** This indicates the cache time for the repetion log filter */ + /** This indicates the cache time for the repetition log filter */ DDWORD m_dwrepetitionCacheTime; - /** This indicates the expire time for the repetion log filter */ + /** This indicates the expire time for the repetition log filter */ DDWORD m_dwexpireCacheTime; /** this number is the separation value between the CW and CCW, if the azimuth is greater than this the section is CW */ double m_cwLimit; @@ -151,6 +154,7 @@ private: WORD m_dwoscNumberThreshold; DDWORD m_dwoscRecoverTime; bool m_checkOsc; + bool m_checkMode; }; diff --git a/Medicina/Servers/MedicinaMount/include/MedicinaMountSocket.h b/Medicina/Servers/MedicinaMount/include/MedicinaMountSocket.h index 45f9d1ed5..adaefefe5 100644 --- a/Medicina/Servers/MedicinaMount/include/MedicinaMountSocket.h +++ b/Medicina/Servers/MedicinaMount/include/MedicinaMountSocket.h @@ -447,10 +447,22 @@ public: * 1) if the tracking error is beyond a threashold an alarm condition is triggered. This condition has a certain validity time. * 2) If more than a number of direction changes (of the tracking error with respect to the zero error) are detected during the alarm time window, the oscillation is declared- * 3) The alarm condition is cleared if the time validity window of the alarm elapsed and the tracking error is again under the threshold. - * In case of detection counter mesures are immediately taken. + * In case of detection counter measures are immediately taken. */ void detectOscillation() throw (AntennaErrors::ConnectionExImpl,ComponentErrors::SocketErrorExImpl,ComponentErrors::TimeoutExImpl,AntennaErrors::NakExImpl,AntennaErrors::AntennaBusyExImpl); - + + /** + * This method has been added to detect the event the ACU mode differs from previously commanded. In case it tries to + * recover from this event by commandind the correct mode. + * @throw AntennaErrors::ConnectionExImpl + * @throw ComponentErrors::SocketErrorExImpl + * @throw ComponentErrors::TimeoutExImpl + * @throw AntennaErrors::NakExImpl + * @throwAntennaErrors::AntennaBusyExImpl + */ + void checkCommandedMode() throw (AntennaErrors::ConnectionExImpl,ComponentErrors::SocketErrorExImpl, + ComponentErrors::TimeoutExImpl,AntennaErrors::NakExImpl,AntennaErrors::AntennaBusyExImpl); + /** * This member function is used by the control thread in order to check if a long job that was started as completed or not. * @param job job identifier @@ -607,6 +619,11 @@ private: */ CACUInterface::TAxeModes m_oscMode; + /** + * this flag indicates that a recovery from mode check in ongoing..... + */ + bool m_modeCheckRecover; + /** * Stores the epoch of the last scan. Used in oscillation prevention */ diff --git a/Medicina/Servers/MedicinaMount/src/Configuration.cpp b/Medicina/Servers/MedicinaMount/src/Configuration.cpp index f7504523d..ebd3b3b2b 100644 --- a/Medicina/Servers/MedicinaMount/src/Configuration.cpp +++ b/Medicina/Servers/MedicinaMount/src/Configuration.cpp @@ -66,6 +66,11 @@ void CConfiguration::Init(maci::ContainerServices *Services) throw (ComponentErr _GET_DOUBLE_ATTRIBUTE("cw_ccw_limit","CW/CCW limit (degrees):",m_cwLimit,"DataBlock/Mount"); _GET_STRING_ATTRIBUTE("CheckOscillation","Check oscillation during tracking: ",check,""); + m_checkOsc=(check=="TRUE"); + + _GET_STRING_ATTRIBUTE("CheckMode","Check ACU mode enabled: ",check,""); + m_checkMode=(check=="TRUE"); + _GET_DOUBLE_ATTRIBUTE("OscillationThreshold","Oscillation theshold (deg):",m_doscThreashold,""); _GET_DWORD_ATTRIBUTE("OscillationAlarmDuration","Oscillation alarm duration (uSec):",m_dwoscAlarmDuration,""); _GET_DWORD_ATTRIBUTE("OscillationNumberThreshold","Oscillation number threashold:",m_dwoscNumberThreshold,""); @@ -74,5 +79,5 @@ void CConfiguration::Init(maci::ContainerServices *Services) throw (ComponentErr m_dwoscRecoverTime*=10; m_dwcontrolThreadPeriod*=10; check.MakeUpper(); - m_checkOsc=(check=="TRUE"); + } diff --git a/Medicina/Servers/MedicinaMount/src/MedicinaMountSocket.cpp b/Medicina/Servers/MedicinaMount/src/MedicinaMountSocket.cpp index 00c5a72f6..16ff05276 100644 --- a/Medicina/Servers/MedicinaMount/src/MedicinaMountSocket.cpp +++ b/Medicina/Servers/MedicinaMount/src/MedicinaMountSocket.cpp @@ -130,6 +130,7 @@ void CMedicinaMountSocket::Init(CConfiguration *config,maci::ContainerServices * m_oscStopTime=0; m_oscMode=CACUInterface::STANDBY; m_lastScanEpoch=0; + m_modeCheckRecover=false; } CACUInterface::TAxeModes CMedicinaMountSocket::getAzimuthMode() throw (ConnectionExImpl,SocketErrorExImpl,TimeoutExImpl) @@ -587,8 +588,11 @@ void CMedicinaMountSocket::Mode(CACUInterface::TAxeModes azMode,CACUInterface::T TIMEVALUE now; IRA::CIRATools::getTime(now); m_Data.setLastCommandedMode(azMode); - m_Data.setAzimuthOffset(0.0); - m_Data.setElevationOffset(0.0); + if (!m_modeCheckRecover) { // need to keep current offsets in case a recovery procedure is ongoing..... + m_Data.setAzimuthOffset(0.0); + m_Data.setElevationOffset(0.0); + m_modeCheckRecover=false; + } m_lastScanEpoch=now.value().value; } @@ -844,6 +848,25 @@ double CMedicinaMountSocket::getHWAzimuth(double destination,const CACUInterface return CIRATools::getHWAzimuth(pos,dest,m_configuration->azimuthLowerLimit(),m_configuration->azimuthUpperLimit(),section,m_configuration->cwLimit()); } +void CMedicinaMountSocket::checkCommandedMode() throw (ConnectionExImpl,SocketErrorExImpl,TimeoutExImpl,AntennaErrors::NakExImpl,AntennaBusyExImpl) +{ + CACUInterface::TAxeModes commandedMode, mode; + if (!m_configuration->checkForMode()) return; + commandedMode=m_Data.getLastCommandedMode(); + if ((commandedMode!=CACUInterface::STANDBY) && (commandedMode!=CACUInterface::UNSTOW) && + (commandedMode!=CACUInterface::STOW) && (commandedMode!=CACUInterface::STOP)) { + mode=getAzimuthMode(); // throw (ConnectionExImpl,SocketErrorExImpl,TimeoutExImpl) + if ((mode!=CACUInterface::UNKNOWN)) { + if ((commandedMode!=mode)) { + CUSTOM_LOG(LM_FULL_INFO,"CMedicinaMountSocket::checkCommandedMode()", + (LM_WARNING,"ACU operation mode differs from commanded one, trying to recover...")); + m_modeCheckRecover=true; + Mode(commandedMode,commandedMode); + } + } + } +} + void CMedicinaMountSocket::detectOscillation() throw (ConnectionExImpl,SocketErrorExImpl,TimeoutExImpl,AntennaErrors::NakExImpl,AntennaBusyExImpl) { TIMEVALUE now; diff --git a/Medicina/Servers/MedicinaMount/src/MedicinaMountThread.cpp b/Medicina/Servers/MedicinaMount/src/MedicinaMountThread.cpp index 695d389de..4236c18ae 100644 --- a/Medicina/Servers/MedicinaMount/src/MedicinaMountThread.cpp +++ b/Medicina/Servers/MedicinaMount/src/MedicinaMountThread.cpp @@ -51,6 +51,7 @@ void CMedicinaMountControlThread::runLoop() CSecAreaResourceWrapper socket=m_pACUControl->Get(); socket->updateComponent(); // before commenting out or deleting consider that inside this method the flushing of pending event of the log dike object is called socket->detectOscillation(); + socket->checkCommandedMode(); if (currentJobID!=0) { ACSErr::Completion_var comp; if (socket->updateLongJobs(currentJobID,comp.out())) { diff --git a/Noto/CDB/alma/ANTENNA/Mount/Mount.xml b/Noto/CDB/alma/ANTENNA/Mount/Mount.xml index 44c2fc8ea..c909831dd 100644 --- a/Noto/CDB/alma/ANTENNA/Mount/Mount.xml +++ b/Noto/CDB/alma/ANTENNA/Mount/Mount.xml @@ -15,6 +15,7 @@ ControlThreadPeriod="200000" RepetitionCacheTime="2000000" RepetitionExpireTime="5000000" + CheckMode="true" CheckOscillation="true" OscillationThreshold="0.01" OscillationAlarmDuration="2000000" diff --git a/Noto/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml b/Noto/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml index 44c2fc8ea..c909831dd 100644 --- a/Noto/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml +++ b/Noto/Configuration/CDB/alma/ANTENNA/Mount/Mount.xml @@ -15,6 +15,7 @@ ControlThreadPeriod="200000" RepetitionCacheTime="2000000" RepetitionExpireTime="5000000" + CheckMode="true" CheckOscillation="true" OscillationThreshold="0.01" OscillationAlarmDuration="2000000" -- GitLab