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

@@ -23,16 +23,25 @@
//---------------------------------------------------------------------------
// Preview
typedef struct SFunctionItem TFunctionItem;
typedef struct SFunctionType TFunctionType;
typedef struct SFunctionItem TFunctionItem;
typedef CFunctionCore * (*FFuncConstructor)( const char * Name );
class Application;
//---------------------------------------------------------------------------
struct SFunctionType {
char * Name;
FFuncConstructor Constructor;
TFunctionType * Next;
};
//---------------------------------------------------------------------------
struct SFunctionItem
{
CFunctionCore * Function;
SFunctionItem * Next;
};
//---------------------------------------------------------------------------
@@ -42,50 +51,54 @@ class CApplication
protected:
// Variables used for configuration
char * ConfigFile;
char * DefinitionFile;
char * AddressFile;
// Configuration
CDataMember * DataTree;
CJSONparse * JSONparser = NULL;
// List
TFunctionType * FirstFunctionType;
TFunctionItem * FirstFunction;
// Output
EDebugLevel LogLevel;
int LogOutput;
// Configuration
CDataMember * ConfigMember;
CDataMember * FunctionConfigMember;
CDataMember * LinkConfigMember;
bool LoadConfigData();
public:
// Public function vars
CDataMember * DataTree;
CLogCore * Log;
CSelect * Selector;
CJSONparse * JSONparser = NULL;
// Configuration
CDataMember * Config;
CDataMember * Definition;
CDataMember * AddressList;
// Life Cycle
CApplication( EDebugLevel pDebugLevel );
virtual ~CApplication();
// Manage Config File
bool ReadParam( int argc, char *argv[] );
void GetProcessName( char ** ProcessName, char * pFilePath );
bool LoadConfig( int argc, char *argv[], const char * pConfigPath );
bool LoadConfig();
bool SaveConfig();
// Manually set configuration
bool SetLogParam( EDebugLevel pDebugLevel, int pOutputDisplay );
// Init application
virtual bool Init();
bool InitConfig( const char * pConfigPath );
bool InitFunctions( const char * pConfigPath );
bool InitFunctionLinks( const char * pConfigPath );
bool InitApplication();
bool InitFunctions();
bool InitFunction( CFunctionCore * Function );
bool InitFunctionLinks();
// Manage Functions
bool AddFunction( CFunctionCore * Function );
bool AddFunctionType( const char * Type, FFuncConstructor Constructor );
CFunctionCore * AddFunction( const char * Type, const char * Name );
CFunctionCore * GetFunction( const char * Name );
// Run Application