- DataTreeCore:
- Bug fix: GetMember() error if member not found
- FunctionCore: (affected: SelectableCore, FileCore, WatchdogCore)
- Made destructor virual
- Standardize method parameter naming, e.g. pName, pLog
- Renamed parameters: DebugLevel -> LogLevel, OutputDisplay -> LogOutput
- Reinstated parameter BaseMember
- Removed logging parameters from constructor
- Created method InitLoggging() (shows "Function Created" message)
- Split LoadConfig() method into parts:
- Implemented public LoadConfig() methods
- Implemented LoadConfigData() method, load parameters from DataTree
- WatchdogCore:
- Derive from CSelectableCore instead of CFunctionCore
- Rename parameter: PingTimeout -> PingInterval
- Replace Ping Channel with Handle only
- Add method SetInterval()
- Send command direct to handle with (channel) Input()
- SelectableCore:
- Rename parameters: Auto -> AutoManage, ReopenTimeout -> ReopenDelay
- Implemented own virtual LoadConfigData() method
- DeviceCore:
- Made all logging conditional: if (Log) Log->Message(...)
- SelectCore:
- Renamed parameters: DebugLevel -> LogLevel
72 lines
1.7 KiB
C++
72 lines
1.7 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 * 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;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|