Major Update:

- Implement consistent Function addition to application
  - Use TYPE_XXX constants to declare function type
  - Use NewXXXX() methods to call constructor correctly
  - Add FunctionType list (with constructor) to Application
  - Create Function by comparison to FunctionType list
- Simplify LoadConfig() and Init() methods for functions
  - Combine methods into Init() method
  - Pass relevant data member to Init() method
  - Remove all CDataMember references on functions
- ApplicationCore:
  - Split ReadParam() method from LoadConfig() method
  - Split main configuration into separate files:
    - config/ - main config file, general application settings
    - definition/ - application definition, e.g. function blocks
  - Definition and Address List files specified in config file
  - Load address file in address/ branch
  - Made DataTree & JSONparser private
  - Made Config, Definition & Address branches public
  - Removed unnecessary branch references
  - Improved event logging
- DataTreeCore:
  - Allow GetChFirstChild & GetChElement to create parent branches
    with correct type, ie. Object/Array
  - Remove unnecessary Create param from GetXxx functions
  - Bug fix: Print empty objects/arrays correct, ie. empty brackets
  - Bug fix: Adding element at specific index
  - Bug fix: Error when get/create string value with "null"
- FunctionCore:
  - Type param now set as constant via constructor
  - Create empty Handles & Channels objects if none in Config
- SelectableCore:
  - Add Queue length parameter to handles for UNIX and TCP sockets
- DeviceCore:
  - Bug fix: missing Process() method
This commit is contained in:
Charl Wentzel
2018-11-24 13:35:23 +02:00
parent 7434334280
commit a972fb9101
15 changed files with 518 additions and 469 deletions

View File

@@ -48,20 +48,21 @@ struct SChannelLink
};
//---------------------------------------------------------------------------
// Function Constructor
#define TYPE_FUNCTION "Function"
//CFunctionCore * NewFunctionCore( const char * Name );
//---------------------------------------------------------------------------
class CFunctionCore
{
protected:
// Function Definition
char * Name;
char * Type;
// Configuration
CDataMember * DataTree;
CDataMember * ConfigMember;
CDataMember * LinkConfigMember;
const char * Type;
char * Name;
// Channels
TChannel * FirstChannel;
TChannel * FirstChannel;
// Logging
CLogCore * Log;
@@ -73,35 +74,26 @@ protected:
int StoredOutputLen;
// Manage Channel
inline TChannel * GetChannel( const char * Name ) {
if (!Name) return NULL;
inline TChannel * GetChannel( const char * pName ) {
if (!pName) return NULL;
TChannel * Channel = FirstChannel;
while (Channel && strcmp( Name, Channel->Name ))
while (Channel && strcmp( pName, Channel->Name ))
Channel = Channel->Next;
return Channel;
}
// Load configuration
virtual bool LoadConfigData();
virtual bool LoadChannelLinkData();
// Data Input/Output
virtual int Output( const TChannel * Channel, const char * Data, int Len );
virtual bool PullInput( TChannel * Channel );
public:
// Life cycle
CFunctionCore( const char * pName, const char * Type );
CFunctionCore( const char * pName, const char * pType = TYPE_FUNCTION );
virtual ~CFunctionCore();
// Load Configuration
virtual bool Init();
bool InitConfig( const char * pConfigPath );
bool InitConfig( CDataMember * pConfigMember );
bool InitChannelLinks( const char * pLinkConfigPath );
bool InitChannelLinks( CDataMember *pLinkConfigMember );
virtual bool Init( CDataMember * FunctionConfig );
virtual bool InitChannelLinks( CDataMember *LinkConfig );
// Set Parameters Manually
bool SetLogParam( EDebugLevel pDebugLevel, int pOutputDisplay );