Commit 1c7bac62 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Machine to be able to give an entity even if it is interrupted (if...

Machine to be able to give an entity even if it is interrupted (if deliverOnInterruption is set as true in the input)
parent e1fd6156
...@@ -135,7 +135,6 @@ class Machine(CoreObject): ...@@ -135,7 +135,6 @@ class Machine(CoreObject):
G.MachineList.append(self) # add machine to global MachineList G.MachineList.append(self) # add machine to global MachineList
if self.operatorPool!="None": if self.operatorPool!="None":
G.OperatedMachineList.append(self) # add the machine to the operatedMachines List G.OperatedMachineList.append(self) # add the machine to the operatedMachines List
# ======================================================================= # =======================================================================
# initialize the machine # initialize the machine
...@@ -770,19 +769,33 @@ class Machine(CoreObject): ...@@ -770,19 +769,33 @@ class Machine(CoreObject):
self.interruptionActions() # execute interruption actions self.interruptionActions() # execute interruption actions
# loop until we reach at a state that there is no interruption # loop until we reach at a state that there is no interruption
while 1: while 1:
self.expectedSignals['interruptionEnd']=1 self.expectedSignals['interruptionEnd']=1
if not self.canDeliverOnInterruption:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption receivedEvent=yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
# if the object canDeliverOnInterruption then it has to wait also for canDispose
transmitter, eventTime=self.interruptionEnd.value else:
assert eventTime==self.env.now, 'the victim of the failure is not the object that received it' self.expectedSignals['canDispose']=1
self.interruptionEnd=self.env.event() receivedEvent=yield self.env.any_of([self.canDispose , self.interruptionEnd])
# if there is no other interruption # if we have interruption end
if self.Up and self.onShift: if (self.interruptionEnd in receivedEvent) or (not self.canDeliverOnInterruption):
# Machine is back to blocked state transmitter, eventTime=self.interruptionEnd.value
self.isBlocked=True assert eventTime==self.env.now, 'the victim of the failure is not the object that received it'
break self.interruptionEnd=self.env.event()
# if there is no other interruption
if self.Up and self.onShift:
# Machine is back to blocked state
self.isBlocked=True
break
# else signalReceiver and continue
elif (self.canDispose in receivedEvent) and self.canDeliverOnInterruption:
transmitter, eventTime=self.canDispose.value
if eventTime!=self.env.now:
self.canDispose=self.env.event()
continue
assert eventTime==self.env.now,'canDispose signal is late'
self.canDispose=self.env.event()
self.signalReceiver()
continue
self.postInterruptionActions() self.postInterruptionActions()
if self.signalReceiver(): if self.signalReceiver():
self.timeLastBlockageStarted=self.env.now self.timeLastBlockageStarted=self.env.now
......
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