From 7d5b9df215a94a366ef6ebd54705359230e885c3 Mon Sep 17 00:00:00 2001 From: Giuseppe Carboni <giuseppecarboni89@live.com> Date: Thu, 9 Jan 2025 16:03:48 +0000 Subject: [PATCH] Some Active Surface upgrades. This branch is meant to gather all the active surface updates for all the three stations. This will be merged onto centos_7_compatibility whenever the upgrade is done. --- .../src/ActiveSurfaceUSDImpl.cpp | 1 + .../SRTActiveSurfaceContainer01.xml | 1 - .../SRTActiveSurfaceContainer06.xml | 29 ++++-- .../SRTActiveSurfaceContainer07.xml | 2 +- .../include/SRTActiveSurfaceCore.h | 2 +- .../include/SRTActiveSurfaceGUIui.h | 2 +- .../src/SRTActiveSurfaceCore.cpp | 63 +++++++++--- .../src/SRTActiveSurfaceGUIui.cpp | 14 ++- .../include/SRTActiveSurfaceBossCore.h | 11 ++- .../include/SRTActiveSurfaceBossImpl.h | 5 +- ...SRTActiveSurfaceBossInitializationThread.h | 65 +++++++++++++ SRT/Servers/SRTActiveSurfaceBoss/src/Makefile | 2 +- .../src/SRTActiveSurfaceBossCore.cpp | 17 +--- .../src/SRTActiveSurfaceBossImpl.cpp | 45 +++------ ...TActiveSurfaceBossInitializationThread.cpp | 97 +++++++++++++++++++ .../src/SRTActiveSurfaceBossSectorThread.cpp | 1 - 16 files changed, 275 insertions(+), 82 deletions(-) create mode 100644 SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossInitializationThread.h create mode 100644 SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossInitializationThread.cpp diff --git a/Common/Servers/ActiveSurfaceUSD/src/ActiveSurfaceUSDImpl.cpp b/Common/Servers/ActiveSurfaceUSD/src/ActiveSurfaceUSDImpl.cpp index d9d23a795..eb5132b2b 100644 --- a/Common/Servers/ActiveSurfaceUSD/src/ActiveSurfaceUSDImpl.cpp +++ b/Common/Servers/ActiveSurfaceUSD/src/ActiveSurfaceUSDImpl.cpp @@ -144,6 +144,7 @@ void USDImpl::initialize() throw (ACSErr::ACSbaseExImpl) _SET_LDEF(acc, "USDImpl::initialize()"); _SET_LDEF(uBits, "USDImpl::initialize()"); } + _GET_PROP(status,m_status,"usdImpl::initialize()") } catch (ASErrors::ASErrorsEx& ex) { diff --git a/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer01/SRTActiveSurfaceContainer01.xml b/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer01/SRTActiveSurfaceContainer01.xml index 9fecba35d..f994d42ca 100644 --- a/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer01/SRTActiveSurfaceContainer01.xml +++ b/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer01/SRTActiveSurfaceContainer01.xml @@ -22,6 +22,5 @@ flushPeriodSeconds="1" > </LoggingConfig> - </Container> diff --git a/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer06/SRTActiveSurfaceContainer06.xml b/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer06/SRTActiveSurfaceContainer06.xml index 69ad936df..f994d42ca 100644 --- a/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer06/SRTActiveSurfaceContainer06.xml +++ b/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer06/SRTActiveSurfaceContainer06.xml @@ -1,11 +1,26 @@ -<?xml version='1.0' encoding='ISO-8859-1'?> -<!-- - - History: - - Tue Sep 23 09:22:44 UTC 2008 modified by jDAL ---> -<Container xmlns="urn:schemas-cosylab-com:Container:1.0" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:log="urn:schemas-cosylab-com:LoggingConfig:1.0" Timeout="30.0" ServerThreads="5" ImplLang="cpp"> +<?xml version="1.0" encoding="ISO-8859-1"?> + +<Container + xmlns="urn:schemas-cosylab-com:Container:1.0" + xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" + xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:log="urn:schemas-cosylab-com:LoggingConfig:1.0" + Timeout="30.0" + ServerThreads="5" + ImplLang="cpp"> + <Autoload> <cdb:e string="baci" /> </Autoload> - <LoggingConfig minLogLevel="5" minLogLevelLocal="10" dispatchPacketSize="0" immediateDispatchLevel="10" flushPeriodSeconds="1" /> + + <LoggingConfig + minLogLevel="5" + minLogLevelLocal="5" + dispatchPacketSize="0" + immediateDispatchLevel="10" + flushPeriodSeconds="1" + > + </LoggingConfig> </Container> + diff --git a/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer07/SRTActiveSurfaceContainer07.xml b/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer07/SRTActiveSurfaceContainer07.xml index c2efb0e9b..f994d42ca 100644 --- a/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer07/SRTActiveSurfaceContainer07.xml +++ b/SRT/CDB/MACI/Containers/SRTActiveSurfaceContainer07/SRTActiveSurfaceContainer07.xml @@ -17,7 +17,7 @@ <LoggingConfig minLogLevel="5" minLogLevelLocal="5" - dispatchPacketSize="10" + dispatchPacketSize="0" immediateDispatchLevel="10" flushPeriodSeconds="1" > diff --git a/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceCore.h b/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceCore.h index 6a466ae03..fb9586a1d 100644 --- a/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceCore.h +++ b/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceCore.h @@ -73,7 +73,7 @@ class SRTActiveSurfaceCore : public QThread int ActuatorStatusCalLabelCode; signals: - int setGUIActuatorColor(int, int, bool, bool); + int setGUIActuatorColor(int, int, bool, bool, bool); int setGUIAllActuators(bool callfromfunction = false); int setGUIcircleORradius(bool callfromfunction = false); int setGUIActuator(bool callfromfunction = false); diff --git a/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceGUIui.h b/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceGUIui.h index c2c110cb9..1a6f57b2c 100644 --- a/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceGUIui.h +++ b/SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceGUIui.h @@ -45,7 +45,7 @@ class SRTActiveSurfaceGUI : public QWidget, public Ui_SRTActiveSurfaceGUI void setactuator(); private slots: - void changeGUIActuatorColor(int, int, bool, bool); + void changeGUIActuatorColor(int, int, bool, bool, bool); void changeGUIAllActuators(bool callfromfunction = false); void changeGUIcircleORradius(bool callfromfunction = false); void changeGUIActuator(bool callfromfunction = false); diff --git a/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceCore.cpp b/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceCore.cpp index 112f53d86..d33ae2c26 100644 --- a/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceCore.cpp +++ b/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceCore.cpp @@ -8,6 +8,7 @@ #include <SRTActiveSurfaceCore.h> // mask pattern for status +#define UNAV 0xFF000000 #define MRUN 0x000080 #define CAMM 0x000100 #define ENBL 0x002000 @@ -123,13 +124,23 @@ void SRTActiveSurfaceCore::run(void) CORBA::Long status = asStatus[actuator - 1]; - bool active; - if ((status & ENBL) == 0) - active = false; + bool active, statusColor; + + if(status == UNAV) + active = false; // red else + { active = true; - emit setGUIActuatorColor(i, l, active, true); + if((status & ENBL) == 0 || (status & CAL) == 0) + { + statusColor = true; // yellow + } + else + statusColor = false; // green + } + + emit setGUIActuatorColor(i, l, active, statusColor, true); } /*CIRATools::getTime(clock); @@ -149,7 +160,8 @@ void SRTActiveSurfaceCore::setactuator(int circle, int actuator) CORBA::Long acc_val; CORBA::Long delay_val; CORBA::Long status; - + bool active; + bool statusColor; /* ActuatorNumber_str = QString("%1_%2").arg(circle).arg(actuator); @@ -182,41 +194,50 @@ void SRTActiveSurfaceCore::setactuator(int circle, int actuator) try { tASBoss->usdStatus4GUIClient(circle, actuator, status); + active = true; + } + catch (ComponentErrors::ComponentNotActiveExImpl& ex) { + active = false; + ex.log(LM_DEBUG); } catch (ComponentErrors::ComponentErrorsExImpl& ex) { //clearactuatorslineedit(); + active = false; ex.log(LM_DEBUG); } catch (CORBA::SystemException& sysEx) { + active = false; _EXCPT(ClientErrors::CORBAProblemExImpl,impl,"SRTActiveSurfaceGUIClient::SRTActiveSurfaceCore::setactuator()"); impl.setName(sysEx._name()); impl.setMinor(sysEx.minor()); impl.log(); } catch (...) { + active = false; _EXCPT(ClientErrors::UnknownExImpl,impl,"SRTActiveSurfaceGUIClient::SRTActiveSurfaceCore::setactuator()"); impl.log(); } - if ((status & ENBL) == 0) { + if (active == true) { + //if ((status & ENBL) == 0) { /*qApp->lock(); tGUI->ActuatorStatusEnblLabel->clear(); qApp->unlock(); qApp->lock(); tGUI->ActuatorStatusEnblLabel->setText("UNABLED"); qApp->unlock();*/ - ActuatorStatusEnblLabelCode = -1; - emit setGUIActuatorStatusEnblLabel(); - } - else { + //ActuatorStatusEnblLabelCode = -1; + //emit setGUIActuatorStatusEnblLabel(); + //} + //else { /*qApp->lock(); tGUI->ActuatorStatusEnblLabel->clear(); qApp->unlock(); qApp->lock(); tGUI->ActuatorStatusEnblLabel->setText("ENABLED"); qApp->unlock();*/ - ActuatorStatusEnblLabelCode = 1; - emit setGUIActuatorStatusEnblLabel(); + //ActuatorStatusEnblLabelCode = 1; + //emit setGUIActuatorStatusEnblLabel(); try { tASBoss->setActuator(circle, actuator, actPos_val, cmdPos_val, Fmin_val, Fmax_val, acc_val, delay_val); ActuatorActualPosition_str.setNum(actPos_val); @@ -256,7 +277,7 @@ void SRTActiveSurfaceCore::setactuator(int circle, int actuator) //ActuatorStatus_color.setRgb( 0, 170, 0 ); //setactuatorcolor(circle, actuator, ActuatorStatus_color); //theCircle = i; theActuator = l; - emit setGUIActuatorColor(circle, actuator, true, false); + //emit setGUIActuatorColor(circle, actuator, active, statusColor, false); //setactuatorstatuslabels(circle,actuator); //The status has been updated right before this if-else section, there is no need to ask it again @@ -304,31 +325,45 @@ void SRTActiveSurfaceCore::setactuator(int circle, int actuator) } if ((status & CAL) == 0) { ActuatorStatusCalLabelCode = -1; + statusColor = true; //tGUI->ActuatorStatusCalLabel->clear(); //tGUI->ActuatorStatusCalLabel->setText("UNCALIBRATED"); + //printf("uncalibrated\n"); + //emit setGUIActuatorColor(circle, actuator, false, false); } else { ActuatorStatusCalLabelCode = 1; + statusColor = false; //tGUI->ActuatorStatusCalLabel->clear(); //tGUI->ActuatorStatusCalLabel->setText("CALIBRATED"); } - emit setGUIActuatorStatusLabels(); + //emit setGUIActuatorStatusLabels(); + //emit setGUIActuatorColor(circle, actuator, active, statusColor, false); } catch (ComponentErrors::ComponentErrorsExImpl& ex) { // clearactuatorslineedit(); + active = false; ex.log(LM_DEBUG); } catch (CORBA::SystemException& sysEx) { + active = false; _EXCPT(ClientErrors::CORBAProblemExImpl,impl,"SRTActiveSurfaceGUIClient::SRTActiveSurfaceCore::setActuator()"); impl.setName(sysEx._name()); impl.setMinor(sysEx.minor()); impl.log(); } catch (...) { + active = false; _EXCPT(ClientErrors::UnknownExImpl,impl,"SRTActiveSurfaceGUIClient::SRTActiveSurfaceCore::setActuator()"); impl.log(); } } + else { + active = false; + statusColor = true; + } + emit setGUIActuatorStatusLabels(); + emit setGUIActuatorColor(circle, actuator, active, statusColor, false); } diff --git a/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceGUIui.cpp b/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceGUIui.cpp index 9abe44d9e..b672cbfb5 100644 --- a/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceGUIui.cpp +++ b/SRT/Clients/SRTActiveSurfaceGUIClient/src/SRTActiveSurfaceGUIui.cpp @@ -12,7 +12,7 @@ SRTActiveSurfaceGUI::SRTActiveSurfaceGUI(QWidget *parent) : QWidget(parent) { setupUi(this); - QObject::connect(&mySRTActiveSurfaceCore, SIGNAL(setGUIActuatorColor(int,int,bool,bool)), this, SLOT(changeGUIActuatorColor(int,int,bool,bool))); + QObject::connect(&mySRTActiveSurfaceCore, SIGNAL(setGUIActuatorColor(int,int,bool,bool,bool)), this, SLOT(changeGUIActuatorColor(int,int,bool,bool,bool))); QObject::connect(&mySRTActiveSurfaceCore, SIGNAL(setGUIAllActuators(bool)), this, SLOT(changeGUIAllActuators(bool))); QObject::connect(&mySRTActiveSurfaceCore, SIGNAL(setGUIcircleORradius(bool)), this, SLOT(changeGUIcircleORradius(bool))); QObject::connect(&mySRTActiveSurfaceCore, SIGNAL(setGUIActuator(bool)), this, SLOT(changeGUIActuator(bool))); @@ -526,7 +526,7 @@ void SRTActiveSurfaceGUI::recoverUSD() } } -void SRTActiveSurfaceGUI::changeGUIActuatorColor(int tcircle, int tactuator, bool active, bool fromRun) +void SRTActiveSurfaceGUI::changeGUIActuatorColor(int tcircle, int tactuator, bool active, bool statusColor, bool fromRun) { if (!fromRun) { @@ -542,13 +542,17 @@ void SRTActiveSurfaceGUI::changeGUIActuatorColor(int tcircle, int tactuator, boo QPushButton* ActuatorButton = this->findChild<QPushButton*>(ActuatorButtonName.str().c_str()); - if(active) + if(active == true && statusColor == false) // attivo e calibrato { - ActuatorButton->setStyleSheet("background-color: rgb(85, 255, 0)"); + ActuatorButton->setStyleSheet("background-color: rgb(85, 255, 0)"); // verde + } + else if (active == true && statusColor == true) // attivo e scalibrato + { + ActuatorButton->setStyleSheet("background-color: rgb(255, 255, 0)"); // giallo } else { - ActuatorButton->setStyleSheet("background-color: rgb(255, 0, 0)"); + ActuatorButton->setStyleSheet("background-color: rgb(255, 0, 0)"); // rosso } } diff --git a/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossCore.h b/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossCore.h index 89494afae..1531f90bb 100644 --- a/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossCore.h +++ b/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossCore.h @@ -46,6 +46,7 @@ #define DELTAEL 15.0 // mask pattern for status +#define UNAV 0xFF000000 #define MRUN 0x000080 #define CAMM 0x000100 #define ENBL 0x002000 @@ -80,6 +81,7 @@ class CSRTActiveSurfaceBossCore { //friend class CSRTActiveSurfaceBossWatchingThread; friend class CSRTActiveSurfaceBossWorkingThread; friend class CSRTActiveSurfaceBossSectorThread; + friend class CSRTActiveSurfaceBossInitializationThread; public: /** * Constructor. Default Constructor. @@ -188,9 +190,6 @@ private: int actuatorcounter, circlecounter, totacts; ACS::doubleSeq actuatorsCorrections; - /** pointer to the component itself */ - acscomponent::ACSComponentImpl *m_thisIsMe; - /** * This represents the status of the whole Active Surface subsystem, it also includes and sammerizes the status of the boss component */ @@ -220,15 +219,17 @@ private: char *s_usdCorrections; - std::vector<bool> m_sector; - bool m_profileSetted; bool m_ASup; bool m_newlut; + bool m_initialized; + std::string m_lut; + + std::vector<int> actuatorsInCircle; }; #endif /*SRTACTIVESURFACEBOSSCORE_H_*/ diff --git a/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossImpl.h b/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossImpl.h index d2f2c7be7..b57b172ea 100644 --- a/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossImpl.h +++ b/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossImpl.h @@ -30,11 +30,10 @@ #include <ManagementErrors.h> #include "SRTActiveSurfaceBossCore.h" #include "SRTActiveSurfaceBossWorkingThread.h" -#include "SRTActiveSurfaceBossSectorThread.h" +#include "SRTActiveSurfaceBossInitializationThread.h" #include <SP_parser.h> #define LOOPSTATUSTIME 10000000 // 1.0 second -#define SECTORTIME 1000000 // 0.1 seconds #define _SET_CDB(PROP,LVAL,ROUTINE) { \ maci::ContainerServices* cs=getContainerServices();\ @@ -213,7 +212,7 @@ class SRTActiveSurfaceBossImpl: public virtual CharacteristicComponentImpl, publ CSRTActiveSurfaceBossWorkingThread *m_workingThread; - std::vector<CSRTActiveSurfaceBossSectorThread*> m_sectorThread; + CSRTActiveSurfaceBossInitializationThread *m_initializationThread; SimpleParser::CParser<CSRTActiveSurfaceBossCore> *m_parser; diff --git a/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossInitializationThread.h b/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossInitializationThread.h new file mode 100644 index 000000000..274963ae0 --- /dev/null +++ b/SRT/Servers/SRTActiveSurfaceBoss/include/SRTActiveSurfaceBossInitializationThread.h @@ -0,0 +1,65 @@ +#ifndef _SRTACTIVESURFACEBOSSINITIALIZATIONTHREAD_H_ +#define _SRTACTIVESURFACEBOSSINITIALIZATIONTHREAD_H_ + +/********************************************************************************************/ +/* OAC Osservatorio Astronomico di Cagliari */ +/* $Id: SRTActiveSurfaceBossInitializationThread.h,v 1.1 2010-07-26 12:36:49 c.migoni Exp $ */ +/* */ +/* This code is under GNU General Public Licence (GPL). */ +/* */ +/* Who When What */ +/* Giuseppe Carboni (giuseppe.carboni@inaf.it) 09/01/2025 Creation */ +/********************************************************************************************/ + +#include <acsThread.h> +#include <IRA> +#include "SRTActiveSurfaceBossCore.h" +#include "SRTActiveSurfaceBossSectorThread.h" +#include <ComponentErrors.h> + +#define SECTORTIME 1000000 // 0.1 seconds + +/** + * This class implements an initialization thread. This thread is in charge of setting up the active surface +*/ +class CSRTActiveSurfaceBossInitializationThread : public ACS::Thread +{ +public: + /** + * Constructor(). + * @param name thread name + * @param responseTime thread's heartbeat response time in 100ns unit. Default value is 1s. + * @param sleepTime thread's sleep time in 100ns unit. Default value is 100ms. + */ + CSRTActiveSurfaceBossInitializationThread(const ACE_CString& name, CSRTActiveSurfaceBossCore *param, + const ACS::TimeInterval& responseTime=ThreadBase::defaultResponseTime,const ACS::TimeInterval& sleepTime=ThreadBase::defaultSleepTime); + + /** + * Destructor. + */ + ~CSRTActiveSurfaceBossInitializationThread(); + + /** + * This method is executed once when the thread starts. + */ + virtual void onStart(); + + /** + * This method is executed once when the thread stops. + */ + virtual void onStop(); + + /** + * This method overrides the thread implementation class. + * The thread can be exited by calling ACS::ThreadBase::stop or ACS::ThreadBase::exit command. + */ + virtual void runLoop(); + +private: + CSRTActiveSurfaceBossCore *m_boss; + std::string m_thread_name; + ACS::Time timestart; + std::vector<CSRTActiveSurfaceBossSectorThread*> m_sectorThread; +}; + +#endif /*_SRTACTIVESURFACEBOSSINITIALIZATIONTHREAD_H_*/ diff --git a/SRT/Servers/SRTActiveSurfaceBoss/src/Makefile b/SRT/Servers/SRTActiveSurfaceBoss/src/Makefile index c9a65272d..b55f8c367 100644 --- a/SRT/Servers/SRTActiveSurfaceBoss/src/Makefile +++ b/SRT/Servers/SRTActiveSurfaceBoss/src/Makefile @@ -83,7 +83,7 @@ LIBRARIES = SRTActiveSurfaceBossImpl LIBRARIES_L = # # <brief description of lllll library> -SRTActiveSurfaceBossImpl_OBJECTS = SRTActiveSurfaceBossImpl SRTActiveSurfaceBossCore SRTActiveSurfaceBossWorkingThread SRTActiveSurfaceBossSectorThread +SRTActiveSurfaceBossImpl_OBJECTS = SRTActiveSurfaceBossImpl SRTActiveSurfaceBossCore SRTActiveSurfaceBossWorkingThread SRTActiveSurfaceBossInitializationThread SRTActiveSurfaceBossSectorThread SRTActiveSurfaceBossImpl_LIBS = lanStubs usdStubs ActiveSurfaceBossStubs SRTActiveSurfaceBossStubs AntennaDefinitionsStubs ManagmentDefinitionsStubs AntennaBossStubs ComponentErrors ASErrors ManagementErrors AntennaErrors IRALibrary ParserErrors DiscosVersion # diff --git a/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossCore.cpp b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossCore.cpp index bfe1c7c69..78db1dae9 100644 --- a/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossCore.cpp +++ b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossCore.cpp @@ -2,11 +2,9 @@ #include <Definitions.h> #include <cstdio> -int actuatorsInCircle[] = {0,24,24,48,48,48,48,96,96,96,96,96,96,96,96,96,8,4}; - CSRTActiveSurfaceBossCore::CSRTActiveSurfaceBossCore(ContainerServices *service, acscomponent::ACSComponentImpl *me) : m_services(service), - m_thisIsMe(me) + actuatorsInCircle{0,24,24,48,48,48,48,96,96,96,96,96,96,96,96,96,8,4} { m_error_strings[ASErrors::NoError ] = "NoError"; m_error_strings[ASErrors::USDCalibrated ] = "USD calibrated"; @@ -43,6 +41,7 @@ void CSRTActiveSurfaceBossCore::initialize() { ACS_LOG(LM_FULL_INFO,"CSRTActiveSurfaceBossCore::initialize()",(LM_INFO,"CSRTActiveSurfaceBossCore::initialize")); + m_initialized = false; m_enable = false; m_tracking = false; m_status = Management::MNG_WARNING; @@ -50,7 +49,6 @@ void CSRTActiveSurfaceBossCore::initialize() actuatorcounter = circlecounter = totacts = 1; for(int i = 0; i < SECTORS; i++) { - m_sector.push_back(false); usdCounters.push_back(0); } m_profileSetted = false; @@ -1366,16 +1364,10 @@ void CSRTActiveSurfaceBossCore::asSetLUT(const char *newlut) void CSRTActiveSurfaceBossCore::setProfile(const ActiveSurface::TASProfile& newProfile) throw (ComponentErrors::ComponentErrorsExImpl) { - bool all_sectors = true; - for(unsigned int i = 0; i < SECTORS; i++) - { - if(!m_sector[i]) all_sectors = false; - } - if (m_newlut == false) m_lut = USDTABLECORRECTIONS; - if(all_sectors) // USD tables has not been loaded yet + if(m_initialized) // USD tables has not been loaded yet { ifstream usdCorrections(m_lut); if(!usdCorrections) @@ -1640,7 +1632,8 @@ void CSRTActiveSurfaceBossCore::asStatus4GUIClient(ACS::longSeq& status) throw ( { for (int actuator = 1; actuator <= actuatorsInCircle[circle]; actuator++) { - int usdStatus = 0; + // Initialize the status word as component unavailable. If the component is available it will be overwritten + int usdStatus = UNAV; if(!CORBA::is_nil(usd[circle][actuator])) { diff --git a/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossImpl.cpp b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossImpl.cpp index 54cb831db..117fec854 100644 --- a/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossImpl.cpp +++ b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossImpl.cpp @@ -125,25 +125,18 @@ void SRTActiveSurfaceBossImpl::initialize() throw (ACSErr::ACSbaseExImpl) _THROW_EXCPT(ComponentErrors::UnexpectedExImpl,"SRTActiveSurfaceBossImpl::initialize()"); } - for(int sector = 0; sector < SECTORS; sector++) + try { - std::stringstream threadName; - threadName << "SRTACTIVESURFACEBOSSSECTOR"; - threadName << sector+1; - try - { - CSRTActiveSurfaceBossSectorThread* sectorThread = getContainerServices()->getThreadManager()->create<CSRTActiveSurfaceBossSectorThread,CSRTActiveSurfaceBossCore *> (threadName.str().c_str(), boss); - m_sectorThread.push_back(sectorThread); - } - catch (acsthreadErrType::acsthreadErrTypeExImpl& ex) - { - _ADD_BACKTRACE(ComponentErrors::ThreadErrorExImpl,_dummy,ex,"SRTActiveSurfaceBossImpl::initialize()"); - throw _dummy; - } - catch (...) - { - _THROW_EXCPT(ComponentErrors::UnexpectedExImpl,"SRTActiveSurfaceBossImpl::initialize()"); - } + m_initializationThread=getContainerServices()->getThreadManager()->create<CSRTActiveSurfaceBossInitializationThread,CSRTActiveSurfaceBossCore *>("SRTACTIVESURFACEBOSSINITTHREAD",boss); + } + catch (acsthreadErrType::acsthreadErrTypeExImpl& ex) + { + _ADD_BACKTRACE(ComponentErrors::ThreadErrorExImpl,_dummy,ex,"SRTActiveSurfaceBossImpl::initialize()"); + throw _dummy; + } + catch (...) + { + _THROW_EXCPT(ComponentErrors::UnexpectedExImpl,"SRTActiveSurfaceBossImpl::initialize()"); } // configure the parser..... @@ -170,12 +163,7 @@ void SRTActiveSurfaceBossImpl::execute() throw (ACSErr::ACSbaseExImpl) throw _dummy; } m_workingThread->resume(); - - for(unsigned int i = 0; i < m_sectorThread.size(); i++) - { - m_sectorThread[i]->setSleepTime(SECTORTIME); - m_sectorThread[i]->resume(); - } + m_initializationThread->resume(); ACS_LOG(LM_FULL_INFO,"SRTActiveSurfaceBossImpl::execute()",(LM_INFO,"SRTActiveSurfaceBossImpl::COMPSTATE_OPERATIONAL")); } @@ -188,13 +176,10 @@ void SRTActiveSurfaceBossImpl::cleanUp() m_workingThread->suspend(); getContainerServices()->getThreadManager()->destroy(m_workingThread); } - for(unsigned int i = 0; i < m_sectorThread.size(); i++) + if (m_initializationThread!=NULL) { - if(m_sectorThread[i] != NULL) - { - m_sectorThread[i]->suspend(); - getContainerServices()->getThreadManager()->destroy(m_sectorThread[i]); - } + m_initializationThread->suspend(); + getContainerServices()->getThreadManager()->destroy(m_initializationThread); } ACS_LOG(LM_FULL_INFO,"SRTActiveSurfaceBossImpl::cleanUp()",(LM_INFO,"SRTActiveSurfaceBossImpl::THREADS_TERMINATED")); if (m_parser!=NULL) delete m_parser; diff --git a/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossInitializationThread.cpp b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossInitializationThread.cpp new file mode 100644 index 000000000..007a43ac8 --- /dev/null +++ b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossInitializationThread.cpp @@ -0,0 +1,97 @@ +#include "SRTActiveSurfaceBossInitializationThread.h" + +CSRTActiveSurfaceBossInitializationThread::CSRTActiveSurfaceBossInitializationThread(const ACE_CString& name, CSRTActiveSurfaceBossCore *param, + const ACS::TimeInterval& responseTime,const ACS::TimeInterval& sleepTime) : ACS::Thread(name,responseTime,sleepTime), m_boss(param) +{ + m_thread_name = "SRTActiveSurfaceBossInitializationThread"; + + this->setSleepTime(1000000); + + AUTO_TRACE(std::string(m_thread_name + "::CSRTActiveSurfaceBossInitializationThread()").c_str()); +} + +CSRTActiveSurfaceBossInitializationThread::~CSRTActiveSurfaceBossInitializationThread() +{ + for(unsigned int i = 0; i < m_sectorThread.size(); i++) + { + if(m_sectorThread[i] != NULL) + { + m_sectorThread[i]->suspend(); + m_boss->m_services->getThreadManager()->destroy(m_sectorThread[i]); + } + } + + AUTO_TRACE(std::string(m_thread_name + "::~CSRTActiveSurfaceBossInitializationThread()").c_str()); +} + +void CSRTActiveSurfaceBossInitializationThread::onStart() +{ + AUTO_TRACE(std::string(m_thread_name + "::onStart()").c_str()); + + for(int sector = 0; sector < SECTORS; sector++) + { + std::stringstream threadName; + threadName << "SRTACTIVESURFACEBOSSSECTOR"; + threadName << sector+1; + try + { + CSRTActiveSurfaceBossSectorThread* sectorThread = m_boss->m_services->getThreadManager()->create<CSRTActiveSurfaceBossSectorThread,CSRTActiveSurfaceBossCore *> (threadName.str().c_str(), m_boss); + sectorThread->setSleepTime(SECTORTIME); + sectorThread->resume(); + m_sectorThread.push_back(sectorThread); + } + catch (acsthreadErrType::acsthreadErrTypeExImpl& ex) + { + _ADD_BACKTRACE(ComponentErrors::ThreadErrorExImpl,_dummy,ex,"SRTActiveSurfaceBossInitializationThread::onStart()"); + throw _dummy; + } + catch (...) + { + _THROW_EXCPT(ComponentErrors::UnexpectedExImpl,"SRTActiveSurfaceBossInitializationThread::onStart()"); + } + } + + TIMEVALUE now; + CIRATools::getTime(now); + this->timestart = now.value().value; +} + +void CSRTActiveSurfaceBossInitializationThread::onStop() +{ + m_boss->m_initialized = true; + + ACS_LOG(LM_FULL_INFO, std::string(m_thread_name + "::onStop()").c_str(), (LM_NOTICE, "ACTIVE SURFACE INITIALIZED")); + + AUTO_TRACE(std::string(m_thread_name + "::onStop()").c_str()); +} + +void CSRTActiveSurfaceBossInitializationThread::runLoop() +{ + for(unsigned int i = 0; i < m_sectorThread.size(); i++) + { + if(m_sectorThread[i]->isAlive()) + { + return; + } + } + + // Set CDB calibrate parameter to 0 where needed + for(int circle = 1; circle <= CIRCLES; circle++) + { + for(int actuator = 1; actuator <= m_boss->actuatorsInCircle[circle]; actuator++) + { + if(!CORBA::is_nil(m_boss->usd[circle][actuator])) + { + int usdStatus = 0; + m_boss->usd[circle][actuator]->getStatus(usdStatus); + + if(!(usdStatus & CAL)) + { + CIRATools::setDBValue(m_boss->m_services, "calibrate", (const long)0, "alma/", m_boss->usd[circle][actuator]->name()); + } + } + } + } + + this->setStopped(); +} diff --git a/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossSectorThread.cpp b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossSectorThread.cpp index 0d35aed43..5abef165e 100644 --- a/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossSectorThread.cpp +++ b/SRT/Servers/SRTActiveSurfaceBoss/src/SRTActiveSurfaceBossSectorThread.cpp @@ -83,7 +83,6 @@ void CSRTActiveSurfaceBossSectorThread::runLoop() } else { - m_boss->m_sector[m_sector] = true; this->setStopped(); } } -- GitLab