#=========================================== The CMSDOutput object =============================================================#
#The CMSDOutput object exports the data prepared by the KE tool to a format that follows the CMSD specification. It uses predefined tags in the CMSD standard.
classCMSDOutput(object):
defDistributions(self,data):
Parameters=[]
ParameterValue=[]
ifdata['distributionType']=='Normal':
deldata['min']
deldata['max']
forindexinlist(data.keys()):
ifindexisnot'distributionType':
Parameters.append(index)
ParameterValue.append(data[index])
returnParameters,ParameterValue
defProcessingTimes(self,tree,stationId,distDict):
root=tree.getroot()
process=tree.findall('./DataSection/ProcessPlan/Process')#It creates a new variable and using the 'findall' order in XML.ETREE library, this new variable holds all the processes defined in the XML file
forprocessinprocess:
process_identifier=process.find('Identifier').text#It creates a new variable that holds the text of the Identifier element in the XML file
ifprocess_identifier==stationId:#It checks using if...elif syntax the value of the process identifier
OperationTime=process.get('OpeationTime')#It gets the element attribute OpearationTime inside the Process node
Distribution=process.get('./OperationTime/Distribution')#It gets the element attribute Distribution inside the OpearationTime node
Name=process.find('./OperationTime/Distribution/Name')#It finds the subelement Name inside the Distribution attribute
Name.text=distDict['distributionType']#It changes the text between the Name element tags, putting the name of the distribution (e.g. in Normal distribution that will be Normal)
Name.text=str(names[0])#It changes the text between the Name element tags, putting the name of the distribution's first parameter (e.g. in Normal that will be the mean)
Value.text=str(values[0])#It changes the text between the Value element tags, putting the value of the distribution's first parameter (e.g. in Normal so for mean value that will be 5.0)
Name.text=str(names[1])#It changes the text between the Name element tags, putting the name of the distribution's second parameter (e.g. in Normal that will be the standarddeviation)
Value.text=str(values[1])#It changes the text between the Value element tags, putting the value of the distribution's second parameter (e.g. in Normal so for standarddeviation value that will be 1.3)
exceptIndexError:
continue
returntree
defTTF(self,tree,stationId,distDict):
root=tree.getroot()
process=tree.findall('./DataSection/ProcessPlan/Process')#It creates a new variable and using the 'findall' order in XML.ETREE library, this new variable holds all the processes defined in the XML file
forprocessinprocess:
process_identifier=process.find('Identifier').text#It creates a new variable that holds the text of the Identifier element in the XML file
ifprocess_identifier==stationId:#It checks using if...elif syntax the value of the process identifier
Name.text=str(names[0])#It changes the text between the Name element tags, putting the name of the distribution's first parameter (e.g. in Normal that will be the mean)
Value.text=str(values[0])#It changes the text between the Value element tags, putting the value of the distribution's first parameter (e.g. in Normal so for mean value that will be 5.0)
Name.text=str(names[1])#It changes the text between the Name element tags, putting the name of the distribution's second parameter (e.g. in Normal that will be the standarddeviation)
Value.text=str(values[1])#It changes the text between the Value element tags, putting the value of the distribution's second parameter (e.g. in Normal so for standarddeviation value that will be 1.3)
exceptIndexError:
continue
returntree
defTTR(self,tree,stationId,distDict):
root=tree.getroot()
process=tree.findall('./DataSection/ProcessPlan/Process')#It creates a new variable and using the 'findall' order in XML.ETREE library, this new variable holds all the processes defined in the XML file
forprocessinprocess:
process_identifier=process.find('Identifier').text#It creates a new variable that holds the text of the Identifier element in the XML file
ifprocess_identifier==stationId:#It checks using if...elif syntax the value of the process identifier
Name.text=str(names[0])#It changes the text between the Name element tags, putting the name of the distribution's first parameter (e.g. in Normal that will be the mean)
Value.text=str(values[0])#It changes the text between the Value element tags, putting the value of the distribution's first parameter (e.g. in Normal so for mean value that will be 5.0)
Name.text=str(names[1])#It changes the text between the Name element tags, putting the name of the distribution's second parameter (e.g. in Normal that will be the standarddeviation)
Value.text=str(values[1])#It changes the text between the Value element tags, putting the value of the distribution's second parameter (e.g. in Normal so for standarddeviation value that will be 1.3)
process=tree.findall('./DataSection/ProcessPlan/Process')#It creates a new variable and using the 'findall' order in XML.ETREE library, this new variable holds all the processes defined in the XML file
forprocessinprocess:
process_identifier=process.find('Identifier').text#It creates a new variable that holds the text of the Identifier element in the XML file
ifprocess_identifier==stationId:#It checks using if...elif syntax the value of the process identifier
Name.text=str(names[0])#It changes the text between the Name element tags, putting the name of the distribution's first parameter (e.g. in Normal that will be the mean)
Value.text=str(values[0])#It changes the text between the Value element tags, putting the value of the distribution's first parameter (e.g. in Normal so for mean value that will be 5.0)
Name.text=str(names[1])#It changes the text between the Name element tags, putting the name of the distribution's second parameter (e.g. in Normal that will be the standarddeviation)
Value.text=str(values[1])#It changes the text between the Value element tags, putting the value of the distribution's second parameter (e.g. in Normal so for standarddeviation value that will be 1.3)