//
//  CurrentGlucose.h
//  CGMAlgo
//
//  Created by yuwell on 2024/11/5.
//

#import <Foundation/Foundation.h>
#import "EDevice.h"

NS_ASSUME_NONNULL_BEGIN

/**
 * Output Parameters {@link AlgorithmTools}
 * @author minyuchun
 */
@interface CurrentGlucose : NSObject
/**
 * glucoseId
 */
@property (nonatomic, assign) int glucoseId;
/**
 * Cumulative Day
 */
@property (nonatomic, assign) int dayCount;
/**
 * glucose hour
 */
@property (nonatomic, assign) int hour;
/**
 * glucose minute
 */
@property (nonatomic, assign) int minute;
/**
 * glucose iw
 */
@property (nonatomic, assign) float Iw;
/**
 * glucose ib
 */
@property (nonatomic, assign) float Ib;
/**
 * glucose T
 */
@property (nonatomic, assign) float T;
/**
 * Last calibration glucose value mg/dL
 */
@property (nonatomic, assign) int BGMG;
/**
 * The sensor signal is converted into a glucose signal mg/dL
 */
@property (nonatomic, assign) int GluMG;
/**
 * calibration count
 */
@property (nonatomic, assign) int BGCount;
/**
 * Valid data count after each calibration
 */
@property (nonatomic, assign) int BGICount;
/**
 * Error
 * {@link ErrorCode}
 */
@property (nonatomic, assign) ErrorCode errorCode;
/**
 * trend information
 * {@link Trend}
 */
@property (nonatomic, assign) Trend trend;
/**
 * {@link CalibrationStatus}
 */
@property (nonatomic, assign) CalibrationStatus calibrationStatus;
/**
 * Countdown - day used with countdownHours and countdownMinutes
 */
@property (nonatomic, assign) int countdownDays;
/**
 * Countdown - hour
 */
@property (nonatomic, assign) int countdownHours;
/**
 * Countdown - minute
 */
@property (nonatomic, assign) int countdownMinutes;

- (NSString *)toString;

@end



/**
 * Algorithm parameters，{@link AlgorithmTools}
 * @author minyuchun
 */
@interface HistoryData : NSObject
/**
 * glucoseId
 */
@property (nonatomic, assign) int glucoseId;
/**
 * CGM Warm-up time, expressed in points, 20 points equals 1 hour
 * Call the method new LatestData(...), automatically configure {@link EDevice} it when passing in the Transmitter name
 */
@property (nonatomic, assign) int initCount;
/**
 * CGM end time, expressed in points, 7220 points equals 14days + 1 hour
 * Call the method  new LatestData(...), automatically configure {@link EDevice} it when passing in the Transmitter name
 */
@property (nonatomic, assign) int endCount;
/**
 * algorithm number tag
 * Call the method new LatestData(...), automatically configure {@link EDevice} it when passing in the Transmitter name
 */
@property (nonatomic, assign) int algorithm;
/**
 * {@link ProtocolTools.Glucose} iws[] all glucose
 */
@property float *Iws;
/**
 * {@link ProtocolTools.Glucose} number of Iws[] all glucose
 */
@property (nonatomic, assign) int IwsCount;
/**
 * ProtocolTools.Glucose} ibs[] all glucose
 */
@property float *Ibs;
/**
 * ProtocolTools.Glucose}number of  ibs[] all glucose
 */
@property (nonatomic, assign) int IbsCount;
/**
 * ProtocolTools.Glucose} Ts[] all glucose
 */
@property float *Ts;
/**
 * ProtocolTools.Glucose}number of  Ts[] all glucose
 */
@property (nonatomic, assign) int TsCount;
/**
 * QR Code information K
 */
@property (nonatomic, assign) float K0;
/**
 * QR Code information R
 */
@property (nonatomic, assign) float R;
/**
 * {@link ist.com.sdk.ProtocolTools.Glucose} startYear glucoseId is 0
 * Call the method setStartTimeMillis(startTimeMillis), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, startYear is 2024
 */
@property (nonatomic, assign) int startYear;
/**
 * {@link ist.com.sdk.ProtocolTools.Glucose} startMonth glucoseId is 0
 * Call the method setStartTimeMillis(startTimeMillis), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, startMonth is 8
 */
@property (nonatomic, assign) int startMonth;
/**
 * {@link ProtocolTools.Glucose} startDay glucoseId is 0
 * Call the method setStartTimeMillis(startTimeMillis), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, startDay is 29
 */
@property (nonatomic, assign) int startDay;
/**
 * {@link ProtocolTools.Glucose} startHour glucoseId is 0
 * Call the method setStartTimeMillis(startTimeMillis), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, startHour is 13
 */
@property (nonatomic, assign) int startHour;
/**
 * {@link.Glucose} startMinute glucoseId is 0
 * Call the method setStartTimeMillis(startTimeMillis), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, startMinute is 30
 */
@property (nonatomic, assign) int startMinute;
/**
 * GlucoseId list corresponding to calibration
 * for example:
 *  First calibration, glucoseId is 61, [61]
 *  Second calibration, glucoseId is 461, [61,461]
 *  Third calibration, glucoseId is 861, [61,461,861]
 */
@property int *newBgToGlucoseIds;
/**
 *  number of newBgToGlucoseIds data
 */
@property (nonatomic, assign) int newBgToGlucoseIdsCount;
/**
 * Glucose value list corresponding to calibration（mg/dL）
 * for example:
 *  First calibration, glucoseId is 61, Glucose value is 90 mg/dL,[90]
 *  Second calibration, glucoseId is 461, Glucose value is 160 mg/dL,[90,160]
 *  Third calibration, glucoseId is 861, Glucose value is 150 mg/dL,[90,160,150]
 */
@property int *newBgValues;
/**
 *  number of newBgValues data
 */
@property (nonatomic, assign) int newBgValuesCount;
/**
 * QR code information
 */
@property (nonatomic, copy) NSString *sensorInfo;
/**
 * timeMillis
 */
@property (nonatomic, assign) long startTimeMillis;
/**
 * transmitter name
 */
@property (nonatomic, copy) NSString *name;
/***
 * {@link EDevice}
 */
@property (nonatomic, strong) EDevice *mEDevice;

- (id)initWithParameters:(int)glucoseId
                  andIws:(float *)iws
             andIwsCount:(int)IwsCount
                  andIbs:(float *)ibs
             andIbsCount:(int)IbsCount
                   andTs:(float *)ts
              andTsCount:(int)tsCount
                   andK0:(float)k0
                    andR:(float)r
      andStartTimeMillis:(long)startTimeMillis
    andNewBgToGlucoseIds:(int *)newBgToGlucoseIds
andNewBgToGlucoseIdsCount:(int)newBgToGlucoseIdsCount
          andNewBgValues:(int *)newBgValues
     andNewBgValuesCount:(int)newBgValuesCount
                 andName:(NSString *)name;

- (id)initWithParameters:(int)glucoseId
                  andIws:(float *)iws
             andIwsCount:(int)IwsCount
                  andIbs:(float *)ibs
             andIbsCount:(int)IbsCount
                   andTs:(float *)ts
              andTsCount:(int)tsCount
                   andK0:(float)k0
                    andR:(float)r
             andStartDay:(int)startDay
            andStartHour:(int)startHour
          andStartMinute:(int)startMinute
    andNewBgToGlucoseIds:(int *)newBgToGlucoseIds
andNewBgToGlucoseIdsCount:(int)newBgToGlucoseIdsCount
          andNewBgValues:(int *)newBgValues
     andNewBgValuesCount:(int)newBgValuesCount
                 andName:(NSString *)name;

- (void)setTransmitterName:(NSString *)name;

- (void)setStartTimeMillisValue:(long)startTimeMillisValue;

@end


@interface LatestData : NSObject
/**
 * glucoseId
 */
@property (nonatomic, assign) int glucoseId;
/**
 * CGM Warm-up time, expressed in points, 20 points equals 1 hour
 * Call the method new LatestData(...), automatically configure {@link EDevice} it when passing in the Transmitter name
 */
@property (nonatomic, assign) int initCount;
/**
 * CGM end time, expressed in points, 7220 points equals 14days + 1 hour
 * Call the method  new LatestData(...), automatically configure {@link EDevice} it when passing in the Transmitter name
 */
@property (nonatomic, assign) int endCount;
/**
 * algorithm number tag
 * Call the method new LatestData(...), automatically configure {@link EDevice} it when passing in the Transmitter name
 */
@property (nonatomic, assign) int algorithm;
/**
 *  {@link Glucose} iw
 */
@property (nonatomic, assign) float Iw;
/**
 * {@link Glucose} ib
 */
@property (nonatomic, assign) float Ib;
/**
 * {@link Glucose} T
 */
@property (nonatomic, assign) float T;
/**
 * QR Code information K
 */
@property (nonatomic, assign) float K0;
/**
 * QR Code information R
 */
@property (nonatomic, assign) float R;
/**
 * {@link Glucose} year
 * Call the method new LatestData(...,timeMillis,...), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, year is 2024
 */
@property (nonatomic, assign) int year;
/**
 * {@link Glucose} month
 * Call the method new LatestData(...,timeMillis,...), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, month is 8
 */
@property (nonatomic, assign) int month;
/**
 * {@link Glucose} day
 * Call the method new LatestData(...,timeMillis,...), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, day is 29
 */
@property (nonatomic, assign) int day;
/**
 * {@linkGlucose} hour
 * Call the method new LatestData(...,timeMillis,...), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, hour is 13
 */
@property (nonatomic, assign) int hour;
/**
 * {@link Glucose} minute
 * Call the method new LatestData(...,timeMillis,...), timeMillis Automatic allocation
 * for example 2024-08-29 13:30, minute is 30
 */
@property (nonatomic, assign) int minute;
/**
 * Supports calibration, currently unavailable
 * Calibration corresponding to glucoseId，
 * newBgToGlucoseId = glucoseId
 */
@property (nonatomic, assign) int newBgToGlucoseId;
/**
 * Calibrated glucose value mg/dL
 */
@property (nonatomic, assign) int newBgValue;
/**
 * transmitter name
 */
@property (nonatomic, copy) NSString *name;
/***
 * {@link EDevice}
 */
@property (nonatomic, strong) EDevice *mEDevice;
/**
 * QR code information
 */
@property (nonatomic, copy) NSString *sensorInfo;
/**
 * timeMillis
 */
@property (nonatomic, assign) long timeMillis;

- (id)initWithParameters:(int)glucoseId
                   andIw:(float)iw
                   andIb:(float)ib
                    andT:(float)t
                   andK0:(float)k0
                    andR:(float)r
           andTimeMillis:(long)timeMillis
                 andName:(NSString *)name;

- (id)initWithParameters:(int)glucoseId
                   andIw:(float)iw
                   andIb:(float)ib
                    andT:(float)t
                   andK0:(float)k0
                    andR:(float)r
           andTimeMillis:(long)timeMillis
     andNewBgToGlucoseId:(int)newBgToGlucoseId
           andNewBgValue:(int)newBgValue
                 andName:(NSString *)name;

- (id)initWithParameters:(int)glucoseId
                   andIw:(float)iw
                   andIb:(float)ib
                    andT:(float)t
                   andK0:(float)k0
                    andR:(float)r
                  andDay:(int)day
                 andHour:(int)hour
               andMinute:(int)minute
                 andName:(NSString *)name;

- (id)initWithParameters:(int)glucoseId
                   andIw:(float)iw
                   andIb:(float)ib
                    andT:(float)t
                   andK0:(float)k0
                    andR:(float)r
                  andDay:(int)day
                 andHour:(int)hour
               andMinute:(int)minute
     andNewBgToGlucoseId:(int)newBgToGlucoseId
           andNewBgValue:(int)newBgValue
                 andName:(NSString *)name;

- (void)setTimeMillisValue:(long)timeMillisValue;

- (void)setTransmitterName:(NSString *)name;

- (NSString *)toString;

@end

NS_ASSUME_NONNULL_END
