Commit 983a66fe authored by Locatelli's avatar Locatelli

Get controller configuration for driver also

parent 5b549dc6
......@@ -2130,6 +2130,24 @@ vector<Database::ServantItem> Database::getDrivers() {
return result;
}
Database::ServantItem Database::getDriver(unsigned long servantID) {
Driver* driver = _IDDriverMap.get(servantID);
ServantItem item;
item.ID = servantID;
item.name = driver->getName();
item.type = driver->getDriverType();
item.clientType = driver->getClientType();
item.isCommand = driver->isCommand();
item.isVisible = driver->isVisible();
item.isEnabled = driver->isEnabled();
item.isRoot = driver->isRoot();
return item;
}
unsigned long Database::getServantID(unsigned long commandID) {
try {
......
......@@ -817,6 +817,11 @@ public:
std::vector<ServantItem> getDrivers();
/**
* Gets the drivers id
*/
ServantItem getDriver(unsigned long servantID);
/**
* Gets the servantID from a commandID.
* throw NoSuchCommandException
*/
......
......@@ -67,7 +67,13 @@ void ServantAccessorDirectImpl::getControllerConfiguration(unsigned long databas
try {
unsigned long controllerID = servantID;
Database::ServantItem item = Database::getInstance(databaseID)->getController(controllerID);
Database::ServantItem item;
if (Database::getInstance(databaseID)->isController(servantID)) {
item = Database::getInstance(databaseID)->getController(controllerID);
} else if (Database::getInstance(databaseID)->isDriver(servantID)) {
item = Database::getInstance(databaseID)->getDriver(controllerID);
}
configuration::ServantDescriptor servantDescriptor;
servantDescriptor.set_name(item.name);
......@@ -82,9 +88,15 @@ void ServantAccessorDirectImpl::getControllerConfiguration(unsigned long databas
servantDescriptor.set_root(item.isRoot);
servantDescriptor.set_channel(0);
createPropertyListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getControllerProperties(controllerID));
createCommandListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getControllerCommands(controllerID));
createChildServantListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getControllerChildServants(controllerID));
if (Database::getInstance(databaseID)->isController(servantID)) {
createPropertyListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getControllerProperties(controllerID));
createCommandListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getControllerCommands(controllerID));
createChildServantListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getControllerChildServants(controllerID));
} else if (Database::getInstance(databaseID)->isDriver(servantID)) {
createPropertyListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getDriverProperties(controllerID));
createCommandListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getDriverCommands(controllerID));
createChildServantListForWholeConfiguration(&servantDescriptor, Database::getInstance(databaseID)->getDriverChildServants(controllerID));
}
servantDescriptor.SerializeToString(&result);
......
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