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

basic-/secondary-/auxiliary-ComponentsList lists added to Order and...

basic-/secondary-/auxiliary-ComponentsList lists added to Order and OrderDecomposition modified in order to update these lists
parent 9cd884a0
......@@ -40,6 +40,9 @@ class Order(Job):
extraPropertyDict=extraPropertyDict)
self.isCritical=isCritical # flag to inform weather the order is critical -> preemption
self.componentsList=componentsList # list of components that the order will be broken into
self.basicComponentsList = [] # list that holds the Basic Components of the order
self.secondaryComponentsList = [] # list that holds the Secondary Components of the order
self.auxiliaryComponentsList = [] # list of the auxiliary components of the order
self.manager=manager # the manager responsible to handle the order
self.basicsEnded=basicsEnded # flag that informs that the basic components of the order are finished
......
......@@ -28,13 +28,20 @@ OrderComponent is an Entity that is a component of a broader order
from Globals import G
from Job import Job
# ============================ The OrderComponent object ==============================
# ===========================================================================
# The OrderComponent object
# ===========================================================================
class OrderComponent(Job): # inherits from the Job class
type="OrderComponent"
def __init__(self, id=None, name=None, route=[], priority=0, dueDate=None, orderDate=None, extraPropertyDict=None,
componentType='Basic', order=None, isCritical=False):
componentType='Basic', order=None, requestingComponent = None, isCritical=False):
Job.__init__(self, id, name, route, priority, dueDate, orderDate, extraPropertyDict)
self.auxiliaryList=[] # Holds the auxiliary components that the component needs for a certain processing
self.order=order # parent order of the order component
self.isCritical=isCritical # this should be self.order.isCritical. Added now for testing
self.componentType = componentType # the type of the component which can be Basic/Secondary/Auxiliary
# if the componentType of the component is Auxiliary then there need a requesting Component be defined
# the requestingComponent is the component that needs the auxiliary component during its processing
# the auxiliary component should then be added to the requestingComponent's auxiliaryList
self.requestingComponent = requestingComponent # the id of the requesting component
......@@ -140,6 +140,17 @@ class OrderDecomposition(CoreObject):
#append the components in the internal queue
for component in entity.componentsList:
self.createOrderComponent(component)
# after the creation of the order's components update each components auxiliary list
# if there are auxiliary components
if len(entity.auxiliaryComponentsList):
# for every auxiliary component
for auxComponent in entity.auxiliaryComponentsList:
# run through the componentsList of the order
for reqComponent in entity.componentsList:
# to find the requestingComponent of the auxiliary component
if auxComponent.requestingComponent==reqComponent.id:
# and add the auxiliary to the requestingComponent auxiliaryList
reqComponent.auxiliaryList.append(auxComponent)
#if there is an order for decomposition
if self.orderToBeDecomposed:
import Globals
......@@ -155,21 +166,23 @@ class OrderDecomposition(CoreObject):
#read attributes fromthe json or from the orderToBeDecomposed
id=component.get('id', 'not found')
name=component.get('name', 'not found')
JSONRoute=component.get('route', []) # dummy variable that holds the routes of the jobs
# the route from the JSON file
# is a sequence of dictionaries
route = [None for i in range(len(JSONRoute))] # variable that holds the argument used in the Job initiation
# hold None for each entry in the 'route' list
# variable that holds the componentType which can be Basic/Secondary/Auxiliary
componentType=component.get('componentType', 'Basic')
# the component that needs the auxiliary (if the componentType is "Auxiliary") during its processing
requestingComponent = component.get('requestingComponent', 'not found')
# dummy variable that holds the routes of the jobs the route from the JSON file is a sequence of dictionaries
JSONRoute=component.get('route', [])
# variable that holds the argument used in the Job initiation hold None for each entry in the 'route' list
route = [None for i in range(len(JSONRoute))]
for routeentity in JSONRoute: # for each 'step' dictionary in the JSONRoute
stepNumber=int(routeentity.get('stepNumber', '0')) # get the stepNumber
nextId=routeentity.get('stationId', 'not found') # the stationId
processingTime=routeentity['processingTime'] # and the 'processingTime' dictionary
distributionType=processingTime.get('distributionType', 'not found')# and from that dictionary
# get the 'mean'
mean=float(processingTime.get('mean', 'not found'))
mean=float(processingTime.get('mean', 'not found')) # get the 'mean'
route[stepNumber]=[nextId, mean] # finally add the 'nextId' and 'mean'
# to the job route
# to the job route
# keep a reference of all extra properties passed to the job
extraPropertyDict = {}
......@@ -195,10 +208,23 @@ class OrderDecomposition(CoreObject):
route.append([exitId, 0])
# initiate the OrderComponent
OC=OrderComponent(id, name, route, priority=self.orderToBeDecomposed.priority, dueDate=self.orderToBeDecomposed.dueDate,
order=self.orderToBeDecomposed,
orderDate=self.orderToBeDecomposed.orderDate, extraPropertyDict=extraPropertyDict,
OC=OrderComponent(id, name, route, \
priority=self.orderToBeDecomposed.priority, \
dueDate=self.orderToBeDecomposed.dueDate, \
componentType=componentType,\
requestingComponent = requestingComponent, \
order=self.orderToBeDecomposed,\
orderDate=self.orderToBeDecomposed.orderDate, \
extraPropertyDict=extraPropertyDict,\
isCritical=self.orderToBeDecomposed.isCritical)
# check the componentType of the component and accordingly add to the corresponding list of the parent order
if OC.componentType == 'Basic':
self.orderToBeDecomposed.basicComponentsList.append(OC)
elif OC.componentType == 'Secondary':
self.orderToBeDecomposed.secondaryComponentsList.append(OC)
else:
self.orderToBeDecomposed.auxiliaryComponentsList.append(OC)
G.OrderComponentList.append(OC)
G.JobList.append(OC)
G.WipList.append(OC)
......
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