//
//  CGMCommonDefine.h
//  CGMAlgo
//
//  Created by yuwell on 2024/11/4.
//

#ifndef CGMCommonDefine_h
#define CGMCommonDefine_h

/**
 * algorithm number tag
 */
typedef NS_ENUM(int, AlgorithmType) {
    /**
     * CT4 algorithm number tag
     */
    AlgorithmType_CT4 = 10,
};



typedef NS_ENUM(int, HW_CHECK_RET) {
    /**battery verification when battery is low*/
    HW_CHECK_FAIL_POWER = 0x01,
    /**Transmitter temperature abnormal*/
    HW_CHECK_FAIL_TEMPERATURE = 0x02,
    /**The detection current does not reach the threshold*/
    HW_CHECK_FAIL_IW = 0x03,
    /**Success*/
    HW_CHECK_SUCCESS = 0x00,
    /**fail*/
    HW_CHECK_FAIL = 0xFF,
};


/**
 * Calibration status output
 * currently unavailable
 * @author minyuchun
 */
typedef NS_ENUM(int, CalibrationStatus) {
    /**
     * Cannot calibrate
     */
    CALIBRATION_STATUS_NOT = 0,
    /**
     * Can calibrate
     */
    CALIBRATION_STATUS_CAN = 1,
    /**
     * Hope calibrate
     */
    CALIBRATION_STATUS_HOPE = 2,
    /**
     * Init calibrate
     */
    CALIBRATION_STATUS_INIT = 3,
    /**
     * Must calibrate
     */
    CALIBRATION_STATUS_MUST = 4,
};



/***
 * glucose error type
 * @author minyuchun
 */
typedef NS_ENUM(int, ErrorCode) {
    /**
     * No Error
     */
    ERROR_CODE_NONE = 0,
    /**
     * Parameter error, please check {@link HistoryData}
     */
    ERROR_CODE_DATA = 1,
    /**
     * The cache in the algorithm is cleared
     * Please call the method {@link AlgorithmTools} algorithmGlucose(HistoryData) to calculate
     */
    ERROR_CODE_ALGORITHM_DATA = 2,
    /**
     * K must be a value greater than 0.1
     */
    ERROR_CODE_INFO_COMPLETE_INIT = 4,
    /**
     * glucoseId is greater than or equal to {@link EDevice} endNumber - 1
     */
    ERROR_CODE_INFO_COMPLETE_END = 5,
    /**
     * iw is too small, check the transmitter or sensor
     */
    ERROR_CODE_CURRENT_SMALL = 103,
    /***
     * iw noise, check the transmitter or sensor
     */
    ERROR_CODE_NOISE = 11,
    /**
     * Sensitivity reduction, check the sensor or individual immune manifestations
     */
    ERROR_CODE_SENSITIVITY_ATTENUATION = 12,
    /**
     * The sensor is detached from the skin or the transmitter is detached from the sensor
     */
    ERROR_CODE_TAKE_OFF = 13,
    /**
     * The outer membrane of the sensor is damaged
     */
    ERROR_CODE_BREAKAGE = 14,
    /**
     * Sensor Problems
     */
    ERROR_CODE_TOUCH = 15,
    /**
     * Water leakage problem
     */
    ERROR_CODE_FLOODING_WATER = 16,
};


/***
 * Current glucose trend
 * Unit of dependence : mg/dL
 * @author minyuchun
 */
typedef NS_ENUM(int, Trend) {
    /**
     * glucose changes is rising rapidly &gt; 2mg/dL/min
     */
    TREND_CODE_RISE_FAST = 2,
    /**
     * glucose changes is rising slowly &lt;= 2mg/dL/min and &gt; 1mg/dL/min
     */
    TREND_CODE_RISE_SLOW = 1,
    /**
     * glucose changes is stable &lt;= 1mg/dL/min and &gt;= -1mg/dL/min
     */
    TREND_CODE_STEADY = 0,
    /**
     * glucose changes is decreasing slowly &lt; -1mg/dL/min and &gt;= -2mg/dL/min
     */
    TREND_CODE_DROP_SLOW = -1,
    /**
     * glucose changes is decreasing rapidly &lt; -2mg/dL/min
     */
    TREND_CODE_DROP_FAST = -2,
    /**
     * glucose changes is decreasing rapidly &lt; -2mg/dL/min and glucose &lt;= 90mg/dL
     */
    TREND_CODE_DROP_FAST_LOW = -3,
    /**
     * Insufficient safety data to generate trends
     */
    TREND_CODE_NONE = 10,
};


typedef NS_ENUM(int, UnbindType) {
    /**
     * Reset due to charging
     */
    UNBIND_CHARGE = 1,
    /***
     * Reset due to non-charging
     */
    UNBIND_OTHER = 0,
    /**
     * No valid reset reason was obtained
     */
    UNBIND_NONE = -1,
};

#endif /* CGMCommonDefine_h */
