Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DModuleType.h
Go to the documentation of this file.
1 // $Id$
2 // $HeadURL$
3 //
4 // File: DModuleType.h
5 // Created: Thu Aug 9 08:56:08 EDT 2012
6 // Creator: davidl (on Darwin harriet.jlab.org 11.4.0 i386)
7 //
8 
9 #ifndef _DModuleType_
10 #define _DModuleType_
11 
12 #include <string>
13 
15  public:
16 
17  // NOTE: The following enum MUST be kept in alignment with the DAQ
18  // group's definitions! The real data will include this module
19  // type in the Block Header for JLab modules (bits 18-21).
20  //
21  // These were taken from mc2coda.h v2
22  // (see /site/coda/3.0/extensions/mc2coda/v2.0/mc2coda.h)
23  //
24  // Add new module types to end of list *before* N_MODULE_TYPES
25  // To add a new module, one also needs to add a new case to the
26  // the switch in the GetModule(type_id_t) method below.
27  enum type_id_t {
28  TID, // =0
29  FADC250, // =1
30  FADC125, // =2
31  F1TDC32, // =3
32  F1TDC48, // =4
33  JLAB_TS, // =5
34  TD, // =6
35  SSP, // =7
36  JLAB_DISC, // =8
44 
45  // The following are not defined by the DAQ group (i.e.
46  // they don't control the data format so can't encode
47  // the module type in it)
48  UNKNOWN, // =16
49  VMECPU, // =17
50  CAEN1190, // =18
51  CAEN1290, // =19
52 
53  CDAQTSG=22, // = 22
54 
55  N_MODULE_TYPES // Make sure this is the last thing in the enum!
56  };
57 
58  //------------------------------
59  // Constructor
60  //
61  DModuleType(type_id_t type, std::string name, std::string description):type(type),name(name),description(description){}
62 
63 
64  //------------------------------
65  // GetModule(type_id_t)
66  //
67  /// Given the type_id of a module type, return a DModuleType object.
68  /// This is much more efficient than GetModule(string), but is still
69  /// not really intended to be called every event.
71  switch(id){
72  case TID : return DModuleType(TID, "TID" , "JLab Trigger Interface");
73  case FADC250 : return DModuleType(FADC250, "FADC250" , "JLab Flash 250 MHz ADC");
74  case FADC125 : return DModuleType(FADC125, "FADC125" , "JLab Flash 125 MHz ADC");
75  case F1TDC32 : return DModuleType(F1TDC32, "F1TDC32" , "JLab F1 TDC (32 chan)");
76  case F1TDC48 : return DModuleType(F1TDC48, "F1TDC48" , "JLab F1 TDC (48 chan)");
77  case JLAB_TS : return DModuleType(JLAB_TS, "JLAB_TS" , "JLab Trigger Supervisor");
78  case TD : return DModuleType(TD, "TD" , "JLab Trigger Distribution");
79  case SSP : return DModuleType(SSP, "SSP" , "JLab Sub-System Processor");
80  case JLAB_DISC: return DModuleType(JLAB_DISC, "JLAB_DISC", "JLab Discriminator");
81 
82  case VMECPU : return DModuleType(VMECPU, "VMECPU" , "VME CPU");
83  case CAEN1190 : return DModuleType(CAEN1190, "CAEN1190" , "CAEN 1190 TDC");
84  case CAEN1290 : return DModuleType(CAEN1290, "CAEN1290" , "CAEN 1290 TDC");
85 
86  default: return DModuleType(UNKNOWN, "UNKNOWN", "Unknown module type");
87  }
88  }
89 
90  //------------------------------
91  // GetModule(string)
92  //
93  /// Given the name of a module type, return a DModuleType object.
94  /// This is not a terribly efficient mechanism and is inteded to
95  /// be called only at the beginning of event processing rather than
96  /// every event.
98  std::vector<DModuleType> modules;
99  GetModuleList(modules);
100  for(unsigned int i=UNKNOWN; i<N_MODULE_TYPES; i++){
101  if(modules[i].name == name)return modules[i];
102  }
103 
104  return GetModule(UNKNOWN);
105  }
106 
107  //------------------------------
108  // GetModuleList
109  //
110  /// Get a list of all module types currently defined. This
111  /// will append the full list to the given "modules" container.
112  /// (The vector is not cleared on input).
113  static void GetModuleList(std::vector<DModuleType> &modules){
114 
115  for(int id=UNKNOWN; id<N_MODULE_TYPES; id++){
116  modules.push_back(GetModule((type_id_t)id));
117  }
118  }
119 
120  //------------------------------
121  // GetName
122  //
123  /// Get the name of a module type based on its id. This can
124  /// be called without an instance of the class if one already
125  /// has the type.
126  static string GetName(type_id_t id){
127  return GetModule(id).GetName();
128  }
129 
130  //------------------------------
131  // GetDescription
132  //
133  /// Get the name of a module type based on its id. This can
134  /// be called without an instance of the class if one already
135  /// has the type.
136  static string GetDescription(type_id_t id){
137  return GetModule(id).GetDescription();
138  }
139 
140  //------------------------------
141  // non-static methods
142  type_id_t GetType(void) const {return type;}
143  string GetName(void) const {return name;}
144  string GetDescription(void) const {return description;}
145 
146  protected:
150 
151 };
152 
154 
155 #endif // _DModuleType_
156 
DModuleType(type_id_t type, std::string name, std::string description)
Definition: DModuleType.h:61
type_id_t GetType(void) const
Definition: DModuleType.h:142
char string[256]
DModuleType::type_id_t MODULE_TYPE
Definition: DModuleType.h:153
static void GetModuleList(std::vector< DModuleType > &modules)
Get a list of all module types currently defined. This will append the full list to the given &quot;module...
Definition: DModuleType.h:113
std::string description
Definition: DModuleType.h:149
string GetDescription(void) const
Definition: DModuleType.h:144
static string GetDescription(type_id_t id)
Get the name of a module type based on its id. This can be called without an instance of the class if...
Definition: DModuleType.h:136
static DModuleType GetModule(type_id_t id)
Given the type_id of a module type, return a DModuleType object. This is much more efficient than Get...
Definition: DModuleType.h:70
string GetName(void) const
Definition: DModuleType.h:143
static string GetName(type_id_t id)
Get the name of a module type based on its id. This can be called without an instance of the class if...
Definition: DModuleType.h:126
type_id_t type
Definition: DModuleType.h:147
static DModuleType GetModule(std::string name)
Given the name of a module type, return a DModuleType object. This is not a terribly efficient mechan...
Definition: DModuleType.h:97
std::string name
Definition: DModuleType.h:148