LCOV - code coverage report
Current view: top level - sspmodules/src/anlBoard - DeviceInterface.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 2 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /**
       2              :  * @file DeviceInterface.hpp
       3              :  *
       4              :  * This is part of the DUNE DAQ , copyright 2020.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  */
       8              : #ifndef SSPMODULES_SRC_ANLBOARD_DEVICEINTERFACE_HPP_
       9              : #define SSPMODULES_SRC_ANLBOARD_DEVICEINTERFACE_HPP_
      10              : 
      11              : #include "logging/Logging.hpp"
      12              : #include "appmodel/SSPLEDCalibModule.hpp"
      13              : #include "appmodel/SSPRegister.hpp"
      14              : 
      15              : #include "DeviceManager.hpp"
      16              : #include "Device.hpp"
      17              : #include "EventPacket.hpp"
      18              : 
      19              : #include <string>
      20              : #include <memory>
      21              : #include <map>
      22              : #include <deque>
      23              : #include <queue>
      24              : #include <vector>
      25              : 
      26              : namespace dunedaq {
      27              : namespace sspmodules {
      28              : 
      29              : struct TriggerInfo{
      30              :   unsigned long startTime;    // NOLINT(runtime/int)
      31              :   unsigned long endTime;      // NOLINT(runtime/int)
      32              :   unsigned long triggerTime;  // NOLINT(runtime/int)
      33              :   unsigned short triggerType; // NOLINT(runtime/int)
      34              : };
      35              : 
      36              : class DeviceInterface{
      37              : 
      38              : public:
      39              : 
      40              :   enum State_t{kUninitialized,kInitialized,kRunning,kStopping,kStopped,kBad};
      41              : 
      42              :   //Just sets the fields needed to request the device.
      43              :   //Real work is done in Initialize which is called manually.
      44              :   explicit DeviceInterface();
      45              : 
      46              :   ~DeviceInterface(){ }
      47              : 
      48              :   void OpenSlowControl();
      49              : 
      50              :   void ConfigureLEDCalib(const appmodel::SSPLEDCalibModule* conf);
      51              : 
      52              : 
      53              :   //Called by ReadEvents
      54              :   //Get an event off the hardware buffer.
      55              :   //Timeout after some wait period
      56              :   void ReadEventFromDevice(EventPacket& event);
      57              : 
      58              :   //Obtain current state of device
      59              :   //inline State_t State(){return fState;}
      60              : 
      61              :   //Setter for single register
      62              :   //If mask is given then only bits which are high in the mask will be set.
      63              :   void SetRegister(unsigned int address, unsigned int value, unsigned int mask=0xFFFFFFFF);
      64              : 
      65              :   //Setter for series of contiguous registers, with vector input
      66              :   void SetRegisterArray(unsigned int address, std::vector<unsigned int> value);
      67              : 
      68              :   //Setter for series of contiguous registers, with C array input
      69              :   void SetRegisterArray(unsigned int address, unsigned int* value, unsigned int size);
      70              : 
      71              :   //Getter for single register
      72              :   //If mask is set then bits which are low in the mask will be returned as zeros.
      73              :   void ReadRegister(unsigned int address, unsigned int& value, unsigned int mask=0xFFFFFFFF);
      74              : 
      75              :   //Getter for series of contiguous registers, with vector output
      76              :   void ReadRegisterArray(unsigned int address, std::vector<unsigned int>& value, unsigned int size);
      77              : 
      78              :   //Getter for series of contiguous registers, with C array output
      79              :   void ReadRegisterArray(unsigned int address, unsigned int* value, unsigned int size);
      80              : 
      81              :   //Methods to set registers with names (as defined in SSPDAQ::RegMap)
      82              : 
      83              :   //Set single named register
      84              :   void SetRegisterByName(std::string name, unsigned int value);
      85              : 
      86              :   //Set single element of an array of registers
      87              :   void SetRegisterElementByName(std::string name, unsigned int index, unsigned int value);
      88              : 
      89              :   //Set all elements of an array to a single value
      90              :   void SetRegisterArrayByName(std::string name, unsigned int value);
      91              : 
      92              :   //Set all elements of an array using values vector
      93              :   void SetRegisterArrayByName(std::string name, std::vector<unsigned int> values);
      94              : 
      95              :   //Read single named register
      96              :   void ReadRegisterByName(std::string name, unsigned int& value);
      97              : 
      98              :   //Read single element of an array of registers
      99              :   void ReadRegisterElementByName(std::string name, unsigned int index, unsigned int& value);
     100              : 
     101              :   //Read all elements of an array into values vector
     102              :   void ReadRegisterArrayByName(std::string name, std::vector<unsigned int>& values);
     103              : 
     104              :   void SetHardwareClockRateInMHz(unsigned int rate){fHardwareClockRateInMHz = rate;}
     105              : 
     106              :   void SetDummyPeriod(int period){fDummyPeriod=period;}
     107              : 
     108              :   void SetUseExternalTimestamp(bool val){fUseExternalTimestamp = val;}
     109              : 
     110            0 :   void SetPartitionNumber(unsigned int val){fPartitionNumber=val;}
     111              : 
     112            0 :   void SetTimingAddress(unsigned int val){fTimingAddress=val;}
     113              : 
     114              :   void PrintHardwareState();
     115              : 
     116              :   std::string GetIdentifier();
     117              : 
     118              :   bool exception() const { return exception_.load(); }
     119              : 
     120              : private:
     121              : 
     122              :   //Internal device object used for hardware operations.
     123              :   //Owned by the device manager, not this object.
     124              :   Device* fDevice;
     125              : 
     126              :   //Index of the device in the hardware-returned list
     127              :   unsigned long fDeviceId;    // NOLINT(runtime/int)
     128              : 
     129              :   //Holds current device state. Hopefully this matches the state of the
     130              :   //hardware itself.
     131              :   State_t fState;
     132              : 
     133              :   void set_exception( bool exception ) { exception_.store( exception ); }
     134              : 
     135              :   bool fUseExternalTimestamp;
     136              : 
     137              :   unsigned int fHardwareClockRateInMHz;
     138              : 
     139              :   int fDummyPeriod;
     140              : 
     141              :   bool fSlowControlOnly;
     142              : 
     143              :   unsigned int fPartitionNumber;
     144              : 
     145              :   unsigned int fTimingAddress;
     146              : 
     147              : 
     148              :   std::atomic<bool> exception_;
     149              : 
     150              : };
     151              : 
     152              : } // namespace sspmodules
     153              : } // namespace dunedaq
     154              : 
     155              : #endif // SSPMODULES_SRC_ANLBOARD_DEVICEINTERFACE_HPP_
        

Generated by: LCOV version 2.0-1