import logging as Log
import grpc,argparse,time,sys,threading

import mllp_grpc.asr_pb2_grpc as asr_pb2_grpc
import mllp_grpc.asr_pb2 as asr_pb2
import mllp_grpc.asr_common_pb2 as asr_common_pb2
import google.protobuf.empty_pb2 as empty_pb2

from math import ceil

ASR_SERVER_HOST = "localhost"
ASR_SERVER_PORT = 8041
ASR_SYSTEM_HOST = "localhost"
ASR_SYSTEM_PORT = 8042

if __name__=='__main__':
    Log.basicConfig(level=Log.INFO)
    addr= '%s:%d'%(ASR_SERVER_HOST, ASR_SERVER_PORT)
    with grpc.insecure_channel(addr) as channel:
        stub= asr_pb2_grpc.ASRStub(channel)
        for info in stub.GetSystemsInfo(empty_pb2.Empty()):
            print(info)
        res= stub.AddSystem(asr_pb2.AddSystemRequest(host=ASR_SYSTEM_HOST,
                                                     port=ASR_SYSTEM_PORT))
        for info in stub.GetSystemsInfo(empty_pb2.Empty()):
            print(info)
