Files
redAcore/WatchdogCore.cpp
Charl Wentzel b900d735b9 Important update:
- Used new core protocol function to create command
- Bug fix: use correct sequence: From, To, Command
2017-07-08 22:39:32 +02:00

65 lines
1.5 KiB
C++

/*
* WatchdogCore.cpp
*
* Created on: July 2017
* Author: wentzelc
*/
// redA Libraries
#include "WatchdogCore.h"
#include "TimingCore.h"
// Standard C/C++ Libraries
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
//---------------------------------------------------------------------------
// Global vars
extern char * ProcessName;
//---------------------------------------------------------------------------
CWatchdogCore::CWatchdogCore( const char * WatchdogName, const int pInterval, CLogCore * pLog, EDebugLevel pDebugLevel ) :
CFunctionCore( WatchdogName, pLog, pDebugLevel, OUT_NORMAL )
{
// Create protocol
Protocol = new CLiteProtocol( 50, '\x01', '\x02', '\x00' );
Protocol->CreateCommand( ProcessName, WatchdogName, "ping" );
// Start timer
PingTimeout = 500;
SetStartTime( &PingTimer );
// Create Channel
Ping = AddChannel( "Ping" );
}
//---------------------------------------------------------------------------
CWatchdogCore::~CWatchdogCore()
{
// Destroy Protocol
if (Protocol)
delete Protocol;
}
//---------------------------------------------------------------------------
bool CWatchdogCore::Process()
{
if (Timeout( PingTimer, PingTimeout ))
{
// Send command
Output( Ping, Protocol->GetCommandStr(), Protocol->GetCommandLen() );
// Reset timer
SetStartTime( &PingTimer );
}
return false;
}
//---------------------------------------------------------------------------