//
// Created by zx on 23-11-27.
//

#ifndef CERES_TEST_BOUNDARY_H
#define CERES_TEST_BOUNDARY_H

#include "proto/def.grpc.pb.h"
#include "proto/communication.pb.h"
#include "communication/transitData.h"
#include "detect/detect_manager.h"

enum BoundRet {
    eNormal = Range_status::Range_correct,  //正常
    eWidth = Range_status::Range_car_width,
    eWheelBase = Range_status::Range_car_wheelbase,
    eFront = Range_status::Range_front,   //前超界
    eBack = Range_status::Range_back,    //后超界
    eLeft = Range_status::Range_left,    //左超界
    eRight = Range_status::Range_right,   //右超界
    eLeftAngle = Range_status::Range_angle_anti_clock, //左倾角过大
    eRightAngle = Range_status::Range_angle_clock,  //右倾角过大
    eWheelAngle = Range_status::Range_steering_wheel_nozero   //前轮角未回正
};

class Boundary {
public:
    Boundary() = default;

    bool init(const std::string &file);

    bool init(JetStream::Limit limit);

    ~Boundary();

    void limit(JetStream::MeasureInfo &info);

    void transMeasureInfo(JetStream::MeasureInfo &in, measure_info &out);

    void transMeasureInfo(JetStream::MeasureInfo &in, TransitData::MeasureInfo &out);

    void transMeasureInfo(DetectManager::DetectResult &in, JetStream::MeasureInfo &out);

private:
    BoundRet limit_boundary(JetStream::MeasureInfo info, JetStream::Boundary bound);

    bool read_proto_param(std::string prototxt_path, ::google::protobuf::Message &protobuf_parameter);

    JetStream::Limit limit_;
};

#endif //CERES_TEST_BOUNDARY_H
