#ifndef _SOFT_SEED_WEIGHT_H
#define _SOFT_SEED_WEIGHT_H
#include "common.h"


typedef enum{
    WEIGHT_DEFAULT = 0,
    WEIGHT_NORMAL = 1, //普通称重
    WEIGHT_LIFT = 2, //吊运称重
    WEIGHT_FPLATE = 3, //前板
    WEIGHT_TRANFER = 4, //转接板
}WEIGHT;
extern uint8_t weight_type;

typedef enum{
    SPREAD_DEFAULT = 0,
    SPREAD_NORMAL = 1, //普通播撒
    SPREAD_JIAOLONG = 2, //搅笼播撒
}SPREAD;
extern uint8_t spread_type;


//EFT前板
#define CAN_EFT_FPLATE (0x8876)
#define CAN_EFT_FPLATE_ACK (0x8877)
//Z70吊运称重
#define CAN_EFT70_WEIGHT (0x88BA)
#define CAN_EFT70_WEIGHT_ACK (0x88BC)


#define Cal_Remove_Peel     20
#define Cal_Weight          21
#define Cal_Seed_Back       23

//EFT播撒器
#define CAN_EFT_SPREAD (0x8851)
#define CAN_EFT_VERSION (0x8853)
//
#define SEND_EFT_INFO (0x88F2)
//
//断料记
#define CAN_MIMO_LACKLOSS (0x88F1)
#define Z70_DEVICE (0x7010)
#define Z70_DEVICE_ACK (0x7011)


#pragma pack(1)
typedef struct
{
    uint8_t work_status; // 工作状态
    uint8_t warn_status; // 报警状态
    uint8_t output;      // 输出信号源
    uint16_t can_rate;   // CAN波特率
    uint8_t reserve;     // 保留
    uint8_t warn_switch; // 报警开关
    uint8_t recv_conut;  // 计数
    int serial_num;      // 厂家编号
} seed;
#pragma pack()
extern seed seed_vkinfo;

#pragma pack(1)
typedef struct {
    uint8_t work_status;    //工作状态
    uint8_t warn_status;    //报警状态 bit0: 1断药
    bool can_enable;        //can使能
    uint16_t capacitance;   //电容
    uint8_t electricity;    //电流
    char temperature;       //温度
    uint8_t func_status;    //功能状态
    uint8_t num;            //循环次数
    uint16_t weight;        //重量

    uint8_t cal_status;     //校准状态

    uint8_t valve_angel;   //舵机角度 0-100
    uint8_t speed_rpm;     //转盘转速  *10
    uint8_t enginearm_lock;//机臂锁
    uint8_t last_arm_lock; //发送给FCU的判断标志
    uint8_t pump1_rpm;     //水泵1转速
    uint8_t pump2_rpm;     //水泵2转速
    uint8_t cent1_rpm;     //喷头1转速
    uint8_t cent2_rpm;     //喷头1转速
    uint64_t watering_warn_status; //水泵喷头报警状态
    uint16_t seed_k[3];     //称重传感器K值

    char version[2];
    char sn[10];
}eft; 
#pragma pack()
extern eft eft_info;

#pragma pack(1)
typedef struct 
{
    uint8_t arm1:1;
    uint8_t arm2:1;
    uint8_t arm3:1;
    uint8_t arm4:1;
    uint8_t reserve1:4;
    uint16_t weight;
    uint8_t Rled_tempture;
    uint8_t Lled_tempture;
    uint8_t Rled_status:1;
    uint8_t Lled_status:1;
    uint8_t Rled_switch:1;
    uint8_t Lled_switch:1;
    uint8_t reserve2:4;
    uint8_t bms_plug_tempture;
    uint8_t bms_battery_tempture;
}eft_fplate;
#pragma pack()
extern eft_fplate fplate;

typedef struct
{
    uint8_t output_mode;
    short   pwm_turntable;
    short   pwm_valve;
}Spread_par;
extern Spread_par spread_par;


#pragma pack(1)
typedef struct
{
    uint8_t sensor_status; // 工作状态
    uint8_t warn_status;   // 报警状态
    uint16_t weight_rate;  // 重量变化率
    int weight;            // 重量
    int serial_num;        // 厂家编号
    uint16_t senor_k[4];   // 称重传感器K值
    uint8_t mode;          // 称重模式 1播撒 2喷洒
    uint16_t dose_rate;    // 最高下药率 kg/min
} weight;
#pragma pack()
extern weight weight_vkinfo;

extern uint16_t last_light_brightness;


typedef struct 
{
    uint16_t distance;
    uint16_t strength;
    uint8_t status; // 0满 1缺
    uint16_t cal_distance;
}_mimo_lackloss;
extern _mimo_lackloss mimo_lackloss;

extern bool Z70_LiftingWeight_exist;

void Eft_Spread_And_Mimolack_recieved_hookfuction(uint32_t CanID, uint8_t data[], uint8_t len);
void can_recv_eft_front_plate(uint32_t CanID, uint8_t data[], uint8_t len);
void can_sendmsg_eft(void);
void can_sendmsg_VK(void);
#endif