Hi, again 👊
Let's make some more simplification of work in Aveva for writing macros.
We already have the assembly PmlNetHelper. In this assembly I added StringHelper class. And now you can use pml function !!join. It returns single line from input array divided by delimiter. For example:
After reading all this, it turns out that for each pseudo-attribute you must write
separately C# code. Sad end ;)
To make the task easier let's create more universal tool.
And step by step.
Creating a pseudoattribute
You need to create a UWRL world for storing the UDA and the UDA itself. The attribute is called, for example, C-CStandard
When creating a UDA, you must set the Pseudo Attribute field to True.
Placement of configuration files.
In the folder where the program is installed exist the archive Samples, in which you can find an example of creating PA (pseudo attribute) - ExamplePseudoAttribute.cs. However, in this case, it is necessary to correct the source code each time when you need add new PA.
The following setting performs the above task based on the setup xml file.
1. Register the settings in the DesignAddins.xml file, which is locally in the program folder, or in the network folder at the address of the variable CAF_ADDINS_PATH.
2. The attached PseudoAtt.dll file must be placed (copied) in the folder with the installed program. This can be done by performing a copy manually or copying from the network folder when the network shortcut is launched.
3. In the project dflts directory (for example, for the SAM project the folder will be called samdflts) you need to place the configuration file PseudoUdaSettings.xml, an example of which is attached. Write in it the necessary PA and expressions to calculate them. Bellow is an example.
4. Some attribute values require additional calculations, i.e. cannot be described by a simple expression. For such cases, you must use the following syntax for the description of expression.
That means there is a function that returns a string value on the passed string of the reference number (REFNO) of the element, for example
Thus, a value will be written to the required attribute, which will be returned by the ConnectionDescGetStringByRef function. If you need to use this approach, then the name of the function must contain a StringByRef that determines the return type and that the refno element is passed to the function.
5. Mandatory conditions: file location, file name, internal file structure (presence of Name, Expression fields).
This setting works for UDA types TEXT (STRING), REAL, BOOL
Variants of errors that may occur when working with settings:
1. The configuration file may contain incorrect data - more often typos.
2. The specified attribute is missing in the project.
3. Attribute is not PA (example: Uda attribute ":UdaNotPseudo" in picture is not PseudoAttribute. Check attribute in Lexicon module.).
4. During operation, if an incorrect expression was specified (for example, propreal of cwei, the expression propreal cwei is correct), then the following notification will be displayed on the command line like: CP: Syntax error in expression: "propreal of cwei" to calculate attribute: UdaReal