etisserant@0: /* etisserant@0: * (c) 2003 Mario de Sousa etisserant@0: * etisserant@0: * Offered to the public under the terms of the GNU General Public License etisserant@0: * as published by the Free Software Foundation; either version 2 of the etisserant@0: * License, or (at your option) any later version. etisserant@0: * etisserant@0: * This program is distributed in the hope that it will be useful, but etisserant@0: * WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General etisserant@0: * Public License for more details. etisserant@0: * etisserant@0: * This code is made available on the understanding that it will not be etisserant@0: * used in safety-critical situations without a full and competent review. etisserant@0: */ etisserant@0: etisserant@0: /* etisserant@0: * An IEC 61131-3 IL and ST compiler. etisserant@0: * etisserant@0: * Based on the etisserant@0: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) etisserant@0: * etisserant@0: */ etisserant@0: etisserant@0: etisserant@0: /* etisserant@0: * Code to be included into the code generated by the 4th stage. etisserant@0: * etisserant@0: * This is part of the 4th stage that generates etisserant@0: * a c++ source program equivalent to the IL and ST etisserant@0: * code. etisserant@0: */ etisserant@0: etisserant@0: etisserant@0: TIME __CURRENT_TIME; etisserant@0: etisserant@0: int main(int argc, char **argv) { etisserant@0: struct timespec tp; etisserant@0: etisserant@0: if (plc_init(DEFAULT_MODULE_NAME, argc, argv) < 0) { etisserant@0: printf("Error connecting to PLC.\n"); etisserant@0: exit(EXIT_FAILURE); etisserant@0: } etisserant@0: __configuration_c config; etisserant@0: /* loop... */ etisserant@0: while (1) { etisserant@0: plc_scan_beg(); etisserant@0: plc_update(); etisserant@0: if (clock_gettime(CLOCK_REALTIME, &tp) < 0) etisserant@0: IEC_error(); etisserant@0: __CURRENT_TIME = tp; etisserant@0: config.run(); etisserant@0: plc_update(); etisserant@0: plc_scan_end(); etisserant@0: } /* while (1) */ etisserant@0: return -1; etisserant@0: } etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: