Home Manual Reference Source Test

Function

Static Public Summary
public

addReferences(nodeId: NodeId, references: Object): Promise

Adds references to a node.

public

async approveToContinue(undefined: HookContext, error: Error): Promise

public

async askForConfirmation(undefined: undefined): Promise

public

callMethod(methodId: NodeId, args: Array<node-opcua~Variant>): *

Calls an OPC-UA method on the server.

public

callScript(scriptId: NodeId, parameters: Object): *

Calls a server script on the server.

public

async checkAtserver(context: HookContext): Promise

public

async checkServerscripts(undefined: HookContext): Promise

public

cleanup(exitCode: number, signal: string, uninstall: function()): boolean

Cleans up after the app ended with the specified code or signal.

public

createNode(nodeId: NodeId, options: Object): *

Creates a new Node on the server.

public

decodeVariant(buffer: Buffer, options: Object): *

Returns a node-opcua~Variant from a Buffer with the given dataType and arrayType.

public

delay(ms: *): *

Returns a promise that resolves after the given duration.

public

dest(path: string, options: Object): *

Creates a new WriteStream to write to path.

public

encodeVariant(variant: node-opcua~Variant): Buffer

Returns a buffer containing a node-opcua~Variants encoded value.

public

escapeForRegExp(source: string): *

Returns a string with all special regular expression characters escaped.

public

finishTask(): Promise<void>

Closes open sessions once a task is complete.

public

Returns the fs~Stats for a path.

public

Adds additional infomation to the error's message and rethows it.

public

async importTask(): Promise<void>

Imports all xml files needed for atscm usage.

public

Returns true for definition file paths.

public
public
public

performPull(nodes: NodeId[], options: Object): *

Pulls the given nodes from the server.

public

performPush(path: string, options: Object): *

Pushes the given path to the server.

public

pick(obj: Object, properties: Array<string>): Object

Picks some properties from an object and returns a new object containing these.

public

promisified(fn: *)

Wraps a function with an async callback in a promise.

public

async pull(options: Object): *

Pulls all nodes from atvise server.

public

async push(): *

Pushes AtviseFiles to atvise server.

public

async readNode(nodeId: NodeId): Promise<any>

Reads a single node's value.

public

reportProgress(task: Promise<any>, options: Object): *

Prints the progress of a task.

public

Switches keys and values in an object.

public

setupContext(undefined: Partial): HookContext

public

sortReferences(references: Object): *

Sorts the given references before they are persisted to disk.

public

src(path: string, options: SourceBrowserOptions): undefined

Starts a new source browser at the given path.

public

async updateFile(path: string, update: UpdateFn, encoding: undefined): Promise

public

async updateJson(path: string, update: UpdateFn): Promise

public

Checks it a given path holds a directory and returns it's fs~Stats if found.

public

A mixin that transforms a regular stream into a WaitingStream, which makes it wait for a node's dependencies to be transformed.

public

async watch(options: Object): Promise<{serverwatcher: Watcher, fileWatcher: sane~Watcher}, Error>

The gulp task invoced when running atscm watch.

public

writeNode(nodeId: NodeId, value: node-opcua~Variant): Promise<node-opcua~StatusCodes

Writes a single node's value.

Static Public

public addReferences(nodeId: NodeId, references: Object): Promise source

import {addReferences} from 'atscm/src/api.js'

Adds references to a node.

Params:

NameTypeAttributeDescription
nodeId NodeId

The node to add the references to.

references Object

The references to add.

Return:

Promise

Resolved once the references were added.

Example:

Add a simple reference
import { ReferenceTypeIds } from 'node-opcua/lib/opcua_node_ids';

addReferences('AGENT.DISPLAYS.Main', {
  [47]: ['VariableTypes.ATVISE.Display'],
  // equals:
  [ReferenceTypeIds.HasTypeDefinition]: ['VariableTypes.ATVISE.Display'],
})
  .then(() => console.log('Done!'))
  .catch(console.error);

public async approveToContinue(undefined: HookContext, error: Error): Promise source

import {approveToContinue} from 'atscm/src/hooks/check-atserver.ts'

Params:

NameTypeAttributeDescription
undefined HookContext
error Error

Return:

Promise

public async askForConfirmation(undefined: undefined): Promise source

import {askForConfirmation} from 'atscm/src/hooks/check-atserver.ts'

Params:

NameTypeAttributeDescription
undefined undefined

Return:

Promise

public callMethod(methodId: NodeId, args: Array<node-opcua~Variant>): * source

import {callMethod} from 'atscm/src/api.js'

Calls an OPC-UA method on the server.

Params:

NameTypeAttributeDescription
methodId NodeId

The method's id.

args Array<node-opcua~Variant>

The arguments to pass.

Return:

*

public callScript(scriptId: NodeId, parameters: Object): * source

import {callScript} from 'atscm/src/api.js'

Calls a server script on the server.

Params:

NameTypeAttributeDescription
scriptId NodeId

The script's id.

parameters Object

The parameters to pass, given as a map of Variants, like { name: { ... } }.

Return:

*

public async checkAtserver(context: HookContext): Promise source

import checkAtserver from 'atscm/src/hooks/check-atserver.ts'

Params:

NameTypeAttributeDescription
context HookContext

Return:

Promise

public async checkServerscripts(undefined: HookContext): Promise source

import checkServerscripts from 'atscm/src/hooks/check-serverscripts.ts'

Params:

NameTypeAttributeDescription
undefined HookContext

Return:

Promise

public cleanup(exitCode: number, signal: string, uninstall: function()): boolean source

import cleanup from 'atscm/src/util/cleanup.js'

Cleans up after the app ended with the specified code or signal.

Params:

NameTypeAttributeDescription
exitCode number
  • nullable: true

The exit code received.

signal string
  • nullable: true

The signal that triggered the exit.

uninstall function()

The uninstall script to run.

Return:

boolean

true if the process should continue exiting.

Test:

public createNode(nodeId: NodeId, options: Object): * source

import {createNode} from 'atscm/src/api.js'

Creates a new Node on the server.

Params:

NameTypeAttributeDescription
nodeId NodeId

The new node's id.

options Object

The options to use.

options.name string

The node's name.

options.parentNodeId NodeId
  • optional

The node's parent, defaults to the calculated parent (Test for Test.Child).

options.nodeClass node-opcua~NodeClass
  • optional

The node's class, defaults so node-opcua~NodeClass.Variable.

options.typeDefinition NodeId
  • optional

The node's type definition, must be provided for non-variable nodes.

options.modellingRule NodeId
  • optional

The node's modelling rule.

options.reference string
  • optional

Name of the type of the node's reference to it's parent.

options.value node-opcua~Variant
  • optional

The node's value, required for all variable nodes.

Return:

*

public decodeVariant(buffer: Buffer, options: Object): * source

import {decodeVariant} from 'atscm/src/lib/coding.js'

Returns a node-opcua~Variant from a Buffer with the given dataType and arrayType.

Params:

NameTypeAttributeDescription
buffer Buffer

The buffer to decode from.

options Object

The options to use.

options.dataType node-opcua~DataType

The data type to decode to.

options.arrayType node-opcua~VariantArrayType

The array type to decode to.

Return:

*

public delay(ms: *): * source

import {delay} from 'atscm/src/lib/helpers/async.ts'

Returns a promise that resolves after the given duration.

Params:

NameTypeAttributeDescription
ms *

Milliseconds to delay.

Return:

*

A promise resolved after the specified delay.

Test:

public dest(path: string, options: Object): * source

import dest from 'atscm/src/lib/gulp/dest.js'

Creates a new WriteStream to write to path.

Params:

NameTypeAttributeDescription
path string

The path to write to.

options Object
  • optional

The options to use. Passed to WriteStream#constructor.

Return:

*

public encodeVariant(variant: node-opcua~Variant): Buffer source

import {encodeVariant} from 'atscm/src/lib/coding.js'

Returns a buffer containing a node-opcua~Variants encoded value.

Params:

NameTypeAttributeDescription
variant node-opcua~Variant

The variant to encode.

Return:

Buffer

A buffer containing the encoded value.

public escapeForRegExp(source: string): * source

import {escapeForRegExp} from 'atscm/src/lib/regexp.ts'

Returns a string with all special regular expression characters escaped.

Params:

NameTypeAttributeDescription
source string

Return:

*

public finishTask(): Promise<void> source

import {finishTask} from 'atscm/src/lib/helpers/tasks.js'

Closes open sessions once a task is complete.

Return:

Promise<void>

Resolved once cleanup is complete.

public getStat(path: string): Promise<fs~Stats, Error> source

import {getStat} from 'atscm/src/util/fs.js'

Returns the fs~Stats for a path.

Params:

NameTypeAttributeDescription
path string

The path to look at.

Return:

Promise<fs~Stats, Error>

Fulfilled with the requested stats or rejected with the error that occurred.

Test:

public handleTaskError(error: Error) source

import {handleTaskError} from 'atscm/src/lib/helpers/tasks.js'

Adds additional infomation to the error's message and rethows it.

Params:

NameTypeAttributeDescription
error Error

The error that occured.

Throw:

Error

The extended error.

public async importTask(): Promise<void> source

import importTask from 'atscm/src/tasks/import.js'

Imports all xml files needed for atscm usage.

Return:

Promise<void>

The running task.

Test:

public isDefinitionFile(path: string): boolean source

import {isDefinitionFile} from 'atscm/src/lib/gulp/src.ts'

Returns true for definition file paths.

Params:

NameTypeAttributeDescription
path string

Return:

boolean

public async loadProjectRequirement(): Promise source

import {loadProjectRequirement} from 'atscm/src/hooks/check-atserver.ts'

Return:

Promise

public async loadRemoteVersion(): Promise source

import {loadRemoteVersion} from 'atscm/src/hooks/check-atserver.ts'

Return:

Promise

public performPull(nodes: NodeId[], options: Object): * source

import {performPull} from 'atscm/src/tasks/pull.js'

Pulls the given nodes from the server.

Params:

NameTypeAttributeDescription
nodes NodeId[]

The nodes to pull from the server.

options Object

Options passed to NodeBrowser.

Return:

*

public performPush(path: string, options: Object): * source

import {performPush} from 'atscm/src/tasks/push.js'

Pushes the given path to the server.

Params:

NameTypeAttributeDescription
path string

The local path to push.

options Object

Options passed to src.

Return:

*

public pick(obj: Object, properties: Array<string>): Object source

import {pick} from 'atscm/src/lib/helpers/Object.js'

Picks some properties from an object and returns a new object containing these.

Params:

NameTypeAttributeDescription
obj Object

The object to pick from.

properties Array<string>

Names of the properties to pick.

Return:

Object

The resulting object.

public promisified(fn: *) source

import {promisified} from 'atscm/src/lib/helpers/async.ts'

Wraps a function with an async callback in a promise.

Params:

NameTypeAttributeDescription
fn *

The function to promisify.

Test:

public async pull(options: Object): * source

import pull from 'atscm/src/tasks/pull.js'

Pulls all nodes from atvise server.

Params:

NameTypeAttributeDescription
options Object
  • optional

The options to use.

options.clean boolean
  • optional

If the source directory should be cleaned first.

Return:

*

Test:

public async push(): * source

import push from 'atscm/src/tasks/push.js'

Pushes AtviseFiles to atvise server.

Return:

*

Test:

public async readNode(nodeId: NodeId): Promise<any> source

import {readNode} from 'atscm/src/api.js'

Reads a single node's value.

Params:

NameTypeAttributeDescription
nodeId NodeId

The node to read.

Return:

Promise<any>

The read value.

public reportProgress(task: Promise<any>, options: Object): * source

import {reportProgress} from 'atscm/src/lib/helpers/log.js'

Prints the progress of a task.

Params:

NameTypeAttributeDescription
task Promise<any>

The task to print the progress for.

options Object

The options used.

options.getter function(): number

A function returning the current progress.

options.formatter function(value: number): string

A function returning a log message for the progress passed.

options.level string
  • optional
  • default: 'info'

The log level to use.

options.logResult boolean
  • optional
  • default: true

If the final progress should be printed.

Return:

*

Example:

A basic implementation
const task = doSomething(); // Returns a Promise

reportProgress(task, {
  getter: () => getTaskProgress(), // returns a number, e.g. 13 if 13 files have been written
  formatter: value => `${value} files written`,
})
 .then(result => { // Results get passed directly from `task`
   console.log(`The result is: ${result}`);
 })
 .catch(console.error) // which means you need error handling as well!

public reverse(obj: Object): Object source

import {reverse} from 'atscm/src/lib/helpers/Object.js'

Switches keys and values in an object. E.G.: { "a": 1 } becomes { 1: "a" }.

Params:

NameTypeAttributeDescription
obj Object

The object to reverse.

Return:

Object

The reversed object.

Test:

public setupContext(undefined: Partial): HookContext source

import {setupContext} from 'atscm/src/hooks/hooks.ts'

Params:

NameTypeAttributeDescription
undefined Partial

Return:

HookContext

public sortReferences(references: Object): * source

import {sortReferences} from 'atscm/src/lib/helpers/mapping.js'

Sorts the given references before they are persisted to disk.

Params:

NameTypeAttributeDescription
references Object

The references to be sorted.

Return:

*

public src(path: string, options: SourceBrowserOptions): undefined source

import src from 'atscm/src/lib/gulp/src.ts'

Starts a new source browser at the given path.

Params:

NameTypeAttributeDescription
path string
options SourceBrowserOptions

Return:

undefined

public async updateFile(path: string, update: UpdateFn, encoding: undefined): Promise source

import {updateFile} from 'atscm/src/lib/helpers/fs.ts'

Params:

NameTypeAttributeDescription
path string
update UpdateFn
encoding undefined

Return:

Promise

public async updateJson(path: string, update: UpdateFn): Promise source

import {updateJson} from 'atscm/src/lib/helpers/fs.ts'

Params:

NameTypeAttributeDescription
path string
update UpdateFn

Return:

Promise

public validateDirectoryExists(directoryPath: string): Promise<fs~Stats, Error> source

import {validateDirectoryExists} from 'atscm/src/util/fs.js'

Checks it a given path holds a directory and returns it's fs~Stats if found.

Params:

NameTypeAttributeDescription
directoryPath string

The path to look at.

Return:

Promise<fs~Stats, Error>

Fulfilled with the directory's stats or rejected with the error that occurred.

Test:

public waitForDependencies(Stream: QueueStream): Class<WaitingStream> source

import {waitForDependencies} from 'atscm/src/lib/server/WaitingStream.js'

A mixin that transforms a regular stream into a WaitingStream, which makes it wait for a node's dependencies to be transformed.

Params:

NameTypeAttributeDescription
Stream QueueStream

The node stream to inherit from.

Return:

Class<WaitingStream>

The resulting stream class.

Example:

Basic usage
import QueueStream from 'atscm/src/lib/server/QueueStream';
import { waitForDependencies } from 'atscm/src/lib/server/WaitingStream';

class MyWaitingStream extends waitForDependencies(QueueStream) {

  dependenciesFor(file) {
    return [
      // An array of node ids
    ];
  }

}

public async watch(options: Object): Promise<{serverwatcher: Watcher, fileWatcher: sane~Watcher}, Error> source

import watch from 'atscm/src/tasks/watch.js'

The gulp task invoced when running atscm watch.

Params:

NameTypeAttributeDescription
options Object

The options to pass to the watch task, see WatchTask#run for available options.

Return:

Promise<{serverwatcher: Watcher, fileWatcher: sane~Watcher}, Error>

Fulfilled once all watchers are set up and Browsersync was initialized.

Test:

public writeNode(nodeId: NodeId, value: node-opcua~Variant): Promise<node-opcua~StatusCodes source

import {writeNode} from 'atscm/src/api.js'

Writes a single node's value.

Params:

NameTypeAttributeDescription
nodeId NodeId

The node to write.

value node-opcua~Variant

The value to write.

Return:

Promise<node-opcua~StatusCodes

The operation status result.