CFEL - ASG Software Suite  2.5.0
CASS
machine_converter.h
Go to the documentation of this file.
1 // Copyright (C) 2009 - 2014 Lutz Foucar
2 
3 /**
4  * @file machine_converter.h contains xtc converter for machine data
5  *
6  * @author Lutz Foucar
7  */
8 
9 
10 #ifndef MACHINEDATACONVERTER_H
11 #define MACHINEDATACONVERTER_H
12 
13 #include <map>
14 #include <tr1/functional>
15 
16 #include <QtCore/QMutex>
17 
18 #include "conversion_backend.h"
19 #include "machine_device.hpp"
20 
21 namespace Pds
22 {
23 class EpicsPvHeader;
24 }
25 
26 namespace cass
27 {
28 class CASSEvent;
29 
30 namespace MachineData
31 {
32 
33 class XTCDataKey;
34 
35 /** Converter for Beamline-, Cavity-, Epics- and EVR Data
36  *
37  * Will convert Beamline data, Cavity data, Epics Data and EVR Data
38  *
39  * @note maybe split this to several converters for the different data types
40  * will this work. ie is only the epics map copied or the whole
41  * event?
42  *
43  * @author Lutz Foucar
44  */
46 {
47 public:
48  /** create singleton if doesnt exist already */
50 
51  /** called for appropriate xtc part.
52  *
53  * @param xtc the xtc that contains evr, epics, beamlinedata info
54  * @param evt pointer to the event that we will write the data to.
55  */
56  void operator()(const Pds::Xtc*xtc, cass::CASSEvent*evt);
57 
58  /** called before the conversion
59  *
60  * @param evt pointer to the event that needs to be finalized
61  */
62  void prepare(CASSEvent *evt);
63 
64  /** called at the end of the conversion
65  *
66  * @param evt pointer to the event that needs to be finalized
67  */
68  void finalize(CASSEvent *evt);
69 
70 private:
71 
72 private:
73  /** constructor
74  *
75  * sets up the pds types that it is responsible for
76  */
77  Converter();
78 
79  /** prevent copy construction */
80  Converter(const Converter&);
81 
82  /** prevent assignment */
83  Converter& operator=(const Converter&);
84 
85  /** the singleton container */
87 
88  /** singleton locker for mutithreaded requests */
89  static QMutex _mutex;
90 
91  /** define the conversion map from keys to strings */
92  typedef std::map<XTCDataKey,std::string> KeyMap_t;
93 
94  /** map Epics Keys to strings */
95  KeyMap_t _index2name;
96 
97  /** define the function to convert epics to cass */
98  typedef std::tr1::function<void(const Pds::EpicsPvHeader&,
99  Device::epicsDataMap_t::iterator,
100  Device::epicsDataMap_t::iterator)> epicsType2val_t;
101 
102  /** define a map to map epics type to function for retrieval of the value */
103  typedef std::map<int16_t, epicsType2val_t > epicsType2convFunc_t;
104 
105  /** map containing fucntions that convert epics values to cass values */
106  epicsType2convFunc_t _epicsType2convFunc;
107 
108  /** a container for the epics values
109  *
110  * @note this is necessary, since not every shot there is info about the
111  * epics values and calibcycle
112  */
114 };
115 }//end namespace MachineData
116 }//end namespace cass
117 
118 #endif
Event to store all LCLS Data.
Definition: cass_event.h:32
KeyMap_t _index2name
map Epics Keys to strings
static ConversionBackend::shared_pointer _instance
the singleton container
file contains base class for all format converters
std::tr1::function< void(const Pds::EpicsPvHeader &, Device::epicsDataMap_t::iterator, Device::epicsDataMap_t::iterator)> epicsType2val_t
define the function to convert epics to cass
epicsType2convFunc_t _epicsType2convFunc
map containing fucntions that convert epics values to cass values
Container for all Machine related Data.
Device _store
a container for the epics values
std::tr1::shared_ptr< ConversionBackend > shared_pointer
typedef
void operator()(const Pds::Xtc *xtc, cass::CASSEvent *evt)
called for appropriate xtc part.
definitions of a machine device
Converter & operator=(const Converter &)
prevent assignment
static QMutex _mutex
singleton locker for mutithreaded requests
Base class for Converters.
static ConversionBackend::shared_pointer instance()
create singleton if doesnt exist already
void prepare(CASSEvent *evt)
called before the conversion
std::map< XTCDataKey, std::string > KeyMap_t
define the conversion map from keys to strings
Converter for Beamline-, Cavity-, Epics- and EVR Data.
void finalize(CASSEvent *evt)
called at the end of the conversion
std::map< int16_t, epicsType2val_t > epicsType2convFunc_t
define a map to map epics type to function for retrieval of the value