Commit f3cd53514506c3c0fd4978fc4d9424942d1ae3f3

Authored by Hacene SI HADJ MOHAND
1 parent 03aa741e

us ok

src/ExternLib/Spectrum/SpectrumProcess.cc
... ... @@ -41,10 +41,14 @@ namespace AMDA {
41 41 SpectrumProcess::SpectrumProcess(Parameter &parameter) : SingleParamProcess_CRTP(parameter) {
42 42  
43 43 _type = SpectrumCreator::SpectrumType::FOURIER;
  44 + _paramInfoId = parameter.getId();
  45 + parameter.setInfoId(_paramInfoId);
44 46 }
45 47  
46 48 SpectrumProcess::SpectrumProcess(const SpectrumProcess& pProcess, Parameter &parameter) : SingleParamProcess_CRTP(pProcess, parameter) {
47 49 _type = SpectrumCreator::SpectrumType::FOURIER;
  50 + _paramInfoId = parameter.getId();
  51 + parameter.setInfoId(_paramInfoId);
48 52 }
49 53  
50 54 SpectrumProcess::~SpectrumProcess() {
... ... @@ -94,26 +98,20 @@ namespace AMDA {
94 98 int size_ = std::ceil(_windowtime/_paramInput->getMinSampling()) +1;
95 99 std::vector<double> frequencies(size_);
96 100 for(int i =0; i<size_; i++ )
97   - frequencies[i] = (double) 1./_paramInput->getMinSampling()/(double) i;
  101 + frequencies[i] = (double) 1./_paramInput->getMinSampling()/(double) (i+1);
98 102  
99   - std::string paramId = _parameterInput->getId();
100   - std::string paramInfoId = _parameterInput->getInfoId();
101   -
102   - if(paramInfoId.empty())
103   - paramInfoId = "freq";
104   -
105   - AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramInfoId);
  103 + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(_paramInfoId);
106 104  
107 105 boost::shared_ptr<AMDA::Info::ParamTable> table(new AMDA::Info::EmbeddedCenterTable(
108   - paramId.c_str(), frequencies, false));
  106 + _paramInfoId.c_str(), frequencies, false));
109 107  
110   - table->addTableParam(AMDA::Info::EmbeddedCenterTable::_paramKey, paramId);
  108 + table->addTableParam(AMDA::Info::EmbeddedCenterTable::_paramKey, _paramInfoId );
111 109 table->setName("Frequencies");
112 110 table->setUnits("Hz");
113 111 table->setIsVariable(false);
114 112 table->setIsFullVariable(false);
115 113  
116   - paramInfo->addTable(1, table);
  114 + paramInfo->addTable(0, table);
117 115  
118 116 return time;
119 117 }
... ...
src/ExternLib/Spectrum/SpectrumProcess.hh
... ... @@ -44,8 +44,8 @@ namespace AMDA {
44 44 double _windowtime;
45 45  
46 46 std::string _sampling;
47   -
48   -
  47 +
  48 + std::string _paramInfoId;
49 49 };
50 50  
51 51  
... ...
src/Info/ParamTable.cc
... ... @@ -195,7 +195,8 @@ namespace AMDA {
195 195 //build min and max values list
196 196 std::stringstream tableMinValues;
197 197 std::stringstream tableMaxValues;
198   - for (int i = 0; i< this->getSize(parameterManager); ++i) {
  198 + int size_ = this->getSize(parameterManager);
  199 + for (int i = 0; i< size_; ++i) {
199 200 if (i > 0) {
200 201 tableMinValues << ",";
201 202 tableMaxValues << ",";
... ... @@ -218,7 +219,7 @@ namespace AMDA {
218 219 AMDA::Parameters::ParameterSPtr pParam = parameterManager->getParameter(paramId);
219 220 Process* lProcess = dynamic_cast<Process*> (pParam->getDataWriterTemplate().get());
220 221 if (lProcess != NULL) {
221   - AMDA::Parameters::SemiVariableTable semiVariableTable = lProcess ->getSemiVariableTable().tabHeader.empty()? lProcess ->getEmbeddedTable() : lProcess ->getSemiVariableTable();
  222 + AMDA::Parameters::SemiVariableTable semiVariableTable = lProcess ->getSemiVariableTable();
222 223 std::list<std::string>::iterator it;
223 224 it = std::find(_printedTables.begin(), _printedTables.end(), paramId);
224 225 if (!semiVariableTable.tabHeader.empty() && it == _printedTables.end()) {
... ... @@ -470,12 +471,12 @@ namespace AMDA {
470 471 return EmbeddedCenterTable::_paramKey;
471 472 }
472 473  
473   - int EmbeddedCenterTable::getSize(ParameterManager* /*parameterManager*/) {
  474 + int EmbeddedCenterTable::getSize(ParameterManager* /*parameterManager*/) {
474 475 return _centersValues.size();
475 476 }
476 477  
477 478  
478   - t_TableBound EmbeddedCenterTable::getBound(ParameterManager* /*parameterManager*/, unsigned int index, std::map<std::string, std::vector<double>>*paramsTableData) {
  479 + t_TableBound EmbeddedCenterTable::getBound(ParameterManager* /*parameterManager*/, unsigned int index, std::map<std::string, std::vector<double>>* /*paramsTableData*/) {
479 480 t_TableBound bound;
480 481 bound.index = index;
481 482  
... ... @@ -494,63 +495,16 @@ namespace AMDA {
494 495 bound.max = index + 1;
495 496 return bound;
496 497 }
497   -
498   - std::vector<double> workingValues;
499   - for (std::vector<double>::iterator it = _centersValues.begin(); it != _centersValues.end(); ++it) {
500   - if (_log) {
501   - workingValues.push_back(log10(*it));
502   - }
503   - else {
504   - workingValues.push_back(*it);
505   - }
506   - }
507   -
508   - double minus = 0.;
509   - double plus = 0.;
510   -
511   - if (index == 0) {
512   - if (!std::isnan(workingValues[1]) && !std::isnan(workingValues[0])) {
513   - plus = (workingValues[1] - workingValues[0]) / 2.;
514   - } else
515   - plus = NAN;
516   - minus = plus;
517   - } else if (index == workingValues.size() - 1) {
518   - if (!std::isnan(workingValues[workingValues.size() - 1]) && !std::isnan(workingValues[workingValues.size() - 2])) {
519   - minus = (workingValues[workingValues.size() - 1] - workingValues[workingValues.size() - 2]) / 2.;
520   - } else
521   - minus = NAN;
522   - plus = minus;
523   - } else {
524   - if (!std::isnan(workingValues[index]) && !std::isnan(workingValues[index - 1]))
525   - minus = (workingValues[index] - workingValues[index - 1]) / 2.;
526   - else
527   - minus = NAN;
528   - if (!std::isnan(workingValues[index + 1]) && !std::isnan(workingValues[index]))
529   - plus = (workingValues[index + 1] - workingValues[index]) / 2.;
530   - else
531   - plus = NAN;
532   - }
533   -
534   - if (!std::isnan(minus))
535   - bound.min = workingValues[index] - minus;
536   - else
537   - bound.min = NAN;
538   - if (!std::isnan(plus))
539   - bound.max = workingValues[index] + plus;
540   - else
541   - bound.max = NAN;
542   -
543   - if (bound.min > bound.max) {
544   - double temp = bound.max;
545   - bound.max = bound.min;
546   - bound.min = temp;
547   - }
548   -
549   - if (_log) {
550   - bound.min = pow(10,bound.min);
551   - bound.max = pow(10,bound.max);
  498 + if(index == 0 ){
  499 + bound.min = 1.0/((1.0/_centersValues[0]+ 1.0/_centersValues[1])/2);
  500 + bound.max = 2.0*_centersValues[0];
  501 + }else if(index ==_centersValues.size() -1){
  502 + bound.max = 1.0/((1.0/_centersValues[index]+ 1.0/_centersValues[index-1])/2);
  503 + bound.min = _centersValues[index]/2;
  504 + }else{
  505 + bound.min = 1.0/((1.0/_centersValues[index]+ 1.0/_centersValues[index+1])/2);
  506 + bound.max = 1.0/((1.0/_centersValues[index]+ 1.0/_centersValues[index-1])/2);
552 507 }
553   -
554 508 return bound;
555 509 }
556 510  
... ...
src/Info/ParamTable.hh
... ... @@ -203,8 +203,9 @@ namespace AMDA {
203 203  
204 204 static std::string _paramKey;
205 205  
  206 + std::vector<double> _centersValues;
  207 +
206 208 private:
207   - std::vector<double> & _centersValues;
208 209  
209 210 bool _log;
210 211 };
... ...
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... ... @@ -316,12 +316,33 @@ namespace plot
316 316 //set Y axis range
317 317 Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
318 318 Range lYAxisRange = lYAxis->Axis::getRange();
  319 +
319 320 AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
  321 +
  322 +
  323 +
320 324 if (isnan(lYAxisRequestRange.getMin()) && isnan(lYAxisRequestRange.getMax()))
321 325 {
322 326 boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
323 327 if (paramInfo != nullptr)
324 328 tableSPtr = paramInfo->getTable(spectroPropertiesPtr->getRelatedDim());
  329 +
  330 + if (tableSPtr == nullptr){
  331 + boost::shared_ptr<AMDA::Info::ParamTable> linkedTableSPtr;
  332 + int counter = 0;
  333 + // work on this
  334 + for (auto pInfo :paramInfo->getLinkedParamList()){
  335 + linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(spectroPropertiesPtr->getRelatedDim());
  336 + if (linkedTableSPtr == nullptr)
  337 + continue;
  338 + counter ++;
  339 + }
  340 + if(linkedTableSPtr == nullptr || counter !=1){
  341 + LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params");
  342 + }else{
  343 + tableSPtr = linkedTableSPtr;
  344 + }
  345 + }
325 346  
326 347 if (tableSPtr == nullptr)
327 348 {
... ... @@ -963,6 +984,23 @@ namespace plot
963 984 AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
964 985 if (paramInfo != nullptr)
965 986 tableSPtr = paramInfo->getTable(pSpectro.getRelatedDim());
  987 +
  988 + if (tableSPtr == nullptr){
  989 + boost::shared_ptr<AMDA::Info::ParamTable> linkedTableSPtr;
  990 + int counter = 0;
  991 + // work on this
  992 + for (auto pInfo :paramInfo->getLinkedParamList()){
  993 + linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(pSpectro.getRelatedDim());
  994 + if (linkedTableSPtr == nullptr)
  995 + continue;
  996 + counter ++;
  997 + }
  998 + if(linkedTableSPtr == nullptr || counter !=1){
  999 + LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params");
  1000 + }else{
  1001 + tableSPtr = linkedTableSPtr;
  1002 + }
  1003 + }
966 1004  
967 1005 //get axis
968 1006 boost::shared_ptr<Axis> lXAxis = _panel->getAxis(pSpectro.getXAxisId());
... ...
src/Parameters/Parameter.hh
... ... @@ -42,11 +42,6 @@ namespace AMDA {
42 42 bool calculateBounds = true;
43 43 };
44 44  
45   - struct EmbeddedTable:SemiVariableTable {
46   - std::string name;
47   - std::string unit;
48   - };
49   -
50 45 /**
51 46 * AMDA::Parameters::Parameter
52 47 */
... ...
src/Parameters/Process.hh
... ... @@ -94,14 +94,6 @@ public:
94 94 _semiVariableTable = semiVariableTable;
95 95 }
96 96  
97   - AMDA::Parameters::EmbeddedTable getEmbeddedTable(){
98   - return _embeddedTable;
99   - }
100   - void setEmbeddedTable(EmbeddedTable embeddedTable){
101   - _embeddedTable = embeddedTable;
102   - }
103   -
104   -
105 97 protected:
106 98 static log4cxx::LoggerPtr _logger;
107 99  
... ... @@ -117,7 +109,6 @@ protected:
117 109 double _gapThreshold;
118 110 bool _isUserProcess;
119 111 AMDA::Parameters::SemiVariableTable _semiVariableTable;
120   - AMDA::Parameters::EmbeddedTable _embeddedTable;
121 112 };
122 113  
123 114 typedef boost::shared_ptr<Process> ProcessSPtr;
... ...