C++ Based OPC UA Client/Server SDK  1.5.5.355
UaClientSdk::UaFileObject Class Reference

This class is a proxy class for access to a FileType Object in the server. More...

#include <uafileobject.h>

Inherited by UaClientSdk::InternalTrustList.

Public Member Functions

 UaFileObject (UaSession *pSession)
 Constructs a File object used to access a FileType object on the server. More...
 
virtual ~UaFileObject ()
 Destroys the File object.
 
void attachToOpenFile (const UaNodeId &fileObjectNodeId, OpcUa_UInt32 fileHandle)
 Used to attach the file object to an already open a file in the server. More...
 
UaStatus open (ServiceSettings &serviceSettings, const UaNodeId &fileObjectNodeId, OpcUa_Byte mode)
 Used to open a file represented by an Object of FileType. More...
 
UaStatus close (ServiceSettings &serviceSettings)
 Used to close the file. More...
 
UaStatus read (ServiceSettings &serviceSettings, OpcUa_Int32 length, UaByteString &data)
 Used to read from the file. More...
 
UaStatus write (ServiceSettings &serviceSettings, const UaByteString &data)
 Used to write to the file. More...
 
UaStatus getPosition (ServiceSettings &serviceSettings, OpcUa_UInt64 &position)
 Used to get the position in the file. More...
 
UaStatus setPosition (ServiceSettings &serviceSettings, OpcUa_UInt64 position)
 Used to set the position in the file. More...
 
OpcUa_UInt32 fileHandle () const
 Returns the file open handle for the file object.
 
UaNodeId fileObjectNodeId () const
 Returns the NodeId for the server side file object.
 

Detailed Description

This class is a proxy class for access to a FileType Object in the server.

Constructor & Destructor Documentation

UaClientSdk::UaFileObject::UaFileObject ( UaSession pSession)

Constructs a File object used to access a FileType object on the server.

A UaSession connected to the server must be passed in. Some of the methods on the server may not require a special user, however most of the methods require special Client’s user credentials. Therefore it is required to configure the UaSession object with the right user token.

Parameters
[in]pSessionThe UaSession object used to communicate with the server

Member Function Documentation

void UaClientSdk::UaFileObject::attachToOpenFile ( const UaNodeId fileObjectNodeId,
OpcUa_UInt32  fileHandle 
)

Used to attach the file object to an already open a file in the server.

This method can be used to attach to a file opened during creation of the file on the server with the FileDirectoryType.

Parameters
[in]fileObjectNodeIdNodeId of the FileType object of the server
[in]fileHandleFile handle for the opened file in the server
UaStatus UaClientSdk::UaFileObject::close ( ServiceSettings serviceSettings)

Used to close the file.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details.
UaStatus UaClientSdk::UaFileObject::getPosition ( ServiceSettings serviceSettings,
OpcUa_UInt64 &  position 
)

Used to get the position in the file.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details.
[in]positionThe position of this proxy object in the file.
If read or write is called, it starts at that position.
UaStatus UaClientSdk::UaFileObject::open ( ServiceSettings serviceSettings,
const UaNodeId fileObjectNodeId,
OpcUa_Byte  mode 
)

Used to open a file represented by an Object of FileType.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details.
[in]fileObjectNodeIdNodeId of the FileType object of the server
modeIndicates whether the file should be opened only for read operations or for read and write operations and where the initial position is set.
The mode is an 8-bit unsigned integer used as bit mask with the structure defined in the following table:
Field Bit Value Description
Read 0 1 The file is opened for reading. If this bit is not set the read Method cannot be executed.
Write 1 2 The file is opened for writing. If this bit is not set the write Method cannot be executed.
EraseExisting 2 4 This bit can only be set if the file is opened for writing (Write bit is set). The existing content of the file is erased and an empty file is provided.
Append 3 8 When the Append bit is set the file is opened at end of the file, otherwise at begin of the file. The setPosition Method can be used to change the position.
UaStatus UaClientSdk::UaFileObject::read ( ServiceSettings serviceSettings,
OpcUa_Int32  length,
UaByteString data 
)

Used to read from the file.

Read is used to read a part of the file starting from the current file position. The file position is advanced by the number of bytes read.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details.
[in]lengthDefines the length in bytes that should be returned in data, starting from the current position of the file object. If the end of file is reached all data until the end of the file is returned. The Server is allowed to return less data than specified length. Only positive values are allowed.
[out]dataContains the returned data of the file. If the ByteString is empty it indicates that the end of the file is reached.
UaStatus UaClientSdk::UaFileObject::setPosition ( ServiceSettings serviceSettings,
OpcUa_UInt64  position 
)

Used to set the position in the file.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details.
[in]positionThe position to be set for this proxy object in the file.
If read or write is called, it starts at that position. If the position is higher than the file size, the position is set to the end of the file.
UaStatus UaClientSdk::UaFileObject::write ( ServiceSettings serviceSettings,
const UaByteString data 
)

Used to write to the file.

Write is used to write a part of the file starting from the current file position. The file position is advanced by the number of bytes written.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details.
[in]dataContains the data to be written at the position of the file. It is server-dependent whether the written data are persistently stored if the session is ended without calling the close Method.

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