Major Update:
- JSONparseCore:
- Add initialisations values for class params
- Add method AddBase() to dynamically change DataTree
- Added Error messages
- DeviceCore:
- Implement ValueTree (JSON tree)
- Node are added as devices & params are created/added
- Nodes (and path) are referenced on devices & params
- Node values are updated as device params are updated
- Added Persistence File (not yet complete)
- Updated InitDevices() & InitDeviceParams()
- Split into smaller methods: CopyTemplateParam() & InitDeviceParam()
- Load Device definition or Parameter maps from files
- Allow loading of nested parameter map files
- Load Parameter as JSON tree, generate names/path dynamically
This commit is contained in:
@@ -15,31 +15,16 @@
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
CJSONparse::CJSONparse()
|
||||
{
|
||||
SetBase( NULL );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
CJSONparse::CJSONparse( CDataMember * pDataTree )
|
||||
{
|
||||
// Object tree
|
||||
DataTree = pDataTree;
|
||||
|
||||
// File Operation
|
||||
InputHandle = -1;
|
||||
OutputHandle = -1;
|
||||
|
||||
Buffer = NULL;
|
||||
|
||||
// Parsing operation
|
||||
BufPos = NULL;
|
||||
Mark = NULL;
|
||||
LineNo = 0;
|
||||
CharNo = 0;
|
||||
RefillBuffer = false;
|
||||
|
||||
// Printing operation
|
||||
Spacer[0] = 0;
|
||||
SpacerLen = 0;
|
||||
|
||||
// Error reporting
|
||||
Error = false;
|
||||
ErrorText[0] = 0;
|
||||
if (!SetBase( pDataTree ))
|
||||
DataTree = NULL;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -52,6 +37,18 @@ CJSONparse::~CJSONparse()
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool CJSONparse::SetBase( CDataMember * Object )
|
||||
{
|
||||
// Validate
|
||||
if (Object && !Object->isObject() && !Object->isNull())
|
||||
return false;
|
||||
|
||||
// Set
|
||||
DataTree = Object;
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool CJSONparse::WriteToScreen( const char * BasePath, const int Indent )
|
||||
{
|
||||
// Print to screen
|
||||
@@ -124,6 +121,8 @@ bool CJSONparse::WriteToHandle( const char * BasePath, const int Handle, const i
|
||||
|
||||
// Validate
|
||||
if (!DataTree) {
|
||||
Error = true;
|
||||
sprintf( ErrorText, "No Data Tree set" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,11 +186,6 @@ bool CJSONparse::ReadFromFile( const char * BasePath, const char * FilePath )
|
||||
int Handle = -1;
|
||||
bool result = false;
|
||||
|
||||
// Validate
|
||||
if (!DataTree) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear Error
|
||||
Error = false;
|
||||
|
||||
@@ -283,7 +277,14 @@ bool CJSONparse::ReadFromBuffer( const char * BasePath )
|
||||
CDataMember * BaseMember = NULL;
|
||||
|
||||
// Validate
|
||||
if (!DataTree || !Buffer) {
|
||||
if (!DataTree) {
|
||||
Error = true;
|
||||
sprintf( ErrorText, "No Data Tree set" );
|
||||
return false;
|
||||
}
|
||||
if (!Buffer) {
|
||||
Error = true;
|
||||
sprintf( ErrorText, "No Data Buffer defined" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user