Commit 09cf6663 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Ioannis Papagiannopoulos

parallel server examples updated in order to work with the new approach

parent ba85e941
...@@ -3,16 +3,13 @@ from dream.simulation.imports import simulate, activate, initialize, infinity ...@@ -3,16 +3,13 @@ from dream.simulation.imports import simulate, activate, initialize, infinity
#the custom queue #the custom queue
class SelectiveQueue(Queue): class SelectiveQueue(Queue):
def haveToDispose(self,callerObject=None): # override so that it first chooses M1 and then M2
caller=callerObject def selectReceiver(self,possibleReceivers=[]):
# if the caller is M1 then return true if there is an Entity to give if M1.canAccept():
if caller.id=='M1': return M1
return len(self.getActiveObjectQueue())>0 elif M2.canAccept():
# else return true only if M1 cannot accept the Entity return M2
if caller.id=='M2': return None
# find M1
M1=Globals.findObjectById('M1') # global method to obtain an object from the id
return len(self.getActiveObjectQueue())>0 and (not (M1.canAccept()))
#define the objects of the model #define the objects of the model
S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part') S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
......
...@@ -3,16 +3,13 @@ from dream.simulation.imports import simulate, activate, initialize, infinity ...@@ -3,16 +3,13 @@ from dream.simulation.imports import simulate, activate, initialize, infinity
#the custom queue #the custom queue
class SelectiveQueue(Queue): class SelectiveQueue(Queue):
def haveToDispose(self,callerObject=None): # override so that it first chooses M1 and then M2
caller=callerObject def selectReceiver(self,possibleReceivers=[]):
# if the caller is M1 then return true if there is an Entity to give if M1.canAccept():
if caller.id=='M1': return M1
return len(self.getActiveObjectQueue())>0 elif M2.canAccept():
# else return true only if M1 cannot accept the Entity return M2
if caller.id=='M2': return None
# find M1
M1=Globals.findObjectById('M1') # global method to obtain an object from the id
return len(self.getActiveObjectQueue())>0 and (not (M1.canAccept()))
#the custom machine #the custom machine
class Milling(Machine): class Milling(Machine):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment