reflow/oven_control.h

140 lines
3.0 KiB
C++

#ifndef _H_OVEN_CTL
#define _H_OVEN_CTL
/*
// operational states
#define OP_CONFIG 0
#define OP_STAND_ALONE 1
#define OP_REMOTE 2*/
enum OP_STATE {
OP_CONFIG,
OP_STAND_ALONE,
OP_REMOTE
};
#define E_DT_MIN 1 // temperature dt too small
#define E_DT_MAX 2 // temperature dt too big
#define E_TIME_MAX 4 // reflow process does take too long
#define E_TS_TOO_SHORT 8 // Ts duration too short
#define E_TS_TOO_LONG 16 // Ts duration too long
#define E_TL_TOO_SHORT 32 // Tl duration too short
#define E_TL_TOO_LONG 64 // Tl duration too long
#define E_TP_TOO_SHORT 128 // Tp duration too short
#define E_TP_TOO_LONG 256 // Tp duration too long
#define E_CONFIG 512 // error happened in config state
// profile states
enum PROFILE_STATE {
START_STATE,
PREHEAT_STATE,
RAMP_UP_STATE,
TAL_FIRST_STATE,
PEAK_STATE,
TAL_SECOND_STATE,
RAMP_DOWN_STATE,
END_STATE,
ERROR_STATE
};
#include <Arduino.h>
class LiquidCrystal;
class DFR_Key;
class Profile;
extern Profile profile;
class OvenCtl {
public:
OvenCtl();
void loop();
// void set_config_state();
private:
// system time, timestamps and temperatures from sensors
int time; // profile seconds
int temperature; // actual oven temp
int last_temperature; // last oven temp
float actual_dt; // actual difference from last to actual temperatur
// timestamps of event beginnings/ends
int Ts_time_start;
int Ts_time_end;
int Tl_time_start;
int Tl_time_end;
int Tp_time_start;
int Tp_time_end;
// thermostat
float set_min;
float set_max;
int set_dt_min;
int set_dt_max;
float ramp_up_hysteresis; // duration in seconds
float ramp_down_hysteresis; // duration in seconds
float actual_hysteresis; // duration in seconds
// ui stuff
boolean disable_checks;
// state machine
unsigned int error_condition;
OP_STATE op_state;
PROFILE_STATE profile_state;
boolean is_oven_heating;
void print_status();
void control_oven();
void set_temp(int, int, int, int);
void get_temp();
void check_dt();
void check_max_duration();
// void set_start_state();
// void set_preheat_state();
// void set_tal_first_state();
// void set_ramp_up_state();
// void set_peak_state();
// void set_tal_second_state();
// void set_ramp_down_state();
// void set_end_state();
// void set_error_state();
// void handle_profile_states();
void handle_stand_alone_state();
void handle_remote_state();
// void handle_config_state();
// void handle_start_state();
// void handle_ramp_up_state();
// void handle_preheat_state();
// void handle_tal_first_state();
// void handle_peak_state();
// void handle_tal_second_state();
// void handle_ramp_down_state();
// void handle_end_state();
// void handle_error_state();
// void check_Ts_duration_min();
// void check_Ts_duration_max();
// void check_Tl_duration_min();
// void check_Tl_duration_max();
// void check_Tp_duration_min();
// void check_Tp_duration_max();
void send_state();
void send_config();
void reset();
void recv_config();
void dispatch_input_config(int);
};
#endif