Important Update:
- Save reference to process config in Function Core
- Moved from DeviceCore to here as common feature
- "Config" : object
Allow additional config to be stored in application definition
- "Config" : string
Name reference to config object in main JSON file
- Remove from Device Core
This commit is contained in:
@@ -69,7 +69,6 @@ CDeviceCore::~CDeviceCore()
|
|||||||
bool CDeviceCore::Init( CDataMember * FunctionConfig )
|
bool CDeviceCore::Init( CDataMember * FunctionConfig )
|
||||||
{
|
{
|
||||||
char * PersistFile = NULL;
|
char * PersistFile = NULL;
|
||||||
char * ConfigName = NULL;
|
|
||||||
CDataMember * PollConfig = NULL;
|
CDataMember * PollConfig = NULL;
|
||||||
int IntVal1;
|
int IntVal1;
|
||||||
int IntVal2;
|
int IntVal2;
|
||||||
@@ -86,13 +85,6 @@ bool CDeviceCore::Init( CDataMember * FunctionConfig )
|
|||||||
if (!(EventChannel = GetChannel( "Event" )))
|
if (!(EventChannel = GetChannel( "Event" )))
|
||||||
EventChannel = AddChannel( "Event", true, true );
|
EventChannel = AddChannel( "Event", true, true );
|
||||||
|
|
||||||
// Get configuration
|
|
||||||
if ((Config = FunctionConfig->GetChild( "Config", true )) && Config->isString()) {
|
|
||||||
ConfigName = (char*)FunctionConfig->GetChStr( "Config" );
|
|
||||||
Config = Application->Config->GetChild( ConfigName, true );
|
|
||||||
}
|
|
||||||
if (Config->isNull()) Config->SetObject();
|
|
||||||
|
|
||||||
// Load Polling configuration
|
// Load Polling configuration
|
||||||
PollConfig = Config->GetChild( "Polling", true );
|
PollConfig = Config->GetChild( "Polling", true );
|
||||||
if (PollConfig->isNull()) PollConfig->SetObject();
|
if (PollConfig->isNull()) PollConfig->SetObject();
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ class CDeviceCore : public CFunctionCore
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// Configuration
|
// Configuration
|
||||||
CDataMember * Config = NULL;
|
|
||||||
CDataMember * ConfigTypes = NULL;
|
CDataMember * ConfigTypes = NULL;
|
||||||
CDataMember * ValueTree = NULL;
|
CDataMember * ValueTree = NULL;
|
||||||
CJSONparse * JSONparse = NULL;
|
CJSONparse * JSONparse = NULL;
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ bool CFunctionCore::Init( CDataMember * FunctionConfig )
|
|||||||
CDataMember * ChannelConfig;
|
CDataMember * ChannelConfig;
|
||||||
EDebugLevel pLogLevel;
|
EDebugLevel pLogLevel;
|
||||||
int pLogOutput;
|
int pLogOutput;
|
||||||
|
char * ConfigName = NULL;
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
if (!FunctionConfig )
|
if (!FunctionConfig )
|
||||||
@@ -118,6 +119,13 @@ bool CFunctionCore::Init( CDataMember * FunctionConfig )
|
|||||||
ChannelConfig = ChannelConfig->GetNextPeer();
|
ChannelConfig = ChannelConfig->GetNextPeer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get main configuration
|
||||||
|
if ((Config = FunctionConfig->GetChild( "Config", true )) && Config->isString()) {
|
||||||
|
ConfigName = (char*)FunctionConfig->GetChStr( "Config" );
|
||||||
|
Config = Application->Config->GetChild( ConfigName, true );
|
||||||
|
}
|
||||||
|
if (Config->isNull()) Config->SetObject();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ protected:
|
|||||||
char * Name = NULL;
|
char * Name = NULL;
|
||||||
bool WaitToTerminate = false;
|
bool WaitToTerminate = false;
|
||||||
|
|
||||||
|
// JSON Config
|
||||||
|
CDataMember * Config = NULL;
|
||||||
|
|
||||||
// Channels
|
// Channels
|
||||||
TChannel * FirstChannel = NULL;
|
TChannel * FirstChannel = NULL;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user