Commit c0e47556 authored by luz's avatar luz

dsScene: getProperty: when scene's channel 0 (0=alias for primary channel) is...

dsScene: getProperty: when scene's channel 0 (0=alias for primary channel) is queried, response must also use id==0, not the real channel type ID!

Same fix was applied months ago on the device level, see 920fb6dc (default channel read: when querying the default channel of a device by specifying "0" as name, the real channelType of the channel was returned, which was confusing. Now "0" is returned.)
parent 09ac9994
......@@ -1526,6 +1526,7 @@ PropertyDescriptorPtr Device::getDescriptorByName(string aPropMatch, int &aStart
// within range, create descriptor
DynamicPropertyDescriptor *descP = new DynamicPropertyDescriptor(aParentDescriptor);
if (aParentDescriptor->hasObjectKey(device_channels_key)) {
// is a channel
if (numericName) {
// query specified a channel number -> return same number in result (to return "0" when default channel "0" was explicitly queried)
descP->propertyName = aPropMatch; // query = name of object
......@@ -1539,7 +1540,7 @@ PropertyDescriptorPtr Device::getDescriptorByName(string aPropMatch, int &aStart
}
}
else {
// by index
// is a scene, name by index
descP->propertyName = string_format("%d", aStartIndex);
}
descP->propertyType = aParentDescriptor->type();
......
......@@ -84,18 +84,25 @@ protected:
bool numericName = getNextPropIndex(aPropMatch, aStartIndex);
if (numericName) {
// specific channel addressed by ID, look up index for it
DsChannelType ct = aStartIndex;
DsChannelType ct = (DsChannelType)aStartIndex;
aStartIndex = PROPINDEX_NONE; // default to not found
ChannelBehaviourPtr cb = scene.getDevice().getChannelByType(ct);
if (cb)
if (cb) {
aStartIndex = (int)cb->getChannelIndex(); // found, return index
}
}
int n = numProps(aDomain, aParentDescriptor);
if (aStartIndex!=PROPINDEX_NONE && aStartIndex<n) {
// within range, create descriptor
DynamicPropertyDescriptor *descP = new DynamicPropertyDescriptor(aParentDescriptor);
// name by channel
descP->propertyName = string_format("%d", scene.getDevice().getChannelByIndex(aStartIndex)->getChannelType());
if (numericName) {
// query specified a channel number -> return same number in result (to return "0" when default channel "0" was explicitly queried)
descP->propertyName = aPropMatch; // query = name of object
}
else {
// wildcard, name by channel type
descP->propertyName = string_format("%d", scene.getDevice().getChannelByIndex(aStartIndex)->getChannelType());
}
descP->propertyType = aParentDescriptor->type();
descP->propertyFieldKey = aStartIndex;
descP->propertyObjectKey = OKEY(scenevalue_key);
......
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