API Reference

# readNode(nodeId)

Reads a single node's value.

# writeNode(nodeId, value)

Writes a single node's value.

# callMethod(methodId, args)

Calls an OPC-UA method on the server.

# callScript(scriptId, parameters)

Calls a server script on the server.

# createNode(nodeId, options, options.name, options.parentNodeId, options.nodeClass, options.typeDefinition, options.modellingRule, options.reference, options.value)

Creates a new Node on the server.

# addReferences(nodeId, references)

Adds references to a node.

# path

The path to the project's configuration file.

# ProjectConfig

The current project's configuration, with overrides (through ATSCM_PROJECT__ env vars) already handled.

Hide members

static get host

The atvise server's host. Can be overridden with the ATSCM_PROJECT__HOST env variable.

static get port

The atvise server ports to use.

static get login

The login to use. Return false if no login is required (default).

static get sourceNodeRegExp

A regular expression matching all source nodes.

static get ignoredNodesRegExp

A regular expression matching all ignored nodes.

static isExternal(id)

Returns true for all external (not in {@link Atviseproject.nodes} or ignored by {@link Atviseproject.ignoreNodes}).

static get timeout

The connection timeout, in milliseconds. Can be overridden with the ATSCM_PROJECT__TIMEOUT env variable.

# loadProjectRequirement()

# loadRemoteVersion()

# askForConfirmation(undefined)

# approveToContinue(undefined, error)

# checkAtserver(context)

# checkServerscripts(undefined)

# setupContext(undefined)

# InitTask

The action run when running "atscm init".

Hide members

static filesToHandle(langId)

Returns the globs of the processed files for the given config lanugage.

static run(options)

Runs the task with the given options.

# ConfigLangs

A map providing dirnames for config langs

# InitOptions

Options available for the "atscm init" command.

# InitOptionsAsArray

{@link InitOptions}, exported as an array. Required to run {@link Inquirer}.

# InitOptionsValidator

A static class containing validators for the options used when running "atscm init".

Hide members

static name(value)

Validates a project name to be a valid npm package name.

# encodeVariant(variant)

Returns a buffer containing a {@link node-opcua~Variant}s encoded value.

# decodeVariant(buffer, options, options.dataType, options.arrayType)

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

# Atviseproject

An atscm project's configuration.

Hide members

static get host

The atvise-server's host. Defaults to localhost.

static get port

The atvise-server ports to use.

static get login

The login to use. Return false if no login is required (default).

static get xmlTransformerOptions
static get useTransformers

The transformers to use in this project. Returns a {@link DisplayTransformer}, a {@link ScriptTransformer} and a {@link NewlinesTransformer} by default.

static get nodes

The atvise-server nodes that atscm should sync. Defaults to the nodes AGENT, SYSTEM, ObjectTypes.PROJECT* and VariableTypes.PROJECT.

static get nodesToWatch

The atvise-server nodes to watch in the corresponding tasks. Defaults to all nodes containing displays.

static get EditorRelatedNodes

An array of editor related node ids. They should be ignored in a atscm project.

static get ServerRelatedNodes

An array of server related node ids. They should be ignored in a atscm project as they are read-only.

static get AtscmRelatedNodes

Server nodes atscm manages itself. These include the serverscripts used during pull/push for example.

static get ignoreNodes

These nodes (and their subnodes, if any) will be ignored by atscm. Defaults to {@link Atviseproject.EditorRelatedNodes} combined with {@link Atviseproject.ServerRelatedNodes}.

static inspect()

Returns an object containing the properties to inspect.

static get vcs

The version control system to optimize tasks for.

static get preserveSortOrderNodes

If atvise builder sort order nodes should be stored.

static get timeout

The connection timeout, in milliseconds.

static get removeBuilderRefs

Remove atv:refpx and atv:refpy attributes from XML to minimize diffs between pulls. This will eventually default to true in a future atscm version.

static get sortXMLAttributes

Sort XML attributes to minimize diffs between pulls. This will eventually default to true in a future atscm version.

# ImportStream

A stream that imports xml files in parallel.

Hide members

get methodId

Id of the importNodes OPC-UA method.

inputArguments(file)

Returns the arguments the importNodes needs to be called with for the given file.

processErrorMessage(file)

Returns an error message specifically for the given file.

handleOutputArguments(file, outputArguments, callback)

Checks if the import succeeded and calls callback with an error otherwise.

# PullStream

A stream that transforms read {@link ReadStream.ReadResult}s and stores the on the filesystem.

Hide members

constructor(readStream)

Creates a new PullStream based on a stream that writes {@link ReadStream.ReadResult} which may be an instance of {@link ReadStream}.

# PushStream

A stream that transforms read {@link vinyl~File}s and pushes them to atvise server.

Hide members

constructor(srcStream)

Creates a new PushSteam based on a source file stream.

# renameConfigPath

Relative path to the rename file.

# WriteStream

A stream that writes {@link Node}s to the file system.

Hide members

constructor(options, options.path, options.base, options.cleanRenameConfig)

Creates a new WriteStream.

get isDestroyed

If the stream is destroyed.

writeAsync(node)
writeRenamefile()

Writes the updated rename config to disk.

# dest(path, options)

Creates a new {@link WriteStream} to write to path.

# FileNode

A node returned by the {@link SourceStream}.

Hide members

valueSoFar

The node's value (may be incomplete, use {@link FileNode#value} to ensure).

specialId

The id stored in the definition file

setRawValue(value)
hasRawValue()
get stringValue

A node's raw value, decoded into a string.

valueIsComplete()
get variantValue

A node's {@link node-opcua~Variant} value.

get value

# isDefinitionFile(path)

Returns true for definition file paths.

# SourceBrowser

Browses the local file system for nodes.

Hide members

constructor(options, options.handleNode, options.readNodeFile)

Sets up a new browser.

get atserverVersion
browse(path, options)

Starts the browser at the given path.

processPath(options)

Enqueues a {@link SourceBrowser#_processPath} call with the given options.

readNode(undefined)

Can be called by transformers to read this path before finishing it's parent nodes.

# src(path, options)

Starts a new source browser at the given path.

# reverse(obj)

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

# pick(obj, properties)

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

# delay(ms)

Returns a promise that resolves after the given duration.

# promisified(fn)

Wraps a function with an async callback in a promise.

# updateFile(path, update, encoding)

# updateJson(path, update)

# reportProgress(task, options, options.getter, options.formatter, options.level, options.logResult)

Prints the progress of a task.

# sortReferences(references)

Sorts the given references before they are persisted to disk.

# handleTaskError(error)

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

# finishTask()

Closes open sessions once a task is complete.

# InitOption

An option the "atscm init" command handles. TODO: Support function values for name, message, default, choices...

Hide members

constructor(messageOrOptions, messageOrOptions.type, messageOrOptions.message, messageOrOptions.default, messageOrOptions.validate, messageOrOptions.choices, messageOrOptions.when, defaultOrUndefined)

Creates a new option based either on a message and (optionally) a default value or some options.

type

The option's {@link inquirer~PromptType}. Defaults to 'input'.

message

The option's message. A '?' sign is added automatically.

default

The default value to use.

choices

The choices available. Applies to list types only.

validate

Validates the user input for this option.

when

A function or boolean that indicates weather or not to prompt this option.

static get DefaultType

The default {@link inquirer~PromptType} to use. Equals 'input'.

# ReferenceTypeIds

References type ids.

# ReferenceTypeNames

Names for references.

# Node

The main model class.

Hide members

addReference(type, id)

Adds a new reference.

constructor(options, options.name, options.parent, options.nodeClass)

Creates a new node.

references

The node's references.

parent
nodeClass
get parentResolvesMetadata

If the parent resolves metadata (for example: split transformer source files).

markAsResolved(key)
isResolved(key)
setReferences(type, ids)
markReferenceAsResolved(name, value)
markAllReferencesAsResolved(name)
hasUnresolvedReference(name)
get filePath

The node's file path.

get nodeId

The node's id.

get typeDefinition

The node's type definition if given.

get modellingRule

The node's modellingRule if given.

hasTypeDefinition(typeDefName)

Returns true if the node has the given type definition.

get hasUnresolvedMetadata

true at the moment.

get metadata

The metadata to store in the node's definition file.

createChild(undefined)

Creates a new child node.

get dataType

The node's data type.

get arrayType

The node's array type.

get isVariable

If the node is a variable.

isVariableNode()
get isDisplay

If the node is an object display.

get isScript

If the node is a serverside script.

get isQuickDynamic

If the node is a quickdynamic.

get isDisplayScript

If the node is a display script.

# ServerNode

A node during a pull.

Hide members

fileName

# SourceNode

A node during a push.

Hide members

idName
get name

The node's name.

renameTo(name)

Renames a node.

# NodeId

A wrapper around {@link node-opcua~NodeId}.

Hide members

constructor(typeOrValue, value, namespace)

Creates a new NodeId. Can be called in multiple ways:

  • with a {@link node-opcua~NodeIdType}, a value and a namespace (defaults to 0),
  • with a value only (type will be taken from it, namespace defaults to 1) or
  • with a {@link NodeId}s string representation (for example ns=1;s=AGENT.DISPLAYS).
static fromFilePath(path)

Creates a new NodeId based on a file path.

get filePath

The node id's value, encoded to a file path.

get parent

The parent node id, or null.

isChildOf(parent)

Checks if the node is a child of another.

get browseName

The node id's browsename as string.

inspect(depth, options)

Returns a string in the format "namespace value" that is printed when inspecting the NodeId using {@link util~inspect}.

# ReverseReferenceTypeIds

Reverse map of {@link node-opcua~ReferenceTypeId}s.

# specialChars

Special characters in regular expressions.

# specialCharsRegExp

A regular expression that matches all special characters in regular expressions.

# escapeForRegExp(source)

Returns a string with all special regular expression characters escaped.

# AddReferencesStream

A stream that adds non-standard references to nodes when pushed.

Hide members

constructor(options)

Creates a new stream for adding references to pushed nodes.

referencesToAdd(file)

Returns the references that need to be set for a file.

dependenciesFor(file)

Returns the referenced nodes that should be processed before the given file.

get scriptId

Id of the CreateNode script added with atscm import.

scriptParameters(file)

The options required to add references to the node for the given file.

processErrorMessage(file)

Prints an error message telling that adding one or more references failed.

handleOutputArguments(file, outArgs, callback)

Handles the results of a script call.

# ExtensionForDataType

A map providing shorter extensions for data types

# DataTypeForExtension

A map providing data types for shorter extensions (Reverse of {@link DataTypeForExtension}).

  • @type {Map<String, node-opcua~DataType>}

# AtviseFile

An extension to {@link vinyl~File} providing some additional, atvise-related properties.

Hide members

static pathForReadResult(readResult)

Returns a storage path for a {@link ReadStream.ReadResult}.

static encodeValue(value, dataType, arrayType)

Encodes a node's value to file contents.

static decodeValue(buffer, dataType, arrayType)

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

static normalizeMtime(date)

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

static fromReadResult(readResult)

Creates a new {@link AtviseFile} for the given {@link ReadStream.ReadResult}.

getMetadata()

Computes a file's metadata if needed.

get nodeClass

The node's class.

get dataType

The file's {@link node-opcua~DataType}.

get arrayType

The file's {@link node-opcua~VariantArrayType}.

get references

The files's references.

get typeDefinition

The file's type definition.

get isReferenceConfig

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

get isDisplay

true for files containing atvise displays.

get isScript

true for files containing atvise scripts.

get isQuickDynamic

true for files containing atvise quick dynamics.

get value

Returns the decoded node value for the file.

contents

The file's contents.

get createNodeValue

Returns the decoded node value for create node serverscript.

get nodeId

Returns the node id associated with the file.

get name

A file's browse and display name.

get parentNodeId

A file's parent's node id.

clone(options)

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

static read(options)

Creates a new AtviseFile and reads it's contents.

# CreateNodeStream

A stream that creates OPC-UA nodes for the passed {@link AtviseFiles}s.

Hide members

get scriptId

Id of the CreateNode script added with atscm import.

scriptParameters(file)

The options required to create a node for the given file.

processErrorMessage(file)

Prints an error message telling that creating a node failed.

handleOutputArguments(file, outArgs, callback)

Handles the results of a script call.

# BrowsedNode

A node discovered while browsing the server's database.

Hide members

id

The node's id. @type {NodeId}

value

The node's value

addReferences(references)

Add multiple references at once.

createChild(options)

Creates new child node.

# NodeBrowser

Browses the server database.

Hide members

constructor(options, options.concurrency, options.handleNode, options.recursive)

Creates a new node browser.

queue

The queue used to process nodes in parallel

parentNode

A map that maps node ids against their discovered hierarchical parent nodes. Used to detect reference conflicts.

ensureHandled
addNode(node)

Instructs the browser to handle a node that would otherwise be queued behind others (eg: its parent node).

browse(nodeIds)

Starts the browser of the given nodes.

# NodeStream

A stream of server nodes.

Hide members

constructor(nodesToBrowse, options, options.recursive, options.ignoreNodes)

Creates new node stream.

recursive

If the discovered nodes should be browsed as well.

get isDestroyed

If the stream is destoyed.

get processed

The number of processed nodes.

get opsPerSecond

The number of processed chunks per second.

# QueueStream

A stream that process atvise server requests in parallel.

Hide members

constructor(options, options.maxParallel)

Creates a new QueueStream with the given options.

get hasPending

true if there are queued operations or an operation is running right now.

get queueEmpty

true if there are no queued operations.

get processed

The number of chunks already processed.

get opsPerSecond

The number of processed chunks per second.

processErrorMessage(chunk)

The error message to use when processing a chunk fails. Must be overridden by all subclasses!.

processChunk(chunk, handleErrors)

The function to call when a chunk is ready to be processed. Must be overridden by all subclasses..

# Session

A wrapper around {@link node-opcua~ClientSession} used to connect to atvise server. The sessions currentyl being opened.

Hide members

static create()

Creates an {@link node-opcuaOPCUAClient} and opens a new {@link node-opcua~ClientSession}. If pooling is active, the shared session will be reused.

static pool()

Starts pooling (reusing) sessions. Note that you'll have to manually close sessions using {@link Session.closeOpen}.

static close(session)

Closes the given session. When session pooling is active the session won't actually be closed and the returned Promise will resolve immediately.

static get open

The sessions currently open. Starting with version 1.0.0-beta.25 there will be one at most.

static closeOpen()

Closes all open sessions.

# Stream

An object transform stream connected to atvise server.

Hide members

constructor(options, options.keepSessionAlive)

Creates a new Stream and starts opening a new session to atvise server.

# AtviseResourceType

An atvise-related resource type.

Hide members

constructor(name, identifier)

Creates a new resource type.

# AtviseTypes

The atvise types to handle. Ordering matters: The {@link MappingTransformer} takes the first match, therefore plain types should always come before resource types!

# waitForDependencies(Stream)

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

# WaitingStream

A {@link QueueStream} that waits for a file's dependencies to be processed before the file is processed itself.

# Watcher

Watches the given nodes for value changes.

Hide members

constructor(nodes)

Creates a new Watcher with the given nodes.

subscriptionStarted

Resolved once the server subscription is set up.

close()

Ends monitoring nodes.

# WriteStream

A stream that writes all read {@link AtviseFile}s to their corresponding nodes on atvise server. The underlying {@link 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.

Hide members

constructor(createStream, addReferencesStream, options)

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

processErrorMessage(file)

The error message to use when writing a file fails.

dependenciesFor(file)

Returns a files parent node and type definition.

processChunk(file, handleErrors)

Writes an {@link AtviseFile} to it's corresponding node on atvise server.

# CallMethodStream

A stream that calls an OPC-UA method for all input files.

Hide members

get methodId

Must be implemented in all subclasses: The {@link NodeId} of the method to call.

get methodBaseId

The {@link NodeId} of the object from which the method should get called. Defaults to the value of {@link NodeId#parent} of {@link CallMethodStream#methodId}.

inputArguments(file)

The input arguments the method should be called with for a file. Needs to be overridden by subclasses in most cases. Returning null indicates no method call is needed.

callRequest(file)

Creates a call method request object for a file.

handleOutputArguments(file, outputArgs, callback)

Must be implemented by all subclasses: If the method call returns a status code of {@link node-opcua~StatusCodes}.Good, this method decides if the output matches the expected results.

processErrorMessage(file)

Returns an error message specifically for the given file.

processChunk(file, handleErrors)

Performs an opcua method call for the given file.

# CallScriptStream

A stream that calls atvise server scripts for all passed nodes.

Hide members

get methodId

The id of the callScript method.

get scriptId

Must be implemented by all subclasses: The id of the script to call.

get scriptBaseId

Id of the script's base object.

scriptParameters(file)

Returns the parameters to call the script with for the given file.

inputArguments(file)

Creates the raw method input arguments for the given file.

processErrorMessage(file)

Returns the error message logged if running the script fails.

processChunk(file, handleErrors)

Calls the script specified in {@link CallScriptStream#scriptId}. If the script does not exist but could be imported by running atscm import a special status description is returned.

# versionNode

The node containing the currently installed server-scripts version.

# ConfigTransformer

Hide members

nonEmptyConfig(input)

Returns an object containing all non-empty properties of the input object. Returns null if no properties are non-empty.

writeConfigFile(config, node, context)

Writes the config file to disk if needed.

# ModernPartialTransformer

A transformer that transforms only some of the files read.

Hide members

shouldBeTransformed(file)

true if file should be transformed.

# SplittingTransformer

A transformer that splits a node into multiple source nodes when pulling.

Hide members

static get extension

The extension to add to container node names when they are pulled.

static get sourceExtensions

The source file extensions to allow.

static splitFile(node, newExtension)

Splits a {@link Node}: The resulting is a clone of the input file, with a different path.

transformFromDB(node, context)

Renames a container node, should be called by all subclasses.

readNodeFile(node)

Returns false for all container nodes, so they don't get read.

combineNodes(node, sourceNodes, context)

Combines the container node and the source nodes to one single node.

transformFromFilesystem(node, context)

Reads a given container nodes source nodes and combines them.

# TransformDirection

The directions a transformer can be run in.

# Transformer

The base transformer class.

Hide members

static combinedTransformer(transformers, direction)

Returns a function that combines multiple transformer actions.

constructor(options, options.direction)

Creates a new Transformer with the specified options.

direction
withDirection(direction)

Returns the Transformer with the given direction.

readNodeFile(node)

Determines if a node's value node should be read, e.G. The Variable.Bool file for a node defined in .Variable.Bool.Json.

transformFromDB(node, context)

Must be overridden by all subclasses: Transforms the given node when using {@link TransformDirection.FromDB}.

transformFromFilesystem(node, context)

Must be overridden by all subclasses: Transforms the given node when using {@link TransformDirection.FromFilesystem}.

compatTransform(direction, node, context)

A transform wrapper that works with both async/await (atscm >= 1) and callback-based (atscm < 1)transformers.

# XMLTransformer

A transformer used to transform XML documents.

Hide members

constructor(options)

Creates a new XMLTransformer based on some options.

get builder

Returns the XML builder to use based on the current {@link Transformer#direction}.

decodeContents(node)

Parses XML in a node's contents.

encodeContents(object)

Builds an XML string from an object.

# importTask()

Imports all xml files needed for atscm usage.

# performPull(nodes, options)

Pulls the given nodes from the server.

# pull(options, options.clean)

Pulls all nodes from atvise server.

# performPush(path, options)

Pushes the given path to the server.

# push()

Pushes {@link AtviseFile}s to atvise server.

# WatchTask

The task executed when running atscm watch.

Hide members

constructor

Creates a new watch task instance. Also creates a new Browsersync instance.

browserSyncInstance

The Browsersync instance used.

get directoryToWatch

The directory to watch.

startFileWatcher()

Starts a file watcher for the directory {@link WatchTask#directoryToWatch}.

startServerWatcher()

Starts a watcher that watches the atvise server for changes.

initBrowserSync(options)

Initializes {@link WatchTask#browserSyncInstance}.

printTaskError(contextMessage, err)

Prints an error that happened while handling a change.

handleFileChange(path, root)

Handles a file change.

handleServerChange(readResult)

Handles an atvise server change.

run(options, options.open)

Starts the file and server watchers, initializes Browsersync and registers change event handlers.

# watch(options)

The gulp task invoced when running atscm watch.

# LintTransformer

A transformer ensuring no invalid alarm condition filter nodes are pulled.

Hide members

shouldBeTransformed(node)

Returns true for all alarm condition filter nodes.

transformFromDB(node, undefined)

Removes filter alarm condition filter nodes that have an invalid dataType.

transformFromFilesystem()

Does nothing.

# MappingTransformer

A Transformer that maps {@link ReadStream.ReadResult}s to {@link AtviseFile}s.

Hide members

constructor(options)

Creates a new mapping transformer.

transformFromDB(node, encoding, callback)

Writes an {@link AtviseFile} for each {@link ReadStream.ReadResult} read. If a read file has a non-standard type (definition) an additional rc file is pushed holding this type.

transformFromFilesystem(node, encoding, callback)

Writes an {@link AtviseFile} for each {@link Node} read.

get transformsReferenceConfigFiles

true as the mapping transformer should infer references from config files.

# NewlinesTransformer

A transformer that handles newline characters in files. During a pull, all breaks are converted the OS-native EOL character and (optionally) a trailing newline is added (for better git diffs). On push, CRLF characters are used and those trailing newlines are removed again.

Hide members

constructor(options, options.trailingNewlines)

Creates a new newline transformer.

shouldBeTransformed(file)

Returns true for all files except binary ones.

transformFromDB(file, enc, callback)

Adds converts line breaks to the current OS's native EOL characters and adds trailing newlines.

transformFromFilesystem(file, enc, callback)

Removes trailing newlines and converts all breaks to CRLF.

get transformsReferenceConfigFiles

true because we want to transform all files.

# cleanup(exitCode, signal, uninstall)

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

# getStat(path)

Returns the {@link fs~Stats} for a path.

# validateDirectoryExists(directoryPath)

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