DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
sspmodules
src
anlBoard
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
11
#include "
appmodel/SSPLEDCalibModule.hpp
"
12
#include "
appmodel/SSPRegister.hpp
"
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
26
namespace
dunedaq
{
27
namespace
sspmodules
{
28
29
struct
TriggerInfo
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
37
class
DeviceInterface
38
{
39
40
public
:
41
enum
State_t
42
{
43
kUninitialized
,
44
kInitialized
,
45
kRunning
,
46
kStopping
,
47
kStopped
,
48
kBad
49
};
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
55
~DeviceInterface
() {}
56
57
void
OpenSlowControl
();
58
59
void
ConfigureLEDCalib
(
const
appmodel::SSPLEDCalibModule
* conf);
60
61
// Called by ReadEvents
62
// Get an event off the hardware buffer.
63
// Timeout after some wait period
64
void
ReadEventFromDevice
(
EventPacket
& event);
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
116
void
SetUseExternalTimestamp
(
bool
val) {
fUseExternalTimestamp
= val; }
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
128
private
:
129
// Internal device object used for hardware operations.
130
// Owned by the device manager, not this object.
131
Device
*
fDevice
;
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.
138
State_t
fState
;
139
140
void
set_exception
(
bool
exception
) {
exception_
.store(
exception
); }
141
142
bool
fUseExternalTimestamp
;
143
144
unsigned
int
fHardwareClockRateInMHz
;
145
146
int
fDummyPeriod
;
147
148
bool
fSlowControlOnly
;
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_
DeviceManager.hpp
Device.hpp
EventPacket.hpp
dunedaq::appmodel::SSPLEDCalibModule
Definition
SSPLEDCalibModule.hpp:36
dunedaq::sspmodules::DeviceInterface::fTimingAddress
unsigned int fTimingAddress
Definition
DeviceInterface.hpp:152
dunedaq::sspmodules::DeviceInterface::fUseExternalTimestamp
bool fUseExternalTimestamp
Definition
DeviceInterface.hpp:142
dunedaq::sspmodules::DeviceInterface::fState
State_t fState
Definition
DeviceInterface.hpp:138
dunedaq::sspmodules::DeviceInterface::SetRegisterByName
void SetRegisterByName(std::string name, unsigned int value)
Definition
DeviceInterface.cxx:199
dunedaq::sspmodules::DeviceInterface::exception_
std::atomic< bool > exception_
Definition
DeviceInterface.hpp:154
dunedaq::sspmodules::DeviceInterface::SetRegister
void SetRegister(unsigned int address, unsigned int value, unsigned int mask=0xFFFFFFFF)
Definition
DeviceInterface.cxx:147
dunedaq::sspmodules::DeviceInterface::ReadRegister
void ReadRegister(unsigned int address, unsigned int &value, unsigned int mask=0xFFFFFFFF)
Definition
DeviceInterface.cxx:172
dunedaq::sspmodules::DeviceInterface::~DeviceInterface
~DeviceInterface()
Definition
DeviceInterface.hpp:55
dunedaq::sspmodules::DeviceInterface::PrintHardwareState
void PrintHardwareState()
Definition
DeviceInterface.cxx:400
dunedaq::sspmodules::DeviceInterface::SetHardwareClockRateInMHz
void SetHardwareClockRateInMHz(unsigned int rate)
Definition
DeviceInterface.hpp:112
dunedaq::sspmodules::DeviceInterface::fPartitionNumber
unsigned int fPartitionNumber
Definition
DeviceInterface.hpp:150
dunedaq::sspmodules::DeviceInterface::ReadRegisterArray
void ReadRegisterArray(unsigned int address, std::vector< unsigned int > &value, unsigned int size)
Definition
DeviceInterface.cxx:183
dunedaq::sspmodules::DeviceInterface::State_t
State_t
Definition
DeviceInterface.hpp:42
dunedaq::sspmodules::DeviceInterface::kRunning
@ kRunning
Definition
DeviceInterface.hpp:45
dunedaq::sspmodules::DeviceInterface::kStopping
@ kStopping
Definition
DeviceInterface.hpp:46
dunedaq::sspmodules::DeviceInterface::kBad
@ kBad
Definition
DeviceInterface.hpp:48
dunedaq::sspmodules::DeviceInterface::kInitialized
@ kInitialized
Definition
DeviceInterface.hpp:44
dunedaq::sspmodules::DeviceInterface::kUninitialized
@ kUninitialized
Definition
DeviceInterface.hpp:43
dunedaq::sspmodules::DeviceInterface::kStopped
@ kStopped
Definition
DeviceInterface.hpp:47
dunedaq::sspmodules::DeviceInterface::ReadEventFromDevice
void ReadEventFromDevice(EventPacket &event)
dunedaq::sspmodules::DeviceInterface::fHardwareClockRateInMHz
unsigned int fHardwareClockRateInMHz
Definition
DeviceInterface.hpp:144
dunedaq::sspmodules::DeviceInterface::SetRegisterArrayByName
void SetRegisterArrayByName(std::string name, unsigned int value)
Definition
DeviceInterface.cxx:215
dunedaq::sspmodules::DeviceInterface::exception
bool exception() const
Definition
DeviceInterface.hpp:126
dunedaq::sspmodules::DeviceInterface::SetTimingAddress
void SetTimingAddress(unsigned int val)
Definition
DeviceInterface.hpp:120
dunedaq::sspmodules::DeviceInterface::SetUseExternalTimestamp
void SetUseExternalTimestamp(bool val)
Definition
DeviceInterface.hpp:116
dunedaq::sspmodules::DeviceInterface::GetIdentifier
std::string GetIdentifier()
Definition
DeviceInterface.cxx:389
dunedaq::sspmodules::DeviceInterface::fDevice
Device * fDevice
Definition
DeviceInterface.hpp:131
dunedaq::sspmodules::DeviceInterface::OpenSlowControl
void OpenSlowControl()
Definition
DeviceInterface.cxx:50
dunedaq::sspmodules::DeviceInterface::fSlowControlOnly
bool fSlowControlOnly
Definition
DeviceInterface.hpp:148
dunedaq::sspmodules::DeviceInterface::ReadRegisterArrayByName
void ReadRegisterArrayByName(std::string name, std::vector< unsigned int > &values)
Definition
DeviceInterface.cxx:254
dunedaq::sspmodules::DeviceInterface::fDeviceId
unsigned long fDeviceId
Definition
DeviceInterface.hpp:134
dunedaq::sspmodules::DeviceInterface::set_exception
void set_exception(bool exception)
Definition
DeviceInterface.hpp:140
dunedaq::sspmodules::DeviceInterface::fDummyPeriod
int fDummyPeriod
Definition
DeviceInterface.hpp:146
dunedaq::sspmodules::DeviceInterface::SetPartitionNumber
void SetPartitionNumber(unsigned int val)
Definition
DeviceInterface.hpp:118
dunedaq::sspmodules::DeviceInterface::DeviceInterface
DeviceInterface()
Definition
DeviceInterface.cxx:36
dunedaq::sspmodules::DeviceInterface::SetDummyPeriod
void SetDummyPeriod(int period)
Definition
DeviceInterface.hpp:114
dunedaq::sspmodules::DeviceInterface::SetRegisterElementByName
void SetRegisterElementByName(std::string name, unsigned int index, unsigned int value)
Definition
DeviceInterface.cxx:207
dunedaq::sspmodules::DeviceInterface::ReadRegisterByName
void ReadRegisterByName(std::string name, unsigned int &value)
Definition
DeviceInterface.cxx:236
dunedaq::sspmodules::DeviceInterface::ReadRegisterElementByName
void ReadRegisterElementByName(std::string name, unsigned int index, unsigned int &value)
Definition
DeviceInterface.cxx:244
dunedaq::sspmodules::DeviceInterface::ConfigureLEDCalib
void ConfigureLEDCalib(const appmodel::SSPLEDCalibModule *conf)
Definition
DeviceInterface.cxx:261
dunedaq::sspmodules::DeviceInterface::SetRegisterArray
void SetRegisterArray(unsigned int address, std::vector< unsigned int > value)
Definition
DeviceInterface.cxx:158
dunedaq::sspmodules::Device
Definition
Device.hpp:28
dunedaq::sspmodules::EventPacket
Definition
EventPacket.hpp:23
SSPLEDCalibModule.hpp
SSPRegister.hpp
Logging.hpp
dunedaq::sspmodules
Definition
anlExceptions.hpp:15
dunedaq
The DUNE-DAQ namespace.
Definition
cib_utilities.cpp:5
dunedaq::size
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size
Definition
FelixIssues.hpp:30
dunedaq::address
Invalid address
Definition
CommonIssues.hpp:26
dunedaq::sspmodules::TriggerInfo
Definition
DeviceInterface.hpp:30
dunedaq::sspmodules::TriggerInfo::startTime
unsigned long startTime
Definition
DeviceInterface.hpp:31
dunedaq::sspmodules::TriggerInfo::endTime
unsigned long endTime
Definition
DeviceInterface.hpp:32
dunedaq::sspmodules::TriggerInfo::triggerTime
unsigned long triggerTime
Definition
DeviceInterface.hpp:33
dunedaq::sspmodules::TriggerInfo::triggerType
unsigned short triggerType
Definition
DeviceInterface.hpp:34
Generated on
for DUNE-DAQ by
1.18.0