Files
redAcore/FunctionCore.h
Charl Wentzel 47577e9f4c Major Updated:
- Added new CDeviceCore Class
  - Methods and structures moved from CModbusInterface
  - Keep track of Devices and DeviceParameters
  - Provides methods & parameters related to polling process
  - Provides parameter events
2016-09-07 08:49:58 +02:00

99 lines
2.5 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"
// 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;
TChannel * Next;
};
//---------------------------------------------------------------------------
struct SChannelLink
{
CFunctionCore * Function;
char * Name;
SChannelLink * Next;
};
//---------------------------------------------------------------------------
class CFunctionCore
{
protected:
// Function Definition
char * Name;
// Channels
TChannel * FirstChannel;
// Output
CLogCore * Log;
EDebugLevel DebugLevel;
int OutputDisplay;
// Manage Channel
inline TChannel * GetChannel( const char * Name ) {
TChannel * Channel = FirstChannel;
while (Channel && strcmp( Name, Channel->Name )) {
Channel = Channel->Next;
}
return Channel;
}
// Manual Data Input/Output
virtual int Output( const TChannel * Channel, const char * Data, int Len );
public:
// Life cycle
CFunctionCore( const char * FunctionName, CLogCore * pLog, EDebugLevel pDebugLevel, int pOuputDisplay );
virtual ~CFunctionCore();
// Miscellaneous
inline const char * GetName() { return Name; };
// Manage Channels
virtual TChannel * AddChannel( const char * ChannelName );
// 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_ */