CoreObject updated to facilitate the signalling of the Router if the receiver...

CoreObject updated to facilitate the signalling of the Router if the receiver to be preempted is operated
parent c68e6eb1
...@@ -273,10 +273,12 @@ class CoreObject(Process): ...@@ -273,10 +273,12 @@ class CoreObject(Process):
if receiver: if receiver:
receiverOperated=False # local variable to inform if the receiver is operated for Loading receiverOperated=False # local variable to inform if the receiver is operated for Loading
try: try:
from MachineJobShop import MachineJobShop
from MachineManagedJob import MachineManagedJob
# TODO: implement preemption for simple machines # TODO: implement preemption for simple machines
if receiver.operatorPool\ if receiver.operatorPool\
and (type(receiver) is MachineJobShop\ and isinstance(receiver, MachineJobShop) or\
or type(receiver) is MachineManagedJob): isinstance(receiver, MachineManagedJob):
# and the operationType list contains Load, the receiver is operated # and the operationType list contains Load, the receiver is operated
if (receiver.operatorPool!="None")\ if (receiver.operatorPool!="None")\
and any(type=="Load" for type in receiver.multOperationTypeList): and any(type=="Load" for type in receiver.multOperationTypeList):
...@@ -286,17 +288,19 @@ class CoreObject(Process): ...@@ -286,17 +288,19 @@ class CoreObject(Process):
# if the obtained Entity is critical and the receiver is preemptive and not operated # if the obtained Entity is critical and the receiver is preemptive and not operated
# in the case that the receiver is operated the preemption is performed by the operators # in the case that the receiver is operated the preemption is performed by the operators
# if the receiver is not Up then no preemption will be performed # if the receiver is not Up then no preemption will be performed
if not receiverOperated: if not receiverOperated and len(receiver.getActiveObjectQueue())>0:
#if the receiver is not empty #if the receiver does not hold an Entity that is also critical
if len(self.receiver.getActiveObjectQueue())>0: if not receiver.getActiveObjectQueue()[0].isCritical:
#if the receiver does not hold an Entity that is also critical receiver.shouldPreempt=True
if not self.receiver.getActiveObjectQueue()[0].isCritical: activeObject.printTrace(self.id, 'preempting receiver '+receiver.id+'.. '*6)
self.receiver.shouldPreempt=True receiver.preempt()
self.printTrace(self.id, 'preempting receiver'+self.receiver.id+'.. '*6) receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
self.receiver.preempt() # sort so that the critical entity is placed in front
self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station activeObjectQueue.sort(key=lambda x: x==activeEntity, reverse=True)
# TODO: sort so that the critical entity is placed in front # if there is a critical entity and the possible receivers are operated then signal the Router
activeObjectQueue.sort(key=lambda x: x==activeEntity, reverse=True) elif receiverOperated:
activeObject.signalRouter(receiver)
activeObjectQueue.sort(key=lambda x: x==activeEntity, reverse=True)
# update wipStatList # update wipStatList
if self.gatherWipStat: if self.gatherWipStat:
self.wipStatList.append([now(), len(activeObjectQueue)]) self.wipStatList.append([now(), len(activeObjectQueue)])
...@@ -371,7 +375,8 @@ class CoreObject(Process): ...@@ -371,7 +375,8 @@ class CoreObject(Process):
def signalRouter(self, receiver=None): def signalRouter(self, receiver=None):
# if an operator is not assigned to the receiver then do not signal the receiver but the Router # if an operator is not assigned to the receiver then do not signal the receiver but the Router
try: try:
if not receiver.assignedOperator: if not receiver.assignedOperator or\
(receiver.isPreemptive and len(receiver.getActiveObjectQueue())>0):
if receiver.isLoadRequested(): if receiver.isLoadRequested():
from Globals import G from Globals import G
if not G.Router.invoked: if not G.Router.invoked:
......
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