Impact Acquire SDK .NET

A helper class derived from System.IO.Stream used to read from and write to a file on a device. More...

Inheritance diagram for DevFileStream:
[legend]

Public Member Functions

 DevFileStream (Device pDev, String fileName, System.IO.FileAccess access)
 Constructs a new mv.impact.acquire.GenICam.DevFileStream object.
 
override void Flush ()
 Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
 
override int Read (byte[] buffer, int offset, int count)
 Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
 
override long Seek (long offset, System.IO.SeekOrigin origin)
 Sets the position within the current stream.
 
override void SetLength (long value)
 Sets the length of the current stream.
 
override void Write (byte[] buffer, int offset, int count)
 Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
 

Properties

override bool CanRead [get]
 Gets a value indicating whether the current stream supports reading.
 
override bool CanSeek [get]
 Gets a value indicating whether the current stream supports seeking.
 
override bool CanWrite [get]
 Gets a value indicating whether the current stream supports writing.
 
override long Length [get]
 Gets the length in bytes of the stream.
 
override long Position [get, set]
 Gets or sets the position within the current stream.
 

Detailed Description

A helper class derived from System.IO.Stream used to read from and write to a file on a device.

This class encapsulates the functionality accessible using instances of mv.impact.acquire.GenICam.FileAccessControl in a much more convenient way.

Whenever a mv.impact.acquire.GenICam.DevFileStream instance is no longer needed Dispose must be called. Encapsulating stream access scopes with a using statement whenever possible is recommended:

using (GenICam.DevFileStream fs = new GenICam.DevFileStream(pDev, fileName, FileAccess.Write))
{
// access the file here
}
A template class to represent 32 bit integer properties and 32 bit enumerated integer properties.
Definition EnumPropertyI.cs:61
A helper class derived from System.IO.Stream used to read from and write to a file on a device.
Definition mvIMPACT_acquire_GenICam_FileStream.cs:57

Downloading a file UserFile from a GenICam device can be achieved like this:

using (GenICam.DevFileStream fs = new GenICam.DevFileStream(getDevicePointerFromSomewhere(), "UserFile", FileAccess.Read))
{
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
// now the file from the device resides in 'buffer'! Do whatever your plans are with the file
}

Uploading a file UserFile to a GenICam device can be achieved like this:

using (GenICam.DevFileStream fs = new GenICam.DevFileStream(getDevicePointerFromSomewhere(), "UserFile", FileAccess.Write))
{
fs.Write(buffer, 0, buffer1.Length);
}
Note
See description of the System.IO.Stream to find out more about how to use this object.
Since
2.20.0

Constructor & Destructor Documentation

◆ DevFileStream()

DevFileStream ( Device pDev,
String fileName,
System::IO::FileAccess access )
inline

Constructs a new mv.impact.acquire.GenICam.DevFileStream object.

Parameters
[in]pDevA pointer to a mv.impact.acquire.Device object obtained from a mv.impact.acquire.DeviceManager object.
[in]fileNameThe name of the file that shall be accessed. This can be any string returned by a call to mv.impact.acquire.EnumPropertyI<T>.listOfValidStrings() on the mv.impact.acquire.GenICam.FileAccessControl.fileSelector property.
[in]accessThe desired file access. Only System.IO.FileAccess.Read and System.IO.FileAccess.Write are supported. Other values will raise a System.ArgumentException.

Member Function Documentation

◆ Flush()

override void Flush ( )
inline

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Note
Calling this function for mv.impact.acquire.GenICam.DevFileStream objects will have no effect as no internal buffering is done!

◆ Read()

override int Read ( byte[] buffer,
int offset,
int count )
inline

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Parameters
[in]bufferAn array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
[in]offsetThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
[in]countThe maximum number of bytes to be read from the current stream.

◆ Seek()

override long Seek ( long offset,
System::IO::SeekOrigin origin )
inline

Sets the position within the current stream.

Use the mv.impact.acquire.GenICam.DevFileStream.CanSeek property to determine whether the current instance supports seeking.

If offset is negative, the new position is required to precede the position specified by origin by the number of bytes specified by offset. If offset is zero (0), the new position is required to be the position specified by origin. If offset is positive, the new position is required to follow the position specified by origin by the number of bytes specified by offset.

Parameters
[in]offsetA byte offset relative to the origin parameter.
[in]originA value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.

◆ SetLength()

override void SetLength ( long value)
inline

Sets the length of the current stream.

Calling this function will raise a System.NotSupportedException exception as the mv.impact.acquire.GenICam.FileAccessControl.fileSize property is not writeable.

◆ Write()

override void Write ( byte[] buffer,
int offset,
int count )
inline

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Use the mv.impact.acquire.GenICam.DevFileStream.CanWrite property to determine whether the current instance supports writing.

If the write operation is successful, the position within the stream advances by the number of bytes written. If an exception occurs, the position within the stream remains unchanged.

Parameters
[in]bufferAn array of bytes. This method copies count bytes from buffer to the current stream.
[in]offsetThe zero-based byte offset in buffer at which to begin copying bytes to the current stream.
[in]countThe number of bytes to be written to the current stream.

Property Documentation

◆ CanRead

override bool CanRead
get

Gets a value indicating whether the current stream supports reading.

◆ CanSeek

override bool CanSeek
get

Gets a value indicating whether the current stream supports seeking.

If the device associated with this stream does not support the mv.impact.acquire.GenICam.FileAccessControl.fileAccessOffset property reading this property will raise a System.NotSupportedException exception.

◆ CanWrite

override bool CanWrite
get

Gets a value indicating whether the current stream supports writing.

◆ Length

override long Length
get

Gets the length in bytes of the stream.

If the device associated with this stream does not support the mv.impact.acquire.GenICam.FileAccessControl.fileSize property reading this property will raise a System.NotSupportedException exception.

◆ Position

override long Position
getset

Gets or sets the position within the current stream.

If the device associated with this stream does not support the mv.impact.acquire.GenICam.FileAccessControl.fileAccessOffset property accessing this property will raise a System.NotSupportedException exception.