Exemplo n.º 1
0
    def test_001(self):
        v1 = gr.RPC_get_string("pyland", "v1", "unit_1_string",
                               "Python Exported String", "", "", "",
                               gr.DISPNULL)
        v1.activate(get1)

        v2 = gr.RPC_get_string("pyland", "v2", "unit_2_string",
                               "Python Exported String", "", "", "",
                               gr.DISPNULL)
        v2.activate(get2)

        v3 = gr.RPC_get_int("pyland", "v3", "unit_3_int",
                            "Python Exported Int", 0, 100, 1, gr.DISPNULL)
        v3.activate(get3.pp)

        v4 = gr.RPC_get_double("pyland", "time", "unit_4_time_double",
                               "Python Exported Double", 0, 1000, 1,
                               gr.DISPNULL)
        v4.activate(get4)

        v5 = gr.RPC_get_vector_float("pyland", "fvec", "unit_5_float_vector",
                                     "Python Exported Float Vector", [], [],
                                     [], gr.DISPTIME | gr.DISPOPTCPLX)
        v5.activate(get5)

        v6 = gr.RPC_get_vector_gr_complex("pyland", "cvec",
                                          "unit_6_gr_complex_vector",
                                          "Python Exported Complex Vector", [],
                                          [], [],
                                          gr.DISPXY | gr.DISPOPTSCATTER)
        v6.activate(get6)

        # print some variables locally
        val = get1()
        rval = v1.get()
        self.assertEqual(val, rval)

        val = get2()
        rval = v2.get()
        self.assertEqual(val, rval)

        val = get3.pp()
        rval = v3.get()
        self.assertEqual(val + 1, rval)

        val = get4()
        rval = v4.get()
        self.assertEqual(val, rval)

        val = get5()
        rval = v5.get()
        self.assertComplexTuplesAlmostEqual(val, rval, 5)

        val = get6()
        rval = v6.get()
        self.assertComplexTuplesAlmostEqual(val, rval, 5)
Exemplo n.º 2
0
    def test_001(self):

        g1 = gr.RPC_get_int("pyland", "v1", "unit_1_int",
                            "Python Exported Int", 0, 100, 10,
                            gr.DISPNULL)
        g1.activate(getset1._get)
        s1 = gr.RPC_get_int("pyland", "v1", "unit_1_int",
                            "Python Exported Int", 0, 100, 10,
                            gr.DISPNULL)
        s1.activate(getset1._set)
        time.sleep(0.01)

        # test int variables
        getset1._set(21)
        val = getset1._get()
        rval = g1.get()
        self.assertEqual(val, rval)

        g2 = gr.RPC_get_float("pyland", "v2", "unit_2_float",
                              "Python Exported Float", -100, 1000.0, 100.0,
                              gr.DISPNULL)
        g2.activate(getset2._get)
        s2 = gr.RPC_get_float("pyland", "v2", "unit_2_float",
                              "Python Exported Float", -100, 1000.0, 100.0,
                              gr.DISPNULL)
        s2.activate(getset2._set)
        time.sleep(0.01)

        # test float variables
        getset2._set(123.456)
        val = getset2._get()
        rval = g2.get()
        self.assertAlmostEqual(val, rval, 4)

        g3 = gr.RPC_get_string("pyland", "v3", "unit_3_string",
                               "Python Exported String", "", "", "",
                               gr.DISPNULL)
        g3.activate(getset3._get)
        s3 = gr.RPC_get_string("pyland", "v3", "unit_3_string",
                               "Python Exported String", "", "", "",
                               gr.DISPNULL)
        s3.activate(getset3._set)
        time.sleep(0.01)

        # test string variables
        getset3._set("third test")
        val = getset3._get()
        rval = g3.get()
        self.assertEqual(val, rval)