Commit 993426a6b40f1ae0dab203104adaa947e98ca135
1 parent
e0277efd
Exists in
master
and in
30 other branches
TIME2000 included
Showing
5 changed files
with
170 additions
and
70 deletions
Show diff stats
src/ParamOutputImpl/Download/DownloadOutput.cc
... | ... | @@ -881,8 +881,8 @@ namespace AMDA |
881 | 881 | _fileWriter->setTimeFormat(_downloadProperties.getTimeFormat()); |
882 | 882 | break; |
883 | 883 | case CDF_ISTP_FILE_FORMAT: |
884 | - _fileWriter = new FileWriter::FileWriterCDFISTP(_parameterManager); | |
885 | - _fileWriter->setTimeFormat(_downloadProperties.getTimeFormat()); | |
884 | + _fileWriter = new FileWriter::FileWriterCDFISTP(_parameterManager); | |
885 | + _fileWriter->setTimeFormat(_downloadProperties.getTimeFormat()); | |
886 | 886 | break; |
887 | 887 | default: |
888 | 888 | LOG4CXX_ERROR(_logger, "DownloadOutput::createFileWriter : File format not implemented"); | ... | ... |
src/ParamOutputImpl/Download/FileWriter.hh
src/ParamOutputImpl/Download/FileWriterCDF.cc
src/ParamOutputImpl/Download/FileWriterCDFISTP.cc
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | #include "FileWriterCDFISTP.hh" |
9 | +#include "FileWriterCDF.hh" | |
9 | 10 | #include "TimeUtil.hh" |
10 | 11 | |
11 | 12 | #include "FileWriter.hh" |
... | ... | @@ -19,45 +20,81 @@ |
19 | 20 | #include <stdlib.h> |
20 | 21 | #include <boost/cast.hpp> |
21 | 22 | |
23 | +#define CDF_TIME_VAR "AMDA_TIME" | |
24 | + | |
22 | 25 | namespace AMDA { |
23 | -namespace ParamOutputImpl { | |
24 | -namespace Download { | |
25 | -namespace FileWriter { | |
26 | - | |
27 | -using namespace AMDA::Info; | |
28 | - | |
29 | -FileWriterCDFISTP::FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager) : | |
30 | - FileWriterCDF(pParameterManager) | |
31 | -{ | |
32 | -} | |
33 | - | |
34 | -bool FileWriterCDFISTP::writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement) | |
35 | -{ | |
36 | - addAttribute("Project", "AMDA>Automated Multi-Dataset Analysis", GLOBAL_SCOPE); | |
37 | - return true; | |
38 | -} | |
39 | - | |
40 | -bool FileWriterCDFISTP::writeMissionInfo(MissionInfoSPtr missionInfo, long varNum) | |
41 | -{ | |
42 | - if (missionInfo == nullptr) { | |
43 | - addAttribute("Source_name", "unk>Unknown mission", GLOBAL_SCOPE); | |
44 | - return false; | |
45 | - } | |
46 | - | |
47 | - std::vector<std::pair<std::string,std::string>> infoMap = missionInfo->getInfoMap(); | |
48 | - //addAttribute(infoMap["MISSION_NAME"] + ">" + infoMap["MISSION_DESCRIPTION"]); | |
49 | - | |
50 | - //write info about mission | |
51 | - | |
52 | - // std::vector<std::pair<std::string,std::string>> infoMap = missionInfo->getInfoMap(); | |
53 | - // | |
54 | - // for (auto info : infoMap) | |
55 | - // addAttribute(info.first, info.second, VARIABLE_SCOPE, varNum); | |
56 | - // return true; | |
57 | - // } | |
58 | - return true; | |
59 | -} | |
60 | -} /* namespace FileWriter */ | |
61 | -} /* namespace Download */ | |
62 | -} /* namespace ParamOutputImpl */ | |
26 | + namespace ParamOutputImpl { | |
27 | + namespace Download { | |
28 | + namespace FileWriter { | |
29 | + | |
30 | + using namespace AMDA::Info; | |
31 | + | |
32 | + FileWriterCDFISTP::FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager) : | |
33 | + FileWriterCDF(pParameterManager) | |
34 | + { | |
35 | + } | |
36 | + | |
37 | + FileWriterCDFISTP::~FileWriterCDFISTP(void) | |
38 | + { | |
39 | + closeFile(); | |
40 | + } | |
41 | + | |
42 | + std::string FileWriterCDFISTP::getExtension(void) | |
43 | + { | |
44 | + return "cdf"; | |
45 | + } | |
46 | + | |
47 | + | |
48 | + bool FileWriterCDFISTP::writeTimeData(std::string /* paramId */, double data, OutputFormatTime /* timeFormat */, bool isFirstParam) | |
49 | + { | |
50 | + if (_cdfid == NULL) | |
51 | + return false; | |
52 | + | |
53 | + if (!isFirstParam) | |
54 | + return true; | |
55 | + | |
56 | + std::stringstream isoTime; | |
57 | + TimeUtil::formatTimeDateInIso(data, isoTime); | |
58 | + | |
59 | + isoTime << "000000"; | |
60 | + | |
61 | + char epString[TT2000_0_STRING_LEN + 1]; | |
62 | + memset(&epString, 0, sizeof(epString)); | |
63 | + if (!isoTime.str().empty()) | |
64 | + strncpy(epString, isoTime.str().c_str(), TT2000_0_STRING_LEN); | |
65 | + | |
66 | + long long epochTime = parseTT2000(epString); | |
67 | + | |
68 | + return writeOneData(CDF_TIME_VAR, 0, &epochTime); | |
69 | + } | |
70 | + | |
71 | + /*bool FileWriterCDFISTP::writeMissionInfo(MissionInfoSPtr missionInfo, long varNum) | |
72 | + { | |
73 | + if (missionInfo == nullptr) { | |
74 | + std::cout << std::endl << std::endl << std::endl << "FER - HAHAHAHA" << std::endl << std::endl << std::endl<< std::endl; | |
75 | + addAttribute("Source_name", "unk>Unknown mission", GLOBAL_SCOPE); | |
76 | + return false; | |
77 | + } | |
78 | + | |
79 | + std::vector<std::pair<std::string,std::string>> infoMap = missionInfo->getInfoMap(); | |
80 | + | |
81 | + for (auto info : infoMap) | |
82 | + std::cout << std::endl << std::endl << std::endl << "FER - " << &info << std::cout << std::endl << std::endl << std::endl << std::endl; | |
83 | + //for (auto info : infoMap) | |
84 | + // if(info.first == "MISSION_NAME") | |
85 | + // addAttribute(info.first + ">" + info["MISSION_DESCRIPTION"]); | |
86 | + | |
87 | + //write info about mission | |
88 | + | |
89 | + // std::vector<std::pair<std::string,std::string>> infoMap = missionInfo->getInfoMap(); | |
90 | + // | |
91 | + // for (auto info : infoMap) | |
92 | + // addAttribute(info.first, info.second, VARIABLE_SCOPE, varNum); | |
93 | + // return true; | |
94 | + // } | |
95 | + return true; | |
96 | + }*/ | |
97 | + } /* namespace FileWriter */ | |
98 | + } /* namespace Download */ | |
99 | + } /* namespace ParamOutputImpl */ | |
63 | 100 | } /* namespace AMDA */ | ... | ... |
src/ParamOutputImpl/Download/FileWriterCDFISTP.hh
... | ... | @@ -13,41 +13,100 @@ |
13 | 13 | #include "DataSetMgr.hh" |
14 | 14 | #include "InstrumentMgr.hh" |
15 | 15 | #include "MissionMgr.hh" |
16 | - | |
17 | 16 | #include "cdf.h" |
18 | - | |
19 | 17 | #include <map> |
20 | 18 | |
21 | 19 | #define NB_RECORDS_BUFFER 100000 |
22 | 20 | |
23 | 21 | namespace AMDA { |
24 | -namespace ParamOutputImpl { | |
25 | -namespace Download { | |
26 | -namespace FileWriter { | |
22 | + namespace ParamOutputImpl { | |
23 | + namespace Download { | |
24 | + namespace FileWriter { | |
27 | 25 | |
28 | -using namespace AMDA::Info; | |
26 | + using namespace AMDA::Info; | |
29 | 27 | |
30 | -/** | |
31 | - * @class FileWriterCDFISTP | |
32 | - * @brief Implementation of FileWriter for CDF file format compliant with ISTP. | |
33 | - * @details | |
34 | - */ | |
35 | -class FileWriterCDFISTP : public FileWriterCDF | |
36 | -{ | |
37 | -public: | |
38 | - | |
39 | - /* | |
40 | - * @brief Constructor | |
41 | - */ | |
42 | - FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager); | |
43 | - virtual bool writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement); | |
44 | - virtual bool writeMissionInfo(MissionInfoSPtr missionInfo, long varNum); | |
45 | - | |
46 | -}; | |
47 | - | |
48 | -} /* namespace FileWriter */ | |
49 | -} /* namespace Download */ | |
50 | -} /* namespace ParamOutputImpl */ | |
28 | + /** | |
29 | + * @class FileWriterCDFISTP | |
30 | + * @brief Implementation of FileWriter for CDF file format compliant with ISTP. | |
31 | + * @details | |
32 | + */ | |
33 | + class FileWriterCDFISTP : public FileWriterCDF | |
34 | + { | |
35 | + public: | |
36 | + | |
37 | + /* | |
38 | + * @brief Constructor | |
39 | + */ | |
40 | + FileWriterCDFISTP(AMDA::Parameters::ParameterManager& pParameterManager); | |
41 | + | |
42 | + /* | |
43 | + * @brief Destructor | |
44 | + */ | |
45 | + virtual ~FileWriterCDFISTP(void); | |
46 | + | |
47 | + /* | |
48 | + * @overload FileWriter::addParameter - Add an output parameter in CDF file | |
49 | + */ | |
50 | + //virtual bool addParameter(ParamProperties *paramProp, AMDA::Common::ParameterIndexComponentList &indexList, | |
51 | + // FileDataType type, bool isFirstParam, int dim1Size = 1, int dim2Size = 1); | |
52 | + | |
53 | + | |
54 | + bool writeTableParamsInfo(std::vector<std::string> tableParams, int level){return true;} | |
55 | + bool writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement){return true;} | |
56 | + bool writeRequestInfo(std::string structure, std::string /* timeFormat */, | |
57 | + int timeResolution, std::string outputParams, std::string ttName) | |
58 | + {return true;} | |
59 | + bool writeParamsInfo(ParamPropertiesList ¶mPropertiesList, OutputStructure outputStructure, | |
60 | + std::string currentParamId) | |
61 | + {return true;} | |
62 | + | |
63 | + bool writeTimeData(std::string /* paramId */, double data, OutputFormatTime /* timeFormat */, bool isFirstParam); | |
64 | + | |
65 | + | |
66 | + | |
67 | + /* | |
68 | + * @overload FileWriter::getExtension - method to get file format extension | |
69 | + */ | |
70 | + virtual std::string getExtension(void); | |
71 | + | |
72 | + | |
73 | + protected: | |
74 | + | |
75 | + //bool addCDFParameter(std::string outputId, AMDA::Common::ParameterIndexComponentList &indexList, | |
76 | + // FileDataType type, int dim1Size, int dim2Size); | |
77 | + | |
78 | + //bool writeMissionInfo(MissionInfoSPtr missionInfo, long varNum); | |
79 | + | |
80 | + /* | |
81 | + * @brief Write instrument info attributes in the CDF file | |
82 | + */ | |
83 | + //bool writeInstrumentInfo(InstrumentInfoSPtr instrumentInfo, long varNum); | |
84 | + | |
85 | + /* | |
86 | + * @brief Write dataset info attributes in the CDF file | |
87 | + */ | |
88 | + //bool writeDatasetInfo(DataSetInfoSPtr datasetInfo, long varNum); | |
89 | + | |
90 | + /* | |
91 | + * @brief Write parameter info attributes in the CDF file | |
92 | + */ | |
93 | + //bool writeParameterInfo(ParamInfoSPtr parameterInfo, long varNum); | |
94 | + | |
95 | + private: | |
96 | + /* | |
97 | + * @brief CDF identifier | |
98 | + */ | |
99 | + CDFid _cdfid; | |
100 | + | |
101 | + /* | |
102 | + * @brief Map of CDF var info | |
103 | + */ | |
104 | + std::map<std::string, ParamCDFVar> _cdfVarMap; | |
105 | + }; | |
106 | + | |
107 | + } /* namespace FileWriter */ | |
108 | + } /* namespace Download */ | |
109 | + } /* namespace ParamOutputImpl */ | |
51 | 110 | } /* namespace AMDA */ |
52 | 111 | |
53 | 112 | #endif /* FILEWRITERCDFISTP_HH_ */ | ... | ... |