Commit 79d6fca0 authored by panos's avatar panos Committed by Jérome Perrin

Modify the already existing example (TwoServers) and add a new example ProductionLine

parent 2625d4c9
'''
Created on 11 Jun 2014
@author: Panos
'''
from xml.etree.ElementTree import ElementTree, Element, SubElement, Comment
from xml.dom import minidom
from xml.etree import ElementTree as etree
#======================================= The CMSD_Output object ============================================#
#This object gives as an output the CMSD document of the example topology with the updated calculated values in Operation time and Scrap quantity in the different stations of the production line
def CMSD_example(list1,list2):
#Use of XML.ETREE Python library to create the CMSD document in XML for the CRE production line
root = Element('opml')
root.set('version', '1.0')
tree=ElementTree(root)
root.append (Comment('CMSDDocument xmlns=urn:cmsd:mainxmlns:xsi'))
#Data section of the CMSD document
DataSection=SubElement(root,'DataSection')
#Part type definition in XML-based CMSD
PartType=SubElement(DataSection,'PartType')
Identifier=SubElement(PartType,'Identifier')
Identifier.text='Part1'
PartType=SubElement(DataSection,'PartType')
Identifier=SubElement(PartType,'Identifier')
Identifier.text='UnfinishedPart1'
#Resources definition in XML-based CMSD. It shows the resource identifier, description, resource type and name.
#The resource information package contains classes for creating definitions of the characteristics and capabilities of the equipment and employees.
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource1'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the first of two parallel stations in Section PA'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P1'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource2'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the second of two parallel stations in Section PA'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P4'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource3'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the first of two parallel stations in Section PA'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P2'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource4'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the second of two parallel stations in Section PA'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P5'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource5'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the first of two parallel stations in Section PA'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P3'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource6'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the second of two parallel stations in Section PA'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P6'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource7'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the machine in Section PB'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='machine'
Name=SubElement(Resource,'Name')
Name.text='P7'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource8'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the first of two parallel stations in Section PC'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P8'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource9'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the second of two parallel stations in Section PC'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P9'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource10'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the first of two parallel stations in Section PD'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P10'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='resource11'
Description=SubElement(Resource,'Description')
Description.text='This resource describes the second of two parallel stations in Section PD'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='station'
Name=SubElement(Resource,'Name')
Name.text='P11'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='A'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='employee'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='B'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='employee'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='C'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='employee'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='D'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='employee'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='E'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='employee'
Resource=SubElement(DataSection,'Resource')
Identifier=SubElement(Resource,'Identifier')
Identifier.text='F'
ResourceType=SubElement(Resource,'ResourceType')
ResourceType.text='employee'
#Process plan definition in XML-based CMSD. A process plan object contains one or more process objects.
#Each process object may represent either an individual process or a process group. The process plan indicates which process executes first.
ProcessPlan=SubElement(DataSection,'ProcessPlan')
Identifier=SubElement(ProcessPlan,'Identifier')
Identifier.text='ProcessPlan:PPPlan1'
PartsProduced=SubElement(ProcessPlan,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='The part produced the process'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(ProcessPlan,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part consumed the process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
FirstProcess=SubElement(ProcessPlan,'FirstProcess')
ProcessIdentifier=SubElement(FirstProcess,'ProcessIdentifier')
ProcessIdentifier.text='PFirst'
#A process group indicates that a group of processes either executes in a sequence (sequence group),
#only one process in the group executes (decision group), or all processes in the group execute (concurrent group).
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='PFirst'
SubProcessGroup=SubElement(Process,'SubProcessGroup')
Type=SubElement(SubProcessGroup,'Type')
Type.text='sequence'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='PA'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='PB'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='PC'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='PD'
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='PA'
SubProcessGroup=SubElement(Process,'SubProcessGroup')
Type=SubElement(SubProcessGroup,'Type')
Type.text='decision'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='PA1'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='PA2'
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='PA1'
SubProcessGroup=SubElement(Process,'SubProcessGroup')
Type=SubElement(SubProcessGroup,'Type')
Type.text='sequence'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P1'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P2'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P3'
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='PB'
SubProcessGroup=SubElement(Process,'SubProcessGroup')
Type=SubElement(SubProcessGroup,'Type')
Type.text='sequence'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P7'
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='PC'
SubProcessGroup=SubElement(Process,'SubProcessGroup')
Type=SubElement(SubProcessGroup,'Type')
Type.text='sequence'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P8'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P9'
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='PD'
SubProcessGroup=SubElement(Process,'SubProcessGroup')
Type=SubElement(SubProcessGroup,'Type')
Type.text='sequence'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P10'
Process=SubElement(Type,'Process')
ProcessIdentifier=SubElement(Process,'ProcessIdentifier')
ProcessIdentifier.text='P11'
#Processes definition in XML-based CMSD. The production planning package contains classes and relationships to create plans for timing of usage of resources
#and describing the sequence of steps to manufacture products using the available resources.
#It defines information such as orders, resources, and operation time description. Properties like the scrap quantity in our case, used in CMSD information model to define characteristics and capabilities of equipment and employees
#In the following script the eleven stations of the CRE line are defined. In each station there is information about the orders, the required resources, the operation time and the scrap quantity.
#============================= P1 ==========================================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P1'
Description=SubElement(Process,'Description')
Description.text='P1'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='A'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource1'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P1']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P1']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P1']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P1'])
#================================ P2 ==========================================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P2'
Description=SubElement(Process,'Description')
Description.text='P2'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='B'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource3'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P2']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P2']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P2']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P2'])
#================================ P3 ==========================================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P3'
Description=SubElement(Process,'Description')
Description.text='P3'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='C'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource5'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P3']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P3']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P3']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P3'])
#================================ P4 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P4'
Description=SubElement(Process,'Description')
Description.text='P4'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='A'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource2'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P4']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P4']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P4']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P4'])
#================================ P5 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P5'
Description=SubElement(Process,'Description')
Description.text='P5'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='B'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource4'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P5']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P5']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P5']['mean'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P5'])
#================================ P6 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P6'
Description=SubElement(Process,'Description')
Description.text='P6'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='C'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource6'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P6']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P6']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P6']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P6'])
#================================ P7 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P7'
Description=SubElement(Process,'Description')
Description.text='P7'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='D'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource8'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P7']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P7']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P7']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P7'])
#================================ P8 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P8'
Description=SubElement(Process,'Description')
Description.text='P8'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='E'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource8'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P8']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P8']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P8']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P8'])
#================================ P9 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P9'
Description=SubElement(Process,'Description')
Description.text='P9'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='E'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource9'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P9']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P9']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P9']['stdev'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P9'])
#================================ P10 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P10'
Description=SubElement(Process,'Description')
Description.text='P10'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='F'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource10'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P10']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P10']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P9']['mean'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P10'])
#================================ P11 =============================================#
Process=SubElement(ProcessPlan,'Process')
Identifier=SubElement(Process,'Identifier')
Identifier.text='P11'
Description=SubElement(Process,'Description')
Description.text='P11'
PartsProduced=SubElement(Process,'PartsProduced')
Description=SubElement(PartsProduced,'Description')
Description.text='...'
PartType=SubElement(PartsProduced,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='Part1'
PartQuantity=SubElement(PartsProduced,'PartQuantity')
PartQuantity.text='1'
PartsConsumed=SubElement(Process,'PartsConsumed')
Description=SubElement(PartsConsumed,'Description')
Description.text='The part that is an input to this process'
PartType=SubElement(PartsConsumed,'PartType')
PartTypeIdentifier=SubElement(PartType,'PartTypeIdentifier')
PartTypeIdentifier.text='UnfinishedPart1'
PartQuantity=SubElement(PartsConsumed,'PartQuantity')
PartQuantity.text='1'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The employee performing the operation'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='F'
ResourcesRequired=SubElement(Process,'ResourcesRequired')
Description=SubElement(ResourcesRequired,'Description')
Description.text='The resource where the operation is being performed'
Resource=SubElement(ResourcesRequired,'Resource')
ResourceIdentifier=SubElement(Resource,'ResourceIdentifier')
ResourceIdentifier.text='resource11'
OperationTime=SubElement(Process,'OperationTime')
Unit=SubElement(OperationTime,'Unit')
Unit.text='minute'
Distribution=SubElement(OperationTime,'Distribution')
Name=SubElement(Distribution,'Name')
Name.text=str(list1['P11']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='mean'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P11']['mean'])
DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name')
Name.text='stdev'
Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P11']['mean'])
Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name')
Name.text='ScrapQuantity'
Name=SubElement(Property,'Name')
Name.text='mean'
Value=SubElement(Property,'Value')
Value.text=str(list2['P11'])
#Return a pretty-printed XML string for the Element
def prettify(elem):
rough_string = etree.tostring(elem, 'utf-8')
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent=" ")
xmlString=prettify(root)
#print xmlString
f=open('CMSD.xml','w') #open an existed xml file in the given directory
f.write(xmlString) #Write and save the produced CMSD document in the xml file
return xmlString
\ No newline at end of file
import json
def JSON_example(list1,list2):
jsonFile= open('JSON_example.json','r')
data = json.load(jsonFile)
jsonFile.close()
nodes=data.get('nodes',{})
for (element_id,element) in nodes.iteritems():
name=element.get('name')
scrapQuantity=element.get('scrapQuantity',{})
processingTime=element.get('processingTime',{})
if name =='P1':
scrapQuantity['mean']=str(list2['P1'])
processingTime['distributionType']=str(list1['P1']['distributionType'])
processingTime['mean']=str(list1['P1']['mean'])
processingTime['stdev']=str(list1['P1']['stdev'])
elif name=='P4':
scrapQuantity['mean']=str(list2['P4'])
processingTime['distributionType']=str(list1['P4']['distributionType'])
processingTime['mean']=str(list1['P4']['mean'])
processingTime['stdev']=str(list1['P4']['stdev'])
elif name=='P2':
scrapQuantity['mean']=str(list2['P2'])
processingTime['distributionType']=str(list1['P2']['distributionType'])
processingTime['mean']=str(list1['P2']['mean'])
processingTime['stdev']=str(list1['P2']['stdev'])
elif name=='P5':
scrapQuantity['mean']=str(list2['P5'])
processingTime['distributionType']=str(list1['P5']['distributionType'])
processingTime['mean']=str(list1['P5']['mean'])
processingTime['stdev']=str(list1['P5']['stdev'])
elif name=='P3':
scrapQuantity['mean']=str(list2['P3'])
processingTime['distributionType']=str(list1['P3']['distributionType'])
processingTime['mean']=str(list1['P3']['mean'])
processingTime['stdev']=str(list1['P3']['stdev'])
elif name=='P6':
scrapQuantity['mean']=str(list2['P6'])
processingTime['distributionType']=str(list1['P6']['distributionType'])
processingTime['mean']=str(list1['P6']['mean'])
processingTime['stdev']=str(list1['P6']['stdev'])
elif name=='P7':
scrapQuantity['mean']=str(list2['P7'])
processingTime['distributionType']=str(list1['P7']['distributionType'])
processingTime['mean']=str(list1['P7']['mean'])
processingTime['stdev']=str(list1['P7']['stdev'])
elif name=='P8':
scrapQuantity['mean']=str(list2['P8'])
processingTime['distributionType']=str(list1['P8']['distributionType'])
processingTime['mean']=str(list1['P8']['mean'])
processingTime['stdev']=str(list1['P8']['stdev'])
elif name=='P9':
scrapQuantity['mean']=str(list2['P9'])
processingTime['distributionType']=str(list1['P9']['distributionType'])
processingTime['mean']=str(list1['P9']['mean'])
processingTime['stdev']=str(list1['P9']['stdev'])
elif name=='P10':
scrapQuantity['mean']=str(list2['P10'])
processingTime['distributionType']=str(list1['P10']['distributionType'])
processingTime['mean']=str(list1['P10']['mean'])
processingTime['stdev']=str(list1['P10']['stdev'])
elif name=='P11':
scrapQuantity['mean']=str(list2['P11'])
processingTime['distributionType']=str(list1['P11']['distributionType'])
processingTime['mean']=str(list1['P11']['mean'])
processingTime['stdev']=str(list1['P11']['stdev'])
else:
continue
jsonFile = open('JSON_exampleOutput.json',"w")
jsonFile.write(json.dumps(data, indent=True))
jsonFile.close()
{
"nodes": {
"P1": {
"name": "P1",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"Q2A": {
"top": 0.7727272727272727,
"_class": "Dream.LineClearance",
"capacity": "2",
"name": "Q2A",
"left": 0.6968085106382979
},
"Q2B": {
"top": 0.7727272727272727,
"_class": "Dream.LineClearance",
"capacity": "2",
"name": "Q2B",
"left": 0.6968085106382979
},
"P4": {
"name": "P4",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"S1": {
"name": "Source",
"top": 0.9545454545454546,
"entity": "Batch",
"interarrivalTime": {
"distributionType": "Fixed",
"mean": "0.5"
},
"batchNumberOfUnits": 100,
"_class": "Dream.BatchSource",
"left": 0.6968085106382979
},
"QPa": {
"top": 0.7727272727272727,
"_class": "Dream.Queue",
"capacity": "3",
"name": "QPa",
"left": 0.6968085106382979
},
"QPr": {
"top": 0.7727272727272727,
"_class": "Dream.Queue",
"capacity": "3",
"name": "QPr",
"left": 0.6968085106382979
},
"P8": {
"name": "P8",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"QStart": {
"top": 0.7727272727272727,
"_class": "Dream.Queue",
"capacity": "-1",
"name": "StartQueue",
"left": 0.6968085106382979
},
"BDB": {
"name": "Batch_DecompositionB",
"top": 0.5909090909090908,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"numberOfSubBatches": 4,
"_class": "Dream.BatchDecomposition",
"left": 0.4414893617021277
},
"P10": {
"name": "P10",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"P11": {
"name": "P11",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"E1": {
"top": 0.045454545454545414,
"_class": "Dream.Exit",
"name": "Stock",
"left": 0.2978723404255319
},
"P2": {
"name": "P2",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"P5": {
"name": "P5",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"Q3B": {
"top": 0.7727272727272727,
"_class": "Dream.LineClearance",
"capacity": "2",
"name": "Q3B",
"left": 0.6968085106382979
},
"Q3A": {
"top": 0.7727272727272727,
"_class": "Dream.LineClearance",
"capacity": "2",
"name": "Q3A",
"left": 0.6968085106382979
},
"BDA": {
"name": "Batch_DecompositionA",
"top": 0.5909090909090908,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"numberOfSubBatches": 4,
"_class": "Dream.BatchDecomposition",
"left": 0.4414893617021277
},
"P9": {
"name": "P9",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"P7": {
"name": "P7",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"P6": {
"name": "P6",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"P3": {
"name": "P3",
"top": 0.5909090909090908,
"scrapQuantity": {
},
"processingTime": {
},
"failures": {},
"_class": "Dream.BatchScrapMachine",
"left": 0.4414893617021277
},
"QM": {
"top": 0.7727272727272727,
"_class": "Dream.Queue",
"capacity": "3",
"name": "QM",
"left": 0.6968085106382979
},
"BRB": {
"name": "Batch_ReassemblyB",
"top": 0.5909090909090908,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"numberOfSubBatches": 4,
"_class": "Dream.BatchReassembly",
"left": 0.4414893617021277
},
"BRA": {
"name": "Batch_ReassemblyA",
"top": 0.5909090909090908,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"numberOfSubBatches": 4,
"_class": "Dream.BatchReassembly",
"left": 0.4414893617021277
}
},
"_class": "Dream.Simulation",
"edges": {
"24": [
"QPa",
"PaB",
{}
],
"25": [
"PaA",
"E1",
{}
],
"26": [
"PaB",
"E1",
{}
],
"20": [
"QPr",
"PrB",
{}
],
"21": [
"PrA",
"QPa",
{}
],
"22": [
"PrB",
"QPa",
{}
],
"23": [
"QPa",
"PaA",
{}
],
"1": [
"QStart",
"BDA",
{}
],
"0": [
"S1",
"QStart",
{}
],
"3": [
"BDA",
"M1A",
{}
],
"2": [
"QStart",
"BDB",
{}
],
"5": [
"Q2A",
"M2A",
{}
],
"4": [
"M1A",
"Q2A",
{}
],
"7": [
"Q3A",
"M3A",
{}
],
"6": [
"M2A",
"Q3A",
{}
],
"9": [
"BRA",
"QM",
{}
],
"8": [
"M3A",
"BRA",
{}
],
"11": [
"M1B",
"Q2B",
{}
],
"10": [
"BDB",
"M1B",
{}
],
"13": [
"M2B",
"Q3B",
{}
],
"12": [
"Q2B",
"M2B",
{}
],
"15": [
"M3B",
"BRB",
{}
],
"14": [
"Q3B",
"M3B",
{}
],
"17": [
"QM",
"MM",
{}
],
"16": [
"BRB",
"QM",
{}
],
"19": [
"QPr",
"PrA",
{}
],
"18": [
"MM",
"QPr",
{}
]
},
"general": {
"maxSimTime": "1440",
"_class": "Dream.Configuration",
"confidenceLevel": "0.95",
"trace": "No",
"numberOfReplications": "1"
}
}
\ No newline at end of file
from StatisticalMeasures import BasicStatisticalMeasures
from DataManipulation import DataManagement
from DistributionFitting import DistFittest
from Example_CMSD import CMSD_example
from Example_JSON import JSON_example
from ExcelOutput import Output
from ReplaceMissingValues import HandleMissingValues
from ImportExceldata import Import_Excel
import xlrd
#================= Main script of KE tool =====================================#
#Read from the given directory the Excel document with the input data
workbook = xlrd.open_workbook('inputData.xls')
worksheets = workbook.sheet_names()
worksheet_ProcessingTimes = worksheets[1] #Define the worksheet with the Processing times data
worksheet_ScrapQuantity = worksheets[0] #Define the worksheet with the Scrap Quantity data
A=Import_Excel() #Call the Python object Import_Excel
ProcessingTimes= A.Input_data(worksheet_ProcessingTimes, workbook) #Create the Processing Times dictionary with keys the different stations in the line and values the processing times of different batches in these stations
ScrapQuantity=A.Input_data(worksheet_ScrapQuantity, workbook) #Create the Scrap Quantity dictionary with keys the different stations in the line and values the scrap quantity data of different batches in these stations
##Get from the Scrap Quantity dictionary the different keys and define the following lists with the scrap quantity data of the different stations in the topology
P7_Scrap = ScrapQuantity.get('P7',[])
P1_Scrap = ScrapQuantity.get('P1',[])
P2_Scrap= ScrapQuantity.get('P3',[])
P3_Scrap=ScrapQuantity.get('P3',[])
P8_Scrap=ScrapQuantity.get('P8',[])
P9_Scrap= ScrapQuantity.get('P9',[])
##Get from the Processing times dictionary the different keys and define the following lists with the processing times data of the different stations in the topology
P7_Proc = ProcessingTimes.get('P7',[])
P1_Proc = ProcessingTimes.get('P1',[])
P2_Proc= ProcessingTimes.get('P2',[])
P3_Proc=ProcessingTimes.get('P3',[])
P8_Proc=ProcessingTimes.get('P8',[])
P9_Proc= ProcessingTimes.get('P9',[])
#Call the HandleMissingValues object and replace with zero the missing values in the lists with the scrap quantity data
B=HandleMissingValues()
P7_Scrap= B.ReplaceWithZero(P7_Scrap)
P1_Scrap= B.ReplaceWithZero(P1_Scrap)
P2_Scrap= B.ReplaceWithZero(P2_Scrap)
P3_Scrap= B.ReplaceWithZero(P3_Scrap)
P8_Scrap= B.ReplaceWithZero(P8_Scrap)
P9_Scrap= B.ReplaceWithZero(P9_Scrap)
# #Call the BasicSatatisticalMeasures object
C=BasicStatisticalMeasures()
#Create a list with values the calculated mean value of scrap quantity on the different stations in the line
listScrap=[C.mean(P1_Scrap),C.mean(P2_Scrap),C.mean(P3_Scrap),C.mean(P1_Scrap),C.mean(P2_Scrap),C.mean(P3_Scrap),C.mean(P7_Scrap),C.mean(P8_Scrap),C.mean(P8_Scrap),C.mean(P9_Scrap), C.mean(P9_Scrap)]
F=DataManagement()
listScrap=F.round(listScrap) #Round the mean values of the list so as to get integers
dictScrap={}
dictScrap['P1']= listScrap[0]
dictScrap['P2']= listScrap[1]
dictScrap['P3']= listScrap[2]
dictScrap['P4']= listScrap[3]
dictScrap['P5']= listScrap[4]
dictScrap['P6']= listScrap[5]
dictScrap['P7']= listScrap[6]
dictScrap['P8']= listScrap[7]
dictScrap['P9']= listScrap[8]
dictScrap['P10']= listScrap[9]
dictScrap['P11']= listScrap[10]
#Create a tuple with the Processing times data lists of the different stations
a=(P1_Proc,P2_Proc,P3_Proc,P1_Proc,P2_Proc,P3_Proc,P7_Proc,P8_Proc,P8_Proc,P9_Proc,P9_Proc)
E=DistFittest() #Call the DistFittest object
dictProc={}
dictProc['P1']= E.ks_test(P1_Proc)
dictProc['P2']= E.ks_test(P1_Proc)
dictProc['P3']= E.ks_test(P1_Proc)
dictProc['P4']= E.ks_test(P1_Proc)
dictProc['P5']= E.ks_test(P1_Proc)
dictProc['P6']= E.ks_test(P1_Proc)
dictProc['P7']= E.ks_test(P1_Proc)
dictProc['P8']= E.ks_test(P1_Proc)
dictProc['P9']= E.ks_test(P1_Proc)
dictProc['P10']= E.ks_test(P1_Proc)
dictProc['P11']= E.ks_test(P1_Proc)
D=Output()
D.PrintDistributionFit(P2_Proc,"DistributionFittingResults_P2Proc.xls")
D.PrintStatisticalMeasures(P2_Proc, "StatisticalMeasuresResults_P2Proc.xls")
CMSD_example(dictProc,dictScrap) #Print the CMSD document, calling the CMSD_example method with arguments the dictProc and dictScrap dictionaries
JSON_example(dictProc,dictScrap)
<?xml version='1.0' encoding='utf8'?>
<CMSDDocument>
<DataSection>
<PartType>
<Identifier>Part1</Identifier>
</PartType>
<PartType>
<Identifier>UnfinishedPart1</Identifier>
</PartType>
<Resource>
<Identifier>S1</Identifier>
<Description>The source of the topology</Description>
<ResourceType>Source</ResourceType>
<Name>RawMaterial</Name>
</Resource>
<Resource>
<Identifier>M1</Identifier>
<Description>The lathe of the topology</Description>
<ResourceType>Machine</ResourceType>
<Name>Machine1</Name>
</Resource>
<Resource>
<Identifier>M2</Identifier>
<Description>The moulding machine of the topology</Description>
<ResourceType>Machine</ResourceType>
<Name>Machine2</Name>
</Resource>
<Resource>
<Identifier>Queue</Identifier>
<Description>The queue of the topology</Description>
<ResourceType>Queue</ResourceType>
<Name>Queue</Name>
</Resource>
<Resource>
<Identifier>Exit</Identifier>
<Description>The exit of the topology</Description>
<ResourceType>Exit</ResourceType>
<Name>Stock</Name>
</Resource>
<Resource>
<Identifier>A</Identifier>
<ResourceType>employee</ResourceType>
</Resource>
<Resource>
<Identifier>B</Identifier>
<ResourceType>employee</ResourceType>
</Resource>
<Resource>
<Identifier>Repairman</Identifier>
<Description>This element describes a class of employees</Description>
<ResourceType>employee</ResourceType>
<Name>W1</Name>
</Resource>
********************************Process Plan*****************************************************
<ProcessPlan>
<Identifier>ProcessPlan:Part1</Identifier>
<PartsProduced>
<Description>The part produced the process</Description>
<PartType>
<PartTypeIdentifier>Part1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part(s) consumed the process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<FirstProcess>
<ProcessIdentifier>MainProcessSequence</ProcessIdentifier>
</FirstProcess>
<Process>
<Identifier>MainProcessSequence</Identifier>
<RepetitionCount>1</RepetitionCount>
<SubProcessGroup>
<Type>sequence</Type>
<Process>
<ProcessIdentifier>A010</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A020</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A030</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A040</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A050</ProcessIdentifier>
</Process>
</SubProcessGroup>
</Process>
***********************************************Process************************************************
<Process>
<Identifier>A010</Identifier>
<Description>Process 1</Description>
<ResourcesRequired>
<Description>Source</Description>
<Resource>
<ResourceIdentifier>S1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<Property>
<Name>interarrivalTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>partType</Name>
<Value>Part</Value>
</Property>
</Process>
<Process>
<Identifier>A020</Identifier>
<Description>Process 2</Description>
<PartsProduced>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<Resource>
<ResourceIdentifier>A</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<ResourcesRequired>
<Description>Machine1.</Description>
<Resource>
<ResourceIdentifier>M1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<OperationTime>
<Unit>minutes</Unit>
<Distribution>
<Name></Name>
<DistributionParameterA>
<Name></Name>
<Value></Value>
</DistributionParameterA>
<DistributionParameterB>
<Name></Name>
<Value></Value>
</DistributionParameterB>
</Distribution>
</OperationTime>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>60</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>5</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Process>
<Process>
<Identifier>A030</Identifier>
<Description>Process 3</Description>
<ResourcesRequired>
<Description>Queue1.</Description>
<Resource>
<ResourceIdentifier>Q1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Process>
<Process>
<Identifier>A040</Identifier>
<Description>Process 4</Description>
<PartsProduced>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<Resource>
<ResourceIdentifier>B</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<ResourcesRequired>
<Description>Machine2.</Description>
<Resource>
<ResourceIdentifier>M2</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<OperationTime>
<Unit>minutes</Unit>
<Distribution>
<Name></Name>
<DistributionParameterA>
<Name></Name>
<Value></Value>
</DistributionParameterA>
<DistributionParameterB>
<Name></Name>
<Value></Value>
</DistributionParameterB>
</Distribution>
</OperationTime>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>40</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>10</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Process>
<Process>
<Identifier>A050</Identifier>
<Description>Process 5</Description>
<ResourcesRequired>
<Description>Exit.</Description>
<Resource>
<ResourceIdentifier>E1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
</ProcessPlan>
</DataSection>
</CMSDDocument>
\ No newline at end of file
{
"modelResource": [
{
"_class": "Dream.Repairman",
"capacity": "1",
"id": "W1",
"name": "W1"
}
],
"_class": "Dream.Simulation",
"coreObject": [
{
"name": "Raw Material",
"entity": "Part",
"interarrivalTime": {
"distributionType": "Fixed",
"mean": "0.5"
},
"successorList": [
"DummyQ"
],
"_class": "Dream.Source",
"id": "S1"
},
{
"predecessorList": [
"DummyQ"
],
"name": "Machine1",
"processingTime": {
},
"successorList": [
"Q1"
],
"failures": {
"MTTR": "5",
"failureDistribution": "Fixed",
"repairman": "W1",
"MTTF": "60"
},
"_class": "Dream.Machine",
"id": "M1"
},
{
"predecessorList": [
"Q1"
],
"name": "Machine2",
"processingTime": {
},
"successorList": [
"E1"
],
"failures": {
"MTTR": "10",
"failureDistribution": "Fixed",
"repairman": "W1",
"MTTF": "40"
},
"_class": "Dream.Machine",
"id": "M2"
},
{
"capacity": "1",
"name": "DummyQ",
"isDummy": "True",
"predecessorList": [
"S1"
],
"successorList": [
"M1"
],
"_class": "Dream.Queue",
"id": "DummyQ"
},
{
"capacity": "1",
"name": "Q1",
"isDummy": "False",
"predecessorList": [
"M1"
],
"successorList": [
"M2"
],
"_class": "Dream.Queue",
"id": "Q1"
},
{
"predecessorList": [
"M2"
],
"_class": "Dream.Exit",
"id": "E1",
"name": "Stock"
}
],
"general": {
"trace": "Yes",
"_class": "Dream.Configuration",
"numberOfReplications": "1",
"maxSimTime": "1440",
"confidenceLevel": "0.95"
}
}
\ No newline at end of file
'''
Created on 19 Feb 2014
@author: Panos
'''
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
from ImportExceldata import Import_Excel
from DistributionFitting import DistFittest
from xml.etree import ElementTree as et
from ExcelOutput import Output
from ReplaceMissingValues import HandleMissingValues
import xlrd
import json
#================================================ This script is a simple example of the Knowledge extraction tool ===============================================================#
#The following is the Main script, that calls two Python objects in order to conduct the three main components of the Knowledge extraction tool
#In the following example the operation times of the topology's two machines are given in an Excel document.
#Import_Excel object imports data from the Excel document to the tool and DistFittest object fits the data to a statistical distribution using Kolmogorov-Smirnov test
workbook = xlrd.open_workbook('inputsKEtool.xls') #Using xlrd library opens the Excel document with the input data
worksheets = workbook.sheet_names()
worksheet_OperationTime = worksheets[0] #It creates a variable that holds the first Excel worksheet
X=Import_Excel() #Call the import_Excel object
OperationTimes= X.Input_data(worksheet_OperationTime,workbook) #It defines a Python dictionary, giving as name OpearationTimes and as value the returned dictionary from the import_Excel object
Machine1_OpearationTimes = OperationTimes.get('Machine1',[]) #Two lists are defined (Machine1_OpearationTimes, Machine2_OpearationTimes) with the operation times data of each machine
Machine2_OpearationTimes = OperationTimes.get('Machine2',[])
A=HandleMissingValues() #Call the HandleMissingValues object
Machine1_OpearationTimes= A.DeleteMissingValue(Machine1_OpearationTimes) #It deletes the missing values in the lists with the operation times data
Machine2_OpearationTimes= A.DeleteMissingValue(Machine2_OpearationTimes)
Dict={}
B=DistFittest() #It calls the DistFittest object
Dict['M1']=B.ks_test(Machine1_OpearationTimes) #It conducts the Kolmogorov-Smirnov test in the list with the operation times data
Dict['M2']=B.ks_test(Machine2_OpearationTimes)
M1=Dict.get('M1')
M2=Dict.get('M2')
#==================================== Output preparation: output the updated values in the CMSD information model of Topology10 ====================================================#
datafile=('CMSD_Topology10.xml') #It defines the name or the directory of the XML file that is manually written the CMSD information model
tree = et.parse(datafile) #This file will be parsed using the XML.ETREE Python library
M1Parameters=[]
M1ParameterValue=[]
for index in list(Dict['M1'].keys()):
if index is not 'distributionType':
M1Parameters.append(index)
M1ParameterValue.append(Dict['M1'][index])
if Dict['M1']['distributionType']=='Normal':
del M1['min']
del M1['max']
elif Dict['M2']['distributionType']=='Normal':
del M2['min']
del M2['max']
M2Parameters=[]
M2ParameterValue=[]
for index in list(Dict['M2'].keys()):
if index is not 'distributionType':
M2Parameters.append(index)
M2ParameterValue.append(Dict['M2'][index])
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
for process in process:
process_identifier=process.find('Identifier').text #It creates a new variable that holds the text of the Identifier element in the XML file
if process_identifier=='A020': #It checks using if...elif syntax if the process identifier is 'A020', so the process that uses the first machine
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=Dict['M1']['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)
DistributionParameterA=process.get('./OperationTime/Distribution/DistributionParameterA')
Name=process.find('./OperationTime/Distribution/DistributionParameterA/Name')
Name.text=str(M1Parameters[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=process.find('./OperationTime/Distribution/DistributionParameterA/Value')
Value.text=str(M1ParameterValue[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)
DistributionParameterB=process.get('./OperationTime/Distribution/DistributionParameterB')
Name=process.find('./OperationTime/Distribution/DistributionParameterB/Name')
Name.text=str(M1Parameters[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=process.find('./OperationTime/Distribution/DistributionParameterB/Value')
Value.text=str(M1ParameterValue[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)
elif process_identifier=='A040': #It checks using if...elif syntax if the process identifier is 'A040', so the process that uses the second machine
OperationTime=process.get('OpeationTime')
Distribution=process.get('./OperationTime/Distribution')
Name=process.find('./OperationTime/Distribution/Name')
Name.text=Dict['M2']['distributionType']
DistributionParameterA=process.get('./OperationTime/Distribution/DistributionParameterA')
Name=process.find('./OperationTime/Distribution/DistributionParameterA/Name')
Name.text=str(M2Parameters[0])
Value=process.find('./OperationTime/Distribution/DistributionParameterA/Value')
Value.text=str(M2ParameterValue[0])
DistributionParameterB=process.get('./OperationTime/Distribution/DistributionParameterB')
Name=process.find('./OperationTime/Distribution/DistributionParameterB/Name')
Name.text=str(M2Parameters[1])
Value=process.find('./OperationTime/Distribution/DistributionParameterB/Value')
Value.text=str(M2ParameterValue[1])
else:
continue
tree.write('CMSD_Topology10_Output.xml',encoding="utf8") #It writes the element tree to a specified file, using the 'utf8' output encoding
#================================= Output preparation: output the updated values in the JSON file of Topology10 =========================================================#
jsonFile= open('JSON_Topology10.json','r') #It opens the Topology10 JSON file
data = json.load(jsonFile) #It loads the file
jsonFile.close()
nodes=data.get('coreObject',[]) #It creates a variable that holds the 'coreObject' list
for element in nodes:
name=element.get('name') #It creates a variable that gets the element attribute 'name'
processingTime=element.get('processingTime',{}) #It creates a variable that gets the element attribute 'processingTime'
if name =='Machine1':
element['processingTime']=Dict['M1'] #It checks using if...elif syntax if the name is 'Machine1', so the first machine in the Topology10
elif name=='Machine2':
element['processingTime']=Dict['M2']
else:
continue
jsonFile = open('JSON_Topology10_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.close() #It closes the file
#================================ Calling the ExcelOutput object, outputs the outcomes of the statistical analysis in Excel files =============================================#
C=Output()
C.PrintDistributionFit(Machine1_OpearationTimes,'Machine1_DistFitResults.xls')
C.PrintStatisticalMeasures(Machine1_OpearationTimes,'Machine1_StatResults.xls')
C.PrintDistributionFit(Machine2_OpearationTimes,'Machine2_DistFitResults.xls')
C.PrintStatisticalMeasures(Machine2_OpearationTimes,'Machine2_StatResults.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