예제 #1
0
    def __step_activated(self, *args):
        text = self['entry4'].get_text()

        if text == '':
            dialog = ConfirmWindow(0, "Please enter a value as stepsize.")
            return

        try:
            aNum = float(text)
        except:
            dialog = ConfirmWindow(
                0, "Please enter a numeric value as step size")
            return

        if aNum <= 0:
            dialog = ConfirmWindow(
                0, "Please enter a positive value as step size")
            return

        if self['radiobuttonSec'].get_active() == True:
            if self.theRuntimeObject.checkState(ME_RUN_MODE) == True:
                self.theRuntimeObject.run(aNum)

        elif self['radiobuttonStep'].get_active() == True:
            if self.theRuntimeObject.checkState(ME_RUN_MODE) == True:
                self.theRuntimeObject.step(aNum)
예제 #2
0
    def generateAutoLayout( self, primarySelection, layoutName ):

        # get secondary selection
        self.__getSecondarySelection( primarySelection )
        self.__getVariableReferenceList( )
	# parse into dot
        text = self.__parseEntities( ME_ROOTID)
        # write to file
        outputFileName =os.getcwd() + os.sep + "dotout"+str(os.getpid() )
        inputFileName = os.getcwd() + os.sep + "dotin" + str( os.getpid() ) 
        fd = open(outputFileName,'w')
        fd.write(text)
        fd.close()
        # process file
        os.system('neato -Tdot "' + outputFileName + '" -o"' + inputFileName + '"')
        #load input file
        try:
            fd = open( inputFileName, 'r')
        except:
            ConfirmWindow( 0, "Auto visualization function needs Graphviz installed.\n Please download and install this free software from http://www.graphviz.org/Download.php.\n Both windows and linux binaries are available.", "")
            return

        intext = " ".join(fd.readlines() )
        fd.close()
        intext = re.sub(r'[\\\n\t]','',intext)
        intext = re.sub('{','{\n',intext)
        intext = re.sub('}','}\n',intext)
        intext = re.sub(';',';\n',intext)
        self.theText = intext.split('\n')
        del intext
        
        
        keyWord, parentID = self.theText[0].strip().split(' ')[0:2]
        if keyWord != "digraph" and parentID!= self.translationList[ME_ROOTID]:
            ConfirmWindow(0, "There was an error processing dot file.\n No layout is created")
            return

        self.__parseGraph( parentID, 1 )
        

        # create systems
        self.__createBB ( ME_ROOTID )
        self.__createSystems(  ME_ROOTID )
        
        self.__createConnections()
        os.unlink ( inputFileName )
        os.unlink( outputFileName )        
        
        
        # create varrefs


        #layoutBuffer = self.theLayoutBufferFactory.createLayoutBuffer(self.theLayoutName)
        #self.theLayoutManager.deleteLayout(self.theLayoutName)
        #aCommand = PasteLayout( self.theLayoutManager, layoutBuffer , self.theLayoutName, True )
        #self.theModelEditor.doCommandList( [ aCommand ] )
        self.theLayoutManager.showLayout( self.theLayoutName )
예제 #3
0
 def __canRun(self):
     if not self.preRunSuccessful:
         dialog = ConfirmWindow(
             1,
             "Your model is not stable for running! Test run hanged or crashed!\nAre you sure you want to run in ModelEditor?\nIf you choose yes, ModelEditor can hang or crash.\n(Changes are saved)",
             "CRITICAL")
         if dialog.return_result() != 0:
             return False
     return True
예제 #4
0
 def changeToDesignMode(self, forced=False):
     # check whether simulation is running
     if self.isRunning():
         if not forced:
             dialog = ConfirmWindow(
                 1,
                 "To perform this operation, simulation must be stopped.\n Can simulation be stopped?"
             )
             if dialog.return_result() == 0:
                 self.theSession.stop()
             else:
                 return False
         else:
             self.theSession.stop()
     self.theMode = ME_DESIGN_MODE
     self.theModelEditor.theMainWindow.updateRunMode()
     return True