runtime/plc_common_main.c
author etisserant
Mon, 24 Sep 2007 17:08:54 +0200
changeset 54 ff82e7088ec5
parent 49 45dc6a944ab6
child 57 3b53f9a509d9
permissions -rw-r--r--
Comments...
/*
 * 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;

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

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

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