Commit a32c346a authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

cherry-pick from readWIPseperatelly. operators now hold schedule. PrintRoute...

cherry-pick from readWIPseperatelly. operators now hold schedule. PrintRoute pritns schedule of operators
parent c0573a03
...@@ -119,11 +119,13 @@ class Broker(ObjectInterruption): ...@@ -119,11 +119,13 @@ class Broker(ObjectInterruption):
# clear the timeWaitForOperatorStarted variable # clear the timeWaitForOperatorStarted variable
self.timeWaitForOperatorStarted = 0 self.timeWaitForOperatorStarted = 0
# update the time that the operation started # update the time that the operation started
self.timeOperationStarted = self.env.now#() self.timeOperationStarted = self.env.now
self.victim.outputTrace(self.victim.currentOperator.objName, "started work in "+ self.victim.objName) self.victim.outputTrace(self.victim.currentOperator.objName, "started work in "+ self.victim.objName)
self.victim.currentOperator.timeLastOperationStarted=self.env.now#() self.victim.currentOperator.timeLastOperationStarted=self.env.now#()
# signal the machine that an operator is reserved # signal the machine that an operator is reserved
self.victim.brokerIsSet.succeed(self.env.now) self.victim.brokerIsSet.succeed(self.env.now)
# update the schedule of the operator
self.victim.currentOperator.schedule.append([self.victim, self.env.now])
# wait till the processing is over # wait till the processing is over
yield self.isCalled yield self.isCalled
...@@ -149,6 +151,8 @@ class Broker(ObjectInterruption): ...@@ -149,6 +151,8 @@ class Broker(ObjectInterruption):
# TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers. # TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers.
self.victim.printTrace(self.victim.currentOperator.objName, finishWork=self.victim.id) self.victim.printTrace(self.victim.currentOperator.objName, finishWork=self.victim.id)
# update the schedule of the operator
self.victim.currentOperator.schedule[-1].append(self.env.now)
# the victim current operator must be cleared after the operator is released # the victim current operator must be cleared after the operator is released
self.timeLastOperationEnded = self.env.now self.timeLastOperationEnded = self.env.now
self.victim.currentOperator.workingStation=None self.victim.currentOperator.workingStation=None
......
...@@ -71,6 +71,8 @@ class Operator(ObjectResource): ...@@ -71,6 +71,8 @@ class Operator(ObjectResource):
self.candidateEntity=None # the entity that will be chosen for processing self.candidateEntity=None # the entity that will be chosen for processing
self.candidateStations=[] # list of candidateStations of the stations (those stations that can receive an entity) self.candidateStations=[] # list of candidateStations of the stations (those stations that can receive an entity)
self.schedule=[] # the working schedule of the resource, the objects the resource was occupied by and the corresponding times
@staticmethod @staticmethod
def getSupportedSchedulingRules(): def getSupportedSchedulingRules():
return ("FIFO", "Priority", "WT", "EDD", "EOD", return ("FIFO", "Priority", "WT", "EDD", "EOD",
......
...@@ -11,9 +11,23 @@ JOB_SHOP_TECHNOLOGY_SEQ=['CAD','CAM','MILL','EDM','ASSM','MA','INJM','IM' ] ...@@ -11,9 +11,23 @@ JOB_SHOP_TECHNOLOGY_SEQ=['CAD','CAM','MILL','EDM','ASSM','MA','INJM','IM' ]
ORDER_COMPONENT_TYPE_SET=set(['OrderComponent','Design','Mould']) ORDER_COMPONENT_TYPE_SET=set(['OrderComponent','Design','Mould'])
def sortMachines(): def sortMachines():
'''sort the machines according to the set provided by JOB_SHOP_TECHNOLOGY_SEQ'''
for tech in JOB_SHOP_TECHNOLOGY_SEQ: for tech in JOB_SHOP_TECHNOLOGY_SEQ:
G.MachineList.sort(key=lambda x: x.id.startswith(tech)) G.MachineList.sort(key=lambda x: x.id.startswith(tech))
def getEventsList(objectsList=[]):
'''create an event list from the schedules of the objects provided'''
events_list=[] # list to hold the events of the system
for object in objectsList:
if object.schedule:
for record in object.schedule:
if not record[1] in events_list:
events_list.append(record[1])
if len(record)==3:
if not record[2] in events_list:
events_list.append(record[2])
return events_list
def outputRoute(): def outputRoute():
''' '''
prints the routes of the Jobs through the model as a table prints the routes of the Jobs through the model as a table
...@@ -37,6 +51,8 @@ def outputRoute(): ...@@ -37,6 +51,8 @@ def outputRoute():
job accessing it) job accessing it)
''' '''
# xx for each station allocate 2 rows and a 3rd one for operators
if G.trace=='Yes': if G.trace=='Yes':
if G.JobList: if G.JobList:
G.routeSheetIndex=G.sheetIndex+1 G.routeSheetIndex=G.sheetIndex+1
...@@ -44,16 +60,8 @@ def outputRoute(): ...@@ -44,16 +60,8 @@ def outputRoute():
G.routeTraceSheet=G.traceFile.add_sheet('sheet '+str(G.routeSheetIndex)+' route', cell_overwrite_ok=True) G.routeTraceSheet=G.traceFile.add_sheet('sheet '+str(G.routeSheetIndex)+' route', cell_overwrite_ok=True)
number_of_machines=len(G.MachineList) number_of_machines=len(G.MachineList)
sortMachines() # sort the machines according to the priority specified in JOB_SHOP_TECHNOLOGY_SEQ sortMachines() # sort the machines according to the priority specified in JOB_SHOP_TECHNOLOGY_SEQ
events_list=[] # list to hold the events of the system # get the events list
# list all events events_list=getEventsList(G.JobList+G.OperatorsList)
for job in G.JobList:
if job.schedule:
for record in job.schedule:
if not record[1] in events_list:
events_list.append(record[1])
if len(record)==3:
if not record[2] in events_list:
events_list.append(record[2])
events_list.sort(cmp=None, key=None, reverse=False) # sort the events events_list.sort(cmp=None, key=None, reverse=False) # sort the events
number_of_events=len(events_list) # keep the total number of events number_of_events=len(events_list) # keep the total number of events
# create a table number_of_events X number_of_machines # create a table number_of_events X number_of_machines
...@@ -61,8 +69,12 @@ def outputRoute(): ...@@ -61,8 +69,12 @@ def outputRoute():
# write the events in the first column and the machineIDs in the first row # write the events in the first column and the machineIDs in the first row
for j, event in enumerate(events_list): for j, event in enumerate(events_list):
G.routeTraceSheet.write(j+1,0,float(event)) G.routeTraceSheet.write(j+1,0,float(event))
# XXX create 3 times as many columns as the number of machines
for j, machine in enumerate(G.MachineList): for j, machine in enumerate(G.MachineList):
G.routeTraceSheet.write(0, j+1, str(machine.id)) machine.cell_ids=range(j*3+1,j*3+3)
machine.op_cel=j*3+3
G.routeTraceSheet.write_merge(0,0,j*3+1,j*3+3,str(machine.id))
# sort the jobs according to their name # sort the jobs according to their name
G.JobList.sort(key=lambda x:x.id) G.JobList.sort(key=lambda x:x.id)
# list of cells to be written # list of cells to be written
...@@ -90,6 +102,7 @@ def outputRoute(): ...@@ -90,6 +102,7 @@ def outputRoute():
# find the station of this step # find the station of this step
station=record[0] # XXX should also hold a list with all the machines G.MachineList? station=record[0] # XXX should also hold a list with all the machines G.MachineList?
# find the column corresponding to the machine # find the column corresponding to the machine
# XXX each machine should have at least 3 columns, 2 for the jobs and one for operators
if station in G.MachineList: if station in G.MachineList:
machine_index=G.MachineList.index(station) machine_index=G.MachineList.index(station)
# find the entrance time of this step # find the entrance time of this step
...@@ -105,26 +118,94 @@ def outputRoute(): ...@@ -105,26 +118,94 @@ def outputRoute():
exit_time_index=len(events_list) exit_time_index=len(events_list)
# for the rows with indices entrance_time_index to exit_time_index print the id of the Job in the column of the machine_index # for the rows with indices entrance_time_index to exit_time_index print the id of the Job in the column of the machine_index
for step in range(entrance_time_index,exit_time_index+1, 1): for step in range(entrance_time_index,exit_time_index+1, 1):
col_to_write=station.cell_ids[0]
stepDone=False stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it # check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not cells: if not cells:
cells.append({'row':step+1, cells.append({'row':step+1,
'col':machine_index+1, 'col':col_to_write,
'job':job.alias}) 'job':job.alias})
G.routeTraceSheet.write(step+1, machine_index+1, job.alias) G.routeTraceSheet.write(step+1, col_to_write, job.alias)
continue continue
for cell in cells: for cell in cells:
if cell['row']==step+1 and cell['col']==machine_index+1: if cell['row']==step+1 and cell['col']==col_to_write:
next_col=station.cell_ids[1]
if not next_col in [x['col'] for x in cells if x['row']==step+1]:
cells.append({'row':step+1,
'col':next_col,
'job':job.alias})
G.routeTraceSheet.write(step+1, next_col, job.alias)
stepDone=True
break
cell['job']=cell['job']+','+job.alias cell['job']=cell['job']+','+job.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['job']) G.routeTraceSheet.write(cell['row'], cell['col'], cell['job'])
stepDone=True stepDone=True
break break
if not stepDone: if not stepDone:
cells.append({'row':step+1, cells.append({'row':step+1,
'col':machine_index+1, 'col':col_to_write,
'job':job.alias}) 'job':job.alias})
G.routeTraceSheet.write(step+1, machine_index+1, job.alias) G.routeTraceSheet.write(step+1, col_to_write, job.alias)
# list of cells to be written
cells=[]
# for every job in the JobList
for worker in G.OperatorsList:
# choose alias for the worker
worker.alias=worker.id
if worker.schedule:
for record in worker.schedule:
# find the station of this step
station=record[0] # XXX should also hold a list with all the machines G.MachineList?
# find the column corresponding to the machine
# XXX each machine should have at least 3 columns, 2 for the jobs and one for operators
if station in G.MachineList:
machine_index=G.MachineList.index(station)
# find the entrance time of this step
entrance_time=record[1] # the time entity entered station
# find the row corresponding to the event and start placing the name of the Job in the cells
entrance_time_index=events_list.index(entrance_time)
# find the exit time of this step
if len(record)==3:
exit_time=record[2] # the time the entity exited the station
# find the row corresponding to the event and place the name of the Job in the cell, this is the last cell of this processing
exit_time_index=events_list.index(exit_time)
elif len(record)!=3:
exit_time_index=len(events_list)
# for the rows with indices entrance_time_index to exit_time_index print the id of the Job in the column of the machine_index
for step in range(entrance_time_index,exit_time_index+1, 1):
col_to_write=station.op_cel
stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not cells:
cells.append({'row':step+1,
'col':col_to_write,
'worker':worker.alias})
G.routeTraceSheet.write(step+1, col_to_write, worker.alias)
continue
for cell in cells:
if cell['row']==step+1 and cell['col']==col_to_write:
cell['worker']=cell['worker']+','+worker.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['worker'])
stepDone=True
break
if not stepDone:
cells.append({'row':step+1,
'col':col_to_write,
'worker':worker.alias})
G.routeTraceSheet.write(step+1, col_to_write, worker.alias)
# print aliases # print aliases
try: try:
sample_job=next(x for x in G.JobList) sample_job=next(x for x in G.JobList)
......
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