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):
# wait until the Queue can accept an entity and one predecessor requests it
yield self.isRequested #[self.isRequested,self.canDispose, self.loadOperatorAvailable]
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
self.isRequested=self.env.event()
......@@ -166,7 +167,8 @@ class Assembly(CoreObject):
self.printTrace(self.id, waitEvent='(to load parts)')
yield self.isRequested
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
self.isRequested=self.env.event()
# TODO: fix the getEntity 'Part' case
......@@ -205,14 +207,16 @@ class Assembly(CoreObject):
# if there was interruption
# TODO not good implementation
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()
# wait for the end of the interruption
self.interruptionActions() # execute interruption actions
# loop until we reach at a state that there is no interruption
while 1:
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()
if self.Up and self.onShift:
break
......@@ -223,10 +227,11 @@ class Assembly(CoreObject):
else:
continue
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()
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()
# try to signal a receiver, if successful then proceed to get an other entity
if self.signalReceiver():
......@@ -242,8 +247,9 @@ class Assembly(CoreObject):
self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)')
yield self.entityRemoved
self.printTrace(self.id, entityRemoved=self.entityRemoved.value)
assert self.entityRemoved.value==self.env.now,'entityRemoved event activated earlier than received'
transmitter, eventTime=self.entityRemoved.value
self.printTrace(self.id, entityRemoved=eventTime)
assert eventTime==self.env.now,'entityRemoved event activated earlier than received'
self.waitEntityRemoval=False
self.entityRemoved=self.env.event()
# 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):
#set it as the timeToWait of the conveyerMover and raise call=true so that it will be triggered
if self.updateMoveTime():
# 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='')
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 self.isRequested in receivedEvent:
transmitter, eventTime=self.isRequested.value
self.printTrace(self.id, isRequested='')
# reset the isRequested signal parameter
self.isRequested=self.env.event()
......@@ -122,10 +124,12 @@ class Conveyer(CoreObject):
# self.loadOperatorAvailable.value=None
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if self.canDispose in receivedEvent:
transmitter, eventTime=self.canDispose.value
self.printTrace(self.id, canDispose='')
self.canDispose=self.env.event()
# if the object received a moveEnd signal from the ConveyerMover
if self.moveEnd in receivedEvent:
transmitter, eventTime=self.moveEnd.value
self.printTrace(self.id, moveEnd='')
self.moveEnd=self.env.event()
# check if there is a possibility to accept and signal a giver
......@@ -359,7 +363,8 @@ class Conveyer(CoreObject):
#calculate the time that the conveyer will become available again and trigger the conveyerMover
if self.updateMoveTime():
# 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 self.haveToDispose():
self.printTrace(self.id, attemptSingalReceiver='(removeEntity)')
......@@ -519,13 +524,15 @@ class ConveyerMover(object):
while 1:
self.conveyer.printTrace(self.conveyer.id, waitEvent='(canMove)')
yield self.canMove #wait until the conveyer triggers the mover
transmitter, eventTime=self.canMove.value
self.canMove=self.env.event()
self.conveyer.printTrace(self.conveyer.id, received='(canMove)')
yield self.env.timeout(self.timeToWait) #wait for the time that the conveyer calculated
# continue if interrupted
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):
# print self.id,'triggered and waiting'
self.entityRemoved=self.env.event()
self.printTrace(self.id, signal='(removedEntity)')
self.entityRemoved.succeed(self.env.now)
succeedTuple=(self,self.env.now)
self.entityRemoved.succeed(succeedTuple)
elif self.waitEntityRemoval:
# print self.id,'not triggered and waiting'
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:
# print self.id,'not triggered but not waiting'
pass
......@@ -460,7 +462,8 @@ class CoreObject(ManPyObject):
self.printTrace(self.id, signalReceiver=self.receiver.id)
# assign the entry of the receiver
self.receiver.assignEntryTo()
self.receiver.isRequested.succeed(self)
succeedTuple=(self,self.env.now)
self.receiver.isRequested.succeed(succeedTuple)
return True
# if no receiver can accept then try to preempt a receive if the stations holds a critical order
self.preemptReceiver()
......@@ -531,7 +534,8 @@ class CoreObject(ManPyObject):
self.giver=giver
self.giver.receiver=self
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 False
......
......@@ -280,7 +280,8 @@ def setWIP(entityList):
if issubclass(entity.currentStation.__class__, Queue):
# send the signal only if it is not already 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
# TODO, maybe use 'class_family attribute here'
if G.env.now==0 and entity.currentStation:
......@@ -291,7 +292,8 @@ def setWIP(entityList):
# 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 not (entity.currentStation.initialWIP.triggered):
entity.currentStation.initialWIP.succeed(G.env)
succeedTuple=(G.env,G.env.now)
entity.currentStation.initialWIP.succeed(succeedTuple)
def countIntervalThroughput():
......
......@@ -327,8 +327,10 @@ class Machine(CoreObject):
self.printTrace(self.id, received='')
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if self.isRequested in receivedEvent:
self.printTrace(self.id, isRequested=self.isRequested.value.id)
assert self.isRequested.value==self.giver, 'the giver is not the requestingObject'
transmitter, eventTime=self.isRequested.value
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'
# reset the signalparam of the isRequested event
self.isRequested=self.env.event()
......@@ -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 self.interruptionEnd in receivedEvent or self.loadOperatorAvailable in receivedEvent:
if self.interruptionEnd in receivedEvent:
assert self.interruptionEnd.value==self.env.now, 'interruptionEnd received later than created'
self.printTrace(self.id, interruptionEnd=str(self.interruptionEnd.value))
transmitter, eventTime=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()
if self.loadOperatorAvailable in receivedEvent:
assert self.loadOperatorAvailable.value==self.env.now,'loadOperatorAvailable received later than created'
self.printTrace(self.id,loadOperatorAvailable=str(self.loadOperatorAvailable.value))
transmitter, eventTime=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()
# try to signal the Giver, otherwise wait until it is requested
if self.signalGiver():
break
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.isProcessingInitialWIP=True
break
......@@ -371,6 +377,9 @@ class Machine(CoreObject):
self.timeWaitForLoadOperatorStarted = self.env.now
# wait until the Broker has waited times equal to loadTime (if any)
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.timeWaitForLoadOperatorEnded = self.env.now
self.loadOperatorWaitTimeCurrentEntity += self.timeWaitForLoadOperatorEnded-self.timeWaitForLoadOperatorStarted
......@@ -396,6 +405,9 @@ class Machine(CoreObject):
self.releaseOperator()
# wait until the Broker has finished processing
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()
# TODO: reset the requestinEntity before receiving the currentEntity
......@@ -420,6 +432,9 @@ class Machine(CoreObject):
self.timeWaitForOperatorStarted = self.env.now
# wait until the Broker has waited times equal to loadTime (if any)
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.timeWaitForOperatorEnded = self.env.now
self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
......@@ -464,6 +479,9 @@ class Machine(CoreObject):
self.releaseOperator()
# wait until the Broker has finished processing
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()
# variables used to flag any interruptions and the end of the processing
......@@ -478,7 +496,8 @@ class Machine(CoreObject):
for oi in self.objectInterruptions:
if oi.type=='Failure':
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
# check when the processingEndedFlag switched to false
......@@ -495,7 +514,8 @@ class Machine(CoreObject):
# 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])
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.interruptionActions() # execute interruption actions
......@@ -505,12 +525,16 @@ class Machine(CoreObject):
and any(type=="Processing" for type in self.multOperationTypeList):
self.releaseOperator()
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()
# loop until we reach at a state that there is no interruption
while 1:
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()
if self.Up and self.onShift:
break
......@@ -524,13 +548,17 @@ class Machine(CoreObject):
self.timeWaitForOperatorStarted = self.env.now
self.requestOperator()
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.timeWaitForOperatorEnded = self.env.now
self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
# if the station is reactivated by the preempt method
elif(self.shouldPreempt):
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.interruptionActions() # execute interruption actions
......@@ -540,6 +568,9 @@ class Machine(CoreObject):
and any(type=="Processing" for type in self.multOperationTypeList):
self.releaseOperator()
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.postInterruptionActions()
......@@ -558,6 +589,9 @@ class Machine(CoreObject):
and not self.interruption:
self.releaseOperator()
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()
# signal the receiver that the activeObject has something to dispose of
if not self.signalReceiver():
......@@ -570,14 +604,16 @@ class Machine(CoreObject):
# if there was interruption
# TODO not good implementation
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()
# wait for the end of the interruption
self.interruptionActions() # execute interruption actions
# loop until we reach at a state that there is no interruption
while 1:
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()
if self.Up and self.onShift:
break
......@@ -588,10 +624,11 @@ class Machine(CoreObject):
else:
continue
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()
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()
# try to signal a receiver, if successful then proceed to get an other entity
if self.signalReceiver():
......@@ -605,8 +642,9 @@ class Machine(CoreObject):
self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)')
yield self.entityRemoved
self.printTrace(self.id, entityRemoved=self.entityRemoved.value)
assert self.entityRemoved.value==self.env.now,'entityRemoved event activated earlier than received'
transmitter, eventTime=self.entityRemoved.value
self.printTrace(self.id, entityRemoved=eventTime)
assert eventTime==self.env.now,'entityRemoved event activated earlier than received'
self.waitEntityRemoval=False
self.entityRemoved=self.env.event()
# 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):
for oi in self.objectInterruptions:
if oi.type=='Failure':
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
if self.isWorkingOnTheLast:
......@@ -679,7 +718,8 @@ class Machine(CoreObject):
# if the objectInterruption is waiting for a a signal
if interruption.victim==self and interruption.waitingSignal:
# signal it and reset the flags
self.endedLastProcessing.succeed(self.env.now)
succeedTuple=(self,self.env.now)
self.endedLastProcessing.succeed(succeedTuple)
interruption.waitinSignal=False
self.isWorkingOnTheLast=False
# 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):
# signalling can be done via Machine request/releaseOperator
# =======================================================================
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
......@@ -94,7 +95,8 @@ class ObjectInterruption(ManPyObject):
# inform the victim by whom will it be interrupted
# TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously
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 self.victim.dedicatedOperator:
# request allocation
......@@ -104,7 +106,8 @@ class ObjectInterruption(ManPyObject):
# reactivate the victim
#===========================================================================
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
self.victim.interruptionStart=self.env.event()
# TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously
......
......@@ -72,7 +72,8 @@ class Broker(ObjectInterruption):
while 1:
# TODO: add new broker event - brokerIsCalled
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.victim.printTrace(self.victim.id, received='(broker)')
# ======= request a resource
......@@ -94,11 +95,13 @@ class Broker(ObjectInterruption):
if not G.Router.invoked:
self.victim.printTrace(self.victim.id, signal='router (broker)')
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.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)')
yield self.resourceAvailable
transmitter, eventTime=self.resourceAvailable.value
self.resourceAvailable=self.env.event()
# remove the currentEntity from the pendingEntities
if self.victim.currentEntity in G.pendingEntities:
......@@ -110,6 +113,7 @@ class Broker(ObjectInterruption):
self.waitForOperator=True
self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)')
yield self.resourceAvailable
transmitter, eventTime=self.resourceAvailable.value
self.resourceAvailable=self.env.event()
self.waitForOperator=False
#===============================================================
......@@ -132,13 +136,15 @@ class Broker(ObjectInterruption):
self.victim.outputTrace(self.victim.currentOperator.objName, "started work in "+ self.victim.objName)
self.victim.currentOperator.timeLastOperationStarted=self.env.now#()
# 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
self.victim.currentOperator.schedule.append([self.victim, self.env.now])
# wait till the processing is over
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()
# 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):
if not self.victim.router.invoked:
self.victim.printTrace(self.victim.id, signal='router (broker)')
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.
# 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.
......@@ -168,5 +175,6 @@ class Broker(ObjectInterruption):
else:
pass
# 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):
while 1:
# wait until the router is called
yield self.isCalled
transmitter, eventTime=self.isCalled.value
self.isCalled=self.env.event()
self.printTrace('','=-'*15)
self.printTrace('','router received event')
......@@ -238,13 +239,15 @@ class Router(ObjectInterruption):
elif station.broker.waitForOperator:
# signal this station's broker that the resource is available
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:
# signal the queue proceeding the station
if station.canAccept()\
and any(type=='Load' for type in station.multOperationTypeList):
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
......
......@@ -102,7 +102,8 @@ class Queue(CoreObject):
self.printTrace(self.id, received='')
# if the event that activated the thread is isRequested then getEntity
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
self.isRequested=self.env.event()
self.getEntity()
......@@ -111,10 +112,11 @@ class Queue(CoreObject):
activeObjectQueue[0].startTime=self.env.now
# if the queue received an loadOperatorIsAvailable (from Router) with signalparam time
if self.loadOperatorAvailable:
# self.printTrace(self.id, loadOperatorAvailable=str(self.loadOperatorAvailable.signalparam))
# transmitter, eventTime=self.loadOperatorAvailable.value
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 self.canDispose in receivedEvent:
transmitter, eventTime=self.canDispose.value
self.printTrace(self.id, canDispose='')
self.canDispose=self.env.event()
# if the event that activated the thread is canDispose then signalReceiver
......
......@@ -63,7 +63,8 @@ class EntityGenerator(object):
self.victim.numberOfArrivals+=1 # we have one new arrival
G.numberOfEntities+=1
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:
entityCounter=G.numberOfEntities+len(self.victim.scheduledEntities) # this is used just ot output the trace correctly
......@@ -138,10 +139,15 @@ class Source(CoreObject):
self.printTrace(self.id, received='')
# if an entity is created try to signal the receiver and continue
if self.entityCreated in receivedEvent:
transmitter, eventTime=self.entityCreated.value
self.entityCreated=self.env.event()
# 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:
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.signalReceiver():
......@@ -192,5 +198,6 @@ class Source(CoreObject):
self.appendEntity(newEntity)
activeEntity=CoreObject.removeEntity(self, entity) # run the default method
if len(self.getActiveObjectQueue())==1:
self.entityCreated.succeed(newEntity)
succeedTuple=(newEntity,self.env.now)
self.entityCreated.succeed(succeedTuple)
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