stage4/generate_cc/plciec.cc
changeset 0 fb772792efd1
equal deleted inserted replaced
-1:000000000000 0:fb772792efd1
       
     1 /*
       
     2  * (c) 2003 Mario de Sousa
       
     3  *
       
     4  * Offered to the public under the terms of the GNU General Public License
       
     5  * as published by the Free Software Foundation; either version 2 of the
       
     6  * License, or (at your option) any later version.
       
     7  *
       
     8  * This program is distributed in the hope that it will be useful, but
       
     9  * WITHOUT ANY WARRANTY; without even the implied warranty of
       
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
       
    11  * Public License for more details.
       
    12  *
       
    13  * This code is made available on the understanding that it will not be
       
    14  * used in safety-critical situations without a full and competent review.
       
    15  */
       
    16 
       
    17 /*
       
    18  * An IEC 61131-3 IL and ST compiler.
       
    19  *
       
    20  * Based on the
       
    21  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    22  *
       
    23  */
       
    24 
       
    25 
       
    26 /*
       
    27  * Code to be included into the code generated by the 4th stage.
       
    28  *
       
    29  * This is part of the 4th stage that generates
       
    30  * a c++ source program equivalent to the IL and ST
       
    31  * code.
       
    32  */
       
    33 
       
    34 
       
    35 TIME __CURRENT_TIME;
       
    36 
       
    37 int main(int argc, char **argv) {
       
    38   struct timespec tp;
       
    39 
       
    40   if (plc_init(DEFAULT_MODULE_NAME, argc, argv) < 0) {
       
    41       printf("Error connecting to PLC.\n");
       
    42       exit(EXIT_FAILURE);
       
    43   }
       
    44   __configuration_c config;
       
    45   /* loop... */
       
    46   while (1) {
       
    47     plc_scan_beg();
       
    48     plc_update();
       
    49     if (clock_gettime(CLOCK_REALTIME, &tp) < 0)
       
    50       IEC_error();
       
    51     __CURRENT_TIME = tp;
       
    52     config.run();
       
    53     plc_update();
       
    54     plc_scan_end();
       
    55   } /* while (1) */
       
    56 return -1;
       
    57 }
       
    58 
       
    59 
       
    60 
       
    61 
       
    62