/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/slowControl/SlowControlEntry.cpp

Go to the documentation of this file.
00001 /* @version $Revision: 1328 $ * @modifiedby $Author: jacquem $ * @lastmodified $Date: 2011-10-03 17:04:17 +0200 (Mon, 03 Oct 2011) $ */
00002 #include <iostream>
00003 #include <fstream>
00004 #include <iomanip>
00005 
00006 #include "slowControl/SlowControlEntry.hh"
00007 #include "slowControl/ChamberSlowControl.hh"
00008 #include "slowControl/BoardSlowControl.hh"
00009 #include "slowControl/PMSlowControl.hh"
00010 
00011 #include "tools/MicroException.hh"
00012 
00013 using namespace std;
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 // general parameters
00017 std::ostream& operator <<(std::ostream& out, const SlowControlEntry& x) {
00018   return(out << "ts=" << fixed << setprecision(3) << x.timeStamp << ", t=" << setprecision(3) << x.temperature << ", p=" << x.pressure);
00019 }
00020 
00021 //--------------------------------------------------------------------//
00022 SlowControlEntry::SlowControlEntry()
00023 {
00024   timeStamp = 0;;
00025   pressure = 0;
00026   overPressure = 0;
00027   temperature = 0;
00028 }
00029 
00030 
00031 //--------------------------------------------------------------------//
00032 SlowControlEntry::~SlowControlEntry()
00033 {
00034   for ( map<ui32, map<ui32, map<ui32, BoardSlowControl>* >* >::iterator iter = boardMap.begin(); iter!= boardMap.end(); iter++)
00035   {
00036      map<ui32, map<ui32, BoardSlowControl>* >* difContainer = iter->second;
00037      for ( map<ui32, map<ui32, BoardSlowControl>* >::iterator boardIter = difContainer->begin(); boardIter!= difContainer->end(); boardIter++)
00038      {
00039         delete boardIter->second;
00040      }
00041     delete difContainer;
00042   }
00043 }
00044 //--------------------------------------------------------------------//
00045 SlowControlEntry::SlowControlEntry(const SlowControlEntry& aSce)
00046 {
00047    (*this) = aSce; // appel operator=
00048 
00049 }
00050 //--------------------------------------------------------------------//
00051 SlowControlEntry&  SlowControlEntry::operator=(const SlowControlEntry& aSce)
00052 {
00053   timeStamp = aSce.timeStamp;
00054   pressure = aSce.pressure;
00055   overPressure = aSce.overPressure;
00056   temperature = aSce.temperature;
00057 
00058   for ( map<ui32, map<ui32, map<ui32, BoardSlowControl>* >* >::const_iterator difIter = aSce.boardMap.begin(); difIter!= aSce.boardMap.end(); difIter++)
00059   {
00060      map<ui32, map<ui32, BoardSlowControl>* >* difContainer = difIter->second;
00061      for ( map<ui32, map<ui32, BoardSlowControl>* >::const_iterator boardIter = difContainer->begin(); boardIter!= difContainer->end(); boardIter++)
00062      {
00063         //delete boardIter->second;
00064        map<ui32, BoardSlowControl>* boardContainer = boardIter->second;
00065        for ( map<ui32, BoardSlowControl>::const_iterator scIter = boardContainer->begin(); scIter!= boardContainer->end(); scIter++)
00066        {
00067          BoardSlowControl newBsc = scIter->second;
00068          ui32 chamberId = difIter->first;
00069          ui32 boardId   = scIter->first;
00070          ui32 difId     = boardIter->first;
00071          this->setBoardParams( chamberId,difId,boardId,  newBsc);
00072        }
00073     }
00074   }
00075 
00076   pmMap =  aSce.pmMap; // a map element by PM ( ref by PM id )
00077 
00078 }
00079 //--------------------------------------------------------------------//
00080 const BoardSlowControl& SlowControlEntry::getBoard(const ui32 chamberId, const ui32 difId, const ui32 boardId) const 
00081 {
00082   if ( boardMap.find(chamberId) != boardMap.end())
00083     {
00084       map<ui32, map<ui32, BoardSlowControl>* >* difContainer = boardMap.find(chamberId)->second;
00085 
00086       if (difContainer->find(difId) !=  difContainer->end())
00087       {
00088         map<ui32 , BoardSlowControl>* boardContainer = difContainer->find(difId)->second;
00089         if (boardContainer->find(boardId) !=  boardContainer->end())
00090         {
00091             return (boardContainer->find(boardId)->second);
00092         }
00093         else
00094         {
00095           throw MicroException("SlowControlEntry.getBoard : no board found");
00096         }
00097       }
00098       else
00099       {
00100           throw MicroException("SlowControlEntry.getBoard : no board found");
00101       }
00102     }
00103     else
00104     {
00105       throw MicroException("SlowControlEntry.getBoard : no board found");
00106     }
00107 
00108 }
00109 
00110 //--------------------------------------------------------------------//
00111 const PMSlowControl& SlowControlEntry::getPM(const ui32 id)  const{
00112    if (pmMap.find(id) != pmMap.end())
00113    {
00114       return pmMap.find(id)->second;
00115    }
00116    else
00117    {
00118       throw MicroException("SlowControlEntry.getPM : no PM found");
00119    }
00120 }
00121 
00122 //--------------------------------------------------------------------//
00123 void SlowControlEntry::setBoardParams(ui32 chamberId, ui32 difId, ui32 boardId, BoardSlowControl& boardSC)
00124 {
00125 
00126     // Search or create difs container for this chamber id
00127     if ( boardMap.find(chamberId) != boardMap.end())
00128     { // difs list already exit for this chamber
00129     }
00130     else
00131     { // does not exit create it
00132       map<ui32 , map<ui32, BoardSlowControl>* >* difContainer = new map<ui32, map<ui32, BoardSlowControl>* >();
00133       boardMap.insert(make_pair(chamberId,difContainer));
00134     }
00135 
00136     // Now we are sure that container for this chamber Id exist
00137     map<ui32, map<ui32, BoardSlowControl>* >* difContainer = boardMap.find(chamberId)->second;
00138     // Search or create boards container for this Difs
00139     if ( difContainer->find(difId) != difContainer->end())
00140     { // board list already exit for this dif
00141     }
00142     else
00143     {
00144       map<ui32, BoardSlowControl>* boardContainer = new map<ui32, BoardSlowControl>();
00145       difContainer->insert(make_pair(difId,boardContainer));
00146     }
00147 
00148     // Now we are sure that container for this chamber Id  and DifId exist
00149     map<ui32, BoardSlowControl>* boardContainer = difContainer->find(difId)->second;
00150     boardContainer->insert(make_pair(boardId,boardSC));
00151 }
00152 
00153 //--------------------------------------------------------------------//
00154 void SlowControlEntry::setPmParams(ui32 id,PMSlowControl& sc)
00155 {
00156    if (pmMap.find(id) != pmMap.end())
00157    {
00158       pmMap.find(id)->second = sc;
00159    }
00160    else
00161    {
00162       pmMap.insert(make_pair(id,sc));
00163    }
00164 
00165 }
00166 

Generated on Mon Jan 7 13:15:22 2013 for MicromegasFramework by  doxygen 1.4.7