From 4b6050ebba250b94ff2e7ea73a8d282953f9c915 Mon Sep 17 00:00:00 2001 From: Giuseppe Carboni Date: Sat, 1 Jun 2024 10:45:43 +0200 Subject: [PATCH] Updated minor servos (#871) * Fix #865, fix #869, updated SRTMinorServo component The component now handles correctly a SETUP command. The component is also capable of commanding the gregorian air blade with the 'setGregorianAirBladeStatus' command. A few bugs were fixed here and there. This branch MUST be tested with the real hardware before merging it onto the centos_7_compatibility branch. * Fixed small bug * Various upgrades * Updated _airBlade.py and _servoReset.py * Updated _servoReset * Updated telescopePark procedure commands order With this order, the gregorian cover is started parking when the antenna is already at 89.8 degrees of elevation. This will avoid getting an error on a gregorian cover axis pre limit. Unfortunately, this will not fix a change in configuration from primary to gregorian or BWG and vice versa. That will need to be addressed by opening a ticket. * Upgraded _servoReset behahviour --- .../src/MinorServoBossTextClient.cpp | 2 +- .../SystemTerminal/src/nuraghe_commands.py | 41 ++++- Common/Servers/Scheduler/src/Core.cpp | 3 + .../GFR/LookupTables/LookupTables.xml | 10 +- .../DataBlock/MinorServo/Tabella Setup.csv | 14 ++ SRT/CDB/alma/MINORSERVO/Boss/Boss.xml | 4 +- 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 + SRT/CDB/alma/MINORSERVO/VBrain/VBrain.xml | 13 ++ .../StationProcedures/StationProcedures.xml | 6 +- .../GFR/LookupTables/LookupTables.xml | 10 +- .../CDB/alma/MINORSERVO/Boss/Boss.xml | 4 +- .../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 + .../CDB/alma/MINORSERVO/VBrain/VBrain.xml | 13 ++ .../StationProcedures/StationProcedures.xml | 6 +- .../idl/SRTMinorServo.idl | 16 ++ .../idl/SRTMinorServoBoss.idl | 26 ++- .../idl/SRTMinorServoCommon.midl | 28 ++++ .../include/SRTMinorServoContainers.h | 20 ++- .../src/SRTMinorServoSocket.cpp | 16 +- .../config/CDB/schemas/SRTMinorServo.xsd | 27 +-- .../config/CDB/schemas/SRTMinorServoBoss.xsd | 40 +---- .../CDB/schemas/SRTMinorServoCommon.xsd | 90 ++++++++++ .../SRTMinorServoVBrainConfiguration.xsd | 33 ++++ SRT/Servers/SRTMinorServo/include/MSDevIOs.h | 75 ++++++++- .../include/SRTMinorServoBossCore.h | 22 ++- .../include/SRTMinorServoBossImpl.h | 35 ++++ .../SRTMinorServo/include/SRTMinorServoImpl.h | 44 ++++- .../include/SRTMinorServoTrackingThread.h | 5 - SRT/Servers/SRTMinorServo/src/Makefile | 4 +- .../src/SRTBaseMinorServoImpl.cpp | 63 +++++-- .../src/SRTMinorServoBossCore.cpp | 156 ++++++++++++++---- .../src/SRTMinorServoBossImpl.cpp | 26 ++- .../src/SRTMinorServoParkThread.cpp | 9 +- .../src/SRTMinorServoScanThread.cpp | 3 +- .../src/SRTMinorServoSetupThread.cpp | 100 ++++++----- .../src/SRTMinorServoTrackingThread.cpp | 21 +-- .../src/SRTProgramTrackMinorServoImpl.cpp | 86 ++++++---- SRT/Servers/SRTMinorServo/src/_airBlade.py | 42 +++++ SRT/Servers/SRTMinorServo/src/_servoReset.py | 91 ++++++++++ 45 files changed, 951 insertions(+), 261 deletions(-) create mode 100644 SRT/CDB/alma/DataBlock/MinorServo/Tabella Setup.csv create mode 100644 SRT/CDB/alma/MINORSERVO/VBrain/VBrain.xml create mode 100644 SRT/Configuration/CDB/alma/MINORSERVO/VBrain/VBrain.xml create mode 100644 SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoCommon.xsd create mode 100644 SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoVBrainConfiguration.xsd create mode 100644 SRT/Servers/SRTMinorServo/src/_airBlade.py create mode 100644 SRT/Servers/SRTMinorServo/src/_servoReset.py diff --git a/Common/Clients/MinorServoBossTextClient/src/MinorServoBossTextClient.cpp b/Common/Clients/MinorServoBossTextClient/src/MinorServoBossTextClient.cpp index 9a5baeeab..0bd15151b 100644 --- a/Common/Clients/MinorServoBossTextClient/src/MinorServoBossTextClient.cpp +++ b/Common/Clients/MinorServoBossTextClient/src/MinorServoBossTextClient.cpp @@ -289,7 +289,7 @@ int main(int argc, char *argv[]) { status_box->setStatusLook(Management::MNG_OK,CStyle(BLACK_GREEN,CStyle::BOLD)); status_box->setStatusLook(Management::MNG_WARNING,CStyle(BLACK_YELLOW,CStyle::BOLD)); status_box->setStatusLook(Management::MNG_FAILURE,CStyle(BLACK_RED,CStyle::BOLD)); - _TW_SET_COMPONENT(motionInfo_field,18,3,30,1,CColorPair::WHITE_BLACK,CStyle::BOLD,output_label); + _TW_SET_COMPONENT(motionInfo_field,18,3,40,1,CColorPair::WHITE_BLACK,CStyle::BOLD,output_label); /* ****************************************************************** */ _TW_SET_COMPONENT(userInput,0,WINDOW_HEIGHT-6,WINDOW_WIDTH-1,1,USER_INPUT_COLOR_PAIR,USER_INPUT_STYLE,NULL); diff --git a/Common/Clients/SystemTerminal/src/nuraghe_commands.py b/Common/Clients/SystemTerminal/src/nuraghe_commands.py index 9931cce9f..4b1723e37 100755 --- a/Common/Clients/SystemTerminal/src/nuraghe_commands.py +++ b/Common/Clients/SystemTerminal/src/nuraghe_commands.py @@ -2,6 +2,9 @@ from __future__ import print_function # Marco Buttu # Doctrings from the "Observing at the SRT with Nuraghe, Issue n.8, 21/10/14", # by Simona Righini and Andrea Orlati" +# 21/05/2024 G. Carboni: commands prependend with SRT_, Medicina_, Noto_ are +# only added to the operator input according to the STATION environment +# variable def antennaPark(): @@ -538,6 +541,12 @@ def servoSetup(): (CCB, KKG, LLP, PLP, PPP) configures the minor servos in ordet to put on focus the receiver """ +def SRT_servoReset(): + """ + servoReset + sends the emergency and alarm reset command to OR7 VBrain server, SRT only + """ + def setAttenuation(): """ setAttenuation=sect,att @@ -584,6 +593,29 @@ def setServoOffset(): setServoOffset=SRP_TY,5 """ +def SRT_setGregorianCoverPosition(): + """ + setGregorianCoverPosition=POSITION + It sets the gregorian cover position + Allowed POSITIONs + CLOSED, closed + OPEN, open + """ + +def SRT_setGregorianAirBladeStatus(): + """ + setGregorianAirBladeStatus=STATUS + It sets the gregorian air blade status + Allowed STATUSes: + AUTO, auto + OFF, off + ON, on + If a ON status is commanded, the air blade stays on for 30 seconds. + It can be toggled off manually. + Sending setGregorianAirBladeStatus=ON again will toggle the air blade to + turn on again. + """ + def setupCCB(): """ The setup command sets the antenna mount, the minor servos, @@ -694,6 +726,9 @@ def wx(): atmospheric pressure (hPa), wind speed (km/h). """ +stations = ['SRT', 'Medicina', 'Noto'] +import os +station = os.environ.get('STATION') import copy myself = __import__(__name__) # Create the commands dictionary @@ -701,10 +736,14 @@ commands = myself.__dict__.copy() # Shallow copy, but we do not mind for cmd in list(commands.keys()): if cmd.startswith('__'): del commands[cmd] + elif any(cmd.startswith(s) for s in stations): + command = commands.pop(cmd) + s, cmd = cmd.split('_') + if s == station: + commands[cmd] = command # Make the setupXXX.__doc__ for cmd in commands: if cmd.startswith('setup'): setupXXX = getattr(myself, cmd) setupXXX.__doc__ = setupCCB.__doc__ - diff --git a/Common/Servers/Scheduler/src/Core.cpp b/Common/Servers/Scheduler/src/Core.cpp index 888b55ddc..7e8566567 100644 --- a/Common/Servers/Scheduler/src/Core.cpp +++ b/Common/Servers/Scheduler/src/Core.cpp @@ -217,6 +217,9 @@ void CCore::execute() throw(ComponentErrors::TimerErrorExImpl, ComponentErrors:: m_parser->add("setServoASConfiguration", "minorservo", 4, &CCore::remoteCall); m_parser->add("clearServoOffsets", "minorservo", 4, &CCore::remoteCall); m_parser->add("setServoOffset", "minorservo", 4, &CCore::remoteCall); + m_parser->add("servoReset", "_servoReset", 0, "SRT"); + m_parser->add("setGregorianCoverPosition", "_cover", 1, "SRT"); + m_parser->add("setGregorianAirBladeStatus", "_airBlade", 1, "SRT"); // active surface m_parser->add("asSetup", "activesurface", 5, &CCore::remoteCall); diff --git a/SRT/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml b/SRT/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml index 00e681dfa..9481f7890 100644 --- a/SRT/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml +++ b/SRT/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml @@ -23,10 +23,10 @@ ROTATION -51.821170 ROTATION -51.821170 - - ROTATION 0 - ROTATION 0 - ROTATION 0 - ROTATION 0 + + + + + diff --git a/SRT/CDB/alma/DataBlock/MinorServo/Tabella Setup.csv b/SRT/CDB/alma/DataBlock/MinorServo/Tabella Setup.csv new file mode 100644 index 000000000..18e70dd49 --- /dev/null +++ b/SRT/CDB/alma/DataBlock/MinorServo/Tabella Setup.csv @@ -0,0 +1,14 @@ +CONFIGURATION;PFP_TX;PFP_TZ;PFP_RTHETA;SRP_TX;SRP_TY;SRP_TZ;SRP_RX;SRP_RY;SRP_RZ;M3R_RZ;GFR_RZ;DR_GFR1;DR_GFR2;DR_GFR3;DR_PFP;GREGORIAN_CAP; +Primario;0;0;0;-5;5;-120;0;0;0;*;*;*;*;*;*;1; +Gregoriano1;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;-88.70659;*;*;*;*;3; +Gregoriano2;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;-159.8899;*;*;*;*;3; +Gregoriano3;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;90.97161;*;*;*;*;3; +Gregoriano4;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;162.771;*;*;*;*;3; +Gregoriano5;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;55.373967;*;*;*;*;3; +Gregoriano6;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;-51.82117;*;*;*;*;3; +Gregoriano7;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; +Gregoriano8;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; +BWG1;0;0;0;-1.5;11.1393650793988;0.358165166130078;0.049894179898239;-0.036111111111111;0;10;0;*;*;*;*;3; +BWG2;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; +BWG3;0;0;0;-1.5;11.1393650793988;-3.77159716192807;0.049894179898239;-0.036111111111111;0;20;0;*;*;*;*;3; +BWG4;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; diff --git a/SRT/CDB/alma/MINORSERVO/Boss/Boss.xml b/SRT/CDB/alma/MINORSERVO/Boss/Boss.xml index 4dab29cf9..4fb06c72f 100644 --- a/SRT/CDB/alma/MINORSERVO/Boss/Boss.xml +++ b/SRT/CDB/alma/MINORSERVO/Boss/Boss.xml @@ -31,7 +31,9 @@ - + + + diff --git a/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml b/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml index 656043cef..f34f6a21c 100644 --- a/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml +++ b/SRT/CDB/alma/MINORSERVO/GFR/GFR.xml @@ -30,5 +30,6 @@ + diff --git a/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml b/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml index abf4e296e..8dfa3aa1c 100644 --- a/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml +++ b/SRT/CDB/alma/MINORSERVO/M3R/M3R.xml @@ -30,5 +30,6 @@ + diff --git a/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml b/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml index 3d22653f9..5503ee2fd 100644 --- a/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml +++ b/SRT/CDB/alma/MINORSERVO/PFP/PFP.xml @@ -31,6 +31,7 @@ + diff --git a/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml b/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml index 693ae9163..d783896b4 100644 --- a/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml +++ b/SRT/CDB/alma/MINORSERVO/SRP/SRP.xml @@ -31,6 +31,7 @@ + diff --git a/SRT/CDB/alma/MINORSERVO/VBrain/VBrain.xml b/SRT/CDB/alma/MINORSERVO/VBrain/VBrain.xml new file mode 100644 index 000000000..32131b046 --- /dev/null +++ b/SRT/CDB/alma/MINORSERVO/VBrain/VBrain.xml @@ -0,0 +1,13 @@ + + + + diff --git a/SRT/CDB/alma/Procedures/StationProcedures/StationProcedures.xml b/SRT/CDB/alma/Procedures/StationProcedures/StationProcedures.xml index 4be2b1e2d..ef34edabf 100644 --- a/SRT/CDB/alma/Procedures/StationProcedures/StationProcedures.xml +++ b/SRT/CDB/alma/Procedures/StationProcedures/StationProcedures.xml @@ -137,11 +137,11 @@ goTo=*,89.8d - receiversPark - servoPark - asPark waitOnSource antennaStop + servoPark + asPark + receiversPark wait=1 antennaPark logMessage=Telescope is now parked diff --git a/SRT/Configuration/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml b/SRT/Configuration/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml index 00e681dfa..9481f7890 100644 --- a/SRT/Configuration/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml +++ b/SRT/Configuration/CDB/alma/DataBlock/MinorServo/GFR/LookupTables/LookupTables.xml @@ -23,10 +23,10 @@ ROTATION -51.821170 ROTATION -51.821170 - - ROTATION 0 - ROTATION 0 - ROTATION 0 - ROTATION 0 + + + + + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/Boss/Boss.xml b/SRT/Configuration/CDB/alma/MINORSERVO/Boss/Boss.xml index 4dab29cf9..4fb06c72f 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/Boss/Boss.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/Boss/Boss.xml @@ -31,7 +31,9 @@ - + + + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml b/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml index 656043cef..f34f6a21c 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/GFR/GFR.xml @@ -30,5 +30,6 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml b/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml index abf4e296e..8dfa3aa1c 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/M3R/M3R.xml @@ -30,5 +30,6 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml b/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml index 3d22653f9..5503ee2fd 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/PFP/PFP.xml @@ -31,6 +31,7 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml b/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml index 693ae9163..d783896b4 100644 --- a/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml +++ b/SRT/Configuration/CDB/alma/MINORSERVO/SRP/SRP.xml @@ -31,6 +31,7 @@ + diff --git a/SRT/Configuration/CDB/alma/MINORSERVO/VBrain/VBrain.xml b/SRT/Configuration/CDB/alma/MINORSERVO/VBrain/VBrain.xml new file mode 100644 index 000000000..8d4815e2e --- /dev/null +++ b/SRT/Configuration/CDB/alma/MINORSERVO/VBrain/VBrain.xml @@ -0,0 +1,13 @@ + + + + diff --git a/SRT/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml b/SRT/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml index 4be2b1e2d..ef34edabf 100644 --- a/SRT/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml +++ b/SRT/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml @@ -137,11 +137,11 @@ goTo=*,89.8d - receiversPark - servoPark - asPark waitOnSource antennaStop + servoPark + asPark + receiversPark wait=1 antennaPark logMessage=Telescope is now parked diff --git a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl index f6680cf78..293610d47 100644 --- a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl +++ b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServo.idl @@ -98,6 +98,11 @@ module MinorServo */ readonly attribute ACS::ROstring current_setup; + /** + * This property returns the current eventual error code. + */ + readonly attribute ROSRTMinorServoError error_code; + /** * This method asks the PLC the status for the corresponding servo * @throw MinorServoErrors::MinorServoErrorsEx when trying to reset the offsets when they don't match the ones loaded into the hardware @@ -225,6 +230,17 @@ module MinorServo * @param max_ranges the maximum range of the servo axes */ void getAxesRanges(out ACS::doubleSeq min_ranges, out ACS::doubleSeq max_ranges); + + /* + * This method returns the current eventual error code + * @return the current eventual error code + */ + SRTMinorServoError getErrorCode(); + + /** + * This command resets the error status inside the component. + */ + void reset(); }; /** diff --git a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoBoss.idl b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoBoss.idl index 9748e827e..746365e31 100644 --- a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoBoss.idl +++ b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoBoss.idl @@ -62,11 +62,21 @@ module MinorServo */ readonly attribute ROSRTMinorServoGregorianCoverStatus gregorian_cover; + /** + * Status of the gregorian air blade + */ + readonly attribute ROSRTMinorServoGregorianAirBladeStatus air_blade; + /** * UNIX Epoch of the last executed command (STATUS commands are not shown here) */ readonly attribute ACS::ROdouble last_executed_command; + /** + * This property returns the current eventual error code. + */ + readonly attribute ROSRTMinorServoError error_code; + /** * This command sets all the minor servos involved in the current focal configuration to their position calculated from the elevation argument * @param elevation, the elevation the minor servos should use to calculate their position @@ -79,7 +89,21 @@ module MinorServo * @param value, the desired gregorian cover position, accepted values are 'open', 'OPEN', 'closed' or 'CLOSED' * @throw MinorServoErrors::MinorServoErrorsEx */ - //void setGregorianCoverPosition(in string value) raises (MinorServoErrors::MinorServoErrorsEx); + void setGregorianCoverPosition(in string value) raises (MinorServoErrors::MinorServoErrorsEx); + + /** + * This command turns the gregorian air blade on or off, or sets it to automatic mode + * @param value, the desired air blade status, accepted values are 'on', 'ON', 'off', 'OFF', 'auto' or 'AUTO' + * @throw MinorServoErrors::MinorServoErrorsEx + */ + void setGregorianAirBladeStatus(in string value) raises (MinorServoErrors::MinorServoErrorsEx); + + /** + * This command resets the error status inside the component. It DOES NOT send a reset command to the Leonardo minor servo system. + * In order to reset emergencies and alarms inside the Leonardo minor servo system the user has to call the servoReset command from operatorInput. + * The servoReset command sends a reset to the Leonardo minnor servo system and then calls this method to clear the component error status. + */ + void reset(); }; }; diff --git a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoCommon.midl b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoCommon.midl index 6addf4c0d..45980430f 100644 --- a/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoCommon.midl +++ b/SRT/Interfaces/SRTMinorServoInterface/idl/SRTMinorServoCommon.midl @@ -59,6 +59,17 @@ module MinorServo }; ACS_ENUM(SRTMinorServoGregorianCoverStatus); + /** + * Enumerator which indicates the status of the gregorian air blade + */ + enum SRTMinorServoGregorianAirBladeStatus + { + AIR_BLADE_STATUS_AUTO, + AIR_BLADE_STATUS_OFF, + AIR_BLADE_STATUS_ON + }; + ACS_ENUM(SRTMinorServoGregorianAirBladeStatus); + /** * Enumerator which indicates the status of a servo drive cabinet */ @@ -98,5 +109,22 @@ module MinorServo MOTION_STATUS_ERROR }; ACS_ENUM(SRTMinorServoMotionStatus); + + /** + * Enumerator which indicates what type of error is present on the component + */ + enum SRTMinorServoError + { + ERROR_NO_ERROR, + ERROR_NOT_CONNECTED, + ERROR_MAINTENANCE, + ERROR_EMERGENCY_STOP, + ERROR_COVER_WRONG_POSITION, + ERROR_CONFIG_ERROR, + ERROR_COMMAND_ERROR, + ERROR_SERVO_BLOCKED, + ERROR_DRIVE_CABINET + }; + ACS_ENUM(SRTMinorServoError); }; #endif diff --git a/SRT/Libraries/SRTMinorServoLibrary/include/SRTMinorServoContainers.h b/SRT/Libraries/SRTMinorServoLibrary/include/SRTMinorServoContainers.h index 4c32b5195..3c5446638 100644 --- a/SRT/Libraries/SRTMinorServoLibrary/include/SRTMinorServoContainers.h +++ b/SRT/Libraries/SRTMinorServoLibrary/include/SRTMinorServoContainers.h @@ -702,7 +702,25 @@ namespace MinorServo */ SRTMinorServoGregorianCoverStatus getGregorianCoverPosition() const { - return SRTMinorServoGregorianCoverStatus(this->get("GREGORIAN_CAP")); + return SRTMinorServoGregorianCoverStatus(std::min(this->get("GREGORIAN_CAP"), (unsigned int)COVER_STATUS_OPEN)); + } + + /** + * Returns the status of the gregorian air blade. + * @return an enum indicating the status of the gregorian air blade. + */ + SRTMinorServoGregorianAirBladeStatus getGregorianAirBladeStatus() const + { + unsigned int status = this->get("GREGORIAN_CAP"); + if(status <= COVER_STATUS_CLOSED) + { + status = AIR_BLADE_STATUS_OFF; + } + else + { + status -= 2; + } + return SRTMinorServoGregorianAirBladeStatus(status); } /** diff --git a/SRT/Libraries/SRTMinorServoLibrary/src/SRTMinorServoSocket.cpp b/SRT/Libraries/SRTMinorServoLibrary/src/SRTMinorServoSocket.cpp index f0606fe29..1f182d455 100644 --- a/SRT/Libraries/SRTMinorServoLibrary/src/SRTMinorServoSocket.cpp +++ b/SRT/Libraries/SRTMinorServoLibrary/src/SRTMinorServoSocket.cpp @@ -74,21 +74,21 @@ void SRTMinorServoSocket::connect() throw impl.getMinorServoErrorsEx(); } - if(Connect(m_error, m_ip_address.c_str(), m_port) == FAIL) + if(setSockMode(m_error, NONBLOCKING) != SUCCESS) { - m_socket_status = TIMEOUT; + m_socket_status = NOTREADY; Close(m_error); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, impl, "SRTMinorServoSocket::SRTMinorServoSocket()"); - impl.setReason("Cannot connect the socket."); + impl.setReason("Cannot set the socket to non-blocking."); throw impl.getMinorServoErrorsEx(); } - if(setSockMode(m_error, NONBLOCKING) != SUCCESS) + if(Connect(m_error, m_ip_address.c_str(), m_port) == FAIL) { - m_socket_status = NOTREADY; + m_socket_status = TIMEOUT; Close(m_error); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, impl, "SRTMinorServoSocket::SRTMinorServoSocket()"); - impl.setReason("Cannot set the socket to non-blocking."); + impl.setReason("Cannot connect the socket."); throw impl.getMinorServoErrorsEx(); } @@ -102,10 +102,10 @@ const bool SRTMinorServoSocket::isConnected() const SRTMinorServoAnswerMap SRTMinorServoSocket::sendCommand(std::string command, std::optional> map) { - std::lock_guard guard(m_mutex); - connect(); + std::lock_guard guard(m_mutex); + double start_time = IRA::CIRATools::getUNIXEpoch(); size_t sent_bytes = 0; diff --git a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd index c6e235928..88b054568 100644 --- a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd +++ b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServo.xsd @@ -10,41 +10,23 @@ xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:mng="urn:schemas-cosylab-com:Managment:1.0" + xmlns:ms="urn:schemas-cosylab-com:SRTMinorServoCommon:1.0" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - - - - - - - - - - - - - - - - - + - + - + @@ -57,6 +39,7 @@ + diff --git a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoBoss.xsd b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoBoss.xsd index 2d87a89a5..153014681 100644 --- a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoBoss.xsd +++ b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoBoss.xsd @@ -9,42 +9,14 @@ xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:mng="urn:schemas-cosylab-com:Managment:1.0" + xmlns:ms="urn:schemas-cosylab-com:SRTMinorServoCommon:1.0" elementFormDefault="qualified" attributeFormDefault="unqualified"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -61,15 +33,17 @@ - + - + - + + + diff --git a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoCommon.xsd b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoCommon.xsd new file mode 100644 index 000000000..d1458353c --- /dev/null +++ b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoCommon.xsd @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoVBrainConfiguration.xsd b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoVBrainConfiguration.xsd new file mode 100644 index 000000000..722053f54 --- /dev/null +++ b/SRT/Servers/SRTMinorServo/config/CDB/schemas/SRTMinorServoVBrainConfiguration.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/SRT/Servers/SRTMinorServo/include/MSDevIOs.h b/SRT/Servers/SRTMinorServo/include/MSDevIOs.h index 330d3905d..49749dc7f 100644 --- a/SRT/Servers/SRTMinorServo/include/MSDevIOs.h +++ b/SRT/Servers/SRTMinorServo/include/MSDevIOs.h @@ -68,9 +68,10 @@ namespace MinorServo * @param scanning a reference to the TBoolean indicating whether the system is scanning or not. * @param current_scan a reference to the SRTMinorServoScan object containing the parameters for the current scan. It is used to read the servo name and axis involved in the scan. */ - MSMotionInfoDevIO(const std::atomic& motion_status, const SRTMinorServoGeneralStatus& boss_status, const std::atomic& scanning, const SRTMinorServoScan& current_scan) : + MSMotionInfoDevIO(const std::atomic& motion_status, const SRTMinorServoGeneralStatus& boss_status, const std::atomic& error, const std::atomic& scanning, const SRTMinorServoScan& current_scan) : m_motion_status(motion_status), m_boss_status(boss_status), + m_error(error), m_scanning(scanning), m_current_scan(current_scan) {} @@ -120,13 +121,13 @@ namespace MinorServo // If I can read the status of the gregorian cover I will notify the user about it on the GUI SRTMinorServoGregorianCoverStatus cover_position = m_boss_status.getGregorianCoverPosition(); - if(cover_position == COVER_STATUS_OPEN) + if(cover_position == COVER_STATUS_CLOSED) { - motion_status += ", gregorian cover open"; + motion_status += ", gregorian cover closed"; } - else if(cover_position == COVER_STATUS_CLOSED) + if(cover_position == COVER_STATUS_OPEN) { - motion_status += ", gregorian cover closed"; + motion_status += ", gregorian cover open"; } } catch(...) @@ -138,7 +139,61 @@ namespace MinorServo } case MOTION_STATUS_ERROR: { - motion_status = "Error"; + switch(m_error.load()) + { + case ERROR_NO_ERROR: + { + // Should never get here, leave empty + motion_status = ""; + break; + } + case ERROR_NOT_CONNECTED: + { + motion_status = "Socket not connected"; + break; + } + case ERROR_MAINTENANCE: + { + motion_status = "System in maintenance mode"; + break; + } + case ERROR_EMERGENCY_STOP: + { + motion_status = "Emergency stop pressed"; + break; + } + case ERROR_COVER_WRONG_POSITION: + { + motion_status = "Gregorian cover in wrong position"; + break; + } + case ERROR_CONFIG_ERROR: + { + motion_status = "Error while configuring the system"; + break; + } + case ERROR_COMMAND_ERROR: + { + motion_status = "Error while executing a remote command"; + break; + } + case ERROR_SERVO_BLOCKED: + { + motion_status = "Minor servo group is blocked"; + break; + } + case ERROR_DRIVE_CABINET: + { + motion_status = "Minor servo group drive cabinet error"; + break; + } + default: + { + // Should never get here, unknown error condition + motion_status = "Unknown error"; + break; + } + } break; } } @@ -161,6 +216,11 @@ namespace MinorServo */ const SRTMinorServoGeneralStatus& m_boss_status; + /** + * Reference to the SRTMinorServoError object of the Boss. + */ + const std::atomic& m_error; + /** * Reference to the boolean telling if the system is scanning. */ @@ -187,6 +247,7 @@ namespace MinorServo SRTMinorServoFocalConfiguration, SRTMinorServoControlStatus, SRTMinorServoGregorianCoverStatus, + SRTMinorServoGregorianAirBladeStatus, SRTMinorServoCabinetStatus, SRTMinorServoOperativeMode > @@ -261,7 +322,7 @@ namespace MinorServo * The templates is specialized for the combinations of types listed right below and the compilation will fail if the developer attempts to use it with any other types combination. */ template || (std::is_same_v && std::is_same_v>) + is_any_v || (std::is_same_v && std::is_same_v>) >> class MSGenericDevIO : public MSBaseDevIO { diff --git a/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossCore.h b/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossCore.h index 157fe1f23..b315443a8 100644 --- a/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossCore.h +++ b/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossCore.h @@ -118,6 +118,14 @@ private: */ void setGregorianCoverPosition(std::string position); + /** + * Sets the gregorian air blade status. + * @param status the desired status for the gregorian air blade, allowed value are 'on', 'ON', 'off', 'OFF', 'auto' or 'AUTO'. + * @throw MinorServoErrors::MinorServoErrorsEx when the commanded status is unknown or the gregorian cover is currently closed, + * when anything goes wrong in the lower communication level or if checkLineStatus throws. + */ + void setGregorianAirBladeStatus(std::string status); + /** * Configures the whole minor servo system to a desired position. * @param elevation the elevation to use for all the minor servo positions calculation. @@ -268,8 +276,15 @@ private: /** * Method that sets all the necessary variable to signal a failure of the minor servo system. + * @param error the type of error the system should display + */ + void setError(SRTMinorServoError error); + + /** + * Method that clears the error status from the system. + * This will show the system cleared the error status and is ready to be configured again. */ - void setFailure(); + void reset(bool force=false); /** * Method used to retrieve a configuration value from the CDB. @@ -382,6 +397,11 @@ private: */ std::atomic m_tracking; + /** + * Enumerator containing the error code. + */ + std::atomic m_error_code; + /** * This boolean will be set to true every time the socket connects. * When true it will trigger a procedure that will check if the minor servos offsets need to be reloaded because of a discrepancy between the DISCOS offsets (user + system) and the Leonardo offsets. diff --git a/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossImpl.h b/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossImpl.h index 40eb0c828..a22cceb6b 100644 --- a/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossImpl.h +++ b/SRT/Servers/SRTMinorServo/include/SRTMinorServoBossImpl.h @@ -264,6 +264,14 @@ public: */ virtual void setGregorianCoverPosition(const char* position); + /** + * Sets the gregorian air blade status. + * @param status the desired status of the gregorian air blade, allowed values are 'on', 'ON', 'off', 'OFF', 'auto' or 'AUTO'. + * @throw MinorServoErrors::MinorServoErrorsEx when the commanded status is unknown or the gregorian cover is currently closed, + * when anything goes wrong in the lower communication level or if checkLineStatus throws. + */ + virtual void setGregorianAirBladeStatus(const char* status); + /** * This method checks if a scan with the given parameters is feasible. * @param start_time the starting ACS::Time for the requested scan. @@ -298,6 +306,11 @@ public: */ virtual void preset(double elevation); + /** + * This command clears the error status from the component. + */ + void reset(); + /** * Parser method. It executes the desired command. */ @@ -417,12 +430,24 @@ public: */ virtual ROSRTMinorServoGregorianCoverStatus_ptr gregorian_cover(); + /** + * Returns a reference to the air_blade property implementation of the IDL interface. + * @return pointer to read-only SRTMinorServoGregorianAirBladeStatus property air_blade. + */ + virtual ROSRTMinorServoGregorianAirBladeStatus_ptr air_blade(); + /** * Returns a reference to the last_executed_command property implementation of the IDL interface. * @return pointer to read-only double property last_executed_command. */ virtual ACS::ROdouble_ptr last_executed_command(); + /** + * Returns a reference to the error_code property implementation of the IDL interface. + * @return pointer to the read-only SRTMinorServoError property error_code. + */ + virtual ROSRTMinorServoError_ptr error_code(); + private: /** * Component name. @@ -539,10 +564,20 @@ private: */ baci::SmartPropertyPointer> m_gregorian_cover_ptr; + /** + * Pointer to the air_blade property. + */ + baci::SmartPropertyPointer> m_air_blade_ptr; + /** * Pointer to the last_executed_command property. */ baci::SmartPropertyPointer m_last_executed_command_ptr; + + /** + * Pointer to the error_code property. + */ + baci::SmartPropertyPointer> m_error_code_ptr; }; #endif diff --git a/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h b/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h index a286b5395..a8254f7dd 100644 --- a/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h +++ b/SRT/Servers/SRTMinorServo/include/SRTMinorServoImpl.h @@ -173,6 +173,17 @@ public: */ void getAxesInfo(ACS::stringSeq_out axes_names_out, ACS::stringSeq_out axes_units_out); + /** + * Returns the current error code. + * @return the current SRTMinorServoError code. + */ + SRTMinorServoError getErrorCode() { return m_error_code.load(); }; + + /** + * Resets the component error code to ERROR_NO_ERROR. + */ + void reset(); + /** * Returns the virtual axes positions to where the servo system was at the given time acs_time. * @param acs_time the epoch we want to retrieve the axes virtual positions of the servo system. @@ -288,6 +299,12 @@ public: */ virtual ACS::ROstring_ptr current_setup(); + /** + * Returns a reference to the error_code property implementation of the IDL interface. + * @return pointer to the read-only SRTMinorServoError property error_code. + */ + virtual ROSRTMinorServoError_ptr error_code(); + protected: /** * Checks if the socket is connected and if the minor servo system is in a good state. @@ -348,17 +365,17 @@ 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. */ SRTMinorServoStatus m_status; + /** + * Current error code. + */ + std::atomic m_error_code; + /** * Commanded user offsets for each axis of the servo system. */ @@ -369,6 +386,11 @@ protected: */ std::vector m_system_offsets; + /** + * Latest commanded virtual positions. It only takes into account the preset command. + */ + std::vector m_commanded_virtual_positions; + /** * Queue of positions assumed by the servo system in time. */ @@ -494,6 +516,11 @@ private: */ baci::SmartPropertyPointer m_current_setup_ptr; + /** + * Pointer to the error_code property. + */ + baci::SmartPropertyPointer> m_error_code_ptr; + /** * Table containing the coefficients for the positions calculations. */ @@ -532,7 +559,9 @@ protected: void getAxesInfo(ACS::stringSeq_out axes_names_out, ACS::stringSeq_out axes_units_out) { SRTBaseMinorServoImpl::getAxesInfo(axes_names_out, axes_units_out); }\ ACS::doubleSeq* getAxesPositions(ACS::Time acs_time) { return SRTBaseMinorServoImpl::getAxesPositions(acs_time); }\ long getTravelTime(const ACS::doubleSeq& start, const ACS::doubleSeq& dest) { return SRTBaseMinorServoImpl::getTravelTime(start, dest); }\ - void getAxesRanges(ACS::doubleSeq_out min_ranges_out, ACS::doubleSeq_out max_ranges_out) { SRTBaseMinorServoImpl::getAxesRanges(min_ranges_out, max_ranges_out); } + void getAxesRanges(ACS::doubleSeq_out min_ranges_out, ACS::doubleSeq_out max_ranges_out) { SRTBaseMinorServoImpl::getAxesRanges(min_ranges_out, max_ranges_out); }\ + SRTMinorServoError getErrorCode() { return SRTBaseMinorServoImpl::getErrorCode(); }\ + void reset() { SRTBaseMinorServoImpl::reset(); } /** * MACRO definition of child classes properties methods. @@ -556,7 +585,8 @@ protected: 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(); } + virtual ACS::ROstring_ptr current_setup() { return SRTBaseMinorServoImpl::current_setup(); }\ + virtual ROSRTMinorServoError_ptr error_code() { return SRTBaseMinorServoImpl::error_code(); } /** * This class implements the SRTGenericMinorServoImpl CORBA interface for a generic SRTMinorServo component. diff --git a/SRT/Servers/SRTMinorServo/include/SRTMinorServoTrackingThread.h b/SRT/Servers/SRTMinorServo/include/SRTMinorServoTrackingThread.h index 32ae15c9e..c5160b019 100644 --- a/SRT/Servers/SRTMinorServo/include/SRTMinorServoTrackingThread.h +++ b/SRT/Servers/SRTMinorServo/include/SRTMinorServoTrackingThread.h @@ -75,11 +75,6 @@ private: * The current trajectory point time. */ ACS::Time m_point_time; - - /** - * Boolean which indicates if the tracking thread exited with an error or not. - */ - bool m_error; }; #endif /*_SRTMINORSERVOTRACKINGTHREAD_H_*/ diff --git a/SRT/Servers/SRTMinorServo/src/Makefile b/SRT/Servers/SRTMinorServo/src/Makefile index c11de1645..a61ed3645 100644 --- a/SRT/Servers/SRTMinorServo/src/Makefile +++ b/SRT/Servers/SRTMinorServo/src/Makefile @@ -9,11 +9,11 @@ EXECUTABLES = EXECUTABLES_L = -PY_SCRIPTS = #_cover +PY_SCRIPTS = _cover _airBlade _servoReset # On-Line Database Files # ---------------------- -CDB_SCHEMAS = SRTMinorServoBoss SRTMinorServo SRTMinorServoSocketConfiguration SRTMinorServoProperties SRTMinorServoLookupTable +CDB_SCHEMAS = SRTMinorServoCommon SRTMinorServoBoss SRTMinorServo SRTMinorServoSocketConfiguration SRTMinorServoVBrainConfiguration SRTMinorServoProperties SRTMinorServoLookupTable # ---------------------------- # Libraries (public and local) diff --git a/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp b/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp index dea56af00..8371127f0 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTBaseMinorServoImpl.cpp @@ -17,8 +17,10 @@ SRTBaseMinorServoImpl::SRTBaseMinorServoImpl(const ACE_CString& component_name, m_virtual_axes_names, SRTBaseMinorServoImpl::getPropertiesTable(*this, "virtual_offsets") ), + m_error_code(ERROR_NO_ERROR), m_user_offsets(m_virtual_axes, 0.0), m_system_offsets(m_virtual_axes, 0.0), + m_commanded_virtual_positions(m_virtual_axes, 0.0), m_positions_queue(5 * 60 * int(1 / getCDBValue(container_services, "status_thread_period", "/MINORSERVO/Boss")), m_virtual_axes), m_min(SRTBaseMinorServoImpl::getMotionConstant(*this, "min_range")), m_max(SRTBaseMinorServoImpl::getMotionConstant(*this, "max_range")), @@ -44,6 +46,7 @@ SRTBaseMinorServoImpl::SRTBaseMinorServoImpl(const ACE_CString& component_name, m_commanded_virtual_positions_ptr(this), m_in_use_ptr(this), m_current_setup_ptr(this), + m_error_code_ptr(this), m_current_lookup_table(), m_socket_configuration(SRTMinorServoSocketConfiguration::getInstance(container_services)), m_socket(SRTMinorServoSocket::getInstance(m_socket_configuration.m_ip_address, m_socket_configuration.m_port, m_socket_configuration.m_timeout)) @@ -92,6 +95,8 @@ void SRTBaseMinorServoImpl::initialize() new MSGenericDevIO>(m_in_use), true); m_current_setup_ptr = new baci::ROstring((m_component_name + ":current_setup").c_str(), getComponent(), new MSGenericDevIO(m_current_setup), true); + m_error_code_ptr = new ROEnumImpl((m_component_name + ":error_code").c_str(), getComponent(), + new MSGenericDevIO>(m_error_code), true); } catch(std::bad_alloc& ba) { @@ -157,6 +162,8 @@ bool SRTBaseMinorServoImpl::status() } catch(...) { + // Something went wrong when sending the status command + m_error_code.store(ERROR_COMMAND_ERROR); return false; } @@ -171,6 +178,7 @@ void SRTBaseMinorServoImpl::stow(CORBA::Long stow_position) if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::stow(m_servo_name, (unsigned int)stow_position)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::stow()").c_str()); ex.setReason("Received NAK in response to a STOW command."); ex.log(LM_DEBUG); @@ -186,6 +194,7 @@ void SRTBaseMinorServoImpl::stop() if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::stop(m_servo_name)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::stop()").c_str()); ex.setReason("Received NAK in response to a STOP command."); ex.log(LM_DEBUG); @@ -206,13 +215,8 @@ void SRTBaseMinorServoImpl::preset(const ACS::doubleSeq& virtual_coords) 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()); - } + 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) @@ -240,16 +244,13 @@ void SRTBaseMinorServoImpl::preset(const ACS::doubleSeq& virtual_coords) if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::preset(m_servo_name, coordinates)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::preset()").c_str()); ex.setReason("Received NAK in response to a PRESET command."); 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()); } @@ -320,9 +321,16 @@ bool SRTBaseMinorServoImpl::setup(const char* configuration_name) clearUserOffsets(); clearSystemOffsets(); m_in_use.store(Management::MNG_TRUE); + // The positions tables inside the Leonardo minor servo systems are calculated with an elevation of 45 degrees. + // We need to be sure the values are correct otherwise there will be a discrepancy. + ACS::doubleSeq commanded_coordinates = *calcCoordinates(45); + std::copy(commanded_coordinates.begin(), commanded_coordinates.end(), m_commanded_virtual_positions.begin()); + return true; + } + else + { + return false; } - - return true; } ACS::doubleSeq* SRTBaseMinorServoImpl::calcCoordinates(double elevation) @@ -408,6 +416,7 @@ void SRTBaseMinorServoImpl::setUserOffset(const char* axis_name, CORBA::Double o if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::offset(m_servo_name, offsets)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::setUserOffset()").c_str()); ex.setReason("Received NAK in response to an OFFSET command."); ex.log(LM_DEBUG); @@ -430,6 +439,7 @@ void SRTBaseMinorServoImpl::clearUserOffsets() if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::offset(m_servo_name, offsets)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::clearUserOffset()").c_str()); ex.setReason("Received NAK in response to an OFFSET command."); ex.log(LM_DEBUG); @@ -486,6 +496,7 @@ void SRTBaseMinorServoImpl::setSystemOffset(const char* axis_name, CORBA::Double if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::offset(m_servo_name, offsets)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::setSystemOffset()").c_str()); ex.setReason("Received NAK in response to an OFFSET command."); ex.log(LM_DEBUG); @@ -509,6 +520,7 @@ void SRTBaseMinorServoImpl::clearSystemOffsets() if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::offset(m_servo_name, offsets)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::clearSystemOffset()").c_str()); ex.setReason("Received NAK in response to an OFFSET command."); ex.log(LM_DEBUG); @@ -534,6 +546,7 @@ void SRTBaseMinorServoImpl::reloadOffsets() // Offsets do not correspond, should reset them by sending a offset command if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::offset(m_servo_name, DISCOS_offsets)).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::reloadOffsets()").c_str()); ex.setReason("Received NAK in response to an OFFSET command."); ex.log(LM_DEBUG); @@ -555,7 +568,7 @@ void SRTBaseMinorServoImpl::getAxesInfo(ACS::stringSeq_out axes_names_out, ACS:: for(size_t i = 0; i < m_virtual_axes; i++) { - axes_names[i] = (m_servo_name + "_" + m_virtual_axes_names[i] == "ROTATION" ? "RZ" : m_virtual_axes_names[i]).c_str(); + axes_names[i] = (m_virtual_axes_names[i] == "ROTATION" ? "RZ" : m_virtual_axes_names[i]).c_str(); axes_units[i] = m_virtual_axes_units[i].c_str(); } @@ -684,6 +697,12 @@ void SRTBaseMinorServoImpl::getAxesRanges(ACS::doubleSeq_out min_ranges_out, ACS max_ranges_out = max_ranges._retn(); } +void SRTBaseMinorServoImpl::reset() +{ + AUTO_TRACE("SRTBaseMinorServoImpl::reset()"); + m_error_code.store(ERROR_NO_ERROR); +} + /////////////////// PROTECTED methods void SRTBaseMinorServoImpl::checkLineStatus() { @@ -692,14 +711,25 @@ void SRTBaseMinorServoImpl::checkLineStatus() _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "checkLineStatus()").c_str()); ex.setReason("Socket not connected."); ex.log(LM_DEBUG); + m_error_code.store(ERROR_NOT_CONNECTED); + throw ex.getMinorServoErrorsEx(); + } + + if(m_status.isBlocked() == Management::MNG_TRUE) + { + _EXCPT(MinorServoErrors::StatusErrorExImpl, ex, (m_servo_name + "::checkLineStatus()").c_str()); + ex.setReason("Servo system blocked."); + ex.log(LM_DEBUG); + m_error_code.store(ERROR_SERVO_BLOCKED); throw ex.getMinorServoErrorsEx(); } - if(m_status.isBlocked() == Management::MNG_TRUE || m_status.getDriveCabinetStatus() == DRIVE_CABINET_ERROR) + if(m_status.getDriveCabinetStatus() == DRIVE_CABINET_ERROR) { _EXCPT(MinorServoErrors::StatusErrorExImpl, ex, (m_servo_name + "::checkLineStatus()").c_str()); - ex.setReason("Servo system blocked or drive cabinet error."); + ex.setReason("Drive cabinet error."); ex.log(LM_DEBUG); + m_error_code.store(ERROR_DRIVE_CABINET); throw ex.getMinorServoErrorsEx(); } } @@ -835,3 +865,4 @@ GET_PROPERTY_REFERENCE(ACS::ROdoubleSeq, SRTBaseMinorServoImpl, m_virtual_system 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); +GET_PROPERTY_REFERENCE(ROSRTMinorServoError, SRTBaseMinorServoImpl, m_error_code_ptr, error_code); diff --git a/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp b/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp index c529b0b0c..3e8120561 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossCore.cpp @@ -24,6 +24,7 @@ SRTMinorServoBossCore::SRTMinorServoBossCore(SRTMinorServoBossImpl& component) : m_scan_active(Management::MNG_FALSE), m_scanning(Management::MNG_FALSE), m_tracking(Management::MNG_FALSE), + m_error_code(ERROR_NO_ERROR), m_reload_servo_offsets(true), m_socket_configuration(SRTMinorServoSocketConfiguration::getInstance(m_component.getContainerServices())), m_socket(SRTMinorServoSocket::getInstance(m_socket_configuration.m_ip_address, m_socket_configuration.m_port, m_socket_configuration.m_timeout)), @@ -31,8 +32,8 @@ SRTMinorServoBossCore::SRTMinorServoBossCore(SRTMinorServoBossImpl& component) : m_servos{ //{ "PFP", m_component.getContainerServices()->getComponent("MINORSERVO/PFP") }, { "SRP", m_component.getContainerServices()->getComponent("MINORSERVO/SRP") }, - { "GFR", m_component.getContainerServices()->getComponent("MINORSERVO/GFR") } - //{ "M3R", m_component.getContainerServices()->getComponent("MINORSERVO/M3R") } + { "GFR", m_component.getContainerServices()->getComponent("MINORSERVO/GFR") }, + { "M3R", m_component.getContainerServices()->getComponent("MINORSERVO/M3R") } }, m_tracking_servos{ //{ "PFP", m_component.getContainerServices()->getComponent("MINORSERVO/PFP") }, @@ -62,13 +63,18 @@ bool SRTMinorServoBossCore::status() try { // Attempt communication anyway - m_socket.sendCommand(SRTMinorServoCommandLibrary::status(), m_status); + if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::status(), m_status).checkOutput()) + { + setError(ERROR_COMMAND_ERROR); + return false; + } if(m_socket_connected.load() == Management::MNG_FALSE) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoBossCore::status()", (LM_NOTICE, "Socket connected.")); + // We just reconnected, we can try to reset the error automatically, if there is another error in the following code the reset will simply be overridden m_socket_connected.store(Management::MNG_TRUE); - m_subsystem_status.store(Management::MNG_WARNING); + reset(true); } } catch(MinorServoErrors::MinorServoErrorsEx& ex) @@ -82,7 +88,7 @@ bool SRTMinorServoBossCore::status() stopThread(m_park_thread); stopThread(m_tracking_thread); stopThread(m_scan_thread); - setFailure(); + setError(ERROR_NOT_CONNECTED); m_reload_servo_offsets = true; } @@ -97,29 +103,28 @@ bool SRTMinorServoBossCore::status() catch(MinorServoErrors::MinorServoErrorsEx& ex) { _IRA_LOGFILTER_LOG(LM_ERROR, "SRTMinorServoBossCore::status()", getReasonFromEx(ex)); - setFailure(); return false; } SRTMinorServoMotionStatus motion_status = m_motion_status.load(); - /*if(motion_status == MOTION_STATUS_TRACKING || motion_status == MOTION_STATUS_CONFIGURED) + if(motion_status == MOTION_STATUS_TRACKING || motion_status == MOTION_STATUS_CONFIGURED) { // We only get here if the system is configured, therefore we check the correct position of the gregorian cover SRTMinorServoGregorianCoverStatus commanded_gregorian_cover_position = m_status.getFocalConfiguration() == CONFIGURATION_PRIMARY ? COVER_STATUS_CLOSED : COVER_STATUS_OPEN; if(m_status.getGregorianCoverPosition() != commanded_gregorian_cover_position) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoBossCore::status()", (LM_CRITICAL, "Gregorian cover in wrong position.")); - setFailure(); + setError(ERROR_COVER_WRONG_POSITION); return false; } - }*/ + } for(const auto& [name, servo] : m_servos) { if(!servo->status()) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoBossCore::status()", (LM_CRITICAL, ("Error checking " + name + " status.").c_str())); - setFailure(); + setError(servo->getErrorCode()); return false; } @@ -131,7 +136,7 @@ bool SRTMinorServoBossCore::status() m_reload_servo_offsets = false; - if(motion_status == MOTION_STATUS_TRACKING) + if(motion_status == MOTION_STATUS_CONFIGURED || motion_status == MOTION_STATUS_TRACKING) { if(std::all_of(m_current_tracking_servos.begin(), m_current_tracking_servos.end(), [](const std::pair& servo) -> bool { @@ -145,10 +150,6 @@ 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); @@ -338,10 +339,10 @@ void SRTMinorServoBossCore::park() m_current_servos.clear(); m_current_tracking_servos.clear(); - /*try + try { // Send the STOW command to close the gregorian cover - if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::stow("Gregoriano", COVER_STATUS_CLOSED)).checkOutput()) + if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::stow("GREGORIAN_CAP", COVER_STATUS_CLOSED)).checkOutput()) { _EXCPT(ManagementErrors::ParkingErrorExImpl, ex, "SRTMinorServoBossCore::park()"); ex.setSubsystem("MinorServo"); @@ -357,7 +358,7 @@ void SRTMinorServoBossCore::park() ex.setReason("Error while sending the STOW command to the gregorian cover."); ex.log(LM_DEBUG); throw ex.getParkingErrorEx(); - }*/ + } // Send the STOP command to all the servos for(const auto& [servo_name, servo] : m_servos) @@ -433,6 +434,14 @@ void SRTMinorServoBossCore::setElevationTracking(std::string configuration) if(m_motion_status.load() == MOTION_STATUS_TRACKING) { m_motion_status.store(MOTION_STATUS_CONFIGURED); + + try + { + preset(getElevation(getTimeStamp())); + } + catch(...) + { + } } } } @@ -517,15 +526,82 @@ void SRTMinorServoBossCore::setGregorianCoverPosition(std::string position) throw ex.getMinorServoErrorsEx(); } - ACS_LOG(LM_FULL_INFO, "setGregorianCoverPosition", (LM_NOTICE, ("SETTING GREGORIAN COVER POSITION TO " + position).c_str())); + SRTMinorServoGregorianCoverStatus desired_position; + if(position == "OPEN") + { + desired_position = COVER_STATUS_OPEN; + } + else + { + desired_position = COVER_STATUS_CLOSED; + } + + if(desired_position != m_status.getGregorianCoverPosition()) + { + ACS_LOG(LM_FULL_INFO, "setGregorianCoverPosition", (LM_NOTICE, ("SETTING GREGORIAN COVER POSITION TO " + position).c_str())); - if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::stow("Gregoriano", position == "OPEN" ? COVER_STATUS_OPEN : COVER_STATUS_CLOSED)).checkOutput()) + if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::stow("GREGORIAN_CAP", desired_position)).checkOutput()) + { + _EXCPT(MinorServoErrors::StowErrorExImpl, ex, "SRTMinorServoBossCore::setGregorianCoverPosition()"); + ex.addData("Reason", "Error while sending a STOW command to the gregorian cover."); + ex.log(LM_DEBUG); + throw ex.getMinorServoErrorsEx(); + } + } +} + +void SRTMinorServoBossCore::setGregorianAirBladeStatus(std::string status) +{ + AUTO_TRACE("SRTMinorServoBossCore::setGregorianAirBladeStatus()"); + + checkLineStatus(); + + std::transform(status.begin(), status.end(), status.begin(), ::toupper); + + if(status != "ON" && status != "OFF" && status != "AUTO") { - _EXCPT(MinorServoErrors::StowErrorExImpl, ex, "SRTMinorServoBossCore::setGregorianCoverPosition()"); - ex.addData("Reason", "Error while sending a STOW command to the gregorian cover."); + _EXCPT(MinorServoErrors::StowErrorExImpl, ex, "SRTMinorServoBossCore::setGregorianAirBladeStatus()"); + ex.addData("Reason", ("Unknown status '" + status + "'.").c_str()); + ex.log(LM_DEBUG); + throw ex.getMinorServoErrorsEx(); + } + + SRTMinorServoMotionStatus motion_status = m_motion_status.load(); + SRTMinorServoGregorianCoverStatus cover_status = m_status.getGregorianCoverPosition(); + if((motion_status != MOTION_STATUS_CONFIGURED && motion_status != MOTION_STATUS_TRACKING) || cover_status == COVER_STATUS_CLOSED) + { + _EXCPT(MinorServoErrors::StatusErrorExImpl, ex, "SRTMinorServoBossCore::setGregorianAirBladeStatus()"); + ex.setReason("You can set the gregorian cover air blade status only when the system is configured or tracking and the gregorian cover is open."); ex.log(LM_DEBUG); throw ex.getMinorServoErrorsEx(); } + + SRTMinorServoGregorianAirBladeStatus desired_status; + if(status == "ON") + { + desired_status = AIR_BLADE_STATUS_ON; + } + else if(status == "OFF") + { + desired_status = AIR_BLADE_STATUS_OFF; + } + else + { + desired_status = AIR_BLADE_STATUS_AUTO; + } + + if(desired_status != m_status.getGregorianAirBladeStatus()) + { + ACS_LOG(LM_FULL_INFO, "setGregorianAirBladeStatus", (LM_NOTICE, ("SETTING AIR BLADE STATUS TO " + status).c_str())); + + if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::stow("GREGORIAN_CAP", 2 + (unsigned int)desired_status)).checkOutput()) + { + _EXCPT(MinorServoErrors::StowErrorExImpl, ex, "SRTMinorServoBossCore::setGregorianAirBladeStatus()"); + ex.addData("Reason", "Error while sending a STOW command to the gregorian cover."); + ex.log(LM_DEBUG); + throw ex.getMinorServoErrorsEx(); + } + } } void SRTMinorServoBossCore::preset(double elevation) @@ -1227,7 +1303,7 @@ void SRTMinorServoBossCore::checkLineStatus() _EXCPT(MinorServoErrors::StatusErrorExImpl, ex, "SRTMinorServoBossCore::checkLineStatus()"); ex.setReason("Socket not connected."); ex.log(LM_DEBUG); - setFailure(); + setError(ERROR_NOT_CONNECTED); throw ex.getMinorServoErrorsEx(); } @@ -1236,7 +1312,7 @@ void SRTMinorServoBossCore::checkLineStatus() _EXCPT(MinorServoErrors::StatusErrorExImpl, ex, "SRTMinorServoBossCore::checkLineStatus()"); ex.setReason("MinorServo system is not controlled by DISCOS."); ex.log(LM_DEBUG); - setFailure(); + setError(ERROR_MAINTENANCE); throw ex.getMinorServoErrorsEx(); } @@ -1245,7 +1321,7 @@ void SRTMinorServoBossCore::checkLineStatus() _EXCPT(MinorServoErrors::StatusErrorExImpl, ex, "SRTMinorServoBossCore::checkLineStatus()"); ex.setReason("MinorServo system in emergency status."); ex.log(LM_DEBUG); - setFailure(); + setError(ERROR_EMERGENCY_STOP); throw ex.getMinorServoErrorsEx(); } } @@ -1285,7 +1361,7 @@ void SRTMinorServoBossCore::startThread(T*& thread, const ACS::TimeInterval& sle _ADD_BACKTRACE(ComponentErrors::CanNotStartThreadExImpl, ex, impl, "SRTMinorServoBossCore::startThread()"); ex.setThreadName(T::c_thread_name); ex.log(LM_DEBUG); - setFailure(); + setError(ERROR_CONFIG_ERROR); throw ex.getComponentErrorsEx(); } } @@ -1315,10 +1391,12 @@ void SRTMinorServoBossCore::destroyThread(T*& thread) ACS_LOG(LM_FULL_INFO, "SRTMinorServoBossCore::destroyThread()", (LM_NOTICE, (std::string(T::c_thread_name) + " destroyed.").c_str())); } -void SRTMinorServoBossCore::setFailure() +void SRTMinorServoBossCore::setError(SRTMinorServoError error) { - AUTO_TRACE("SRTMinorServoBossCore::setFailure()"); + AUTO_TRACE("SRTMinorServoBossCore::setError()"); + m_commanded_setup = ""; + m_actual_setup = "Error"; m_subsystem_status.store(Management::MNG_FAILURE); m_ready.store(Management::MNG_FALSE); m_elevation_tracking.store(Management::MNG_FALSE); @@ -1327,6 +1405,28 @@ void SRTMinorServoBossCore::setFailure() m_scanning.store(Management::MNG_FALSE); m_tracking.store(Management::MNG_FALSE); m_motion_status.store(MOTION_STATUS_ERROR); + m_error_code.store(error); +} + +void SRTMinorServoBossCore::reset(bool force) +{ + AUTO_TRACE("SRTMinorServoBossCore::reset()"); + + if(m_error_code.load() == ERROR_NOT_CONNECTED && !force) + { + // If we are still not connected we should not proceed with the reset + return; + } + + for(const auto& [servo_name, servo] : m_servos) + { + servo->reset(); + } + + m_actual_setup = "Unknown"; + m_subsystem_status.store(Management::MNG_WARNING); + m_motion_status.store(MOTION_STATUS_UNCONFIGURED); + m_error_code.store(ERROR_NO_ERROR); } Management::TBoolean SRTMinorServoBossCore::getCDBConfiguration(std::string which_configuration) diff --git a/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossImpl.cpp b/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossImpl.cpp index 8a8a55374..ee9f13f24 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossImpl.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTMinorServoBossImpl.cpp @@ -30,7 +30,9 @@ SRTMinorServoBossImpl::SRTMinorServoBossImpl(const ACE_CString& component_name, m_power_ptr(this), m_emergency_ptr(this), m_gregorian_cover_ptr(this), - m_last_executed_command_ptr(this) + m_air_blade_ptr(this), + m_last_executed_command_ptr(this), + m_error_code_ptr(this) { AUTO_TRACE("SRTMinorServoBossImpl::SRTMinorServoBossImpl()"); @@ -60,7 +62,7 @@ void SRTMinorServoBossImpl::initialize() m_actual_setup_ptr = new baci::ROstring((m_component_name + ":actualSetup").c_str(), getComponent(), new MSGenericDevIO(m_core.m_actual_setup), true); m_motion_info_ptr = new baci::ROstring((m_component_name + ":motionInfo").c_str(), getComponent(), - new MSMotionInfoDevIO(m_core.m_motion_status, m_core.m_status, m_core.m_scanning, m_core.m_current_scan), true); + new MSMotionInfoDevIO(m_core.m_motion_status, m_core.m_status, m_core.m_error_code, m_core.m_scanning, m_core.m_current_scan), true); m_starting_ptr = new ROEnumImpl((m_component_name + ":starting").c_str(), getComponent(), new MSGenericDevIO>(m_core.m_starting), true); m_as_configuration_ptr = new ROEnumImpl((m_component_name + ":asConfiguration").c_str(), getComponent(), @@ -87,8 +89,11 @@ void SRTMinorServoBossImpl::initialize() m_emergency_ptr = new ROEnumImpl((m_component_name + ":emergency").c_str(), getComponent(), new MSAnswerMapDevIO("emergency", m_core.m_status, &SRTMinorServoGeneralStatus::emergencyPressed), true); m_gregorian_cover_ptr = new ROEnumImpl((m_component_name + ":gregorian_cover").c_str(), getComponent(), new MSAnswerMapDevIO("gregorian_cover", m_core.m_status, &SRTMinorServoGeneralStatus::getGregorianCoverPosition), true); + m_air_blade_ptr = new ROEnumImpl((m_component_name + ":air_blade").c_str(), getComponent(), new MSAnswerMapDevIO("air_blade", m_core.m_status, &SRTMinorServoGeneralStatus::getGregorianAirBladeStatus), true); m_last_executed_command_ptr = new baci::ROdouble((m_component_name + ":last_executed_command").c_str(), getComponent(), new MSAnswerMapDevIO("last_executed_command", m_core.m_status, &SRTMinorServoGeneralStatus::getLastExecutedCommand), true); + m_error_code_ptr = new ROEnumImpl((m_component_name + ":error_code").c_str(), getComponent(), + new MSGenericDevIO>(m_core.m_error_code), true); } catch(std::bad_alloc& ba) { @@ -105,7 +110,8 @@ void SRTMinorServoBossImpl::initialize() m_parser.add("setServoASConfiguration", new SP::function1>(this, &SRTMinorServoBossImpl::setASConfiguration), 1); m_parser.add("setServoOffset", new SP::function2, SP::I>(this, &SRTMinorServoBossImpl::setUserOffset), 2); m_parser.add("clearServoOffsets", new SP::function0(this, &SRTMinorServoBossImpl::clearOffsets), 0); - //m_parser.add("setGregorianCoverPosition", new SP::function1>(this, &SRTMinorServoBossImpl::setGregorianCoverPosition), 1); + m_parser.add("setGregorianCoverPosition", new SP::function1>(this, &SRTMinorServoBossImpl::setGregorianCoverPosition), 1); + m_parser.add("setGregorianAirBladeStatus", new SP::function1>(this, &SRTMinorServoBossImpl::setGregorianAirBladeStatus), 1); ACS_LOG(LM_FULL_INFO, "SRTMinorServoBossImpl::initialize()", (LM_NOTICE, "PARSER INITIALIZED")); @@ -335,6 +341,12 @@ void SRTMinorServoBossImpl::setGregorianCoverPosition(const char* position) m_core.setGregorianCoverPosition(std::string(position)); } +void SRTMinorServoBossImpl::setGregorianAirBladeStatus(const char* status) +{ + AUTO_TRACE("SRTMinorServoBossImpl::setGregorianAirBladeStatus()"); + m_core.setGregorianAirBladeStatus(std::string(status)); +} + CORBA::Boolean SRTMinorServoBossImpl::checkScan(const ACS::Time start_time, const MinorServoScan& scan_info, const Antenna::TRunTimeParameters& antenna_info, TRunTimeParameters_out ms_parameters) { AUTO_TRACE("SRTMinorServoBossImpl::checkScan()"); @@ -359,6 +371,12 @@ void SRTMinorServoBossImpl::preset(double elevation) m_core.preset(elevation); } +void SRTMinorServoBossImpl::reset() +{ + AUTO_TRACE("SRTMinorServoBossImpl::reset()"); + m_core.reset(); +} + CORBA::Boolean SRTMinorServoBossImpl::command(const char* cmd, CORBA::String_out answer) { AUTO_TRACE("SRTMinorServoBossImpl::command()"); @@ -416,7 +434,9 @@ GET_PROPERTY_REFERENCE(ROSRTMinorServoControlStatus, SRTMinorServoBossImpl, m_co GET_PROPERTY_REFERENCE(Management::ROTBoolean, SRTMinorServoBossImpl, m_power_ptr, power); GET_PROPERTY_REFERENCE(Management::ROTBoolean, SRTMinorServoBossImpl, m_emergency_ptr, emergency); GET_PROPERTY_REFERENCE(ROSRTMinorServoGregorianCoverStatus, SRTMinorServoBossImpl, m_gregorian_cover_ptr, gregorian_cover); +GET_PROPERTY_REFERENCE(ROSRTMinorServoGregorianAirBladeStatus, SRTMinorServoBossImpl, m_air_blade_ptr, air_blade); GET_PROPERTY_REFERENCE(ACS::ROdouble, SRTMinorServoBossImpl, m_last_executed_command_ptr, last_executed_command); +GET_PROPERTY_REFERENCE(ROSRTMinorServoError, SRTMinorServoBossImpl, m_error_code_ptr, error_code); #include MACI_DLL_SUPPORT_FUNCTIONS(SRTMinorServoBossImpl) diff --git a/SRT/Servers/SRTMinorServo/src/SRTMinorServoParkThread.cpp b/SRT/Servers/SRTMinorServo/src/SRTMinorServoParkThread.cpp index 8afaab79f..f13092fb3 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTMinorServoParkThread.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTMinorServoParkThread.cpp @@ -43,7 +43,6 @@ void SRTMinorServoParkThread::runLoop() catch(MinorServoErrors::MinorServoErrorsEx& ex) { ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); - m_core.setFailure(); this->setStopped(); return; } @@ -51,7 +50,7 @@ void SRTMinorServoParkThread::runLoop() if(IRA::CIRATools::getUNIXEpoch() - m_start_time >= PARK_TIMEOUT) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoParkThread::runLoop()", (LM_CRITICAL, "Timeout while performing a park operation.")); - m_core.setFailure(); + m_core.setError(ERROR_CONFIG_ERROR); this->setStopped(); return; } @@ -61,13 +60,13 @@ void SRTMinorServoParkThread::runLoop() case 0: { // First we check if the gregorian cover has closed - //bool completed = m_core.m_status.getGregorianCoverPosition() == COVER_STATUS_CLOSED ? true : false; + bool completed = m_core.m_status.getGregorianCoverPosition() == COVER_STATUS_CLOSED; // Then we cycle through all the servos and make sure their operative mode is STOP - if(/*completed && */std::all_of(m_core.m_servos.begin(), m_core.m_servos.end(), [](const std::pair& servo) -> bool + if(completed && std::all_of(m_core.m_servos.begin(), m_core.m_servos.end(), [](const std::pair& servo) -> bool { ACSErr::Completion_var comp; - return servo.second->operative_mode()->get_sync(comp.out()) == OPERATIVE_MODE_STOP ? true : false; + return servo.second->operative_mode()->get_sync(comp.out()) == OPERATIVE_MODE_STOP; })) { m_status = 1; diff --git a/SRT/Servers/SRTMinorServo/src/SRTMinorServoScanThread.cpp b/SRT/Servers/SRTMinorServo/src/SRTMinorServoScanThread.cpp index a70f66795..d195b2bf1 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTMinorServoScanThread.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTMinorServoScanThread.cpp @@ -67,7 +67,6 @@ void SRTMinorServoScanThread::onStop() if(m_error) // We didn't reach the end of the scan because of some error { // Should we set everything to failure? - m_core.setFailure(); return; } @@ -168,6 +167,7 @@ void SRTMinorServoScanThread::runLoop() else { m_error = true; + m_core.setError(ERROR_CONFIG_ERROR); this->setStopped(); return; } @@ -224,6 +224,7 @@ void SRTMinorServoScanThread::runLoop() { ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); m_error = true; + m_core.setError(ERROR_COMMAND_ERROR); this->setStopped(); return; } diff --git a/SRT/Servers/SRTMinorServo/src/SRTMinorServoSetupThread.cpp b/SRT/Servers/SRTMinorServo/src/SRTMinorServoSetupThread.cpp index 1daa85968..c48f98d14 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTMinorServoSetupThread.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTMinorServoSetupThread.cpp @@ -23,9 +23,9 @@ void SRTMinorServoSetupThread::onStart() m_status = 0; - //SRTMinorServoFocalConfiguration commanded_configuration = m_core.m_commanded_configuration.load(); - //m_LDO_configuration = LDOConfigurationNameTable.left.at(commanded_configuration); - //m_gregorian_cover_position = commanded_configuration == CONFIGURATION_PRIMARY ? COVER_STATUS_CLOSED : COVER_STATUS_OPEN; + SRTMinorServoFocalConfiguration commanded_configuration = m_core.m_commanded_configuration.load(); + m_LDO_configuration = LDOConfigurationNameTable.left.at(commanded_configuration); + m_gregorian_cover_position = commanded_configuration == CONFIGURATION_PRIMARY ? COVER_STATUS_CLOSED : COVER_STATUS_OPEN; ACS_LOG(LM_FULL_INFO, "SRTMinorServoSetupThread::onStart()", (LM_NOTICE, ("SETUP THREAD STARTED WITH '" + m_core.m_commanded_setup + "' CONFIGURATION").c_str())); } @@ -45,7 +45,6 @@ void SRTMinorServoSetupThread::onStop() catch(ComponentErrors::ComponentErrorsEx& ex) { ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); - m_core.setFailure(); } } } @@ -61,7 +60,6 @@ void SRTMinorServoSetupThread::runLoop() catch(MinorServoErrors::StatusErrorEx& ex) { ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); - m_core.setFailure(); this->setStopped(); return; } @@ -69,7 +67,7 @@ void SRTMinorServoSetupThread::runLoop() if(IRA::CIRATools::getUNIXEpoch() - m_start_time >= SETUP_TIMEOUT) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoSetupThread::runLoop()", (LM_CRITICAL, "Timeout while performing a setup operation.")); - m_core.setFailure(); + m_core.setError(ERROR_CONFIG_ERROR); this->setStopped(); return; } @@ -98,32 +96,17 @@ void SRTMinorServoSetupThread::runLoop() servo->clearUserOffsets(); } - //m_status = 2; - //m_status = 100; - m_status = 5; + m_status = 2; break; } - /*case 100: // Send the STOW command to the gregorian cover - { - if(!m_core.m_socket.sendCommand(SRTMinorServoCommandLibrary::stow("Gregoriano", m_gregorian_cover_position)).checkOutput()) - { - ACS_LOG(LM_FULL_INFO, "SRTMinorServoSetupThread::runLoop()", (LM_CRITICAL, "Received NAK when setting the gregorian cover position.")); - m_core.setFailure(); - this->setStopped(); - return; - } - - m_status = 5; - break; - }*/ - /*case 2: // Send the SETUP command + case 2: // Send the SETUP command { try { if(!m_core.m_socket.sendCommand(SRTMinorServoCommandLibrary::setup(m_LDO_configuration)).checkOutput()) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoSetupThread::runLoop()", (LM_CRITICAL, "Received NAK in response to a SETUP command.")); - m_core.setFailure(); + m_core.setError(ERROR_CONFIG_ERROR); this->setStopped(); return; } @@ -135,7 +118,7 @@ void SRTMinorServoSetupThread::runLoop() catch(...) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoSetupThread::runLoop()", (LM_CRITICAL, "Communication error while sending a SETUP command.")); - m_core.setFailure(); + m_core.setError(ERROR_CONFIG_ERROR); this->setStopped(); return; } @@ -151,24 +134,21 @@ void SRTMinorServoSetupThread::runLoop() break; } - case 4: // Wait for the whole system to reach the desired configuration + case 4: // Wait for all the servos to reach the desired configuration { - // First we check the status of the gregorian cover - bool completed = m_core.m_status.getGregorianCoverPosition() == m_gregorian_cover_position ? true : false; - // Then we cycle through all the servos and make sure their operative mode is SETUP - if(completed && std::all_of(m_core.m_servos.begin(), m_core.m_servos.end(), [](const std::pair& servo) -> bool + if(std::all_of(m_core.m_servos.begin(), m_core.m_servos.end(), [](const std::pair& servo) -> bool { ACSErr::Completion_var comp; - return servo.second->operative_mode()->get_sync(comp.out()) == OPERATIVE_MODE_SETUP ? true : false; + return servo.second->operative_mode()->get_sync(comp.out()) == OPERATIVE_MODE_SETUP; })) { m_status = 5; } break; - }*/ - case 5: // Load the servos coefficients and send a PRESET command + } + case 5: // Load the servos coefficients { for(const auto& [servo_name, servo] : m_core.m_servos) { @@ -190,38 +170,43 @@ void SRTMinorServoSetupThread::runLoop() catch(...) { ACS_LOG(LM_FULL_INFO, "SRTMinorServoSetupThread::runLoop()", (LM_CRITICAL, ("Error while loading a SETUP to servo'" + servo_name + "'.").c_str())); - m_core.setFailure(); + m_core.setError(ERROR_CONFIG_ERROR); this->setStopped(); return; } } - // This step is necessary because we have _ASACTIVE configurations that have a slightly different position from the commanded one - // Unfortunately, the Leonardo implementation accepts a fixed number of configurations, therefore we share the _ASACTIVE and AS not active configurations for each focal position - for(const auto& [servo_name, servo] : m_core.m_current_servos) + if(m_core.m_commanded_setup.find("_ASACTIVE") == std::string::npos) { - try - { - servo->preset(*servo->calcCoordinates(45)); - } - catch(MinorServoErrors::MinorServoErrorsEx& ex) + // We commanded a configuration which does not use the active surface, therefore we need to send some slightly different coordinates with a preset command + + for(const auto& [servo_name, servo] : m_core.m_current_servos) { - ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); - m_core.setFailure(); - this->setStopped(); - return; + try + { + servo->preset(*servo->calcCoordinates(45)); + } + catch(MinorServoErrors::MinorServoErrorsEx& ex) + { + ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); + m_core.setError(ERROR_COMMAND_ERROR); + this->setStopped(); + return; + } } + m_status = 6; + } + else + { + // _ASACTIVE configuration, jump directly to state 7 + m_status = 7; } - m_status = 6; break; } - case 6: // Wait for the whole system to reach the PRESET configuration + case 6: // Wait for the used servos to reach the PRESET configuration { - // First we check the status of the gregorian cover - //bool completed = m_core.m_status.getGregorianCoverPosition() == m_gregorian_cover_position ? true : false; - - if(/*completed && */std::all_of(m_core.m_current_servos.begin(), m_core.m_current_servos.end(), [this](const std::pair& servo) -> bool + if(std::all_of(m_core.m_current_servos.begin(), m_core.m_current_servos.end(), [this](const std::pair& servo) -> bool { ACSErr::Completion_var comp; return servo.second->operative_mode()->get_sync(comp.out()) == OPERATIVE_MODE_PRESET ? true : false; @@ -232,7 +217,16 @@ void SRTMinorServoSetupThread::runLoop() break; } - case 7: // Finally set all the variables values and eventually start the elevation tracking thread + case 7: // Check the status of the gregorian cover + { + if(m_core.m_status.getGregorianCoverPosition() == m_gregorian_cover_position) + { + m_status = 8; + } + + break; + } + case 8: // Finally set all the variables values and eventually start the elevation tracking thread { m_core.m_actual_setup = m_core.m_commanded_setup; m_core.m_starting.store(Management::MNG_FALSE); diff --git a/SRT/Servers/SRTMinorServo/src/SRTMinorServoTrackingThread.cpp b/SRT/Servers/SRTMinorServo/src/SRTMinorServoTrackingThread.cpp index 7f4350101..b45fb40e5 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTMinorServoTrackingThread.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTMinorServoTrackingThread.cpp @@ -4,8 +4,7 @@ using namespace MinorServo; SRTMinorServoTrackingThread::SRTMinorServoTrackingThread(const ACE_CString& name, SRTMinorServoBossCore& core, const ACS::TimeInterval& response_time, const ACS::TimeInterval& sleep_time): ACS::Thread(name, response_time, sleep_time), - m_core(core), - m_error(false) + m_core(core) { AUTO_TRACE("SRTMinorServoTrackingThread::SRTMinorServoTrackingThread()"); } @@ -33,11 +32,6 @@ void SRTMinorServoTrackingThread::onStop() ACS_LOG(LM_FULL_INFO, "SRTMinorServoTrackingThread::onStop()", (LM_NOTICE, "TRACKING THREAD STOPPED")); m_core.m_elevation_tracking.store(Management::MNG_FALSE); - - if(m_error) - { - m_core.setFailure(); - } } void SRTMinorServoTrackingThread::runLoop() @@ -51,7 +45,6 @@ void SRTMinorServoTrackingThread::runLoop() catch(MinorServoErrors::MinorServoErrorsEx& ex) { ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); - m_error = true; this->setStopped(); return; } @@ -59,7 +52,7 @@ void SRTMinorServoTrackingThread::runLoop() if(m_core.m_motion_status.load() != MOTION_STATUS_TRACKING) { // System is not ready or is not configured for tracking yet, we wait, even though we should never get here - _IRA_LOGFILTER_LOG(LM_WARNING, "SRTMinorServoScanThread::runLoop()", "Waiting for the system to be configured for tracking!"); + _IRA_LOGFILTER_LOG(LM_WARNING, "SRTMinorServoTrackingThread::runLoop()", "Waiting for the system to be configured for tracking!"); return; } @@ -87,7 +80,7 @@ void SRTMinorServoTrackingThread::runLoop() } else { - m_error = true; + m_core.setError(ERROR_CONFIG_ERROR); this->setStopped(); return; } @@ -103,7 +96,7 @@ void SRTMinorServoTrackingThread::runLoop() } catch(ComponentErrors::ComponentErrorsEx& ex) { - _IRA_LOGFILTER_LOG(LM_WARNING, "SRTMinorServoScanThread::runLoop()", (std::string(getReasonFromEx(ex)) + ": using a fixed elevation of 45° for tracking!").c_str()); + _IRA_LOGFILTER_LOG(LM_WARNING, "SRTMinorServoTrackingThread::runLoop()", (std::string(getReasonFromEx(ex)) + ": using a fixed elevation of 45° for tracking!").c_str()); m_core.m_elevation_tracking.store(Management::MNG_FALSE); } @@ -114,21 +107,21 @@ void SRTMinorServoTrackingThread::runLoop() catch(MinorServoErrors::MinorServoErrorsEx& ex) { ACS_SHORT_LOG((LM_ERROR, ex.errorTrace.routine)); - m_error = true; + m_core.setError(ERROR_COMMAND_ERROR); this->setStopped(); return; } catch(std::exception& ex) { ACS_SHORT_LOG((LM_ERROR, ex.what())); - m_error = true; + m_core.setError(ERROR_COMMAND_ERROR); this->setStopped(); return; } catch(CORBA::Exception& ex) { ACS_SHORT_LOG((LM_ERROR, ex._info().c_str())); - m_error = true; + m_core.setError(ERROR_COMMAND_ERROR); this->setStopped(); return; } diff --git a/SRT/Servers/SRTMinorServo/src/SRTProgramTrackMinorServoImpl.cpp b/SRT/Servers/SRTMinorServo/src/SRTProgramTrackMinorServoImpl.cpp index 16fa1ebd6..ddad515e1 100644 --- a/SRT/Servers/SRTMinorServo/src/SRTProgramTrackMinorServoImpl.cpp +++ b/SRT/Servers/SRTMinorServo/src/SRTProgramTrackMinorServoImpl.cpp @@ -55,53 +55,70 @@ bool SRTProgramTrackMinorServoImpl::status() { bool status = SRTBaseMinorServoImpl::status(); - try + ACS::doubleSeq virtual_positions = m_status.getVirtualPositions(); + std::vector commanded_positions; + + SRTMinorServoOperativeMode operative_mode = m_status.getOperativeMode(); + if(operative_mode == OPERATIVE_MODE_PROGRAMTRACK) { - ACS::Time last_timestamp = m_status.getTimestamp(); + try + { + ACS::Time last_timestamp = m_status.getTimestamp(); - // The timestamp of the read positions always corresponds to the one we're asking since they both belong to the same STATUS command answer - // The tracking timestamp is interpolated instead - ACS::doubleSeq virtual_positions = m_status.getVirtualPositions(); - std::pair> tracking_point = m_tracking_queue.get(last_timestamp); + // The timestamp of the read positions always corresponds to the one we're asking since they both belong to the same STATUS command answer + // The tracking timestamp is interpolated instead + std::pair> tracking_point = m_tracking_queue.get(last_timestamp); + commanded_positions = tracking_point.second; - m_remaining_trajectory_points.store(m_tracking_queue.getRemainingPoints(last_timestamp)); + m_remaining_trajectory_points.store(m_tracking_queue.getRemainingPoints(last_timestamp)); - if(tracking_point.first < last_timestamp) + if(tracking_point.first < last_timestamp) + { + // We are past the last point of the trajectory, we concluded it + m_tracking.store(Management::MNG_FALSE); + m_tracking_queue.clear(); + m_tracking_error = std::vector(m_virtual_axes, 0.0); + return status; + } + } + catch(...) { - // We are past the last point of the trajectory, we concluded it - m_tracking.store(Management::MNG_FALSE); - m_tracking_queue.clear(); + // We might get here if m_tracking_queue is empty + // So whenever we just got a new setup or if we are past the last point inside the trajectory + m_tracking.store(Management::MNG_FALSE); // May be redundant but who cares? m_tracking_error = std::vector(m_virtual_axes, 0.0); + return status; } - else - { - bool is_tracking = true; + } + else if(operative_mode == OPERATIVE_MODE_SETUP || operative_mode == OPERATIVE_MODE_PRESET) + { + commanded_positions = m_commanded_virtual_positions; + } + else + { + m_tracking.store(Management::MNG_FALSE); + m_tracking_error = std::vector(m_virtual_axes, 0.0); + return status; + } - std::transform(virtual_positions.begin(), virtual_positions.end(), tracking_point.second.begin(), m_tracking_error.begin(), [](double current_pos, double commanded_pos) - { - return std::fabs(current_pos - commanded_pos); - }); + bool is_tracking = true; - for(size_t i = 0; i < m_virtual_axes; i++) - { - if(std::fabs(m_tracking_error[i]) > m_tracking_delta[i]) - { - is_tracking = false; - break; - } - } + std::transform(virtual_positions.begin(), virtual_positions.end(), commanded_positions.begin(), m_tracking_error.begin(), [](double current_pos, double commanded_pos) + { + return std::fabs(current_pos - commanded_pos); + }); - m_tracking.store(is_tracking ? Management::MNG_TRUE : Management::MNG_FALSE); - } - } - catch(...) + for(size_t i = 0; i < m_virtual_axes; i++) { - // We might get here if m_tracking_queue is empty - // So whenever we just got a new setup or if we are past the last point inside the trajectory - m_tracking.store(Management::MNG_FALSE); // May be redundant but who cares? - m_tracking_error = std::vector(m_virtual_axes, 0.0); + if(std::fabs(m_tracking_error[i]) > m_tracking_delta[i]) + { + is_tracking = false; + break; + } } + m_tracking.store(is_tracking ? Management::MNG_TRUE : Management::MNG_FALSE); + return status; } @@ -147,6 +164,7 @@ void SRTProgramTrackMinorServoImpl::programTrack(CORBA::Long trajectory_id, CORB if(!m_socket.sendCommand(SRTMinorServoCommandLibrary::programTrack(m_servo_name, trajectory_id, point_id, coordinates, point_id > 0 ? 0 : IRA::CIRATools::ACSTime2UNIXEpoch(point_time))).checkOutput()) { + m_error_code.store(ERROR_COMMAND_ERROR); _EXCPT(MinorServoErrors::CommunicationErrorExImpl, ex, (m_servo_name + "::programTrack()").c_str()); ex.setReason("Received NAK in response to a PROGRAMTRACK command!"); ex.log(LM_DEBUG); diff --git a/SRT/Servers/SRTMinorServo/src/_airBlade.py b/SRT/Servers/SRTMinorServo/src/_airBlade.py new file mode 100644 index 000000000..820e945cf --- /dev/null +++ b/SRT/Servers/SRTMinorServo/src/_airBlade.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +# This is a python script that can be used to set the air blade status +# who when what +# Giuseppe Carboni(giuseppe.carboni@inaf.it) 18/05/2024 Creation + +from Acspy.Clients.SimpleClient import PySimpleClient +import ACSLog +import maciErrType +import maciErrTypeImpl +import ClientErrorsImpl +import MinorServoErrors +import ManagementErrorsImpl +import sys +from SimpleParserPy import add_user_message + +def main(): + compName = 'MINORSERVO/Boss' + + simpleClient = PySimpleClient() + + try: + component = simpleClient.getComponent(compName) + except Exception as ex: + newEx = ClientErrorsImpl.CouldntAccessComponentExImpl(exception=ex, create=1) + newEx.setComponentName(compName) + add_user_message(newEx, 'MinorServoBoss not ready or not properly configured') + simpleClient.disconnect() + sys.exit(1) + + try: + inputs = component.setGregorianAirBladeStatus(sys.argv[1]) + except MinorServoErrors.MinorServoErrorsEx as ex: + newEx = ClientErrorsImpl.CouldntPerformActionExImpl(exception=ex, create=1) + newEx.setReason('MinorServoBoss gregorian air blade status') + add_user_message(newEx, 'Unable to set the gregorian air blade status') + simpleClient.disconnect() + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/SRT/Servers/SRTMinorServo/src/_servoReset.py b/SRT/Servers/SRTMinorServo/src/_servoReset.py new file mode 100644 index 000000000..ab95fdc16 --- /dev/null +++ b/SRT/Servers/SRTMinorServo/src/_servoReset.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +# This is a python script that can be used to send OR7 VBrain an emergency and +# alarms reset command +# who when what +# Giuseppe Carboni(giuseppe.carboni@inaf.it) 21/05/2024 Creation + +import sys +import time +import requests +import urllib3 +import cdbErrType +import ComponentErrorsImpl +import ClientErrorsImpl +from IRAPy import logger +from SimpleParserPy import add_user_message +from Acspy.Clients.SimpleClient import PySimpleClient +from Acspy.Util import ACSCorba +from MinorServo import ERROR_NO_ERROR + + +def get_cdb_args(): + try: + path = 'alma/MINORSERVO/VBrain' + dal = ACSCorba.cdb() + dao = dal.get_DAO_Servant(path) + field = 'Protocol' + protocol = dao.get_field_data(field).strip() + field = 'IPAddress' + address = dao.get_field_data(field).strip() + field = 'Port' + port = dao.get_field_data(field).strip() + except cdbErrType.CDBRecordDoesNotExistEx: + reason = f'CDB record {path} does not exist' + logger.logError(reason) + exc = ComponentErrorsImpl.CouldntGetAttributeExImpl() + exc.setData('Reason', reason) + raise exc + except cdbErrType.CDBFieldDoesNotExistEx: + reason = f'CDB field {field} does not exist' + logger.logError(reasong) + exc = ComponentErrorsImpl.ValidationErrorExImpl() + exc.setReason(reason) + raise exc + return protocol, address, port + + +def send_requests(protocol, address, port): + url = \ + f'{protocol}://{address}:{port}/Exporting/json/ExecuteCommand?name' + emergency = f'{url}=INAF_SRT_OR7_EMG_RESET_CMD' + alarms = f'{url}=INAF_SRT_OR7_RESET_CMD' + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + try: + # We just try to send the commands, if it fails, we do nothing, it + # means there is a problem reaching the VBrain server so we cannot + # reset the status anyway + response = requests.get(emergency, verify=False, timeout=3) + time.sleep(3) + response = requests.get(alarms, verify=False, timeout=3) + except: + pass + + +if __name__ == "__main__": + # Retrieve the CDB attributes + protocol, address, port = get_cdb_args() + + # Retrieve the component + compName = 'MINORSERVO/Boss' + + simpleClient = PySimpleClient() + + try: + component = simpleClient.getComponent(compName) + # Check if we have an error, if not we just exit immediately + error_code = component.error_code.get_sync()[0] + if error_code == ERROR_NO_ERROR: + sys.exit(0) + except Exception as ex: + newEx = ClientErrorsImpl.CouldntAccessComponentExImpl(exception=ex, create=1) + newEx.setComponentName(compName) + add_user_message(newEx, 'MinorServoBoss not ready or not properly configured') + simpleClient.disconnect() + sys.exit(1) + + # Send the reset commands to VBrain + send_requests(protocol, address, port) + + # Send the reset command to the component + component.reset() -- GitLab