runtime/plc_common_main.c
author lbessard
Tue, 02 Oct 2007 18:05:36 +0200
changeset 60 e9667bec7f00
parent 57 3b53f9a509d9
child 137 187a4e2412e5
permissions -rw-r--r--
Test on wx version changed to test on platform
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;
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 54
diff changeset
    28
static int init_level=0;
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    29
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    30
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    31
 * Prototypes of funcions exported by plugins 
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    32
 **/
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    33
%(calls_prototypes)s
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    34
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    35
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    36
 * Retrive input variables, run PLC and publish output variables 
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    37
 **/
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    38
void __run()
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    39
{
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    40
    %(retrive_calls)s
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    41
    
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    42
    config_run__(tick++);
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    43
    
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    44
    %(publish_calls)s
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    45
}
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    46
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    47
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    48
 * Initialize variables according to PLC's defalut values,
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    49
 * and then init plugins with that values  
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    50
 **/
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 54
diff changeset
    51
int __init(int argc,char **argv)
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    52
{
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 54
diff changeset
    53
    int res;
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    54
    config_init__();
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    55
    %(init_calls)s
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 54
diff changeset
    56
    return 0;
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    57
}
54
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    58
/*
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    59
 * Calls plugin cleanup proc.
ff82e7088ec5 Comments...
etisserant
parents: 49
diff changeset
    60
 **/
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    61
void __cleanup()
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    62
{
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    63
    %(cleanup_calls)s
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    64
}
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    65