From 05d18e6018f359f2f043fe4459ff2c3430d7f08e Mon Sep 17 00:00:00 2001 From: Andrea Orlati Date: Wed, 30 Sep 2020 14:14:42 +0200 Subject: [PATCH] fix issue #553: three keywords added to the main header: 'Subscan LonOffset, SubScan LatOffset, SubScan OffsetFrame' (#555) --- CHANGELOG.md | 3 +- .../AntennaInterface/idl/AntennaBoss.midl | 12 +++++- .../CommonInterface/include/AntennaModule.h | 28 +++++++++++++ .../CommonInterface/src/AntennaModule.cpp | 27 +++++++++++++ .../Interfaces/CommonInterface/src/Makefile | 5 ++- .../AntennaBoss/include/AntennaBossImpl.h | 13 +++++++ Common/Servers/AntennaBoss/include/BossCore.h | 5 +++ .../AntennaBoss/src/AntennaBossImpl.cpp | 15 +++++++ Common/Servers/AntennaBoss/src/BossCore.cpp | 7 ++++ Common/Servers/FitsWriter/include/MetaData.h | 16 ++++++++ Common/Servers/FitsWriter/include/Version.h | 6 ++- .../Servers/FitsWriter/src/EngineThread.cpp | 39 +++++++++++++++++++ Common/Servers/FitsWriter/src/FitsWriter.cpp | 1 + Common/Servers/FitsWriter/src/MetaData.cpp | 2 + 14 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 Common/Interfaces/CommonInterface/src/AntennaModule.cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cf5e1132..f61e5e884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,8 +85,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/ ## [discos1.0.5] - ## Added issue #504 - added credits clause (regarding INAF data ownership) to fits files headers - issue #518 - KBand receivers cryo temperature read wrongly with connection problems. More information: + issue #518 - KBand receivers cryo temperature read wrongly with connection problems. More information: https://github.com/discos/discos/issues/518#issuecomment-590838480 + issue #530 - New Fitszilla versione 1.21 online. The subscan offsets related keywords added to the primary header. ## Fixed issue #518 - In case of communication error we set a dummy value (100000) for the temperature properties, and the related timestamp keeps the value of the last communication timestamp. diff --git a/Common/Interfaces/AntennaInterface/idl/AntennaBoss.midl b/Common/Interfaces/AntennaInterface/idl/AntennaBoss.midl index 5d9387118..8788c9af8 100644 --- a/Common/Interfaces/AntennaInterface/idl/AntennaBoss.midl +++ b/Common/Interfaces/AntennaInterface/idl/AntennaBoss.midl @@ -647,7 +647,7 @@ module Antenna { void getObservedHorizontal(in ACS::Time timestamp,in ACS::TimeInterval duration,out double az,out double el); /** - * This method should only be used internally to know the user offsets currently commanded + * This method should only be used internally to know the offsets currently commanded. i.e. the sum of all offset types * @throw CORBA::SystemExcpetion * @param azOff user offset for the azimuth (radians) * @param elOff user offset for the elevation (radians) @@ -657,6 +657,16 @@ module Antenna { * @param latOff user offset for the latitude (radians) */ void getAllOffsets(out double azOff,out double elOff,out double raOff,out double decOff,out double lonOff,out double latOff); + + /** + * This method should only be used internally to know the scan offsets currently commanded + * @throw CORBA::SystemException + * @param lonOff user offset for the longitude (radians) + * @param latOff user offset for the latitude (radians) + * @param offFrame reference frame of the offsets + */ + void getScanOffsets(out double lonOff, out double latOff,out TCoordinateFrame offFrame); + /** * This method is used internally to know the scan axis/direction os the presently commanded scan diff --git a/Common/Interfaces/CommonInterface/include/AntennaModule.h b/Common/Interfaces/CommonInterface/include/AntennaModule.h index 606128b4e..d9952755d 100644 --- a/Common/Interfaces/CommonInterface/include/AntennaModule.h +++ b/Common/Interfaces/CommonInterface/include/AntennaModule.h @@ -19,6 +19,34 @@ namespace Antenna { */ class Definitions { public: + static bool map(const char *str,TCoordinateFrame& frame) { + if (strcasecmp(str,"EQ")==0) { + frame=Antenna::ANT_EQUATORIAL; + return true; + } + else if (strcasecmp(str,"HOR")==0) { + frame=Antenna::ANT_HORIZONTAL; + return true; + } + else if (strcasecmp(str,"GAL")==0) { + frame=Antenna::ANT_GALACTIC; + return true; + } + else { + return false; + } + } + static const char *map(const TCoordinateFrame& frame) { + if (frame==Antenna::ANT_EQUATORIAL) { + return "EQ"; + } + if (frame==Antenna::ANT_HORIZONTAL) { + return "HOR"; + } + else { // Antenna::ANT_GALACTIC + return "GAL"; + } + } static bool map(const char *str,TsubScanGeometry& geometry) { if (strcasecmp(str,"LAT")==0) { geometry=Antenna::SUBSCAN_CONSTLAT; diff --git a/Common/Interfaces/CommonInterface/src/AntennaModule.cpp b/Common/Interfaces/CommonInterface/src/AntennaModule.cpp new file mode 100644 index 000000000..2d8011249 --- /dev/null +++ b/Common/Interfaces/CommonInterface/src/AntennaModule.cpp @@ -0,0 +1,27 @@ + +#include "AntennaModule.h" + + +#define FRAME_TEST1 "HOR" +#define FRAME_TEST2 "DUMMY" + +int main(int argc, char *argv[]) +{ + Antenna::TCoordinateFrame frame; + printf("galactic frame: %s\n",(const char *)Antenna::Definitions::map(Antenna::ANT_GALACTIC)); + printf("equatorial frame: %s\n",(const char *)Antenna::Definitions::map(Antenna::ANT_EQUATORIAL)); + printf("horizontal frame: %s\n",(const char *)Antenna::Definitions::map(Antenna::ANT_HORIZONTAL)); + if (Antenna::Definitions::map(FRAME_TEST1,frame)) { + printf("%s maps to %s\n",FRAME_TEST1,(const char *)Antenna::Definitions::map(frame)); + } + else { + printf("Conversion Error: %s\n",(const char *)FRAME_TEST1); + } + if (Antenna::Definitions::map(FRAME_TEST2,frame)) { + printf("%s maps to %s\n",FRAME_TEST2,(const char *)Antenna::Definitions::map(frame)); + } + else { + printf("Conversion Error: %s\n",(const char *)FRAME_TEST2); + } + return 0; +} diff --git a/Common/Interfaces/CommonInterface/src/Makefile b/Common/Interfaces/CommonInterface/src/Makefile index c80275755..8cd217de2 100644 --- a/Common/Interfaces/CommonInterface/src/Makefile +++ b/Common/Interfaces/CommonInterface/src/Makefile @@ -37,7 +37,7 @@ MAKE_PDF = ON # C programs (public and local) # ----------------------------- EXECUTABLES = -EXECUTABLES_L = TestReceivers TestManagement #TestAntenna +EXECUTABLES_L = TestReceivers TestManagement TestAntenna TestReceivers_OBJECTS = ReceiversModule TestReceivers_LIBS= baci maci @@ -45,6 +45,9 @@ TestReceivers_LIBS= baci maci TestManagement_OBJECTS = ManagementModule TestManagement_LIBS= ManagementErrors baci maci +TestAntenna_OBJECTS = AntennaModule +TestAntenna_LIBS= baci maci + # # xxxxx_OBJECTS = diff --git a/Common/Servers/AntennaBoss/include/AntennaBossImpl.h b/Common/Servers/AntennaBoss/include/AntennaBossImpl.h index 1a22972dc..50d1347ec 100644 --- a/Common/Servers/AntennaBoss/include/AntennaBossImpl.h +++ b/Common/Servers/AntennaBoss/include/AntennaBossImpl.h @@ -632,6 +632,19 @@ public: */ void getAllOffsets(CORBA::Double_out azOff,CORBA::Double_out elOff,CORBA::Double_out raOff,CORBA::Double_out decOff,CORBA::Double_out lonOff,CORBA::Double_out latOff) throw (CORBA::SystemException); + /** + * This method should only be used internally to know the scan offsets currently commanded + * @throw CORBA::SystemException + * @param azOff user offset for the azimuth (radians) + * @param elOff user offset for the elevation (radians) + * @param raOff user offset for the right ascension (radians) + * @param decOff user offset for the declination (radians) + * @param lonOff user offset for the longitude (radians) + * @param latOff user offset for the latitude (radians) + */ + void getScanOffsets(CORBA::Double_out lonOff,CORBA::Double_out latOff, + Antenna::TCoordinateFrame_out frameOff) throw (CORBA::SystemException); + /** * It can be called to know which is the axis the antenna is currently performing the scan * @param axis returned identfier of the axis diff --git a/Common/Servers/AntennaBoss/include/BossCore.h b/Common/Servers/AntennaBoss/include/BossCore.h index c789f9f8f..8e6f11c81 100644 --- a/Common/Servers/AntennaBoss/include/BossCore.h +++ b/Common/Servers/AntennaBoss/include/BossCore.h @@ -322,6 +322,11 @@ public: */ void getAllOffsets(double& azOff,double& elOff,double& raOff,double& decOff,double& lonOff,double& latOff) const; + /** + * Get the scan offsets configured for the current scan + */ + void getScanOffsets(double& lonOff,double& latOff,Antenna::TCoordinateFrame& frame); + /** * @return the J2000 right ascension of the target */ diff --git a/Common/Servers/AntennaBoss/src/AntennaBossImpl.cpp b/Common/Servers/AntennaBoss/src/AntennaBossImpl.cpp index 54d5dc27e..47335abb3 100644 --- a/Common/Servers/AntennaBoss/src/AntennaBossImpl.cpp +++ b/Common/Servers/AntennaBoss/src/AntennaBossImpl.cpp @@ -612,6 +612,21 @@ void AntennaBossImpl::getAllOffsets(CORBA::Double_out azOff,CORBA::Double_out el azOff=(CORBA::Double)az; elOff=(CORBA::Double)el; raOff=(CORBA::Double)ra; decOff=(CORBA::Double)dec; lonOff=(CORBA::Double)lon; latOff=(CORBA::Double)lat; } +void AntennaBossImpl::getScanOffsets(CORBA::Double_out lonOff,CORBA::Double_out latOff, + Antenna::TCoordinateFrame_out frameOff) throw (CORBA::SystemException) +{ + double lon,lat; + Antenna::TCoordinateFrame frame; + if (!m_core) { + lonOff=latOff=0.0; + frameOff=Antenna::ANT_HORIZONTAL; + return; + } + CSecAreaResourceWrapper resource=m_core->Get("IMPL:getScanOffsets"); + resource->getScanOffsets(lon,lat,frame); + lonOff=(CORBA::Double)lon; latOff=(CORBA::Double)lat; frameOff=frame; +} + void AntennaBossImpl::getScanAxis (Management::TScanAxis_out axis) throw (CORBA::SystemException) { if (!m_core) { diff --git a/Common/Servers/AntennaBoss/src/BossCore.cpp b/Common/Servers/AntennaBoss/src/BossCore.cpp index 9241a9eed..f5694844a 100644 --- a/Common/Servers/AntennaBoss/src/BossCore.cpp +++ b/Common/Servers/AntennaBoss/src/BossCore.cpp @@ -659,6 +659,13 @@ void CBossCore::setOffsets(const double& lonOff,const double& latOff,const Anten addOffsets(m_longitudeOffset,m_latitudeOffset,m_offsetFrame,m_userOffset,m_scanOffset); } +void CBossCore::getScanOffsets(double& lonOff,double& latOff,Antenna::TCoordinateFrame& frame) +{ + lonOff=m_scanOffset.lon; + latOff=m_scanOffset.lat; + frame=m_scanOffset.frame; +} + void CBossCore::getAllOffsets(double& azOff,double& elOff,double& raOff,double& decOff,double& lonOff,double& latOff) const { if (m_offsetFrame==Antenna::ANT_HORIZONTAL) { diff --git a/Common/Servers/FitsWriter/include/MetaData.h b/Common/Servers/FitsWriter/include/MetaData.h index e3666a40f..790990d2d 100644 --- a/Common/Servers/FitsWriter/include/MetaData.h +++ b/Common/Servers/FitsWriter/include/MetaData.h @@ -167,6 +167,13 @@ public: m_azOff=azOff; m_elOff=elOff; m_raOff=raOff; m_decOff=decOff; m_lonOff=lonOff; m_latOff=latOff; } + /** + * It allows to set the antenna scan offsets as directly returned by the Antenna subsystem + */ + void setAntennaScanOffsets(const double& lon,const double& lat, const Antenna::TCoordinateFrame& frame) { + m_lonScanOff=lon;m_latScanOff=lat;m_frameScanOff=frame; + } + /** * @return the antenna position offsets */ @@ -174,6 +181,13 @@ public: azOff=m_azOff; elOff=m_elOff; raOff=m_raOff; decOff=m_decOff; lonOff=m_lonOff; latOff=m_latOff; } + /** + * @return the antenna scan offsets + */ + void getAntennaScanOffsets(double& lon,double& lat,Antenna::TCoordinateFrame& frame) { + lon=m_lonScanOff;lat=m_latScanOff;frame=m_frameScanOff; + } + /** * Stores the list of values corresponding to the estimated source flux of the source, * @param fl list of fluxes, one value is given corresponding to each input, but just one for each section is taken @@ -300,6 +314,8 @@ private: * antenna position offsets */ double m_azOff,m_elOff,m_raOff,m_decOff,m_lonOff,m_latOff; + double m_lonScanOff,m_latScanOff; + Antenna::TCoordinateFrame m_frameScanOff; /** * stores the estimated source fluxes, one for each section. */ diff --git a/Common/Servers/FitsWriter/include/Version.h b/Common/Servers/FitsWriter/include/Version.h index 0fe3c2151..fd296ae84 100644 --- a/Common/Servers/FitsWriter/include/Version.h +++ b/Common/Servers/FitsWriter/include/Version.h @@ -21,8 +21,11 @@ #define FITS_VERSION9 "V.1.11" #define FITS_VERSION10 "V.1.12" #define FITS_VERSION11 "V.1.2" +#define FITS_VERSION12 "V.1.21" -#define CURRENT_VERSION FITS_VERSION11 + + +#define CURRENT_VERSION FITS_VERSION12 #define DEFAULT_COMMENT CURRENT_VERSION" Created by S. Righini, M. Bartolini & A. Orlati" @@ -37,6 +40,7 @@ #define HISTORY9 FITS_VERSION9" Added the keyword SIGNAL in main header of each sub scan fits" #define HISTORY10 FITS_VERSION10" Summary.fits has now a number of meaningful keywords" #define HISTORY11 FITS_VERSION11" Frequency and bandwidth columns added to Section table reporting backend sampled band" +#define HISTORY12 FITS_VERSION12" SubScan offsets added to the primary header" #define CREDITS1 " " #define CREDITS2 "These data are property of:" diff --git a/Common/Servers/FitsWriter/src/EngineThread.cpp b/Common/Servers/FitsWriter/src/EngineThread.cpp index a8cc02803..ee72e4fea 100644 --- a/Common/Servers/FitsWriter/src/EngineThread.cpp +++ b/Common/Servers/FitsWriter/src/EngineThread.cpp @@ -566,6 +566,8 @@ void CEngineThread::runLoop() IRA::CString sourceName; double sourceRa,sourceDec,sourceVlsr; double azOff,elOff,raOff,decOff,lonOff,latOff; + double lonScanOff,latScanOff; + Antenna::TCoordinateFrame frameScanOff; double dut1; long scanTag; long scanID,subScanID; @@ -596,6 +598,7 @@ void CEngineThread::runLoop() m_info.getReceiverPolarization(polarizations); m_info.getSource(sourceName,sourceRa,sourceDec,sourceVlsr); m_info.getAntennaOffsets(azOff,elOff,raOff,decOff,lonOff,latOff); + m_info.getAntennaScanOffsets(lonScanOff,latScanOff,frameScanOff); scanTag=m_data->getScanTag(); scanID=m_data->getScanID(); subScanID=m_data->getSubScanID(); @@ -748,6 +751,27 @@ void CEngineThread::runLoop() impl.log(LM_ERROR); // not filtered, because the user need to know about the problem immediately m_data->setStatus(Management::MNG_FAILURE); } + else if(!m_file->setPrimaryHeaderKey("SubScan LatOffset",latScanOff,"SubScan Latitude Offset")) { + _EXCPT(ManagementErrors::FitsCreationErrorExImpl,impl,"CEngineThread::runLoop()"); + impl.setFileName((const char *)m_data->getFileName()); + impl.setError(m_file->getLastError()); + impl.log(LM_ERROR); // not filtered, because the user need to know about the problem immediately + m_data->setStatus(Management::MNG_FAILURE); + } + else if(!m_file->setPrimaryHeaderKey("SubScan LonOffset",lonScanOff,"SubScan Longitude Offset")) { + _EXCPT(ManagementErrors::FitsCreationErrorExImpl,impl,"CEngineThread::runLoop()"); + impl.setFileName((const char *)m_data->getFileName()); + impl.setError(m_file->getLastError()); + impl.log(LM_ERROR); // not filtered, because the user need to know about the problem immediately + m_data->setStatus(Management::MNG_FAILURE); + } + else if(!m_file->setPrimaryHeaderKey("SubScan OffsetFrame",Antenna::Definitions::map(frameScanOff),"SubScan Offset frame")) { + _EXCPT(ManagementErrors::FitsCreationErrorExImpl,impl,"CEngineThread::runLoop()"); + impl.setFileName((const char *)m_data->getFileName()); + impl.setError(m_file->getLastError()); + impl.log(LM_ERROR); // not filtered, because the user need to know about the problem immediately + m_data->setStatus(Management::MNG_FAILURE); + } else if(!m_file->setPrimaryHeaderKey("ScanID",scanID,"Scan Identifier")) { _EXCPT(ManagementErrors::FitsCreationErrorExImpl,impl,"CEngineThread::runLoop()"); impl.setFileName((const char *)m_data->getFileName()); @@ -978,9 +1002,24 @@ void CEngineThread::collectAntennaData(FitsWriter_private::CFile* summaryFile) ACSErr::Completion_var comp; CORBA::Double ra=0.0,dec=0.0,vrad=0.0; CORBA::Double raOff=0.0,decOff=0.0,azOff=0.0,elOff=0.0,lonOff=0.0,latOff=0.0; + CORBA::Double scanLonOff=0.0,scanLatOff=0.0; IRA::CString sourceName=""; Antenna::TReferenceFrame VFrame=Antenna::ANT_UNDEF_FRAME; Antenna::TVradDefinition VDefinition=Antenna::ANT_UNDEF_DEF; + Antenna::TCoordinateFrame scanFrameOff=Antenna::ANT_HORIZONTAL; + + try { + m_antennaBoss->getScanOffsets(scanLonOff,scanLatOff,scanFrameOff); + } + catch (CORBA::SystemException& ex) { + _EXCPT(ComponentErrors::CORBAProblemExImpl,impl,"CEngineThread::collectAntennaData()"); + impl.setName(ex._name()); + impl.setMinor(ex.minor()); + impl.log(LM_ERROR); + m_data->setStatus(Management::MNG_WARNING); + antennaBossError=true; + } + m_info.setAntennaScanOffsets(scanLonOff,scanLatOff,scanFrameOff); try { //get the target name and parameters ACS::ROstring_var targetRef; diff --git a/Common/Servers/FitsWriter/src/FitsWriter.cpp b/Common/Servers/FitsWriter/src/FitsWriter.cpp index 31c5f66fc..0623ce480 100644 --- a/Common/Servers/FitsWriter/src/FitsWriter.cpp +++ b/Common/Servers/FitsWriter/src/FitsWriter.cpp @@ -233,6 +233,7 @@ bool CFitsWriter::create() if (!CFitsTools::primaryHeaderHistory(pFits,HISTORY9,m_lastError)) return false; if (!CFitsTools::primaryHeaderHistory(pFits,HISTORY10,m_lastError)) return false; if (!CFitsTools::primaryHeaderHistory(pFits,HISTORY11,m_lastError)) return false; + if (!CFitsTools::primaryHeaderHistory(pFits,HISTORY12,m_lastError)) return false; if (!CFitsTools::primaryHeaderComment(pFits,CREDITS1,m_lastError)) return false; if (!CFitsTools::primaryHeaderComment(pFits,CREDITS2,m_lastError)) return false; diff --git a/Common/Servers/FitsWriter/src/MetaData.cpp b/Common/Servers/FitsWriter/src/MetaData.cpp index 189edd856..f1e879ab2 100644 --- a/Common/Servers/FitsWriter/src/MetaData.cpp +++ b/Common/Servers/FitsWriter/src/MetaData.cpp @@ -26,6 +26,8 @@ CMetaData::CMetaData() m_servoAxisNames.length(0); m_restFreq.length(0); m_azOff=m_elOff=m_raOff=m_decOff=m_lonOff=m_latOff=0.0; + m_lonScanOff=m_latScanOff=0.0; + m_frameScanOff=Antenna::ANT_HORIZONTAL; m_subScanConf.signal=Management::MNG_SIGNAL_NONE; m_calDiode=false; } -- GitLab