ChimeraTK-DeviceAccess  03.18.00
helperFunctions.cc
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #include "helperFunctions.h"
5 
6 #include <sstream>
7 
8 void populateDummyDeviceInfo(ChimeraTK::DeviceInfoMap::DeviceInfo& deviceInfo, std::string dmapFileName,
9  std::string deviceName, std::string deviceFile, std::string mapFileName) {
10  static int lineNumber = 1;
11  if(deviceName == "card") deviceName = appendNumberToName(deviceName, lineNumber);
12  if(deviceFile == "/dev/dummy_device_identifier") deviceFile = appendNumberToName(deviceName, lineNumber);
13  if(mapFileName == "/dev/dummy_map_file") mapFileName = appendNumberToName(deviceName, lineNumber);
14 
15  deviceInfo.deviceName = deviceName;
16  deviceInfo.uri = deviceFile;
17  deviceInfo.mapFileName = mapFileName;
18  deviceInfo.dmapFileName = dmapFileName;
19  deviceInfo.dmapFileLineNumber = ++lineNumber;
20 }
21 
22 std::string appendNumberToName(std::string name, int suffixNumber) {
23  std::stringstream deviceName;
24  deviceName << name << suffixNumber;
25  return (deviceName.str());
26 }
27 
29  const ChimeraTK::DeviceInfoMap::DeviceInfo& deviceInfo1, const ChimeraTK::DeviceInfoMap::DeviceInfo& deviceInfo2) {
30  bool result = (deviceInfo1.deviceName == deviceInfo2.deviceName) && (deviceInfo1.uri == deviceInfo2.uri) &&
31  (deviceInfo1.mapFileName == deviceInfo2.mapFileName) && (deviceInfo1.dmapFileName == deviceInfo2.dmapFileName) &&
32  (deviceInfo1.dmapFileLineNumber == deviceInfo2.dmapFileLineNumber);
33  return result;
34 }
helperFunctions.h
ChimeraTK::DeviceInfoMap::DeviceInfo::deviceName
std::string deviceName
logical name of the device
Definition: DeviceInfoMap.h:32
ChimeraTK::DeviceInfoMap::DeviceInfo::mapFileName
std::string mapFileName
name of the MAP file storing information about PCIe registers mapping
Definition: DeviceInfoMap.h:35
populateDummyDeviceInfo
void populateDummyDeviceInfo(ChimeraTK::DeviceInfoMap::DeviceInfo &deviceInfo, std::string dmapFileName, std::string deviceName, std::string deviceFile, std::string mapFileName)
Definition: helperFunctions.cc:8
ChimeraTK::DeviceInfoMap::DeviceInfo::dmapFileName
std::string dmapFileName
name of the DMAP file
Definition: DeviceInfoMap.h:37
ChimeraTK::DeviceInfoMap::DeviceInfo::dmapFileLineNumber
uint32_t dmapFileLineNumber
line number in DMAP file storing listed above information
Definition: DeviceInfoMap.h:38
ChimeraTK::DeviceInfoMap::DeviceInfo
Stores information about one device.
Definition: DeviceInfoMap.h:30
appendNumberToName
std::string appendNumberToName(std::string name, int suffixNumber)
Definition: helperFunctions.cc:22
ChimeraTK::DeviceInfoMap::DeviceInfo::uri
std::string uri
uri which describes the device (or name of the device file in /dev in backward compatibility mode)
Definition: DeviceInfoMap.h:33
compareDeviceInfos
bool compareDeviceInfos(const ChimeraTK::DeviceInfoMap::DeviceInfo &deviceInfo1, const ChimeraTK::DeviceInfoMap::DeviceInfo &deviceInfo2)
Definition: helperFunctions.cc:28