- 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
138 lines
4.0 KiB
C++
138 lines
4.0 KiB
C++
/*
|
|
* FunctionCore.h
|
|
*
|
|
* Created on: 18 May 2016
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
#ifndef REDACORE_FUNCTIONCORE_H_
|
|
#define REDACORE_FUNCTIONCORE_H_
|
|
|
|
// redA Libraries
|
|
#include "LogCore.h"
|
|
#include "BufferCore.h"
|
|
#include "DataTreeCore.h"
|
|
|
|
// Standard C/C++ Libraries
|
|
#include <string.h>
|
|
#include <sys/time.h>
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Preview
|
|
typedef struct SChannel TChannel;
|
|
typedef struct SChannelLink TChannelLink;
|
|
|
|
class CFunctionCore;
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
struct SChannel
|
|
{
|
|
char * Name;
|
|
|
|
TChannelLink * FirstInput;
|
|
TChannelLink * FirstOutput;
|
|
|
|
bool InputEnabled;
|
|
bool OutputEnabled;
|
|
|
|
TChannel * Next;
|
|
};
|
|
//---------------------------------------------------------------------------
|
|
|
|
struct SChannelLink
|
|
{
|
|
CFunctionCore * Function;
|
|
char * Name;
|
|
|
|
SChannelLink * Next;
|
|
};
|
|
//---------------------------------------------------------------------------
|
|
|
|
class CFunctionCore
|
|
{
|
|
protected:
|
|
// Function Definition
|
|
char * Name;
|
|
|
|
// Configuration
|
|
CDataTree * DataTree;
|
|
TDataMember * BaseMember;
|
|
|
|
// Channels
|
|
TChannel * FirstChannel;
|
|
|
|
// Output
|
|
CLogCore * Log;
|
|
EDebugLevel LogLevel;
|
|
int LogOutput;
|
|
|
|
// Manage Channel
|
|
inline TChannel * GetChannel( const char * Name ) {
|
|
if (!Name) return NULL;
|
|
TChannel * Channel = FirstChannel;
|
|
while (Channel && strcmp( Name, Channel->Name ))
|
|
Channel = Channel->Next;
|
|
return Channel;
|
|
}
|
|
|
|
// Load configuraiton
|
|
virtual bool LoadConfigData();
|
|
|
|
// Manual Data Input/Output
|
|
virtual int Output( const TChannel * Channel, const char * Data, int Len );
|
|
|
|
public:
|
|
// Life cycle
|
|
CFunctionCore( const char * pName, CLogCore * pLog );
|
|
virtual ~CFunctionCore();
|
|
|
|
// Load Configuration
|
|
virtual bool LoadConfig( CDataTree * pDataTree, const char * pBasePath );
|
|
virtual bool LoadConfig( CDataTree * pDataTree, TDataMember * pBaseMember );
|
|
|
|
// Set Parameters Manually
|
|
bool InitLogging( EDebugLevel pDebugLevel, int pOutputDisplay );
|
|
bool SetDebugLevel( EDebugLevel pDebugLevel );
|
|
|
|
// Miscellaneous
|
|
inline const char * GetName() { return Name; };
|
|
|
|
// Manage Channels
|
|
virtual TChannel * AddChannel( const char * ChannelName, const bool pInputEnable = true, const bool pOutputEnabled = true );
|
|
inline bool SetChannelOutEnable( const char * ChannelName, const bool pOutputEnable ) {
|
|
TChannel * Channel = GetChannel( ChannelName );
|
|
if (!Channel) return false;
|
|
Channel->OutputEnabled = pOutputEnable;
|
|
return true;
|
|
}
|
|
inline bool SetChannelInEnable( const char * ChannelName, const bool pInputEnable ) {
|
|
TChannel * Channel = GetChannel( ChannelName );
|
|
if (!Channel) return false;
|
|
Channel->InputEnabled = pInputEnable;
|
|
return true;
|
|
}
|
|
inline bool isInputEnabled( const char * ChannelName ) {
|
|
TChannel * Channel = GetChannel( ChannelName );
|
|
return ((Channel)? Channel->InputEnabled : false);
|
|
}
|
|
inline bool isOutputEnabled( const char * ChannelName ) {
|
|
TChannel * Channel = GetChannel( ChannelName );
|
|
return ((Channel)? Channel->OutputEnabled : false);
|
|
}
|
|
|
|
// Manual Data Input/Output
|
|
virtual int Input( const char * ChannelName, const char * Data, int MaxLen = -1 );
|
|
virtual int Output( const char * ChannelName, const char * Data, int Len = -1 );
|
|
|
|
// Automated Data Input/Output
|
|
virtual bool LinkInputChannel( const char * ChannelName, CFunctionCore * OutFunction, const char * OutChannelName, bool Bidirectional );
|
|
virtual bool LinkOutputChannel( const char * ChannelName, CFunctionCore * InFunction, const char * InChannelName, bool Bidirectional );
|
|
virtual bool Process() = 0;
|
|
};
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif /* REDACORE_FUNCTIONCORE_H_ */
|