Cancel
Showing results for 
Search instead for 
Did you mean: 

Same global variable in different frames

Creator
Creator

Hi,

 

I have encountered a problem regarding the use of global variables in a hierarchy. 

In my model I have several different subframes where each subframe constitutes a machine. The reason why I chose to model this way is because every machine can execute different kinds of processes. In each process the pallet is unloaded and the MU's are being processed one by one. 

 

I have written some code telling that each process only can handle one pallet since only one pallet can be in the machine at the time. However, my methods only works per process. That is, pallets may enter two different processes at the same time - which is wrong!

I use the boolean global variable machineOccupy in order to see if there are any pallets in the process. How can I use this variable in order to make sure that only one process is working at the time?
I have a thought of using entrance controls for buffers outside the sub-frame that is connected with the global variable inside the subframe, but I do not see how it could work. Or how it could help me make sure that only one entrance is used at the time. 

 

A suggestion in the forum to a guy with a similair problem was to drag and drop the variable to the Models in the Library, but keeping the variable here and dragging it to the different frames where I want to use it does not work. 

 

Could someone please help me??

 

Kind regards,

Sophie

 

PS. "Palettenter" and Pelletexit" in the method in the enclosed photo are SingleProcs in the sub-frames Unbatch and Batch. 

 

6 REPLIES 6

Re: Same global variable in different frames

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
you can use the global variable by name (same frame) or path (somewhere in the model). You can have global variables with the same name in each sub-frame without problems.

"I have written some code telling that each process only can handle one pallet since only one pallet can be in the machine at the time. However, my methods only works per process. That is, pallets may enter two different processes at the same time - which is wrong!"

can you post this code?
If you want to have only one MU in the frame, you need to lock the frame. This you can do with a global variable inside the frame. If you move a part into the frame, you wait until this variable is false...e.g. call from the main frame:

waituntil frame.machineOccupied = false
@.move
frame.machineOccupied:=true

After exiting the frame, you need to set frame.machineOccupied to false.


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

Re: Same global variable in different frames

Creator
Creator

Hi Steffen!

 

It seems like the code you ask for isn't working as I thought it did. The code does not make sure that only one pallet enters a process at the time.. So now I have two problems to handle. The code I had written for the variable MachineOccupied to handle this is enclosed in the photo mainframe in my initial post. The name of the method is "OccupancyControl"

 

could you please help me? I don't know where to start with the problem anymore. 

 

Regards,

Sophie

Re: Same global variable in different frames

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
can you post your model?

Where do you call the methods? What is the content of the method OccupancyControl?
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Same global variable in different frames

Creator
Creator

Hi again,

 

Here are some photos of the rest of the subframes that can complement previous sent photos. My employer does not allow me to send the model due to confidential data in the tables. Is it possible to help me from what I have enclosed so far?

 

Regards,
Sophie 

Re: Same global variable in different frames

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
hard to say without a look into your model;
you could try the following in the occupancyControl:
set the variable already in the previous buffer to false, no entrance control in the first buffer:

if ?="PallettExit"
MachineOccupied:=false
elseif ?.~ /= self.~ then
--buffer outside3 the frame
waituntil self.~.MachineOccupied = false
self.~.machineOccupied:=true
@.move
end

You can also send your model to my mail-address, then I will have a look on it.
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Same global variable in different frames

Creator
Creator

Thank you very much Steffen!

 

I'll send you my model from my colleagues email, and we'll se if that will help us figure out the problem.

 

Best Regards

Sophie