Commit 456c2400 authored by panos's avatar panos

The KE tool main script of this example ammended to call the JSONOutput object

parent 9e448f6d
...@@ -26,9 +26,9 @@ from Transformations import BasicTransformations ...@@ -26,9 +26,9 @@ from Transformations import BasicTransformations
from DistributionFitting import DistFittest from DistributionFitting import DistFittest
from DistributionFitting import Distributions from DistributionFitting import Distributions
from ExcelOutput import Output from ExcelOutput import Output
from JSONOutput import JSONOutput
import ImportDatabase import ImportDatabase
import json import json
#================================= Extract data from the database ==========================================# #================================= Extract data from the database ==========================================#
cnxn=ImportDatabase.ConnectionData(seekName='ServerData', implicitExt='txt', number_of_cursors=3) cnxn=ImportDatabase.ConnectionData(seekName='ServerData', implicitExt='txt', number_of_cursors=3)
...@@ -126,25 +126,22 @@ distMTTR_MILL2 = dist_MTTR.Poisson_distrfit(MTTR_MILL2) ...@@ -126,25 +126,22 @@ distMTTR_MILL2 = dist_MTTR.Poisson_distrfit(MTTR_MILL2)
jsonFile = open('JSON_example.json','r') #It opens the JSON file jsonFile = open('JSON_example.json','r') #It opens the JSON file
data = json.load(jsonFile) #It loads the file data = json.load(jsonFile) #It loads the file
jsonFile.close() jsonFile.close()
nodes = data.get('nodes',[]) #It creates a variable that holds the 'nodes' dictionary
exportJSON=JSONOutput()
for element in nodes: stationId1='M1'
processingTime = nodes[element].get('processingTime',{}) #It creates a variable that gets the element attribute 'processingTime' stationId2='M2'
MTTF_Nodes = nodes[element].get('MTTF',{}) #It creates a variable that gets the element attribute 'MTTF' data1=exportJSON.ProcessingTimes(data, stationId1, distProcTime_MILL1)
MTTR_Nodes = nodes[element].get('MTTR',{}) #It creates a variable that gets the element attribute 'MTTR' data2=exportJSON.ProcessingTimes(data1, stationId2, distProcTime_MILL2)
if element == 'M1': data3=exportJSON.TTF(data2, stationId1, distMTTF_MILL1)
nodes['M1']['processingTime'] = distProcTime_MILL1 #It checks using if syntax if the element is 'M1' data4=exportJSON.TTR(data3, stationId1, distMTTR_MILL1)
nodes['M1']['failures']['MTTF'] = distMTTF_MILL1
nodes['M1']['failures']['MTTR'] = distMTTR_MILL1 data5=exportJSON.TTF(data4, stationId2, distMTTF_MILL2)
elif element == 'M2': data6=exportJSON.TTR(data5, stationId2, distMTTR_MILL2)
nodes['M2']['processingTime'] = distProcTime_MILL2 #It checks using if syntax if the element is 'M2'
nodes['M2']['failures']['MTTF'] = distMTTF_MILL2
nodes['M2']['failures']['MTTR'] = distMTTR_MILL2
jsonFile = open('JSON_ParallelStations_Output.json',"w") #It opens the JSON file jsonFile = open('JSON_ParallelStations_Output.json',"w") #It opens the JSON file
jsonFile.write(json.dumps(data, indent=True)) #It writes the updated data to the JSON file jsonFile.write(json.dumps(data6, indent=True)) #It writes the updated data to the JSON file
jsonFile.close() #It closes the file jsonFile.close() #It closes the file
#=================== Calling the ExcelOutput object, outputs the outcomes of the statistical analysis in xls files ==========================# #=================== Calling the ExcelOutput object, outputs the outcomes of the statistical analysis in xls files ==========================#
export=Output() export=Output()
...@@ -161,4 +158,4 @@ export.PrintDistributionFit(procTime_MILL2,'procTimeMILL2_DistFitResults.xls') ...@@ -161,4 +158,4 @@ export.PrintDistributionFit(procTime_MILL2,'procTimeMILL2_DistFitResults.xls')
export.PrintDistributionFit(MTTF_MILL1,'MTTFMILL1_DistFitResults.xls') export.PrintDistributionFit(MTTF_MILL1,'MTTFMILL1_DistFitResults.xls')
export.PrintDistributionFit(MTTF_MILL2,'MTTFMILL2_DistFitResults.xls') export.PrintDistributionFit(MTTF_MILL2,'MTTFMILL2_DistFitResults.xls')
export.PrintDistributionFit(MTTR_MILL1,'MTTRMILL1_DistFitResults.xls') export.PrintDistributionFit(MTTR_MILL1,'MTTRMILL1_DistFitResults.xls')
export.PrintDistributionFit(MTTR_MILL2,'MTTRMILL2_DistFitResults.xls') export.PrintDistributionFit(MTTR_MILL2,'MTTRMILL2_DistFitResults.xls')
\ No newline at end of file
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