Buffer Interface
Public Member Functions | Static Public Member Functions | List of all members
BFGTLUtilities::Device Class Reference

Interface to access and modify features on a Gen<i>Cam device. More...

#include <BFGTLUtilities.hpp>

Public Member Functions

 Device (BFVOID)
 
 ~Device (BFVOID)
 
BFVOID open (BufferAcquisition::BufferInterface const &bufin)
 
BFVOID open (Bd hBoard)
 
BFVOID open (const BFU32 brdNum)
 
BFVOID openSWConnector (const BFU32 Switch, const BFU32 Connector)
 
BFVOID close (BFVOID)
 
BFBOOL isOpen (BFVOID) const
 
bool operator! (BFVOID) const
 
 operator bool (BFVOID) const
 
Bd getBoardHandle (BFVOID) const
 
BFU32 getBoardNumber (BFVOID) const
 
BFVOID getBoardSWConnector (BFU32 &Switch, BFU32 &Connector) const
 
std::vector< std::string > getNodeNames (BFVOID) const
 
BFBOOL enumerateNodeName (const BFSIZET index, BFCHAR *const nameBuf, BFSIZET *const pNameSize) const
 
BFBOOL nodeExists (std::string const &name) const
 
BFBOOL nodeExists (const BFCHAR *const name) const
 
BaseNode getNode (std::string const &name) const
 
BaseNode getNode (const BFCHAR *const name) const
 

Static Public Member Functions

static BFU32 boardCount (BFVOID)
 

Detailed Description

Interface to access and modify features on a Gen<i>Cam device.

The BFGTLUtilities::Device class provides an independent interface to Gen<i>Cam devices, as exposed by BitFlow frame grabbers through the BFGTL Gen<i>Cam producer. 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  )

Construct an unopened BFGTLUtilities Device.

35  : m_pd (new PrivateData)
36 { }
Device::~Device ( BFVOID  )

Deallocate the BFGTLUtilities Device.

References close().

42 {
43  close();
44  delete m_pd;
45 }
BFVOID close(BFVOID)
Definition: BFGTLUtilities.cpp:168

Member Function Documentation

BFU32 Device::boardCount ( BFVOID  )
static

Return the number of BitFlow boards installed on the system.

Returns
The number of BitFlow boards installed on the system.
Exceptions
BiException- Thrown if the BitFlow boards cannot be enumerated.

References BI_CIERROR_CISYSBRDENUM, and BiException::check().

55 {
56  BFU32 count;
57  if (BF_OK != CiSysBrdEnum(CISYS_TYPE_ANY, &count))
59  return count;
60 }
unsigned long BFU32
Definition: BFTypeNT.h:55
Definition: BiError.h:371
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:306
BFVOID Device::close ( BFVOID  )

Close the BFGTL Camera Device.

Exceptions
BFCiException- Thrown if the Device cannot be closed.

References BFCiException::check().

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

169 {
170  if (m_pd->m_dev)
171  BFCiException::check(m_pd->m_hBoard, BFGTLDevClose(m_pd->m_dev) );
172 
173  if (m_pd->m_hBoardLcl)
174  CiBrdClose(m_pd->m_hBoardLcl);
175 
176  m_pd->m_hBoard = nullptr;
177  m_pd->m_hBoardLcl = nullptr;
178  m_pd->m_dev = nullptr;
179  m_pd->m_boardNumber = ~BFU32(0);
180  m_pd->m_switch = ~BFU32(0);
181  m_pd->m_connector = ~BFU32(0);
182 }
unsigned long BFU32
Definition: BFTypeNT.h:55
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
BFBOOL Device::enumerateNodeName ( const BFSIZET  index,
BFCHAR *const  nameBuf,
BFSIZET *const  pNameSize 
) const

Retrieve a list of all available Camera Device node names.

Parameters
[in]index- The node index to enumerate.
[out]nameBuf- The node name string buffer, filled with as much data as is possible. This may be nullptr.
[in,out]pNameSize- As input, the size of nameBuf. As output, the buffer size required to read the entire name string.
Returns
True if the node at index exists.
Exceptions
BFCiException- Thrown if a Device access error occurs.

References BFCiException::check().

289 {
290  size_t nodeCnt;
291  BFCiException::check(m_pd->m_hBoard, BFGTLDevNodeEnum(m_pd->m_dev, &nodeCnt) );
292 
293  if (index >= nodeCnt)
294  return false;
295 
296  BFCiException::check(m_pd->m_hBoard, BFGTLDevNodeName(m_pd->m_dev, index, nameBuf, pNameSize) );
297 
298  return true;
299 }
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
Bd Device::getBoardHandle ( BFVOID  ) const

Return the opened board handle. If opened by board number or switch connector, this is an internally allocated handle. If opened by Bd handle, this is the externally supplied handle. If closed, returns nullptr.

Returns
The corresponding board handle, if opened. nullptr, if closed.
222 {
223  return m_pd->m_hBoard;
224 }
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 current board number, if opened by board number. ~BFU32(0), otherwise.
233 {
234  return m_pd->m_boardNumber;
235 }
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).

242 {
243  Switch = m_pd->m_switch;
244  Connector = m_pd->m_connector;
245 }
BaseNode Device::getNode ( std::string const &  name) const

Retrieve a Camera Device node from a given node name.

Returns
A Camera Device node from a given node name.
Exceptions
BFCiException- Thrown if no node could be opened on this Device with the given name.

References BFCiException::check().

329 {
330  BFGTLNode hNode;
331  BFCiException::check(m_pd->m_hBoard, BFGTLNodeOpen(m_pd->m_dev, name.c_str(), &hNode) );
332 
333  return BaseNode (m_pd->m_hBoard, *this, hNode);
334 }
Base class for BFGTLUtilities::Device node access and modification.
Definition: BFGTLUtilities.hpp:237
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
BaseNode Device::getNode ( const BFCHAR *const  name) const

Retrieve a Camera Device node from a given node name.

Returns
A Camera Device node from a given node name.
Exceptions
BFCiException- Thrown if no node could be opened on this Device with the given name.

References BFCiException::check().

344 {
345  BFGTLNode hNode;
346  BFCiException::check(m_pd->m_hBoard, BFGTLNodeOpen(m_pd->m_dev, name, &hNode) );
347 
348  return BaseNode (m_pd->m_hBoard, *this, hNode);
349 }
Base class for BFGTLUtilities::Device node access and modification.
Definition: BFGTLUtilities.hpp:237
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
std::vector< std::string > Device::getNodeNames ( BFVOID  ) const

Retrieve a list of all available Camera Device node names.

Returns
A list of all available Camera Device node names.
Exceptions
BFCiException- Thrown if a Device access error occurs.

References BFCiException::check().

255 {
256  size_t nodeCnt;
257  BFCiException::check(m_pd->m_hBoard, BFGTLDevNodeEnum(m_pd->m_dev, &nodeCnt) );
258 
259  std::vector<std::string> nodeNames (nodeCnt);
260  for (size_t i = 0; i < nodeCnt; i++)
261  {
262  size_t nameSize;
263  BFCiException::check(m_pd->m_hBoard, BFGTLDevNodeName(m_pd->m_dev, i, nullptr, &nameSize) );
264 
265  std::vector<char> nameStr (nameSize);
266  BFCiException::check(m_pd->m_hBoard, BFGTLDevNodeName(m_pd->m_dev, i, nameStr.data(), &nameSize) );
267  nameStr.back() = 0;
268 
269  nodeNames[i] = nameStr.data();
270  }
271 
272  return std::move(nodeNames);
273 }
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
BFBOOL Device::isOpen ( BFVOID  ) const

Return whether or not a BFGTL Camera Device has been opened or not.

Returns
Whether or not a BFGTL Camera Device has been opened or not.

Referenced by operator!().

190 {
191  return !!m_pd->m_dev;
192 }
BFBOOL Device::nodeExists ( std::string const &  name) const

Query whether or not the named node exists.

Returns
True or false, whether or not the named node exists for this device.
307 {
308  return BFGTLDevNodeExists(m_pd->m_dev, name.c_str());
309 }
BFBOOL Device::nodeExists ( const BFCHAR *const  name) const

Query whether or not the named node exists.

Returns
True or false, whether or not the named node exists for this device.
317 {
318  return BFGTLDevNodeExists(m_pd->m_dev, name);
319 }
BFVOID Device::open ( BufferAcquisition::BufferInterface const &  bufin)

Open the Device corresponding to specified BufferInterface. The Device must be closed prior to closing the BufferInterface. Closes the current Device first, if necessary.

Exceptions
BFCiException- Thrown if the Device cannot be opened.

References BufferAcquisition::BufferInterface::getBoardHandle().

70 {
71  open(bufin.getBoardHandle());
72 }
BFVOID open(BufferAcquisition::BufferInterface const &bufin)
Definition: BFGTLUtilities.cpp:69
BFVOID Device::open ( Bd  hBoard)

Open the BFGTL Camera Device corresponding to the given board handle. The Device must be closed prior to closing the board handle. Closes the current Device first, if necessary.

Exceptions
BFCiException- Thrown if the Device cannot be opened.

References BFCiException::check(), and close().

82 {
83  close();
84 
85  BFGTLDev hDev;
86  BFCiException::check(hBoard, BFGTLDevOpen(hBoard, &hDev) );
87 
88  m_pd->m_hBoard = hBoard;
89  m_pd->m_dev = hDev;
90 }
BFVOID close(BFVOID)
Definition: BFGTLUtilities.cpp:168
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
BFVOID Device::open ( const BFU32  brdNum)

Open a BFGTL Camera Device for the given board number. Closes the current Device first, if necessary.

Exceptions
BiException- Thrown if the specified board couldn't be accessed.
BFCiException- Thrown if the Device cannot be opened.

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

100 {
101  close();
102 
103  Bd hBoard;
104  BiException::check(0, BiBrdOpenEx(BiTypeAny, brdNum, &hBoard, BFSysSecondProcessOpen|BFSysAllowTwoOpens|BFSysNoIntThread|BFSysNoCameraOpen) );
105 
106  BFGTLDev hDev;
107  try
108  {
109  BFCiException::check(hBoard, BFGTLDevOpen(hBoard, &hDev) );
110  }
111  catch (BFExceptionBase const&)
112  {
113  BiBrdClose(hBoard);
114  throw;
115  }
116 
117  m_pd->m_hBoard = hBoard;
118  m_pd->m_hBoardLcl = hBoard;
119  m_pd->m_dev = hDev;
120  m_pd->m_boardNumber = brdNum;
121 }
Base class of all BitFlow exception classes.
Definition: BFException.hpp:11
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:306
#define BiTypeAny
Definition: BiDef.h:33
BFVOID close(BFVOID)
Definition: BFGTLUtilities.cpp:168
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
void *** Bd
Definition: BFType.h:88
BFVOID Device::openSWConnector ( const BFU32  Switch,
const BFU32  Connector 
)

Open a BFGTL Camera Device for the given Board switch and Connector. Closes the current Device first, if necessary.

Exceptions
BiException- Thrown if the specified board couldn't be accessed.
BFCiException- Thrown if the Device cannot be opened.

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

131 {
132  BFRC rc;
133  close();
134 
135  CiENTRY entry;
136  rc = CiSysBoardFindSWConnector(CISYS_TYPE_ANY, Switch, Connector, &entry);
137  if (BF_OK != rc)
139 
140  Bd hBoard;
141  rc = CiBrdOpen(&entry, &hBoard, BFSysSecondProcessOpen|BFSysAllowTwoOpens);
142  if (BF_OK != rc)
144 
145  BFGTLDev hDev;
146  try
147  {
148  BFCiException::check(hBoard, BFGTLDevOpen(hBoard, &hDev) );
149  }
150  catch (BFExceptionBase const&)
151  {
152  CiBrdClose(hBoard);
153  throw;
154  }
155 
156  m_pd->m_hBoard = hBoard;
157  m_pd->m_hBoardLcl = hBoard;
158  m_pd->m_dev = hDev;
159  m_pd->m_switch = Switch;
160  m_pd->m_connector = Connector;
161 }
BFU32 BFRC
Definition: BFType.h:92
Base class of all BitFlow exception classes.
Definition: BFException.hpp:11
Definition: BiError.h:373
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:306
BFVOID close(BFVOID)
Definition: BFGTLUtilities.cpp:168
static void check(Bd hBoard, const BFU32 error)
Definition: BFException.cpp:212
void *** Bd
Definition: BFType.h:88
Definition: BiError.h:372
Device::operator bool ( BFVOID  ) const

Equivalent to isOpen.

Returns
Whether or not a BFGTL Camera Device has been opened or not.
210 {
211  return !!isOpen();
212 }
BFBOOL isOpen(BFVOID) const
Definition: BFGTLUtilities.cpp:189
bool Device::operator! ( BFVOID  ) const

Inverse of isOpen.

Returns
Whether or not a BFGTL Camera Device is closed.

References isOpen().

200 {
201  return !isOpen();
202 }
BFBOOL isOpen(BFVOID) const
Definition: BFGTLUtilities.cpp:189

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