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

invokeType flag added to broker

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