MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / VerifyRefreshedValue

Method VerifyRefreshedValue

cpp/src/value_classes/Value.cpp:554–752  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Check a refreshed value -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

552// Check a refreshed value
553//-----------------------------------------------------------------------------
554int Value::VerifyRefreshedValue
555(
556 void* _originalValue,
557 void* _checkValue,
558 void* _newValue,
559 ValueID::ValueType _type,
560 int _originalValueLength, // = 0,
561 int _checkValueLength, // = 0,
562 int _newValueLength // = 0
563)
564{
565 // TODO: this is pretty rough code, but it's reused by each value type. It would be
566 // better if the actions were taken (m_value = _value, etc.) in this code rather than
567 // in the calling routine as a result of the return value. In particular, it's messy
568 // to be setting these values after the refesh or notification is sent. With some
569 // focus on the actual variable storage, we should be able to accomplish this with
570 // memory functions. It's really the strings that make things complicated(?).
571 // if this is the first read of a value, assume it is valid (and notify as a change)
572 if( !IsSet() )
573 {
574 Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Initial read of value" );
575 Value::OnValueChanged();
576 return 2; // confirmed change of value
577 }
578 else
579 {
580 switch( _type )
581 {
582 case ValueID::ValueType_Button: // Button is stored as a bool
583 case ValueID::ValueType_Bool: // bool
584 {
585 Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%s, new value=%s, type=%s", *((bool*)_originalValue)?"true":"false", *((uint8*)_newValue)?"true":"false", GetTypeNameFromEnum(_type) );
586 break;
587 }
588 case ValueID::ValueType_Byte: // byte
589 {
590 Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%d, new value=%d, type=%s", *((uint8*)_originalValue), *((uint8*)_newValue), GetTypeNameFromEnum(_type) );
591 break;
592 }
593 case ValueID::ValueType_Decimal: // decimal is stored as a string, so treat it as a string here
594 case ValueID::ValueType_String: // string
595 {
596 Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%s, new value=%s, type=%s", ((string*)_originalValue)->c_str(), ((string*)_newValue)->c_str(), GetTypeNameFromEnum(_type) );
597 break;
598 }
599 case ValueID::ValueType_Short: // short
600 {
601 Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%d, new value=%d, type=%s", *((short*)_originalValue), *((short*)_newValue), GetTypeNameFromEnum(_type));
602 break;
603 }
604 case ValueID::ValueType_List: // List Type is treated as a int32
605 case ValueID::ValueType_Int: // int32
606 case ValueID::ValueType_BitSet: // BitSet
607 {
608 Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%d, new value=%d, type=%s", *((int32*)_originalValue), *((int32*)_newValue), GetTypeNameFromEnum(_type) );
609 break;
610 }
611 case ValueID::ValueType_Raw: // raw

Callers

nothing calls this directly

Calls 6

WriteFunction · 0.85
GetNodeIdMethod · 0.80
RefreshValueMethod · 0.80
GetFunction · 0.50
c_strMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected