GSISimulatedCycleDescriptor.cpp

Go to the documentation of this file.
00001 //Copyright GSI 2012
00002 #include <fesa-core-gsi/Synchronization/GSISimulatedCycleDescriptor.h>
00003 #include <fesa-core-gsi/Exception/GSIException.h>
00004 #include <fesa-core-gsi/RealTime/TimingSimulationStructures.h>
00005 #include <vector>
00006 
00007 namespace fesaGSI
00008 {
00009     GSISimulatedCycleDescriptor::GSISimulatedCycleDescriptor(const std::string& timingDomain,
00010             const std::string& timingCriterion, const std::string& timingSimulationConfigurationFile) :
00011         fesa::CycleDescriptor(timingDomain,timingCriterion)
00012     {
00013         timingDomain_ = timingDomain;
00014         timingCriterion_ = timingCriterion;
00015         readCycleSelectorColFromFile(timingSimulationConfigurationFile);
00016     }
00017 
00018     GSISimulatedCycleDescriptor::~GSISimulatedCycleDescriptor()
00019     {
00020 
00021     }
00022 
00023     void GSISimulatedCycleDescriptor::readCycleSelectorColFromFile(const std::string& timingSimulationConfigurationFile)
00024     {
00025         TimingSimulationConfig config(timingSimulationConfigurationFile);
00026 
00027         std::vector<DomainConfig*>::iterator domainIter;
00028         for (domainIter = config.timingDomainCol_.begin(); domainIter != config.timingDomainCol_.end(); domainIter++)
00029         {
00030                 if((*domainIter)->name_ == timingDomain_)
00031                 {
00032                 std::vector<CycleConfig>::iterator cycleIter;
00033                 for (cycleIter = (*domainIter)->superCycle_.cycleCol_.begin(); cycleIter != (*domainIter)->superCycle_.cycleCol_.end(); cycleIter++)
00034                 {
00035                         std::string cycleSelectorName;
00036                         if(timingCriterion_ == "USER")
00037                         {
00038                                 cycleSelectorName = timingDomain_ + "." + timingCriterion_ + "." + cycleIter->cycleName_;
00039                         }
00040                         else
00041                         {
00042                         if(cycleIter->telegramData_ != NULL)
00043                         {
00044                                 if(timingCriterion_ == "DEST")
00045                                 {
00046                                         cycleSelectorName = timingDomain_ + "." + timingCriterion_ + "." + cycleIter->telegramData_->destination_;
00047                                 }
00048                                 else if(timingCriterion_ == "PARTY")
00049                                 {
00050                                         cycleSelectorName = timingDomain_ + "." + timingCriterion_ + "." + cycleIter->telegramData_->particleType_;
00051                                 }
00052                                 else if(timingCriterion_ == "SPCON")
00053                                 {
00054                                         cycleSelectorName = timingDomain_ + "." + timingCriterion_ + "." + cycleIter->telegramData_->spCon_;
00055                                 }
00056                                 else
00057                                 {
00058                                         throw GSIException(__FILE__, __LINE__, FesaGSITimingSimulationFileCorrupt.c_str());
00059                                 }
00060                         }
00061                         }
00062                         addSelector(cycleSelectorName);
00063                 }
00064                 return;//the domain-element is unique .. if we found it, we can return
00065                 }
00066         }
00067         //if we arrive here: nothing found
00068         throw GSIException(__FILE__, __LINE__, FesaGSITimingSimulationFileCorrupt.c_str());
00069     }
00070 }//end namespace

Generated on 25 Jan 2013 for fesa-core-gsi by  doxygen 1.6.1