/* * WatchdogCore.cpp * * Created on: July 2017 * Author: wentzelc */ // redA Libraries #include "WatchdogCore.h" #include "TimingCore.h" // Standard C/C++ Libraries #include #include #include #include #include //--------------------------------------------------------------------------- // Global vars extern char * ProcessName; //--------------------------------------------------------------------------- CWatchdogCore::CWatchdogCore( const char * pName, CSelect * pSelect, CLogCore * pLog ) : CSelectableCore( pName, pSelect, pLog ) { // Create protocol Protocol = new CLiteProtocol( 50, '\x01', '\x02', '\x00' ); Protocol->CreateCommand( ProcessName, pName, "ping" ); // Start timer PingInterval = 500; SetStartTime( &PingTimer ); // Create handle Ping = CreateHandle( "Ping", true ); } //--------------------------------------------------------------------------- CWatchdogCore::~CWatchdogCore() { // Destroy Protocol if (Protocol) delete Protocol; } //--------------------------------------------------------------------------- bool CWatchdogCore::SetInterval( int pPingInterval ) { PingInterval = pPingInterval; return true; } //--------------------------------------------------------------------------- bool CWatchdogCore::Process() { if (Timeout( PingTimer, PingInterval )) { // Send command Input( Ping->Name, Protocol->GetCommandStr(), Protocol->GetCommandLen() ); // Reset timer SetStartTime( &PingTimer ); } return false; } //---------------------------------------------------------------------------