//----------------------------------------------------
/**
	\file		maintick.c

	\brief		Funkce hlavniho ticku
				<<< ALL >>>

	\author		ConTeK s.r.o., Pavel Vavra, Jakub Kastner
	\version	01.01
	\date		24.5.2012
*/
//----------------------------------------------------

#include "maintick.h"
#include "gvariables.h"
#include "XmlVariables.h"
#include "pccomm.h"


#ifdef DBGMONITOR
  #include "appdebug.h"
#endif


//----------------------------------------------------
/**
	\brief		Funkce hlavního ticku
*/
//----------------------------------------------------

void MainTick(void)
{
	//! Tik ukladanim persistentnich dat
	ParamStoreTick(&gParCtxCtrl);

	//! komunikace
	PcCommTick();

#ifdef DBGMONITOR
	DebugTick();
#endif

	ThermoUpdateConstant( &gThermocouple, gParam.Pst.Conf.Temp.AmpfGain,
		gParam.Pst.Conf.Temp.mVoltOnC, gParam.Pst.Conf.Temp.AmpfOffset,
		gParam.Pst.Conf.Temp.FilterConstant, gParam.Pst.Conf.Temp.ThermoSens25,
		gParam.Pst.Conf.Temp.A0, gParam.Pst.Conf.Temp.A1, gParam.Pst.Conf.Temp.A2,
		gParam.Pst.Conf.Temp.A3, gParam.Pst.Conf.Temp.A4, gParam.Pst.Conf.Temp.A5,
		gParam.Pst.Conf.Temp.A6, gParam.Pst.Conf.Temp.A7, gParam.Pst.Conf.Temp.A8, 
		gParam.Pst.Conf.Temp.A9);

	LambdaUpdateConstant( &gLambda, gParam.Pst.Conf.Lambda.AmpfGain, 
		gParam.Pst.Conf.Lambda.AmpfOffset, gParam.Pst.Conf.Lambda.FilterConstant,
		gParam.Pst.Conf.Lambda.X1, gParam.Pst.Conf.Lambda.Y1,
		gParam.Pst.Conf.Lambda.X2, gParam.Pst.Conf.Lambda.Y2);

	PhotoUpdateConstant( &gPhoto, gParam.Pst.Conf.Photo.ResPower, gParam.Pst.Conf.Photo.FilterConstant,
		gParam.Pst.Conf.Photo.PhotoResLevel, gParam.Pst.Conf.Photo.PhotoTransLevel);


	//! mereni doby main ticku
	gParam.Debug.Timing.LastMainTickTime = (uint16_t)gTimeTickCtx.MainTickTime;
	gParam.Debug.Timing.MaxMainTickTime = (uint16_t)gTimeTickCtx.MainTickMaxTime;
}
