aqhome-react: expand properties also when reading units and links.
This commit is contained in:
@@ -42,7 +42,7 @@ static AQHREACT_UNIT_NET *_readUnitNetNoTemplate(AQHOME_REACT *aqh, GWEN_XMLNODE
|
||||
static GWEN_XMLNODE *_readUnitNetFileToXml(AQHOME_REACT *aqh, const char *sFilename);
|
||||
static void _readNetParamDefsWithList(AQHREACT_PARAM_LIST *paramList, GWEN_XMLNODE *unitNetNode);
|
||||
static int _readUnits(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unitNetNode, GWEN_DB_NODE *dbNetParams);
|
||||
static int _readLinks(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unitNetNode);
|
||||
static int _readLinks(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unitNetNode, GWEN_DB_NODE *dbNetParams);
|
||||
static AQHREACT_UNIT *_readUnit(AQHOME_REACT *aqh, GWEN_XMLNODE *unitNode, GWEN_DB_NODE *dbNetParams);
|
||||
static int _readParamValuesForList(const AQHREACT_PARAM_LIST *paramList, GWEN_XMLNODE *parentNode, GWEN_DB_NODE *dbNetParams);
|
||||
static int _readParamValueForList(const AQHREACT_PARAM_LIST *paramList, GWEN_XMLNODE *paramNode, GWEN_DB_NODE *dbNetParams);
|
||||
@@ -50,6 +50,7 @@ static int _setParamDataFromString(AQHREACT_PARAM *param, const char *value);
|
||||
static AQHREACT_PARAM *_readNetParamDef(GWEN_XMLNODE *paramNode);
|
||||
static int _readLink(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *linkNode);
|
||||
static int _setParamDoubleValueFromString(AQHREACT_PARAM *param, const char *s);
|
||||
static int _treeExpandProperties(const GWEN_XMLNODE *n, GWEN_DB_NODE *dbVars);
|
||||
|
||||
|
||||
|
||||
@@ -276,6 +277,8 @@ AQHREACT_UNIT_NET *_readUnitNetWithTemplate(AQHOME_REACT *aqh, GWEN_XMLNODE *uni
|
||||
AQHREACT_UnitNet_free(unitNet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* read netParam definitions from template file */
|
||||
_readNetParamDefsWithList(AQHREACT_UnitNet_GetParamList(unitNet), templateNetXml);
|
||||
|
||||
/* also read netParams from this file (after reading from template) */
|
||||
@@ -318,7 +321,7 @@ AQHREACT_UNIT_NET *_readUnitNetWithTemplate(AQHOME_REACT *aqh, GWEN_XMLNODE *uni
|
||||
}
|
||||
|
||||
/* read links from template file */
|
||||
rv=_readLinks(aqh, unitNet, templateNetXml);
|
||||
rv=_readLinks(aqh, unitNet, templateNetXml, dbNetParams);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
GWEN_DB_Group_free(dbNetParams);
|
||||
@@ -328,7 +331,7 @@ AQHREACT_UNIT_NET *_readUnitNetWithTemplate(AQHOME_REACT *aqh, GWEN_XMLNODE *uni
|
||||
}
|
||||
|
||||
/* read additional links from this file (if any) */
|
||||
rv=_readLinks(aqh, unitNet, unitNetXml);
|
||||
rv=_readLinks(aqh, unitNet, unitNetXml, dbNetParams);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
GWEN_DB_Group_free(dbNetParams);
|
||||
@@ -376,7 +379,7 @@ AQHREACT_UNIT_NET *_readUnitNetNoTemplate(AQHOME_REACT *aqh, GWEN_XMLNODE *unitN
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rv=_readLinks(aqh, unitNet, unitNetNode);
|
||||
rv=_readLinks(aqh, unitNet, unitNetNode, dbNetParams);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
GWEN_DB_Group_free(dbNetParams);
|
||||
@@ -426,6 +429,16 @@ int _readUnits(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unit
|
||||
if (nGroup) {
|
||||
GWEN_XMLNODE *n;
|
||||
|
||||
if (dbNetParams) {
|
||||
int rv;
|
||||
|
||||
rv=_treeExpandProperties(nGroup, dbNetParams);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
n=GWEN_XMLNode_FindFirstTag(nGroup, "unit", NULL, NULL);
|
||||
while(n) {
|
||||
AQHREACT_UNIT *unit;
|
||||
@@ -446,7 +459,7 @@ int _readUnits(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unit
|
||||
|
||||
|
||||
|
||||
int _readLinks(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unitNetNode)
|
||||
int _readLinks(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unitNetNode, GWEN_DB_NODE *dbNetParams)
|
||||
{
|
||||
GWEN_XMLNODE *nGroup;
|
||||
|
||||
@@ -454,6 +467,16 @@ int _readLinks(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *unit
|
||||
if (nGroup) {
|
||||
GWEN_XMLNODE *n;
|
||||
|
||||
if (dbNetParams) {
|
||||
int rv;
|
||||
|
||||
rv=_treeExpandProperties(nGroup, dbNetParams);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
n=GWEN_XMLNode_FindFirstTag(nGroup, "link", NULL, NULL);
|
||||
while(n) {
|
||||
int rv;
|
||||
@@ -765,5 +788,29 @@ int _readLink(AQHOME_REACT *aqh, AQHREACT_UNIT_NET *unitNet, GWEN_XMLNODE *linkN
|
||||
}
|
||||
|
||||
|
||||
int _treeExpandProperties(const GWEN_XMLNODE *n, GWEN_DB_NODE *dbVars)
|
||||
{
|
||||
int rv;
|
||||
const GWEN_XMLNODE *nn;
|
||||
|
||||
rv=GWEN_XMLNode_ExpandProperties(n, dbVars);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nn=GWEN_XMLNode_GetFirstTag(n);
|
||||
while(nn) {
|
||||
rv=_treeExpandProperties(nn, dbVars);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
nn=GWEN_XMLNode_GetNextTag(nn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user