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

WriteStream

Extends:

WaitingStream → WriteStream

A stream that writes all read AtviseFiles to their corresponding nodes on atvise server. The underlying TreeStream ensures the nodes are processed in an order that respects the parent-child relations between nodes. Nodes are created (if needed) before their children are processed.

Constructor Summary

Public Constructor
public

constructor(createStream: CreateNodeStream, addReferencesStream: AddReferencesStream, options: Object)

Creates a new write stream with the given CreateNodeStream and AddReferencesStream.

Member Summary

Private Members
private

The stream responsible for adding additional references.

private

If a node has to be created first, it's callback is added to this map.

Method Summary

Public Methods
public

Returns a files parent node and type definition.

public

processChunk(file: AtviseFile, handleErrors: function(err: Error, statusCode: node-opcua~StatusCodes, onSuccess: function))

Writes an AtviseFile to it's corresponding node on atvise server.

public

The error message to use when writing a file fails.

Private Methods
private

_createNode(file: AtviseFile, handleErrors: function(err: Error, statusCode: node-opcua~StatusCodes, onSuccess: function))

Pushes a node to the piped create stream and waits for the node to be created.

Public Constructors

public constructor(createStream: CreateNodeStream, addReferencesStream: AddReferencesStream, options: Object) source

Creates a new write stream with the given CreateNodeStream and AddReferencesStream. Implementer have to ensure this create stream is actually piped.

Params:

NameTypeAttributeDescription
createStream CreateNodeStream

The stream that handles node creations.

addReferencesStream AddReferencesStream

The stream that adds missing node references.

options Object

The options passed to the underlying TreeStream.

Private Members

private _addReferencesStream: AddReferencesStream source

The stream responsible for adding additional references.

private _createCallbacks: function(err: Error) source

If a node has to be created first, it's callback is added to this map.

Public Methods

public dependenciesFor(file: AtviseFile): NodeId[] source

Returns a files parent node and type definition.

Params:

NameTypeAttributeDescription
file AtviseFile

The file to check.

Return:

NodeId[]

The files dependencies.

public processChunk(file: AtviseFile, handleErrors: function(err: Error, statusCode: node-opcua~StatusCodes, onSuccess: function)) source

Writes an AtviseFile to it's corresponding node on atvise server.

Params:

NameTypeAttributeDescription
file AtviseFile

The file to write.

handleErrors function(err: Error, statusCode: node-opcua~StatusCodes, onSuccess: function)

The error handler to call. See QueueStream#processChunk for details.

Test:

public processErrorMessage(file: AtviseFile): string source

The error message to use when writing a file fails.

Params:

NameTypeAttributeDescription
file AtviseFile

The file being processed.

Return:

string

The error message to use.

Test:

Private Methods

private _createNode(file: AtviseFile, handleErrors: function(err: Error, statusCode: node-opcua~StatusCodes, onSuccess: function)) source

Pushes a node to the piped create stream and waits for the node to be created.

Params:

NameTypeAttributeDescription
file AtviseFile

The file create the node for.

handleErrors function(err: Error, statusCode: node-opcua~StatusCodes, onSuccess: function)

The error handler to call. See QueueStream#processChunk for details.