File: RobotRaconteurMatlabTestClient.py

package info (click to toggle)
robotraconteur 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,380 kB
  • sloc: cpp: 1,149,268; cs: 87,653; java: 58,127; python: 26,897; ansic: 356; sh: 152; makefile: 90; xml: 51
file content (47 lines) | stat: -rw-r--r-- 911 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

import RobotRaconteur as RR
RRN = RR.RobotRaconteurNode.s
import time


def ev1():
    print("Event 1")


def ev2(a, b):
    print("Event2 : " + str(a) + " " + str(b))


def main():
    RRN.RegisterTransport(RR.LocalTransport())
    RRN.RegisterTransport(RR.TcpTransport())

    cred1 = {"password": RR.RobotRaconteurVarValue("testpass1", "string")}
    c = RRN.ConnectService(
        'tcp://localhost:4343/{0}/MatlabTestService', "testuser1", cred1)

    c.testevent1 += ev1
    c.testevent2 += ev2

    c.testfunc1(10, 20)
    print(c.testprop1)
    c.testprop1 = 30
    print(c.testfunc2(20))

    print(c.testprop2)
    s = RRN.NewStructure('example.MatlabTestService.MatlabTestStruct', c)
    s.val1 = 38274
    s.val2 = [1.234, 3.14]

    c.testprop2 = s
    c2 = c.testprop2
    print(c2.val1)
    print(c2.val2)

    time.sleep(2)

    RRN.DisconnectService(c)


if __name__ == '__main__':
    main()