Cancel
Showing results for 
Search instead for 
Did you mean: 

Reset all user defined attributes on parallel procs

Creator
Creator

Hi,

 

Whenever I reset my model I would like to reset a counter, which is incorporated in every parallelproc in my model. Hence, every parallel proc has a user defined attribute called "counter". Whenever I reset my model these counters need to go back to zero. Is there any way to do this without typing out every parallel proc's name.counter in the reset method? I have a lot of parallel procs namely...

 

The counter is an integer.

 

Kind regards,

Noud

5 REPLIES 5

Re: Reset all user defined attributes on parallel procs

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

you can use the inheritance of the parallelProc to find all children

 

for var i:=1 to .materialflow.parallelProc.numChildren loop

   .materialflow.parallelProc.childNo(i).counter:=0

next

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Reset all user defined attributes on parallel procs

Creator
Creator

He says that he does not recognize counter ("unknown identifier counter"). Any idea why this is the case?

 

Kind regards,

Noud

Re: Reset all user defined attributes on parallel procs

Phenom
Phenom

@Noud

 

 Using the inheritance capabilities of Plant Simulation, another possibility could be to :

 

Define a user defined method in your parallel proc class object.

 

 Rename it to "reset"  so that the inherited object  reset  methods will be triggered , when you reset your model.

 

Add the following code to reset your user defined counter attribute in the method

 

@.counter :=0

 

 

Re: Reset all user defined attributes on parallel procs

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
than you have some parallelProcs without the attribute counter, but you can check, if there is the attribute counter with isNameUnique("counter") --> false --> the attribute exists

for var i:=1 to .materialflow.parallelProc.numChildren loop
if .materialflow.parallelProc.childNo(i).isNameUnique("counter") = false then
.materialflow.parallelProc.childNo(i).counter:=0
end
next
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Reset all user defined attributes on parallel procs

Creator
Creator

Completely correct! Thank you very much Smiley Very Happy