tc-context
Version:
TwinCAT ADS Communication Library for creating an active TwinCAT Context, with automatic symbol and type mapping
753 lines • 36.2 kB
TypeScript
/**
* Module, which contains the definitions of all the `TcSymbols` and their derived types, through which data manipulation with the
* Target PLC is made. The `TcSymbols` act as the interface between the `TcContext` and the `TcBindings`, where the `TcBindings`
* manage all the data parsing, checking and Symbol memory location, while the `TcSymbol` itself, as a wrapper for those bindings
* and collection of children Symbols.
*
*
* Licensed under MIT License.
*
* Copyright (c) 2020 Dmitrij Trifanov <d.v.trifanov@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* @packageDocumentation
*/
/// <reference types="debug" />
import { TcContext } from './tc-context';
import { TcSymbolGetEvent, TcSymbolSetEvent, TcSymbolClearedEvent, TcSymbolChangedEvent, TcEmitter } from './tc-event';
import { TcSymbolBinding, TcBooleanBinding, TcNumericBinding, TcStringBinding, TcEnumBinding, TcStructureBinding, TcArrayBinding, TcNamespaceBinding } from './tc-binding';
import { TcBooleanType, TcNumericType, TcStringType, TcEnumType, TcStructType, TcArrayType } from './tc-type';
import { TcSymbolPointer } from './tc-com';
/**
* Invokes a Rpc Method of a `Function_Block`, with the provided arguments
*
* @param args - All the arguments, as an object, that are passed to the method
*
* @throws {@link TcComIsInvalidException} - Attempted to use an Invalid `TcCom` Object for subscription
* @throws {@link TcComMethodCallException} - Failed to call the Rpc Method on the PLC Side
*
* @return The result of the method call
*
*/
export declare type TcSymbolMethod = (args: any) => Promise<{
result: any;
outputs?: any;
}>;
/**
* Class representing an instance of a PLC Symbol, mapped to the `TcContext`. The `TcSymbol` itself
* acts as a bridge to the `TcBinding`, which has the responsibility of low-level ADS operations.
*
* ***NOTE:*** In order to avoid naming collisions with the Symbols declared in the Target PLC, all public
* methods of `TcSymbol` start with the '$' character.
*
* The `TcSymbol` should not be directly created, as it serves as a Template for the Derived `TcSymbols`
*
*/
export declare abstract class TcSymbol {
/**
* TcSymbols are indexable, in case they are structured types, and can nest children `TcSymbols`.
* Alternatively, if a `TcSymbol` has Rpc Methods enabled, this methods can be also invoked over
* the index.
*/
[key: string]: TcSymbol | TcSymbolMethod;
/**
* Constructs the foundation of a `TcSymbol` Object
*
* @param path - The Path of this Symbol, relative to its origin point
* @param parent - Potential parent of this `TcSymbol` and to whom events will propagate to
* @param readOnly - Flag which marks this `TcSymbol` as a ReadOnly symbol, and no operation of write-type can be issued to the `TcSymbol`
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, parent?: TcSymbol, readOnly?: boolean, debug?: boolean);
/**
* Access the potential parent of this `TcSymbol`
*/
get $parent(): TcSymbol | undefined;
/**
* Access the path of this `TcSymbol` from its origin point
*/
get $path(): string;
/**
* Access the `TcBinding` information of this `TcSymbol`
*/
abstract get $binding(): TcSymbolBinding;
/**
* Returns true if this `TcSymbol` is ReadOnly
*/
get $readOnly(): boolean;
/**
* Returns the value of this `TcSymbol` from the Target PLC Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<any>;
/**
* Writes the provided value to the Target PLC Symbol, and when completed returns what was
* written to the Target PLC Symbol
*
* @param value - The value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a value to a non-existent field
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: any): Promise<any>;
/**
* Clears the data of the Target PLC Symbol to their implicit default values, or the explicitly specified ones
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingReadOnlyException} - Attempted to clear a ReadOnly Symbol
*
*/
$clear(): Promise<void>;
/**
* Activates value change detection of the Target PLC Symbol. The sampling rate can be explicitly
* set, in case the value changes uneseceraly too fast.
*
* @param sampling - The speed at which change in the Target PLC Symbol value is detected
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComSubscribeException} - An error occurred when subscribing to the Symbol
*
*/
$subscribe(sampling?: number): Promise<void>;
/**
* Deactivated value change detection of the Target PLC Symbol. Does not remove the event handlers
* though, they simply will not be invoked.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComUnsubscribeException} - An error occurred when unsubscribing for a Symbol
*/
$unsubscribe(): Promise<void>;
/**
* Attached the provided callback, which will be called when the `TcSymbol becomes invalidated
*
* @param callback - The function, which is to be called upon invalidation
*/
$onInvalidated(callback: (symbol: TcSymbol) => void): void;
/**
* Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol.$set()` has completed
* @event set
*/
$on(event: 'set', listener: (e: TcSymbolSetEvent) => void): TcSymbol;
/**
* Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol.$get` has completed
* @event get
*/
$on(event: 'get', listener: (e: TcSymbolGetEvent) => void): TcSymbol;
/**
* Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol.$clear()` has completed
* @event cleared
*/
$on(event: 'cleared', listener: (e: TcSymbolClearedEvent) => void): TcSymbol;
/**
* Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol` detects a change in the PLC Symbol
* @event changed
*/
$on(event: 'changed', listener: (e: TcSymbolChangedEvent) => void): TcSymbol;
/**
* Removes a listener from the specified event
*
* @param eventName - The event name, from which the listener is to be removed
* @param listener - The listener, which is to be removed from the specified event
*/
$off(eventName: string, listener: (e: any) => void): TcSymbol;
/**
* Attached a listener to an event, which is only invoked once. For the full list
* of events, see `TcSymbol.$on()`
*
* @param eventName - The event name, which the listener will listen for
* @param listener - The listener, which is called when the event is emitted
*/
$once(eventName: string, listener: (e: any) => void): TcSymbol;
/**
* Internal function, for calling invalidation on the provided `TcSymbol
*
* @param symbol - `TcSymbol`, which is to be invalidated
* @internal
*/
static invalidate(symbol: TcSymbol): void;
/**
* Invalidates the `TcBinding`of this symbol, as well as, if a callback as provided
* in case of invalidation - will invoke it
*/
protected __invalidate(): void;
/**
* Optional Callback, which is called when this `TcSymbol` is invalidated
* @internal
*/
private __invalidateCallback?;
/**
* The potential `TcSymbol` parent of this `TcSymbol`
* @internal
*/
private __parent;
/**
* String path of this `TcSymbol`
* @internal
*/
private __path;
/**
* Flag, which when true signal this `TcSymbol` is ReadOnly
* @internal
*/
private __readOnly;
/**
* @internal
*/
protected __log: debug.Debugger;
}
/**
* Class representing an instance of a PLC Symbol of Type `BOOL`.
*/
export declare class TcBooleanSymbol extends TcSymbol {
/**
* Constructs a `TcSymbol`, which is designed to interface with a `BOOL` Symbol on the Target
* PLC.
*
* @param path - The Path of this Symbol, relative to its origin point
* @param parent - Potential parent of this `TcSymbol` and to whom events will propagate to
* @param pointer - The memory location of the Target PLC Symbol
* @param params - The Type parameters of this `BOOL` Symbol
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, parent: TcSymbol, pointer: TcSymbolPointer, params: TcBooleanType, debug?: boolean);
/**
* Access the `TcBinding` of this `TcSymbol`
*/
get $binding(): TcBooleanBinding;
/**
* Returns the boolean value of this `TcSymbol` from the Target PLC `BOOL` Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<boolean>;
/**
* Writes the provided boolean value to the Target PLC Symbol, and when completed returns what was
* written to the Target PLC Symbol
*
* @param value - The boolean value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a value to a non-existent field
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: boolean): Promise<boolean>;
/**
* `TcBinding` used by this Symbol
* @internal
*/
private __binding;
}
/**
* Class representing an instance of a PLC Symbol of Numeric Type.
*/
export declare class TcNumericSymbol extends TcSymbol {
/**
* Constructs a `TcSymbol`, which is designed to interface with a Numeric Symbol on the Target
* PLC.
*
* @param path - The Path of this Symbol, relative to its origin point
* @param parent - Potential parent of this `TcSymbol` and to whom events will propagate to
* @param pointer - The memory location of the Target PLC Symbol
* @param params - The Type parameters of this Symbol
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, parent: TcSymbol, pointer: TcSymbolPointer, params: TcNumericType, debug?: boolean);
/**
* Access the `TcBinding` of this `TcSymbol`
*/
get $binding(): TcNumericBinding;
/**
* Access the maximum value that can be written to this symbol
*/
get $upperBorder(): number | bigint;
/**
* Access the minimum value that can be written to this symbol
*/
get $lowerBorder(): number | bigint;
/**
* Returns the numeric value of this `TcSymbol` from the Target PLC Numeric Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<number>;
/**
* Writes the provided numeric value to the Target PLC Symbol, and when completed returns what was
* written to the Target PLC Symbol
*
* @param value - The numeric value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a value which is out of range of this numeric type
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: number): Promise<number>;
/**
* `TcBinding` used by this Symbol
* @internal
*/
private __binding;
}
/**
* Class representing an instance of a PLC Symbol of Type `STRING` or `WSTRING`.
*/
export declare class TcStringSymbol extends TcSymbol {
/**
* Constructs a `TcSymbol`, which is designed to interface with a `STRING` or `WSTRING` Symbol on the Target
* PLC.
*
* @param path - The Path of this Symbol, relative to its origin point
* @param parent - Potential parent of this `TcSymbol` and to whom events will propagate to
* @param pointer - The memory location of the Target PLC Symbol
* @param params - The Type parameters of this `STRING` or `WSTRING` Symbol
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, parent: TcSymbol, pointer: TcSymbolPointer, params: TcStringType, debug?: boolean);
/**
* The maximum length of a string, that can be written
*/
get $length(): number | bigint;
/**
* Access the `TcBinding` of this `TcSymbol`
*/
get $binding(): TcStringBinding;
/**
* Returns the string value of this `TcSymbol` from the Target PLC `STRING` or `WSTRING` Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<string>;
/**
* Writes the provided string value to the Target PLC Symbol, and when completed returns what was
* written to the Target PLC Symbol
*
* @param value - The string value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a string value longer than maximum length
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: string): Promise<string>;
/**
* `TcBinding` used by this Symbol
* @internal
*/
private __binding;
}
/**
* Class representing an instance of a PLC Symbol of Type `ENUM`.
*/
export declare class TcEnumSymbol extends TcSymbol {
/**
* Constructs a `TcSymbol`, which is designed to interface with a `ENUM` Symbol on the Target
* PLC.
*
* @param path - The Path of this Symbol, relative to its origin point
* @param parent - Potential parent of this `TcSymbol` and to whom events will propagate to
* @param pointer - The memory location of the Target PLC Symbol
* @param params - The Type parameters of this `ENUM` Symbol
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, parent: TcSymbol, pointer: TcSymbolPointer, params: TcEnumType, debug?: boolean);
/**
* Access the fields of this enumerator, which can
* be written
*/
get $fields(): string[];
/**
* Access the `TcBinding` of this `TcSymbol`
*/
get $binding(): TcEnumBinding;
/**
* Returns the string enum value of this `TcSymbol` from the Target PLC `ENUM` Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<string>;
/**
* Writes the provided string enum value, which is part of the allowed fields to
* the Target PLC Symbol, and when completed returns what was written to the Target PLC Symbol
*
* @param value - The string enum value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a value to a non-existent field
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: string): Promise<string>;
/**
* `TcBinding` used by this Symbol
* @internal
*/
private __binding;
}
/**
* Class representing an instance of a PLC Symbol of `Structure`, `Function_Block` or `UNION` Type.
*/
export declare class TcStructureSymbol extends TcSymbol {
/**
* Constructs a `TcSymbol`, which is designed to interface with a `Structure`, `Function_Block` or `UNION` Symbol on the Target
* PLC.
*
* @param path - The Path of this Symbol, relative to its origin point
* @param parent - Potential parent of this `TcSymbol` and to whom events will propagate to
* @param pointer - The memory location of the Target PLC Symbol
* @param params - The Type parameters of this Symbol
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, parent: TcSymbol, pointer: TcSymbolPointer, params: TcStructType, debug?: boolean);
/**
* Access the `TcBinding` of this `TcSymbol`
*/
get $binding(): TcStructureBinding;
/**
* Returns the structured value of this `TcSymbol` from the Target PLC `Structure`, `Function_Block` or `UNION` Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<{
[key: string]: any;
}>;
/**
* Writes the provided structured value to the Target PLC Symbol, and when completed returns what was
* written to the Target PLC Symbol
*
* @param value - The structured value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a value which is out of range of this type
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: {
[key: string]: any;
}): Promise<{
[key: string]: any;
}>;
/**
* Iterates over all the `TcSymbol` Children of this `TcSymbol, and
* passes each of them to the provided callback
*
* @param callback - Callback, to which each `TcSymbol` Child is passed
*/
$each(callback: (symbol: TcSymbol, key: string, parent: TcSymbol) => void): void;
/**
* Internal use function, which registers a `TcSymbol` Child as part of this `TcSymbol
* @param child - The Child that is to be registered
*/
private __addChild;
/**
* Internal use function, which registers an Rpc Method to this Structure
* @param name - The name of the method to create
*/
private __addMethod;
/**
* Invalidates all the `TcSymbol` Children, before invalidating itself
*/
protected __invalidate(): void;
/**
* `TcBinding` used by this Symbol
* @internal
*/
private __binding;
/**
* List of children of this `TcSymbol`
* @internal
*/
private __children;
}
/**
* Class representing an instance of a PLC Symbol of `ARRAY OF...` Type.
*/
export declare class TcArraySymbol extends TcSymbol {
/**
* Constructs a `TcSymbol`, which is designed to interface with a `ARRAY OF...` Symbol on the Target
* PLC.
*
* @param path - The Path of this Symbol, relative to its origin point
* @param parent - Potential parent of this `TcSymbol` and to whom events will propagate to
* @param pointer - The memory location of the Target PLC Symbol
* @param params - The Type parameters of this Symbol
* @param depth - The Depth of this array, relative to the number of Dimensions in total
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, parent: TcSymbol, pointer: TcSymbolPointer, params: TcArrayType, depth: number, debug?: boolean);
/**
* Access the `TcBinding` of this `TcSymbol`
*/
get $binding(): TcArrayBinding;
/**
* Access the starting index of this array, due to TwinCAT allowing arrays to
* start at any number
*/
get $startIndex(): number;
/**
* Access the total length of the array
*/
get $length(): number;
/**
* Returns the array value of this `TcSymbol` from the Target PLC `ARRAY OF...` Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<any[]>;
/**
* Writes the provided array value to the Target PLC Symbol, and when completed returns what was
* written to the Target PLC Symbol
*
* @param value - The array value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a value which is out of range of this type
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: any[]): Promise<any[]>;
/**
* Internal use function, which registers a `TcSymbol` Child as part of this `TcSymbol
* @param child - The Child that is to be registered
*/
private __addChild;
/**
* Iterates over all the `TcSymbol` Children of this `TcSymbol, and
* passes each of them to the provided callback
*
* @param callback - Callback, to which each `TcSymbol` Child is passed
*/
$each(callback: (symbol: TcSymbol, index: number, parent: TcSymbol) => void): void;
/**
* Invalidates all the `TcSymbol` Children, before invalidating itself
*/
protected __invalidate(): void;
/**
* Internal function, for creating the children of the Array Symbol.
* If the array is multidimensional, it will create proxy-arrays to house
* each dimension
*
* @param depth - The Depth of the current array relative to the amount of dimensions
* @param params - The Parameters of the Array, from which construction is made
*/
private __createChildren;
/**
* Internal function, for handling multidimensional arrays, where it splits the current `TcSymbolPointer`
* and creates proxy arrays, to house the different dimensions
*
* @param path - The modified path for multidimensional arrays reference
* @param segments - The number of splits for this dimension
* @param depth - The current dimension depth, relative to the total amount of dimensions
* @param params - The Parameters of the Array, from which construction is made
*/
private __createProxyArrays;
/**
* `TcBinding` used by this Symbol
* @internal
*/
private __binding;
/**
* List of children of this `TcSymbol`
* @internal
*/
private __children;
}
/**
* Class representing an instance of a PLC Symbol, which is the initial entry point to the `TcSymbol` map.
* These namespaces are usually `PROGRAMS` and different Variable Lists.
*
* This `TcSymbol` deduces its IndexOffset, IndexGroup and Size, based on the provided children
*/
export declare class TcNamespaceSymbol extends TcSymbol {
/**
* Constructs a `TcSymbol`, which is designed to interface a namespace Symbol on the Target
* PLC.
*
* @param path - The Path of this Symbol, relative to its origin point
* @param context - The `TcContext`, that this namespace is apart of
* @param parent - Parent Emitter, to whom errors are propagated to
* @param debug - If enabled, will produce debug information
*/
constructor(path: string, context: TcContext, parent: TcEmitter, debug?: boolean);
/**
* Access the `TcBinding` of this `TcSymbol`
*/
get $binding(): TcNamespaceBinding;
/**
* Iterates over all the `TcSymbol` Children of this `TcSymbol, and
* passes each of them to the provided callback
*
* @param callback - Callback, to which each `TcSymbol` Child is passed
*/
$each(callback: (symbol: TcSymbol, key: string, parent: TcSymbol) => void): void;
/**
* Returns the structured value of this `TcSymbol` from the Target PLC namespace Symbol,
* which the `TcSymbol.$binding` is linked to.
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComDataReadException} - An error occurred when fetching the Symbol Data
* @throws {@link TcComFromRawException} - An error occurred when parsing Data to values
* @throws {@link TcBindingOutOfRangeException} - Error occurred when parsing returned Data from the Target PLC Symbol
*
* @return - The value of the Target PLC Symbol
*/
get $get(): Promise<{
[key: string]: any;
}>;
/**
* Writes the provided structured value to the Target PLC Symbol, and when completed returns what was
* written to the Target PLC Symbol
*
* @param value - The structured value that is to be written to the Target PLC Symbol
*
* @throws {@link TcBindingIsInvalidException} - Attempting operation on an invalidated `TcBinding`
* @throws {@link TcComIsInvalidException} - Attempting operation on an invalidated `TcCom` Object
* @throws {@link TcComToRawException} - An error occurred when parsing values to Data
* @throws {@link TcComDataWriteException} - An error occurred when writing the Symbol Data
* @throws {@link TcBindingOutOfRangeException} - Attempted to write a value which is out of range of this type
* @throws {@link TcBindingInvalidTypeException} - Type-mismatch occurred when parsing Values to Data
* @throws {@link TcBindingReadOnlyException} - Attempted to write to a ReadOnly Symbol
*
* @return - The value which was written to the Target PLC Symbol
*/
$set(value: {
[key: string]: any;
}): Promise<{
[key: string]: any;
}>;
/**
* Internal use function, which registers a `TcSymbol` Child as part of this `TcSymbol
* @param child - The Child that is to be registered
*/
private __addChild;
/**
* Internal use function, to add a `TcSymbol` Child to this `TcNamespaceSymbol`.
* Should not be called outside the library
*
* @param namespace - The namespace, to which the `TcSymbol` Child is added
* @param child - The `TcSymbol` Child, that is to be added to the namespace
*
* @internal
*/
static addChild(namespace: TcNamespaceSymbol, child: {
key: string;
symbol: TcSymbol;
}): void;
/**
* Invalidates all the `TcSymbol` Children, before invalidating itself
*/
protected __invalidate(): void;
/**
* `TcBinding` used by this Symbol
* @internal
*/
private __binding;
/**
* List of children of this `TcSymbol`
* @internal
*/
private __children;
}
//# sourceMappingURL=tc-symbol.d.ts.map