tests/plc.c
changeset 132 39f88c3d803d
parent 57 db9cadaab2ea
child 279 c0453b7f99df
equal deleted inserted replaced
131:f55ef301e14c 132:39f88c3d803d
     1 #include "iec_std_lib.h"
     1 #include "iec_std_lib.h"
     2 #include <stdio.h>
     2 #include <stdio.h>
     3 
     3 
       
     4 #define __print_BOOL(name) printf("  %s = (BOOL) %s\n",#name, name?"TRUE":"FALSE");
       
     5 #define __print_SINT(name) printf("  %s = (SINT) %d\n",#name, name);
       
     6 #define __print_INT(name) printf("  %s = (INT) %d\n",#name, name);
       
     7 #define __print_DINT(name) printf("  %s = (DINT) %d\n",#name, name);
       
     8 #define __print_LINT(name) printf("  %s = (LINT) %d\n",#name, name);
       
     9 #define __print_USINT(name) printf("  %s = (USINT) %u\n",#name, name);
       
    10 #define __print_UINT(name) printf("  %s = (UINT) %u\n",#name, name);
       
    11 #define __print_UDINT(name) printf("  %s = (UDINT) %u\n",#name, name);
       
    12 #define __print_ULINT(name) printf("  %s = (ULINT) %lu\n",#name, name);
       
    13 #define __print_REAL(name) printf("  %s = (REAL) %f\n",#name, (double)name);
       
    14 #define __print_LREAL(name) printf("  %s = (LREAL) %f\n",#name, (double)name);
       
    15 #define __print_TIME(name) {STRING __tmp = __time_to_string(name);__tmp.body[__tmp.len] = 0; printf("  %s = (TIME) %*s\n",#name, __tmp.len, &__tmp.body);}
       
    16 #define __print_DATE(name) {STRING __tmp = __date_to_string(name);__tmp.body[__tmp.len] = 0; printf("  %s = (DATE) %*s\n",#name, __tmp.len, &__tmp.body);}
       
    17 #define __print_TOD(name) {STRING __tmp = __tod_to_string(name);__tmp.body[__tmp.len] = 0; printf("  %s = (TOD) %*s\n",#name, __tmp.len, &__tmp.body);}
       
    18 #define __print_DT(name) {STRING __tmp = __dt_to_string(name);__tmp.body[__tmp.len] = 0; printf("  %s = (DT) %*s\n",#name, __tmp.len, &__tmp.body);}
       
    19 #define __print_STRING(name) printf("  %s = (STRING) {%d, \"%*s\"}\n",#name, name->len, name->len, &name->body);
       
    20 #define __print_BYTE(name) printf("  %s = (BYTE) 0x%2.2x\n",#name, name);
       
    21 #define __print_WORD(name) printf("  %s = (WORD) 0x%4.4x\n",#name, name);
       
    22 #define __print_DWORD(name) printf("  %s = (DWORD) 0x%8.8x\n",#name, name);
       
    23 #define __print_LWORD(name) printf("  %s = (LWORD) 0x%16.16lx\n",#name, name);
     4 /*
    24 /*
     5  * Functions and variables provied by generated C softPLC
    25  * Functions and variables provied by generated C softPLC
     6  **/ 
    26  **/ 
     7 void config_run__(int tick);
    27 void config_run__(int tick);
     8 void config_init__(void);
    28 void config_init__(void);
    11  *  Functions and variables to export to generated C softPLC
    31  *  Functions and variables to export to generated C softPLC
    12  **/
    32  **/
    13  
    33  
    14 TIME __CURRENT_TIME;
    34 TIME __CURRENT_TIME;
    15 
    35 
    16 #define __LOCATED_VAR(type, name, ...) type name;
    36 #define __LOCATED_VAR(type, name, ...) type __##name;
       
    37 #include "LOCATED_VARIABLES.h"
       
    38 #undef __LOCATED_VAR
       
    39 #define __LOCATED_VAR(type, name, ...) type* name = &__##name;
    17 #include "LOCATED_VARIABLES.h"
    40 #include "LOCATED_VARIABLES.h"
    18 #undef __LOCATED_VAR
    41 #undef __LOCATED_VAR
    19 
    42 
    20 static int tick = 0;
    43 static int tick = 0;
    21 
    44