Exemplo n.º 1
0
def main(argv=sys.argv):
    #try:
    xme_file = "InputModel.xme"
    # import xme file and open gme project using gmepy
    mga_file = gme.xme2mga(xme_file)  # import XME
    # get project directory
    project = gme.Project.open(mga_file)

    run_importer(project.project, ".", "InputModel.component.acm")

    return 0
def main(argv=sys.argv):    
    #try:
    xme_file = "InputModel.xme"
    # import xme file and open gme project using gmepy
    mga_file = gme.xme2mga(xme_file)  # import XME
    # get project directory
    project = gme.Project.open(mga_file)
    
    run_importer(project.project,".","InputModel.component.acm")
    
		
		
    return 0
meta_path = ''
if paradigm == "CyPhyML" and ( not 'META_PATH' in os.environ or os.environ[ 'META_PATH' ] == '' ):
    print "META_PATH environment variable not set and CyPhyML paradigm specified"
    print "If CyPhyML paradigm is specified, META_PATH environment variable must be set to trunk of CyPhyML code base to run this program"
    sys.exit( 1 )
else:
    meta_path = os.environ[ 'META_PATH' ]

destdir = vcp_path + r"\generated\ESM2SLC\models\\" + paradigm
destfile = destdir + r"\ESM2SLC.mga"

if not os.path.exists( destdir ):
    os.makedirs( destdir )

# these output a file of the same name in the same directory
gme.xme2mga( vcp_path + r"\src\models\ESM2SLC\ESM2SLC.xme", destfile )

if paradigm != "CyPhyML":
    print "\"" + paradigm + "\" paradigm specified:  no transform will be executed"
    sys.exit( 0 )

print "Executing transform ...",
sys.stdout.flush()

# change the metaname of the UML diagram
gme.mga2xme( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.mga" )
with file( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.xme", "rb" ) as xme:
    lines = xme.readlines()
with file( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.xme", "wb" ) as xme:
    for line in lines:
        xme.write(  line.replace( 'metaname="UML"', 'metaname="UMLModelTransformer"' )  )
meta_path = ''
if paradigm == "CyberComposition" and ( not 'META_PATH' in os.environ or os.environ[ 'META_PATH' ] == '' ):
    print "META_PATH environment variable not set and CyberComposition paradigm specified"
    print "If CyberComposition paradigm is specified, META_PATH environment variable must be set to trunk of Cyber code base to run this program"
    sys.exit( 1 )
else:
    meta_path = os.environ[ 'META_PATH' ]

destdir = meta_path + r"\src\Cyber2SFC_CodeGen\SF_CodeGen"
destfile = destdir + r"\Cyber2SFC_udm.mga"

if not os.path.exists( destdir ):
    os.makedirs( destdir )

gme.xme2mga( destdir + r"\Cyber2SFC_udm.xme", destfile )

mga = win32com.client.DispatchEx("Mga.MgaProject")
mga.Open( "MGA=" + destfile )

gme.mga2xme( meta_path + r"\generated\Cyber\models\CyberComposition_uml.mga" )
xme = win32com.client.DispatchEx("Mga.MgaParser")
xme.ParseProject(mga, meta_path + r"\generated\Cyber\models\CyberComposition_uml.xme")

mga.BeginTransactionInNewTerr()

SF_TypeBase = mga.RootFolder.ObjectByPath('/@CyberComposition|kind=Package/@Simulink|kind=Namespace/@Types|kind=ClassDiagram/@SF_TypeBase|kind=Class')
TypeBase = mga.RootFolder.ObjectByPath('/LINKS/NewClassDiagram/TypeBase')
TypeBase.Referred = SF_TypeBase

State = mga.RootFolder.ObjectByPath('/@CyberComposition|kind=Package/@Simulink|kind=Namespace/@Stateflow|kind=ClassDiagram/@State|kind=Class')
meta_path = ''
if paradigm == "CyPhyML" and ( not 'META_PATH' in os.environ or os.environ[ 'META_PATH' ] == '' ):
    print "META_PATH environment variable not set and CyPhyML paradigm specified"
    print "If CyPhyML paradigm is specified, META_PATH environment variable must be set to trunk of CyPhyML code base to run this program"
    sys.exit( 1 )
else:
    meta_path = os.environ[ 'META_PATH' ]

destdir = vcp_path + r"\generated\SF_CodeGen\models\\" + paradigm
destfile = destdir + r"\ESM2SFC.mga"

if not os.path.exists( destdir ):
    os.makedirs( destdir )

# these output a file of the same name in the same directory
gme.xme2mga( vcp_path + r"\src\SF_CodeGen\models\ESM2SFC.xme", destfile )

if paradigm != "CyPhyML":
    print "\"" + paradigm + "\" paradigm specified:  no transform will be executed"
    sys.exit( 0 )

print "Executing transform ...",
sys.stdout.flush()

# change the metaname of the UML diagram
gme.mga2xme( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.mga" )
with file( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.xme", "rb" ) as xme:
    lines = xme.readlines()
with file( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.xme", "wb" ) as xme:
    for line in lines:
        xme.write(  line.replace( 'metaname="UML"', 'metaname="UMLModelTransformer"' )  )