Commit b03f2eca8ce3329933743e9ea0e99eba95e64701

Authored by Benjamin Renard
1 parent 8bed959f

Improve amdaParameterInfo process (for #5637)

src/TimeUtil/TimeUtil.cc
... ... @@ -35,7 +35,7 @@ void TimeUtil::formatTimeInIso(const double time, std::ostream& pOs, t_DDTimeKin
35 35  
36 36 tm.times = time;
37 37 SetIntNew(&tm, timeKind);
38   - if(tm.year % 4 == 0) visocos = 1; else visocos = 0;
  38 + if (((tm.year & 3) == 0)&&(((tm.year % 100) != 0)||((tm.year % 400)==0))) visocos = 1; else visocos = 0;
39 39 int month = 0;
40 40 while((month < 12) && (tm.day >= monthday[visocos][month])) month++;
41 41  
... ...
src/amdaParameterInfo/CMakeLists.txt
... ... @@ -2,6 +2,7 @@
2 2 PROJECT(amdaParameterInfo)
3 3  
4 4 include_directories(
  5 + ${CMAKE_HOME_DIRECTORY}/src/TimeUtil/
5 6 ${CMAKE_HOME_DIRECTORY}/src/helpers/
6 7 ${CMAKE_HOME_DIRECTORY}/src/Info/
7 8 ${CMAKE_HOME_DIRECTORY}/src/Common/
... ... @@ -12,6 +13,7 @@ include_directories(
12 13 ${CMAKE_HOME_DIRECTORY}/src/Plugins/
13 14 ${CMAKE_HOME_DIRECTORY}/src/TimeTableCatalog/
14 15 ${CMAKE_HOME_DIRECTORY}/src/SpiceKernel/
  16 + ${DDCLIENTINCLUDE_DIR}
15 17 ${LOG4CXX_INCLUDE_DIR}
16 18 ${LIBXML2_INCLUDE_DIR}
17 19 ${Boost_INCLUDE_DIR}
... ... @@ -29,6 +31,7 @@ ADD_EXECUTABLE( amdaParameterInfo ${source_files} )
29 31  
30 32 target_link_libraries(
31 33 amdaParameterInfo
  34 + TimeUtil
32 35 AMDA_COMMON
33 36 ${CMAKE_THREAD_LIBS_INIT}
34 37 Parameters
... ...
src/amdaParameterInfo/Main.cc
... ... @@ -17,6 +17,7 @@
17 17 #include "Process.hh"
18 18 #include "ParameterInfo.hh"
19 19 #include "ServicesServer.hh"
  20 +#include "TimeUtil.hh"
20 21  
21 22 using namespace std;
22 23 namespace po = boost::program_options;
... ... @@ -24,7 +25,7 @@ using namespace log4cxx;
24 25 using namespace log4cxx::helpers;
25 26 using namespace AMDA::Parameters;
26 27  
27   -#define YEAR_3000_TIMESTAMP 32503680000
  28 +#define MAX_YEAR 2040
28 29  
29 30 /**
30 31 * Main function
... ... @@ -70,7 +71,22 @@ int main(int argc, char *argv[]) {
70 71 ///Create ParameterManager and configuration
71 72 ParameterManager parameterManager;
72 73 std::string emptyStr;
73   - parameterManager.addInputInterval(0,YEAR_3000_TIMESTAMP, 0, emptyStr, emptyStr, 0);
  74 + std::stringstream ss;
  75 + char startTimeIso[24];
  76 + char stopTimeIso[24];
  77 + memset(startTimeIso, 0, 24*sizeof(char));
  78 + memset(stopTimeIso, 0, 24*sizeof(char));
  79 +
  80 + for (int y = 1970; y < MAX_YEAR; ++y) {
  81 + ss << std::setfill('0') << y << "-01-01T00:00:00.000";
  82 + memcpy(startTimeIso, ss.str().c_str(), 24*sizeof(char));
  83 + double startTime = AMDA::TimeUtil::readTimeInIso(startTimeIso);
  84 + ss.str("");
  85 + ss << std::setfill('0') << y << "-12-31T23:59:59.000";
  86 + memcpy(stopTimeIso, ss.str().c_str(), 24*sizeof(char));
  87 + double stopTime = AMDA::TimeUtil::readTimeInIso(stopTimeIso);
  88 + parameterManager.addInputInterval(startTime, stopTime, 0, emptyStr, emptyStr, 0);
  89 + }
74 90  
75 91 if (!lProperties["app.param.gapthreshold"].empty())
76 92 {
... ...
src/amdaParameterInfo/ParameterInfo.cc
... ... @@ -161,14 +161,18 @@ void ParameterInfo::writeTable(boost::shared_ptr&lt;AMDA::Info::ParamTable&gt; tableSP
161 161  
162 162 void ParameterInfo::apply() {
163 163 //Intervals loop
164   - while (_currentTimeInterval != _timeIntervalList->end())
  164 + bool skip = false;
  165 + while (!skip && (_currentTimeInterval != _timeIntervalList->end()))
165 166 {
166 167 if (_currentTimeInterval->_stopTime - _currentTimeInterval->_startTime == 0) {
167 168 ++_currentTimeInterval;
168 169 continue;
169 170 }
170 171  
171   - _parameterManager.getParameter(_parameter->getId())->getAsync(this).get();
  172 + ParamDataIndexInfo paramIndexInfo = _parameterManager.getParameter(_parameter->getId())->getAsync(this).get();
  173 + if (paramIndexInfo._nbDataToProcess > 0) {
  174 + skip = true;
  175 + }
172 176  
173 177 ++_currentTimeInterval;
174 178 }
... ...