// 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 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; }