Esempio n. 1
0
    def Load(filename, label):
        """ Load CMD from filename
		"""
        import Core.Components.Container as Container

        assert (filename.endswith('.cmd'))

        ### new ContainerBlock instance
        m = Container.ContainerBlock()

        load_file_result = m.LoadFile(filename)

        if isinstance(load_file_result, Exception):
            wx.MessageBox(
                _('Error loading %s model : %s' %
                  (label, str(load_file_result))), _('Error'),
                wx.OK | wx.ICON_ERROR)
            return None

        else:
            ### mandatory due to the LoadFile call before
            m.label = label

            # coupled input ports
            m.input = 0
            m.output = 0
            for s in m.shapes:
                if isinstance(s, Container.iPort):
                    m.input += 1
                elif isinstance(s, Container.oPort):
                    m.output += 1

            return m
Esempio n. 2
0
    def Create(self):
        """ Create CMD from constructor
		"""
        import Core.Components.Container as Container
        # new containerBlock model
        self.__m = Container.ContainerBlock(self._label, self._inputs,
                                            self._outputs)

        # input and output ports
        for i in xrange(self._inputs):
            self.__m.nbiPort += i
            id = self.__m.nbiPort
            iport = Container.iPort(label='IPort %d' % id)
            iport.id = id
            self.__m.AddShape(iport)

        for o in xrange(self._outputs):
            self.__m.nboPort += o
            id = self.__m.nboPort
            oport = Container.oPort(label='OPort %d' % id)
            oport.id = id
            self.__m.AddShape(oport)

        self.__m.python_path = self._python_file
        self.__m.model_path = self._model_file

        return self.__m