Commit 8a765025 authored by Georgios Dagkakis's avatar Georgios Dagkakis

invokeType flag added to broker

parent 1ebd69f7
...@@ -1156,6 +1156,7 @@ class Machine(CoreObject): ...@@ -1156,6 +1156,7 @@ class Machine(CoreObject):
# prepare the machine to be operated # prepare the machine to be operated
# ======================================================================= # =======================================================================
def requestOperator(self): def requestOperator(self):
self.broker.invokeType='request'
self.broker.invoke() self.broker.invoke()
self.toBeOperated = True self.toBeOperated = True
...@@ -1177,6 +1178,7 @@ class Machine(CoreObject): ...@@ -1177,6 +1178,7 @@ class Machine(CoreObject):
operator.timeLastShiftEnded=self.env.now operator.timeLastShiftEnded=self.env.now
operator.unAssign() # set the flag operatorAssignedTo to None operator.unAssign() # set the flag operatorAssignedTo to None
operator.workingStation=None operator.workingStation=None
self.toBeOperated = False
self.outputTrace(operator.name, "released from "+ self.objName) self.outputTrace(operator.name, "released from "+ self.objName)
# XXX in case of skilled operators which stay at the same station should that change # XXX in case of skilled operators which stay at the same station should that change
elif not operator.operatorDedicatedTo==self: elif not operator.operatorDedicatedTo==self:
...@@ -1186,13 +1188,14 @@ class Machine(CoreObject): ...@@ -1186,13 +1188,14 @@ class Machine(CoreObject):
# if the Router is expecting for signal send it # if the Router is expecting for signal send it
from Globals import G from Globals import G
from SkilledOperatorRouter import SkilledRouter from SkilledOperatorRouter import SkilledRouter
self.toBeOperated = False
if G.RouterList[0].__class__ is SkilledRouter: if G.RouterList[0].__class__ is SkilledRouter:
if G.RouterList[0].expectedFinishSignals: if G.RouterList[0].expectedFinishSignals:
if self.id in G.RouterList[0].expectedFinishSignalsDict: if self.id in G.RouterList[0].expectedFinishSignalsDict:
signal=G.RouterList[0].expectedFinishSignalsDict[self.id] signal=G.RouterList[0].expectedFinishSignalsDict[self.id]
self.sendSignal(receiver=G.RouterList[0], signal=signal) self.sendSignal(receiver=G.RouterList[0], signal=signal)
self.broker.invokeType='release'
self.broker.invoke() self.broker.invoke()
self.toBeOperated = False
# ======================================================================= # =======================================================================
# check if the machine is currently operated by an operator # check if the machine is currently operated by an operator
......
...@@ -49,6 +49,9 @@ class Broker(ObjectInterruption): ...@@ -49,6 +49,9 @@ class Broker(ObjectInterruption):
self.timeLastOperationEnded = 0 self.timeLastOperationEnded = 0
self.timeWaitForOperatorStarted=0 self.timeWaitForOperatorStarted=0
self.waitForOperator=False self.waitForOperator=False
# flag that shows if broker was called to request or release operator.
# Machine updates this before calling the broker
self.invokeType='request'
#=========================================================================== #===========================================================================
# the initialize method # the initialize method
...@@ -75,11 +78,13 @@ class Broker(ObjectInterruption): ...@@ -75,11 +78,13 @@ class Broker(ObjectInterruption):
self.expectedSignals['isCalled']=1 self.expectedSignals['isCalled']=1
yield self.isCalled yield self.isCalled
# if self.victim.id=='St2M0':
# print self.env.now, self.victim.id, 'Broker Called',self.invokeType
transmitter, eventTime=self.isCalled.value transmitter, eventTime=self.isCalled.value
assert eventTime==self.env.now, 'the broker should be granted control instantly' 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)')
if self.invokeType=='request':
# ======= request a resource # ======= request a resource
if self.victim.isOperated()\ if self.victim.isOperated()\
and any(type=='Load' or type=='Setup' or type=='Processing'\ and any(type=='Load' or type=='Setup' or type=='Processing'\
...@@ -145,6 +150,8 @@ class Broker(ObjectInterruption): ...@@ -145,6 +150,8 @@ class Broker(ObjectInterruption):
with self.victim.operatorPool.getResource(self.victim.currentOperator).request() as request: with self.victim.operatorPool.getResource(self.victim.currentOperator).request() as request:
yield request yield request
if self.victim.id=='St2M0':
print 1
# update the operator workingStation # update the operator workingStation
self.victim.currentOperator.workingStation=self.victim self.victim.currentOperator.workingStation=self.victim
self.victim.printTrace(self.victim.currentOperator.objName, startWork=self.victim.id) self.victim.printTrace(self.victim.currentOperator.objName, startWork=self.victim.id)
...@@ -178,14 +185,22 @@ class Broker(ObjectInterruption): ...@@ -178,14 +185,22 @@ class Broker(ObjectInterruption):
self.expectedSignals['isCalled']=1 self.expectedSignals['isCalled']=1
yield self.isCalled yield self.isCalled
# if self.victim.id=='St2M0':
# print self.env.now, self.victim.id, 'Broker Called 2', self.invokeType
transmitter, eventTime=self.isCalled.value transmitter, eventTime=self.isCalled.value
assert eventTime==self.env.now, 'the broker should be granted control instantly' 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) if self.invokeType=='release':
# if self.victim.id=='St2M0':
# print 2
# 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.currentOperator.operatorDedicatedTo==self.victim: if not self.victim.currentOperator.operatorDedicatedTo==self.victim:
if not self.victim.isOperated(): if not self.victim.isOperated():
# if self.victim.id=='St2M0':
# print 3
# 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
......
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