psana_examples/src/DumpControl.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: DumpControl.cpp 6920 2013-10-07 22:09:39Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class DumpControl...
00007 //
00008 // Author List:
00009 //      Andrei Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana_examples/DumpControl.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 #include <iomanip>
00022 
00023 //-------------------------------
00024 // Collaborating Class Headers --
00025 //-------------------------------
00026 #include "MsgLogger/MsgLogger.h"
00027 #include "psddl_psana/control.ddl.h"
00028 
00029 //-----------------------------------------------------------------------
00030 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00031 //-----------------------------------------------------------------------
00032 
00033 using namespace psana_examples;
00034 PSANA_MODULE_FACTORY(DumpControl)
00035 
00036 namespace {
00037   
00038   void
00039   printClockTime(std::ostream& str, const Pds::ClockTime& time) 
00040   {
00041     str << time.seconds();
00042     if (time.nanoseconds()) {
00043       str.fill('0');
00044       str << std::setw(9) << time.nanoseconds();
00045       str.fill(' ');
00046     }
00047     str << "sec";
00048   }
00049 
00050 
00051   void printPVControl(std::ostream& str, const Psana::ControlData::PVControl& ctrl)
00052   {
00053     str << "\n    " << ctrl.name() << " index=" << ctrl.index()
00054         << " value=" << ctrl.value() << " array=" << int(ctrl.array());
00055   }
00056 
00057   void printPVMonitor(std::ostream& str, const Psana::ControlData::PVMonitor& mon)
00058   {
00059     str << "\n    " << mon.name() << " index=" << mon.index()
00060         << " low value=" << mon.loValue()
00061         << " high value=" << mon.hiValue()
00062         << " array=" << int(mon.array());
00063   }
00064 
00065   void printPVLabel(std::ostream& str, const Psana::ControlData::PVLabel& lbl)
00066   {
00067     str << "\n    " << lbl.name() << " value=" << lbl.value();
00068   }
00069 
00070 }
00071 
00072 //              ----------------------------------------
00073 //              -- Public Function Member Definitions --
00074 //              ----------------------------------------
00075 
00076 namespace psana_examples {
00077 
00078 //----------------
00079 // Constructors --
00080 //----------------
00081 DumpControl::DumpControl (const std::string& name)
00082   : Module(name)
00083 {
00084   m_src = configSrc("source", "ProcInfo()");
00085 }
00086 
00087 //--------------
00088 // Destructor --
00089 //--------------
00090 DumpControl::~DumpControl ()
00091 {
00092 }
00093 
00094 // Method which is called at the beginning of the calibration cycle
00095 void 
00096 DumpControl::beginCalibCycle(Event& evt, Env& env)
00097 {
00098   MsgLog(name(), trace, "in beginCalibCycle()");
00099 
00100   shared_ptr<Psana::ControlData::ConfigV1> config = env.configStore().get(m_src);
00101   if (config) {
00102     
00103     WithMsgLog(name(), info, str) {
00104       
00105       str << "ControlData::ConfigV1:"
00106           <<  "\n  uses_duration = " << (config->uses_duration() ? "yes" : "no")
00107           <<  "\n  duration = ";
00108       printClockTime(str, config->duration());
00109       str <<  "\n  uses_events = " << (config->uses_events() ? "yes" : "no")
00110           << "\n  events = " << config->events();
00111 
00112       const ndarray<const Psana::ControlData::PVControl, 1>& pvControls = config->pvControls();
00113       for (unsigned i = 0; i < pvControls.size(); ++ i) {
00114         if (i == 0) str << "\n  PV Controls:";
00115         printPVControl(str, pvControls[i]);
00116       }
00117 
00118       const ndarray<const Psana::ControlData::PVMonitor, 1>& pvMonitors = config->pvMonitors();
00119       for (unsigned i = 0; i < pvMonitors.size(); ++ i) {
00120         if (i == 0) str << "\n  PV Monitors:";
00121         printPVMonitor(str, pvMonitors[i]);
00122       }
00123     }
00124     
00125   }
00126 
00127 
00128   shared_ptr<Psana::ControlData::ConfigV2> config2 = env.configStore().get(m_src);
00129   if (config2) {
00130 
00131     WithMsgLog(name(), info, str) {
00132 
00133       str << "ControlData::ConfigV2:"
00134           <<  "\n  uses_duration = " << (config2->uses_duration() ? "yes" : "no")
00135           <<  "\n  duration = ";
00136       printClockTime(str, config2->duration());
00137       str <<  "\n  uses_events = " << (config2->uses_events() ? "yes" : "no")
00138           << "\n  events = " << config2->events();
00139 
00140       const ndarray<const Psana::ControlData::PVControl, 1>& pvControls = config2->pvControls();
00141       for (unsigned i = 0; i < pvControls.size(); ++ i) {
00142         if (i == 0) str << "\n  PV Controls:";
00143         printPVControl(str, pvControls[i]);
00144       }
00145 
00146       const ndarray<const Psana::ControlData::PVMonitor, 1>& pvMonitors = config2->pvMonitors();
00147       for (unsigned i = 0; i < pvMonitors.size(); ++ i) {
00148         if (i == 0) str << "\n  PV Monitors:";
00149         printPVMonitor(str, pvMonitors[i]);
00150       }
00151 
00152       const ndarray<const Psana::ControlData::PVLabel, 1>& pvLabels = config2->pvLabels();
00153       for (unsigned i = 0; i < pvLabels.size(); ++ i) {
00154         if (i == 0) str << "\n  PV Labels:";
00155         printPVLabel(str, pvLabels[i]);
00156       }
00157     }
00158 
00159   }
00160 
00161 
00162   shared_ptr<Psana::ControlData::ConfigV3> config3 = env.configStore().get(m_src);
00163   if (config3) {
00164 
00165     WithMsgLog(name(), info, str) {
00166 
00167       str << "ControlData::ConfigV3:"
00168           <<  "\n  uses_duration = " << (config3->uses_duration() ? "yes" : "no")
00169           <<  "\n  duration = ";
00170       printClockTime(str, config3->duration());
00171       str <<  "\n  uses_events = " << (config3->uses_events() ? "yes" : "no")
00172           <<  "\n  uses_l3t_events = " << (config3->uses_l3t_events() ? "yes" : "no")
00173           << "\n  events = " << config3->events();
00174 
00175       const ndarray<const Psana::ControlData::PVControl, 1>& pvControls = config3->pvControls();
00176       for (unsigned i = 0; i < pvControls.size(); ++ i) {
00177         if (i == 0) str << "\n  PV Controls:";
00178         printPVControl(str, pvControls[i]);
00179       }
00180 
00181       const ndarray<const Psana::ControlData::PVMonitor, 1>& pvMonitors = config3->pvMonitors();
00182       for (unsigned i = 0; i < pvMonitors.size(); ++ i) {
00183         if (i == 0) str << "\n  PV Monitors:";
00184         printPVMonitor(str, pvMonitors[i]);
00185       }
00186 
00187       const ndarray<const Psana::ControlData::PVLabel, 1>& pvLabels = config3->pvLabels();
00188       for (unsigned i = 0; i < pvLabels.size(); ++ i) {
00189         if (i == 0) str << "\n  PV Labels:";
00190         printPVLabel(str, pvLabels[i]);
00191       }
00192     }
00193 
00194   }
00195 }
00196 
00197 // Method which is called with event data
00198 void 
00199 DumpControl::event(Event& evt, Env& env)
00200 {
00201 }
00202   
00203 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7