printRoute methods added to Job and Operator, printRoute static method updated

parent 5bd8dbae
......@@ -50,6 +50,8 @@ class Job(Entity): # inherits from the Entity c
self.extraPropertyDict = extraPropertyDict
# variable used to differentiate entities with and entities without routes
self.family='Job'
# used by printRoute
self.alias='J'+str(len(G.JobList))
# =======================================================================
# outputs results to JSON File
......@@ -149,4 +151,58 @@ class Job(Entity): # inherits from the Entity c
if not self in router.conflictingEntities:
router.conflictingEntities.append(self)
return availableReceiver
#===========================================================================
# print the route (the different stations the entity moved through)
#===========================================================================
def printRoute(self):
if self.schedule:
for record in self.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=G.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=G.events_list.index(exit_time)
elif len(record)!=3:
exit_time_index=len(G.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.station_col_inds[0] # XXX
stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not G.cells_to_write:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'job':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
continue
for cell in G.cells_to_write:
if cell['row']==step+1 and cell['col']==col_to_write:
next_col=station.station_col_inds[1] # XXX
if not next_col in [x['col'] for x in G.cells_to_write if x['row']==step+1]: # XXX
G.cells_to_write.append({'row':step+1, # XXX
'col':next_col, # XXX
'job':self.alias}) # XXX
G.routeTraceSheet.write(step+1, next_col, self.alias) # XXX
stepDone=True # XXX
break # XXX
cell['job']=cell['job']+','+self.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['job'])
stepDone=True
break
if not stepDone:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'job':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
......@@ -73,6 +73,8 @@ class Operator(ObjectResource):
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
# alias used by printRoute
self.alias=self.id
@staticmethod
def getSupportedSchedulingRules():
......@@ -351,7 +353,7 @@ class Operator(ObjectResource):
G.outputIndex+=1
G.outputIndex+=1
# =======================================================================
# =======================================================================
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
......@@ -367,4 +369,50 @@ class Operator(ObjectResource):
json['results']['working_ratio'] = getConfidenceIntervals(self.Working)
json['results']['waiting_ratio'] = getConfidenceIntervals(self.Waiting)
G.outputJSON['elementList'].append(json)
\ No newline at end of file
#===========================================================================
# print the route (the different stations the resource was occupied by)
#===========================================================================
def printRoute(self):
if self.schedule:
for record in self.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
from Globals import G
# 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 G.cells_to_write
entrance_time_index=G.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=G.events_list.index(exit_time)
elif len(record)!=3:
exit_time_index=len(G.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_col_indx
stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not G.cells_to_write:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'worker':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
continue
for cell in G.cells_to_write:
if cell['row']==step+1 and cell['col']==col_to_write:
cell['worker']=cell['worker']+','+self.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['worker'])
stepDone=True
break
if not stepDone:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'worker':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
\ No newline at end of file
This diff is collapsed.
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