def run():
protoConfig = ProtoConfig.getConfig()
channel = grpc.insecure_channel('localhost:%s' % protoConfig.ports.frontEndPort)
stub = sensors_pb2.FrontEndStub(channel)
dbchannel = grpc.insecure_channel('localhost:%s' % protoConfig.ports.daoPort)
dbstub = dao_pb2.DaoStub(dbchannel)
lux = getLux(stub)
print('lux: ', lux)
temperature = getTemperature(stub)
print('temperature: ', temperature)
irButton = getIrButtonPressed(stub)
print('irButton: ', irButton)
loudness = getSound(stub)
print('loudness: ', loudness)
req = sensors_pb2.GetButtonPressedRequest()
buttonPressed = stub.GetButtonPressed(req).pressed
print('buttonPressed', buttonPressed)
req = sensors_pb2.SetLedStripRequest(
length=30,
brightness=100 if buttonPressed else 0,
speed=5)
response = stub.SetLedStrip(req)
req = dao_pb2.SelectRequest(
table='lux',
limit=10,
cols=[
dao_pb2.RequestCol(name='lux'),
dao_pb2.RequestCol(name='date')
],
)
columns = dbstub.Select(req).columns
print('result %s' % columns)
评论列表
文章目录