Commit 236cd24c0d03c047a8e50364377c7b6d428cf353
1 parent
3e0e9607
Exists in
master
and in
85 other branches
working in full variable table
Showing
4 changed files
with
61 additions
and
25 deletions
Show diff stats
src/Info/ParamTable.cc
... | ... | @@ -101,6 +101,20 @@ namespace AMDA { |
101 | 101 | bool ParamTable::isVariable(ParameterManager* /*parameterManager*/) { |
102 | 102 | return _variable; |
103 | 103 | } |
104 | + | |
105 | + /* | |
106 | + * @brief Set isVariable attribute | |
107 | + */ | |
108 | + void ParamTable::setIsFullVariable(bool isFullVariable) { | |
109 | + _fullVariable = isFullVariable; | |
110 | + } | |
111 | + | |
112 | + /* | |
113 | + * @brief Get if it's a variable table | |
114 | + */ | |
115 | + bool ParamTable::isFullVariable(ParameterManager* /*parameterManager*/) { | |
116 | + return _fullVariable; | |
117 | + } | |
104 | 118 | |
105 | 119 | void ParamTable::addTableParam(std::string key, std::string name) { |
106 | 120 | _tableParams[key] = name; |
... | ... | @@ -183,7 +197,8 @@ namespace AMDA { |
183 | 197 | } |
184 | 198 | } |
185 | 199 | |
186 | - void ParamTable::addSemiVariableTableInfo(ParameterManager* parameterManager, int dim, std::string paramId, std::string tabKey, std::vector<std::pair<std::string, std::string>>&infoMap) { | |
200 | + bool ParamTable::addSemiVariableTableInfo(ParameterManager* parameterManager, int dim, std::string paramId, std::string tabKey, std::vector<std::pair<std::string, std::string>>&infoMap) { | |
201 | + bool isAddedTable = false; | |
187 | 202 | AMDA::Parameters::ParameterSPtr pParam = parameterManager->getParameter(paramId); |
188 | 203 | Process* lProcess = dynamic_cast<Process*> (pParam->getDataWriterTemplate().get()); |
189 | 204 | if (lProcess != NULL) { |
... | ... | @@ -191,6 +206,7 @@ namespace AMDA { |
191 | 206 | std::list<std::string>::iterator it; |
192 | 207 | it = std::find(_printedTables.begin(), _printedTables.end(), paramId); |
193 | 208 | if (!semiVariableTable.tabHeader.empty() && it == _printedTables.end()) { |
209 | + isAddedTable = true; | |
194 | 210 | std::stringstream head; |
195 | 211 | head.str(""); |
196 | 212 | head << "mode" << " "; |
... | ... | @@ -209,7 +225,7 @@ namespace AMDA { |
209 | 225 | if (variableSizes || !semiVariableTable.calculateBounds) { |
210 | 226 | std::ostringstream values; |
211 | 227 | for (auto tabValues : semiVariableTable.tabValues) { |
212 | - values <<tabValues.first<< " "; | |
228 | + values << tabValues.first << " "; | |
213 | 229 | for (unsigned int i = 0; i < nValues; i++) { |
214 | 230 | if (i < tabValues.second.size()) { |
215 | 231 | values << std::to_string(tabValues.second[i]) << " "; |
... | ... | @@ -217,20 +233,20 @@ namespace AMDA { |
217 | 233 | values << "NAN "; |
218 | 234 | } |
219 | 235 | } |
220 | - PUSHINFO(infoMap, "", values.str()); | |
221 | - values.str(""); | |
236 | + PUSHINFO(infoMap, "", values.str()); | |
237 | + values.str(""); | |
222 | 238 | } |
223 | 239 | } else { |
224 | 240 | std::vector<double> energyVec; |
225 | 241 | std::map<std::string, std::vector<double>> paramsTableData; |
226 | 242 | std::map<int, std::vector<double>> semiVariableTableData; |
227 | - for (int i = 0; i < nValues; ++i) { | |
243 | + for (unsigned int i = 0; i < nValues; ++i) { | |
228 | 244 | energyVec.clear(); |
229 | 245 | for (unsigned int j = 0; j < nModes; ++j) { |
230 | 246 | energyVec.push_back(semiVariableTable.tabValues[std::to_string(j)][i]); |
231 | 247 | } |
232 | 248 | paramsTableData[tabKey] = energyVec; |
233 | - for (int j = 0; j < 2 * nModes; j = j + 2) { | |
249 | + for (unsigned int j = 0; j < 2 * nModes; j = j + 2) { | |
234 | 250 | t_TableBound bound = getBound(parameterManager, j / 2, ¶msTableData); |
235 | 251 | semiVariableTableData[j].push_back(bound.min); |
236 | 252 | semiVariableTableData[j + 1].push_back(bound.max); |
... | ... | @@ -256,12 +272,13 @@ namespace AMDA { |
256 | 272 | } |
257 | 273 | _printedTables.push_back(paramId); |
258 | 274 | } |
275 | + | |
259 | 276 | } |
260 | 277 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramId); |
261 | 278 | const std::vector<std::string>& paramLinkedParams = paramInfo->getLinkedParamList(); |
262 | 279 | for (auto pId : paramLinkedParams) |
263 | 280 | addSemiVariableTableInfo(parameterManager, dim, pId, tabKey, infoMap); |
264 | - | |
281 | + return isAddedTable; | |
265 | 282 | } |
266 | 283 | |
267 | 284 | void ParamTable::addVariableTableInfo(ParameterManager * parameterManager, int dim, std::vector<std::pair<std::string, std::string>>&tableInfo) { |
... | ... | @@ -269,17 +286,15 @@ namespace AMDA { |
269 | 286 | if (!tableParams.empty()) { |
270 | 287 | std::stringstream infoKey; |
271 | 288 | int i = 0; |
272 | - for (auto linkedParam : tableParams) { | |
289 | + for (auto tableParam : tableParams) { | |
273 | 290 | infoKey.str(""); |
274 | - infoKey << VARIABLE_PARAMETER_TABLE << linkedParam.first << "[" << i << "]"; | |
275 | - PUSHINFO(tableInfo, infoKey.str(), linkedParam.second); | |
276 | - AMDA::Parameters::ParameterSPtr variableTableParam = parameterManager->getParameter(linkedParam.second); | |
277 | - addSemiVariableTableInfo(parameterManager, dim, linkedParam.second, linkedParam.first, tableInfo); | |
278 | - // adding balib tables if exist | |
279 | - ParameterSPtr pParam = parameterManager->getParameter(linkedParam.second); | |
280 | - std::map<std::string, boost::shared_ptr<std::vector<double>>> infoList = pParam->getInfoList(); | |
281 | - if (!infoList.empty()) { | |
282 | - // pour l'instant rien | |
291 | + infoKey << VARIABLE_PARAMETER_TABLE << tableParam.first << "[" << i << "]"; | |
292 | + PUSHINFO(tableInfo, infoKey.str(), tableParam.second); | |
293 | + AMDA::Parameters::ParameterSPtr variableTableParam = parameterManager->getParameter(tableParam.second); | |
294 | + bool semiVariable = addSemiVariableTableInfo(parameterManager, dim, tableParam.second, tableParam.first, tableInfo); | |
295 | + if (!semiVariable) { | |
296 | + this->_fullVariable = true; | |
297 | + variableTableParam->setIsTableIndexParam(true); | |
283 | 298 | } |
284 | 299 | i++; |
285 | 300 | } |
... | ... | @@ -651,6 +666,15 @@ namespace AMDA { |
651 | 666 | } |
652 | 667 | return res; |
653 | 668 | } |
669 | + | |
670 | + bool LinkTable::isFullVariable(ParameterManager* parameterManager) { | |
671 | + bool res = false; | |
672 | + ParamTable* table = getOriginParamTable(parameterManager); | |
673 | + if (table != NULL) { | |
674 | + res = table->isFullVariable(parameterManager); | |
675 | + } | |
676 | + return res; | |
677 | + } | |
654 | 678 | |
655 | 679 | std::map<std::string, std::string>& LinkTable::getTableParams(ParameterManager* parameterManager) { |
656 | 680 | ParamTable* table = getOriginParamTable(parameterManager); | ... | ... |
src/Info/ParamTable.hh
... | ... | @@ -67,6 +67,10 @@ namespace Info { |
67 | 67 | void setIsVariable(bool isVariable); |
68 | 68 | |
69 | 69 | virtual bool isVariable(ParameterManager *parameterManager); |
70 | + | |
71 | + void setIsFullVariable(bool isVariable); | |
72 | + | |
73 | + virtual bool isFullVariable(ParameterManager *parameterManager); | |
70 | 74 | |
71 | 75 | void addTableParam(std::string key, std::string name); |
72 | 76 | |
... | ... | @@ -76,7 +80,7 @@ namespace Info { |
76 | 80 | |
77 | 81 | void addTableInfo(ParameterManager *parameterManager, int dim, std::vector<std::pair<std::string,std::string>>& infoMap); |
78 | 82 | |
79 | - void addSemiVariableTableInfo(ParameterManager *parameterManager, int dim, std::string paramId, std::string key, std::vector<std::pair<std::string,std::string>>& infoMap); | |
83 | + bool addSemiVariableTableInfo(ParameterManager *parameterManager, int dim, std::string paramId, std::string key, std::vector<std::pair<std::string,std::string>>& infoMap); | |
80 | 84 | |
81 | 85 | protected: |
82 | 86 | /** logger of paramTable */ |
... | ... | @@ -91,6 +95,8 @@ namespace Info { |
91 | 95 | std::list<std::string> _printedTables; |
92 | 96 | |
93 | 97 | bool _variable; |
98 | + | |
99 | + bool _fullVariable = false; | |
94 | 100 | |
95 | 101 | std::map<std::string, std::string> _tableParams; |
96 | 102 | |
... | ... | @@ -224,6 +230,8 @@ namespace Info { |
224 | 230 | virtual std::string getUnits(ParameterManager *parameterManager); |
225 | 231 | |
226 | 232 | virtual bool isVariable(ParameterManager *parameterManager); |
233 | + | |
234 | + virtual bool isFullVariable(ParameterManager *parameterManager); | |
227 | 235 | |
228 | 236 | virtual std::map<std::string, std::string>& getTableParams(ParameterManager *parameterManager); |
229 | 237 | ... | ... |
src/ParamOutputImpl/Download/DownloadOutput.cc
... | ... | @@ -106,12 +106,12 @@ namespace AMDA { |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - void DownloadOutput::addAditionalDownloadParams(std::string paramId){ | |
109 | + void DownloadOutput::addAditionalDownloadParams(std::string paramId, bool isFullVariable){ | |
110 | 110 | AMDA::Parameters::ParameterSPtr pParam = _parameterManager.getParameter(paramId); |
111 | 111 | if( pParam == NULL) |
112 | 112 | return; |
113 | 113 | AMDA::Info::ParamInfoSPtr processInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramId); |
114 | - if(pParam->isTableIndexParam() && processInfo->getProcessInfo().empty()){ | |
114 | + if( isFullVariable || (pParam->isTableIndexParam() && processInfo->getProcessInfo().empty())){ | |
115 | 115 | pParam->openConnection(this); |
116 | 116 | ParamProperties* paramProperties = new ParamProperties(); |
117 | 117 | paramProperties->setOriginalId(paramId); |
... | ... | @@ -123,7 +123,7 @@ namespace AMDA { |
123 | 123 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramId); |
124 | 124 | const std::vector<std::string>& paramLinkedParams = paramInfo->getLinkedParamList(); |
125 | 125 | for(auto pId:paramLinkedParams) |
126 | - addAditionalDownloadParams(pId); | |
126 | + addAditionalDownloadParams(pId, false); | |
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
... | ... | @@ -157,9 +157,10 @@ namespace AMDA { |
157 | 157 | LOG4CXX_DEBUG(gLogger, "DownloadOutput::init - " << paramProperties->getOutputId()); |
158 | 158 | _parameterManager.getParameter(paramProperties->getOutputId())->init(this, _timeIntervalList); |
159 | 159 | |
160 | - AMDA::Parameters::ParameterSPtr param = _parameterManager.getParameter(paramProperties->getOriginalId()); | |
160 | + AMDA::Parameters::ParameterSPtr param = _parameterManager.getParameter(paramProperties->getOriginalId()); | |
161 | 161 | |
162 | 162 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramProperties->getOriginalId()); |
163 | + | |
163 | 164 | // adding tableParams |
164 | 165 | std::map<int, boost::shared_ptr < AMDA::Info::ParamTable>> tables = paramInfo->getTables(); |
165 | 166 | if (!tables.empty()) { |
... | ... | @@ -174,11 +175,14 @@ namespace AMDA { |
174 | 175 | continue; |
175 | 176 | tableParam -> init(this, _timeIntervalList); |
176 | 177 | AMDA::Info::ParamInfoSPtr tableInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(tableParamId.second); |
178 | + std::vector<std::pair<std::string,std::string>> tableInfoMap = tableInfo->getTableInfoMap(&_parameterManager); | |
177 | 179 | _tableParamsList.push_back( tableParamId.second); |
180 | + if(table.second->isFullVariable(&_parameterManager)) | |
181 | + addAditionalDownloadParams(tableParamId.second, true); | |
178 | 182 | for(auto linkedParamId : tableInfo->getLinkedParamList()){ |
179 | - addAditionalDownloadParams(linkedParamId); | |
183 | + addAditionalDownloadParams(linkedParamId, false); | |
180 | 184 | } |
181 | - } | |
185 | + } | |
182 | 186 | } |
183 | 187 | } |
184 | 188 | } | ... | ... |
src/ParamOutputImpl/Download/DownloadOutput.hh
... | ... | @@ -148,7 +148,7 @@ public: |
148 | 148 | /* |
149 | 149 | * @brief add semi-variable and fully variable table indexes to the current download |
150 | 150 | */ |
151 | - void addAditionalDownloadParams(std::string paramId); | |
151 | + void addAditionalDownloadParams(std::string paramId, bool isFullVariable); | |
152 | 152 | |
153 | 153 | protected: |
154 | 154 | /** | ... | ... |