Applies to:
PcVue 12 onwards |
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
Summary:
In Application Architect expression engine, it is possible to count things like the number of templates that has been instantiated at a certain level of the instances tree. It is also possible to count the number of variables, of symbols, of mimics… This article propose to discover this feature through a simple use case. |
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
Details:
The sample project is collecting power of solar panels on the roof of a building. We want to know the maximum power that can be expected according to the number of solar panels installed. Not only does the Application Architect automatically position symbols (see KB1122), but it is also able to automatically count the number of instantiated solar panels. Thus it is easy to create an expression which is multiplying the number of solar panel by the maximum power of one solar panel. In Application Architect, the parameter definition: The expression used: =ChildCount(_ctInst,”*”,1) We add and use this parameter in ROOF template: We can check that the value is correct in the instances tree: So after synchronisation, the basic expression on variables will calculate the maximum power of all solar panels: Thanks to all this, we have the right values in the mimic after the synchronization. Whether we add panels or remove them:
How to use the ChildCount function in an expression :The argument eCountType determines which types of child items should be counted and on which criteria, child item’s instance name or child item’s template name. Possible values are as follow:
The str argument is used to take into account child elements that match a pattern based on a regular expression:
The argument num is the depth level for matching child items:
For instance: =Childcount(_ctInst_ByType,”Solar*”,-1) Download attachments:
|
|||||||||||||||||||||||||||||||||||||||||
Created on: 15 Jun 2021 Last update: 30 May 2024