bool ClimateControlBehaviour::accessField(PropertyAccessMode aMode, ApiValuePtr aPropValue, PropertyDescriptorPtr aPropertyDescriptor) { if (aPropertyDescriptor->hasObjectKey(climatecontrol_key)) { if (aMode==access_read) { // read properties switch (aPropertyDescriptor->fieldKey()) { // Description properties case activeCoolingMode_key+descriptions_key_offset: aPropValue->setBoolValue(climateDeviceKind==climatedevice_fancoilunit); // FCUs can cool actively return true; // Settings properties case heatingSystemCapability_key+settings_key_offset: aPropValue->setUint8Value(heatingSystemCapability); return true; case heatingSystemType_key+settings_key_offset: aPropValue->setUint8Value(heatingSystemType); return true; } } else { // write properties switch (aPropertyDescriptor->fieldKey()) { // Settings properties case heatingSystemCapability_key+settings_key_offset: setPVar(heatingSystemCapability, (VdcHeatingSystemCapability)aPropValue->uint8Value()); return true; case heatingSystemType_key+settings_key_offset: setPVar(heatingSystemType, (VdcHeatingSystemType)aPropValue->uint8Value()); return true; } } } // not my field, let base class handle it return inherited::accessField(aMode, aPropValue, aPropertyDescriptor); }
PropertyDescriptorPtr OutputBehaviour::getDescriptorByName(string aPropMatch, int &aStartIndex, int aDomain, PropertyDescriptorPtr aParentDescriptor) { if (aParentDescriptor && aParentDescriptor->hasObjectKey(output_groups_key)) { // array-like container PropertyDescriptorPtr propDesc; bool numericName = getNextPropIndex(aPropMatch, aStartIndex); int n = numProps(aDomain, aParentDescriptor); if (aStartIndex!=PROPINDEX_NONE && aStartIndex<n) { // within range, create descriptor DynamicPropertyDescriptor *descP = new DynamicPropertyDescriptor(aParentDescriptor); descP->propertyName = string_format("%d", aStartIndex); descP->propertyType = aParentDescriptor->type(); descP->propertyFieldKey = aStartIndex; descP->propertyObjectKey = aParentDescriptor->objectKey(); propDesc = PropertyDescriptorPtr(descP); // advance index aStartIndex++; } if (aStartIndex>=n || numericName) { // no more descriptors OR specific descriptor accessed -> no "next" descriptor aStartIndex = PROPINDEX_NONE; } return propDesc; } // None of the containers within Device - let base class handle Device-Level properties return inherited::getDescriptorByName(aPropMatch, aStartIndex, aDomain, aParentDescriptor); }
int OutputBehaviour::numProps(int aDomain, PropertyDescriptorPtr aParentDescriptor) { if (aParentDescriptor->hasObjectKey(output_groups_key)) { return 64; // group mask has 64 bits for now } return inherited::numProps(aDomain, aParentDescriptor); }
PropertyContainerPtr OutputBehaviour::getContainer(PropertyDescriptorPtr &aPropertyDescriptor, int &aDomain) { if (aPropertyDescriptor->isArrayContainer() && aPropertyDescriptor->hasObjectKey(output_groups_key)) { return PropertyContainerPtr(this); // handle groups array myself } // unknown here return inherited::getContainer(aPropertyDescriptor, aDomain); }
// access to all fields bool ChannelBehaviour::accessField(PropertyAccessMode aMode, ApiValuePtr aPropValue, PropertyDescriptorPtr aPropertyDescriptor) { if (aPropertyDescriptor->hasObjectKey(channel_Key)) { if (aMode==access_read) { // read properties switch (aPropertyDescriptor->fieldKey()) { // Description properties case name_key+descriptions_key_offset: aPropValue->setStringValue(getName()); return true; case channelIndex_key+descriptions_key_offset: aPropValue->setUint8Value(channelIndex); return true; case min_key+descriptions_key_offset: aPropValue->setDoubleValue(getMin()); return true; case max_key+descriptions_key_offset: aPropValue->setDoubleValue(getMax()); return true; case resolution_key+descriptions_key_offset: aPropValue->setDoubleValue(getResolution()); return true; // Settings properties // - none for now // States properties case value_key+states_key_offset: // get value of channel, possibly calculating it if needed (color conversions) aPropValue->setDoubleValue(getChannelValueCalculated()); return true; case age_key+states_key_offset: if (channelLastSync==Never) aPropValue->setNull(); // no value known else aPropValue->setDoubleValue((double)(MainLoop::now()-channelLastSync)/Second); return true; } } else { // write properties switch (aPropertyDescriptor->fieldKey()) { // Settings properties // - none for now // States properties case value_key+states_key_offset: setChannelValue(aPropValue->doubleValue(), 0, true); // always apply, no transition time return true; } } } // single class level properties only, don't call inherited return false; }
// access to all fields bool EnoceanDevice::accessField(PropertyAccessMode aMode, ApiValuePtr aPropValue, PropertyDescriptorPtr aPropertyDescriptor) { if (aPropertyDescriptor->hasObjectKey(enoceanDevice_key)) { if (aMode==access_read) { // read properties switch (aPropertyDescriptor->fieldKey()) { case profileVariants_key: aPropValue->setType(apivalue_object); // make object (incoming object is NULL) return getProfileVariants(aPropValue); case profile_key: aPropValue->setInt32Value(getEEProfile()); return true; case packetage_key: // Note lastPacketTime is set to now at startup, so additionally check lastRSSI if (lastPacketTime==Never || lastRSSI<=-999) aPropValue->setNull(); else aPropValue->setDoubleValue((double)(MainLoop::now()-lastPacketTime)/Second); return true; case rssi_key: if (lastRSSI<=-999) aPropValue->setNull(); else aPropValue->setInt32Value(lastRSSI); return true; case repeaterCount_key: if (lastRSSI<=-999) aPropValue->setNull(); else aPropValue->setUint8Value(lastRepeaterCount); return true; } } else { // write properties switch (aPropertyDescriptor->fieldKey()) { case profile_key: setProfileVariant(aPropValue->int32Value()); return true; } } } // not my field, let base class handle it return inherited::accessField(aMode, aPropValue, aPropertyDescriptor); }
bool SensorBehaviour::accessField(PropertyAccessMode aMode, ApiValuePtr aPropValue, PropertyDescriptorPtr aPropertyDescriptor) { if (aPropertyDescriptor->hasObjectKey(sensor_key)) { if (aMode==access_read) { // read properties switch (aPropertyDescriptor->fieldKey()) { // Description properties case sensorType_key+descriptions_key_offset: aPropValue->setUint16Value(sensorType); return true; case sensorUsage_key+descriptions_key_offset: aPropValue->setUint16Value(sensorUsage); return true; case min_key+descriptions_key_offset: aPropValue->setDoubleValue(min); return true; case max_key+descriptions_key_offset: aPropValue->setDoubleValue(max); return true; case resolution_key+descriptions_key_offset: aPropValue->setDoubleValue(resolution); return true; case updateInterval_key+descriptions_key_offset: aPropValue->setDoubleValue((double)updateInterval/Second); return true; case aliveSignInterval_key+descriptions_key_offset: aPropValue->setDoubleValue((double)aliveSignInterval/Second); return true; // Settings properties case group_key+settings_key_offset: aPropValue->setUint16Value(sensorGroup); return true; case minPushInterval_key+settings_key_offset: aPropValue->setDoubleValue((double)minPushInterval/Second); return true; case changesOnlyInterval_key+settings_key_offset: aPropValue->setDoubleValue((double)changesOnlyInterval/Second); return true; // States properties case value_key+states_key_offset: // value if (lastUpdate==Never) aPropValue->setNull(); else aPropValue->setDoubleValue(currentValue); return true; case age_key+states_key_offset: // age if (lastUpdate==Never) aPropValue->setNull(); else aPropValue->setDoubleValue((double)(MainLoop::now()-lastUpdate)/Second); return true; } } else { // write properties switch (aPropertyDescriptor->fieldKey()) { // Settings properties case group_key+settings_key_offset: setPVar(sensorGroup, (DsGroup)aPropValue->int32Value()); return true; case minPushInterval_key+settings_key_offset: setPVar(minPushInterval, (MLMicroSeconds)(aPropValue->doubleValue()*Second)); return true; case changesOnlyInterval_key+settings_key_offset: setPVar(changesOnlyInterval, (MLMicroSeconds)(aPropValue->doubleValue()*Second)); return true; } } } // not my field, let base class handle it return inherited::accessField(aMode, aPropValue, aPropertyDescriptor); }
// access to all fields bool ChannelBehaviour::accessField(PropertyAccessMode aMode, ApiValuePtr aPropValue, PropertyDescriptorPtr aPropertyDescriptor) { if (aPropertyDescriptor->hasObjectKey(channel_Key)) { if (aMode==access_read) { // read properties switch (aPropertyDescriptor->fieldKey()) { // Description properties case name_key+descriptions_key_offset: aPropValue->setStringValue(getName()); return true; case channelIndex_key+descriptions_key_offset: if (aPropertyDescriptor->getApiVersion()>=3) return false; // property does not exist any more in v3 and later aPropValue->setUint8Value(channelIndex); return true; case dsIndex_key+descriptions_key_offset: aPropValue->setUint8Value(channelIndex); return true; case channelType_key+descriptions_key_offset: aPropValue->setUint8Value(getChannelType()); return true; case siunit_key+descriptions_key_offset: aPropValue->setStringValue(valueUnitName(getChannelUnit(), false)); return true; case unitsymbol_key+descriptions_key_offset: aPropValue->setStringValue(valueUnitName(getChannelUnit(), true)); return true; case min_key+descriptions_key_offset: aPropValue->setDoubleValue(getMin()); return true; case max_key+descriptions_key_offset: aPropValue->setDoubleValue(getMax()); return true; case resolution_key+descriptions_key_offset: aPropValue->setDoubleValue(getResolution()); return true; // Settings properties // - none for now // States properties case value_key+states_key_offset: // get value of channel, possibly calculating it if needed (color conversions) aPropValue->setDoubleValue(getChannelValueCalculated()); return true; case age_key+states_key_offset: if (channelLastSync==Never) aPropValue->setNull(); // no value known else aPropValue->setDoubleValue((double)(MainLoop::now()-channelLastSync)/Second); // time of last sync (does not necessarily relate to currently visible "value", as this might be a to-be-applied new value already) return true; } } else { // write properties switch (aPropertyDescriptor->fieldKey()) { // Settings properties // - none for now // States properties case value_key+states_key_offset: setChannelValue(aPropValue->doubleValue(), output.transitionTime, true); // always apply, default transition time (normally 0, unless set in outputState) return true; } } } // single class level properties only, don't call inherited return false; }
bool OutputBehaviour::accessField(PropertyAccessMode aMode, ApiValuePtr aPropValue, PropertyDescriptorPtr aPropertyDescriptor) { if (aPropertyDescriptor->hasObjectKey(output_groups_key)) { if (aMode==access_read) { // read group membership if (isMember((DsGroup)aPropertyDescriptor->fieldKey())) { aPropValue->setBoolValue(true); return true; } return false; } else { // write group setGroupMembership((DsGroup)aPropertyDescriptor->fieldKey(), aPropValue->boolValue()); return true; } } else if (aPropertyDescriptor->hasObjectKey(output_key)) { if (aMode==access_read) { // read properties switch (aPropertyDescriptor->fieldKey()) { // Description properties case outputFunction_key+descriptions_key_offset: aPropValue->setUint8Value(outputFunction); return true; case outputUsage_key+descriptions_key_offset: aPropValue->setUint16Value(outputUsage); return true; case variableRamp_key+descriptions_key_offset: aPropValue->setBoolValue(variableRamp); return true; case maxPower_key+descriptions_key_offset: aPropValue->setDoubleValue(maxPower); return true; // Settings properties case mode_key+settings_key_offset: aPropValue->setUint8Value(actualOutputMode()); // return actual mode, never outputmode_default return true; case pushChanges_key+settings_key_offset: aPropValue->setBoolValue(pushChanges); return true; // State properties case localPriority_key+states_key_offset: aPropValue->setBoolValue(localPriority); return true; } } else { // write properties switch (aPropertyDescriptor->fieldKey()) { // Settings properties case mode_key+settings_key_offset: setOutputMode((DsOutputMode)aPropValue->int32Value()); return true; case pushChanges_key+settings_key_offset: setPVar(pushChanges, aPropValue->boolValue()); return true; // State properties case localPriority_key+states_key_offset: setPVar(localPriority, aPropValue->boolValue()); return true; } } } // not my field, let base class handle it return inherited::accessField(aMode, aPropValue, aPropertyDescriptor); }