Commit 3df8379c authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

basic signalling altered. now succeed() should be provided with the...

basic signalling altered. now succeed() should be provided with the transmitter and the time as arguments
parent 6c8fdf8e
...@@ -156,7 +156,8 @@ class Assembly(CoreObject): ...@@ -156,7 +156,8 @@ class Assembly(CoreObject):
# wait until the Queue can accept an entity and one predecessor requests it # wait until the Queue can accept an entity and one predecessor requests it
yield self.isRequested #[self.isRequested,self.canDispose, self.loadOperatorAvailable] yield self.isRequested #[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if self.isRequested.value: if self.isRequested.value:
self.printTrace(self.id, isRequested=self.isRequested.value.id) transmitter, eventTime=self.isRequested.value
self.printTrace(self.id, isRequested=transmitter.id)
# reset the isRequested signal parameter # reset the isRequested signal parameter
self.isRequested=self.env.event() self.isRequested=self.env.event()
...@@ -166,7 +167,8 @@ class Assembly(CoreObject): ...@@ -166,7 +167,8 @@ class Assembly(CoreObject):
self.printTrace(self.id, waitEvent='(to load parts)') self.printTrace(self.id, waitEvent='(to load parts)')
yield self.isRequested yield self.isRequested
if self.isRequested.value: if self.isRequested.value:
self.printTrace(self.id, isRequested=self.isRequested.value.id) transmitter, eventTime=self.isRequested.value
self.printTrace(self.id, isRequested=transmitter.id)
# reset the isRequested signal parameter # reset the isRequested signal parameter
self.isRequested=self.env.event() self.isRequested=self.env.event()
# TODO: fix the getEntity 'Part' case # TODO: fix the getEntity 'Part' case
...@@ -205,14 +207,16 @@ class Assembly(CoreObject): ...@@ -205,14 +207,16 @@ class Assembly(CoreObject):
# if there was interruption # if there was interruption
# TODO not good implementation # TODO not good implementation
if self.interruptionStart in receivedEvent: if self.interruptionStart in receivedEvent:
assert self.interruptionStart.value==self.env.now, 'the interruption has not been processed on the time of activation' transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
# wait for the end of the interruption # wait for the end of the interruption
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:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it' transmitter, eventTime=self.interruptionEnd.value
assert eventTime==self.env.now, 'the victim of the failure is not the object that received it'
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
if self.Up and self.onShift: if self.Up and self.onShift:
break break
...@@ -223,10 +227,11 @@ class Assembly(CoreObject): ...@@ -223,10 +227,11 @@ class Assembly(CoreObject):
else: else:
continue continue
if self.canDispose in receivedEvent: if self.canDispose in receivedEvent:
if self.canDispose.value!=self.env.now: transmitter, eventTime=self.canDispose.value
if eventTime!=self.env.now:
self.canDispose=self.env.event() self.canDispose=self.env.event()
continue continue
assert self.canDispose.value==self.env.now,'canDispose signal is late' assert eventTime==self.env.now,'canDispose signal is late'
self.canDispose=self.env.event() self.canDispose=self.env.event()
# try to signal a receiver, if successful then proceed to get an other entity # try to signal a receiver, if successful then proceed to get an other entity
if self.signalReceiver(): if self.signalReceiver():
...@@ -242,8 +247,9 @@ class Assembly(CoreObject): ...@@ -242,8 +247,9 @@ class Assembly(CoreObject):
self.waitEntityRemoval=True self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)') self.printTrace(self.id, waitEvent='(entityRemoved)')
yield self.entityRemoved yield self.entityRemoved
self.printTrace(self.id, entityRemoved=self.entityRemoved.value) transmitter, eventTime=self.entityRemoved.value
assert self.entityRemoved.value==self.env.now,'entityRemoved event activated earlier than received' self.printTrace(self.id, entityRemoved=eventTime)
assert eventTime==self.env.now,'entityRemoved event activated earlier than received'
self.waitEntityRemoval=False self.waitEntityRemoval=False
self.entityRemoved=self.env.event() self.entityRemoved=self.env.event()
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed # if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
......
...@@ -103,12 +103,14 @@ class Conveyer(CoreObject): ...@@ -103,12 +103,14 @@ class Conveyer(CoreObject):
#set it as the timeToWait of the conveyerMover and raise call=true so that it will be triggered #set it as the timeToWait of the conveyerMover and raise call=true so that it will be triggered
if self.updateMoveTime(): if self.updateMoveTime():
# print self.id, 'time to move', self.conveyerMover.timeToWait # print self.id, 'time to move', self.conveyerMover.timeToWait
self.conveyerMover.canMove.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.conveyerMover.canMove.succeed(succeedTuple)
self.printTrace(self.id, waitEvent='') self.printTrace(self.id, waitEvent='')
receivedEvent=yield self.env.any_of([self.isRequested , self.canDispose , self.moveEnd]) # , self.loadOperatorAvailable] receivedEvent=yield self.env.any_of([self.isRequested , self.canDispose , self.moveEnd]) # , self.loadOperatorAvailable]
# if the event that activated the thread is isRequested then getEntity # if the event that activated the thread is isRequested then getEntity
if self.isRequested in receivedEvent: if self.isRequested in receivedEvent:
transmitter, eventTime=self.isRequested.value
self.printTrace(self.id, isRequested='') self.printTrace(self.id, isRequested='')
# reset the isRequested signal parameter # reset the isRequested signal parameter
self.isRequested=self.env.event() self.isRequested=self.env.event()
...@@ -122,10 +124,12 @@ class Conveyer(CoreObject): ...@@ -122,10 +124,12 @@ class Conveyer(CoreObject):
# self.loadOperatorAvailable.value=None # self.loadOperatorAvailable.value=None
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer # if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if self.canDispose in receivedEvent: if self.canDispose in receivedEvent:
transmitter, eventTime=self.canDispose.value
self.printTrace(self.id, canDispose='') self.printTrace(self.id, canDispose='')
self.canDispose=self.env.event() self.canDispose=self.env.event()
# if the object received a moveEnd signal from the ConveyerMover # if the object received a moveEnd signal from the ConveyerMover
if self.moveEnd in receivedEvent: if self.moveEnd in receivedEvent:
transmitter, eventTime=self.moveEnd.value
self.printTrace(self.id, moveEnd='') self.printTrace(self.id, moveEnd='')
self.moveEnd=self.env.event() self.moveEnd=self.env.event()
# check if there is a possibility to accept and signal a giver # check if there is a possibility to accept and signal a giver
...@@ -359,7 +363,8 @@ class Conveyer(CoreObject): ...@@ -359,7 +363,8 @@ class Conveyer(CoreObject):
#calculate the time that the conveyer will become available again and trigger the conveyerMover #calculate the time that the conveyer will become available again and trigger the conveyerMover
if self.updateMoveTime(): if self.updateMoveTime():
# print self.id, 'time to move', self.conveyerMover.timeToWait # print self.id, 'time to move', self.conveyerMover.timeToWait
self.conveyerMover.canMove.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.conveyerMover.canMove.succeed(succeedTuple)
# if there is anything to dispose of then signal a receiver # if there is anything to dispose of then signal a receiver
if self.haveToDispose(): if self.haveToDispose():
self.printTrace(self.id, attemptSingalReceiver='(removeEntity)') self.printTrace(self.id, attemptSingalReceiver='(removeEntity)')
...@@ -519,13 +524,15 @@ class ConveyerMover(object): ...@@ -519,13 +524,15 @@ class ConveyerMover(object):
while 1: while 1:
self.conveyer.printTrace(self.conveyer.id, waitEvent='(canMove)') self.conveyer.printTrace(self.conveyer.id, waitEvent='(canMove)')
yield self.canMove #wait until the conveyer triggers the mover yield self.canMove #wait until the conveyer triggers the mover
transmitter, eventTime=self.canMove.value
self.canMove=self.env.event() self.canMove=self.env.event()
self.conveyer.printTrace(self.conveyer.id, received='(canMove)') self.conveyer.printTrace(self.conveyer.id, received='(canMove)')
yield self.env.timeout(self.timeToWait) #wait for the time that the conveyer calculated yield self.env.timeout(self.timeToWait) #wait for the time that the conveyer calculated
# continue if interrupted # continue if interrupted
self.conveyer.moveEntities() # move the entities of the conveyer self.conveyer.moveEntities() # move the entities of the conveyer
self.conveyer.moveEnd.succeed(self.env.now) # send a signal to the conveyer that the move has ended succeedTuple=(self,self.env.now)
self.conveyer.moveEnd.succeed(succeedTuple) # send a signal to the conveyer that the move has ended
...@@ -267,11 +267,13 @@ class CoreObject(ManPyObject): ...@@ -267,11 +267,13 @@ class CoreObject(ManPyObject):
# print self.id,'triggered and waiting' # print self.id,'triggered and waiting'
self.entityRemoved=self.env.event() self.entityRemoved=self.env.event()
self.printTrace(self.id, signal='(removedEntity)') self.printTrace(self.id, signal='(removedEntity)')
self.entityRemoved.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.entityRemoved.succeed(succeedTuple)
elif self.waitEntityRemoval: elif self.waitEntityRemoval:
# print self.id,'not triggered and waiting' # print self.id,'not triggered and waiting'
self.printTrace(self.id, signal='(removedEntity)') self.printTrace(self.id, signal='(removedEntity)')
self.entityRemoved.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.entityRemoved.succeed(succeedTuple)
elif not self.waitEntityRemoval: elif not self.waitEntityRemoval:
# print self.id,'not triggered but not waiting' # print self.id,'not triggered but not waiting'
pass pass
...@@ -460,7 +462,8 @@ class CoreObject(ManPyObject): ...@@ -460,7 +462,8 @@ class CoreObject(ManPyObject):
self.printTrace(self.id, signalReceiver=self.receiver.id) self.printTrace(self.id, signalReceiver=self.receiver.id)
# assign the entry of the receiver # assign the entry of the receiver
self.receiver.assignEntryTo() self.receiver.assignEntryTo()
self.receiver.isRequested.succeed(self) succeedTuple=(self,self.env.now)
self.receiver.isRequested.succeed(succeedTuple)
return True return True
# if no receiver can accept then try to preempt a receive if the stations holds a critical order # if no receiver can accept then try to preempt a receive if the stations holds a critical order
self.preemptReceiver() self.preemptReceiver()
...@@ -531,7 +534,8 @@ class CoreObject(ManPyObject): ...@@ -531,7 +534,8 @@ class CoreObject(ManPyObject):
self.giver=giver self.giver=giver
self.giver.receiver=self self.giver.receiver=self
self.printTrace(self.id, signalGiver=self.giver.id) self.printTrace(self.id, signalGiver=self.giver.id)
self.giver.canDispose.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.giver.canDispose.succeed(succeedTuple)
return True return True
return False return False
......
...@@ -280,7 +280,8 @@ def setWIP(entityList): ...@@ -280,7 +280,8 @@ def setWIP(entityList):
if issubclass(entity.currentStation.__class__, Queue): if issubclass(entity.currentStation.__class__, Queue):
# send the signal only if it is not already triggered # send the signal only if it is not already triggered
if not entity.currentStation.canDispose.triggered: if not entity.currentStation.canDispose.triggered:
entity.currentStation.canDispose.succeed(G.env.now) succeedTuple=(G.env,G.env.now)
entity.currentStation.canDispose.succeed(succeedTuple)
# if we are in the start of the simulation the object is of server type then we should send initialWIP signal # if we are in the start of the simulation the object is of server type then we should send initialWIP signal
# TODO, maybe use 'class_family attribute here' # TODO, maybe use 'class_family attribute here'
if G.env.now==0 and entity.currentStation: if G.env.now==0 and entity.currentStation:
...@@ -291,7 +292,8 @@ def setWIP(entityList): ...@@ -291,7 +292,8 @@ def setWIP(entityList):
# trigger initialWIP event only if it has not been triggered. Otherwise # trigger initialWIP event only if it has not been triggered. Otherwise
# if we set more than one entities (e.g. in reassembly) it will crash # if we set more than one entities (e.g. in reassembly) it will crash
if not (entity.currentStation.initialWIP.triggered): if not (entity.currentStation.initialWIP.triggered):
entity.currentStation.initialWIP.succeed(G.env) succeedTuple=(G.env,G.env.now)
entity.currentStation.initialWIP.succeed(succeedTuple)
def countIntervalThroughput(): def countIntervalThroughput():
......
...@@ -327,8 +327,10 @@ class Machine(CoreObject): ...@@ -327,8 +327,10 @@ class Machine(CoreObject):
self.printTrace(self.id, received='') self.printTrace(self.id, received='')
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity # if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if self.isRequested in receivedEvent: if self.isRequested in receivedEvent:
self.printTrace(self.id, isRequested=self.isRequested.value.id) transmitter, eventTime=self.isRequested.value
assert self.isRequested.value==self.giver, 'the giver is not the requestingObject' self.printTrace(self.id, isRequested=transmitter.id)
assert eventTime==self.env.now, 'isRequested was triggered earlier, not now'
assert transmitter==self.giver, 'the giver is not the requestingObject'
assert self.giver.receiver==self, 'the receiver of the signalling object in not the station' assert self.giver.receiver==self, 'the receiver of the signalling object in not the station'
# reset the signalparam of the isRequested event # reset the signalparam of the isRequested event
self.isRequested=self.env.event() self.isRequested=self.env.event()
...@@ -337,18 +339,22 @@ class Machine(CoreObject): ...@@ -337,18 +339,22 @@ class Machine(CoreObject):
# if an operator was rendered available while it was needed by the machine to proceed with getEntity # if an operator was rendered available while it was needed by the machine to proceed with getEntity
if self.interruptionEnd in receivedEvent or self.loadOperatorAvailable in receivedEvent: if self.interruptionEnd in receivedEvent or self.loadOperatorAvailable in receivedEvent:
if self.interruptionEnd in receivedEvent: if self.interruptionEnd in receivedEvent:
assert self.interruptionEnd.value==self.env.now, 'interruptionEnd received later than created' transmitter, eventTime=self.interruptionEnd.value
self.printTrace(self.id, interruptionEnd=str(self.interruptionEnd.value)) assert eventTime==self.env.now, 'interruptionEnd received later than created'
self.printTrace(self.id, interruptionEnd=str(eventTime))
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
if self.loadOperatorAvailable in receivedEvent: if self.loadOperatorAvailable in receivedEvent:
assert self.loadOperatorAvailable.value==self.env.now,'loadOperatorAvailable received later than created' transmitter, eventTime=self.loadOperatorAvailable.value
self.printTrace(self.id,loadOperatorAvailable=str(self.loadOperatorAvailable.value)) assert eventTime==self.env.now,'loadOperatorAvailable received later than created'
self.printTrace(self.id,loadOperatorAvailable=str(eventTime))
self.loadOperatorAvailable=self.env.event() self.loadOperatorAvailable=self.env.event()
# try to signal the Giver, otherwise wait until it is requested # try to signal the Giver, otherwise wait until it is requested
if self.signalGiver(): if self.signalGiver():
break break
if self.initialWIP in receivedEvent: if self.initialWIP in receivedEvent:
assert self.initialWIP.value==self.env, 'initial wip was not sent by the Environment' transmitter, eventTime=self.initialWIP.value
assert transmitter==self.env, 'initialWIP was not sent by the Environment'
assert eventTime==self.env.now, 'initialWIP was not received on time'
self.initialWIP=self.env.event() self.initialWIP=self.env.event()
self.isProcessingInitialWIP=True self.isProcessingInitialWIP=True
break break
...@@ -371,6 +377,9 @@ class Machine(CoreObject): ...@@ -371,6 +377,9 @@ class Machine(CoreObject):
self.timeWaitForLoadOperatorStarted = self.env.now self.timeWaitForLoadOperatorStarted = self.env.now
# wait until the Broker has waited times equal to loadTime (if any) # wait until the Broker has waited times equal to loadTime (if any)
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
self.timeWaitForLoadOperatorEnded = self.env.now self.timeWaitForLoadOperatorEnded = self.env.now
self.loadOperatorWaitTimeCurrentEntity += self.timeWaitForLoadOperatorEnded-self.timeWaitForLoadOperatorStarted self.loadOperatorWaitTimeCurrentEntity += self.timeWaitForLoadOperatorEnded-self.timeWaitForLoadOperatorStarted
...@@ -396,6 +405,9 @@ class Machine(CoreObject): ...@@ -396,6 +405,9 @@ class Machine(CoreObject):
self.releaseOperator() self.releaseOperator()
# wait until the Broker has finished processing # wait until the Broker has finished processing
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
# TODO: reset the requestinEntity before receiving the currentEntity # TODO: reset the requestinEntity before receiving the currentEntity
...@@ -420,6 +432,9 @@ class Machine(CoreObject): ...@@ -420,6 +432,9 @@ class Machine(CoreObject):
self.timeWaitForOperatorStarted = self.env.now self.timeWaitForOperatorStarted = self.env.now
# wait until the Broker has waited times equal to loadTime (if any) # wait until the Broker has waited times equal to loadTime (if any)
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
self.timeWaitForOperatorEnded = self.env.now self.timeWaitForOperatorEnded = self.env.now
self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
...@@ -464,6 +479,9 @@ class Machine(CoreObject): ...@@ -464,6 +479,9 @@ class Machine(CoreObject):
self.releaseOperator() self.releaseOperator()
# wait until the Broker has finished processing # wait until the Broker has finished processing
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
# variables used to flag any interruptions and the end of the processing # variables used to flag any interruptions and the end of the processing
...@@ -478,7 +496,8 @@ class Machine(CoreObject): ...@@ -478,7 +496,8 @@ class Machine(CoreObject):
for oi in self.objectInterruptions: for oi in self.objectInterruptions:
if oi.type=='Failure': if oi.type=='Failure':
if oi.deteriorationType=='working': if oi.deteriorationType=='working':
oi.victimStartsProcess.succeed(self.env.now) succeedTuple=(self,self.env.now)
oi.victimStartsProcess.succeed(succeedTuple)
# this loop is repeated until the processing time is expired with no failure # this loop is repeated until the processing time is expired with no failure
# check when the processingEndedFlag switched to false # check when the processingEndedFlag switched to false
...@@ -495,7 +514,8 @@ class Machine(CoreObject): ...@@ -495,7 +514,8 @@ class Machine(CoreObject):
# receivedEvent = yield self.env.timeout(self.tinM) | self.interruptionStart | self.preemptQueue # receivedEvent = yield self.env.timeout(self.tinM) | self.interruptionStart | self.preemptQueue
receivedEvent = yield self.env.any_of([self.interruptionStart, self.env.timeout(self.tinM) , self.preemptQueue]) receivedEvent = yield self.env.any_of([self.interruptionStart, self.env.timeout(self.tinM) , self.preemptQueue])
if self.interruptionStart in receivedEvent: # if a failure occurs while processing the machine is interrupted. if self.interruptionStart in receivedEvent: # if a failure occurs while processing the machine is interrupted.
assert self.interruptionStart.value==self.env.now, 'the interruption has not been processed on the time of activation' transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
self.interruptionActions() # execute interruption actions self.interruptionActions() # execute interruption actions
...@@ -505,12 +525,16 @@ class Machine(CoreObject): ...@@ -505,12 +525,16 @@ class Machine(CoreObject):
and any(type=="Processing" for type in self.multOperationTypeList): and any(type=="Processing" for type in self.multOperationTypeList):
self.releaseOperator() self.releaseOperator()
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
# 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:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it' transmitter, eventTime=self.interruptionEnd.value
assert eventTime==self.env.now, 'the interruptionEnd was received later than anticipated'
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
if self.Up and self.onShift: if self.Up and self.onShift:
break break
...@@ -524,13 +548,17 @@ class Machine(CoreObject): ...@@ -524,13 +548,17 @@ class Machine(CoreObject):
self.timeWaitForOperatorStarted = self.env.now self.timeWaitForOperatorStarted = self.env.now
self.requestOperator() self.requestOperator()
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
self.timeWaitForOperatorEnded = self.env.now self.timeWaitForOperatorEnded = self.env.now
self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
# if the station is reactivated by the preempt method # if the station is reactivated by the preempt method
elif(self.shouldPreempt): elif(self.shouldPreempt):
if (self.preemptQueue in receivedEvent): if (self.preemptQueue in receivedEvent):
assert self.preemptQueue.value==self.env.now, 'the preemption must be performed on the time of request' transmitter, eventTime=self.preemptQueue.value
assert eventTime==self.env.now, 'the preemption must be performed on the time of request'
self.preemptQueue=self.env.event() self.preemptQueue=self.env.event()
self.interruptionActions() # execute interruption actions self.interruptionActions() # execute interruption actions
...@@ -540,6 +568,9 @@ class Machine(CoreObject): ...@@ -540,6 +568,9 @@ class Machine(CoreObject):
and any(type=="Processing" for type in self.multOperationTypeList): and any(type=="Processing" for type in self.multOperationTypeList):
self.releaseOperator() self.releaseOperator()
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
self.postInterruptionActions() self.postInterruptionActions()
...@@ -558,6 +589,9 @@ class Machine(CoreObject): ...@@ -558,6 +589,9 @@ class Machine(CoreObject):
and not self.interruption: and not self.interruption:
self.releaseOperator() self.releaseOperator()
yield self.brokerIsSet yield self.brokerIsSet
transmitter, eventTime=self.brokerIsSet.value
assert transmitter==self.broker, 'brokerIsSet is not sent by the stations broker'
assert eventTime==self.env.now, 'brokerIsSet is not received on time'
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
# signal the receiver that the activeObject has something to dispose of # signal the receiver that the activeObject has something to dispose of
if not self.signalReceiver(): if not self.signalReceiver():
...@@ -570,14 +604,16 @@ class Machine(CoreObject): ...@@ -570,14 +604,16 @@ class Machine(CoreObject):
# if there was interruption # if there was interruption
# TODO not good implementation # TODO not good implementation
if self.interruptionStart in receivedEvent: if self.interruptionStart in receivedEvent:
assert self.interruptionStart.value==self.env.now, 'the interruption has not been processed on the time of activation' transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
# wait for the end of the interruption # wait for the end of the interruption
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:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it' transmitter, eventTime=self.interruptionEnd.value
assert eventTime==self.env.now, 'the victim of the failure is not the object that received it'
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
if self.Up and self.onShift: if self.Up and self.onShift:
break break
...@@ -588,10 +624,11 @@ class Machine(CoreObject): ...@@ -588,10 +624,11 @@ class Machine(CoreObject):
else: else:
continue continue
if self.canDispose in receivedEvent: if self.canDispose in receivedEvent:
if self.canDispose.value!=self.env.now: transmitter, eventTime=self.canDispose.value
if eventTime!=self.env.now:
self.canDispose=self.env.event() self.canDispose=self.env.event()
continue continue
assert self.canDispose.value==self.env.now,'canDispose signal is late' assert eventTime==self.env.now,'canDispose signal is late'
self.canDispose=self.env.event() self.canDispose=self.env.event()
# try to signal a receiver, if successful then proceed to get an other entity # try to signal a receiver, if successful then proceed to get an other entity
if self.signalReceiver(): if self.signalReceiver():
...@@ -605,8 +642,9 @@ class Machine(CoreObject): ...@@ -605,8 +642,9 @@ class Machine(CoreObject):
self.waitEntityRemoval=True self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)') self.printTrace(self.id, waitEvent='(entityRemoved)')
yield self.entityRemoved yield self.entityRemoved
self.printTrace(self.id, entityRemoved=self.entityRemoved.value) transmitter, eventTime=self.entityRemoved.value
assert self.entityRemoved.value==self.env.now,'entityRemoved event activated earlier than received' self.printTrace(self.id, entityRemoved=eventTime)
assert eventTime==self.env.now,'entityRemoved event activated earlier than received'
self.waitEntityRemoval=False self.waitEntityRemoval=False
self.entityRemoved=self.env.event() self.entityRemoved=self.env.event()
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed # if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
...@@ -669,7 +707,8 @@ class Machine(CoreObject): ...@@ -669,7 +707,8 @@ class Machine(CoreObject):
for oi in self.objectInterruptions: for oi in self.objectInterruptions:
if oi.type=='Failure': if oi.type=='Failure':
if oi.deteriorationType=='working': if oi.deteriorationType=='working':
oi.victimEndsProcess.succeed(self.env.now) succeedTuple=(self,self.env.now)
oi.victimEndsProcess.succeed(succeedTuple)
# in case Machine just performed the last work before the scheduled maintenance signal the corresponding object # in case Machine just performed the last work before the scheduled maintenance signal the corresponding object
if self.isWorkingOnTheLast: if self.isWorkingOnTheLast:
...@@ -679,7 +718,8 @@ class Machine(CoreObject): ...@@ -679,7 +718,8 @@ class Machine(CoreObject):
# if the objectInterruption is waiting for a a signal # if the objectInterruption is waiting for a a signal
if interruption.victim==self and interruption.waitingSignal: if interruption.victim==self and interruption.waitingSignal:
# signal it and reset the flags # signal it and reset the flags
self.endedLastProcessing.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.endedLastProcessing.succeed(succeedTuple)
interruption.waitinSignal=False interruption.waitinSignal=False
self.isWorkingOnTheLast=False self.isWorkingOnTheLast=False
# set timeLastShiftEnded attribute so that if it is overtime working it is not counted as off-shift time # set timeLastShiftEnded attribute so that if it is overtime working it is not counted as off-shift time
......
...@@ -72,7 +72,8 @@ class ObjectInterruption(ManPyObject): ...@@ -72,7 +72,8 @@ class ObjectInterruption(ManPyObject):
# signalling can be done via Machine request/releaseOperator # signalling can be done via Machine request/releaseOperator
# ======================================================================= # =======================================================================
def invoke(self): def invoke(self):
self.isCalled.succeed(self.env.now) succeedTuple=(self.victim,self.env.now)
self.isCalled.succeed(succeedTuple)
#=========================================================================== #===========================================================================
# returns the internal queue of the victim # returns the internal queue of the victim
...@@ -94,7 +95,8 @@ class ObjectInterruption(ManPyObject): ...@@ -94,7 +95,8 @@ class ObjectInterruption(ManPyObject):
# inform the victim by whom will it be interrupted # inform the victim by whom will it be interrupted
# TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously # TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously
self.victim.interruptedBy=self.type self.victim.interruptedBy=self.type
self.victim.interruptionStart.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.victim.interruptionStart.succeed(succeedTuple)
# if the machines are operated by dedicated operators # if the machines are operated by dedicated operators
if self.victim.dedicatedOperator: if self.victim.dedicatedOperator:
# request allocation # request allocation
...@@ -104,7 +106,8 @@ class ObjectInterruption(ManPyObject): ...@@ -104,7 +106,8 @@ class ObjectInterruption(ManPyObject):
# reactivate the victim # reactivate the victim
#=========================================================================== #===========================================================================
def reactivateVictim(self): def reactivateVictim(self):
self.victim.interruptionEnd.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.victim.interruptionEnd.succeed(succeedTuple)
#reset the interruptionStart event of the victim #reset the interruptionStart event of the victim
self.victim.interruptionStart=self.env.event() self.victim.interruptionStart=self.env.event()
# TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously # TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously
......
...@@ -72,7 +72,8 @@ class Broker(ObjectInterruption): ...@@ -72,7 +72,8 @@ class Broker(ObjectInterruption):
while 1: while 1:
# TODO: add new broker event - brokerIsCalled # TODO: add new broker event - brokerIsCalled
yield self.isCalled yield self.isCalled
assert self.isCalled.value==self.env.now, 'the broker should be granted control instantly' transmitter, eventTime=self.isCalled.value
assert eventTime==self.env.now, 'the broker should be granted control instantly'
self.isCalled=self.env.event() self.isCalled=self.env.event()
self.victim.printTrace(self.victim.id, received='(broker)') self.victim.printTrace(self.victim.id, received='(broker)')
# ======= request a resource # ======= request a resource
...@@ -94,11 +95,13 @@ class Broker(ObjectInterruption): ...@@ -94,11 +95,13 @@ class Broker(ObjectInterruption):
if not G.Router.invoked: if not G.Router.invoked:
self.victim.printTrace(self.victim.id, signal='router (broker)') self.victim.printTrace(self.victim.id, signal='router (broker)')
G.Router.invoked=True G.Router.invoked=True
G.Router.isCalled.succeed(self.env.now) succeedTuple=(self,self.env.now)
G.Router.isCalled.succeed(succeedTuple)
self.waitForOperator=True self.waitForOperator=True
self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)') self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)')
yield self.resourceAvailable yield self.resourceAvailable
transmitter, eventTime=self.resourceAvailable.value
self.resourceAvailable=self.env.event() self.resourceAvailable=self.env.event()
# remove the currentEntity from the pendingEntities # remove the currentEntity from the pendingEntities
if self.victim.currentEntity in G.pendingEntities: if self.victim.currentEntity in G.pendingEntities:
...@@ -110,6 +113,7 @@ class Broker(ObjectInterruption): ...@@ -110,6 +113,7 @@ class Broker(ObjectInterruption):
self.waitForOperator=True self.waitForOperator=True
self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)') self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)')
yield self.resourceAvailable yield self.resourceAvailable
transmitter, eventTime=self.resourceAvailable.value
self.resourceAvailable=self.env.event() self.resourceAvailable=self.env.event()
self.waitForOperator=False self.waitForOperator=False
#=============================================================== #===============================================================
...@@ -132,13 +136,15 @@ class Broker(ObjectInterruption): ...@@ -132,13 +136,15 @@ class Broker(ObjectInterruption):
self.victim.outputTrace(self.victim.currentOperator.objName, "started work in "+ self.victim.objName) self.victim.outputTrace(self.victim.currentOperator.objName, "started work in "+ self.victim.objName)
self.victim.currentOperator.timeLastOperationStarted=self.env.now#() self.victim.currentOperator.timeLastOperationStarted=self.env.now#()
# signal the machine that an operator is reserved # signal the machine that an operator is reserved
self.victim.brokerIsSet.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.victim.brokerIsSet.succeed(succeedTuple)
# update the schedule of the operator # update the schedule of the operator
self.victim.currentOperator.schedule.append([self.victim, self.env.now]) self.victim.currentOperator.schedule.append([self.victim, self.env.now])
# wait till the processing is over # wait till the processing is over
yield self.isCalled yield self.isCalled
assert self.isCalled.value==self.env.now, 'the broker should be granted control instantly' transmitter, eventTime=self.isCalled.value
assert eventTime==self.env.now, 'the broker should be granted control instantly'
self.isCalled=self.env.event() self.isCalled=self.env.event()
# The operator is released (the router is not called in the case of skilled ops that work constantly on the same machine) # The operator is released (the router is not called in the case of skilled ops that work constantly on the same machine)
...@@ -153,7 +159,8 @@ class Broker(ObjectInterruption): ...@@ -153,7 +159,8 @@ class Broker(ObjectInterruption):
if not self.victim.router.invoked: if not self.victim.router.invoked:
self.victim.printTrace(self.victim.id, signal='router (broker)') self.victim.printTrace(self.victim.id, signal='router (broker)')
self.victim.router.invoked=True self.victim.router.invoked=True
self.victim.router.isCalled.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.victim.router.isCalled.succeed(succeedTuple)
# TODO: signalling the router will give the chance to it to take the control, but when will it eventually receive it. # TODO: signalling the router will give the chance to it to take the control, but when will it eventually receive it.
# after signalling the broker will signal it's victim that it has finished it's processes # after signalling the broker will signal it's victim that it has finished it's processes
# TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers. # TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers.
...@@ -168,5 +175,6 @@ class Broker(ObjectInterruption): ...@@ -168,5 +175,6 @@ class Broker(ObjectInterruption):
else: else:
pass pass
# return the control to the victim # return the control to the victim
self.victim.brokerIsSet.succeed(self.env.now) succeedTuple=(self,self.env.now)
self.victim.brokerIsSet.succeed(succeedTuple)
...@@ -107,6 +107,7 @@ class Router(ObjectInterruption): ...@@ -107,6 +107,7 @@ class Router(ObjectInterruption):
while 1: while 1:
# wait until the router is called # wait until the router is called
yield self.isCalled yield self.isCalled
transmitter, eventTime=self.isCalled.value
self.isCalled=self.env.event() self.isCalled=self.env.event()
self.printTrace('','=-'*15) self.printTrace('','=-'*15)
self.printTrace('','router received event') self.printTrace('','router received event')
...@@ -238,13 +239,15 @@ class Router(ObjectInterruption): ...@@ -238,13 +239,15 @@ class Router(ObjectInterruption):
elif station.broker.waitForOperator: elif station.broker.waitForOperator:
# signal this station's broker that the resource is available # signal this station's broker that the resource is available
self.printTrace('router', 'signalling broker of'+' '*50+operator.isAssignedTo().id) self.printTrace('router', 'signalling broker of'+' '*50+operator.isAssignedTo().id)
station.broker.resourceAvailable.succeed(self.env.now) succeedTuple=(self,self.env.now)
station.broker.resourceAvailable.succeed(succeedTuple)
else: else:
# signal the queue proceeding the station # signal the queue proceeding the station
if station.canAccept()\ if station.canAccept()\
and any(type=='Load' for type in station.multOperationTypeList): and any(type=='Load' for type in station.multOperationTypeList):
self.printTrace('router', 'signalling'+' '*50+operator.isAssignedTo().id) self.printTrace('router', 'signalling'+' '*50+operator.isAssignedTo().id)
station.loadOperatorAvailable.succeed(self.env.now) succeedTuple=(self,self.env.now)
station.loadOperatorAvailable.succeed(succeedTuple)
#=========================================================================== #===========================================================================
# clear the pending lists of the router # clear the pending lists of the router
......
...@@ -102,7 +102,8 @@ class Queue(CoreObject): ...@@ -102,7 +102,8 @@ class Queue(CoreObject):
self.printTrace(self.id, received='') self.printTrace(self.id, received='')
# if the event that activated the thread is isRequested then getEntity # if the event that activated the thread is isRequested then getEntity
if self.isRequested in receivedEvent: if self.isRequested in receivedEvent:
self.printTrace(self.id, isRequested=self.isRequested.value.id) transmitter, eventTime=self.isRequested.value
self.printTrace(self.id, isRequested=transmitter.id)
# reset the isRequested signal parameter # reset the isRequested signal parameter
self.isRequested=self.env.event() self.isRequested=self.env.event()
self.getEntity() self.getEntity()
...@@ -111,10 +112,11 @@ class Queue(CoreObject): ...@@ -111,10 +112,11 @@ class Queue(CoreObject):
activeObjectQueue[0].startTime=self.env.now activeObjectQueue[0].startTime=self.env.now
# if the queue received an loadOperatorIsAvailable (from Router) with signalparam time # if the queue received an loadOperatorIsAvailable (from Router) with signalparam time
if self.loadOperatorAvailable: if self.loadOperatorAvailable:
# self.printTrace(self.id, loadOperatorAvailable=str(self.loadOperatorAvailable.signalparam)) # transmitter, eventTime=self.loadOperatorAvailable.value
self.loadOperatorAvailable=self.env.event() self.loadOperatorAvailable=self.env.event()
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer # if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if self.canDispose in receivedEvent: if self.canDispose in receivedEvent:
transmitter, eventTime=self.canDispose.value
self.printTrace(self.id, canDispose='') self.printTrace(self.id, canDispose='')
self.canDispose=self.env.event() self.canDispose=self.env.event()
# if the event that activated the thread is canDispose then signalReceiver # if the event that activated the thread is canDispose then signalReceiver
......
...@@ -62,8 +62,9 @@ class EntityGenerator(object): ...@@ -62,8 +62,9 @@ class EntityGenerator(object):
self.victim.getActiveObjectQueue().append(entity) # append the entity to the resource self.victim.getActiveObjectQueue().append(entity) # append the entity to the resource
self.victim.numberOfArrivals+=1 # we have one new arrival self.victim.numberOfArrivals+=1 # we have one new arrival
G.numberOfEntities+=1 G.numberOfEntities+=1
self.victim.appendEntity(entity) self.victim.appendEntity(entity)
self.victim.entityCreated.succeed(entity) succeedTupple=(entity,self.env.now)
self.victim.entityCreated.succeed(succeedTupple)
# else put it on the time list for scheduled Entities # else put it on the time list for scheduled Entities
else: else:
entityCounter=G.numberOfEntities+len(self.victim.scheduledEntities) # this is used just ot output the trace correctly entityCounter=G.numberOfEntities+len(self.victim.scheduledEntities) # this is used just ot output the trace correctly
...@@ -138,11 +139,16 @@ class Source(CoreObject): ...@@ -138,11 +139,16 @@ class Source(CoreObject):
self.printTrace(self.id, received='') self.printTrace(self.id, received='')
# if an entity is created try to signal the receiver and continue # if an entity is created try to signal the receiver and continue
if self.entityCreated in receivedEvent: if self.entityCreated in receivedEvent:
transmitter, eventTime=self.entityCreated.value
self.entityCreated=self.env.event() self.entityCreated=self.env.event()
# otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of # otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of
if self.canDispose in receivedEvent or self.loadOperatorAvailable in receivedEvent: if self.canDispose in receivedEvent or self.loadOperatorAvailable in receivedEvent:
self.canDispose=self.env.event() if self.canDispose in receivedEvent:
self.loadOperatorAvailable=self.env.event() transmitter, eventTime=self.canDispose.value
self.canDispose=self.env.event()
if self.loadOperatorAvailable in receivedEvent:
transmitter, eventTime=self.loadOperatorAvailable.value
self.loadOperatorAvailable=self.env.event()
if self.haveToDispose(): if self.haveToDispose():
if self.signalReceiver(): if self.signalReceiver():
continue continue
...@@ -192,5 +198,6 @@ class Source(CoreObject): ...@@ -192,5 +198,6 @@ class Source(CoreObject):
self.appendEntity(newEntity) self.appendEntity(newEntity)
activeEntity=CoreObject.removeEntity(self, entity) # run the default method activeEntity=CoreObject.removeEntity(self, entity) # run the default method
if len(self.getActiveObjectQueue())==1: if len(self.getActiveObjectQueue())==1:
self.entityCreated.succeed(newEntity) succeedTuple=(newEntity,self.env.now)
self.entityCreated.succeed(succeedTuple)
return activeEntity return activeEntity
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