def createMould(self, component): #read attributes from the json or from the orderToBeDecomposed id = component.get('id', 'not found') name = component.get('name', 'not found') try: # 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 = [x for x in JSONRoute] # copy JSONRoute # assert that the assembler is in the moulds route and update the initial step of the mould's route firstStep = route.pop(0) assert (self.id in firstStep.get('stationIdsList',[])),\ 'the assembler must be in the mould-to-be-created route\' initial step' # normal processing operation processingTime = firstStep['processingTime'] processingTime = self.getOperationTime(processingTime) self.rng = RandomNumberGenerator(self, processingTime) self.procTime = self.rng.generateNumber() # update the activeObject's processing time according to the readings in the mould's route processDistType = processingTime.keys()[0] procTime = float(processingTime[processDistType].get('mean', 0)) processOpType = firstStep.get('operationType', {}).get( 'Processing', 'not found') # can be manual/automatic # task_id task_id = firstStep.get('task_id', None) # sequence sequence = firstStep.get('sequence', None) # operator operator = firstStep.get('operator', {}) # technology technology = firstStep.get('technology', None) # quantity quantity = firstStep.get('quantity', None) # setup operation setupTime = firstStep.get('setupTime', None) if setupTime: setupTime = self.getOperationTime(setupTime) self.stpRng = RandomNumberGenerator(self, setupTime) # update the activeObject's processing time according to the readings in the mould's route setupDistType = setupTime.keys()[0] setTime = float(setupTime[setupDistType].get('mean', 0)) setupOpType = firstStep.get('operationType', {}).get( 'Setup', 'not found') # can be manual/automatic # update the first step of the route with the activeObjects id as sole element of the stationIdsList route.insert(0, {'stationIdsList':[str(self.id)], 'processingTime':{str(processDistType):{'mean':str(procTime)}},\ 'setupTime':{str(setupDistType):{'mean':str(setupTime)}}, 'operationType':{'Processing':processOpType,'Setup':setupOpType}}) else: # update the first step of the route with the activeObjects id as sole element of the stationIdsList route.insert( 0, { 'stationIdsList': [str(self.id)], 'processingTime': { str(processDistType): { 'mean': str(procTime) } }, 'operationType': { 'Processing': processOpType } }) # if there is task_id then add it to the route if task_id: route[0]["task_id"] = task_id # if there is sequence then add it to the route if sequence: route[0]["sequence"] = sequence # if there is operator then add it to the route if operator: route[0]["operator"] = operator # if there is technology then add it to the route if technology: route[0]["technology"] = technology # if there is quantity then add it to the route if quantity != None: route[0]["quantity"] = quantity #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: elementIds = element.get('stationIdsList', []) for obj in G.ObjList: for elementId in elementIds: if obj.id == elementId and obj.type == 'Exit': exitAssigned = True # assign an exit to the route of the mould if not exitAssigned: exitId = None for obj in G.ObjList: if obj.type == 'Exit': exitId = obj.id break if exitId: route.append({ 'stationIdsList': [str(exitId)], 'processingTime': {} }) # 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 # create and initiate the OrderComponent from Mould import Mould M=Mould(id, name, route, \ priority=self.mouldParent.priority, \ order=self.mouldParent,\ dueDate=self.mouldParent.dueDate, \ orderDate=self.mouldParent.orderDate, \ extraPropertyDict=extraPropertyDict,\ isCritical=self.mouldParent.isCritical) # update the mouldToBeCreated self.mouldToBeCreated = M G.JobList.append(M) G.WipList.append(M) G.EntityList.append(M) G.MouldList.append(M) #initialize the component M.initialize() except: # added for testing print 'the mould to be created', component.get( 'name', 'not found'), 'cannot be created', 'time', self.env.now raise
def createMould(self, component): #read attributes from the json or from the orderToBeDecomposed id = component.get('id', 'not found') name = component.get('name', 'not found') try: # 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 = [x for x in JSONRoute] # copy JSONRoute # assert that the assembler is in the moulds route and update the initial step of the mould's route firstStep = route.pop(0) assert (self.id in firstStep.get('stationIdsList',[])),\ 'the assembler must be in the mould-to-be-created route\' initial step' processingTime = firstStep['processingTime'] # update the activeObject's processing time according to the readings in the mould's route self.distType = processingTime.keys()[0] self.procTime = float(processingTime[self.distType].get('mean', 0)) # update the first step of the route with the activeObjects id as sole element of the stationIdsList route.insert( 0, { 'stationIdsList': [str(self.id)], 'processingTime': { str(self.distType): { 'mean': str(self.procTime) } } }) #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: elementIds = element.get('stationIdsList', []) for obj in G.ObjList: for elementId in elementIds: if obj.id == elementId and obj.type == 'Exit': exitAssigned = True # assign an exit to the route of the mould if not exitAssigned: exitId = None for obj in G.ObjList: if obj.type == 'Exit': exitId = obj.id break if exitId: route.append({ 'stationIdsList': [str(exitId)], 'processingTime': {} }) # 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 # create and initiate the OrderComponent from Mould import Mould M=Mould(id, name, route, \ priority=self.mouldParent.priority, \ order=self.mouldParent,\ dueDate=self.mouldParent.dueDate, \ orderDate=self.mouldParent.orderDate, \ extraPropertyDict=extraPropertyDict,\ isCritical=self.mouldParent.isCritical) # update the mouldToBeCreated self.mouldToBeCreated = M G.JobList.append(M) G.WipList.append(M) G.EntityList.append(M) G.MouldList.append(M) #initialize the component M.initialize() except: # added for testing print 'the mould to be created', component.get( 'name', 'not found'), 'cannot be created', 'time', self.env.now raise
def createMould(self, component): #read attributes from the json or from the orderToBeDecomposed id=component.get('id', 'not found') name=component.get('name', 'not found') try: # 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 = [x for x in JSONRoute] # copy JSONRoute # assert that the assembler is in the moulds route and update the initial step of the mould's route firstStep = route.pop(0) assert (self.id in firstStep.get('stationIdsList',[])),\ 'the assembler must be in the mould-to-be-created route\' initial step' # normal processing operation processingTime=firstStep['processingTime'] processingTime=self.getOperationTime(processingTime) self.rng=RandomNumberGenerator(self, processingTime) self.procTime=self.rng.generateNumber() # update the activeObject's processing time according to the readings in the mould's route processDistType=processingTime.keys()[0] procTime=float(processingTime[processDistType].get('mean', 0)) processOpType=firstStep.get('operationType',{}).get('Processing','not found') # can be manual/automatic # task_id task_id = firstStep.get('task_id', None) # sequence sequence = firstStep.get('sequence', None) # operator operator = firstStep.get('operator', {}) # technology technology = firstStep.get('technology', None) # quantity quantity = firstStep.get('quantity', None) # setup operation setupTime=firstStep.get('setupTime',None) if setupTime: setupTime=self.getOperationTime(setupTime) self.stpRng=RandomNumberGenerator(self, setupTime) # update the activeObject's processing time according to the readings in the mould's route setupDistType=setupTime.keys()[0] setTime=float(setupTime[setupDistType].get('mean', 0)) setupOpType=firstStep.get('operationType',{}).get('Setup','not found') # can be manual/automatic # update the first step of the route with the activeObjects id as sole element of the stationIdsList route.insert(0, {'stationIdsList':[str(self.id)], 'processingTime':{str(processDistType):{'mean':str(procTime)}},\ 'setupTime':{str(setupDistType):{'mean':str(setupTime)}}, 'operationType':{'Processing':processOpType,'Setup':setupOpType}}) else: # update the first step of the route with the activeObjects id as sole element of the stationIdsList route.insert(0, {'stationIdsList':[str(self.id)], 'processingTime':{str(processDistType):{'mean':str(procTime)}}, 'operationType':{'Processing':processOpType}}) # if there is task_id then add it to the route if task_id: route[0]["task_id"] = task_id # if there is sequence then add it to the route if sequence: route[0]["sequence"] = sequence # if there is operator then add it to the route if operator: route[0]["operator"] = operator # if there is technology then add it to the route if technology: route[0]["technology"] = technology # if there is quantity then add it to the route if quantity!=None: route[0]["quantity"] = quantity #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: elementIds = element.get('stationIdsList',[]) for obj in G.ObjList: for elementId in elementIds: if obj.id==elementId and obj.type=='Exit': exitAssigned=True # assign an exit to the route of the mould if not exitAssigned: exitId=None for obj in G.ObjList: if obj.type=='Exit': exitId=obj.id break if exitId: route.append({'stationIdsList':[str(exitId)],'processingTime':{}}) # 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 # create and initiate the OrderComponent from Mould import Mould M=Mould(id, name, route, \ priority=self.mouldParent.priority, \ order=self.mouldParent,\ dueDate=self.mouldParent.dueDate, \ orderDate=self.mouldParent.orderDate, \ extraPropertyDict=extraPropertyDict,\ isCritical=self.mouldParent.isCritical) # update the mouldToBeCreated self.mouldToBeCreated=M G.JobList.append(M) G.WipList.append(M) G.EntityList.append(M) G.MouldList.append(M) #initialize the component M.initialize() except: # added for testing print 'the mould to be created', component.get('name', 'not found'), 'cannot be created', 'time', self.env.now raise
def createMould(self, component): #read attributes from the json or from the orderToBeDecomposed id=component.get('id', 'not found') name=component.get('name', 'not found') try: # 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 = [x for x in JSONRoute] # copy JSONRoute # assert that the assembler is in the moulds route and update the initial step of the mould's route firstStep = route.pop(0) assert (self.id in firstStep.get('stationIdsList',[])),\ 'the assembler must be in the mould-to-be-created route\' initial step' processingTime=firstStep['processingTime'] # update the activeObject's processing time according to the readings in the mould's route self.distType=processingTime.keys()[0] self.procTime=float(processingTime[self.distType].get('mean', 0)) # update the first step of the route with the activeObjects id as sole element of the stationIdsList route.insert(0, {'stationIdsList':[str(self.id)],'processingTime':{str(self.distType):{'mean':str(self.procTime)}}}) #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: elementIds = element.get('stationIdsList',[]) for obj in G.ObjList: for elementId in elementIds: if obj.id==elementId and obj.type=='Exit': exitAssigned=True # assign an exit to the route of the mould if not exitAssigned: exitId=None for obj in G.ObjList: if obj.type=='Exit': exitId=obj.id break if exitId: route.append({'stationIdsList':[str(exitId)],'processingTime':{}}) # 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 # create and initiate the OrderComponent from Mould import Mould M=Mould(id, name, route, \ priority=self.mouldParent.priority, \ order=self.mouldParent,\ dueDate=self.mouldParent.dueDate, \ orderDate=self.mouldParent.orderDate, \ extraPropertyDict=extraPropertyDict,\ isCritical=self.mouldParent.isCritical) # update the mouldToBeCreated self.mouldToBeCreated=M G.JobList.append(M) G.WipList.append(M) G.EntityList.append(M) G.MouldList.append(M) #initialize the component M.initialize() except: # added for testing print 'the mould to be created', component.get('name', 'not found'), 'cannot be created', 'time', self.env.now raise