Commit d762d546 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

Job object updated to output a json result noting its schedule. Format should...

Job object updated to output a json result noting its schedule. Format should be discussed along with the input format
parent d92a00dd
......@@ -86,6 +86,7 @@ class CoreObject(Process):
activeObjectQueue.append(activeEntity) #get the entity from the previous object
#and put it in front of the activeQ
giverObject.removeEntity() #remove the entity from the previous object
activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
......
......@@ -38,7 +38,12 @@ class Entity(object):
self.width=1.0
self.height=1.0
self.length=1.0
self.priority=priority
self.dueDate=dueDate
self.orderDate=orderDate
\ No newline at end of file
self.schedule=[] #a list that holds information about the schedule of the entity (when it enters and exits every station)
#outputs results to JSON File
def outputResultsJSON(self):
pass
\ No newline at end of file
......@@ -47,9 +47,18 @@ class ExitJobShop(Exit):
#gets an entity from the previous station
def getEntity(self):
name=self.previousStation.Res.activeQ[0].name #get the name of the entity for the trace
self.totalLifespan+=now()-self.previousStation.Res.activeQ[0].startTime #Add the entity's lifespan to the total one.
self.previousStation.removeEntity() #remove the entity from the previous object
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
giverObject=self.previousStation
giverObjectQueue=giverObject.Res.activeQ
activeEntity=giverObjectQueue[0]
name=activeEntity.name #get the name of the entity for the trace
self.totalLifespan+=now()-activeEntity.startTime #Add the entity's lifespan to the total one.
giverObject.removeEntity() #remove the entity from the previous object
self.outputTrace(name)
activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result
\ No newline at end of file
......@@ -40,6 +40,22 @@ class Job(Entity):
self.remainingRoute=route #the remaining route. in the beginning this should be the same as the full route
self.currentStop=route[0][0] #the starting stop should be the first in the route
#outputs results to JSON File
def outputResultsJSON(self):
from Globals import G
if(G.numberOfReplications==1): #if we had just one replication output the results to excel
json={}
json['_class'] = 'Dream.Job';
json['id'] = str(self.id)
json['results'] = {}
json['results']['schedule']={}
i=0
for record in self.schedule:
json['results']['schedule'][str(i)]={}
json['results']['schedule'][str(i)]['stationId']=record[0]
json['results']['schedule'][str(i)]['entranceTime']=record[1]
i+=1
G.outputJSON['elementList'].append(json)
......@@ -50,7 +50,7 @@ except ImportError:
sys.modules['scipy'] = scipy
logger.error("Scipy cannot be imported, using dummy implementation")
from SimPy.Simulation import activate, initialize, simulate
from SimPy.Simulation import activate, initialize, simulate, now
from Source import Source
from Globals import G
from Machine import Machine
......@@ -387,6 +387,8 @@ def setWIP():
object=obj
object.Res.activeQ.append(entity)
entity.remainingRoute[0][0]="" #remove data from the remaining route.
entity.schedule.append([object.id,now()]) #append the time to schedule so that it can be read in the result
#the main script that is ran
def main(argv=[], input_data=None):
......@@ -469,6 +471,9 @@ def main(argv=[], input_data=None):
model_resource.outputResultsJSON()
except AttributeError:
pass
for job in G.JobList:
job.outputResultsJSON()
outputJSONString=json.dumps(G.outputJSON, indent=True)
G.outputJSONFile.write(outputJSONString)
......
......@@ -60,13 +60,22 @@ class QueueJobShop(Queue):
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
self.Res.activeQ.append(self.previousStation.Res.activeQ[0]) #get the entity from the previous object
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
giverObject=self.previousStation
giverObjectQueue=giverObject.Res.activeQ
activeEntity=giverObjectQueue[0]
self.Res.activeQ.append(giverObjectQueue[0]) #get the entity from the previous object
#and put it in front of the activeQ
self.previousStation.removeEntity() #remove the entity from the previous object
self.Res.activeQ[-1].remainingRoute[0][0]="" #remove data from the remaining route.
activeEntity.remainingRoute[0][0]="" #remove data from the remaining route.
#This is needed so that the Queue will not request again for the Entity
self.outputTrace(self.Res.activeQ[-1].name, "got into "+self.objName)
self.outputTrace(activeEntity.name, "got into "+activeObject.objName)
activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result
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