diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b8b90a97c40c01b7cca0208235ca9e54dad0850..94fe468832574cb0fade71c23f4a6e3c08dfd20d 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 0dca04b5fb042fc19cbd7d7762322fc8fd34648e..60cdd2868a1b40d8aedea7dd05b1b4a87a43febe 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 0dca04b5fb042fc19cbd7d7762322fc8fd34648e..60cdd2868a1b40d8aedea7dd05b1b4a87a43febe 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 7dbd347358286a71c69ca20c0a0db90c4da7ae54..8b6d4af508a7146f53f8c9dcb00ad6599d8e093c 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 dcee4e1e1d239012ec375be0da12c9f44db8851b..84d00bdb16199b8e2ebded15c9d852c1df6d823e 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 45f9d1ed5c756312f9a71f3868eadeb7021fbcb7..adaefefe5e70e4e2aac8983d2c0f6b82fa685a1d 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 f7504523db58f2cbb26c7b5b3853cde418ebef2a..ebd3b3b2b5b39cfed7c43b133495e651a611ca70 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 00c5a72f60273e17c634b430836803e5931ebc6f..16ff052767a4258eda05ed167c548b383c725150 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 695d389de19c01725a9c09316bf8b19d8cdeb131..4236c18ae9a3c2d89a6a5c22fea88ef43b0517d5 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 44c2fc8ea4ff976d3a35d2b81c98b4b32da5a4d3..c909831dd49659319fb5fba34536ad397d602f42 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 44c2fc8ea4ff976d3a35d2b81c98b4b32da5a4d3..c909831dd49659319fb5fba34536ad397d602f42 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"