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

OrderDecomposition modified to avoid creating entities of type Mould

parent ec0a8e72
......@@ -34,8 +34,18 @@ from Job import Job
class Order(Job):
type="Order"
def __init__(self, id=None, name=None, route=[], priority=0, dueDate=None, orderDate=None, isCritical=False,
componentsList=[], manager=None, basicsEnded=0, componentsReadyForAssembly=0, extraPropertyDict=None):
def __init__(self, id=None,
name=None,
route=[],
priority=0,
dueDate=None,
orderDate=None,
isCritical=False,
componentsList=[],
manager=None,
basicsEnded=0,
componentsReadyForAssembly=0,
extraPropertyDict=None):
Job. __init__(self, id=id, name=name, route=route, priority=priority, dueDate=dueDate, orderDate=orderDate,
extraPropertyDict=extraPropertyDict)
self.isCritical=isCritical # flag to inform weather the order is critical -> preemption
......
......@@ -34,9 +34,17 @@ from Job import Job
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, requestingComponent = None,
readyForAssembly = 0, isCritical=False):
def __init__(self, id=None, name=None,
route=[],
priority=0,
dueDate=None,
orderDate=None,
extraPropertyDict=None,
componentType='Basic',
order=None,
requestingComponent = None,
readyForAssembly = 0,
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
......
......@@ -192,73 +192,81 @@ class OrderDecomposition(CoreObject):
# creates the components
# =======================================================================
def createOrderComponent(self, component):
#read attributes fromthe json or from the orderToBeDecomposed
#read attributes from the json or from the orderToBeDecomposed
id=component.get('id', 'not found')
name=component.get('name', 'not found')
# 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
# routeentity.pop(str(stepNumber),None) # remove the stepNumber key
route[stepNumber]=routeentity
# keep a reference of all extra properties passed to the job
extraPropertyDict = {}
for key, value in component.items():
if key not in ('_class', 'id'):
extraPropertyDict[key] = value
#Below it is to assign an exit if it was not assigned in JSON
#have to talk about it with NEX
exitAssigned=False
for element in route:
# elementId=element[0]
elementIds = element.get('stationIdsList',[])
for obj in G.ObjList:
for elementId in elementIds:
if obj.id==elementId and obj.type=='Exit':
exitAssigned=True
if not exitAssigned:
exitId=None
for obj in G.ObjList:
if obj.type=='Exit':
exitId=obj.id
break
if exitId:
# route.append([exitId, 0])
route.append({'stationIdsList':[str(exitId)],\
'processingTime':{}})
# initiate the OrderComponent
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)
G.EntityList.append(OC)
self.newlyCreatedComponents.append(OC) #keep these to pass them to setWIP
OC.initialize() #initialize the component
\ No newline at end of file
# there is the case were the component of the componentsList of the parent Order
# is of type Mould and therefore has no argument componentType
# in this case no Mould object should be initiated
try:
# 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
# routeentity.pop(str(stepNumber),None) # remove the stepNumber key
route[stepNumber]=routeentity
# keep a reference of all extra properties passed to the job
extraPropertyDict = {}
for key, value in component.items():
if key not in ('_class', 'id'):
extraPropertyDict[key] = value
#Below it is to assign an exit if it was not assigned in JSON
#have to talk about it with NEX
exitAssigned=False
for element in route:
# elementId=element[0]
elementIds = element.get('stationIdsList',[])
for obj in G.ObjList:
for elementId in elementIds:
if obj.id==elementId and obj.type=='Exit':
exitAssigned=True
if not exitAssigned:
exitId=None
for obj in G.ObjList:
if obj.type=='Exit':
exitId=obj.id
break
if exitId:
# route.append([exitId, 0])
route.append({'stationIdsList':[str(exitId)],\
'processingTime':{}})
# initiate the OrderComponent
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)
G.EntityList.append(OC)
self.newlyCreatedComponents.append(OC) #keep these to pass them to setWIP
OC.initialize() #initialize the component
except:
# added for testing
print 'the component of the order', sefl.orderToBeDecomposed.name, 'is of type Mould\
and thus nothing is created', 'time', now()
\ No newline at end of file
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