Skip to content

Commit 1b1d686

Browse files
committed
Added ability to have nddl code directly in the TREX xml
This replace the previous approach that if no model attribute was given was looking for [<agent>.]<reactor>.nddl
1 parent f161b92 commit 1b1d686

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

extra/europa/EuropaReactor.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ EuropaReactor::EuropaReactor(TeleoReactor::xml_arg_type arg)
8282
"relation_gv")),
8383
m_full_log(parse_attr<bool>(false, xml_factory::node(arg),
8484
"all_plans")) {
85-
bool found;
85+
bool found, is_file;
8686
std::string nddl;
8787

8888

@@ -93,15 +93,29 @@ EuropaReactor::EuropaReactor(TeleoReactor::xml_arg_type arg)
9393
if( m_full_log )
9494
syslog(warn)<<"I will log all my plans as they are produced."
9595
<<"\n\tThis can be very costful in term of disk space.";
96+
97+
// std::string content = cfg.second.data();
98+
// if( !content.empty() )
99+
// std::cout<<"content:\n"<<content<<std::endl;
100+
96101

97102
// Load the specified model
98103
if( model ) {
104+
is_file = true;
99105
if( model->empty() )
100106
throw XmlError(cfg, "Attribute \"model\" is empty.");
101107
nddl = *model;
102108
if( !locate_nddl(nddl) )
103109
throw XmlError(cfg, "Unable to locate model file \""+(*model)+"\"");
104110
} else {
111+
std::string content = cfg.second.data();
112+
syslog(null, info)<<"No model file; parsing xml text data instead:\n"
113+
<<content
114+
<<"\n-----------------------------------------------------";
115+
is_file = false;
116+
nddl = content;
117+
118+
/*
105119
std::string short_nddl = getName().str()+".nddl",
106120
long_nddl = getGraphName().str()+"."+short_nddl;
107121
@@ -114,9 +128,10 @@ EuropaReactor::EuropaReactor(TeleoReactor::xml_arg_type arg)
114128
if( !locate_nddl(nddl) )
115129
throw ReactorException(*this, "Unable to locate "+long_nddl+" or "+short_nddl);
116130
}
131+
*/
117132
}
118133
// Load the nddl model
119-
if( !playTransaction(nddl) ) {
134+
if( !playTransaction(nddl, is_file) ) {
120135
syslog(null,error)<<"Model is inconsistent.";
121136
throw ReactorException(*this, "model in "+nddl+" is inconsistent.");
122137
}

extra/europa/core/Assembly.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ bool Assembly::locate_nddl(std::string &nddl) const {
395395
return found;
396396
}
397397

398-
bool Assembly::playTransaction(std::string const &nddl) {
398+
bool Assembly::playTransaction(std::string const &nddl, bool isFile) {
399399
std::string const &path = m_trex_schema->nddl_path();
400400
std::string ret;
401401

@@ -404,7 +404,7 @@ bool Assembly::playTransaction(std::string const &nddl) {
404404

405405
// parse nddl
406406
try {
407-
ret = executeScript("nddl", nddl, true);
407+
ret = executeScript("nddl", nddl, isFile);
408408
} catch(EUROPA::PSLanguageExceptionList const &l_err) {
409409
std::ostringstream err;
410410
err<<"Error while parsing "<<nddl<<":\n"<<l_err;

extra/europa/trex/europa/Assembly.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ namespace TREX {
10721072
* @retval true the plan database is consistent
10731073
* @retval false the plan database is now inconsistent
10741074
*/
1075-
bool playTransaction(std::string const &nddl);
1075+
bool playTransaction(std::string const &nddl, bool isFile);
10761076

10771077
/** @brief Configure solvers
10781078
* @param[in] synchronizer A XML solver configuration file name

0 commit comments

Comments
 (0)