Skip to content

Commit

Permalink
move to detdataformats
Browse files Browse the repository at this point in the history
  • Loading branch information
roland-sipos committed Nov 3, 2021
1 parent bebf675 commit 90c4c46
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 98 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ daq_setup_environment()

find_package(appfwk REQUIRED)
find_package(logging REQUIRED)
find_package(dataformats REQUIRED)
find_package(detdataformats REQUIRED)
find_package(readout REQUIRED)

daq_codegen(sspcardreader.jsonnet TEMPLATES Structs.hpp.j2 Nljs.hpp.j2 )
daq_codegen( *info.jsonnet DEP_PKGS opmonlib TEMPLATES opmonlib/InfoStructs.hpp.j2 opmonlib/InfoNljs.hpp.j2 )

set(DUNEDAQ_DEPENDENCIES readout::readout dataformats::dataformats)
set(DUNEDAQ_DEPENDENCIES appfwk::appfwk readout::readout detdataformats::detdataformats)

# Provide override functionality for SSP dependencies
#option(WITH_FTD2XX_AS_PACKAGE "SSP external (ftd2xx) as a dunedaq package" OFF)
Expand All @@ -37,7 +37,7 @@ set(DUNEDAQ_DEPENDENCIES readout::readout dataformats::dataformats)
# Note that when the ers library is linked in, it uses a "::" because
# it's in an external package, not a local CMake target. The semantics
# are <namespace>::<shared library / executable>
daq_add_library(anlBoard/*.cxx SSPCardWrapper.cpp LINK_LIBRARIES appfwk::appfwk ${SSP_DEPENDENCIES} ${DUNEDAQ_DEPENDENCIES})
daq_add_library(anlBoard/*.cxx SSPCardWrapper.cpp LINK_LIBRARIES ${SSP_DEPENDENCIES} ${DUNEDAQ_DEPENDENCIES})
#daq_add_library(IntPrinter.cpp LINK_LIBRARIES ers::ers)

#if(WITH_FTD2XX_AS_PACKAGE)
Expand All @@ -51,7 +51,7 @@ daq_add_library(anlBoard/*.cxx SSPCardWrapper.cpp LINK_LIBRARIES appfwk::appfwk
#daq_add_python_bindings(ssp_wrapper.cpp LINK_LIBRARIES ${PROJECT_NAME})

##############################################################################
daq_add_plugin(SSPCardReader duneDAQModule LINK_LIBRARIES appfwk::appfwk sspmodules)
daq_add_plugin(SSPCardReader duneDAQModule LINK_LIBRARIES sspmodules)

##############################################################################
#daq_add_application( toylibrary_test_program toylibrary_test_program.cxx TEST LINK_LIBRARIES ${Boost_PROGRAM_OPTIONS_LIBRARY} toylibrary )
Expand Down
2 changes: 1 addition & 1 deletion cmake/sspmodulesConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include(CMakeFindDependencyMacro)

find_dependency(appfwk)
find_dependency(logging)
find_dependency(dataformats)
find_dependency(detdataformats)
find_dependency(readout)

if (EXISTS ${CMAKE_SOURCE_DIR}/@PROJECT_NAME@)
Expand Down
4 changes: 2 additions & 2 deletions src/SSPCardWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SSPCardWrapper::init(const data_t& args)
// configuration parameters that you're looking for in args aren't available since the args you're
// getting here is likely only *::Init data from the json file

m_device_interface = new dunedaq::sspmodules::DeviceInterface(dunedaq::dataformats::ssp::kEthernet);
m_device_interface = new dunedaq::sspmodules::DeviceInterface(dunedaq::detdataformats::ssp::kEthernet);
m_device_interface->Initialize(args);

TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "SSPCardWrapper::init complete.";
Expand Down Expand Up @@ -491,7 +491,7 @@ SSPCardWrapper::process_ssp()
<< ", calls to GetNext " << m_num_read_event_calls << ", of which returned null "
<< m_num_zero_fragments << std::endl;

// std::size_t dataLength = millislice.size()-dunedaq::dataformats::MillisliceHeader::sizeInUInts;
// std::size_t dataLength = millislice.size()-dunedaq::detdataformats::MillisliceHeader::sizeInUInts;

// SSPFragment::Metadata metadata;
// metadata.sliceHeader=*((SSPDAQ::MillisliceHeader*)(void*)millislice.data());
Expand Down
2 changes: 1 addition & 1 deletion src/SSPCardWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "sspmodules/sspcardreader/Nljs.hpp"

#include "dataformats/ssp/SSPTypes.hpp"
#include "detdataformats/ssp/SSPTypes.hpp"

#include "SSPIssues.hpp"
#include "anlBoard/DeviceInterface.hpp"
Expand Down
44 changes: 22 additions & 22 deletions src/anlBoard/DeviceInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum
};

// SSPDAQ::DeviceInterface::DeviceInterface(SSPDAQ::Comm_t commType, unsigned long deviceId)
dunedaq::sspmodules::DeviceInterface::DeviceInterface(dunedaq::dataformats::ssp::Comm_t commType)
dunedaq::sspmodules::DeviceInterface::DeviceInterface(dunedaq::detdataformats::ssp::Comm_t commType)
: fCommType(commType)
, fDeviceId(0)
, fState(dunedaq::sspmodules::DeviceInterface::kUninitialized)
Expand Down Expand Up @@ -67,9 +67,9 @@ dunedaq::sspmodules::DeviceInterface::OpenSlowControl()
dunedaq::sspmodules::Device* device = 0;

TLOG_DEBUG(TLVL_WORK_STEPS) << "Opening "
<< ((fCommType == dunedaq::dataformats::ssp::kUSB)
<< ((fCommType == dunedaq::detdataformats::ssp::kUSB)
? "USB"
: ((fCommType == dunedaq::dataformats::ssp::kEthernet) ? "Ethernet" : "Emulated"))
: ((fCommType == dunedaq::detdataformats::ssp::kEthernet) ? "Ethernet" : "Emulated"))
<< " device #" << fDeviceId << " for slow control only..." << std::endl;

device = devman.OpenDevice(fCommType, fDeviceId, true);
Expand Down Expand Up @@ -509,7 +509,7 @@ dunedaq::sspmodules::DeviceInterface::BuildFragment(const dunedaq::sspmodules::T

unsigned int dataSizeInWords = 0;

dataSizeInWords += dunedaq::dataformats::MillisliceHeader::sizeInUInts;
dataSizeInWords += dunedaq::detdataformats::MillisliceHeader::sizeInUInts;
for (auto ev = eventsToWrite.begin(); ev != eventsToWrite.end(); ++ev) {
dataSizeInWords += (*ev)->header.length;
}
Expand All @@ -518,7 +518,7 @@ dunedaq::sspmodules::DeviceInterface::BuildFragment(const dunedaq::sspmodules::T
// Build slice header//
//==================//

dunedaq::dataformats::MillisliceHeader sliceHeader;
dunedaq::detdataformats::MillisliceHeader sliceHeader;
sliceHeader.length = dataSizeInWords;
sliceHeader.nTriggers = eventsToWrite.size();
sliceHeader.startTime = theTrigger.startTime;
Expand All @@ -533,16 +533,16 @@ dunedaq::sspmodules::DeviceInterface::BuildFragment(const dunedaq::sspmodules::T
fragmentData.resize(dataSizeInWords);

static unsigned int headerSizeInWords =
sizeof(dunedaq::dataformats::EventHeader) / sizeof(unsigned int); // Size of DAQ event header
sizeof(dunedaq::detdataformats::EventHeader) / sizeof(unsigned int); // Size of DAQ event header

// Put millislice header at front of vector
auto sliceDataPtr = fragmentData.begin();
unsigned int* millisliceHeaderPtr = static_cast<unsigned int*>(static_cast<void*>(&sliceHeader));
std::copy(
millisliceHeaderPtr, millisliceHeaderPtr + dunedaq::dataformats::MillisliceHeader::sizeInUInts, sliceDataPtr);
millisliceHeaderPtr, millisliceHeaderPtr + dunedaq::detdataformats::MillisliceHeader::sizeInUInts, sliceDataPtr);

// Fill rest of vector with event data
sliceDataPtr += dunedaq::dataformats::MillisliceHeader::sizeInUInts;
sliceDataPtr += dunedaq::detdataformats::MillisliceHeader::sizeInUInts;

for (auto ev = eventsToWrite.begin(); ev != eventsToWrite.end(); ++ev) {
// DAQ event header
Expand Down Expand Up @@ -667,7 +667,7 @@ dunedaq::sspmodules::DeviceInterface::ReadEventFromDevice(EventPacket& event)
unsigned int* headerBlock = (unsigned int*)&event.header;
headerBlock[0] = 0xAAAAAAAA;

static const unsigned int headerReadSize = (sizeof(dunedaq::dataformats::EventHeader) / sizeof(unsigned int) - 1);
static const unsigned int headerReadSize = (sizeof(dunedaq::detdataformats::EventHeader) / sizeof(unsigned int) - 1);

// Wait for hardware queue to fill with full header data
unsigned int timeWaited = 0; // in us
Expand Down Expand Up @@ -705,7 +705,7 @@ dunedaq::sspmodules::DeviceInterface::ReadEventFromDevice(EventPacket& event)
std::copy(data.begin(), data.end(), &(headerBlock[1]));

// Wait for hardware queue to fill with full event data
unsigned int bodyReadSize = event.header.length - (sizeof(dunedaq::dataformats::EventHeader) / sizeof(unsigned int));
unsigned int bodyReadSize = event.header.length - (sizeof(dunedaq::detdataformats::EventHeader) / sizeof(unsigned int));
queueLengthInUInts = 0;
timeWaited = 0; // in us

Expand Down Expand Up @@ -740,7 +740,7 @@ dunedaq::sspmodules::DeviceInterface::ReadEventFromDevice(EventPacket& event)
// Copy event data into event packet
event.data = std::move(data);

auto ehsize = sizeof(struct dunedaq::dataformats::EventHeader);
auto ehsize = sizeof(struct dunedaq::detdataformats::EventHeader);
auto ehlength = event.header.length;
TLOG_DEBUG(TLVL_WORK_STEPS) << "Event data size: " << event.data.size() << " ehsize: " << ehsize
<< " ehl: " << ehlength;
Expand Down Expand Up @@ -887,17 +887,17 @@ dunedaq::sspmodules::DeviceInterface::Configure(const nlohmann::json& args)
}

auto m_cfg = args.get<dunedaq::sspmodules::sspcardreader::Conf>();
int interfaceTypeCode = m_cfg.interface_type; // dunedaq::dataformats::kEthernet;
int interfaceTypeCode = m_cfg.interface_type; // dunedaq::detdataformats::kEthernet;
std::stringstream ss;
switch (interfaceTypeCode) {
case 0:
fCommType = dunedaq::dataformats::ssp::kUSB;
fCommType = dunedaq::detdataformats::ssp::kUSB;
break;
case 1:
fCommType = dunedaq::dataformats::ssp::kEthernet;
fCommType = dunedaq::detdataformats::ssp::kEthernet;
break;
case 2:
fCommType = dunedaq::dataformats::ssp::kEmulated;
fCommType = dunedaq::detdataformats::ssp::kEmulated;
break;
case 999:
ss << "Error: Invalid interface type set (" << interfaceTypeCode << ")!" << std::endl;
Expand All @@ -909,7 +909,7 @@ dunedaq::sspmodules::DeviceInterface::Configure(const nlohmann::json& args)
throw ConfigurationError(ERS_HERE, ss.str());
}
//
if (fCommType != dunedaq::dataformats::ssp::kEthernet) {
if (fCommType != dunedaq::detdataformats::ssp::kEthernet) {
fDeviceId = 0;
std::stringstream ss;
ss << "Error: Non-functioning interface type set: " << fCommType
Expand All @@ -926,9 +926,9 @@ dunedaq::sspmodules::DeviceInterface::Configure(const nlohmann::json& args)
dunedaq::sspmodules::Device* device = 0;

TLOG_DEBUG(TLVL_WORK_STEPS) << "Configuring "
<< ((fCommType == dunedaq::dataformats::ssp::kUSB)
<< ((fCommType == dunedaq::detdataformats::ssp::kUSB)
? "USB"
: ((fCommType == dunedaq::dataformats::ssp::kEthernet) ? "Ethernet" : "Emulated"))
: ((fCommType == dunedaq::detdataformats::ssp::kEthernet) ? "Ethernet" : "Emulated"))
<< " device #" << fDeviceId << "..." << std::endl;

device = devman.OpenDevice(fCommType, fDeviceId);
Expand Down Expand Up @@ -1227,17 +1227,17 @@ dunedaq::sspmodules::DeviceInterface::GetIdentifier()

std::string ident;
ident += "SSP@";
if (fCommType == dunedaq::dataformats::ssp::kUSB) {
if (fCommType == dunedaq::detdataformats::ssp::kUSB) {
ident += "(USB";
ident += fDeviceId;
ident += "):";
} else if (fCommType == dunedaq::dataformats::ssp::kEthernet) {
} else if (fCommType == dunedaq::detdataformats::ssp::kEthernet) {
boost::asio::ip::address ip = boost::asio::ip::address_v4(fDeviceId);
std::string ipString = ip.to_string();
ident += "(";
ident += ipString;
ident += "):";
} else if (fCommType == dunedaq::dataformats::ssp::kEmulated) {
} else if (fCommType == dunedaq::detdataformats::ssp::kEmulated) {
ident += "(EMULATED";
ident += fDeviceId;
ident += "):";
Expand All @@ -1246,7 +1246,7 @@ dunedaq::sspmodules::DeviceInterface::GetIdentifier()
}

unsigned long // NOLINT(runtime/int)
dunedaq::sspmodules::DeviceInterface::GetTimestamp(const dunedaq::dataformats::EventHeader& header)
dunedaq::sspmodules::DeviceInterface::GetTimestamp(const dunedaq::detdataformats::EventHeader& header)
{
unsigned long packetTime = 0; // NOLINT(runtime/int)
TLOG_DEBUG(TLVL_WORK_STEPS) << "fUseExternalTimestamp value: " << std::boolalpha << fUseExternalTimestamp
Expand Down
8 changes: 4 additions & 4 deletions src/anlBoard/DeviceInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "appfwk/app/Nljs.hpp"
#include "readout/ReadoutTypes.hpp"
#include "dataformats/ssp/SSPTypes.hpp"
#include "detdataformats/ssp/SSPTypes.hpp"
#include "logging/Logging.hpp"

#include "DeviceManager.hpp"
Expand Down Expand Up @@ -48,7 +48,7 @@ class DeviceInterface{

//Just sets the fields needed to request the device.
//Real work is done in Initialize which is called manually.
explicit DeviceInterface(dunedaq::dataformats::ssp::Comm_t commType);
explicit DeviceInterface(dunedaq::detdataformats::ssp::Comm_t commType);

~DeviceInterface(){
//if(fRequestReceiver){
Expand Down Expand Up @@ -174,7 +174,7 @@ class DeviceInterface{
Device* fDevice;

//Whether we are using USB or Ethernet to connect to the device
dunedaq::dataformats::ssp::Comm_t fCommType;
dunedaq::detdataformats::ssp::Comm_t fCommType;

//Index of the device in the hardware-returned list
unsigned long fDeviceId; // NOLINT(runtime/int)
Expand All @@ -189,7 +189,7 @@ class DeviceInterface{

bool GetTriggerInfo(const EventPacket& event,dunedaq::sspmodules::TriggerInfo& newTrigger);

unsigned long GetTimestamp(const dunedaq::dataformats::EventHeader& header); // NOLINT(runtime/int)
unsigned long GetTimestamp(const dunedaq::detdataformats::EventHeader& header); // NOLINT(runtime/int)

//Build a millislice containing only a header and place in fQueue
// void BuildEmptyMillislice(unsigned long startTime,unsigned long endTime);
Expand Down
10 changes: 5 additions & 5 deletions src/anlBoard/DeviceManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef SSPMODULES_SRC_ANLBOARD_DEVICEMANAGER_CXX_
#define SSPMODULES_SRC_ANLBOARD_DEVICEMANAGER_CXX_

#include "dataformats/ssp/SSPTypes.hpp"
#include "detdataformats/ssp/SSPTypes.hpp"

#include "DeviceManager.hpp"
//#include "ftd2xx.h"
Expand Down Expand Up @@ -175,12 +175,12 @@ dunedaq::sspmodules::DeviceManager::RefreshDevices()
}

dunedaq::sspmodules::Device*
dunedaq::sspmodules::DeviceManager::OpenDevice(dunedaq::dataformats::ssp::Comm_t commType,
dunedaq::sspmodules::DeviceManager::OpenDevice(dunedaq::detdataformats::ssp::Comm_t commType,
unsigned int deviceNum,
bool slowControlOnly)
{
// Check for devices if this hasn't yet been done
if (!fHaveLookedForDevices && commType != dunedaq::dataformats::ssp::kEmulated) {
if (!fHaveLookedForDevices && commType != dunedaq::detdataformats::ssp::kEmulated) {
this->RefreshDevices();
}

Expand All @@ -200,7 +200,7 @@ dunedaq::sspmodules::DeviceManager::OpenDevice(dunedaq::dataformats::ssp::Comm_t
// }
// break;
//
case dunedaq::dataformats::ssp::kEthernet:
case dunedaq::detdataformats::ssp::kEthernet:
if (fEthernetDevices.find(deviceNum) == fEthernetDevices.end()) {
fEthernetDevices[deviceNum] = (std::move(
std::unique_ptr<dunedaq::sspmodules::EthernetDevice>(new dunedaq::sspmodules::EthernetDevice(deviceNum))));
Expand All @@ -214,7 +214,7 @@ dunedaq::sspmodules::DeviceManager::OpenDevice(dunedaq::dataformats::ssp::Comm_t
}
break;

case dunedaq::dataformats::ssp::kEmulated:
case dunedaq::detdataformats::ssp::kEmulated:
while (fEmulatedDevices.size() <= deviceNum) {
fEmulatedDevices.push_back(std::move(std::unique_ptr<dunedaq::sspmodules::EmulatedDevice>(
new dunedaq::sspmodules::EmulatedDevice(fEmulatedDevices.size()))));
Expand Down
4 changes: 2 additions & 2 deletions src/anlBoard/DeviceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef SSPMODULES_SRC_ANLBOARD_DEVICEMANAGER_HPP_
#define SSPMODULES_SRC_ANLBOARD_DEVICEMANAGER_HPP_

#include "dataformats/ssp/SSPTypes.hpp"
#include "detdataformats/ssp/SSPTypes.hpp"

//#include "ftd2xx.h"
//#include "USBDevice.h"
Expand Down Expand Up @@ -39,7 +39,7 @@ class DeviceManager{
//unsigned int GetNUSBDevices();

//Open a device and return a pointer containing a handle to it
Device* OpenDevice(dunedaq::dataformats::ssp::Comm_t commType,unsigned int deviceId,bool slowControlOnly=false);
Device* OpenDevice(dunedaq::detdataformats::ssp::Comm_t commType,unsigned int deviceId,bool slowControlOnly=false);

//Interrogate FTDI for list of devices. GetNUSBDevices and OpenDevice will call this
//if it has not yet been run, so it should not normally be necessary to call this directly.
Expand Down
6 changes: 3 additions & 3 deletions src/anlBoard/EmulatedDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef SSPMODULES_SRC_ANLBOARD_EMULATEDDEVICE_CXX_
#define SSPMODULES_SRC_ANLBOARD_EMULATEDDEVICE_CXX_

#include "dataformats/ssp/SSPTypes.hpp"
#include "detdataformats/ssp/SSPTypes.hpp"

#include "anlExceptions.hpp"
#include "EmulatedDevice.hpp"
Expand Down Expand Up @@ -151,7 +151,7 @@ void dunedaq::sspmodules::EmulatedDevice::Stop(){
void dunedaq::sspmodules::EmulatedDevice::EmulatorLoop(){

//dune::DAQLogger::LogDebug("SSP_EmulatedDevice")<<"Starting emulator loop..."<<std::endl;
static unsigned int headerSizeInWords=sizeof(dunedaq::dataformats::EventHeader)/sizeof(unsigned int);
static unsigned int headerSizeInWords=sizeof(dunedaq::detdataformats::EventHeader)/sizeof(unsigned int);

//We want to generate events on random channels at random times
std::default_random_engine generator;
Expand All @@ -171,7 +171,7 @@ void dunedaq::sspmodules::EmulatedDevice::EmulatorLoop(){
int channel = channelDistribution(generator);

//Build an event header.
dunedaq::dataformats::EventHeader header;
dunedaq::detdataformats::EventHeader header;

//Standard header word
header.header=0xAAAAAAAA;
Expand Down
2 changes: 1 addition & 1 deletion src/anlBoard/EmulatedDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef SSPMODULES_SRC_ANLBOARD_EMULATEDDEVICE_HPP_
#define SSPMODULES_SRC_ANLBOARD_EMULATEDDEVICE_HPP_

#include "dataformats/ssp/SSPTypes.hpp"
#include "detdataformats/ssp/SSPTypes.hpp"

#include "Device.hpp"
#include "SafeQueue.hpp"
Expand Down
Loading

0 comments on commit 90c4c46

Please sign in to comment.