runtime/plc_common_main.c
author lbessard
Wed, 25 Jun 2008 17:32:53 +0200
changeset 172 8eefeccbd021
parent 137 187a4e2412e5
child 178 2390b409eb93
permissions -rw-r--r--
Adding support for modification in CanFestival eds_utils
/*
 * Functions and variables provied by generated C softPLC
 **/ 
extern int common_ticktime__;

/*
 * Functions and variables provied by plc.c
 **/ 
void run(long int tv_sec, long int tv_nsec);

#define maxval(a,b) ((a>b)?a:b)

#include "iec_types.h"

/*
 * Functions and variables provied by generated C softPLC
 **/ 
void config_run__(int tick);
void config_init__(void);

/*
 *  Functions and variables to export to generated C softPLC
 **/
 
IEC_TIME __CURRENT_TIME;

static int tick = 0;
static int init_level=0;

/*
 * Prototypes of functions exported by plugins 
 **/
%(calls_prototypes)s

/*
 * Retrieve input variables, run PLC and publish output variables 
 **/
void __run()
{
    %(retrieve_calls)s
    
    config_run__(tick++);
    
    %(publish_calls)s
}

/*
 * Initialize variables according to PLC's defalut values,
 * and then init plugins with that values  
 **/
int __init(int argc,char **argv)
{
    int res;
    config_init__();
    %(init_calls)s
    return 0;
}
/*
 * Calls plugin cleanup proc.
 **/
void __cleanup()
{
    %(cleanup_calls)s
}