This ObjectType defines a type for files. It is formally defined in Table C.1.

Table C.1 – FileType

Attribute

Value

BrowseName

FileType

IsAbstract

False

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Subtype of the BaseObjectType defined in 6.2

HasProperty

Variable

Size

UInt64

PropertyType

Mandatory

HasProperty

Variable

Writable

Boolean

PropertyType

Mandatory

HasProperty

Variable

UserWritable

Boolean

PropertyType

Mandatory

HasProperty

Variable

OpenCount

UInt16

PropertyType

Mandatory

HasProperty

Variable

MimeType

String

PropertyType

Optional

HasComponent

Method

Open

Defined in C.2.1

Mandatory

HasComponent

Method

Close

Defined in C.2.2

Mandatory

HasComponent

Method

Read

Defined in C.2.3

Mandatory

HasComponent

Method

Write

Defined in C.2.4

Mandatory

HasComponent

Method

GetPosition

Defined in C.2.5

Mandatory

HasComponent

Method

SetPosition

Defined in C.2.6

Mandatory

Size defines the size of the file in Bytes. When a file is opened for write the size might not be accurate.

Writable indicates whether the file is writable. It does not take any user access rights into account, i.e. although the file is writable this may be restricted to a certain user / user group. The Property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.

UserWritable indicates whether the file is writable taking user access rights into account. The Property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.

OpenCount indicates the number of currently valid file handles on the file.

The optional Property MimeType contains the media type of the file based on RFC 2046.

Note that all Methods on a file require a fileHandle, which is returned in the Open Method.

Open is used to open a file represented by an Object of FileType. When a client opens a file it gets a file handle that is valid while the session is open. Clients shall use the Close Method to release the handle when they do not need access to the file anymore. Clients can open the same file several times for read. A request to open for writing shall return Bad_NotWritable when the file is already opened. A request to open for reading shall return Bad_NotReadable when the file is already opened for writing.

Signature

Open(

[in] Byte mode

[out] UInt32 fileHandle

);

Argument

Description

mode

Indicates 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

Description

Read

0

The file is opened for reading. If this bit is not set the Read Method cannot be executed.

Write

1

The file is opened for writing. If this bit is not set the Write Method cannot be executed.

EraseExisting

2

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

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.

Reserved

4:7

Reserved for future use. Shall always be zero.

fileHandle

A handle for the file used in other method calls indicating not the file (this is done by the Object of the Method call) but the access request and thus the position in the file. The fileHandle is generated by the server and is unique for the Session. Clients cannot transfer the fileHandle to another Session but need to get a new fileHandle by calling the Open Method.

Method Result Codes (defined in Call Service)

Result Code

Description

Bad_NotReadable

See OPC 10000-4 for a general description. File might be locked and thus not readable.

Bad_NotWritable

See OPC 10000-4 for a general description.

Bad_InvalidState

See OPC 10000-4 for a general description. The file is locked and thus not writable.

Bad_InvalidArgument

See OPC 10000-4 for a general description. Mode setting is invalid.

Bad_NotFound

See OPC 10000-4 for a general description.

Bad_UnexpectedError

See OPC 10000-4 for a general description.

Table C.2 specifies the AddressSpace representation for the Open Method.

Table C.2 – Open Method AddressSpace Definition

Attribute

Value

BrowseName

Open

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

InputArguments

Argument[]

PropertyType

Mandatory

HasProperty

Variable

OutputArguments

Argument[]

PropertyType

Mandatory

Close is used to close a file represented by a FileType. When a client closes a file the handle becomes invalid.

Signature

Close(

[in] UInt32 fileHandle

);

Argument

Description

fileHandle

A handle indicating the access request and thus indirectly the position inside the file.

Method Result Codes (defined in Call Service)

Result Code

Description

Bad_InvalidArgument

See OPC 10000-4 for a general description. Invalid file handle in call.

Table C.3 specifies the AddressSpace representation for the Close Method.

Table C.3 – Close Method AddressSpace Definition

Attribute

Value

BrowseName

Close

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

InputArguments

Argument[]

PropertyType

Mandatory

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.

Signature

Read(

[in] UInt32 fileHandle

[in] Int32 length

[out] ByteString data

);

Argument

Description

fileHandle

A handle indicating the access request and thus indirectly the position inside the file.

Length

Defines the length in bytes that should be returned in data, starting from the current position of the file handle. 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.

Data

Contains the returned data of the file. If the ByteString is empty it indicates that the end of the file is reached.

Method Result Codes (defined in Call Service)

Result Code

Description

Bad_InvalidArgument

See OPC 10000-4 Invalid file handle in call or non-positive length.

Bad_UnexpectedError

See OPC 10000-4 for a general description.

Bad_InvalidState

See OPC 10000-4 for a general description. File was not opened for read access.

Table C.4 specifies the AddressSpace representation for the Read Method.

Table C.4 – Read Method AddressSpace Definition

Attribute

Value

BrowseName

Read

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

InputArguments

Argument[]

PropertyType

Mandatory

HasProperty

Variable

OutputArguments

Argument[]

PropertyType

Mandatory

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.

Signature

Write(

[in] UInt32 fileHandle

[in] ByteString data

);

Argument

Description

fileHandle

A handle indicating the access request and thus indirectly the position inside the file.

data

Contains 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 with the fileHandle.

Writing an empty or null ByteString returns a Good result code without any affect on the file.

Method Result Codes (defined in Call Service)

Result Code

Description

Bad_InvalidArgument

See OPC 10000-4 for a general description. Invalid file handle in call.

Bad_NotWritable

See OPC 10000-4 for a general description. File might be locked and thus not writable.

Bad_InvalidState

See OPC 10000-4 for a general description. File was not opened for write access.

Table C.5 specifies the AddressSpace representation for the Write Method.

Table C.5 – Write Method AddressSpace Definition

Attribute

Value

BrowseName

Write

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

InputArguments

Argument[]

PropertyType

Mandatory

GetPosition is used to provide the current position of the file handle.

Signature

GetPosition(

[in] UInt32 fileHandle

[out] UInt64 position

);

Argument

Description

fileHandle

A handle indicating the access request and thus indirectly the position inside the file.

Position

The position of the fileHandle in the file. If a Read or Write is called it starts at that position.

Method Result Codes (defined in Call Service)

Result Code

Description

Bad_InvalidArgument

See OPC 10000-4 for a general description. Invalid file handle in call.

Table C.6 specifies the AddressSpace representation for the GetPosition Method.

Table C.6 – GetPosition Method AddressSpace Definition

Attribute

Value

BrowseName

GetPosition

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

InputArguments

Argument[]

PropertyType

Mandatory

HasProperty

Variable

OutputArguments

Argument[]

PropertyType

Mandatory

SetPosition is used to set the current position of the file handle.

Signature

SetPosition(

[in] UInt32 fileHandle

[in] UInt64 position

);

Argument

Description

fileHandle

A handle indicating the access request and thus indirectly the position inside the file.

Position

The position to be set for the fileHandle in the file. If a 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.

Method Result Codes (defined in Call Service)

Result Code

Description

Bad_InvalidArgument

See OPC 10000-4 for a general description. Invalid file handle in call.

Table C.7 specifies the AddressSpace representation for the SetPosition Method.

Table C.7 – SetPosition Method AddressSpace Definition

Attribute

Value

BrowseName

SetPosition

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

InputArguments

Argument[]

PropertyType

Mandatory