Commit 76363b51 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

in case of single-machine-dedicated-skilled operators, the broker does not invoke the Router.

parent bb51d0ad
...@@ -80,29 +80,30 @@ class Broker(ObjectInterruption): ...@@ -80,29 +80,30 @@ class Broker(ObjectInterruption):
and any(type=='Load' or type=='Setup' or type=='Processing'\ and any(type=='Load' or type=='Setup' or type=='Processing'\
for type in self.victim.multOperationTypeList): for type in self.victim.multOperationTypeList):
# update the time that the station is waiting for the operator # update the time that the station is waiting for the operator
self.timeWaitForOperatorStarted=self.env.now#() self.timeWaitForOperatorStarted=self.env.now
#=============================================================== #===============================================================
# if the victim already holds an entity that means that the machine's operation type # if the victim already holds an entity that means that the machine's operation type
# is no Load or setup, in that case the router is already invoked and the machine is already assigned an operator # is no Load or setup, in that case the router is already invoked and the machine is already assigned an operator
from Globals import G from Globals import G
if not self.victimQueueIsEmpty(): if not self.victim.checkForSkilledOperators():
# add the currentEntity to the pendingEntities if not self.victimQueueIsEmpty():
if not self.victim.currentEntity in G.pendingEntities: # add the currentEntity to the pendingEntities
G.pendingEntities.append(self.victim.currentEntity) if not self.victim.currentEntity in G.pendingEntities:
if not G.Router.invoked: G.pendingEntities.append(self.victim.currentEntity)
self.victim.printTrace(self.victim.id, signal='router (broker)') if not G.Router.invoked:
G.Router.invoked=True self.victim.printTrace(self.victim.id, signal='router (broker)')
G.Router.isCalled.succeed(self.env.now) G.Router.invoked=True
G.Router.isCalled.succeed(self.env.now)
self.waitForOperator=True
self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)') self.waitForOperator=True
yield self.resourceAvailable self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)')
self.resourceAvailable=self.env.event() yield self.resourceAvailable
# remove the currentEntity from the pendingEntities self.resourceAvailable=self.env.event()
if self.victim.currentEntity in G.pendingEntities: # remove the currentEntity from the pendingEntities
G.pendingEntities.remove(self.victim.currentEntity) if self.victim.currentEntity in G.pendingEntities:
self.waitForOperator=False G.pendingEntities.remove(self.victim.currentEntity)
self.victim.printTrace(self.victim.id, resourceAvailable='(broker)') self.waitForOperator=False
self.victim.printTrace(self.victim.id, resourceAvailable='(broker)')
#=============================================================== #===============================================================
...@@ -132,33 +133,32 @@ class Broker(ObjectInterruption): ...@@ -132,33 +133,32 @@ class Broker(ObjectInterruption):
assert self.isCalled.value==self.env.now, 'the broker should be granted control instantly' assert self.isCalled.value==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 operator is released (the router is not called in the case of skilled ops that work constantly on the same machine)
if not self.victim.checkForSkilledOperators():
if not self.victim.isOperated(): if not self.victim.isOperated():
self.victim.currentOperator.totalWorkingTime+=self.env.now-self.victim.currentOperator.timeLastOperationStarted self.victim.currentOperator.totalWorkingTime+=self.env.now-self.victim.currentOperator.timeLastOperationStarted
# signal the other brokers waiting for the same operators that they are now free # signal the other brokers waiting for the same operators that they are now free
# also signal the stations that were not requested to receive because the operator was occupied # also signal the stations that were not requested to receive because the operator was occupied
# TODO: signalling the router must be done more elegantly, router must be set as global variable # TODO: signalling the router must be done more elegantly, router must be set as global variable
# if the router is already invoked then do not signal it again # if the router is already invoked then do not signal it again
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.signal(now()) self.victim.router.isCalled.succeed(self.env.now)
self.victim.router.isCalled.succeed(self.env.now) # 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.
self.victim.printTrace(self.victim.currentOperator.objName, finishWork=self.victim.id)
self.victim.printTrace(self.victim.currentOperator.objName, finishWork=self.victim.id) # update the schedule of the operator
# update the schedule of the operator self.victim.currentOperator.schedule[-1].append(self.env.now)
self.victim.currentOperator.schedule[-1].append(self.env.now) # the victim current operator must be cleared after the operator is released
# the victim current operator must be cleared after the operator is released self.timeLastOperationEnded = self.env.now
self.timeLastOperationEnded = self.env.now self.victim.currentOperator.workingStation=None
self.victim.currentOperator.workingStation=None self.victim.currentOperator = None
self.victim.currentOperator = None else:
else: pass
pass
# return the control to the victim # return the control to the victim
self.victim.brokerIsSet.succeed(self.env.now) self.victim.brokerIsSet.succeed(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