コード例 #1
0
ファイル: client.py プロジェクト: zukobronja/apollo
def test_client_class():
    """
    Client send request
    """
    node = cyber.Node("client_node")
    client = node.create_client("server_01", ChatterBenchmark,
                                ChatterBenchmark)
    req = ChatterBenchmark()
    req.content = "clt:Hello service!"
    req.seq = 0
    count = 0
    while not cyber.is_shutdown():
        time.sleep(1)
        count += 1
        req.seq = count
        print("-" * 80)
        response = client.send_request(req)
        print("get Response [ ", response, " ]")
コード例 #2
0
def callback(data):
    print "-" * 80
    print "get Request [ ", data, " ]"
    # print "req type is ", type(data) # <class
    # 'cyber.proto.chatter_pb2.ChatterBenchmark'>
    response = ChatterBenchmark()
    response.content = "svr: Hello client!"
    response.seq = data.seq + 2
    return response
コード例 #3
0
ファイル: talker.py プロジェクト: xingjiangyu/apollo
def test_talker_class():
    """
    Test talker.
    """
    msg = ChatterBenchmark()
    msg.content = "py:talker:send Alex!"
    msg.stamp = 9999
    msg.seq = 0
    print(msg)
    test_node = cyber.Node("node_name1")
    g_count = 1

    writer = test_node.create_writer("channel/chatter", ChatterBenchmark, 6)
    while not cyber.is_shutdown():
        time.sleep(1)
        g_count = g_count + 1
        msg.seq = g_count
        msg.content = "I am python talker."
        print("=" * 80)
        print("write msg -> %s" % msg)
        writer.write(msg)