TcHmiSrv.Core.Tools.DynamicSymbols Namespace

Provides types to dynamically create, read and write symbols in TwinCAT HMI server extensions.

Classes

 

Class

Description

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 1:

Definition

Represents a definition that can be referenced in a JSON schema.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 2:

DefinitionMismatchException

Represents an Exception that is thrown when two Definitions with the same key are not equal.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 3:

DynamicSymbolException

Represents an Exception that is thrown when handling a Command in the DynamicSymbolsProvider failed.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 4:

DynamicSymbolsProvider

Provides dynamic symbols in TwinCAT HMI server extensions.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 5:

JsonSchemaContractResolver

Represents an IContractResolver for JSON schemas.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 6:

JsonSchemaValue

Represent a JSON schema.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 7:

SortedDynamicSymbolsProvider

Provides dynamic symbols in TwinCAT HMI server extensions. The Symbols are sorted using StringComparer

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 8:

Symbol

Represents a symbol of a TwinCAT HMI server extension.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 9:

SymbolWithDirectValue

Represents a symbol of a TwinCAT HMI server extension with a Value that can be set directly.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 10:

SymbolWithValue

Represents a symbol of a TwinCAT HMI server extension with a Value.

TcHmiSrv.Core.Tools.DynamicSymbols Namespace 11:

TcHmiJSchemaGenerator

Generates a JsonSchemaValue from a specified Type.

Remarks

This implementation replaces the TcHmiSrv.DynamicSymbols.TcHmiSchemaGenerator class.
Dynamic symbols are exposed through an instance of the DynamicSymbolsProvider class. It represents a collection of symbols provided by a TwinCAT HMI server extension.
The DynamicSymbolsProvider class implements the IDictionary.TKey, TValue. interface, which makes it easy to add new symbols with DynamicSymbolsProvider.Add(string, Symbol) and remove existing symbols with DynamicSymbolsProvider.Remove(string) at runtime of the TwinCAT HMI server extension.
There are also many other methods to read and modify the contents of a DynamicSymbolsProvider. Just take a look at its documentation to explore them all.

When adding a new symbol to the DynamicSymbolsProvider using DynamicSymbolsProvider.Add(string, Symbol), DynamicSymbolsProvider.AddOrUpdate(string, Symbol) or the IDictionary.TKey, TValue. indexer, you have to provide a String and an instance of a type derived from the abstract Symbol class:

Now, how are the dynamic symbols provided by your TwinCAT HMI server extension with DynamicSymbolsProvider ?
First of all, dynamic symbols are provided by three function symbols that the TwinCAT HMI Server calls for each TwinCAT HMI server extension that implements them. Therefore, you have to add the following lines to the "symbols" property in the Config.json of your TwinCAT HMI server extension: Which information does each of the above symbols provide? Let's take a quick look at them:

After declaring the required symbols ListSymbols, GetDefinitions and GetSchema by adding them to the Config.json of your TwinCAT HMI server extension, they still need to be defined by implementing them. But don't worry: You don't have to do this on your own!
The Symbol class that was mentioned above already contains all the necessary information that must be returned for the above symbols. Therefore, you only have to pass the CommandGroup specified by the OnRequestEventArgs.Commands property of the RequestListener.OnRequest event handler to the DynamicSymbolsProvider.HandleCommands(CommandGroup) method as in the following piece of code where this.provider represents the instance of the DynamicSymbolsProvider class: This adds the appropriate information to the Command.ReadValue property of the ListSymbols, GetDefinitions and GetSchemaCommands.
Furthermore, DynamicSymbolsProvider.HandleCommands(CommandGroup) also handles Commands for reading and writing dynamic symbols by calling the Symbol.Read(Queue{string}) and Symbol.Write(Queue{string}, Value) methods mentioned above.
Non-dynamic symbols and symbols other than ListSymbols, GetDefinitions and GetSchema included in the Config.json of your TwinCAT HMI server extension cannot be handled by DynamicSymbolsProvider.HandleCommands(CommandGroup). To not ignore them, unhandled Commands are returned as an IEnumerable.T. so that you can handle them normally in your TwinCAT HMI server extension.