Hello,
I'd like to reduce the number of cyclics in a customer's project.
The cyclics are calculating the average value of specific variables.
Right now there is one cyclic for each of the respective variables.
Here's my question:
Is there a way to create one global cyclic and a SCADA Basic program that could replace all the other cyclics?
Thank you for your replies.
BR,
Daniel
Of course!
1 Cyclic is calling 1 Sub
This Sub is calling the others one by one...
But, why your customers doesn't use expressions?
Nico
What we have done for this customer is highly generic, but unfortunately not very scalable.
In fact the cyclics that Daniel is speaking about are used to calculate the average value of a variable for the past 15 minutes. I guess you cannot do that with expressions?
We did that by encapsulating everything in an Application Architect template that can be attached to arbitrary other templates which contain a register variable and which contains the register variable for the calculated average and a cyclic which calls the SCADA Basic script that performs the calculation.
As the project is growing we end up with a huge number of cyclics each including a unique branch context. Now, for several reason we would like to change that. First because cyclics are expensive and potentially impact performance. Second because their name is automatically generated by the AA. As we have a highly nested setup in the AA, the cyclics' names exceed the maximum of 40 characters.
So as Daniel pointed out we would like to replace the huge number of cyclics with a single one. However, in that case we lose the information about the branch context which is stored in the cyclic (plus a few other parameters that are pushed into the SCADA Basic script as arguments).
The only considerable option would be to store all branch names for which the average calculation shall be performed (and the other calculation paramters) in a text file. That is not nice, error-prone and much less generic than the original approach.
Why not storing the name of the branch in a global array and then deactivate the cyclics. after that the global cyclic would be able to retrieve all the branches. Just an idea, not sure it is possible.
Another possibility is to add a mimic in your template. For example mybranchmimic. after generation you will have a lot of empty mimic and you can retrieve the branches with a function that replace _ by . and substract the final part of the file name.
IMHO you could create a _INFO variable in your template that you could use only to store in attributes all arguments needed like the branch name.
But your problem is to get the list of instances needing to be treated by your average function. The trick given by Ludo is working but a bit rough.
Creating an instance list in a csv file is a periodic demand we have as AA improvements. But so far we don't have it.
So, for me, the cleanest way is to run a VBA on startup. The function will read the /Templates/Tpl_Instances.xml and with a nice xslt request you could retrieve your list and create the csv file. i did it once and it's not complex.
The only constraint is that, after AA generation, you must run this function manually. Or maybe on startup is enough...
Another solution, the simplest I guess, is to ask your customer maintaining this csv file manually :whistle:
What do you think?
Nico
Thanks for all your inputs!
In any case we will loose our previously generic approach, which allowed to do everything exclusively in AA.
As a conclusion I think storing the required branch names in a text file is most appropriate (I already guessed so). I agree, it would be good to have someting available in AA that automatically creates entries in a file for a selection of instances. Here is my upvote for that feature.
@Ludo: What do you mean with "global array"?
So, finally what solution do you propose to your customer? Manual file management or the VBA startup script?
@Ludo: What do you mean with "global array"?
I mean array declared in the Global programm. But read carefully the DIM help instruction first, there some warnings.
So, finally what solution do you propose to your customer? Manual file management or the VBA startup script?
I think we will leave everything as is for the moment. The limitation of cyclic names to 40 characters will be removed in 11.1 Update. So the issue is no longer as urgent as it was before.
For reducing the number of cyclics I think we will wait until a sustainable AND generic solution will be available (that means: being able to populate a text file from AA or iterating a population from SCADA Basic).
@Daniel: Can you confirm?
Yes, I confirm.
As a short-term solution we use the new 11.1 Update version.
Nevertheless we keep the long-termn solution to replace the existing cyclics in mind.
But read carefully the DIM help instruction first, there some warnings.
The most important point is that every single element in the array consume a symbol in scada basic and by default Scada Basic is limited to 4000 symbols.
I just mentionned that because today we had a Hot Line case with a customer who fall into the trap:
Dear Sir,
When I declare (in GLOBALS) two tables:
DIM x[3700] As single;
DIM y[3700] As single;
I receive in log viewer fault: “BASIC, symbol table full”When I declare only one table:
DIM x[3700] As single;
there is no problem. (But I need two tables)What can I do with it? Why it is not possible?
I am using PcVue 9.0 SP2.
Armin/Daniel
OK, but how many cyclics will have your project (roughly)?
And what is the period?
Nico
Hello,
I would use extended Attributes to identify, which variable should be calculated. You can also add additional parameters to another extended attribute or store them in another variable.
Then you just need to browse the var-tree and check for the attribute.
You can use VBA or SCADA Basic with an AI-Grid, maybe there is a way to browse in VBA without an AI-Grid or you use the SVMgr, which would maybe the most beautiful way to browse and calculate the average.


