Class InformationModelExtensions
Namespace: TecnoPack
Assembly: CO0002_Templ_FlowpackHMI_V00_26_M.dll
Provides extension methods for working with the FTOptix information model, including dictionary creation, tag retrieval, localization, and node resolution.
public static class InformationModelExtensions
Inheritance
object ← InformationModelExtensions
Methods
CreateDictionary(string)
Creates a localizable dictionary variable from scratch, ready to store translations.
How it works:
- Instantiates a UA variable with a custom variable type using specific NodeIds.
- Initializes the value as a 2D table with a single row:
- First column: "Key"
- Subsequent columns: project language codes (locales), e.g., "en-US", "it-IT".
- The first row serves as the dictionary header, ready to be filled with translation entries.
public static IUAVariable CreateDictionary(string dictionaryName)
Parameters
dictionaryName string
The name of the dictionary variable to create in the information model. Choose a meaningful name to ensure it can be easily retrieved via OPC UA.
Returns
IUAVariable
An IUAVariable representing the dictionary, with the header row already initialized.
After creation, rows can be added containing translation keys and their corresponding localized values.
GetDefaultNamespaceIndex(IContext)
Retrieves the default namespace index for the given context.
public static int GetDefaultNamespaceIndex(IContext context)
Parameters
context IContext
The UA context from which to retrieve the default namespace index.
Returns
int
The default namespace index. If the context does not provide a valid index, the current project’s namespace index is returned.
GetLocalizedTextFromKey(string)
Retrieves a localized text value from a dictionary key, using the default context.
public static LocalizedText GetLocalizedTextFromKey(string key)
Parameters
key string
The key representing the text to localize.
Returns
LocalizedText
A
GetTagStructuresByType(Folder, string)
Retrieves a collection of
public static IEnumerable<TagStructure> GetTagStructuresByType(Folder tagsFolder, string tagTypeName)
Parameters
tagsFolder Folder
The folder containing tags to search.
tagTypeName string
The variable type name to filter by.
Returns
IEnumerable<TagStructure>
An enumerable of matching
ResolveNode<T>(NodeId, string)
Resolves a
public static T ResolveNode<T>(this NodeId id, string parameterName = null) where T : class, IUANode
Parameters
id NodeId
The
parameterName string
Automatically populated by the compiler using the CallerArgumentExpression feature;
used to provide accurate exception messages. Do not pass this parameter manually.
Returns
T
The resolved UA node of type T.
Type Parameters
T
The expected node type, constrained to
Examples
var label = someNodeId.ResolveNode<Label>();
Exceptions
ArgumentNullException
Thrown when the provided id is null.
ArgumentException
Thrown when no node of type T could be resolved.
See Also
InformationModel.Get<T>(NodeId)