/*
 * usr_gpio.h
 *
 *  Created on: 2022��4��11��
 *      Author: amos
 */

#ifndef USR_LYSIS_H_
#define USR_LYSIS_H_

#include "van_com_algorithm.h"
/*************************************/

#define TUPE_OPTIC_PORT PF//光开
#define TUPE_OPTIC_PIN  BIT5//光开
#define TUPE_OPTIC_INT_CH  5//光开
#define TUPE_OPTIC()  (PF5)  //按键

#define HEAT_UP_CH_MASK PWM_CH_4_MASK 
#define HEAT_UP_CH	4
#define COOL_DOWN_CH_MASK PWM_CH_5_MASK 
#define COOL_DOWN_CH	5 

#define MOTOR_CHECK_SPEED	60
#define MOTOR_MOVEFORM_OPTIC_TIM	10
#define MOTOR_LOOP_TIM	100

#define MOTOR_SWING_TIM	100

typedef enum {
	HEAT_UP = 0,
	COOL_DOWN = 1,
}HEAT_DIR;


typedef enum Heat_state {
  PID_IDLE,
  PID_OVERHEAT,
  PID_OVERHEATLAST,
  PID_OVERCOOL,
  PID_OVERCOOLLAST,
  PID_ADJ,
  PID_STAB,
  PID_ERROR,
} pid_state_def;

typedef enum {
  THERMOSTAT_NOR,     // 正常
  THERMOSTAT_COOL_EER,    //制冷坏
  THERMOSTAT_HEAT_EER, // 加热坏
  THERMOSTAT_SENSER_EER,     // 传感器坏
  THERMOSTAT_TUBEEXIST_EER,     //存在试管
  THERMOSTAT_TUBENOEXIST_EER,     //不存在试管
} THERMOSTAT_ERR_State;



typedef enum THERMO_state {
  THERMOSTAT_PWRON,
  THERMOSTAT_CHECK,
  THERMOSTAT_WARM,
  THERMOSTAT_IDLE,
  THERMOSTAT_INSERT,
  THERMOSTAT_NOTICE,
  THERMOSTAT_WORK,
  THERMOSTAT_END,
  THERMOSTAT_ERROR,
} thermostat_state_def;


typedef struct
{
	float offset;               
    float overHeat;       
    float overHeatTime;          
    float overCool;       
    float overCoolTime;       
    float idletemp;  	      
    float worktime;  		     
    pid_def  pid;	
	unsigned int pwdId;
    float cabinTem;    
	pid_state_def pid_st; 
	unsigned int pid_stable;   
	unsigned int pid_stable_time;   
	thermostat_state_def thermostat_st;
	THERMOSTAT_ERR_State eerst;
  unsigned int recGoalFlag;
  unsigned int firstin;
}lysis_ctr_def;

void updatParm_lysis(void);
void set_lysis(float goal) ;
uint32_t lysis_work(void);
uint32_t Close_lysis_work(void);
uint32_t get_lysis_st(float *temp,unsigned int *st);
/***********************************/
#endif /* USR_HEATER_H_ */
