From 993426a6b40f1ae0dab203104adaa947e98ca135 Mon Sep 17 00:00:00 2001 From: Furkan Date: Thu, 13 Oct 2022 12:22:58 +0200 Subject: [PATCH] TIME2000 included --- src/ParamOutputImpl/Download/DownloadOutput.cc | 4 ++-- src/ParamOutputImpl/Download/FileWriter.hh | 3 ++- src/ParamOutputImpl/Download/FileWriterCDF.cc | 3 +++ src/ParamOutputImpl/Download/FileWriterCDFISTP.cc | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------- src/ParamOutputImpl/Download/FileWriterCDFISTP.hh | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------- 5 files changed, 170 insertions(+), 70 deletions(-) diff --git a/src/ParamOutputImpl/Download/DownloadOutput.cc b/src/ParamOutputImpl/Download/DownloadOutput.cc index 8bbb10b..8a9c8a3 100644 --- a/src/ParamOutputImpl/Download/DownloadOutput.cc +++ b/src/ParamOutputImpl/Download/DownloadOutput.cc @@ -881,8 +881,8 @@ namespace AMDA _fileWriter->setTimeFormat(_downloadProperties.getTimeFormat()); break; case CDF_ISTP_FILE_FORMAT: - _fileWriter = new FileWriter::FileWriterCDFISTP(_parameterManager); - _fileWriter->setTimeFormat(_downloadProperties.getTimeFormat()); + _fileWriter = new FileWriter::FileWriterCDFISTP(_parameterManager); + _fileWriter->setTimeFormat(_downloadProperties.getTimeFormat()); break; default: LOG4CXX_ERROR(_logger, "DownloadOutput::createFileWriter : File format not implemented"); diff --git a/src/ParamOutputImpl/Download/FileWriter.hh b/src/ParamOutputImpl/Download/FileWriter.hh index d176f8c..ce76ba9 100644 --- a/src/ParamOutputImpl/Download/FileWriter.hh +++ b/src/ParamOutputImpl/Download/FileWriter.hh @@ -39,7 +39,8 @@ namespace AMDA DT_DOUBLE, DT_LONGDOUBLE, DT_LOGICAL, - DT_TIME + DT_TIME, + DT_TIME2000 } FileDataType; // Info keys for AMDA bloc diff --git a/src/ParamOutputImpl/Download/FileWriterCDF.cc b/src/ParamOutputImpl/Download/FileWriterCDF.cc index 601c9da..f0eb04a 100644 --- a/src/ParamOutputImpl/Download/FileWriterCDF.cc +++ b/src/ParamOutputImpl/Download/FileWriterCDF.cc @@ -148,6 +148,9 @@ namespace AMDA case DT_TIME: cdfVar.type = CDF_EPOCH; break; + case DT_TIME2000: + cdfVar.type = CDF_TIME_TT2000; + break; case DT_NONE: cdfVar.type = CDF_CHAR; break; diff --git a/src/ParamOutputImpl/Download/FileWriterCDFISTP.cc b/src/ParamOutputImpl/Download/FileWriterCDFISTP.cc index aecbc49..2c849a8 100644 --- a/src/ParamOutputImpl/Download/FileWriterCDFISTP.cc +++ b/src/ParamOutputImpl/Download/FileWriterCDFISTP.cc @@ -6,6 +6,7 @@ */ #include "FileWriterCDFISTP.hh" +#include "FileWriterCDF.hh" #include "TimeUtil.hh" #include "FileWriter.hh" @@ -19,45 +20,81 @@ #include #include +#define CDF_TIME_VAR "AMDA_TIME" + namespace AMDA { -namespace ParamOutputImpl { -namespace Download { -namespace FileWriter { - -using namespace AMDA::Info; - -FileWriterCDFISTP::FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager) : - FileWriterCDF(pParameterManager) -{ -} - -bool FileWriterCDFISTP::writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement) -{ - addAttribute("Project", "AMDA>Automated Multi-Dataset Analysis", GLOBAL_SCOPE); - return true; -} - -bool FileWriterCDFISTP::writeMissionInfo(MissionInfoSPtr missionInfo, long varNum) -{ - if (missionInfo == nullptr) { - addAttribute("Source_name", "unk>Unknown mission", GLOBAL_SCOPE); - return false; - } - - std::vector> infoMap = missionInfo->getInfoMap(); - //addAttribute(infoMap["MISSION_NAME"] + ">" + infoMap["MISSION_DESCRIPTION"]); - - //write info about mission - - // std::vector> infoMap = missionInfo->getInfoMap(); - // - // for (auto info : infoMap) - // addAttribute(info.first, info.second, VARIABLE_SCOPE, varNum); - // return true; - // } - return true; -} -} /* namespace FileWriter */ -} /* namespace Download */ -} /* namespace ParamOutputImpl */ + namespace ParamOutputImpl { + namespace Download { + namespace FileWriter { + + using namespace AMDA::Info; + + FileWriterCDFISTP::FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager) : + FileWriterCDF(pParameterManager) + { + } + + FileWriterCDFISTP::~FileWriterCDFISTP(void) + { + closeFile(); + } + + std::string FileWriterCDFISTP::getExtension(void) + { + return "cdf"; + } + + + bool FileWriterCDFISTP::writeTimeData(std::string /* paramId */, double data, OutputFormatTime /* timeFormat */, bool isFirstParam) + { + if (_cdfid == NULL) + return false; + + if (!isFirstParam) + return true; + + std::stringstream isoTime; + TimeUtil::formatTimeDateInIso(data, isoTime); + + isoTime << "000000"; + + char epString[TT2000_0_STRING_LEN + 1]; + memset(&epString, 0, sizeof(epString)); + if (!isoTime.str().empty()) + strncpy(epString, isoTime.str().c_str(), TT2000_0_STRING_LEN); + + long long epochTime = parseTT2000(epString); + + return writeOneData(CDF_TIME_VAR, 0, &epochTime); + } + + /*bool FileWriterCDFISTP::writeMissionInfo(MissionInfoSPtr missionInfo, long varNum) + { + if (missionInfo == nullptr) { + std::cout << std::endl << std::endl << std::endl << "FER - HAHAHAHA" << std::endl << std::endl << std::endl<< std::endl; + addAttribute("Source_name", "unk>Unknown mission", GLOBAL_SCOPE); + return false; + } + + std::vector> infoMap = missionInfo->getInfoMap(); + + for (auto info : infoMap) + std::cout << std::endl << std::endl << std::endl << "FER - " << &info << std::cout << std::endl << std::endl << std::endl << std::endl; + //for (auto info : infoMap) + // if(info.first == "MISSION_NAME") + // addAttribute(info.first + ">" + info["MISSION_DESCRIPTION"]); + + //write info about mission + + // std::vector> infoMap = missionInfo->getInfoMap(); + // + // for (auto info : infoMap) + // addAttribute(info.first, info.second, VARIABLE_SCOPE, varNum); + // return true; + // } + return true; + }*/ + } /* namespace FileWriter */ + } /* namespace Download */ + } /* namespace ParamOutputImpl */ } /* namespace AMDA */ diff --git a/src/ParamOutputImpl/Download/FileWriterCDFISTP.hh b/src/ParamOutputImpl/Download/FileWriterCDFISTP.hh index a33c1a6..b56afcc 100644 --- a/src/ParamOutputImpl/Download/FileWriterCDFISTP.hh +++ b/src/ParamOutputImpl/Download/FileWriterCDFISTP.hh @@ -13,41 +13,100 @@ #include "DataSetMgr.hh" #include "InstrumentMgr.hh" #include "MissionMgr.hh" - #include "cdf.h" - #include #define NB_RECORDS_BUFFER 100000 namespace AMDA { -namespace ParamOutputImpl { -namespace Download { -namespace FileWriter { + namespace ParamOutputImpl { + namespace Download { + namespace FileWriter { -using namespace AMDA::Info; + using namespace AMDA::Info; -/** - * @class FileWriterCDFISTP - * @brief Implementation of FileWriter for CDF file format compliant with ISTP. - * @details - */ -class FileWriterCDFISTP : public FileWriterCDF -{ -public: - - /* - * @brief Constructor - */ - FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager); - virtual bool writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement); - virtual bool writeMissionInfo(MissionInfoSPtr missionInfo, long varNum); - -}; - -} /* namespace FileWriter */ -} /* namespace Download */ -} /* namespace ParamOutputImpl */ + /** + * @class FileWriterCDFISTP + * @brief Implementation of FileWriter for CDF file format compliant with ISTP. + * @details + */ + class FileWriterCDFISTP : public FileWriterCDF + { + public: + + /* + * @brief Constructor + */ + FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager); + + /* + * @brief Destructor + */ + virtual ~FileWriterCDFISTP(void); + + /* + * @overload FileWriter::addParameter - Add an output parameter in CDF file + */ + //virtual bool addParameter(ParamProperties *paramProp, AMDA::Common::ParameterIndexComponentList &indexList, + // FileDataType type, bool isFirstParam, int dim1Size = 1, int dim2Size = 1); + + + bool writeTableParamsInfo(std::vector tableParams, int level){return true;} + bool writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement){return true;} + bool writeRequestInfo(std::string structure, std::string /* timeFormat */, + int timeResolution, std::string outputParams, std::string ttName) + {return true;} + bool writeParamsInfo(ParamPropertiesList ¶mPropertiesList, OutputStructure outputStructure, + std::string currentParamId) + {return true;} + + bool writeTimeData(std::string /* paramId */, double data, OutputFormatTime /* timeFormat */, bool isFirstParam); + + + + /* + * @overload FileWriter::getExtension - method to get file format extension + */ + virtual std::string getExtension(void); + + + protected: + + //bool addCDFParameter(std::string outputId, AMDA::Common::ParameterIndexComponentList &indexList, + // FileDataType type, int dim1Size, int dim2Size); + + //bool writeMissionInfo(MissionInfoSPtr missionInfo, long varNum); + + /* + * @brief Write instrument info attributes in the CDF file + */ + //bool writeInstrumentInfo(InstrumentInfoSPtr instrumentInfo, long varNum); + + /* + * @brief Write dataset info attributes in the CDF file + */ + //bool writeDatasetInfo(DataSetInfoSPtr datasetInfo, long varNum); + + /* + * @brief Write parameter info attributes in the CDF file + */ + //bool writeParameterInfo(ParamInfoSPtr parameterInfo, long varNum); + + private: + /* + * @brief CDF identifier + */ + CDFid _cdfid; + + /* + * @brief Map of CDF var info + */ + std::map _cdfVarMap; + }; + + } /* namespace FileWriter */ + } /* namespace Download */ + } /* namespace ParamOutputImpl */ } /* namespace AMDA */ #endif /* FILEWRITERCDFISTP_HH_ */ -- libgit2 0.21.2