AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/src/bacapp.c
bool bacapp_same_value(
    BACNET_APPLICATION_DATA_VALUE * value,
    BACNET_APPLICATION_DATA_VALUE * test_value)
{
    bool status = false;        /*return value */

    /* does the tag match? */
    if (test_value->tag == value->tag)
        status = true;
    if (status) {
        /* second test for same-ness */
        status = false;
        /* does the value match? */
        switch (test_value->tag) {
#if defined (BACAPP_NULL)
            case BACNET_APPLICATION_TAG_NULL:
                status = true;
                break;
#endif
#if defined (BACAPP_BOOLEAN)
            case BACNET_APPLICATION_TAG_BOOLEAN:
                if (test_value->type.Boolean == value->type.Boolean)
                    status = true;
                break;
#endif
#if defined (BACAPP_UNSIGNED)
            case BACNET_APPLICATION_TAG_UNSIGNED_INT:
                if (test_value->type.Unsigned_Int == value->type.Unsigned_Int)
                    status = true;
                break;
#endif
#if defined (BACAPP_SIGNED)
            case BACNET_APPLICATION_TAG_SIGNED_INT:
                if (test_value->type.Signed_Int == value->type.Signed_Int)
                    status = true;
                break;
#endif
#if defined (BACAPP_REAL)
            case BACNET_APPLICATION_TAG_REAL:
                if (test_value->type.Real == value->type.Real)
                    status = true;
                break;
#endif
#if defined (BACAPP_DOUBLE)
            case BACNET_APPLICATION_TAG_DOUBLE:
                if (test_value->type.Double == value->type.Double)
                    status = true;
                break;
#endif
#if defined (BACAPP_ENUMERATED)
            case BACNET_APPLICATION_TAG_ENUMERATED:
                if (test_value->type.Enumerated == value->type.Enumerated)
                    status = true;
                break;
#endif
#if defined (BACAPP_DATE)
            case BACNET_APPLICATION_TAG_DATE:
                if (datetime_compare_date(&test_value->type.Date,
                        &value->type.Date) == 0)
                    status = true;
                break;
#endif
#if defined (BACAPP_TIME)
            case BACNET_APPLICATION_TAG_TIME:
                if (datetime_compare_time(&test_value->type.Time,
                        &value->type.Time) == 0)
                    status = true;
                break;
#endif
#if defined (BACAPP_OBJECT_ID)
            case BACNET_APPLICATION_TAG_OBJECT_ID:
                if ((test_value->type.Object_Id.type ==
                        value->type.Object_Id.type) &&
                    (test_value->type.Object_Id.instance ==
                        value->type.Object_Id.instance)) {
                    status = true;
                }
                break;
#endif
#if defined (BACAPP_CHARACTER_STRING)
            case BACNET_APPLICATION_TAG_CHARACTER_STRING:
                status =
                    characterstring_same(&value->type.Character_String,
                    &test_value->type.Character_String);
                break;
#endif
#if defined (BACAPP_OCTET_STRING)
            case BACNET_APPLICATION_TAG_OCTET_STRING:
                status =
                    octetstring_value_same(&value->type.Octet_String,
                    &test_value->type.Octet_String);
                break;
#endif
#if defined (BACAPP_BIT_STRING)
            case BACNET_APPLICATION_TAG_BIT_STRING:
                status =
                    bitstring_same(&value->type.Bit_String,
                    &test_value->type.Bit_String);
                break;
#endif
#if defined (BACAPP_LIGHTING_COMMAND)
            case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
                status = lighting_command_same(
                    &value->type.Lighting_Command,
                    &test_value->type.Lighting_Command);
                break;
#endif
            default:
                status = false;
                break;
        }
    }
    return status;
}
/* generic - can be used by other unit tests
   returns true if matching or same, false if different */
can be used by other unit tests
returns true if matching or same, false if different
can be used by other unit tests returns true if matching or same false if different
bool bacapp_same_value(
    BACNET_APPLICATION_DATA_VALUE * value,
    BACNET_APPLICATION_DATA_VALUE * test_value)
{
    bool status = false;        
    if (test_value->tag == value->tag)
        status = true;
    if (status) {
        status = false;
        switch (test_value->tag) {
#if defined (BACAPP_NULL)
            case BACNET_APPLICATION_TAG_NULL:
                status = true;
                break;
#endif
#if defined (BACAPP_BOOLEAN)
            case BACNET_APPLICATION_TAG_BOOLEAN:
                if (test_value->type.Boolean == value->type.Boolean)
                    status = true;
                break;
#endif
#if defined (BACAPP_UNSIGNED)
            case BACNET_APPLICATION_TAG_UNSIGNED_INT:
                if (test_value->type.Unsigned_Int == value->type.Unsigned_Int)
                    status = true;
                break;
#endif
#if defined (BACAPP_SIGNED)
            case BACNET_APPLICATION_TAG_SIGNED_INT:
                if (test_value->type.Signed_Int == value->type.Signed_Int)
                    status = true;
                break;
#endif
#if defined (BACAPP_REAL)
            case BACNET_APPLICATION_TAG_REAL:
                if (test_value->type.Real == value->type.Real)
                    status = true;
                break;
#endif
#if defined (BACAPP_DOUBLE)
            case BACNET_APPLICATION_TAG_DOUBLE:
                if (test_value->type.Double == value->type.Double)
                    status = true;
                break;
#endif
#if defined (BACAPP_ENUMERATED)
            case BACNET_APPLICATION_TAG_ENUMERATED:
                if (test_value->type.Enumerated == value->type.Enumerated)
                    status = true;
                break;
#endif
#if defined (BACAPP_DATE)
            case BACNET_APPLICATION_TAG_DATE:
                if (datetime_compare_date(&test_value->type.Date,
                        &value->type.Date) == 0)
                    status = true;
                break;
#endif
#if defined (BACAPP_TIME)
            case BACNET_APPLICATION_TAG_TIME:
                if (datetime_compare_time(&test_value->type.Time,
                        &value->type.Time) == 0)
                    status = true;
                break;
#endif
#if defined (BACAPP_OBJECT_ID)
            case BACNET_APPLICATION_TAG_OBJECT_ID:
                if ((test_value->type.Object_Id.type ==
                        value->type.Object_Id.type) &&
                    (test_value->type.Object_Id.instance ==
                        value->type.Object_Id.instance)) {
                    status = true;
                }
                break;
#endif
#if defined (BACAPP_CHARACTER_STRING)
            case BACNET_APPLICATION_TAG_CHARACTER_STRING:
                status =
                    characterstring_same(&value->type.Character_String,
                    &test_value->type.Character_String);
                break;
#endif
#if defined (BACAPP_OCTET_STRING)
            case BACNET_APPLICATION_TAG_OCTET_STRING:
                status =
                    octetstring_value_same(&value->type.Octet_String,
                    &test_value->type.Octet_String);
                break;
#endif
#if defined (BACAPP_BIT_STRING)
            case BACNET_APPLICATION_TAG_BIT_STRING:
                status =
                    bitstring_same(&value->type.Bit_String,
                    &test_value->type.Bit_String);
                break;
#endif
#if defined (BACAPP_LIGHTING_COMMAND)
            case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
                status = lighting_command_same(
                    &value->type.Lighting_Command,
                    &test_value->type.Lighting_Command);
                break;
#endif
            default:
                status = false;
                break;
        }
    }
    return status;
}
bool bacapp_same_value ( BACNET_APPLICATION_DATA_VALUE * value , BACNET_APPLICATION_DATA_VALUE * test_value ) { bool status = false ; if ( test_value -> tag == value -> tag ) status = true ; if ( status ) { status = false ; switch ( test_value -> tag ) { #if defined ( BACAPP_NULL ) case BACNET_APPLICATION_TAG_NULL : status = true ; break ; #endif #if defined ( BACAPP_BOOLEAN ) case BACNET_APPLICATION_TAG_BOOLEAN : if ( test_value -> type . Boolean == value -> type . Boolean ) status = true ; break ; #endif #if defined ( BACAPP_UNSIGNED ) case BACNET_APPLICATION_TAG_UNSIGNED_INT : if ( test_value -> type . Unsigned_Int == value -> type . Unsigned_Int ) status = true ; break ; #endif #if defined ( BACAPP_SIGNED ) case BACNET_APPLICATION_TAG_SIGNED_INT : if ( test_value -> type . Signed_Int == value -> type . Signed_Int ) status = true ; break ; #endif #if defined ( BACAPP_REAL ) case BACNET_APPLICATION_TAG_REAL : if ( test_value -> type . Real == value -> type . Real ) status = true ; break ; #endif #if defined ( BACAPP_DOUBLE ) case BACNET_APPLICATION_TAG_DOUBLE : if ( test_value -> type . Double == value -> type . Double ) status = true ; break ; #endif #if defined ( BACAPP_ENUMERATED ) case BACNET_APPLICATION_TAG_ENUMERATED : if ( test_value -> type . Enumerated == value -> type . Enumerated ) status = true ; break ; #endif #if defined ( BACAPP_DATE ) case BACNET_APPLICATION_TAG_DATE : if ( datetime_compare_date ( & test_value -> type . Date , & value -> type . Date ) == 0 ) status = true ; break ; #endif #if defined ( BACAPP_TIME ) case BACNET_APPLICATION_TAG_TIME : if ( datetime_compare_time ( & test_value -> type . Time , & value -> type . Time ) == 0 ) status = true ; break ; #endif #if defined ( BACAPP_OBJECT_ID ) case BACNET_APPLICATION_TAG_OBJECT_ID : if ( ( test_value -> type . Object_Id . type == value -> type . Object_Id . type ) && ( test_value -> type . Object_Id . instance == value -> type . Object_Id . instance ) ) { status = true ; } break ; #endif #if defined ( BACAPP_CHARACTER_STRING ) case BACNET_APPLICATION_TAG_CHARACTER_STRING : status = characterstring_same ( & value -> type . Character_String , & test_value -> type . Character_String ) ; break ; #endif #if defined ( BACAPP_OCTET_STRING ) case BACNET_APPLICATION_TAG_OCTET_STRING : status = octetstring_value_same ( & value -> type . Octet_String , & test_value -> type . Octet_String ) ; break ; #endif #if defined ( BACAPP_BIT_STRING ) case BACNET_APPLICATION_TAG_BIT_STRING : status = bitstring_same ( & value -> type . Bit_String , & test_value -> type . Bit_String ) ; break ; #endif #if defined ( BACAPP_LIGHTING_COMMAND ) case BACNET_APPLICATION_TAG_LIGHTING_COMMAND : status = lighting_command_same ( & value -> type . Lighting_Command , & test_value -> type . Lighting_Command ) ; break ; #endif default : status = false ; break ; } } return status ; }
generic - can be used by other unit tests
returns true if matching or same, false if different
generic - can be used by other unit tests returns true if matching or same false if different
/*return value */ /* does the tag match? */ /* second test for same-ness */ /* does the value match? */