- Index
- » Programming
- » Modelica Language
- » Creating counters of component instances
Creating counters of component instances
Creating counters of component instances
Hello,
I am trying to build a library with counters for the component instances. The naive code would be something of the following style:
class Pipe
Integer ipipe; //actual number of the instance
outer Integer npipe; //global counter for the total number of pipes
initial algorithm
npipe := npipe + 1;
ipipe := npipe;
end Pipe;
model hydro_circuit;
inner Integer npipe(start=0,fixed=false); //global counter for the normal number of pipes
Pipe pa, pb, pc, pd;
end hydro_circuit;
I have been unable to achieve my goal: after initialization I want
npipe=4
pa.ipipe=1
pb.ipipe=2
pc.ipipe=3
pd.ipipe = 4.
Apparentely, the initial algorithm blocks are considered as multiple equations assigning the same variable npipe.
Thanks in advance for any help
- Index
- » Programming
- » Modelica Language
- » Creating counters of component instances