Commit a4f61ca3 authored by yannick legoc's avatar yannick legoc

Added GetWholeDynamicProperties request to get the dynamic properties alias

parent 5f5471b3
......@@ -67,6 +67,8 @@ message Message {
GetFormattedValue = 27;
GetPropertyId = 28;
GetWholeDynamicProperties = 29;
}
required Type type = 1;
......@@ -154,7 +156,7 @@ message CommandRequest {
required uint32 commandID = 2;
}
message GetWholeScannablePropertiesRequest {
message GetWholePropertiesRequest {
required uint32 databaseID = 1;
}
......
......@@ -85,6 +85,7 @@ void DatabaseResponder::initProcessFunctions() {
m_processFunctions[database::Message::GetWholeScannableProperties] = &DatabaseResponder::processGetWholeScannableProperties;
m_processFunctions[database::Message::GetFormattedValue] = &DatabaseResponder::processGetFormattedValue;
m_processFunctions[database::Message::GetPropertyId] = &DatabaseResponder::processGetPropertyIDRequest;
m_processFunctions[database::Message::GetWholeDynamicProperties] = &DatabaseResponder::processGetWholeDynamicProperties;
}
void DatabaseResponder::processGetInt32Value(const std::string & message, std::string & response) {
......@@ -465,13 +466,13 @@ void DatabaseResponder::processStopCommand(const std::string & message, std::str
void DatabaseResponder::processGetWholeScannableProperties(const std::string & message, std::string & response) {
database::GetWholeScannablePropertiesRequest messageRequest;
database::GetWholePropertiesRequest messageRequest;
messageRequest.ParseFromString(message);
common::StringResponse responseMessage;
// Call to generate the exception.
std::string result = m_propertyAccessor->getWholeScannableProperties(messageRequest.databaseid());
std::string result = Database::getInstance(messageRequest.databaseid())->getWholeScannableProperties();
responseMessage.set_value(result);
// Serialize the response.
......@@ -523,6 +524,21 @@ void DatabaseResponder::processGetPropertyIDRequest(const std::string & message,
responseMessage.SerializeToString(&response);
}
void DatabaseResponder::processGetWholeDynamicProperties(const std::string & message, std::string & response) {
database::GetWholePropertiesRequest messageRequest;
messageRequest.ParseFromString(message);
common::StringResponse responseMessage;
// Call to generate the exception.
std::string result = Database::getInstance(messageRequest.databaseid())->getWholeDynamicProperties();
responseMessage.set_value(result);
// Serialize the response.
responseMessage.SerializeToString(&response);
}
void DatabaseResponder::loop() {
// Initialize the map of functions.
......
......@@ -94,6 +94,8 @@ private:
void processGetPropertyIDRequest(const std::string & message, std::string & response);
void processGetWholeDynamicProperties(const std::string & message, std::string & response);
dataprovider::PropertyAccessorDirectImpl* m_propertyAccessor;
dataprovider::CommandAccessorDirectImpl* m_commandAccessor;
......
......@@ -3767,18 +3767,24 @@ int32 Database::getNumberOfScannableProperties(const std::string & controllerTyp
return result;
}
void Database::addPropertyInfoString(const std::string& servantType, const Database::PropertyInfoItem& item, std::string& output) const {
void Database::addPropertyInfoString(const std::string& servantType, const Database::PropertyInfoItem& item, std::string& output, bool dynamic) const {
// Only add a property that has an alias.
if (item.aliasPropertyName.empty()) {
return;
}
// Do not add dynamic properties.
if (item.isDynamic) {
// Select the dynamic properties or not depending on the dynamic value.
if (item.isDynamic != dynamic) {
return;
}
// Set dynamic.
string dynamicString = "false";
if (item.isDynamic) {
dynamicString = "true";
}
// Set scannable.
string scannable = "false";
if (item.isScan) {
......@@ -3786,7 +3792,7 @@ void Database::addPropertyInfoString(const std::string& servantType, const Datab
}
// Create the XML tags.
output += string("\t<property_info controller_type='") + servantType + "' alias='" + item.aliasPropertyName + "' scannable='" + scannable + "'>\n";
output += string("\t<property_info controller_type='") + servantType + "' alias='" + item.aliasPropertyName + "' scannable='" + scannable + "' dynamic='" + dynamicString + "'>\n";
output += string("\t\t<actual_property name='") + item.actualPropertyName + "'/>\n";
output += string("\t\t<setpoint_property name='") + item.setpointPropertyName + "'/>\n";
output += string("\t\t<offset_property name='") + item.offsetPropertyName + "'/>\n";
......@@ -3810,11 +3816,51 @@ std::string Database::getWholeScannableProperties() const {
vector<PropertyInfoItem> items = getPropertyInfoItems(servantType);
for (auto p = items.begin(); p != items.end(); ++p) {
addPropertyInfoString(servantType, *p, result);
addPropertyInfoString(servantType, *p, result, false);
}
for (auto p = items.begin(); p != items.end(); ++p) {
addPropertyInfoString(servantType, *p, result, false);
}
}
for (deque<string>::const_iterator t = types.begin(); t != types.end(); ++t) {
vector<PropertyInfoItem> items = getPropertyInfoItems(*t);
for (auto p = items.begin(); p != items.end(); ++p) {
addPropertyInfoString(servantType, *p, result, false);
}
}
}
result += "</properties>";
return result;
}
std::string Database::getWholeDynamicProperties() const {
string result("<properties>\n");
// iterate the controller type inheritance
for (HashMap<string, deque<string> >::const_iterator i = _controllerTypeInheritance.begin(); i != _controllerTypeInheritance.end(); ++i) {
string servantType = i->first;
deque<string> const & types = i->second;
// test if servantType is not types (seems to happen only for legacy controllers)
if (types.front() != servantType) {
// Get the setpoints.
vector<PropertyInfoItem> items = getPropertyInfoItems(servantType);
for (auto p = items.begin(); p != items.end(); ++p) {
addPropertyInfoString(servantType, *p, result, true);
}
for (auto p = items.begin(); p != items.end(); ++p) {
addPropertyInfoString(servantType, *p, result);
addPropertyInfoString(servantType, *p, result, true);
}
}
......@@ -3823,7 +3869,7 @@ std::string Database::getWholeScannableProperties() const {
vector<PropertyInfoItem> items = getPropertyInfoItems(*t);
for (auto p = items.begin(); p != items.end(); ++p) {
addPropertyInfoString(servantType, *p, result);
addPropertyInfoString(servantType, *p, result, true);
}
}
}
......
......@@ -1247,11 +1247,17 @@ public:
int32 getNumberOfScannableProperties(const std::string & controllerType) const;
/**
* Returns the content of all the scannable properties.
* Returns the model of all the scannable properties.
* The result is an XML string with all possible entries. The controller inheritance is not used but the properties are copied if inherited.
*/
std::string getWholeScannableProperties() const;
/**
* Returns the model of all the dynamic properties.
* The result is an XML string with all possible entries. The controller inheritance is not used but the properties are copied if inherited.
*/
std::string getWholeDynamicProperties() const;
// Property unit //////////////////////////////////////////////////////////////////////////////
/**
......@@ -1326,7 +1332,7 @@ private:
void controllerToString(Controller* controller, bool save, std::string& result);
void driverToString(Driver* driver, bool save, std::string& result);
void addPropertyInfoString(const std::string& servantType, const PropertyInfoItem& item, std::string& output) const;
void addPropertyInfoString(const std::string& servantType, const PropertyInfoItem& item, std::string& output, bool dynamic) const;
/**
* Checks the value against the list of enumerated values.
......
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