----------------------------------------------------------------------------- Set a value on the Z-Wave device -----------------------------------------------------------------------------
| 213 | // Set a value on the Z-Wave device |
| 214 | //----------------------------------------------------------------------------- |
| 215 | bool Powerlevel::SetValue |
| 216 | ( |
| 217 | Value const& _value |
| 218 | ) |
| 219 | { |
| 220 | bool res = false; |
| 221 | uint8 instance = _value.GetID().GetInstance(); |
| 222 | |
| 223 | switch( _value.GetID().GetIndex() ) |
| 224 | { |
| 225 | case PowerlevelIndex_Powerlevel: |
| 226 | { |
| 227 | if( ValueList* value = static_cast<ValueList*>( GetValue( instance, PowerlevelIndex_Powerlevel ) ) ) |
| 228 | { |
| 229 | ValueList::Item const *item = (static_cast<ValueList const*>( &_value))->GetItem(); |
| 230 | if (item != NULL) |
| 231 | value->OnValueRefreshed( item->m_value ); |
| 232 | value->Release(); |
| 233 | } |
| 234 | res = true; |
| 235 | break; |
| 236 | } |
| 237 | case PowerlevelIndex_Timeout: |
| 238 | { |
| 239 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( instance, PowerlevelIndex_Timeout ) ) ) |
| 240 | { |
| 241 | value->OnValueRefreshed( (static_cast<ValueByte const*>( &_value))->GetValue() ); |
| 242 | value->Release(); |
| 243 | } |
| 244 | res = true; |
| 245 | break; |
| 246 | } |
| 247 | case PowerlevelIndex_Set: |
| 248 | { |
| 249 | // Set |
| 250 | if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, PowerlevelIndex_Set ) ) ) |
| 251 | { |
| 252 | if( button->IsPressed() ) |
| 253 | { |
| 254 | res = Set( instance ); |
| 255 | } |
| 256 | button->Release(); |
| 257 | } |
| 258 | break; |
| 259 | } |
| 260 | case PowerlevelIndex_TestNode: |
| 261 | { |
| 262 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( instance, PowerlevelIndex_TestNode ) ) ) |
| 263 | { |
| 264 | value->OnValueRefreshed( (static_cast<ValueByte const*>( &_value))->GetValue() ); |
| 265 | value->Release(); |
| 266 | } |
| 267 | res = true; |
| 268 | break; |
| 269 | } |
| 270 | case PowerlevelIndex_TestPowerlevel: |
| 271 | { |
| 272 | if( ValueList* value = static_cast<ValueList*>( GetValue( instance, PowerlevelIndex_TestPowerlevel ) ) ) |
nothing calls this directly
no test coverage detected