Commit 246c4a2d authored by Georgios Dagkakis's avatar Georgios Dagkakis

Operator to be able to release current work in the end of shift

parent c0f50815
......@@ -213,6 +213,11 @@ class Machine(CoreObject):
loadTime['max'] = float(loadTime['mean']) + 5 * float(loadTime['stdev'])
return loadTime
# events about the availability of process operator
# TODO group those operator relate events
self.processOperatorAvailable=self.env.event()
self.processOperatorUnavailable=self.env.event()
#===========================================================================
# create an operatorPool if needed
......@@ -611,7 +616,8 @@ class Machine(CoreObject):
# and recalculate the processing time left tinM, passivate while waiting for repair.
# if a preemption has occurred then react accordingly (proceed with getting the critical entity)
# 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, self.processOperatorUnavailable])
if self.interruptionStart in receivedEvent: # if a failure occurs while processing the machine is interrupted.
transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
......@@ -671,6 +677,26 @@ class Machine(CoreObject):
self.brokerIsSet=self.env.event()
self.timeWaitForOperatorEnded = self.env.now
self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
# if the processing operator left
elif self.processOperatorUnavailable in receivedEvent:
assert self.env.now==self.processOperatorUnavailable.value, 'the operator leaving has not been processed at \
the time it should'
self.processOperatorUnavailable=self.env.event()
# machine has to release the operator
self.releaseOperator()
# request for allocation
self.requestAllocation()
# wait until the Broker has finished processing
yield self.brokerIsSet
self.brokerIsSet=self.env.event()
# carry interruption actions
self.interruptionActions()
# wait until there is available processing operator (to be sent by Router)
yield self.processOperatorAvailable # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.processOperatorAvailable.value, 'the operator available has not been received in time'
self.processOperatorAvailable=self.env.event()
# carry post interruption actions
self.postInterruptionActions()
# if the station is reactivated by the preempt method
elif(self.shouldPreempt):
if (self.preemptQueue in receivedEvent):
......
......@@ -61,7 +61,7 @@ class ShiftScheduler(ObjectInterruption):
# =======================================================================
def run(self):
from CoreObject import CoreObject
from ObjectInterruption import ObjectInterruption
from ObjectResource import ObjectResource
# the victim should not be interrupted but the scheduler should wait for the processing to finish before the stations turns to off-shift mode
self.victim.totalOffShiftTime=0
......@@ -109,9 +109,11 @@ class ShiftScheduler(ObjectInterruption):
self.victim.isLocked=True # lock the entry of the victim
yield self.env.timeout(self.receiveBeforeEndThreshold) # wait until the shift is over
self.victim.isLocked=False # unlock the entry of the victim
# if the mode is to end current work before going off-shift and there is current work, wait for victimEndedLastProcessing
# signal before going off-shift
# if the victim is station
if issubclass(self.victim.__class__, CoreObject):
# if the mode is to end current work before going off-shift and there is current work,
# wait for victimEndedLastProcessing
# signal before going off-shift
if self.endUnfinished and self.victim.isProcessing:
self.victim.isWorkingOnTheLast=True
self.waitingSignal=True
......@@ -124,6 +126,15 @@ class ShiftScheduler(ObjectInterruption):
transmitter, eventTime=self.victim.endedLastProcessing.value
self.victim.endedLastProcessing=self.env.event()
# if the victim is operator
elif issubclass(self.victim.__class__, ObjectResource):
# if the operator is working in a station and the mode is
# to stop current work in the end of shift
# signal to the station that the operator has to leave
station=self.victim.workingStation
if station:
if not self.endUnfinished and station.isProcessing:
station.processOperatorUnavailable.succeed(self.env.now)
# if the victim has interruptions that measure only the on-shift time, they have to be notified
for oi in self.victim.objectInterruptions:
......
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