psana_examples/src/DumpUsdUsb.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: DumpUsdUsb.cpp 5839 2013-03-22 18:16:33Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class DumpUsdUsb...
00007 //
00008 // Author List:
00009 //      Andy Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana_examples/DumpUsdUsb.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 
00022 //-------------------------------
00023 // Collaborating Class Headers --
00024 //-------------------------------
00025 #include "MsgLogger/MsgLogger.h"
00026 #include "psddl_psana/usdusb.ddl.h"
00027 
00028 //-----------------------------------------------------------------------
00029 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00030 //-----------------------------------------------------------------------
00031 
00032 // This declares this class as psana module
00033 using namespace psana_examples;
00034 PSANA_MODULE_FACTORY(DumpUsdUsb)
00035 
00036 //              ----------------------------------------
00037 //              -- Public Function Member Definitions --
00038 //              ----------------------------------------
00039 
00040 namespace psana_examples {
00041 
00042 //----------------
00043 // Constructors --
00044 //----------------
00045 DumpUsdUsb::DumpUsdUsb (const std::string& name)
00046   : Module(name)
00047   , m_src()
00048 {
00049   // get the values from configuration or use defaults
00050   m_src = configSrc("source", "DetInfo(:USDUSB)");
00051 }
00052 
00053 //--------------
00054 // Destructor --
00055 //--------------
00056 DumpUsdUsb::~DumpUsdUsb ()
00057 {
00058 }
00059 
00060 /// Method which is called at the beginning of the calibration cycle
00061 void 
00062 DumpUsdUsb::beginCalibCycle(Event& evt, Env& env)
00063 {
00064   shared_ptr<Psana::UsdUsb::ConfigV1> config1 = env.configStore().get(m_src);
00065   if (config1) {
00066     WithMsgLog(name(), info, str) {
00067       str << "UsdUsb::ConfigV1:";
00068       str << "\n  counting_mode = " << config1->counting_mode();
00069       str << "\n  quadrature_mode = " << config1->quadrature_mode();
00070     }
00071   }
00072 }
00073 
00074 /// Method which is called with event data, this is the only required 
00075 /// method, all other methods are optional
00076 void 
00077 DumpUsdUsb::event(Event& evt, Env& env)
00078 {
00079   shared_ptr<Psana::UsdUsb::DataV1> data1 = evt.get(m_src);
00080   if (data1) {
00081     WithMsgLog(name(), info, str) {
00082       str << "UsdUsb::DataV1:";
00083       str << "\n  encoder_count = " << data1->encoder_count();
00084       str << "\n  analog_in = " << data1->analog_in();
00085       ndarray<const uint8_t, 1> st = data1->status();
00086       str << "\n  status = [" << int(st[0]) << ' ' << int(st[1]) << ' ' << int(st[2]) << ' ' << int(st[3]) <<']' ;
00087       str << "\n  digital_in = " << int(data1->digital_in());
00088       str << "\n  timestamp = " << int(data1->timestamp());
00089     }
00090   }
00091 }
00092 
00093 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7