targets/var_access.c
author Edouard Tisserant <edouard.tisserant@gmail.com>
Wed, 30 Jun 2021 15:51:59 +0200
branchsvghmi
changeset 3267 5f20f391ae31
parent 2710 aaa1dc426213
child 3395 93ad018fb602
permissions -rw-r--r--
SVGHMI: Prepare accepting multiple clients on multiple HMI: Use POULibrary new capability to add variables to PLC Configuration. Now heartbeat and HMI tree root are added by the library part of SVGHMI, and not by each instance.
2632
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     1
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     2
#define __Unpack_case_t(TYPENAME) \
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     3
        case TYPENAME##_ENUM :\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     4
            *flags = ((__IEC_##TYPENAME##_t *)varp)->flags;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     5
            forced_value_p = *real_value_p = &((__IEC_##TYPENAME##_t *)varp)->value;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     6
            break;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     7
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     8
#define __Unpack_case_p(TYPENAME)\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     9
        case TYPENAME##_O_ENUM :\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    10
            *flags = __IEC_OUTPUT_FLAG;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    11
        case TYPENAME##_P_ENUM :\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    12
            *flags |= ((__IEC_##TYPENAME##_p *)varp)->flags;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    13
            *real_value_p = ((__IEC_##TYPENAME##_p *)varp)->value;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    14
            forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    15
            break;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    16
2710
aaa1dc426213 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2632
diff changeset
    17
#define __Is_a_string(dsc) (dsc->type == STRING_ENUM)   ||\
aaa1dc426213 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2632
diff changeset
    18
                           (dsc->type == STRING_P_ENUM) ||\
aaa1dc426213 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2632
diff changeset
    19
                           (dsc->type == STRING_O_ENUM)
aaa1dc426213 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2632
diff changeset
    20
2632
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    21
static void* UnpackVar(__Unpack_desc_type *dsc, void **real_value_p, char *flags)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    22
{
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    23
    void *varp = dsc->ptr;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    24
    void *forced_value_p = NULL;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    25
    *flags = 0;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    26
    /* find data to copy*/
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    27
    switch(dsc->type){
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    28
        __ANY(__Unpack_case_t)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    29
        __ANY(__Unpack_case_p)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    30
    default:
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    31
        break;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    32
    }
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    33
    if (*flags & __IEC_FORCE_FLAG)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    34
        return forced_value_p;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    35
    return *real_value_p;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    36
}
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    37