Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
(*
* (c) 2005 Mario de Sousa
*
* Offered to the public under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*)
(*
* An IEC 61131-3 IL and ST compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
*
*)
(*
* This is part of the library conatining the functions
* and function blocks defined in the standard.
*
* Math functions on Time and Date data types.
* -------------------------------------------
*
* We also include the two data type conversions defined in table 30 of the IEC 61131-3 standard (version
*)
(* NOTE: The IEC 61131-3 standard library includes overloaded functions, which are not
* allowed in user code. Since our compiler does not yet support overloaded functions, these
* are commented out in the following library for the moment...
*)
(***************)
(* TIME + TIME *)
(***************)
FUNCTION ADD : TIME
VAR_INPUT
IN1 : TIME;
IN2 : TIME;
END_VAR
ADD := IN1 + IN2;
END_FUNCTION
FUNCTION ADD_TIME : TIME
VAR_INPUT
IN1 : TIME;
IN2 : TIME;
END_VAR
ADD_TIME := IN1 + IN2;
END_FUNCTION
FUNCTION SUB : TIME
VAR_INPUT
IN1 : TIME;
IN2 : TIME;
END_VAR
SUB := IN1 - IN2;
END_FUNCTION
FUNCTION SUB_TIME : TIME
VAR_INPUT
IN1 : TIME;
IN2 : TIME;
END_VAR
SUB_TIME := IN1 - IN2;
END_FUNCTION
(**************)
(* TIME + TOD *)
(**************)
FUNCTION ADD : TOD
VAR_INPUT
IN1 : TOD;
IN2 : TIME;
END_VAR
ADD := IN1 + IN2;
END_FUNCTION
(* The following function is not defined in the standard, but its existance makes sense. *)
FUNCTION ADD : TOD
VAR_INPUT
IN1 : TIME;
IN2 : TOD;
END_VAR
ADD := IN1 + IN2;
END_FUNCTION
FUNCTION ADD_TOD_TIME : TOD
VAR_INPUT
IN1 : TOD;
IN2 : TIME;
END_VAR
ADD_TOD_TIME := IN1 + IN2;
END_FUNCTION
FUNCTION SUB : TOD
VAR_INPUT
IN1 : TOD;
IN2 : TIME;
END_VAR
SUB := IN1 - IN2;
END_FUNCTION
FUNCTION SUB_TOD_TIME : TOD
VAR_INPUT
IN1 : TOD;
IN2 : TIME;
END_VAR
SUB_TOD_TIME := IN1 - IN2;
END_FUNCTION
(*************)
(* TIME + DT *)
(*************)
FUNCTION ADD : DT
VAR_INPUT
IN1 : DT;
IN2 : TIME;
END_VAR
ADD := IN1 + IN2;
END_FUNCTION
(* The following function is not defined in the standard, but its existance makes sense. *)
FUNCTION ADD : DT
VAR_INPUT
IN1 : TIME;
IN2 : DT;
END_VAR
ADD := IN1 + IN2;
END_FUNCTION
FUNCTION ADD_DT_TIME : DT
VAR_INPUT
IN1 : DT;
IN2 : TIME;
END_VAR
ADD_DT_TIME := IN1 + IN2;
END_FUNCTION
(***************)
(* DATE + DATE *)
(***************)
FUNCTION SUB : TIME
VAR_INPUT
IN1 : DATE;
IN2 : DATE;
END_VAR
SUB := IN1 - IN2;
END_FUNCTION
FUNCTION SUB_DATE_DATE : TIME
VAR_INPUT
IN1 : DATE;
IN2 : DATE;
END_VAR
SUB_DATE_DATE := IN1 - IN2;
END_FUNCTION
(*************)
(* TOD + TOD *)
(*************)
FUNCTION SUB : TIME
VAR_INPUT
IN1 : TOD;
IN2 : TOD;
END_VAR
SUB := IN1 - IN2;
END_FUNCTION
FUNCTION SUB_TOD_TOD : TIME
VAR_INPUT
IN1 : TOD;
IN2 : TOD;
END_VAR
SUB_TOD_TOD := IN1 - IN2;
END_FUNCTION
(*************)
(* TIME + DT *)
(*************)
FUNCTION SUB : DT
VAR_INPUT
IN1 : DT;
IN2 : TIME;
END_VAR
SUB := IN1 - IN2;
END_FUNCTION
FUNCTION SUB_DT_TIME : DT
VAR_INPUT
IN1 : DT;
IN2 : TIME;
END_VAR
SUB_DT_TIME := IN1 - IN2;
END_FUNCTION
(***********)
(* DT + DT *)
(***********)
FUNCTION SUB : TIME
VAR_INPUT
IN1 : DT;
IN2 : DT;
END_VAR
SUB := IN1 - IN2;
END_FUNCTION
FUNCTION SUB_DT_DT : TIME
VAR_INPUT
IN1 : DT;
IN2 : DT;
END_VAR
SUB_DT_DT := IN1 - IN2;
END_FUNCTION
(******************)
(* TIME * ANY_NUM *)
(******************)
FUNCTION MUL : TIME
VAR_INPUT
IN1 : TIME;
IN2 : LREAL;
END_VAR
MUL := IN1 * IN2;
END_FUNCTION
FUNCTION MULTIME : TIME
VAR_INPUT
IN1 : TIME;
IN2 : LREAL;
END_VAR
MULTIME := IN1 * IN2;
END_FUNCTION
FUNCTION DIV : TIME
VAR_INPUT
IN1 : TIME;
IN2 : LREAL;
END_VAR
DIV := IN1 / IN2;
END_FUNCTION
FUNCTION DIVTIME : TIME
VAR_INPUT
IN1 : TIME;
IN2 : LREAL;
END_VAR
DIVTIME := IN1 / IN2;
END_FUNCTION
(*************)
(* DATE + DT *)
(*************)
FUNCTION CONCAT_DATE_TOD : DT
VAR_INPUT
IN1 : DATE;
IN2 : TOD;
END_VAR
CONCAT_DATE_TOD := IN1 + IN2;
END_FUNCTION
(*************************)
(* Data Type Conversions *)
(*************************)
FUNCTION DT_TO_DATE : DATE
VAR_INPUT
IN1 : DT;
END_VAR
{DT_TO_DATE = IN1.__to_DATE();}
END_FUNCTION
FUNCTION DT_TO_TOD : TOD
VAR_INPUT
IN1 : DT;
END_VAR
{DT_TO_TOD = IN1.__to_TOD();}
END_FUNCTION