targets/var_access.c
author Edouard Tisserant
Thu, 26 Sep 2019 09:33:49 +0200
branchsvghmi
changeset 2786 1b82f21b2b41
parent 2767 302347f48193
child 2710 aaa1dc426213
permissions -rw-r--r--
SVGHMI: new test svg to drive next implementation
2767
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     1
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     2
#define __Unpack_case_t(TYPENAME) \
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     3
        case TYPENAME##_ENUM :\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     4
            *flags = ((__IEC_##TYPENAME##_t *)varp)->flags;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     5
            forced_value_p = *real_value_p = &((__IEC_##TYPENAME##_t *)varp)->value;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     6
            break;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     7
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     8
#define __Unpack_case_p(TYPENAME)\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     9
        case TYPENAME##_O_ENUM :\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    10
            *flags = __IEC_OUTPUT_FLAG;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    11
        case TYPENAME##_P_ENUM :\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    12
            *flags |= ((__IEC_##TYPENAME##_p *)varp)->flags;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    13
            *real_value_p = ((__IEC_##TYPENAME##_p *)varp)->value;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    14
            forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    15
            break;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    16
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    17
static void* UnpackVar(__Unpack_desc_type *dsc, void **real_value_p, char *flags)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    18
{
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    19
    void *varp = dsc->ptr;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    20
    void *forced_value_p = NULL;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    21
    *flags = 0;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    22
    /* find data to copy*/
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    23
    switch(dsc->type){
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    24
        __ANY(__Unpack_case_t)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    25
        __ANY(__Unpack_case_p)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    26
    default:
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    27
        break;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    28
    }
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    29
    if (*flags & __IEC_FORCE_FLAG)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    30
        return forced_value_p;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    31
    return *real_value_p;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    32
}
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    33