Test
Dependencies: mbed-dev-OS5_10_4
Diff: MySources/LoopTimer.cpp
- Revision:
- 0:014fad4dfb9d
diff -r 000000000000 -r 014fad4dfb9d MySources/LoopTimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MySources/LoopTimer.cpp Fri Aug 07 07:24:21 2020 +0000 @@ -0,0 +1,128 @@ +/*------------------------------------------------------------------------------- +Programm Name: LoopTimer.cpp +Version: 1.0 +Sprache: C++ +Compiler: mbed +Autor: PS +Copyright: PS + + +Funktion: Main Funktionen +04.08.2016: Projekt: RpaAnalyse +-------------------------------------------------------------------------------*/ +#include "Headers.h" + + + +Ticker flipper; // Timerinterrupt +// Variablen, die in Interruptroutinen verwendet werden +volatile int nMyTimer; +int ZustandsTimer; +int g_nSendDisableTimer; +int g_nTftTimer; // wird vor allem fuer das Abfragen der Uhr genommen + + +/*------------------------------------------------------------------------------- +Interrupt Funktion. Wird auf 1ms gesetzt +-------------------------------------------------------------------------------*/ +void flip() +{ + nMyTimer++; +} +/*------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------*/ +void DetachMyTicker() +{ + flipper.detach(); + g_fTimerIsRunning = false; +} +/*------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------*/ +void AttachMyTicker() +{ +#ifdef SEND_DEBUG_TO_HOST + sprintf(HostIf.strTempBuf, "%c#DG#Attach Ticker%c",STX, ETX); + SendTelToHost(false, false, false); +#endif + + flipper.attach_us(&flip, 1000); // setup flipper to call flip after 1000 us + nMyTimer = 0; + MVars.nMittelTimer = 0; + MVars.nSendTimer = 0; + g_fTimerIsRunning = true; + g_nSendDisableTimer = 0; +} +/*------------------------------------------------------------------------------- +SetTimerInterrupt: +-------------------------------------------------------------------------------*/ +void SetTimerInterrupt(int Flag) +{ + if(Flag == 0) // ausschalten + { + if(g_fTimerIsRunning == true) + { + DetachMyTicker(); + } + } + else + { + if(g_fTimerIsRunning == false) + { + AttachMyTicker(); + } + } +} +/*------------------------------------------------------------------------------- + Funktion CheckTimerHandlingAndScanner: prüft ob Messdaten reinkommen +-------------------------------------------------------------------------------*/ +int CheckTimerHandlingAndScanner() +{ + MVars.nMittelTimer++; + MVars.nSendTimer++; +// nScreenSaverTimer++; // 2017-02-02 UFa: Timer ScreenSaver + ZustandsTimer++; + nMyTimer--; + g_nTftTimer++; + if(g_nSendDisableTimer > 0) g_nSendDisableTimer--; + + if(MVars.nSendTimer >=500) + { +// g_fDoCheckIRange = true; + MVars.nSendTimer = 0; + } + +// Der SAetGenValues wäre für RPA nicht notwendig, wenn m_fScan aber auf false +// bleibt, dann sollte das kein Problem sein +#ifndef PGU_RPA + if(MVars.m_fScan == true) // wenn true, dann wird gescannt + SetGenValues(); +#endif + return(true); +} +/*------------------------------------------------------------------------------- + Funktion RequestDateTime +-------------------------------------------------------------------------------*/ +int RequestDateTime() +{ +#ifdef USE_RTC +// Uhrzeit //UFa Timer + if(m_fTimeAlternate == true) + { + if(g_fDisableTimeRead == false) + { + seconds = time(NULL); + MyTm = localtime(&seconds); // seconds = time(NULL); vorher + sprintf(DtTime.cTimeBuffer,"%02d:%02d:%02d", MyTm->tm_hour, MyTm->tm_min,MyTm->tm_sec); + sprintf(DtTime.cDateBuffer,"%04d:%02d:%02d", MyTm->tm_year + 1900, MyTm->tm_mon +1 , MyTm->tm_mday); + m_fTimeAlternate = false; + } + } + else + m_fTimeAlternate = true; +#endif + return(true); +} + + \ No newline at end of file