DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DeviceInterface.hpp
Go to the documentation of this file.
1
8#ifndef SSPMODULES_SRC_ANLBOARD_DEVICEINTERFACE_HPP_
9#define SSPMODULES_SRC_ANLBOARD_DEVICEINTERFACE_HPP_
10
13#include "logging/Logging.hpp"
14
15#include "Device.hpp"
16#include "DeviceManager.hpp"
17#include "EventPacket.hpp"
18
19#include <deque>
20#include <map>
21#include <memory>
22#include <queue>
23#include <string>
24#include <vector>
25
26namespace dunedaq {
27namespace sspmodules {
28
30{
31 unsigned long startTime; // NOLINT(runtime/int)
32 unsigned long endTime; // NOLINT(runtime/int)
33 unsigned long triggerTime; // NOLINT(runtime/int)
34 unsigned short triggerType; // NOLINT(runtime/int)
35};
36
38{
39
40public:
50
51 // Just sets the fields needed to request the device.
52 // Real work is done in Initialize which is called manually.
53 explicit DeviceInterface();
54
56
57 void OpenSlowControl();
58
60
61 // Called by ReadEvents
62 // Get an event off the hardware buffer.
63 // Timeout after some wait period
65
66 // Obtain current state of device
67 // inline State_t State(){return fState;}
68
69 // Setter for single register
70 // If mask is given then only bits which are high in the mask will be set.
71 void SetRegister(unsigned int address, unsigned int value, unsigned int mask = 0xFFFFFFFF);
72
73 // Setter for series of contiguous registers, with vector input
74 void SetRegisterArray(unsigned int address, std::vector<unsigned int> value);
75
76 // Setter for series of contiguous registers, with C array input
77 void SetRegisterArray(unsigned int address, unsigned int* value, unsigned int size);
78
79 // Getter for single register
80 // If mask is set then bits which are low in the mask will be returned as zeros.
81 void ReadRegister(unsigned int address, unsigned int& value, unsigned int mask = 0xFFFFFFFF);
82
83 // Getter for series of contiguous registers, with vector output
84 void ReadRegisterArray(unsigned int address, std::vector<unsigned int>& value, unsigned int size);
85
86 // Getter for series of contiguous registers, with C array output
87 void ReadRegisterArray(unsigned int address, unsigned int* value, unsigned int size);
88
89 // Methods to set registers with names (as defined in SSPDAQ::RegMap)
90
91 // Set single named register
92 void SetRegisterByName(std::string name, unsigned int value);
93
94 // Set single element of an array of registers
95 void SetRegisterElementByName(std::string name, unsigned int index, unsigned int value);
96
97 // Set all elements of an array to a single value
98 void SetRegisterArrayByName(std::string name, unsigned int value);
99
100 // Set all elements of an array using values vector
101 void SetRegisterArrayByName(std::string name, std::vector<unsigned int> values);
102
103 // Read single named register
104 void ReadRegisterByName(std::string name, unsigned int& value);
105
106 // Read single element of an array of registers
107 void ReadRegisterElementByName(std::string name, unsigned int index, unsigned int& value);
108
109 // Read all elements of an array into values vector
110 void ReadRegisterArrayByName(std::string name, std::vector<unsigned int>& values);
111
112 void SetHardwareClockRateInMHz(unsigned int rate) { fHardwareClockRateInMHz = rate; }
113
114 void SetDummyPeriod(int period) { fDummyPeriod = period; }
115
117
118 void SetPartitionNumber(unsigned int val) { fPartitionNumber = val; }
119
120 void SetTimingAddress(unsigned int val) { fTimingAddress = val; }
121
122 void PrintHardwareState();
123
124 std::string GetIdentifier();
125
126 bool exception() const { return exception_.load(); }
127
128private:
129 // Internal device object used for hardware operations.
130 // Owned by the device manager, not this object.
132
133 // Index of the device in the hardware-returned list
134 unsigned long fDeviceId; // NOLINT(runtime/int)
135
136 // Holds current device state. Hopefully this matches the state of the
137 // hardware itself.
139
141
143
145
147
149
150 unsigned int fPartitionNumber;
151
152 unsigned int fTimingAddress;
153
154 std::atomic<bool> exception_;
155};
156
157} // namespace sspmodules
158} // namespace dunedaq
159
160#endif // SSPMODULES_SRC_ANLBOARD_DEVICEINTERFACE_HPP_
void SetRegisterByName(std::string name, unsigned int value)
void SetRegister(unsigned int address, unsigned int value, unsigned int mask=0xFFFFFFFF)
void ReadRegister(unsigned int address, unsigned int &value, unsigned int mask=0xFFFFFFFF)
void SetHardwareClockRateInMHz(unsigned int rate)
void ReadRegisterArray(unsigned int address, std::vector< unsigned int > &value, unsigned int size)
void ReadEventFromDevice(EventPacket &event)
void SetRegisterArrayByName(std::string name, unsigned int value)
void ReadRegisterArrayByName(std::string name, std::vector< unsigned int > &values)
void SetRegisterElementByName(std::string name, unsigned int index, unsigned int value)
void ReadRegisterByName(std::string name, unsigned int &value)
void ReadRegisterElementByName(std::string name, unsigned int index, unsigned int &value)
void ConfigureLEDCalib(const appmodel::SSPLEDCalibModule *conf)
void SetRegisterArray(unsigned int address, std::vector< unsigned int > value)
The DUNE-DAQ namespace.
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size
Invalid address