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

new method checkCondition() added to conditional buffer. Latest objects...

new method checkCondition() added to conditional buffer. Latest objects incorporated to LineGenerationJson
parent 04e1b32d
......@@ -35,7 +35,7 @@ class ConditionalBuffer(QueuePreemptive):
# ===========================================================================
# the __init__ function
# ===========================================================================
def __init__(self, id, name, capacity=1, dummy=False, schedulingRule="CB"):
def __init__(self, id, name, capacity=-1, dummy=False, schedulingRule="CB"):
# run the default method, change the schedulingRule to CB
# for description, check activeQSorter function of Queue coreObject
QueuePreemptive.__init__(self, id, name, capacity, dummy, schedulingRule)
......@@ -59,17 +59,20 @@ class ConditionalBuffer(QueuePreemptive):
# in this case return zero
if len(activeObjectQueue)==0:
return False
# 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
if activeEntity.componentType=='Secondary'\
and (not activeEntity.order.basicsEnded):
# check the condition
if not activeObject.checkCondition():
return False
# # 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
# if activeEntity.componentType=='Secondary'\
# and (not activeEntity.order.basicsEnded):
# return False
# -------------------------------------------------------------------
#if we have only one possible receiver just check if the receiver is the caller
if(len(activeObject.next)==1 or callerObject==None):
......@@ -92,6 +95,21 @@ class ConditionalBuffer(QueuePreemptive):
#return True if the Queue caller is the receiver
return thecaller is self.receiver
# =======================================================================
# check weather the condition is True
# =======================================================================
def checkCondition(self):
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)
\ No newline at end of file
......@@ -89,6 +89,8 @@ from ScheduledMaintenance import ScheduledMaintenance
from Failure import Failure
from Order import Order
from OrderDecomposition import OrderDecomposition
from ConditionalBuffer import ConditionalBuffer
from MouldAssemblyBuffer import MouldAssemblyBuffer
import ExcelHandler
import time
......@@ -163,6 +165,9 @@ def createObjects():
G.MachinePreemptiveList=[]
G.QueuePreemptiveList=[]
G.OrderDecompositionList=[]
G.ConditionalBufferList=[]
G.MouldAssemblyBufferList=[]
G.MouldAssemblyList=[]
# -----------------------------------------------------------------------
# loop through all the model resources
......@@ -647,6 +652,57 @@ def createObjects():
G.OrderDecompositionList.append(OD)
G.ObjList.append(OD)
elif objClass=='Dream.ConditionalBuffer':
id=element.get('id', 'not found')
name=element.get('name', 'not found')
CB=ConditionalBuffer(id, name)
CB.nextIds=getSuccessorList(id)
G.QueueList.append(CB)
G.QueuePreemptiveList.append(CB)
G.ConditionalBufferList.append(CB)
G.ObjList.append(CB)
elif objClass=='Dream.MouldAssemblyBuffer':
id=element.get('id', 'not found')
name=element.get('name', 'not found')
MAB=MouldAssemblyBuffer(id, name)
MAB.nextIds=getSuccessorList(id)
G.QueueList.append(MAB)
G.QueuePreemptiveList.append(MAB)
G.MouldAssemblyBufferList.append(MAB)
G.ObjList.append(MAB)
elif objClass=='Dream.MouldAssembly':
from MouldAssembly import MouldAssembly
id=element.get('id', 'not found')
name=element.get('name', 'not found')
processingTime=element.get('processingTime',{})
distributionType=processingTime.get('distributionType', 'not found')
mean=float(processingTime.get('mean', '0'))
stdev=float(processingTime.get('stdev', '0'))
min=float(processingTime.get('min', '0'))
max=float(processingTime.get('max', '0'))
failures=element.get('failures', {})
failureDistribution=failures.get('failureDistribution', 'not found')
MTTF=float(failures.get('MTTF', '0'))
MTTR=float(failures.get('MTTR', '0'))
availability=float(failures.get('availability', '0'))
resetOnPreemption=bool(int(element.get('resetOnPreemption', '0')))
r='None'
for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
if(id in repairman.coreObjectIds): # (if any) is assigned to repair
r=repairman # the machine with ID equal to id
MA=MouldAssembly(id, name, 1, distribution=distributionType, failureDistribution=failureDistribution,
MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r,
mean=mean,stdev=stdev,min=min,max=max, resetOnPreemption=resetOnPreemption)
MA.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
G.MachinePreemptiveList.append(MA) # add machine to global MachinePreemptiveList
G.MachineList.append(MA) # add machine to global MachineList
G.MouldAssemblyList.append(MA)
G.ObjList.append(MA) # add machine to ObjList
# -----------------------------------------------------------------------
# loop through all the nodes to
# search for Event Generator and create them
......
......@@ -36,7 +36,7 @@ class MouldAssemblyBuffer(QueuePreemptive):
# ===========================================================================
# the __init__ function
# ===========================================================================
def __init__(self, id, name, capacity=1, dummy=False, schedulingRule="MAB"):
def __init__(self, id, name, capacity=-1, dummy=False, schedulingRule="MAB"):
# run the default method, change the schedulingRule to 'MAB'
# for description, check activeQSorter function of Queue coreObject
QueuePreemptive.__init__(self, id, name, capacity, dummy, schedulingRule)
......
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