Buffer Interface
Classes | Public Member Functions | List of all members
CXPReg::Device Class Reference

Interface to access and modify registers on a CoaXPress camera. More...

#include <CXPReg.hpp>

Classes

struct  PrivateData
 

Public Member Functions

 Device (BFVOID)
 
 ~Device (BFVOID)
 
BFVOID open (const BFU32 boardNumber)
 
BFVOID openSWConnector (const BFU32 Switch, const BFU32 Connector)
 
BFVOID close (BFVOID)
 
BFBOOL isOpen (BFVOID) const
 
BFBOOL isCxp (BFVOID) const
 
BFU32 getBoardNumber (BFVOID) const
 
BFVOID getBoardSWConnector (BFU32 &Switch, BFU32 &Connector) const
 
BFU32 readReg (const BFU32 address) const
 
BFU32 readReg (const BFU32 link, const BFU32 address) const
 
BFVOID writeReg (const BFU32 address, const BFU32 value)
 
BFVOID writeReg (const BFU32 link, const BFU32 address, const BFU32 value)
 
BFSIZET readData (const BFU32 address, const BFU32 bytesToRead, std::vector< BFU8 > &dataOut) const
 
BFSIZET readData (const BFU32 address, const BFU32 bytesToRead, BFU8 *const dataOut, const BFSIZET dataOutSize) const
 
BFSIZET readData (const BFU32 link, const BFU32 address, const BFU32 bytesToRead, std::vector< BFU8 > &dataOut) const
 
BFSIZET readData (const BFU32 link, const BFU32 address, const BFU32 bytesToRead, BFU8 *const dataOut, const BFSIZET dataOutSize) const
 
BFVOID writeData (const BFU32 address, std::vector< BFU8 > const &dataIn)
 
BFVOID writeData (const BFU32 address, const BFU8 *const dataIn, const BFSIZET dataInSize)
 
BFVOID writeData (const BFU32 link, const BFU32 address, std::vector< BFU8 > const &dataIn)
 
BFVOID writeData (const BFU32 link, const BFU32 address, const BFU8 *const dataIn, const BFSIZET dataInSize)
 

Detailed Description

Interface to access and modify registers on a CoaXPress camera.

The CXPReg::Device class provides an independent interface to CoaXPres registers, as exposed by BitFlow frame grabbers. This may be used simultaneously with the BufferAcquisition classes, or completely independently. BufferAcquisition::BufferInterface implements its own CXP register methods.

Constructor & Destructor Documentation

Device::Device ( BFVOID  )

Initializes a new CXPReg::Device instance.

29  : m_pd (*new PrivateData)
30 { }
Device::~Device ( BFVOID  )

Cleanup the CXPReg::Device and its resources.

References close().

36 {
37  close();
38  delete &m_pd;
39 }
BFVOID close(BFVOID)
Definition: CXPReg.cpp:92

Member Function Documentation

BFVOID Device::close ( BFVOID  )

Close the currently open board, if any.

References isOpen().

Referenced by open(), openSWConnector(), and ~Device().

93 {
94  if (isOpen())
95  BiBrdClose(m_pd.hBoard);
96 
97  m_pd.hBoard = nullptr;
98 
99  m_pd.boardNumber = ~BFU32(0);
100  m_pd.boardSwitch = ~BFU32(0);
101  m_pd.boardConnector = ~BFU32(0);
102 }
BFBOOL isOpen(BFVOID) const
Definition: CXPReg.cpp:109
unsigned long BFU32
Definition: BFTypeNT.h:55
BFU32 Device::getBoardNumber ( BFVOID  ) const

Return the opened board number. Returns ~BFU32(0), if the board isn't open, or wasn't opened with a board number (see getBoardSWConnector).

Returns
The system wide BitFlow board index with which the board was opened, if the board was opened by index. ~BFU32(0), if no board is opened, or if the board was opeend by switch and connector.
134 {
135  return m_pd.boardNumber;
136 }
BFVOID Device::getBoardSWConnector ( BFU32 Switch,
BFU32 Connector 
) const

Retrieve the opened board switch and connector. Retrieves ~BFU32(0), if the board isn't open, or wasn't opened with openSWConnector (see getBoardNumber).

Parameters
[out]Switch- Output value of the switch setting used to open the board, if the board has been opened by switch and connector.
[out]Connector- Output value of the connector index used to open the board, if the board has been opened by switch and connector.
149 {
150  Switch = m_pd.boardSwitch;
151  Connector = m_pd.boardConnector;
152 }
BFBOOL Device::isCxp ( BFVOID  ) const

Returns whether or not the open board is a CXP board or not. If not, than the CXP register functions will fail.

Returns
True if a CoaXPress board is open, false otherwise.

References isOpen().

121 {
122  return isOpen() && BFIsCXP(m_pd.hBoard);
123 }
BFBOOL isOpen(BFVOID) const
Definition: CXPReg.cpp:109
BFBOOL Device::isOpen ( BFVOID  ) const

Returns if a board is open or not.

Returns
The open status of this CXPReg::Device.

Referenced by close(), and isCxp().

110 {
111  return !!m_pd.hBoard;
112 }
BFVOID Device::open ( const BFU32  boardNumber)

Open a board with the given index.

Parameters
[in]boardNumber- The system wide BitFlow board index of the board to open. This includes non-CXP devices.
Exceptions
BiExceptionthrown if the board cannot be opened.

References BiTypeAny, BrdOpenOptions, BiException::check(), and close().

50 {
51  close();
52 
53  Bd hBoard;
54  BiException::check(0, BiBrdOpenEx(BiTypeAny, boardNumber, &hBoard, BrdOpenOptions) );
55 
56  m_pd.hBoard = hBoard;
57  m_pd.boardNumber = boardNumber;
58 }
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:306
#define BiTypeAny
Definition: BiDef.h:33
void *** Bd
Definition: BFType.h:88
BFVOID close(BFVOID)
Definition: CXPReg.cpp:92
Definition: CXPReg.cpp:5
BFVOID Device::openSWConnector ( const BFU32  Switch,
const BFU32  Connector 
)

Open a board with the given switch setting and connector index.

Parameters
[in]Switch- The board switch setting used to determine which physical board to open.
[in]Connector- The index of the connector to be opeend.
Exceptions
BiExceptionthrown if a board with the Switch setting cannot be found, if located board doesn't have a connector with the specified index, or if the board cannot be opened.

References BI_CIERROR_CIBRDOPEN, BI_CIERROR_CISYSBOARDFINDSWCONNECTOR, BrdOpenOptions, BiException::check(), and close().

71 {
72  close();
73 
74  CiENTRY entry;
75  BFRC rc = CiSysBoardFindSWConnector(CISYS_TYPE_ANY, Switch, Connector, &entry);
76  if (BF_OK != rc)
78 
79  Bd hBoard;
80  rc = CiBrdOpen(&entry, &hBoard, BrdOpenOptions);
81  if (BF_OK != rc)
83 
84  m_pd.hBoard = hBoard;
85  m_pd.boardSwitch = Switch;
86  m_pd.boardConnector = Connector;
87 }
BFU32 BFRC
Definition: BFType.h:92
Definition: BiError.h:373
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:306
void *** Bd
Definition: BFType.h:88
BFVOID close(BFVOID)
Definition: CXPReg.cpp:92
Definition: CXPReg.cpp:5
Definition: BiError.h:372
BFSIZET Device::readData ( const BFU32  address,
const BFU32  bytesToRead,
std::vector< BFU8 > &  dataOut 
) const

Read the values from a sequence of CoaXPress registers, returning the length of data read.

Parameters
[in]address- The register address on the connected CXP camera to read from.
[in]bytesToRead- The number of bytes to be read.
[out]dataOut- Output buffer of the data read, resized to fit the data, if necessary
Returns
The number of bytes actually read.
Exceptions
BFCiExceptionthrown if the data read operation fails.

Referenced by readData().

225 {
226  return readData(0xFF, address, bytesToRead, dataOut);
227 }
BFSIZET readData(const BFU32 address, const BFU32 bytesToRead, std::vector< BFU8 > &dataOut) const
Definition: CXPReg.cpp:224
BFSIZET Device::readData ( const BFU32  address,
const BFU32  bytesToRead,
BFU8 *const  dataOut,
const BFSIZET  dataOutSize 
) const

Read the values from a sequence of CoaXPress registers, returning the length of data read. Store as much of the output data as can be in the dataOut buffer, dropping any data that won't fit.

Parameters
[in]address- The register address on the connected CXP camera to read from.
[in]bytesToRead- The number of bytes to be read.
[out]dataOut- Output buffer of the data read. Filled as much as possible, given the dataOutSize.
[in]dataOutSize- Byte size of the dataOut buffer.
Returns
The number of bytes actually read.
Exceptions
BFCiExceptionthrown if the data read operation fails.

References readData().

245 {
246  return readData(0xFF, address, bytesToRead, dataOut, dataOutSize);
247 }
BFSIZET readData(const BFU32 address, const BFU32 bytesToRead, std::vector< BFU8 > &dataOut) const
Definition: CXPReg.cpp:224
BFSIZET Device::readData ( const BFU32  link,
const BFU32  address,
const BFU32  bytesToRead,
std::vector< BFU8 > &  dataOut 
) const

Read the values from a sequence of CoaXPress registers, returning the length of data read.

Parameters
[in]link- The camera link to read from.
[in]address- The register address on the connected CXP camera to read from.
[in]bytesToRead- The number of bytes to be read.
[out]dataOut- Output buffer of the data read, resized to fit the data, if necessary
Returns
The number of bytes actually read.
Exceptions
BFCiExceptionthrown if the data read operation fails.

References readData().

263 {
264  // Round the vector size up to the nearest 32-bit WORD byte-size.
265  const size_t minimumDataSize = (bytesToRead + 3) & ~3u;
266  if (dataOut.size() < minimumDataSize)
267  dataOut.resize(minimumDataSize);
268 
269  return readData(link, address, bytesToRead, dataOut.data(), dataOut.size());
270 }
BFSIZET readData(const BFU32 address, const BFU32 bytesToRead, std::vector< BFU8 > &dataOut) const
Definition: CXPReg.cpp:224
BFSIZET Device::readData ( const BFU32  link,
const BFU32  address,
const BFU32  bytesToRead,
BFU8 *const  dataOut,
const BFSIZET  dataOutSize 
) const

Read the values from a sequence of CoaXPress registers, returning the length of data read. Store as much of the output data as can be in the dataOut buffer, dropping any data that won't fit.

Parameters
[in]link- The camera link to read from.
[in]address- The register address on the connected CXP camera to read from.
[in]bytesToRead- The number of bytes to be read.
[out]dataOut- Output buffer of the data read. Filled as much as possible, given the dataOutSize.
[in]dataOutSize- Byte size of the dataOut buffer.
Returns
The number of bytes actually read.
Exceptions
BFCiExceptionthrown if the data read operation fails.

References BFCiException::check().

289 {
290  BFU32 bytesRead;
291  BFCiException::check(m_pd.hBoard, BFCXPReadData(m_pd.hBoard, link, address, bytesToRead, &bytesRead, dataOut, dataOutSize) );
292  return bytesRead;
293 }
unsigned long BFU32
Definition: BFTypeNT.h:55
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
BFU32 Device::readReg ( const BFU32  address) const

Read the value of a single CoaXPress register.

Parameters
[in]address- The register address on the connected CXP camera to read from.
Returns
The value stored at the specified address.
Exceptions
BFCiExceptionthrown if the register read operation fails.
164 {
165  return readReg(0xFF, address);
166 }
BFU32 readReg(const BFU32 address) const
Definition: CXPReg.cpp:163
BFU32 Device::readReg ( const BFU32  link,
const BFU32  address 
) const

Read the value of a single CoaXPress register.

Parameters
[in]link- The camera link to read from.
[in]address- The register address on the connected CXP camera to read from.
Returns
The value stored at the specified address.
Exceptions
BFCiExceptionthrown if the register read operation fails.

References BFCiException::check().

179 {
180  BFU32 value;
181  BFCiException::check(m_pd.hBoard, BFCXPReadReg(m_pd.hBoard, link, address, &value) );
182  return value;
183 }
unsigned long BFU32
Definition: BFTypeNT.h:55
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
BFVOID Device::writeData ( const BFU32  address,
std::vector< BFU8 > const &  dataIn 
)

Write data to a sequence of CoaXPress registers.

Parameters
[in]address- The register address on the connected CXP camera to write to.
[in]dataIn- The input data buffer, specifying the data to be written.
Exceptions
BFCiExceptionthrown if the data write operation fails.

Referenced by writeData().

304 {
305  writeData(0xFF, address, dataIn.data(), dataIn.size());
306 }
BFVOID writeData(const BFU32 address, std::vector< BFU8 > const &dataIn)
Definition: CXPReg.cpp:303
BFVOID Device::writeData ( const BFU32  address,
const BFU8 *const  dataIn,
const BFSIZET  dataInSize 
)

Write data to a sequence of CoaXPress registers.

Parameters
[in]address- The register address on the connected CXP camera to write to.
[in]dataIn- The input data buffer, specifying the data to be written.
[in]dataInSize- The number of bytes from dataIn that are to be written. This should be no bigger than the physical byte size of dataIn.
Exceptions
BFCiExceptionthrown if the data write operation fails.

References writeData().

319 {
320  writeData(0xFF, address, dataIn, dataInSize);
321 }
BFVOID writeData(const BFU32 address, std::vector< BFU8 > const &dataIn)
Definition: CXPReg.cpp:303
BFVOID Device::writeData ( const BFU32  link,
const BFU32  address,
std::vector< BFU8 > const &  dataIn 
)

Write data to a sequence of CoaXPress registers.

Parameters
[in]link- The camera link to write on.
[in]address- The register address on the connected CXP camera to write to.
[in]dataIn- The input data buffer, specifying the data to be written.
Exceptions
BFCiExceptionthrown if the data write operation fails.

References writeData().

333 {
334  writeData(link, address, dataIn.data(), dataIn.size());
335 }
BFVOID writeData(const BFU32 address, std::vector< BFU8 > const &dataIn)
Definition: CXPReg.cpp:303
BFVOID Device::writeData ( const BFU32  link,
const BFU32  address,
const BFU8 *const  dataIn,
const BFSIZET  dataInSize 
)

Write data to a sequence of CoaXPress registers.

Parameters
[in]link- The camera link to write on.
[in]address- The register address on the connected CXP camera to write to.
[in]dataIn- The input data buffer, specifying the data to be written.
[in]dataInSize- The number of bytes from dataIn that are to be written. This should be no bigger than the physical byte size of dataIn.
Exceptions
BFCiExceptionthrown if the data write operation fails.

References BFCiException::check().

349 {
350  BFCiException::check(m_pd.hBoard, BFCXPWriteData(m_pd.hBoard, link, address, const_cast<BFU8*>(dataIn), (BFU32)dataInSize) );
351 }
unsigned long BFU32
Definition: BFTypeNT.h:55
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
BFVOID Device::writeReg ( const BFU32  address,
const BFU32  value 
)

Write the value of a single CoaXPress register.

Parameters
[in]address- The register address on the connected CXP camera to write to.
[in]value- The value to be written.
Exceptions
BFCiExceptionthrown if the register write operation fails.
194 {
195  writeReg(0xFF, address, value);
196 }
BFVOID writeReg(const BFU32 address, const BFU32 value)
Definition: CXPReg.cpp:193
BFVOID Device::writeReg ( const BFU32  link,
const BFU32  address,
const BFU32  value 
)

Write the value of a single CoaXPress register.

Parameters
[in]link- The camera link to write on.
[in]address- The register address on the connected CXP camera to write to.
[in]value- The value to be written.
Exceptions
BFCiExceptionthrown if the register write operation fails.

References BFCiException::check().

208 {
209  BFCiException::check(m_pd.hBoard, BFCXPWriteReg(m_pd.hBoard, link, address, value) );
210 }
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212

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