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...
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     1
/*
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     2
 * Functions and variables provied by generated C softPLC
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     3
 **/ 
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     4
extern int common_ticktime__;
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     5
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     6
/*
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     7
 * Functions and variables provied by plc.c
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     8
 **/ 
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
     9
void run(long int tv_sec, long int tv_nsec);
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    10
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    11
#define maxval(a,b) ((a>b)?a:b)
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    12
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    13
#include "iec_types.h"
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    14
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    15
/*
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    16
 * Functions and variables provied by generated C softPLC
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    17
 **/ 
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    18
void config_run__(int tick);
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    19
void config_init__(void);
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    20
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    21
/*
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    22
 *  Functions and variables to export to generated C softPLC
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    23
 **/
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    24
 
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    25
IEC_TIME __CURRENT_TIME;
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    26
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    27
static int tick = 0;
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    28
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    29
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    30
 * Prototypes of funcions exported by plugins 
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    31
 **/
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    32
%(calls_prototypes)s
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    33
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    34
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    35
 * Retrive input variables, run PLC and publish output variables 
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    36
 **/
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    37
void __run()
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    38
{
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    39
    %(retrive_calls)s
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    40
    
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    41
    config_run__(tick++);
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    42
    
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    43
    %(publish_calls)s
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    44
}
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    45
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    46
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    47
 * Initialize variables according to PLC's defalut values,
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    48
 * and then init plugins with that values  
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    49
 **/
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    50
void __init()
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    51
{
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    52
    config_init__();
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    53
    %(init_calls)s
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    54
}
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    55
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    56
 * Calls plugin cleanup proc.
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    57
 **/
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    58
void __cleanup()
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    59
{
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    60
    %(cleanup_calls)s
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    61
}
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    62