----------------------------------------------------------------------------- Set a value in the Z-Wave device -----------------------------------------------------------------------------
| 164 | // Set a value in the Z-Wave device |
| 165 | //----------------------------------------------------------------------------- |
| 166 | bool Configuration::SetValue |
| 167 | ( |
| 168 | Value const& _value |
| 169 | ) |
| 170 | { |
| 171 | uint16 param = _value.GetID().GetIndex(); |
| 172 | switch( _value.GetID().GetType() ) |
| 173 | { |
| 174 | case ValueID::ValueType_BitSet: |
| 175 | { |
| 176 | ValueBitSet const& vbs = static_cast<ValueBitSet const&>( _value ); |
| 177 | Set( param, (int32)vbs.GetValue(), vbs.GetSize() ); |
| 178 | return true; |
| 179 | } |
| 180 | case ValueID::ValueType_Bool: |
| 181 | { |
| 182 | ValueBool const& valueBool = static_cast<ValueBool const&>( _value ); |
| 183 | Set( param, (int32)valueBool.GetValue(), 1 ); |
| 184 | return true; |
| 185 | } |
| 186 | case ValueID::ValueType_Byte: |
| 187 | { |
| 188 | ValueByte const& valueByte = static_cast<ValueByte const&>( _value ); |
| 189 | Set( param, (int32)valueByte.GetValue(), 1 ); |
| 190 | return true; |
| 191 | } |
| 192 | case ValueID::ValueType_Short: |
| 193 | { |
| 194 | ValueShort const& valueShort = static_cast<ValueShort const&>( _value ); |
| 195 | Set( param, (int32)valueShort.GetValue(), 2 ); |
| 196 | return true; |
| 197 | } |
| 198 | case ValueID::ValueType_Int: |
| 199 | { |
| 200 | ValueInt const& valueInt = static_cast<ValueInt const&>( _value ); |
| 201 | Set( param, valueInt.GetValue(), 4 ); |
| 202 | return true; |
| 203 | } |
| 204 | case ValueID::ValueType_List: |
| 205 | { |
| 206 | ValueList const& valueList = static_cast<ValueList const&>( _value ); |
| 207 | if (valueList.GetItem() != NULL) |
| 208 | Set( param, valueList.GetItem()->m_value, valueList.GetSize() ); |
| 209 | return true; |
| 210 | } |
| 211 | case ValueID::ValueType_Button: |
| 212 | { |
| 213 | ValueButton const& valueButton = static_cast<ValueButton const&>( _value ); |
| 214 | Set( param, valueButton.IsPressed(), 1 ); |
| 215 | return true; |
| 216 | } |
| 217 | default: |
| 218 | { |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | Log::Write( LogLevel_Info, GetNodeId(), "Configuration::Set failed (bad value or value type) - Parameter=%d", param ); |
| 223 | return false; |