コード例 #1
0
ファイル: SimulationNoGUI.py プロジェクト: anup5889/devsimpy
def makeSimulation(filename, T):
    """
	"""

    a = Container.Diagram()

    if not isinstance(a.LoadFile(filename), Exception):
        sys.stdout.write("\nFichier charge\n")

        try:
            master = Container.Diagram.makeDEVSInstance(a)
        except:
            return False
        else:
            sim = runSimulation(master, T)
            thread = sim.Run()

            # first_time = time.time()
            # while(thread.isAlive()):
            # new_time = time.time()
            # Printer(new_time - first_time)

            sys.stdout.write("\nTime : %s" % str(master.FINAL_TIME))
            sys.stdout.write("\nFin.\n")
    else:
        sys.stdout.write(
            "\n/!\ Il y a eu une erreur. Le fichier n'a pas ete charge. /!\ \n"
        )
コード例 #2
0
ファイル: SimulationNoGUI.py プロジェクト: anup5889/devsimpy
def makeJS(filename):
    """
	"""

    a = Container.Diagram()
    if a.LoadFile(filename):
        sys.stdout.write("\nFichier charge\n")
        master = Container.Diagram.makeDEVSInstance(a)

        addInner = []
        liaison = []
        model = {}
        labelEnCours = str(os.path.basename(a.last_name_saved).split('.')[0])

        # path = os.path.join(os.getcwd(),os.path.basename(a.last_name_saved).split('.')[0] + ".js") # genere le fichier js dans le dossier de devsimpy
        # path = filename.split('.')[0] + ".js" # genere le fichier js dans le dossier du dsp charge.

        #Position initial du 1er modele
        x = [40]
        y = [40]
        myBool = True

        model, liaison, addInner = Join.makeJoin(a, addInner, liaison, model,
                                                 myBool, x, y, labelEnCours)
        Join.makeDEVSConf(model, liaison, addInner, "%s.js" % labelEnCours)
    else:
        return False
コード例 #3
0
ファイル: XML.py プロジェクト: anup5889/devsimpy
	def OnInit(self):
		import Core.Components.Container as Container
		import GUI.ShapeCanvas as ShapeCanvas
		import GUI.DetachedFrame as DetachedFrame
		import __builtin__
		import gettext
		from Core.DomainInterface.DomainStructure import DomainStructure
		from Core.DomainInterface.DomainBehavior import DomainBehavior

		__builtin__.__dict__['ICON_PATH'] = os.path.join('Assets', 'icons')
		__builtin__.__dict__['ICON_PATH_16_16'] = os.path.join(ICON_PATH, '16x16')
		__builtin__.__dict__['NB_HISTORY_UNDO'] = 5
		__builtin__.__dict__['DOMAIN_PATH'] = 'Domain'
		__builtin__.__dict__['FONT_SIZE'] = 12
		__builtin__.__dict__['_'] = gettext.gettext
		__builtin__.__dict__['LOCAL_EDITOR'] = False

		diagram = Container.Diagram()

		self.frame = DetachedFrame.DetachedFrame(None, -1, "Test", diagram)
		newPage = ShapeCanvas.ShapeCanvas(self.frame, wx.NewId(), name='Test')
		newPage.SetDiagram(diagram)

		getDiagramFromXML("Diagram.xml", canvas=newPage)
		#diagram.SetParent(newPage)

		self.frame.Show()

		return True
コード例 #4
0
    def AddEditPage(self, title, defaultDiagram=None):
        """
		Adds a new page for editing to the notebook and keeps track of it.
		
		@type title: string
		@param title: Title for a new page
		"""

        ### title page list
        title_pages = map(lambda p: p.name, self.pages)

        ### occurence of title in existing title pages
        c = title_pages.count(title)

        title = title + "(%d)" % c if c != 0 else title

        ### new page
        newPage = ShapeCanvas.ShapeCanvas(self, wx.NewId(), name=title)

        ### new diagram
        d = defaultDiagram or Container.Diagram()
        d.SetParent(newPage)

        ### diagram and background newpage setting
        newPage.SetDiagram(d)

        ### print canvas variable setting
        self.print_canvas = newPage
        self.print_size = self.GetSize()

        self.pages.append(newPage)
        self.AddPage(newPage, title, imageId=0)
        self.SetSelection(self.GetPageCount() - 1)
コード例 #5
0
ファイル: Components.py プロジェクト: anup5889/devsimpy
    def Load(filename, label, canvas):
        """ Load component from filename
		"""
        import Core.Components.Container as Container
        #assert(filename.endswith('.dsp'))

        # its possible to use the orignal copy of the droped diagram
        dial = wx.MessageDialog(
            canvas, _('Do you want to open the orignal diagram in a new tab?'),
            'Question', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)

        new_tab = dial.ShowModal() == wx.ID_YES

        # load diagram in a new page
        if new_tab:
            diagram = Container.Diagram()
        else:
            diagram = canvas.GetDiagram()

        ### if diagram is instanciated
        if diagram:
            load_file_result = diagram.LoadFile(filename)

            ### if diagram is loaded
            if not isinstance(load_file_result, Exception):

                mainW = canvas.GetTopLevelParent()
                nb2 = mainW.nb2

                ### if new tab
                if new_tab:
                    nb2.AddEditPage(label, diagram)
                else:
                    selection = nb2.GetSelection()
                    nb2.SetPageText(selection, label)

                # Add as new recent file
                if filename not in mainW.openFileList:
                    mainW.openFileList.insert(0, filename)
                    del mainW.openFileList[-1]
                    mainW.cfg.Write("openFileList",
                                    str(eval("mainW.openFileList")))
                    mainW.cfg.Flush()

                return True
            else:
                info = _(
                    'Error opening file \n file : %s \n object : %s \n error : %s '
                ) % (filename, load_file_result[1], load_file_result[0])
                wx.MessageBox(info, _('Error'), wx.OK | wx.ICON_ERROR)
                return False
コード例 #6
0
ファイル: DetachedFrame.py プロジェクト: anup5889/devsimpy
	def OnInit(self):

		import gettext
		import Core.Components.Container as Container
		import __builtin__

		__builtin__.__dict__['NB_HISTORY_UNDO'] = 5
		__builtin__.__dict__['ICON_PATH'] = os.path.join('Assets','icons')
		__builtin__.__dict__['ICON_PATH_16_16'] = os.path.join(ICON_PATH,'16x16')
		__builtin__.__dict__['_'] = gettext.gettext

		diagram = Container.Diagram()

		self.frame = DetachedFrame(None, -1, "Test", diagram)
		self.frame.Show()
		return True