Buffer Interface
BufferInterface.h
Go to the documentation of this file.
1 #pragma once
2 #include "BiApi.h"
3 #include "BFException.hpp"
4 
5 #include <string>
6 #include <vector>
7 
50 namespace BufferAcquisition
51 {
63  class BFDLL BufferInterface
64  {
65  public:
66  // Forward declaration of the dependent Properties class. See: BufferInterfaceProperties.h
67  class Properties;
68 
69  // Constructor
71 
72  // Destructor
73  virtual ~BufferInterface (BFVOID);
74 
75  // Return the number of boards installed on this system.
76  static BFU32 boardCount (BFVOID);
77 
78  // Opens board for acquisition.
79  BFVOID open (const BFU32 brdNumber);
80 
81  // Opens board for acquisition with specified options
82  BFVOID open (const BFU32 brdNumber, const BFU32 options);
83 
84  // Opens board for acquisition and loads the camera file given.
85  BFVOID open (const BFU32 brdNumber, std::string const& camFileName);
86  BFVOID open (const BFU32 brdNumber, const BFCHAR *const camFileName);
87 
88  // Opens board for acquisition and loads the camera file given with specified options.
89  BFVOID open (const BFU32 brdNumber, std::string const& camFileName, const BFU32 options);
90  BFVOID open (const BFU32 brdNumber, const BFCHAR *const camFileName, const BFU32 options);
91 
92  // Opens board for acquisition given the specified switch and connector.
93  BFVOID openSWConnector (const BFU32 Switch, const BFU32 Connector);
94 
95  // Opens board for acquisition given the specified switch and connector.
96  BFVOID openSWConnector (const BFU32 Switch, const BFU32 Connector, const BFU32 options);
97 
98  // Closes board resources.
99  BFVOID close (BFVOID);
100 
106  inline Bd getBoardHandle (BFVOID) const
107  {
108  return m_hBoard;
109  }
110 
111  // Return the opened board number. Returns ~BFU32(0), if the board isn't open, or wasn't
112  // opened with a board number (see getBoardSWConnector).
113  BFU32 getBoardNumber (BFVOID) const;
114 
115  // Retrieve the opened board switch and connector. Retrieves ~BFU32(0), if the board isn't
116  // open, or wasn't opened with openSWConnector (see getBoardNumber).
117  BFVOID getBoardSWConnector (BFU32 &Switch, BFU32 &Connector);
118 
119  // Retrieve a list of modes supported by the current camera file, returning the number
120  // of modes determined. R64 and older board models to not support multi-mode camera files,
121  // and no modes will be returned for that case.
122  BFSIZET enumerateCameraModes (std::vector<std::string> &modes, std::vector<std::string> &descriptions = std::vector<std::string>()) const;
123  BFBOOL enumerateCameraMode (const BFSIZET index, BFCHAR *const modeBuf, BFSIZET *const pModeSize, BFCHAR *const descBuf, BFSIZET *const pDescSize) const;
124 
125  // Get the current camera mode's name. R64 and older board models do not support camera modes.
126  std::string getCameraMode (BFVOID) const;
127  BFBOOL getCameraMode (BFCHAR *const modeBuf, BFSIZET *const pModeSize) const;
128 
129  // Set the current camera mode to that named. R64 and older board models do not support camera modes.
130  BFVOID setCameraMode (std::string const& modeName);
131  BFVOID setCameraMode (const BFCHAR *const modeName);
132 
133  // Set the size of the acquired frame.
134  BFVOID setAcqFrameSize (const BFU32 XSize, const BFU32 YSize);
135 
136  // Set the Region Of Interest (ROI) of the acquired frame.
137  BFVOID setAcqROI (const BFU32 XOffset, const BFU32 YOffset, const BFU32 XSize, const BFU32 YSize);
138 
139  // Connect or disconnect the external hardware trigger circuitry.
140  BFVOID setExTriggerConnect (const CiTrigSelect trigger = CiTrigA, const BFU32 state = BFExTrigConnect);
141 
142  // Programs the New Timing Generator (NTG).
143  BFVOID setExposureControl (const BFDOUBLE ExposurePeriod, const BFDOUBLE LineFramePeriod, const BFU32 TriggerMode, const BFBOOL AssertedHigh, const BFU32 OutputSignal);
144 
145  // Retrieve the current configuration of the New Timing Generator (NTG).
146  BFVOID getExposureControl (BFDOUBLE &ExposurePeriod, BFDOUBLE &LineFramePeriod, BFU32 &TriggerMode, BFBOOL &AssertedHigh, BFU32 &OutputSignal) const;
147 
148  // Returns a pointer to the array of pointers to the buffers.
149  PBFU32* getBufferArrayPointers (BFVOID);
150  const PBFU32* getBufferArrayPointers (BFVOID) const;
151 
152  // Returns information about the board and camera file.
153  BFU32 getBrdInfo (const BFU32 brdInqVar) const;
154 
155  // Returns the number of frames that have been captured.
156  BFU32 getNumFramesCaptured (BFVOID) const;
157 
158  // Returns the number of frames that where missed during acquisition.
159  BFU32 getNumFramesMissed (BFVOID) const;
160 
161  // If returns TRUE <=> a start command has been issued.
162  BFBOOL getStartAcqFlag (BFVOID) const;
163 
164  // If returns TRUE <=> a stop command has been issued.
165  BFBOOL getStopAcqFlag (BFVOID) const;
166 
167  // If returns TRUE <=> an abort command has been issued.
168  BFBOOL getAbortAcqFlag (BFVOID) const;
169 
170  // If returns TRUE <=> a pause command has been issued.
171  BFBOOL getPauseAcqFlag (BFVOID) const;
172 
173  // If returns TRUE <=> instance cleanup has occured.
174  BFBOOL getCleanupAcqFlag (BFVOID) const;
175 
176  // Returns the major version of the Bi API.
177  static BFU32 getMajorVersion (BFVOID);
178 
179  // Returns the minor version of the Bi API.
180  static BFU32 getMinorVersion (BFVOID);
181 
182  // Sets the hardware trigger mode
183  BFVOID setTriggerMode (const BFU32 triggerMode = BiTrigFreeRun, const BFU32 trigPolarity = BiTrigAssertedHigh);
184 
185  // Returns the current hardware trigger mode of the board.
186  BFU32 getTriggerMode (BFVOID) const;
187 
188  // Returns the current hardware trigger polarity.
189  BFU32 getTriggerPolarity (BFVOID) const;
190 
191  // Issues a software trigger.
192  BFVOID issueSoftwareTrigger (const BFU32 trigMode = BiTrigAssertTrigA);
193 
194  // Displays dialog describing error
195  BFU32 showError (const BFU32 errorNum) const;
196 
197  // Write a single buffer to disk.
198  BFVOID writeBuffer (PBFCHAR fileName, const BFSIZET fileNameSize, const BFU32 bufferNumber, const BFU32 options) const;
199  BFVOID writeBuffer (std::string const& fileName, const BFU32 bufferNumber, const BFU32 options) const;
200 
201  // Write a sequence of buffers to disk.
202  BFVOID writeSeqBuffer (PBFCHAR fileName, const BFSIZET fileNameSize, const BFU32 firstBufNumber, const BFU32 numBufs, const BFU32 Options) const;
203  BFVOID writeSeqBuffer (std::string const& fileName, const BFU32 firstBufNumber, const BFU32 numBufs, const BFU32 Options) const;
204 
205  // read a sequence of files into memory.
206  BFVOID readSeqFile (std::string const& fileName, const BFU32 firstBufNumber, const BFU32 numBufs);
207  BFVOID readSeqFile (const BFCHAR *const fileName, const BFU32 firstBufNumber, const BFU32 numBufs);
208 
209  // Clears all buffers memory
210  BFVOID clearBuffers (BFVOID);
211 
212  // Returns the error text for a specific error number
213  std::string getErrorText (const BFU32 errorNumber) const;
214  BFVOID getErrorText (const BFU32 errorNumber, PBFCHAR errorText, const PBFU32 errorTextSize) const;
215 
216  // Returns the number of buffers software is behind the hardware DMA engine.
217  BFU32 getBufferQueueSize (BFVOID) const;
218 
219  // Set Buffer acquisition timeout.
220  BFVOID setTimeout (const BFU32 TimeoutValue);
221 
222  // Loads a camera file for the board to use.
223  BFVOID loadCamFile (std::string const& camFileName);
224  BFVOID loadCamFile (const BFCHAR *const camFileName);
225 
226  // Unloads a camera file loaded by the loadCamFile method.
227  BFVOID unloadCamFile (BFVOID);
228 
230 
231  // Read the value of a single CoaXPress register.
232  BFU32 cxpReadReg (const BFU32 address) const;
233  BFU32 cxpReadReg (const BFU32 link, const BFU32 address) const;
234 
235  // Write the value of a single CoaXPress register.
236  BFVOID cxpWriteReg (const BFU32 address, const BFU32 value);
237  BFVOID cxpWriteReg (const BFU32 link, const BFU32 address, const BFU32 value);
238 
239  // Read the values from a sequence of CoaXPress registers, returning
240  // the length of data read. Store as much of the output data as can be
241  // in the dataOut buffer, dropping any data that won't fit. In the variants
242  // using std::vector, the vector will be resized to fit at least the size
243  // of bytesToRead.
244  BFSIZET cxpReadData (const BFU32 address, const BFU32 bytesToRead, std::vector<BFU8> &dataOut) const;
245  BFSIZET cxpReadData (const BFU32 address, const BFU32 bytesToRead, BFU8 *const dataOut, const BFSIZET dataOutSize) const;
246  BFSIZET cxpReadData (const BFU32 link, const BFU32 address, const BFU32 bytesToRead, std::vector<BFU8> &dataOut) const;
247  BFSIZET cxpReadData (const BFU32 link, const BFU32 address, const BFU32 bytesToRead, BFU8 *const dataOut, const BFSIZET dataOutSize) const;
248 
249  // Write data to a sequence of CoaXPress registers.
250  BFVOID cxpWriteData (const BFU32 address, std::vector<BFU8> const& dataIn);
251  BFVOID cxpWriteData (const BFU32 address, const BFU8 *const dataIn, const BFSIZET dataInSize);
252  BFVOID cxpWriteData (const BFU32 link, const BFU32 address, std::vector<BFU8> const& dataIn);
253  BFVOID cxpWriteData (const BFU32 link, const BFU32 address, const BFU8 *const dataIn, const BFSIZET dataInSize);
254 
256 
257  // Retrieve the name of the frame grabber register at the given index.
258  std::string bfRegName (const BFU32 RegId) const;
259  BFVOID bfRegName (const BFU32 RegId, PBFCHAR nameBuf, const BFSIZET nameBufSize) const;
260 
261  // Return the index of the given frame grabber register name, or REG_UNDEFINED,
262  // if there is no register with that name.
263  BFU32 bfRegId (std::string const& regName) const;
264  BFU32 bfRegId (const BFCHAR *const regName) const;
265 
266  // Peek the value at the given frame grabber register index.
267  BFU32 bfRegPeek (const BFU32 RegId) const;
268 
269  // Poke the value at the given frame grabber register index.
270  BFVOID bfRegPoke (const BFU32 RegId, const BFU32 Value);
271 
272  // Returns if the board is open or not
273  BFBOOL isBoardOpen (BFVOID) const;
274 
275  // Returns if the board is setup or not
276  BFBOOL isBoardSetup (BFVOID) const;
277 
278  // Retrieve a reference to the BufferInterface::Properties.
279  BufferInterface::Properties const& properties (void) const;
280 
281  protected:
284 
286  mutable BIBA m_BufferArray;
287 
290 
295 
296  private:
297  // Private data members.
298  struct PrivateData;
299  PrivateData &m_pd;
300 
301  // BufferInterface is non-copyable.
303  BufferInterface& operator= (BufferInterface const&);
304  };
305 }
char BFCHAR
Definition: BFTypeNT.h:33
unsigned long BFU32
Definition: BFTypeNT.h:55
#define BiTrigFreeRun
Definition: BiDef.h:86
#define BiTrigAssertTrigA
Definition: BiDef.h:110
unsigned long * PBFU32
Definition: BFTypeNT.h:55
Bd getBoardHandle(BFVOID) const
Definition: BufferInterface.h:106
BFBOOL isSetup
Definition: BufferInterface.h:293
BIBA m_BufferArray
Definition: BufferInterface.h:286
PBFCNF m_pCam
Definition: BufferInterface.h:289
#define BiTrigAssertedHigh
Definition: BiDef.h:104
BFBOOL isOpen
Definition: BufferInterface.h:294
Bd m_hBoard
Definition: BufferInterface.h:283
Class library for BitFlow frame grabber acquisition.
Definition: BFGTLUtilities.hpp:114
void *** Bd
Definition: BFType.h:88
PBFVOID PBFCNF
Definition: BFType.h:97
size_t BFSIZET
Definition: BFTypeNT.h:93
char * PBFCHAR
Definition: BFTypeNT.h:33
BFBOOL isMemAssigned
Definition: BufferInterface.h:291
double BFDOUBLE
Definition: BFTypeNT.h:41
void BFVOID
Definition: BFTypeNT.h:32
Static properties of an open BufferAcquisition::BufferInterface.
Definition: BufferInterfaceProperties.h:92
unsigned char BFU8
Definition: BFTypeNT.h:59
BFBOOL isMemAllocated
Definition: BufferInterface.h:292
Base class for buffered acquisition using a BitFlow frame grabber.
Definition: BufferInterface.h:63
struct _BFBUFARY BIBA
int BFBOOL
Definition: BFTypeNT.h:34