Commit eeddd816 authored by yannick legoc's avatar yannick legoc

Corrected the generic command box access to the alias property and managed the...

Corrected the generic command box access to the alias property and managed the writeparams command failures
parent e98697d0
......@@ -86,7 +86,13 @@ CommandBox::CommandBoxType GenericCommandBox::getType() const {
void GenericCommandBox::setControllerName(const std::string& name) {
_controllerName = name;
_controllerID = DataAccess::getInstance()->getServantID(_controllerName);
try {
_controllerID = DataAccess::getInstance()->getServantID(_controllerName);
}
catch (...) {
// Do nothing.
}
}
const std::string& GenericCommandBox::getControllerName() {
......@@ -128,17 +134,26 @@ void GenericCommandBox::setProperty() {
// Getting the property ID, checking if it exists
try {
// Find the setpoint property associated with the alias.
string propertyName = _propertyName;
// Get the real property name
if (InstrumentManager::getInstance() != 0) {
// Get the name of the controller
string controllerName = DataAccess::getInstance()->getServantName(getExecutionDatabaseID(), _controllerID);
map<string, string> propertyAliases = InstrumentManager::getInstance()->getExperimentController(controllerName)->getAliasPropertyMap();
map<string, string>::iterator p = propertyAliases.find(propertyName);
if (p != propertyAliases.end()) {
propertyName = p->second;
string controllerType = DataAccess::getInstance()->getControllerType(getExecutionDatabaseID(), _controllerID);
// Get the property infos.
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getAllPropertyInfoItems(getExecutionDatabaseID(), controllerType);
// Look for the existence of an alias.
// If the alias is not found, then take the property as is.
for (auto i : items) {
// Search for the alias without whitespace.
if (i.aliasPropertyName == _propertyName) {
// Select the setpoint or actual property.
if (i.setpointPropertyName.empty()) {
propertyName = i.actualPropertyName;
}
else {
propertyName = i.setpointPropertyName;
}
}
}
......
......@@ -55,6 +55,8 @@ void SetCommandBox::executeCommand() {
} catch (const Exception& e) {
// do nothing
} catch (...) {
cerr << "Unexpected exception while executing Set command box" << endl;
}
// write log
......
......@@ -27,6 +27,12 @@ using namespace boost;
namespace dataprovider {
CommandAccessorDirectImpl::NoSuchServantException::NoSuchServantException()
: common::Exception("common::dataprovider::NoSuchServantException", "No such servant") {}
CommandAccessorDirectImpl::NoSuchCommandException::NoSuchCommandException()
: common::Exception("common::dataprovider::NoSuchCommandException", "No such command") {}
CommandAccessorDirectImpl::CommandAccessorDirectImpl() {
}
......@@ -66,6 +72,7 @@ unsigned long CommandAccessorDirectImpl::getCommandID(unsigned long databaseID,
return Database::getInstance(databaseID)->getCommandID(servantID, commandName);
} catch (Database::NoSuchCommandException& e) {
cout << "NoSuchCommandException" << endl;
throw NoSuchCommandException();
}
}
......
......@@ -42,8 +42,15 @@ class CommandAccessorDirectImpl {
public:
enum ActiveResult {EXECUTE, RECURSIVE, WAIT, SKIP};
class NoSuchServantException {};
class NoSuchCommandException {};
class NoSuchServantException : public common::Exception {
public:
NoSuchServantException();
};
class NoSuchCommandException : public common::Exception {
public:
NoSuchCommandException();
};
/**
* Constructor.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment