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 2 specifies the AddressSpace representation for the Open Method.

Table 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

Conformance Units

Base Info FileType Base