Allows reading/writing to files hosted on the device. More...
Public Member Functions | |
PvGenFile () | |
Constructor. | |
virtual | ~PvGenFile () |
Destructor. | |
PvResult | Open (PvGenParameterArray *aArray, const PvString &aFilename, PvGenOpenMode aMode) |
Opens a file through the GenICam interface. More... | |
PvResult | Close () |
Closes the PvGenFile. More... | |
bool | IsOpened () const |
If the file object is opened or not. More... | |
PvResult | WriteFrom (const PvString &aLocalFilename) |
Writes a complete local file to the opened device file. More... | |
PvResult | ReadTo (const PvString &aLocalFilename) |
Reads a complete device file and writes it to a local file. More... | |
PvResult | Write (const uint8_t *aBuffer, int64_t aLength, int64_t &aBytesWritten) |
Writes data to the opened device file. More... | |
PvResult | Read (uint8_t *aBuffer, int64_t aLength, int64_t &aBytesRead) |
Reads data from the opened device file. More... | |
PvResult | GetStatus (PvString &aStatus) |
Returns the status of the last operation on a PvGenFile. More... | |
PvString | GetLastErrorMessage () const |
Used to retrieve string-based operation of the last operation on a PvGenFile. More... | |
PvResult | GetProgress (int64_t &aCompleted, int64_t &aTotal) |
Returns progress about the current read or write operation. More... | |
Static Public Member Functions | |
static bool | IsSupported (PvGenParameterArray *aArray) |
Static method used to query if a PvGenParameterArray supports file access. More... | |
static bool | IsReadable (PvGenParameterArray *aArray, const PvString &aFilename) |
Returns true if a file defined by the GenICam interface can be read. More... | |
static bool | IsWritable (PvGenParameterArray *aArray, const PvString &aFilename) |
Returns true if a file defined by the GenICam interface can be written. More... | |
static void | GetFiles (PvGenParameterArray *aArray, PvStringList &aFiles) |
Returns all files currently supported by a GenICam interface. More... | |
Allows reading/writing to files hosted on the device.
These files could be debug information, look-up tables, new firmware, configuration files, persistent configurations or just about anything.
PvResult PvGenFile::Close | ( | ) |
Closes the PvGenFile.
Closes the PvGenFile, detaches the PvGenParameterArray.
|
static |
Returns all files currently supported by a GenICam interface.
[in] | aArray | The GenICam parameter array. |
[out] | aFiles | A string array that is filled with all available files. |
PvString PvGenFile::GetLastErrorMessage | ( | ) | const |
Used to retrieve string-based operation of the last operation on a PvGenFile.
Use this method to retrieve detailed information about the last failed operation that returned PvResult::Code::GENERIC_ERROR.
EOFs and other status are not considered errors (PvResult::Code::OK is still returned) and are monitored through the GetStatus method.
PvResult PvGenFile::GetProgress | ( | int64_t & | aCompleted, |
int64_t & | aTotal | ||
) |
Returns progress about the current read or write operation.
[out] | aCompleted | How many bytes have been read or written. |
[out] | aTotal | Total byte count for the read or write operation. |
Returns the status of the last operation on a PvGenFile.
Last status of a read or write operation as provided by the device. The only enum entry guaranteed to be provided by all devices is "Success" and everything else is quality of implementation.
As an example, the reference GenApi implementation for files assumes end-of-file (EOF) if anything else other than "Success" is reported after a read or a write.
Open, Close, Read and Write operations can return PvResult::Code::OK but still show something else through GetStatus. The direct result code shows if the internal GenApi operation succeeded and the GetStatus shows the success or failure (or EOF) of the operation on the device.
[out] | aStatus | Last status from a read or write operation. |
bool PvGenFile::IsOpened | ( | ) | const |
If the file object is opened or not.
|
static |
Returns true if a file defined by the GenICam interface can be read.
[in] | aArray | The GenICam parameter array. |
[in] | aFilename | The file we are testing readability on. |
|
static |
Static method used to query if a PvGenParameterArray supports file access.
A PvGenParameterArray must support the following features in order to allow access to device files through GenICam:
[in] | aArray | The eBUS SDK GenApi parameter array to test. |
|
static |
Returns true if a file defined by the GenICam interface can be written.
[in] | aArray | The eBUS SDK GenApi parameter array. |
[in] | aFilename | The file we are testing writability on. |
PvResult PvGenFile::Open | ( | PvGenParameterArray * | aArray, |
const PvString & | aFilename, | ||
PvGenOpenMode | aMode | ||
) |
Opens a file through the GenICam interface.
Attaches the PvGenFile object to a GenICam parameter array, validates the filename exists for this device and perform the open operation through GenApi.
[in] | aArray | The eBUS SDK GenApi parameter array to use. |
[in] | aFilename | The filename of the file to open on the device. Must match one of the pre-defined enumeration entry of the FileSelector feature. The filename is case sensitive. |
[in] | aMode | Mode used to access the file. Read or write. |
PvResult PvGenFile::Read | ( | uint8_t * | aBuffer, |
int64_t | aLength, | ||
int64_t & | aBytesRead | ||
) |
Reads data from the opened device file.
Reads aLength bytes from the device file into aBuffer. If EOF (end-of-file) is reached, PvResult::Code::OK is returned but aBytesRead is 0 or less than aLength.
[in] | aBuffer | Pointer to the buffer where to write the data read from the device file. |
[in] | aLength | Number of bytes to read to the device file. |
[out] | aBytesRead | Number of bytes successfully read from the device file. |
Reads a complete device file and writes it to a local file.
[in] | aLocalFilename | The full path of the local file where data read from the device file is written to. |
PvResult PvGenFile::Write | ( | const uint8_t * | aBuffer, |
int64_t | aLength, | ||
int64_t & | aBytesWritten | ||
) |
Writes data to the opened device file.
Writes aLength bytes from aBuffer to the device file. If EOF (end-of-file) is reached, PvResult::Code::OK is returned but aBytesWritten is 0 or less than aLength.
[in] | aBuffer | Pointer to the data to write to the device file. |
[in] | aLength | Number of bytes to write to the device file. |
[out] | aBytesWritten | Number of bytes successfully written to the device file. |
Writes a complete local file to the opened device file.
If the file you are attempting to write to the device is not of a mod-4 length (in bytes) it will be padded with zero bytes in order to make sure the last write operation does not fail. This requirement does not come from GenICam but from the underlying GigE Vision control protocol.
[in] | aLocalFilename | The full path of the local file to write to the device file. |
Copyright (c) 2002-2021 Pleora Technologies Inc.
www.pleora.com