----------------------------------------------------------------------------- Create the values for this command class based on the reported parameters -----------------------------------------------------------------------------
| 242 | // Create the values for this command class based on the reported parameters |
| 243 | //----------------------------------------------------------------------------- |
| 244 | bool Meter::HandleSupportedReport |
| 245 | ( |
| 246 | uint8 const* _data, |
| 247 | uint32 const _length, |
| 248 | uint32 const _instance |
| 249 | ) |
| 250 | { |
| 251 | bool canReset = ((_data[1] & 0x80) != 0); |
| 252 | int8 meterType = (MeterType)(_data[1] & 0x1f); |
| 253 | if (meterType > 4) /* size of c_meterTypes */ |
| 254 | { |
| 255 | Log::Write (LogLevel_Warning, GetNodeId(), "meterType Value was greater than range. Dropping Message"); |
| 256 | return false; |
| 257 | } |
| 258 | |
| 259 | |
| 260 | ClearStaticRequest( StaticRequest_Version ); |
| 261 | if( Node* node = GetNodeUnsafe() ) |
| 262 | { |
| 263 | string msg; |
| 264 | msg = c_meterTypes[meterType]; |
| 265 | msg += ": "; |
| 266 | // Create the list of supported scales |
| 267 | uint8 scaleSupported = _data[2]; |
| 268 | if( GetVersion() == 2 ) |
| 269 | { |
| 270 | // Only four scales are allowed in version 2 |
| 271 | scaleSupported &= 0x0f; |
| 272 | } |
| 273 | |
| 274 | for( uint8 i=0; i<8; ++i ) |
| 275 | { |
| 276 | if( scaleSupported & (1<<i) ) |
| 277 | { |
| 278 | uint8 baseIndex = i<<2; // We leave space between the value indices to insert previous and time delta values if we need to later on. |
| 279 | switch( meterType ) |
| 280 | { |
| 281 | case MeterType_Electric: |
| 282 | { |
| 283 | if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, baseIndex ) ) ) |
| 284 | { |
| 285 | value->SetLabel( c_electricityLabels[i] ); |
| 286 | value->SetUnits( c_electricityUnits[i] ); |
| 287 | value->Release(); |
| 288 | } |
| 289 | else |
| 290 | { |
| 291 | node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, baseIndex, c_electricityLabels[i], c_electricityUnits[i], true, false, "0.0", 0 ); |
| 292 | } |
| 293 | if( i != 0 ) |
| 294 | msg += ", "; |
| 295 | msg += c_electricityUnits[i]; |
| 296 | break; |
| 297 | } |
| 298 | case MeterType_Gas: |
| 299 | { |
| 300 | if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, baseIndex ) ) ) |
| 301 | { |
nothing calls this directly
no test coverage detected