mvIMPACT Acquire SDK C++
GenICam interface layout(file stream)

Classes and functions that will be available if the device is used with the GenICam interface layout. More...

Classes

class  FileProtocolAdapter
 Adapter between the std::iostreambuf and the SFNC Features representing the device file system. More...
 
class  IDevFileStreamBase< CharType, Traits >
 An output stream buffer derived from std::basic_istream used to read from a file on a device. More...
 
class  IDevFileStreamBuf< CharType, Traits >
 An input stream buffer derived from std::basic_streambuf used to read from a file of a device. More...
 
class  ODevFileStreamBase< CharType, Traits >
 An output stream buffer derived from std::basic_ostream used to write to a file on a device. More...
 
class  ODevFileStreamBuf< CharType, Traits >
 An output stream buffer derived from std::basic_streambuf used to write to a file on a device. More...
 

Typedefs

typedef IDevFileStreamBase< char, std::char_traits< char > > IDevFileStream
 A type for char type file access. More...
 
typedef ODevFileStreamBase< char, std::char_traits< char > > ODevFileStream
 A type for char type file access. More...
 

Detailed Description

Classes and functions that will be available if the device is used with the GenICam interface layout.

This group contains classes and functions that will be available if the device is used with the mvIMPACT::acquire::dilGenICam interface layout.

Typedef Documentation

◆ IDevFileStream

typedef IDevFileStreamBase<char, std::char_traits<char> > IDevFileStream

A type for char type file access.

Provided for convenience only. This type represents an input file stream for char data.

Example:

//-----------------------------------------------------------------------------
void downloadUserFile( Device* pDev )
//-----------------------------------------------------------------------------
{
string srcName = "UserFile";
string dstName = "Downloaded_file.txt";
bool boOk = false;
try
{
// download a file
file.open( pDev, srcName.c_str() );
if( !file.fail() )
{
FILE* pFile;
size_t lSize;
char * pBuffer;
size_t result;
lSize = file.size();
// allocate memory to contain the whole file:
pBuffer = (char*)malloc( sizeof(char) * lSize );
if( pBuffer )
{
// copy the file into the pBuffer:
printf( "Copying from flash to pBuffer..." );
file.read( pBuffer, lSize );
printf( "Ready.\n" );
// write pBuffer to file
pFile = fopen( dstName.c_str(), "wb" );
if( pFile != NULL )
{
result = fwrite( pBuffer, 1, lSize, pFile );
if( result != lSize )
{
printf( "%s(%d): Could not write all data to file %s locally.\n", __FUNCTION__, __LINE__, dstName.c_str() );
}
else
{
boOk = true;
}
}
else
{
printf( "%s(%d): Could not open file %s with write access locally.\n", __FUNCTION__, __LINE__, dstName.c_str() );
}
free( pBuffer );
fclose( pFile );
}
else
{
printf("Memory error\n");
}
}
else
{
printf( "%s(%d): Could not open file %s with read access on device.\n", __FUNCTION__, __LINE__, srcName.c_str() );
}
}
catch( const ImpactAcquireException& e )
{
// this e.g. might happen if the same device is already opened in another process...
cout << "An error occurred while opening the device " << pDev->serial.read()
<< "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << endl;
}
if( boOk )
{
printf( "User file successfully saved to file '%s'.\n", dstName.c_str() );
}
}
An output stream buffer derived from std::basic_istream used to read from a file on a device.
Definition: mvIMPACT_acquire_GenICam_FileStream.h:764
void open(mvIMPACT::acquire::Device *pDev, const char *pFileName, std::ios_base::openmode mode=std::ios_base::in)
Opens a file on the device.
Definition: mvIMPACT_acquire_GenICam_FileStream.h:835
std::streamsize size(void) const
Returns the size of the file on the device.
Definition: mvIMPACT_acquire_GenICam_FileStream.h:861

◆ ODevFileStream

typedef ODevFileStreamBase<char, std::char_traits<char> > ODevFileStream

A type for char type file access.

Provided for convenience only. This type represents an output file stream for char data.

Example:

//-----------------------------------------------------------------------------
void uploadUserFile( Device* pDev )
//-----------------------------------------------------------------------------
{
string srcName = "Upload_Source.txt";
string dstName = "UserFile"; // This name hase to be used.
bool boOk = false;
try
{
// upload a file
file.open( pDev, dstName.c_str() );
if( !file.fail() )
{
FILE* pFile;
size_t lSize;
char * pBuffer;
size_t result;
pFile = fopen( srcName.c_str(), "rb" );
if( pFile != NULL )
{
// obtain file size:
fseek( pFile , 0 , SEEK_END );
lSize = ftell( pFile );
rewind( pFile );
// allocate memory to contain the whole file:
pBuffer = (char*)malloc( sizeof(char) * lSize );
if( pBuffer )
{
// copy the file into the pBuffer:
printf( "Copying file to pBuffer..." );
result = fread( pBuffer, 1, lSize, pFile );
if( result != lSize )
{
printf( "%s(%d): Could not read all data from file %s locally.\n", __FUNCTION__, __LINE__, srcName.c_str() );
}
else
{
// the whole file has been copied into 'pBuffer' now.
//file.seekp();
file.write( pBuffer, lSize );
printf( "ready.\nSaving to flash..." );
boOk = true;
}
free( pBuffer );
}
else
{
printf( "Memory error\n" );
}
fclose( pFile );
}
else
{
printf( "%s(%d): Could not open file %s with read access locally.\n", __FUNCTION__, __LINE__, srcName.c_str() );
}
}
else
{
printf( "%s(%d): Could not open file %s with write access on device.\n", __FUNCTION__, __LINE__, dstName.c_str() );
}
}
catch( const ImpactAcquireException& e )
{
// this e.g. might happen if the same device is already opened in another process...
cout << "An error occurred while opening the device " << pDev->serial.read()
<< "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << endl;
}
if( boOk )
{
printf( "ready.\nFile '%s' successfully uploaded to device.\n", srcName.c_str() );
}
}
An output stream buffer derived from std::basic_ostream used to write to a file on a device.
Definition: mvIMPACT_acquire_GenICam_FileStream.h:661
void open(mvIMPACT::acquire::Device *pDev, const char *pFileName, std::ios_base::openmode mode=std::ios_base::out|std::ios_base::trunc)
Open file on device in write mode.
Definition: mvIMPACT_acquire_GenICam_FileStream.h:728