/****************************************************************************
 Title	:	TERMINAL FOR VISUALIZATION AND CONTROL CONDITIONS IN HOUSE
 Author	:	Patrik Szalay <xszala01@stud.feec.vutbr.cz>
 File	:	regulation.h
 Software:	CodeWarrior Development Studio Version: 10.6 Build Id:140329
 Target	:	MC9S08LH64
*****************************************************************************/

#ifndef REGULATION_H_
#define REGULATION_H_

#include <hidef.h>
#include "derivative.h"
#include "IO.h" 
#include "clock.h"
#include "temp_meas.h"

extern byte pumpDelayTime;
extern int pumpDelayTimer;
extern bool pumpEnable, pumpDelayEnable;
#define maxWaterTempHyst 1000
#define NOT_MEASURED_VALUE 999996
#define DAY 1
#define NIGHT 2

#define ROOMTEMP_MIN 500
#define ROOMTEMP_MAX 3000
#define ROOMTEMP_STEP 50
#define ROOMTEMP_HYST_MAX	200
#define ROOMTEMP_HYST_MIN	20
#define ROOMTEMP_HYST_STEP	20

#define WATER_MIN	4000
#define WATER_MAX	9500
#define WATER_STEP	500

#define WATER_DIFF_MIN	1000
#define WATER_DIFF_MAX	3000
#define WATER_DIFF_STEP	500

#define PUMP_TIME_MIN	1
#define PUMP_TIME_MAX	20
#define PUMP_TIME_STEP	1

#define AUTOSW_MIN	1000
#define AUTOSW_MAX	2500
#define AUTOSW_STEP	100

void InitAverages(void);

decimal getRoom_Temp(void);
void setRoom_Temp(decimal value);

decimal getOutDoor_Temp(void);
void setOutDoor_Temp(decimal value);

decimal getOutDoor_Hum(void);
void setOutDoor_Hum(decimal value);

decimal getWater_Out_Temp(void);
void setWater_Out_Temp(decimal value);

decimal getWater_Return_Temp(void);
void setWater_Return_Temp(decimal value);

decimal getRegulateToTemp(void);

decimal getRegulateToDayTemp(void);
void setRegulateToDayTemp(decimal value);

decimal getRegulateToNightTemp(void);
void setRegulateToNightTemp(decimal value);

decimal getRegulateToMaxWaterTemp(void);
void setRegulateToMaxWaterTemp(decimal value);

decimal getRegulationHyst(void);
void setRegulationHyst(decimal value);

decimal getWaterDiff(void);
void setWaterDiff(decimal value);

decimal getWaterDiffHyst(void);
void setWaterDiffHyst(decimal value);

byte getPumpDelayTime(void);
void setPumpDelayTime(byte value);

bool getHeater_State(void);
void setHeater_State(bool state);

bool getPump_State(void);
void setPump_State(bool state);

void setAverageTemp(void);
decimal getAverageTemp(void);
void setAVGTemp(decimal value);

int getDayTempStart(void);
void setDayTempStart(int value);

int getDayTempEnd(void);
void setDayTempEnd(int value);

bool getSystType(void);
void setSystType(bool value);

decimal getOnAverageTemp(void);
void setOnAverageTemp(decimal value);

decimal getOffAverageTemp(void);
void setOffAverageTemp(decimal value);

bool getAutoSwitchingState(void);
void setAutoSwitchingState(bool value);

void setRegulateToTemp(void);

byte getDayState(void);
void setHeating(void);


void Thermostat(void);



#endif /* REGULATION_H_ */
