Home Manual Reference Source Test
import AtviseFile from 'atscm/src/lib/server/AtviseFile.js'
public class | source

AtviseFile

Extends:

vinyl~File → AtviseFile

An extension to vinyl~File providing some additional, atvise-related properties.

Test:

Static Method Summary

Static Public Methods
public static

decodeValue(buffer: Buffer, dataType: node-opcua~DataType, arrayType: node-opcua~VariantArrayType): *

Decodes a file's contents to a node's value.

public static

encodeValue(value: *, dataType: node-opcua~DataType, arrayType: node-opcua~VariantArrayType): Buffer

Encodes a node's value to file contents.

public static

Creates a new AtviseFile for the given ReadStream.ReadResult.

public static

As file mtimes do not support millisecond resolution these must be removed before storing files.

public static

Returns a storage path for a ReadStream.ReadResult.

public static

read(options: Object): Promise

Creates a new AtviseFile and reads it's contents.

Member Summary

Public Members
public get
public

contents: Buffer

The file's contents.

public get

Returns the decoded node value for create node serverscript.

public get

The file's node-opcua~DataType.

public get

true for files containing atvise displays.

public get

true for files containing atvise quick dynamics.

public get

true for reference config files (for example .index.htm.json).

public get

true for files containing atvise scripts.

public get

A file's browse and display name.

public get

The node's class.

public get

Returns the node id associated with the file.

public get

A file's parent's node id.

public get

The files's references.

public get

The file's type definition.

public set

value(newValue: *)

Sets the node value for the file.

public get

value: *

Returns the decoded node value for the file.

Private Members
private

The node's stored node-opcua~VariantArrayType.

private

The node's stored node-opcua~DataType.

private

A node's browse- and display name.

private

The node's class.

private

References the node holds: In most cases this will be a single entry for 'HasTypeDefinition'.

Method Summary

Public Methods
public

clone(options: Object): AtviseFile

Returns a new file with all attributes of the current file.

public

Computes a file's metadata if needed.

Private Methods
private

Static Public Methods

public static decodeValue(buffer: Buffer, dataType: node-opcua~DataType, arrayType: node-opcua~VariantArrayType): * source

Decodes a file's contents to a node's value.

Params:

NameTypeAttributeDescription
buffer Buffer

The file contents to decode.

dataType node-opcua~DataType

The node-opcua~DataType to decode the contents.

arrayType node-opcua~VariantArrayType

The files array type.

Return:

* (nullable: true)

The decoded node value or null.

Test:

public static encodeValue(value: *, dataType: node-opcua~DataType, arrayType: node-opcua~VariantArrayType): Buffer source

Encodes a node's value to file contents.

Params:

NameTypeAttributeDescription
value *

The value to encode.

dataType node-opcua~DataType

The node-opcua~DataType to encode the value for.

arrayType node-opcua~VariantArrayType

The files array type.

Return:

Buffer (nullable: true)

The encoded file contents or null.

Test:

public static fromReadResult(readResult: ReadStream.ReadResult): AtviseFile source

Creates a new AtviseFile for the given ReadStream.ReadResult.

Params:

NameTypeAttributeDescription
readResult ReadStream.ReadResult

The read result to create the file for.

Return:

AtviseFile

The resulting file.

Test:

public static normalizeMtime(date: Date): Date source

As file mtimes do not support millisecond resolution these must be removed before storing files.

Params:

NameTypeAttributeDescription
date Date

The original mtime.

Return:

Date

The normalized mtime.

Test:

public static pathForReadResult(readResult: ReadStream.ReadResult): * source

Returns a storage path for a ReadStream.ReadResult.

Params:

NameTypeAttributeDescription
readResult ReadStream.ReadResult

The read result to get a path for.

Return:

*

Test:

public static read(options: Object): Promise source

Creates a new AtviseFile and reads it's contents.

Params:

NameTypeAttributeDescription
options Object

See vinyl~File for available options.

Return:

Promise

Resolved with the new file of rejected with the error that occured while trying to read it's path.

Test:

Public Members

public contents: Buffer source

The file's contents.

public get createNodeValue: * source

Returns the decoded node value for create node serverscript.

public get isDisplay: boolean source

true for files containing atvise displays.

Test:

public get isQuickDynamic: boolean source

true for files containing atvise quick dynamics.

Test:

public get isReferenceConfig: boolean source

true for reference config files (for example .index.htm.json).

public get isScript: boolean source

true for files containing atvise scripts.

Test:

public get name: string source

A file's browse and display name.

public get nodeClass: node-opcua~NodeClass source

The node's class.

public get nodeId: NodeId source

Returns the node id associated with the file.

Test:

public get parentNodeId: NodeId source

A file's parent's node id.

public get references: Map<string, NodeId|NodeId[]> source

The files's references.

public get typeDefinition: node-opcua~NodeId source

The file's type definition.

Test:

public set value(newValue: *) source

Sets the node value for the file.

public get value: * source

Returns the decoded node value for the file.

Private Members

private _arrayType: node-opcua~VariantArrayType source

The node's stored node-opcua~VariantArrayType.

private _dataType: node-opcua~DataType source

The node's stored node-opcua~DataType.

private _name: string source

A node's browse- and display name.

private _nodeClass: node-opcua~NodeClass source

The node's class.

private _references: Map<String, NodeId[]> source

References the node holds: In most cases this will be a single entry for 'HasTypeDefinition'.

Public Methods

public clone(options: Object): AtviseFile source

Returns a new file with all attributes of the current file.

Params:

NameTypeAttributeDescription
options Object

See the vinyl~File docs for all options available.

Return:

AtviseFile

The cloned file.

Test:

See:

public getMetadata(): AtviseFile source

Computes a file's metadata if needed.

Return:

AtviseFile

The file.

Private Methods

private _getMetadata() source

Recalculates AtviseFile#dataType, AtviseFile#arrayType and AtviseFile#typeDefinition. Never call this method directly..

Test: