- Implement new ApplicationCore:
- Manage Tools: Log, DataTree, JSONparser & Selector
- Load configuration, Manage FunctionBlocks
- FunctionCore & dirived classes, SignalCore:
- affects: SelectableCore, DeviceCore, FileCore, WatchdogCore
- Do not pass Log()
- Define and pass Type
- Update/reduce included headers
- Use ProcessName and Application global vars
- Get Log, DataTree from Application
- Use virtual Init() function to set must have Channels/Handles
- DataTreeCore:
- Bug fix: Check if child members exist and destroy in SetValuePtr()
- Add method GetFirstChild with BaseMember & Path
- Bug fix: do not use RootMember if no Parent in GetChildxxx() methods
- SignalCore, SelectCore:
- Use Application->Log()
- FunctionCore:
- Add itself to Application (function list)
- Add parameter: LinkConfigMember, Type
- Use virtual LoadConfigData() to configure from DataTree
- Rename methods: LoadConfig() -> InitConfig(),
InitLogging() -> SetLogParam(), SetDebugLevel() -> SetLogLevel()
- Add method: GetType(), LoadChannelLinkData(), InitChannelLinks()
- Modify LinkIn/OutputChannel() to use name for InFunction, not pointer
- SelectableCore & Dirived classes:
- Affects DeviceCore & WatchdogClient
- Rename parameter: Select -> Selector, BaseMember -> ConfigMember
- Get Selector from Application->Selector
- Change Handles JSON structure from Array to Key:Value pairs
- Bug fix: check if Selector exist during Input()
- Bug fix: do not set PortNo if not exist
100 lines
2.3 KiB
C++
100 lines
2.3 KiB
C++
/*
|
|
* Application.h
|
|
*
|
|
* Created on: 13 Jul 2017
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
#ifndef REDACORE_APPLICATIONCORE_H_
|
|
#define REDACORE_APPLICATIONCORE_H_
|
|
|
|
// redA Libraries
|
|
#include "SignalCore.h"
|
|
#include "TimingCore.h"
|
|
#include "LogCore.h"
|
|
#include "DataTreeCore.h"
|
|
#include "JSONparseCore.h"
|
|
#include "FunctionCore.h"
|
|
#include "SelectableCore.h"
|
|
|
|
// Standard C/C++ Libraries
|
|
#include <string.h>
|
|
#include <sys/time.h>
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Preview
|
|
typedef struct SFunctionItem TFunctionItem;
|
|
|
|
class Application;
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
struct SFunctionItem
|
|
{
|
|
CFunctionCore * Function;
|
|
|
|
SFunctionItem * Next;
|
|
};
|
|
//---------------------------------------------------------------------------
|
|
|
|
class CApplication
|
|
{
|
|
protected:
|
|
// Variables used for configuration
|
|
char * ConfigFile;
|
|
char * AddressFile;
|
|
|
|
// List
|
|
TFunctionItem * FirstFunction;
|
|
|
|
// Configuration
|
|
CJSONparse * ConfigParser = NULL;
|
|
|
|
// Output
|
|
EDebugLevel LogLevel;
|
|
int LogOutput;
|
|
|
|
// Configuration
|
|
TDataMember * ConfigMember;
|
|
TDataMember * FunctionConfigMember;
|
|
TDataMember * LinkConfigMember;
|
|
|
|
bool LoadConfigData();
|
|
|
|
public:
|
|
// Public function vars
|
|
CDataTree * DataTree;
|
|
CLogCore * Log;
|
|
CSelect * Selector;
|
|
|
|
// Life Cycle
|
|
CApplication( EDebugLevel pDebugLevel );
|
|
virtual ~CApplication();
|
|
|
|
// Manage Config File
|
|
void GetProcessName( char ** ProcessName, char * pFilePath );
|
|
bool LoadConfig( int argc, char *argv[], const char * pConfigPath );
|
|
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 );
|
|
|
|
// Manage Functions
|
|
bool AddFunction( CFunctionCore * Function );
|
|
CFunctionCore * GetFunction( const char * Name );
|
|
|
|
// Run Application
|
|
bool Run();
|
|
};
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif /* REDACORE_APPLICATIONCORE_H_ */
|