For a customer project I am looking for a solution that allows me to configure variables with accumulated data on all levels of the variable database.
For example:
- All values of the branch AAA.BBB.CCC.* and below shall be accumulated in a register variable called AAA.BBB.CCC.ACTIVE_COUNT.
- All values of the branch AAA.BBB.* and below shall be accumulated in a register variable called AAA.BBB.ACTIVE_COUNT.
- All values of the branch AAA.* and below shall be accumulated in a register variable called AAA.ACTIVE_COUNT.
- ...
My idea would be to "abuse" the alarm syntheses feature of PcVue and to declare all the bit variables that shall be accounted for the accumulation as an alarm with a certain priority. Alarms with this priority level would be separated from the real alarm management and not be taken into account by alarm viewers and alarm notification.
Do you regard this as an appropriate solution? Is there a simpler solution?
What do you want to count? Alarms, bits, registers?
Only bit variables...
Consider a line of things with a status On/Off. I want to count the number of things in a line with status equals "On".
Consider a block of lines. I want to count the number of things in a block with status equals "On".
Consider a block of blocks. I want to count the number of things in that block with status equals "On".
And so on...
Is it possible to browse variables in VBA like for example:
For each var in Variables("AAA.BBB.CCC")
...
Next
??
There are only two ways to enumerates variables in PcVue:
- Variable Toolkit manager
- Webservices Toolkit
It's not possible with VBA or SCADA Basic.
Another solution is to parse the varexp.dat to find the variables that corresponds to your branch
Correct!
Armin, you can use your solution but take care on the performances. How many alarm synthesis do you will have?
2 alternatives:
- Expressions:
AAA.BBB.CCC.ACTIVE_COUNT = (AAA.BBB.AAA.bit1 == 1) + (AAA.BBB.AAA.bit2 == 1) + .....
AAA.BBB.ACTIVE_COUNT = AAA.BBB.AAA.ACTIVE_COUNT + AAA.BBB.BBB.ACTIVE_COUNT + ....
And so on....
- By events
Nico
Thanks. Good to know that the alarm synthesis may have a high impact on performance. The expressions approach does not seem generic enough to me.
Besides that, my second choice would have been SCADA Basic. In the best case I would have a register variable within each branch telling me how many bit variables there need to be accumulated. And then go through the branch with deferred variable naming:
for variableIndex=0; variableIndex<variablesInBranch; variableIndex++;
varName = ADDSTRING(branch, "bit");
varName = ADDSTRING(varName, variableIndex);
activeCount = activeCount + (?varname==1);
next variableIndex
But even if there is no variable indicating the number of summand I go try to cumulate variables with deferred naming until an error occurs in the variable referencing as it is not possible to check ?varName before executing an operation on it. Unfortunately, it is not certain which return value the function will have when exiting on error. Right?
You can test if the variable exist before doing the sum.
VARIABLE("STATUS",varname,"EXIST")
Thanks Nico, good point!
Okay now, next project, next requirement...:
It is the cumulation of register values according to a certain naming rule.
To put the requirement in pseudo-code:
Accumulate all the variables which end with .VAL (or which have a certain extended attribute) from the branch B1.B2.B3 and its sub branches and put the value into the variable .SUM.
This is what I regard as one of the most critical missing variable behaviors, by the way. It would be great to have something like that in the future (analog to alarm synthesis)...
Anyway, as Florent pointed out, at the moment it is only possible to do this in the svMgr or the WST. But since this is a basic requirement in the engery generation and energy distribution business I am sure that somebody must have done it before.
Has anyone of you such kind of svmgr-dll that may be shared?


