package cn.iocoder.yudao.module.grpc.service.geometry;

import com.google.protobuf.DoubleValue;
import device.proto.robotics.nav.ChassisNavigationControlService;
import device.proto.robotics.nav.ChassisNavigationServiceGrpc;
import io.grpc.Channel;
import lombok.extern.slf4j.Slf4j;
//import net.devh.springboot.autoconfigure.grpc.client.GrpcClient;

import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.stereotype.Service;

import java.util.Iterator;

@Slf4j
@Service
public class GeometryServiceImpl implements GeometryService{

    @GrpcClient("ChassisNavigationService")
    private Channel serverChannel;

    @Override
    public String onVehiclePoseUpdated() {
        log.info("测试GRPC连接");

        ChassisNavigationServiceGrpc.ChassisNavigationServiceBlockingStub myServiceStub
                = ChassisNavigationServiceGrpc.newBlockingStub(this.serverChannel);
        Iterator<ChassisNavigationControlService.Response> responseIterator = myServiceStub.onVehiclePoseUpdated(null);
        while (responseIterator.hasNext()) {
            log.info("机车推送的消息 :{}",responseIterator.next());
        }
        DoubleValue build = DoubleValue.newBuilder().build();
        ChassisNavigationControlService.Response response = myServiceStub.forkControl(build);
        return response.toString();
    }



}
