Commit ea3ca76d authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

ConditionalBuffer corrected - MouldAssemblyBuffer haveToDispose modified

parent 16ba284e
......@@ -39,6 +39,12 @@ class NoCallerError(Exception):
# the QueuePreemptive object
# ===========================================================================
class ConditionalBuffer(QueuePreemptive):
# =======================================================================
# the default __init__ method of the QueuePreemptive class
# whereas the default capacity is set to infinity
# =======================================================================
def __init__(self, id, name, capacity=-1, dummy=False, schedulingRule="FIFO"):
QueuePreemptive.__init__(self, id=id, name=name, capacity=capacity, dummy=dummy, schedulingRule=schedulingRule)
# =======================================================================
# checks if the Buffer can dispose an entity.
......@@ -92,14 +98,30 @@ class ConditionalBuffer(QueuePreemptive):
activeObject = self.getActiveObject()
activeObjectQueue = activeObject.getActiveObjectQueue()
# read the entity to be disposed
activeEntity = activeObjectQueue[0]
# assert that the entity.type is OrderComponent
assert activeEntity.type=='OrderComponent',\
"the entity to be disposed is not of type OrderComponent"
# if the type of the component is Secondary then verify that the basics of the same Order
# are already processed before disposing them to the next object
return activeEntity.componentType=='Secondary'\
and (activeEntity.order.basicsEnded)
index = 0
activeEntity=None
for index in range(len(activeObjectQueue)):
if activeObjectQueue[index].componentType=='Basic':
activeEntity=activeObjectQueue[index]
return True
elif activeObjectQueue[index].order.basicsEnded:
activeEntity=activeObjectQueue[index]
return True
index +=1
# if there is no entity in the activeQ that its parentOrder has the flag componentsReadyForAssembly set
if not activeEntity:
# return false
return False
# # activeEntity = activeObjectQueue[0]
# # assert that the entity.type is OrderComponent
# assert activeEntity.type=='OrderComponent',\
# "the entity to be disposed is not of type OrderComponent"
# # if the type of the component is Secondary then verify that the basics of the same Order
# # are already processed before disposing them to the next object
# # TODO: the activeEntity is already checked if it has the basicsEnded flag set
# return activeEntity.componentType=='Secondary'\
# and (activeEntity.order.basicsEnded)
# =======================================================================
# sort the entities of the activeQ
......
......@@ -133,7 +133,19 @@ class MouldAssemblyBuffer(QueuePreemptive):
# if the length is zero then no componentType or entity.type can be read
if len(activeObjectQueue)==0:
return False
activeEntity = activeObjectQueue[0] # read the entity to be disposed
# read the entity to be disposed
index = 0
activeEntity=None
for index in range(len(activeObjectQueue)):
if activeObjectQueue[index].order.componentsReadyForAssembly:
activeEntity=activeObjectQueue[index]
break
index +=1
# if there is no entity in the activeQ that its parentOrder has the flag componentsReadyForAssembly set
if not activeEntity:
# return false
return False
# activeEntity = activeObjectQueue[0]
if(len(activeObject.next)==1): #if we have only one possible receiver
activeObject.receiver=activeObject.next[0]
else: # otherwise,
......@@ -151,6 +163,7 @@ class MouldAssemblyBuffer(QueuePreemptive):
return False
# if the successors (MouldAssembly) internal queue is empty then proceed with checking weather
# the caller is the receiver
# TODO the activeEntity is already checked for the flag componentsReadyForAssembly
if len(receiverQueue)==0:
if activeEntity.type=='Mould':
return thecaller is activeObject.receiver
......
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