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
#the custom queue
class SelectiveQueue(Queue):
def haveToDispose(self,callerObject=None):
caller=callerObject
# if the caller is M1 then return true if there is an Entity to give
if caller.id=='M1':
return len(self.getActiveObjectQueue())>0
# else return true only if M1 cannot accept the Entity
if caller.id=='M2':
# find M1
M1=Globals.findObjectById('M1') # global method to obtain an object from the id
return len(self.getActiveObjectQueue())>0 and (not (M1.canAccept()))
# override so that it first chooses M1 and then M2
def selectReceiver(self,possibleReceivers=[]):
if M1.canAccept():
return M1
elif M2.canAccept():
return M2
return None
#define the objects of the model
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
#the custom queue
class SelectiveQueue(Queue):
def haveToDispose(self,callerObject=None):
caller=callerObject
# if the caller is M1 then return true if there is an Entity to give
if caller.id=='M1':
return len(self.getActiveObjectQueue())>0
# else return true only if M1 cannot accept the Entity
if caller.id=='M2':
# find M1
M1=Globals.findObjectById('M1') # global method to obtain an object from the id
return len(self.getActiveObjectQueue())>0 and (not (M1.canAccept()))
# override so that it first chooses M1 and then M2
def selectReceiver(self,possibleReceivers=[]):
if M1.canAccept():
return M1
elif M2.canAccept():
return M2
return None
#the custom 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