DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::sspmodules::DeviceManager Class Reference

#include <DeviceManager.hpp>

Public Member Functions

Device * OpenDevice (unsigned int deviceId, bool slowControlOnly=false)
void RefreshDevices ()

Static Public Member Functions

static DeviceManager & Get ()

Private Member Functions

 DeviceManager ()
 DeviceManager (DeviceManager const &)
void operator= (DeviceManager const &)

Private Attributes

std::map< unsigned long, std::unique_ptr< EthernetDevice > > fEthernetDevices
bool fHaveLookedForDevices

Detailed Description

Definition at line 29 of file DeviceManager.hpp.

Constructor & Destructor Documentation

◆ DeviceManager() [1/2]

dunedaq::sspmodules::DeviceManager::DeviceManager ( )
private

Definition at line 35 of file DeviceManager.cxx.

35{}

◆ DeviceManager() [2/2]

dunedaq::sspmodules::DeviceManager::DeviceManager ( DeviceManager const & )
private

Member Function Documentation

◆ Get()

dunedaq::sspmodules::DeviceManager & dunedaq::sspmodules::DeviceManager::Get ( )
static

Definition at line 29 of file DeviceManager.cxx.

30{
31 static dunedaq::sspmodules::DeviceManager instance;
32 return instance;
33}

◆ OpenDevice()

dunedaq::sspmodules::Device * dunedaq::sspmodules::DeviceManager::OpenDevice ( unsigned int deviceId,
bool slowControlOnly = false )

Definition at line 161 of file DeviceManager.cxx.

162{
163
164 Device* device = 0;
165 if (fEthernetDevices.find(deviceNum) == fEthernetDevices.end()) {
166 fEthernetDevices[deviceNum] = (std::move(
167 std::unique_ptr<dunedaq::sspmodules::EthernetDevice>(new dunedaq::sspmodules::EthernetDevice(deviceNum))));
168 }
169 if (fEthernetDevices[deviceNum]->IsOpen()) {
170 // dune::DAQLogger::LogError("SSP_DeviceManager")<<"Attempt to open already open device!"<<std::endl;
171 throw(EDeviceAlreadyOpen());
172 } else {
173 device = fEthernetDevices[deviceNum].get();
174 device->Open(slowControlOnly);
175 }
176 return device;
177}
std::map< unsigned long, std::unique_ptr< EthernetDevice > > fEthernetDevices

◆ operator=()

void dunedaq::sspmodules::DeviceManager::operator= ( DeviceManager const & )
private

◆ RefreshDevices()

void dunedaq::sspmodules::DeviceManager::RefreshDevices ( )

Definition at line 47 of file DeviceManager.cxx.

48{
49 for (auto device = fEthernetDevices.begin(); device != fEthernetDevices.end(); ++device) {
50 if ((device->second)->IsOpen()) {
51 // dune::DAQLogger::LogWarning("SSP_DeviceManager")<<"Device manager refused request to refresh device list"
52 //<<"due to ethernet devices still open"<<std::endl;
53 }
54 }
55
56 // Clear Device List
57 // fUSBDevices.clear();
58 fEthernetDevices.clear();
59
60 //
61 // //===========================//
62 // //==Find USB devices=========//
63 // //===========================//
64 //
65 // unsigned int ftNumDevs;
66 //
67 // std::map<std::string,FT_DEVICE_LIST_INFO_NODE*> dataChannels;
68 // std::map<std::string,FT_DEVICE_LIST_INFO_NODE*> commChannels;
69 //
70 // // This code uses FTDI's D2XX driver to determine the available devices
71 // if(FT_CreateDeviceInfoList(&ftNumDevs)!=FT_OK){
72 // try {
73 // //dune::DAQLogger::LogError("SSP_DeviceManager")<<"Failed to create FTDI device info list"<<std::endl;
74 // } catch (...) {}
75 // throw(EFTDIError("Error in FT_CreateDeviceInfoList"));
76 // }
77 //
78 // FT_DEVICE_LIST_INFO_NODE* deviceInfoNodes=new FT_DEVICE_LIST_INFO_NODE[ftNumDevs];
79 //
80 // if(FT_GetDeviceInfoList(deviceInfoNodes,&ftNumDevs)!=FT_OK){
81 // delete deviceInfoNodes;
82 // try {
83 // //dune::DAQLogger::LogError("SSP_DeviceManager")<<"Failed to get FTDI device info list"<<std::endl;
84 // } catch (...) {}
85 // throw(EFTDIError("Error in FT_GetDeviceInfoList"));
86 // }
87 //
88 // //Search through all devices for compatible interfaces
89 // for (unsigned int i = 0; i < ftNumDevs; i++) {
90 // // NOTE 1: Each device is actually 2 FTDI devices. Device with "A" at the end of serial number is the
91 // // data channel. "B" is the comms channel. Need to associate FTDI devices with the same base
92 // // number together to get a "whole" board.
93 // //
94 // // NOTE 2: There is a rare error in which the FTDI driver returns FT_OK but the device info is incorrect
95 // // In this case, the check on ftType and/or length of ftSerial will fail
96 // // The discover code will therefore fail to find any useable devices but will not return an error
97 // // The calling code should check numDevices and rerun FindDevices if it equals zero
98 //
99 // // Search only for devices we can use (skip any others)
100 // if (deviceInfoNodes[i].Type != FT_DEVICE_2232H) {
101 // continue; // Skip to next device
102 // }
103 //
104 // // Add FTDI device to Device List using Serial number
105 // //If length is zero, then device is probably open in another process (though maybe we don't get type then
106 // either...)
107 // //===TODO: Should check flags for open devices and report the number open in other processes to cout
108 // unsigned int length = strlen(deviceInfoNodes[i].SerialNumber); // Find length of serial number
109 // (including 'A' or 'B') if (length == 0) {
110 // continue; // Skip to next device
111 // }
112 //
113 // char serial[16];
114 //
115 // strncpy(serial, deviceInfoNodes[i].SerialNumber, length - 1); // Copy base serial number
116 // serial[length-1] = 0; // Append NULL because strncpy() didn't!
117 //
118 // // Update device list with FTDI device number
119 // switch (deviceInfoNodes[i].SerialNumber[length -1]) {
120 // case 'A':
121 // dataChannels[serial]=&(deviceInfoNodes[i]);
122 // break;
123 // case 'B':
124 // commChannels[serial]=&(deviceInfoNodes[i]);
125 // break;
126 // default:
127 // break;
128 // }
129 // }
130 //
131 // //Check that device list is as expected, then construct USB device objects for each board
132 // if(dataChannels.size()!=commChannels.size()){
133 // try {
134 // //dune::DAQLogger::LogError("SSP_DeviceManager")<<"Different number of data and comm channels on
135 // FTDI!"<<std::endl;
136 // } catch (...) {}
137 // delete deviceInfoNodes;
138 // throw(EBadDeviceList());
139 // }
140 // std::map<std::string,FT_DEVICE_LIST_INFO_NODE*>::iterator dIter=dataChannels.begin();
141 // std::map<std::string,FT_DEVICE_LIST_INFO_NODE*>::iterator cIter=commChannels.begin();
142 //
143 // for(;dIter!=dataChannels.end();++dIter,++cIter){
144 // if(dIter->first!=cIter->first){
145 // try {
146 // //dune::DAQLogger::LogError("SSP_DeviceManager")<<"Non-matching serial numbers for data and comm channels on
147 // FTDI!"<<std::endl;
148 // } catch (...) {}
149 // delete deviceInfoNodes;
150 // throw(EBadDeviceList());
151 // }
152 // fUSBDevices.push_back(USBDevice(dIter->second,cIter->second));
153 // //dune::DAQLogger::LogInfo("SSP_DeviceManager")<<"Found a device with serial "<<dIter->first<<std::endl;
154 // }
155 //
156 // delete[] deviceInfoNodes;
157 //
158}

Member Data Documentation

◆ fEthernetDevices

std::map<unsigned long, std::unique_ptr<EthernetDevice> > dunedaq::sspmodules::DeviceManager::fEthernetDevices
private

Definition at line 56 of file DeviceManager.hpp.

◆ fHaveLookedForDevices

bool dunedaq::sspmodules::DeviceManager::fHaveLookedForDevices
private

Definition at line 58 of file DeviceManager.hpp.


The documentation for this class was generated from the following files: