/*
 * APP_TimingTasks.c
 *
 *  Created on: 2020年5月25日
 *      Author: LuoXF
 */

#include "Allinclusions.h"




void LogReporting(void* pSysInfo)
{

}


void TimingTaskRegis(tSysCtrl* pSysCtrl,tTimingTasks* pTimingTasks,UINT8 TasksNum)
{
    tTimingTasks* TimingTasks = pTimingTasks;
    tSysCtrl*     SysCtrl     = pSysCtrl;

    SysCtrl->SysFonc.TimingTasks[TasksNum].Func              = TimingTasks->Func;
    SysCtrl->SysFonc.TimingTasks[TasksNum].ulTimingSaveTime  = TimingTasks->ulTimingSaveTime;
    SysCtrl->SysFonc.TimingTasks[TasksNum].ulTimingTime      = TimingTasks->ulTimingTime;
}

void TimingTaskInit()
{
    tTimingTasks TimingTasks;

//    TimingTasks.Func             = &CollectCurrentDevStatus;
//    TimingTasks.ulTimingTime     = 50;
//    TimingTasks.ulTimingSaveTime = 0;
//    TimingTaskRegis(&SysInfo,&TimingTasks,0);
//
//    TimingTasks.Func             = &LogReporting;
//    TimingTasks.ulTimingTime     = 1000;
//    TimingTasks.ulTimingSaveTime = 0;
//    TimingTaskRegis(&SysInfo,&TimingTasks,1);
}

void TimingTasks(tSysCtrl* pSysCtrl)
{
    UINT8 ucNum         = 0;
    tSysTime* SysTime   = &pSysCtrl->SysTime;
    tSysFonc* SysFonc   = &pSysCtrl->SysFonc;

    for(ucNum=0;ucNum<TIMINGTASKSNUM;ucNum++)
    {
        if( SysTime->GetSysTime() >= SysFonc->TimingTasks[ucNum].ulTimingSaveTime)
        {
            SysFonc->TimingTasks[ucNum].Func(pSysCtrl);
            SysFonc->TimingTasks[ucNum].ulTimingSaveTime = SysTime->GetSysTime() + SysFonc->TimingTasks[ucNum].ulTimingTime;
        }
    }
}
