----------------------------------------------------------------------------- Apply XML differences to a value -----------------------------------------------------------------------------
| 2808 | // Apply XML differences to a value |
| 2809 | //----------------------------------------------------------------------------- |
| 2810 | void Node::ReadValueFromXML |
| 2811 | ( |
| 2812 | uint8 const _commandClassId, |
| 2813 | TiXmlElement const* _valueElement |
| 2814 | ) |
| 2815 | { |
| 2816 | int32 intVal; |
| 2817 | |
| 2818 | ValueID::ValueGenre genre = Value::GetGenreEnumFromName( _valueElement->Attribute( "genre" ) ); |
| 2819 | ValueID::ValueType type = Value::GetTypeEnumFromName( _valueElement->Attribute( "type" ) ); |
| 2820 | |
| 2821 | uint8 instance = 0; |
| 2822 | if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "instance", &intVal ) ) |
| 2823 | { |
| 2824 | instance = (uint8)intVal; |
| 2825 | } |
| 2826 | |
| 2827 | uint16 index = 0; |
| 2828 | if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "index", &intVal ) ) |
| 2829 | { |
| 2830 | index = (uint16)intVal; |
| 2831 | } |
| 2832 | |
| 2833 | ValueID id = ValueID( m_homeId, m_nodeId, genre, _commandClassId, instance, index, type ); |
| 2834 | |
| 2835 | // Try to get the value from the ValueStore (everything except configuration parameters |
| 2836 | // should already have been created when the command class instance count was read in). |
| 2837 | // Create it if it doesn't already exist. |
| 2838 | if( ValueStore* store = GetValueStore() ) |
| 2839 | { |
| 2840 | if( Value* value = store->GetValue( id.GetValueStoreKey() ) ) |
| 2841 | { |
| 2842 | // Check if values type are the same |
| 2843 | ValueID::ValueType v_type = value->GetID().GetType(); |
| 2844 | if ( v_type == type ) { |
| 2845 | value->ReadXML( m_homeId, m_nodeId, _commandClassId, _valueElement ); |
| 2846 | value->Release(); |
| 2847 | } else { |
| 2848 | Log::Write( LogLevel_Info, m_nodeId, "xml value type (%s) is different to stored value type (%s). Value is recreate with xml params.", value->GetTypeNameFromEnum(type), value->GetTypeNameFromEnum(v_type) ); |
| 2849 | store->RemoveValue( value->GetID().GetValueStoreKey() ); |
| 2850 | CreateValueFromXML( _commandClassId, _valueElement ); |
| 2851 | } |
| 2852 | } |
| 2853 | else |
| 2854 | { |
| 2855 | CreateValueFromXML( _commandClassId, _valueElement ); |
| 2856 | } |
| 2857 | } |
| 2858 | } |
| 2859 | |
| 2860 | //----------------------------------------------------------------------------- |
| 2861 | // <Node::GetValue> |
no test coverage detected