UA Bundle SDK .NET  2.3.3.343
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Modules Pages
UnifiedAutomation.UaServer.FileModel Class Reference

An object that represents a file that can be accessed via the server. More...

Inherits UnifiedAutomation.UaServer.BaseObjectModel, UnifiedAutomation.UaServer.IMethodDispatcher, UnifiedAutomation.UaServer.IFileMethods, and IDisposable.

Inherited by UnifiedAutomation.UaServer.AddressSpaceFileModel.

Classes

class  OpenFileHandle
 Caches information about an open file handle. More...
 

Public Member Functions

void Dispose ()
 Frees any unmanaged resources. More...
 
virtual StatusCode Open (RequestContext context, FileModel model, byte mode, out uint fileHandle)
 Opens the specified file. More...
 
virtual StatusCode Close (RequestContext context, FileModel model, uint fileHandle)
 Closes the specified file. More...
 
virtual StatusCode Read (RequestContext context, FileModel model, uint fileHandle, int length, out byte[] data)
 Reads the specified file. More...
 
virtual StatusCode Write (RequestContext context, FileModel model, uint fileHandle, byte[] data)
 Writes the specified file. More...
 
virtual StatusCode SetPosition (RequestContext context, FileModel model, uint fileHandle, ulong position)
 Sets the current position of the file. More...
 
virtual StatusCode GetPosition (RequestContext context, FileModel model, uint fileHandle, out ulong position)
 Returns the current position of the file. More...
 
 FileModel ()
 Initializes a new instance of the FileModel class. More...
 
 FileModel (FileModel template)
 Initializes a new instance of the FileModel class. More...
 
virtual CallMethodEventHandler GetMethodDispatcher (RequestContext context, NodeId objectId, NodeId methodId)
 Gets the method dispatcher. More...
 
virtual StatusCode DispatchMethod (RequestContext context, MethodHandle methodHandle, IList< Variant > inputArguments, List< StatusCode > inputArgumentResults, List< Variant > outputArguments)
 Dispatches the method. More...
 
- Public Member Functions inherited from UnifiedAutomation.UaServer.BaseObjectModel
 BaseObjectModel ()
 Initializes a new instance of the BaseObjectModel class. More...
 
 BaseObjectModel (BaseObjectModel template)
 Initializes a new instance of the BaseObjectModel class. More...
 
- Public Member Functions inherited from UnifiedAutomation.UaServer.ModelControllerBase
virtual ModelHandle GetModelHandle (StringTable namespaceUris, object instance)
 Gets the metadata handle. More...
 
virtual DataValue GetValue (IMapperContext context, ModelMapping mapping)
 Gets the value associated with the mapping. More...
 
virtual bool SetValue (IMapperContext context, ModelMapping mapping, DataValue value)
 Sets the value associated with the mapping. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 An overrideable version of the Dispose. More...
 
void CleanupExpiredHandles ()
 Cleans up any expired handles. More...
 
StatusCode OpenStream (OpenFileHandle handle)
 Opens a stream for the file referenced by FileOnDisk. More...
 
OpenFileHandle FindHandle (RequestContext context, uint fileHandle)
 Finds the handle. More...
 
void SaveHandle (OpenFileHandle handle)
 Assigns a unique id to the handle and saves the handle. More...
 
void CloseHandle (OpenFileHandle handle)
 Closes the stream associated with the handle and sets the size of the File object. More...
 

Protected Attributes

object Lock = new object()
 An object used to synchronize access to the file object. More...
 

Properties

FileInfo FileOnDisk [get, set]
 Gets or sets the disk file which can be accessed via the file object. More...
 
int MaxFileSize [get, set]
 Gets or sets the maximum size of the file in bytes. More...
 
uint NextFileHandle [get, set]
 Gets or sets the next file handle to assign. More...
 
ushort OpenCount [get, set]
 Gets or sets the OpenCount More...
 
ulong Size [get, set]
 Gets or sets the Size More...
 
bool UserWritable [get, set]
 Gets or sets the UserWritable More...
 
bool Writable [get, set]
 Gets or sets the Writable More...
 
IFileMethods FileMethods [get, set]
 Gets or sets the File methods. More...
 
- Properties inherited from UnifiedAutomation.UaServer.ModelControllerBase
ModelHandle ModelHandle [get, set]
 Gets or sets the metadata handle. More...
 
object UserData [get, set]
 Gets or sets the user data. More...
 

Events

EventHandler< OpenFileEventArgsOpenRequested
 Occurs when the file is opened. More...
 
EventHandler< CloseFileEventArgsCloseRequested
 Occurs when the file is closed. More...
 

Detailed Description

An object that represents a file that can be accessed via the server.

This ObjectType defines a type for files.

This class implements support for the FileType object on the server side.

Any number of open read handles is allowed but only one handle may be open for write at a time. Subclasses may be used to replace the FileStream with other abstract stream implementations. There are two events (OpenRequested and CloseRequested) which can be used to determine permissions.

See FileModel Example for example code.

Note that all Methods on a file require a FileHandle, which is returned in the UnifiedAutomation.UaServer.IFileMethods.Open Method.

Constructor & Destructor Documentation

UnifiedAutomation.UaServer.FileModel.FileModel ( )
inline

Initializes a new instance of the FileModel class.

UnifiedAutomation.UaServer.FileModel.FileModel ( FileModel  template)
inline

Initializes a new instance of the FileModel class.

Parameters
templateThe template.

Member Function Documentation

void UnifiedAutomation.UaServer.FileModel.CleanupExpiredHandles ( )
inlineprotected

Cleans up any expired handles.

virtual StatusCode UnifiedAutomation.UaServer.FileModel.Close ( RequestContext  context,
FileModel  model,
uint  fileHandle 
)
inlinevirtual

Closes the specified file.

Parameters
contextThe context.
modelThe file model.
fileHandleThe file handle returned by the Open method.
Returns
The result of the operation.

Implements UnifiedAutomation.UaServer.IFileMethods.

void UnifiedAutomation.UaServer.FileModel.CloseHandle ( OpenFileHandle  handle)
inlineprotected

Closes the stream associated with the handle and sets the size of the File object.

Parameters
handleThe handle.
virtual StatusCode UnifiedAutomation.UaServer.FileModel.DispatchMethod ( RequestContext  context,
MethodHandle  methodHandle,
IList< Variant inputArguments,
List< StatusCode inputArgumentResults,
List< Variant outputArguments 
)
inlinevirtual

Dispatches the method.

Parameters
contextThe context.
methodHandleThe method handle.
inputArgumentsThe input arguments.
inputArgumentResultsThe input argument results.
outputArgumentsThe output arguments.
Returns

Reimplemented in UnifiedAutomation.UaServer.AddressSpaceFileModel.

void UnifiedAutomation.UaServer.FileModel.Dispose ( )
inline

Frees any unmanaged resources.

virtual void UnifiedAutomation.UaServer.FileModel.Dispose ( bool  disposing)
inlineprotectedvirtual

An overrideable version of the Dispose.

OpenFileHandle UnifiedAutomation.UaServer.FileModel.FindHandle ( RequestContext  context,
uint  fileHandle 
)
inlineprotected

Finds the handle.

Parameters
contextThe context.
fileHandleThe file handle.
Returns
An open handle.
virtual CallMethodEventHandler UnifiedAutomation.UaServer.FileModel.GetMethodDispatcher ( RequestContext  context,
NodeId  objectId,
NodeId  methodId 
)
inlinevirtual

Gets the method dispatcher.

Parameters
contextThe context.
objectIdThe object id.
methodIdThe method id.
Returns

Implements UnifiedAutomation.UaServer.IMethodDispatcher.

Reimplemented in UnifiedAutomation.UaServer.AddressSpaceFileModel.

virtual StatusCode UnifiedAutomation.UaServer.FileModel.GetPosition ( RequestContext  context,
FileModel  model,
uint  fileHandle,
out ulong  position 
)
inlinevirtual

Returns the current position of the file.

Parameters
contextThe context.
modelThe file model.
fileHandleThe file handle returned by the Open method (see UnifiedAutomation.UaServer.IFileMethods.GetPosition).
positionThe current position (see UnifiedAutomation.UaServer.IFileMethods.GetPosition).
Returns
The result of the operation.

Implements UnifiedAutomation.UaServer.IFileMethods.

virtual StatusCode UnifiedAutomation.UaServer.FileModel.Open ( RequestContext  context,
FileModel  model,
byte  mode,
out uint  fileHandle 
)
inlinevirtual

Opens the specified file.

See UnifiedAutomation.UaServer.IFileMethods.Open for more information.

Parameters
contextThe context.
modelThe model.
modeThe file access mode (see UnifiedAutomation.UaServer.IFileMethods.Open). The mode is described in the FileAccessModes enumeration.
fileHandleThe file handle (see UnifiedAutomation.UaServer.IFileMethods.Open). The file handle has to be used for other methods of the FileModel like Close or Read.
Returns
The result of the operation.

Implements UnifiedAutomation.UaServer.IFileMethods.

StatusCode UnifiedAutomation.UaServer.FileModel.OpenStream ( OpenFileHandle  handle)
inlineprotected

Opens a stream for the file referenced by FileOnDisk.

Parameters
handleThe handle.
Returns
If FileOnDisk is null, a memory stream is created.
virtual StatusCode UnifiedAutomation.UaServer.FileModel.Read ( RequestContext  context,
FileModel  model,
uint  fileHandle,
int  length,
out byte[]  data 
)
inlinevirtual

Reads the specified file.

Parameters
contextThe context.
modelThe model.
fileHandleThe file handle returned by the Open method (see UnifiedAutomation.UaServer.IFileMethods.Read).
lengthThe length (see UnifiedAutomation.UaServer.IFileMethods.Read).
dataThe returned data.
Returns
The result of the operation.

Implements UnifiedAutomation.UaServer.IFileMethods.

void UnifiedAutomation.UaServer.FileModel.SaveHandle ( OpenFileHandle  handle)
inlineprotected

Assigns a unique id to the handle and saves the handle.

Parameters
handleThe handle.
virtual StatusCode UnifiedAutomation.UaServer.FileModel.SetPosition ( RequestContext  context,
FileModel  model,
uint  fileHandle,
ulong  position 
)
inlinevirtual

Sets the current position of the file.

Parameters
contextThe context.
modelThe file model.
fileHandleThe file handle returned by the Open method (see UnifiedAutomation.UaServer.IFileMethods.SetPosition).
positionThe new position (see UnifiedAutomation.UaServer.IFileMethods.SetPosition).
Returns
The result of the operation.

Implements UnifiedAutomation.UaServer.IFileMethods.

virtual StatusCode UnifiedAutomation.UaServer.FileModel.Write ( RequestContext  context,
FileModel  model,
uint  fileHandle,
byte[]  data 
)
inlinevirtual

Writes the specified file.

See UnifiedAutomation.UaServer.IFileMethods.Write for more information.

Parameters
contextThe context.
modelThe file model.
fileHandleThe file handle returned by the Open method (see UnifiedAutomation.UaServer.IFileMethods.Write).
dataThe data to write (see UnifiedAutomation.UaServer.IFileMethods.Write).
Returns
The result of the operation.

Implements UnifiedAutomation.UaServer.IFileMethods.

Member Data Documentation

object UnifiedAutomation.UaServer.FileModel.Lock = new object()
protected

An object used to synchronize access to the file object.

Property Documentation

IFileMethods UnifiedAutomation.UaServer.FileModel.FileMethods
getset

Gets or sets the File methods.

The File methods.

FileInfo UnifiedAutomation.UaServer.FileModel.FileOnDisk
getset

Gets or sets the disk file which can be accessed via the file object.

This should be null if a subclass implements a more complex I/O model.

int UnifiedAutomation.UaServer.FileModel.MaxFileSize
getset

Gets or sets the maximum size of the file in bytes.

uint UnifiedAutomation.UaServer.FileModel.NextFileHandle
getsetprotected

Gets or sets the next file handle to assign.

ushort UnifiedAutomation.UaServer.FileModel.OpenCount
getset

Gets or sets the OpenCount

Indicates the number of currently valid file handles on the file.

ulong UnifiedAutomation.UaServer.FileModel.Size
getset

Gets or sets the Size

Defines the size of the file in Bytes.

When a file is opened for writing and the FileHandle is still valid, the size might not be accurate.

bool UnifiedAutomation.UaServer.FileModel.UserWritable
getset

Gets or sets the 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.

bool UnifiedAutomation.UaServer.FileModel.Writable
getset

Gets or sets the 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.

Event Documentation

EventHandler<CloseFileEventArgs> UnifiedAutomation.UaServer.FileModel.CloseRequested

Occurs when the file is closed.

EventHandler<OpenFileEventArgs> UnifiedAutomation.UaServer.FileModel.OpenRequested

Occurs when the file is opened.


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