UNPKG

tc-context

Version:

TwinCAT ADS Communication Library for creating an active TwinCAT Context, with automatic symbol and type mapping

106 lines 4.83 kB
/** * Module containing the Symbol Registry, responsible for fetching the ADS Symbol Data through the {@link TcContext} Component, processing it * and building a Symbol Map, which is based on the Type Data from the {@link TcContext}'s `TcTypeRegistry` * * * 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 */ import * as TcEvents from "./tc-event"; import { TcContext } from './tc-context'; import { TcNamespaceSymbol } from './tc-symbol'; /** * Class responsible for creating and managing the TwinCAT Symbol map, which is fetched * from the TwinCAT's Target PLC and processed through the previously created `TcTypeRegistry` of * the `TcContext` */ export declare class TcSymbolRegistry extends TcEvents.TcEmitter { /** * Constructor, which used the {@link TcContext}'s {@link TcCom} Object for ADS Communication and the * {@link TcContext}'s {@link TcTypeRegistry} form Symbol Map generation * * @param context - Parent {@link TcContext}, of whom `TcSymbolRegistry` is a part of, and whom to propagate events to * @param debug - If enabled, will produce debug information */ constructor(context: TcContext, debug?: boolean); /** * Access the created ${@link TcSymbol} Map */ get namespaces(): { [key: string]: TcNamespaceSymbol; }; /** * Fetches the ADS Symbol Data and creates the Symbol Map based on the Type Information, * registered by the `TcContext` * * @throws {@link TcComIsInvalidException} - TcCom has not been initialized before creating Symbol Map * @throws {@link TcComSymbolQueryException} - Failed to query Symbol Data * @throws {@link TcComToRawException} - Error occurred when transforming value to raw data * */ create(): Promise<void>; /** * Destroys the created Symbol Map, by invalidating all the created `TcSymbols` and `TcNamespaces` * and cleaning the internal map */ destroy(): void; /** * Emitted from {@link TcSymbolRegistry} when it creates the Symbol Map * @event created */ on(event: 'created', listener: (e: TcEvents.TcSymbolRegistryCreatedEvent) => void): any; /** * Emitted from {@link TcSymbolRegistry} when it destroys the Symbol Map * @event destroyed */ on(event: 'destroyed', listener: (e: TcEvents.TcSymbolRegistryDestroyedEvent) => void): any; /** * Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol.$set()` has completed * @event set */ on(event: 'set', listener: (e: TcEvents.TcSymbolSetEvent) => void): any; /** * Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol.$get` has completed * @event get */ on(event: 'get', listener: (e: TcEvents.TcSymbolGetEvent) => void): any; /** * Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol.$clear()` has completed * @event cleared */ on(event: 'cleared', listener: (e: TcEvents.TcSymbolClearedEvent) => void): any; /** * Emitted from {@link TcBinding} of a {@link TcSymbol} when `TcSymbol` detects a change in the PLC Symbol * @event changed */ on(event: 'changed', listener: (e: TcEvents.TcSymbolChangedEvent) => void): any; /** * The `TcContext`, which acts as a parent to the `TcSymbolRegistry` and to whom events are propagated * @internal */ private __context; /** * Stores the map of Symbols * @internal */ private __map; /** * @internal */ private __log; } //# sourceMappingURL=tc-symbol-registry.d.ts.map