targets/plc_common_main.c
changeset 280 f2ef79f3dba0
parent 245 60a221d72152
child 286 a2a8a52b0d4f
equal deleted inserted replaced
279:47d29c4b55a3 280:f2ef79f3dba0
     1 /*
     1 /**
     2  * Prototypes for function provided by arch-specific code (main)
     2  * Code common to all C targets
     3  * concatained after this template
     3  **/ 
     4  ** /
       
     5 
     4 
       
     5 #include "iec_types.h"
     6 
     6 
     7 /*
     7 /*
     8  * Functions and variables provied by generated C softPLC
     8  * Prototypes of functions provied by generated C softPLC
     9  **/ 
       
    10 extern int common_ticktime__;
       
    11 
       
    12 /*
       
    13  * Functions and variables provied by plc.c
       
    14  **/ 
       
    15 void run(long int tv_sec, long int tv_nsec);
       
    16 
       
    17 #define maxval(a,b) ((a>b)?a:b)
       
    18 
       
    19 #include "iec_types.h"
       
    20 /*#include "stdio.h" /* For debug */
       
    21 
       
    22 /*
       
    23  * Functions and variables provied by generated C softPLC
       
    24  **/ 
     9  **/ 
    25 void config_run__(int tick);
    10 void config_run__(int tick);
    26 void config_init__(void);
    11 void config_init__(void);
       
    12 
       
    13 /*
       
    14  * Prototypes of functions provied by generated target C code
       
    15  * */
    27 void __init_debug(void);
    16 void __init_debug(void);
    28 void __cleanup_debug(void);
    17 void __cleanup_debug(void);
       
    18 /*void __retrieve_debug(void);*/
       
    19 void __publish_debug(void);
    29 
    20 
       
    21 void __init_python(void);
       
    22 void __cleanup_python(void);
       
    23 void __retrieve_python(void);
       
    24 void __publish_python(void);
    30 
    25 
    31 /*
    26 /*
    32  *  Functions and variables to export to generated C softPLC and plugins
    27  *  Variables used by generated C softPLC and plugins
    33  **/
    28  **/
    34  
       
    35 IEC_TIME __CURRENT_TIME;
    29 IEC_TIME __CURRENT_TIME;
    36 IEC_BOOL __DEBUG;
       
    37 int __tick = -1;
    30 int __tick = -1;
    38 
    31 
       
    32 /* Help to quit cleanly when init fail at a certain level */
    39 static int init_level = 0;
    33 static int init_level = 0;
    40 
    34 
    41 /*
    35 /*
    42  * Prototypes of functions exported by plugins 
    36  * Prototypes of functions exported by plugins 
    43  **/
    37  **/
    50 {
    44 {
    51     __tick++;
    45     __tick++;
    52 
    46 
    53     %(retrieve_calls)s
    47     %(retrieve_calls)s
    54 
    48 
       
    49     __retrieve_python();
       
    50 
    55     /*__retrieve_debug();*/
    51     /*__retrieve_debug();*/
    56     
    52     
    57     config_run__(__tick);
    53     config_run__(__tick);
       
    54 
       
    55     __publish_python();
    58 
    56 
    59     __publish_debug();
    57     __publish_debug();
    60     
    58     
    61     %(publish_calls)s
    59     %(publish_calls)s
    62 
    60 
   167 			/* DO ALIGNEMENT */
   165 			/* DO ALIGNEMENT */
   168 			PLC_SetTimer(Tcorr - elapsed, PeriodicTcorr);
   166 			PLC_SetTimer(Tcorr - elapsed, PeriodicTcorr);
   169 		}
   167 		}
   170 	}
   168 	}
   171 }
   169 }
       
   170 
       
   171 /**
       
   172  * Prototypes for function provided by arch-specific code (main)
       
   173  * is concatained hereafter
       
   174  **/