Page History
...
The Xtc package defines several classes.
Class XtcFileIterator
An xtc file is a collection of datagrams (Dgram).
A datagram contains: Sequence, Env and Xtc.. This is an iterator to loop through all datagrams in a file.
Public Member Functions:
Code Block |
---|
// Constructor and destructor XtcFileIterator(int fd, size_t maxDgramSize); ~XtcFileIterator(); Dgram* next(); |
Class Dgram
Datagram - structure of a piece of information within the xtc file.
A datagram contains: Sequence, Env and Xtc.
Code Block |
---|
Dgram --- Dgram ----------------------------------------- | | | Sequence Env Xtc |
Class Xtc
This class defines a container for data stored in an xtc file. An event is a collection of such containers. The size and location of the unspecified data contained are defined by the "sizeofPayload" and "payload" functions. To iterate over a set of such containers see "XtcIterator.hh".
Public Member Functions:
Constructors:
Code Block |
---|
//Constructor used to create an empty, unlabeled
Xtc() : damage(0), extent(0) {};
// Copy constructor, will copy everything, but NOT the payload.
Xtc(const Xtc& xtc) :
damage(xtc.damage), src(xtc.src), contains(xtc.contains), extent(sizeof(Xtc)) {}
//
Xtc(const TypeId& type) :
damage(0), contains(type), extent(sizeof(Xtc)) {}
Xtc(const TypeId& type, const Src& _src) :
damage(0), src(_src), contains(type), extent(sizeof(Xtc)) {}
Xtc(const TypeId& _tag, const Src& _src, unsigned _damage) :
damage(_damage), src(_src), contains(_tag), extent(sizeof(Xtc)) {}
Xtc(const TypeId& _tag, const Src& _src, const Damage& _damage) :
damage(_damage), src(_src), contains(_tag), extent(sizeof(Xtc)) {}
|
Overloaded allocation operators to allow the insertion of a dummy "Xtc" within a datagram.
Code Block |
---|
void* operator new(size_t size, char* p) { return (void*)p; }
void* operator new(size_t size, Xtc* p) { return p->alloc(size); }
|
Public Attributes:
Code Block |
---|
PDS_DGRAM_STRUCT // #define PDS_DGRAM_STRUCT Sequence seq; Env env; Xtc xtc
|
Class Sequence
Defined in pdsdata/xtc/Sequence.hh
.
Public Types:
Code Block |
---|
enum Type {Event = 0, Occurrence = 1, Marker = 2};
enum {NumberOfTypes = 3};
|
Public Member Functions:
Code Block |
---|
// Constructors
Sequence() {}
Sequence(const Sequence&);
Sequence(const ClockTime& clock, const TimeStamp& stamp);
Sequence(Type, TransitionId::Value, const ClockTime&, const TimeStamp&);
Type type() const;
TransitionId::Value service() const;
bool isExtended() const;
bool isEvent() const;
const ClockTime& clock() const {return _clock;}
const TimeStamp& stamp() const {return _stamp;}
Sequence& operator=(const Sequence&);
|
Class Env
Defined in pdsdata/xtc/Env.hh
Public Member Functions
Code Block |
---|
// Constructors
Env() {}
Env(const Env& in) : _env(in._env) {}
Env(uint32_t env);
uint32_t value() const;
const Env& operator=(const Env& that);
|
Class Xtc
This class defines a container for data stored in an xtc file. An event is a collection of such containers. The size and location of the unspecified data contained are defined by the "sizeofPayload" and "payload" functions. To iterate over a set of such containers see "XtcIterator.hh".
Public Member Functions:
Constructors:
Code Block |
---|
//Constructor used to create an empty, unlabeled
Xtc() : damage(0), extent(0) {}; |
Code Block |
// Return a pointer (of unspecified type) to the payload associated with this class char* payload() const { return (char*)(this+1); } // Return the size (in bytes) ofCopy constructor, will copy everything, but NOT the payload associated with the class. intXtc(const Xtc& xtc) : sizeofPayloaddamage(xtc.damage) const { return extent - , src(xtc.src), contains(xtc.contains), extent(sizeof(Xtc);) {} // Return the Xtc(const whichTypeId& istype) immediately: following an object of this class. Xtc* next() damage(0), contains(type), extent(sizeof(Xtc)) {} Xtc(const TypeId& type, const Src& _src) : damage(0), { return (Xtc*)((char*)this+extent); } src(_src), contains(type), extent(sizeof(Xtc)) {} Xtc(const Xtc* next() TypeId& _tag, const Src& _src, unsigned _damage) : const { return (const Xtc*)((char*)this+extent); damage(_damage), src(_src), contains(_tag), extent(sizeof(Xtc)) {} void* alloc(uint32_t size) { void* buffer = next(); extent += size; return buffer; } Xtc(const TypeId& _tag, const Src& _src, const Damage& _damage) : damage(_damage), src(_src), contains(_tag), extent(sizeof(Xtc)) {} |
Overloaded allocation operators to allow the insertion of a dummy "Xtc" within a datagram.Public Attributes:
Code Block |
---|
Damagevoid* operator damage; Srcnew(size_t size, char* p) { return src;(void*)p; } TypeIdvoid* operator contains; new(size_t size, Xtc* p) { uint32_t extent; |
Class XtcIterator
This is an abstract class.
This class allows iteration over a collection of "Xtc" objects. An "event" generated from DataFlow consists of data described by a collection of "Xtc" objects. Therefore, this class is instrumental in the navigation of an event's data. The set of "Xtc"s is determined by passing (typically to the constructor) a root "Xtc" which describes the collection of "Xtc"s to process. This root, for example is provided by an event's datagram. As this is an Abstract-Base-Class, it is expected that an application will subclass from this class, providing an implementation of the "process" method. This method will be called back for each "Xtc" in the collection. Note that the "Xtc" to process is passed as an argument. If the "process" method wishes to abort the iteration a zero (0) value is returned. The iteration is initiated by calling the "iterate" member function.
Public Member Functions:
Constructors and destructor:
Code Block |
---|
XtcIterator(Xtc* root);
XtcIterator() {}
virtual ~XtcIterator() {}
|
The first constructor takes an argument the "Xtc" which defines the collection to iterate over.
Code Block |
---|
virtual int process(Xtc* xtc) = 0;
|
This function is pure virtual and must be implemented by all derived classes.
Code Block |
---|
void iterate();
|
This function commences iteration over the collection specified by the constructor.
Code Block |
---|
void iterate(Xtc*);
|
Iterate over the collection specifed as an argument to the function. For each "Xtc" found call back the "process" function. If the "process" function returns zero (0) the iteration is aborted and control is returned to the caller. Otherwise, control is returned when all elements of the collection have been scanned.
Code Block |
---|
const Xtc* root() const;
|
This function returns the collection specified by the constructor.
Class Sequence
Defined in pdsdata/xtc/Sequence.hh
.
Public Types:
Code Block |
---|
enum Type {Event = 0, Occurrence = 1, Marker = 2};
enum {NumberOfTypes = 3};
|
return p->alloc(size); }
|
Code Block |
---|
// Return a pointer (of unspecified type) to the payload associated with this class
char* payload() const { return (char*)(this+1); }
// Return the size (in bytes) of the payload associated with the class.
int sizeofPayload() const { return extent - sizeof(Xtc); }
// Return the Xtc which is immediately following an object of this class.
Xtc* next() { return (Xtc*)((char*)this+extent); }
const Xtc* next() const { return (const Xtc*)((char*)this+extent); }
void* alloc(uint32_t size) { void* buffer = next(); extent += size; return buffer; }
|
Public Attributes:
Code Block |
---|
Damage damage;
Src src;
TypeId contains;
uint32_t extent;
|
Class XtcIterator
This class allows iteration over a collection of "Xtc" objects. An "event" generated from DataFlow consists of data described by a collection of "Xtc" objects. Therefore, this class is instrumental in the navigation of an event's data. The set of "Xtc"s is determined by passing (typically to the constructor) a root "Xtc" which describes the collection of "Xtc"s to process. This root, for example is provided by an event's datagram.
As this is an Abstract-Base-Class, it is expected that an application will subclass from this class, providing an implementation of the "process" method. This method will be called back for each "Xtc" in the collection. Note that the "Xtc" to process is passed as an argument. If the "process" method wishes to abort the iteration a zero (0) value is returned. The iteration is initiated by calling the "iterate" member function.
Public Member Functions:
Constructors and destructorPublic Member Functions:
Code Block |
---|
// ConstructorsXtcIterator(Xtc* root); SequenceXtcIterator() {} Sequencevirtual ~XtcIterator(const Sequence&);) {} |
The first constructor takes an argument the "Xtc" which defines the collection to iterate over.
Code Block |
---|
virtual int process(Xtc* xtc) = 0;
|
This function is pure virtual and must be implemented by all derived classes.
Code Block |
---|
void iterate();
|
This function commences iteration over the collection specified by the constructor.
Code Block |
---|
Sequence(const ClockTime& clock, const TimeStamp& stamp); Sequence(Type, TransitionId::Value, const ClockTime&, const TimeStamp&); Typevoid type() const; TransitionId::Value serviceiterate(Xtc*) const; bool isExtended() const; bool isEvent() const; const ClockTime& clock() const {return _clock;} const TimeStamp& stamp() const {return _stamp;} Sequence& operator=(const Sequence&); |
Class Env
Defined in pdsdata/xtc/Env.hh
Public Member Functions
;
|
Iterate over the collection specifed as an argument to the function. For each "Xtc" found call back the "process" function. If the "process" function returns zero (0) the iteration is aborted and control is returned to the caller. Otherwise, control is returned when all elements of the collection have been scanned.
Code Block |
---|
const Xtc* root() const;
|
This function returns the collection specified by the constructor.
Class Level
Defined in pdsdata/xtc/Level.hh
Public Types:
Code Block |
---|
enum Type{Control, Source, Segment, Event, Recorder, Observer, Reporter,
NumberOfLevels};
|
Static Public Member Functions
Code Block |
---|
static const char* name(Type type);
|
Class TransitionId
Public Types:
Code Block |
---|
enum Value {
Unknown, Reset,
Map, Unmap,
Configure, Unconfigure,
BeginRun, EndRun,
BeginCalibCycle, EndCalibCycle,
Enable, Disable,
L1Accept,
NumberOf };
|
Static Public Member Functions:
Code Block |
---|
static const char* name(TransitionId::Value id |
Code Block |
// Constructors
Env() {}
Env(const Env& in) : _env(in._env) {}
Env(uint32_t env);
uint32_t value() const;
const Env& operator=(const Env& that);
|
Class Src
This is a base class for any source of information in the xtc file (e.g. Detector, Beamline, Process). Defined in pdsdata/xtc/Src.hh
...
Code Block |
---|
// Constructors DetInfo() {} DetInfo(uint32_t processId, // Detector det, // uint32_t detId, // Device dev, // uint32_t devId); // bool operator==(const DetInfo &) const; uint32_t processId() const; Detector detector() const; Device device() const; uint32_t detId() const; uint32_t devId detector() const; |
Static Public Member Functions
Code Block |
---|
static const char *name(Detector)Device device() const; static const char *name(Device)uint32_t detId() const; static const char *name(const DetInfo &); |
Class ClockTime
Defined in pdsdata/xtc/ClockTime.hh
.
Public Member Functions:
...
uint32_t devId() const;
|
Static Public Member Functions
Code Block |
---|
|
...
static const char |
...
*name(Detector); |
...
static const char *name(Device); |
...
static |
...
const char |
...
*name( |
...
const DetInfo &); |
Class ClockTime
Defined in pdsdata/xtc/ClockTime.hh
.
Public Member Functions:
- Constructors (ClockTime has no destructor) {return _high;}
unsigned nanoseconds() const {return _low;}
Operators
Code Block ClockTime& operator=(const ClockTime&); bool operator> ClockTime(const ClockTime& t) const; bool operator==(const ClockTime&) const;
Class Damage
Defined in pdsdata/xtc/Damage.hh
, inline implementation.
ClockTime(unsigned sec, unsigned nsec);
- Accessors:
Code Block unsigned seconds () const {return _high;} unsigned nanoseconds() const {return _low;}
- Operators
Code Block ClockTime& operator=(const ClockTime&); bool operator> (const ClockTime&) const; bool operator==(const ClockTime&) const;
Class Damage
Defined in pdsdata/xtc/Damage.hh
, inline implementation.
Public Types:
Code Block |
---|
enum Value {
|
Code Block |
Bit Mask Name ----------------------------------- 1 0x00002 DroppedContribution 12 0x01000 OutOfOrder 13 0x02000 OutOfSynch 14 0x04000 UserDefined 15 0x08000 IncompleteContribution 16 0x10000 ContainsIncomplete Bit = n means 1<<n, i.e. 1 shifted left n bits: DroppedContribution = 1, OutOfOrder Decimal Binary int32_t value = 1= 12, OutOfSynch 00000000000000000000000000000001 = 13, UserDefined = 14, | IncompleteContribution = 15, | ContainsIncomplete | = 16 |}; DroppedContribution // reserve the top byte to augment user defined 00000000000000000000000000000010errors OutOfOrder enum {NotUserBitsMask=0x00FFFFFF, 00000000000000000001000000000000 OutOfSynch 00000000000000000010000000000000 UserDefined 00000000000000000100000000000000 IncompleteContribution 00000000000000001000000000000000 ContainsIncomplete 00000000000000010000000000000000 |
Public Types:
UserBitsShift = 24};
|
- DroppedContribution - means that event is "split" and contains only partial data from incomplete set of detectors. There may be another (or even few) datagram with the same timestamp containing remaining data from the same event.
- OutOfOrder - In this case the event may contain data from one or more detector which actually belong to a different event.
- OutOfSynch
- UserDefined - reserved for user-defined conditions
- IncompleteContribution - means that data in that particular container is badly damaged, are incomplete, and cannot be used
- ContainsIncomplete - means that it contains one or more containers at deeper XTC levels which have IncompleteContribution damage, events with this damage may be partially useful
Code Block |
---|
Bit Mask Name
-----------------------------------
1 0x00002 DroppedContribution
12 0x01000 OutOfOrder
13 0x02000 OutOfSynch
14 0x04000 UserDefined
15 0x08000 IncompleteContribution
16 0x10000 ContainsIncomplete
Bit = n means 1<<n, i.e. 1 shifted left n bits:
|
Code Block |
enum Value { DroppedContribution = 1, OutOfOrder = 12, OutOfSynch = 13, UserDefined Decimal Binary int32_t value = 14, 1 IncompleteContribution = 15, ContainsIncomplete 00000000000000000000000000000001 = 16 }; // reserve the top byte to augment user defined errors enum {NotUserBitsMask=0x00FFFFFF, UserBitsShift = 24}; |
Public Member Functions:
Code Block |
---|
// Constructor | Damage(uint32_t v) : _damage(v) {} | | uint32_t value() const | DroppedContribution { return _damage; }00000000000000000000000000000010 OutOfOrder void increase(Damage::Value v) { _damage |= ((1<<v) & NotUserBitsMask); } void 00000000000000000001000000000000 OutOfSynch increase(uint32_t v) { _damage |= v & NotUserBitsMask; } uint32_t bits() const00000000000000000010000000000000 UserDefined { return _damage & NotUserBitsMask;}00000000000000000100000000000000 IncompleteContribution uint32_t userBits() const 00000000000000001000000000000000 ContainsIncomplete { return _damage >> 00000000000000010000000000000000 |
Public Member Functions:
Code Block |
---|
UserBitsShift; } void// Constructor userBitsDamage(uint32_t v) : _damage(v) {} uint32_t _damage &= NotUserBitsMask; value() const _damage |= (v{ <<return UserBitsShift)_damage; } } |
Class Dgram
Datagram - structure of a piece of information within the xtc file.
Public Attributes:
Code Block |
---|
void PDS_DGRAM_STRUCT // #define PDS_DGRAM_STRUCT Sequence seq; Env env; Xtc xtc |
Class Level
Defined in pdsdata/xtc/Level.hh
Public Types:
Code Block |
---|
enum Type{Control, Source, Segment, Event, Recorder, Observer, Reporter, increase(Damage::Value v) { _damage |= ((1<<v) & NotUserBitsMask); } void increase(uint32_t v) { _damage |= v & NotUserBitsMask; } uint32_t bits() const NumberOfLevels}; |
Static Public Member Functions
Code Block |
---|
static const{ char* name(Type type); |
Class TimeStamp
Public Types:
Code Block |
---|
enum {NumFiducialBits = 17}; return _damage & NotUserBitsMask;} uint32_t userBits() const enum {MaxFiducials = (1<<17)-32}; { return enum_damage {ErrFiducial>> = (1<<17)-1}; |
Public Member Functions:
Code Block |
---|
UserBitsShift; } void TimeStamp(); TimeStampuserBits(const TimeStamp&); uint32_t v) { TimeStamp(const_damage TimeStamp&, unsigned control)= NotUserBitsMask; TimeStamp(unsigned ticks, unsigned fiducials, unsigned vector, unsigned control=0_damage |= (v << UserBitsShift); unsigned ticks} |
Class TimeStamp
Public Types:
Code Block |
---|
enum {NumFiducialBits ()= const17}; unsigned fiducials() constenum {MaxFiducials = (1<<17)-32}; unsignedenum control{ErrFiducial = (1<<17) const-1}; |
Public Member Functions:
Code Block |
---|
unsignedTimeStamp(); vector TimeStamp(const TimeStamp&) const; TimeStamp& operator= (const TimeStamp&, unsigned control); boolTimeStamp(unsigned ticks, unsigned fiducials, unsigned vector, unsigned operator==(const TimeStamp&) const; bool control=0); unsigned ticks operator>=(const TimeStamp&) const; unsigned bool fiducials() const; unsigned control operator<=(const TimeStamp& () const; boolunsigned vector operator< (const TimeStamp&) const; bool operator> TimeStamp& operator= (const TimeStamp&) const; |
Class TransitionId
Public Types:
Code Block |
---|
enumbool Value { Unknown, Reset,operator==(const TimeStamp&) const; bool Map, Unmap, operator>=(const Configure, Unconfigure,TimeStamp&) const; bool BeginRun, EndRun, operator<=(const BeginCalibCycle, EndCalibCycle, TimeStamp&) const; bool Enable, Disable, operator< (const L1Accept, TimeStamp&) const; NumberOf }; |
Static Public Member Functions:
Code Block |
---|
bool static const char*operator> name(TransitionId::Value id)const TimeStamp&) const; |
Class TypeId
Public Types:
...
Code Block |
---|
TypeId() {}
TypeId(const TypeId& v);
TypeId(Type type, uint32_t version);
Type id() const;
uint32_t version() const;
uint32_t value() const;
static const char* name(Type type);
|
Class XtcFileIterator
Public Member Functions:
Code Block |
---|
// Constructor and destructor
XtcFileIterator(int fd, size_t maxDgramSize);
~XtcFileIterator();
Dgram* next();
|