コード例 #1
0
ファイル: test_base.py プロジェクト: flschiavoni/mosaicode
    def create_block(self, diagram_control=None):
        if diagram_control is None:
            diagram_control = self.create_diagram_control()

        System()
        block_model = BlockModel()
        System.add_port(self.create_port())

        block_model.ports = [{
            "type": "Test",
            "label": "Click",
            "conn_type": "Input",
            "name": "0"
        }, {
            "type": "Test",
            "label": "Click",
            "conn_type": "Output",
            "name": "1"
        }, {
            "type": "Test",
            "label": "Click",
            "conn_type": "Input",
            "name": "2"
        }, {
            "type": "Test",
            "label": "Click",
            "conn_type": "Output",
            "name": "3"
        }]

        block_model.help = "Test"
        block_model.label = "Test"
        block_model.color = "200:200:25:150"
        block_model.group = "Test"
        block_model.codes = {"code0": "Test", "Code1": "Test", "Code2": "Test"}
        block_model.type = "Test"
        block_model.language = "Test"
        block_model.properties = [{
            "name": "test",
            "label": "Test",
            "value": "0",
            "type": MOSAICODE_FLOAT
        }]
        block_model.extension = "Test"
        block_model.file = None

        result = BlockControl.load_ports(block_model, System.get_ports())
        System.add_block(block_model)
        self.assertEquals(result[1], "Success")
        self.assertEquals(result[0], True)
        self.assertEquals(len(block_model.ports), 4)

        block = Block(diagram_control.diagram, block_model)
        self.assertEquals(len(block.ports), 4)

        return block
コード例 #2
0
    def create_block(self, diagram_control=None):
        if diagram_control is None:
            diagram_control = self.create_diagram_control()

        block_model = BlockModel()

        port0 = Port()
        port0.label = "Test0"
        port0.conn_type = Port.OUTPUT
        port0.name = "Test0"
        port0.type = "Test"

        port1 = Port()
        port1.label = "Test1"
        port1.conn_type = Port.INPUT
        port1.name = "Test1"
        port1.type = "Test"

        block_model.ports = [port0, port1]

        block_model.help = "Test"
        block_model.label = "Test"
        block_model.color = "200:200:25:150"
        block_model.group = "Test"
        block_model.codes = {"code0":"Test",
                       "Code1":"Test",
                       "Code2":"Test"}
        block_model.type = "Test"
        block_model.maxIO = 2
        block_model.language = "language"
        block_model.properties = [{"name": "test",
                             "label": "Test",
                             "type": MOSAICODE_FLOAT
                             }]

        block_model.extension = "Test"
        block_model.file = None

        block = Block(diagram_control.diagram, block_model)


        return block