#ifndef SENSORIS11_H
#define SENSORIS11_H
#include   <Arduino.h>
#include "comon.h"
#include "IS11Comon.h"
#include "log.h"
#include "Communication_Protocol.h"
#include "tuigan.h"
#include "servo.h"
#include "DS18B20.h"
#include "SoftwareSerial.h"
#include "SDmanger.h"
#include "ds1302.h"
#include "InterpolationLib.h"
#include "CastumullSpline.h"

class SensorIS11 {
public:
    SensorIS11();
    STRSensorInfo SensorInfo;
    STRSensorInfo initSensor();
    STRSensorInfo GetSensorInfo();
    void SetShutter(int id);// 0 dark 1 green 2 blue
    void GetOneDate(int msc);
    int OptSnenser(int percent);
    unsigned short DATABUFF[2048];
    int shutterup,shutterdown;
    unsigned short *DownData=nullptr;
    unsigned short *UpData=nullptr;
    void shortLittletoBiG( unsigned short *data,int lenth);
   
    int Getmaxvalue(unsigned short *data,int lenth);
    // void TakeOneJob();
    
    void TakeOneJob1(bool dingbing);
    void TakeOneJob();
    void servo_direction(int direction);

    void send_dn(HardwareSerial  *wb485Serial,IS11_datastruct *IS11_datastructure,uint32_t fengbao_num);
    void send_radiance(HardwareSerial  *wb485Serial,IS11_datastruct *IS11_datastructure,uint32_t fengbao_num);
    void senddata(HardwareSerial  *wb485Serial,u_int32_t send_data_type,uint32_t fengbao_num);
    void save_dingbiao(uint8_t * data);
    void save_guangpu_data(IS11_datastruct * data);
    // int dingbiao(u_int32_t step,u_int32_t shutter_timer);
    
    void advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int32_t collect_times,u_int32_t remove_dark);
    void opt(u_int32_t direction);
    PRINTFUNC PrintFunc;
    void send_chongcaiyang(HardwareSerial  *wb485Serial,IS11_datastruct *IS11_datastructure,uint32_t fengbao_num);


    void get_fanshelv();
    // void send_fanshelv(HardwareSerial  *wb485Serial);
    void send_fanshelv(HardwareSerial  * wb485Serial,uint32_t fengbao_num);
    void calculation(float bochang1,float bochang2);
    // Ds1302 ds1302;
    
    volatile float calculation_value;

    int shutternow;
    u_int32_t index = 0;
    volatile u_int32_t work_progress;
    volatile u_int32_t dingbiao_shutter;
    //uint16_t result[2048];


    float chongcaiyang_step = 0.2;
    clalidata_struct radiance_struct_up;
    clalidata_struct radiance_struct_down;
    clalidata_struct fanshelv_struct;

    u_char *DataRetrun;

 
};





#endif