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

results outputted also in a JSON file

parent a8e40eee
......@@ -239,7 +239,18 @@ class Assembly(Process):
G.outputIndex+=1
G.outputIndex+=1
#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.Assembly';
json['id'] = str(self.id)
json['results'] = {}
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
G.outputJSON['coreObject'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
......
......@@ -317,6 +317,18 @@ class Conveyer(Process):
G.outputIndex+=1
G.outputIndex+=1
#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.Conveyer';
json['id'] = str(self.id)
json['results'] = {}
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
G.outputJSON['coreObject'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
......
......@@ -273,7 +273,19 @@ class Dismantle(Process):
G.outputIndex+=1
G.outputIndex+=1
#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.Dismantle';
json['id'] = str(self.id)
json['results'] = {}
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
G.outputJSON['coreObject'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def checkIfArrayHasDifValues(self, array):
......
......@@ -183,6 +183,19 @@ class Exit(Process):
G.outputSheet.write(G.outputIndex,3,self.TaktTime[0])
G.outputIndex+=1
G.outputIndex+=1
#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.Exit';
json['id'] = str(self.id)
json['results'] = {}
json['results']['throughput']=self.numOfExits
json['results']['lifespan']=((self.totalLifespan)/self.numOfExits)/G.Base
json['results']['takt_time']=((self.totalTaktTime)/self.numOfExits)/G.Base
G.outputJSON['coreObject'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
......
......@@ -36,9 +36,13 @@ class G:
traceSheet = traceFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True) #create excel sheet
#the output excel
#variables for excel output
outputIndex=0 #index that shows in what row we are
sheetIndex=1 #index that shows in what sheet we are
outputFile = xlwt.Workbook() #create excel file
outputSheet = outputFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True) #create excel sheet
#variables for json output
outputJSON={}
outputJSONFile=None
......@@ -297,6 +297,10 @@ def main(argv=[]):
for core_object in G.ObjList:
core_object.postProcessing(G.maxSimTime)
#carry on the post processing operations for every model resource in the topology
for model_resource in G.RepairmanList:
model_resource.postProcessing(G.maxSimTime)
#output trace to excel
if(G.trace=="Yes"):
G.traceFile.save('trace'+str(i+1)+'.xls')
......@@ -308,13 +312,45 @@ def main(argv=[]):
G.outputSheet.write(G.outputIndex,0, "Execution Time")
G.outputSheet.write(G.outputIndex,1, str(time.time()-start)+" seconds")
G.outputIndex+=2
G.outputJSONFile=open('outputJSON.json', mode='w')
G.outputJSON['_class'] = 'Dream.Simulation';
G.outputJSON['general'] ={};
G.outputJSON['general']['_class'] = 'Dream.Configuration';
G.outputJSON['general']['totalExecutionTime'] = (time.time()-start);
G.outputJSON['modelResource'] =[];
G.outputJSON['coreObject'] =[];
#output data to JSON for every object in the topology
for core_object in G.ObjList:
try:
core_object.outputResultsJSON()
except AttributeError:
pass
#output data to JSON for every resource in the topology
for model_resource in G.RepairmanList:
try:
model_resource.outputResultsJSON()
except AttributeError:
pass
outputJSONString=str(str(G.outputJSON))
outputJSONString=outputJSONString.replace("'", '"')
G.outputJSONFile.write(str(outputJSONString))
#output data to excel for every object in the topology
for core_object in G.ObjList:
core_object.outputResultsXL(G.maxSimTime)
#output data to excel for every resource in the topology
for model_resource in G.RepairmanList:
model_resource.outputResultsXL(G.maxSimTime)
G.outputFile.save("output.xls")
print "execution time="+str(time.time()-start)
if __name__ == '__main__':
main()
main()
......@@ -13,6 +13,7 @@ from SimPy.Simulation import activate, passivate, waituntil, now, hold
from Failure import Failure
from RandomNumberGenerator import RandomNumberGenerator
import scipy.stats as stat
import sys
#the Machine object
class Machine(Process):
......@@ -419,6 +420,20 @@ class Machine(Process):
G.outputIndex+=1
G.outputIndex+=1
#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.Machine';
json['id'] = str(self.id)
json['results'] = {}
json['results']['failure_ratio']=100*self.totalFailureTime/G.maxSimTime
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
G.outputJSON['coreObject'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def checkIfArrayHasDifValues(self, array):
......
......@@ -9,6 +9,7 @@ Models a FIFO queue where entities can wait in order to get into a server
from SimPy.Simulation import *
#import sys
#the Queue object
class Queue(Process):
......@@ -196,4 +197,8 @@ class Queue(Process):
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
#outputs results to JSON File
def outputResultsJSON(self):
pass
\ No newline at end of file
......@@ -83,7 +83,18 @@ class Repairman(object):
G.outputSheet.write(G.outputIndex,3,self.Waiting[0])
G.outputIndex+=1
G.outputIndex+=1
#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.Repairman';
json['id'] = str(self.id)
json['results'] = {}
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
G.outputJSON['modelResource'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
......
......@@ -139,3 +139,7 @@ class Source(Process):
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
#outputs results to JSON File
def outputResultsJSON(self):
pass
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