NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
XMLCrateReader.h
Go to the documentation of this file.
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2017.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Authors:
11  Ron Fox
12  Giordano Cerriza
13  NSCL
14  Michigan State University
15  East Lansing, MI 48824-1321
16 */
17 
21 #ifndef XMLCRATEREADER_H
22 #define XMLCRATEREADER_H
23 
24 #include "CrateReader.h"
25 
26 #include <stdint.h>
27 #include <map>
28 #include <string>
29 #include <stdio.h>
30 #include <tinyxml2.h>
31 #include "tinyxmlutil.h"
32 
33 namespace DDAS {
34 
65 class XMLCrateReader : public CrateReader {
66 public:
67 
68  // For each slot our document processor fills the following struct:
69 
70  struct SlotInformation {
71  unsigned s_slot; // Required.
72  std::string s_configFile; // required.
73  unsigned s_evtlen; // Required
74  unsigned s_fifothreshold; // Defaults to 10*EXTFIFO_READ_THRESH
75  bool s_infinityclock; // Defaults to false.
76  double s_timestampscale; // Defaults to 1.0
77  bool s_externalclock; // Defaults to false.
78  };
79 private:
80  // Map from slots to SlotInformation:
81 
82  std::map<unsigned short, SlotInformation> m_slotInfo;
83 public:
84  XMLCrateReader(const char* configFile);
85  virtual ~XMLCrateReader();
86 
87  // Required to implement the interface:
88 
89  virtual SettingsReader* createReader(unsigned short slot);
90 
91 
92  // Info getters the CrateReader doesn't need but others do:
93 
94  unsigned short getCrateId() const {return m_crateId;}
95  unsigned getEvtLen(unsigned short slot);
96  unsigned getFifoThreshold(unsigned short slot);
97  bool isInfinityClock(unsigned short slot);
98  double getTimestampScale(unsigned short slot);
99  bool isExternalClock(unsigned short slot);
100  const std::map<unsigned short, SlotInformation>&
101  getSlotInformation() const {return m_slotInfo;}
102 private:
103  const SlotInformation& getSlotInfo(unsigned short slot);
104  void processCrateFile(FILE* pFile);
105  void processCrateInfo(tinyxml2::XMLElement& root);
106  SlotInformation processSlotInfo(tinyxml2::XMLElement& slot);
107  void checkDuplicateSlot(const SlotInformation& slot);
108 
109 };
110 
111 
112 } // DDAS Namespace.
113 #endif
virtual ~XMLCrateReader()
Definition: XMLCrateReader.cpp:71
unsigned getFifoThreshold(unsigned short slot)
Definition: XMLCrateReader.cpp:109
unsigned getEvtLen(unsigned short slot)
Definition: XMLCrateReader.cpp:97
virtual SettingsReader * createReader(unsigned short slot)
Definition: XMLCrateReader.cpp:83
: Defines a class that can read a crate.
Definition: tinyxml2.h:1258
Definition: XMLCrateReader.h:65
Definition: SettingsReader.h:38
Definition: CrateReader.h:40
double getTimestampScale(unsigned short slot)
Definition: XMLCrateReader.cpp:130
: Provide common utilities for working with Tinyxml2
Definition: XMLCrateReader.h:70
bool isExternalClock(unsigned short slot)
Definition: XMLCrateReader.cpp:141
bool isInfinityClock(unsigned short slot)
Definition: XMLCrateReader.cpp:119
Definition: functions.h:26
XMLCrateReader(const char *configFile)
Definition: XMLCrateReader.cpp:48