fix issue #73: add missing overloaded functions ADD, SUB, MUL and DIV for TIME, TOD, DT, ...
authorMario de Sousa <msousa@fe.up.pt>
Wed, 26 Dec 2018 19:36:03 +0000
changeset 1085 9766936990db
parent 1084 54f72ee52708
child 1086 ee66a14e38f7
fix issue #73: add missing overloaded functions ADD, SUB, MUL and DIV for TIME, TOD, DT, ...
lib/C/iec_std_functions.h
lib/create_standard_function_txt.sh
lib/standard_functions.txt
--- a/lib/C/iec_std_functions.h	Wed Dec 26 12:39:41 2018 +0000
+++ b/lib/C/iec_std_functions.h	Wed Dec 26 19:36:03 2018 +0000
@@ -1752,46 +1752,100 @@
   return __time_add(IN1, IN2);
 }
 
+/* overloaded version of ADD(TIME, TIME) */
+static inline TIME ADD__TIME__TIME__TIME(EN_ENO_PARAMS TIME IN1, TIME IN2){
+  TEST_EN(TIME)
+  return __time_add(IN1, IN2);
+}
+
 static inline TOD ADD_TOD_TIME(EN_ENO_PARAMS TOD IN1, TIME IN2){
   TEST_EN(TOD)
   return __time_add(IN1, IN2);
 }
 
+/* overloaded version of ADD(TOD, TIME) */
+static inline TOD ADD__TOD__TOD__TIME(EN_ENO_PARAMS TOD IN1, TIME IN2){
+  TEST_EN(TIME)
+  return __time_add(IN1, IN2);
+}
+
 static inline DT ADD_DT_TIME(EN_ENO_PARAMS DT IN1, TIME IN2){
   TEST_EN(DT)
   return __time_add(IN1, IN2);
 }
 
+/* overloaded version of ADD(DT, TIME) */
+static inline DT ADD__DT__DT__TIME(EN_ENO_PARAMS DT IN1, TIME IN2){
+  TEST_EN(TIME)
+  return __time_add(IN1, IN2);
+}
+
 static inline TIME SUB_TIME(EN_ENO_PARAMS TIME IN1, TIME IN2){
   TEST_EN(TIME)
   return __time_sub(IN1, IN2);
 }
 
+/* overloaded version of SUB(TIME, TIME) */
+static inline TIME SUB__TIME__TIME__TIME(EN_ENO_PARAMS TIME IN1, TIME IN2){
+  TEST_EN(TIME)
+  return __time_sub(IN1, IN2);
+}
+
 static inline TIME SUB_DATE_DATE(EN_ENO_PARAMS DATE IN1, DATE IN2){
   TEST_EN(TIME)
   return __time_sub(IN1, IN2);
 }
 
+/* overloaded version of SUB(DATE, DATE) */
+static inline TIME SUB__TIME__DATE__DATE(EN_ENO_PARAMS DATE IN1, DATE IN2){
+  TEST_EN(TIME)
+  return __time_sub(IN1, IN2);
+}
+
 static inline TOD SUB_TOD_TIME(EN_ENO_PARAMS TOD IN1, TIME IN2){
   TEST_EN(TOD)
   return __time_sub(IN1, IN2);
 }
 
+/* overloaded version of SUB(TOD, TIME) */
+static inline TOD SUB__TOD__TOD__TIME(EN_ENO_PARAMS TOD IN1, TIME IN2){
+  TEST_EN(TOD)
+  return __time_sub(IN1, IN2);
+}
+
 static inline TIME SUB_TOD_TOD(EN_ENO_PARAMS TOD IN1, TOD IN2){
   TEST_EN(TIME)
   return __time_sub(IN1, IN2);
 }
 
+/* overloaded version of SUB(TOD, TOD) */
+static inline TIME SUB__TIME__TOD__TOD(EN_ENO_PARAMS TOD IN1, TOD IN2){
+  TEST_EN(TIME)
+  return __time_sub(IN1, IN2);
+}
+
 static inline DT SUB_DT_TIME(EN_ENO_PARAMS DT IN1, TIME IN2){
   TEST_EN(DT)
   return __time_sub(IN1, IN2);
 }
 
+/* overloaded version of SUB(DT, TIME) */
+static inline DT SUB__DT__DT__TIME(EN_ENO_PARAMS DT IN1, TIME IN2){
+  TEST_EN(DT)
+  return __time_sub(IN1, IN2);
+}
+
 static inline TIME SUB_DT_DT(EN_ENO_PARAMS DT IN1, DT IN2){
   TEST_EN(TIME)
   return __time_sub(IN1, IN2);
 }
 
+/* overloaded version of SUB(DT, DT) */
+static inline TIME SUB__TIME__DT__DT(EN_ENO_PARAMS DT IN1, DT IN2){
+  TEST_EN(TIME)
+  return __time_sub(IN1, IN2);
+}
+
 
 /***  MULTIME  ***/
 #define __iec_(TYPENAME)\
@@ -1802,6 +1856,15 @@
 __ANY_NUM(__iec_)
 #undef __iec_
 
+/***  MULTIME_TYPENAME  ***/
+#define __iec_(TYPENAME)\
+static inline TIME MULTIME_##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
+  TEST_EN(TIME)\
+  return __time_mul(IN1, (LREAL)IN2);\
+}
+__ANY_NUM(__iec_)
+#undef __iec_
+
 /***  MUL  ***/
 #define __iec_(TYPENAME)\
 static inline TIME MUL__TIME__TIME__##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
@@ -1820,6 +1883,15 @@
 __ANY_NUM(__iec_)
 #undef __iec_
 
+/***  DIVTIME_TYPENAME  ***/
+#define __iec_(TYPENAME)\
+static inline TIME DIVTIME_##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
+  TEST_EN(TIME)\
+  return __time_div(IN1, (LREAL)IN2);\
+}
+__ANY_NUM(__iec_)
+#undef __iec_
+
 /***  DIV  ***/
 #define __iec_(TYPENAME)\
 static inline TIME DIV__TIME__TIME__##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
--- a/lib/create_standard_function_txt.sh	Wed Dec 26 12:39:41 2018 +0000
+++ b/lib/create_standard_function_txt.sh	Wed Dec 26 19:36:03 2018 +0000
@@ -836,16 +836,25 @@
 /***  Functions of time data types  ***/
 /**************************************/
 
-__function_2p(ADD_TIME, TIME, IN1, TIME, IN2, TIME)
-__function_2p(ADD_TOD_TIME, TOD, IN1, TOD, IN2, TIME)
-__function_2p(ADD_DT_TIME, DT, IN1, DT, IN2, TIME)
-
-__function_2p(SUB_TIME, TIME, IN1, TIME, IN2, TIME)
+__function_2p(ADD_TIME,      TIME, IN1, TIME, IN2, TIME)
+__function_2p(ADD,           TIME, IN1, TIME, IN2, TIME)       /* overloaded function */
+__function_2p(ADD_TOD_TIME,  TOD,  IN1, TOD,  IN2, TIME)
+__function_2p(ADD,           TOD,  IN1, TOD,  IN2, TIME)       /* overloaded function */
+__function_2p(ADD_DT_TIME,   DT,   IN1, DT,   IN2, TIME)
+__function_2p(ADD,           DT,   IN1, DT,   IN2, TIME)       /* overloaded function */
+
+__function_2p(SUB_TIME,      TIME, IN1, TIME, IN2, TIME)
+__function_2p(SUB,           TIME, IN1, TIME, IN2, TIME)       /* overloaded function */
 __function_2p(SUB_DATE_DATE, TIME, IN1, DATE, IN2, DATE)
-__function_2p(SUB_TOD_TIME, TOD, IN1, TOD, IN2, TIME)
-__function_2p(SUB_TOD_TOD, TIME, IN1, TOD, IN2, TOD)
-__function_2p(SUB_DT_TIME, DT, IN1, DT, IN2, TIME)
-__function_2p(SUB_DT_DT, TIME, IN1, DT, IN2, DT)
+__function_2p(SUB,           TIME, IN1, DATE, IN2, DATE)       /* overloaded function */
+__function_2p(SUB_TOD_TIME,  TOD,  IN1, TOD,  IN2, TIME)
+__function_2p(SUB,           TOD,  IN1, TOD,  IN2, TIME)       /* overloaded function */
+__function_2p(SUB_TOD_TOD,   TIME, IN1, TOD,  IN2, TOD )
+__function_2p(SUB,           TIME, IN1, TOD,  IN2, TOD )       /* overloaded function */
+__function_2p(SUB_DT_TIME,   DT,   IN1, DT,   IN2, TIME)
+__function_2p(SUB,           DT,   IN1, DT,   IN2, TIME)       /* overloaded function */
+__function_2p(SUB_DT_DT,     TIME, IN1, DT,   IN2, DT  )
+__function_2p(SUB,           TIME, IN1, DT,   IN2, DT  )       /* overloaded function */
 
 
 /***  MULTIME  ***/
--- a/lib/standard_functions.txt	Wed Dec 26 12:39:41 2018 +0000
+++ b/lib/standard_functions.txt	Wed Dec 26 19:36:03 2018 +0000
@@ -1763,15 +1763,24 @@
 FUNCTION FIND : UDINT VAR_INPUT IN1 : STRING; IN2 : STRING; END_VAR RETURN; END_FUNCTION
 FUNCTION FIND : ULINT VAR_INPUT IN1 : STRING; IN2 : STRING; END_VAR RETURN; END_FUNCTION
 FUNCTION ADD_TIME : TIME VAR_INPUT IN1 : TIME; IN2 : TIME; END_VAR RETURN; END_FUNCTION
+FUNCTION ADD : TIME VAR_INPUT IN1 : TIME; IN2 : TIME; END_VAR RETURN; END_FUNCTION
 FUNCTION ADD_TOD_TIME : TOD VAR_INPUT IN1 : TOD; IN2 : TIME; END_VAR RETURN; END_FUNCTION
+FUNCTION ADD : TOD VAR_INPUT IN1 : TOD; IN2 : TIME; END_VAR RETURN; END_FUNCTION
 FUNCTION ADD_DT_TIME : DT VAR_INPUT IN1 : DT; IN2 : TIME; END_VAR RETURN; END_FUNCTION
+FUNCTION ADD : DT VAR_INPUT IN1 : DT; IN2 : TIME; END_VAR RETURN; END_FUNCTION
 
 FUNCTION SUB_TIME : TIME VAR_INPUT IN1 : TIME; IN2 : TIME; END_VAR RETURN; END_FUNCTION
+FUNCTION SUB : TIME VAR_INPUT IN1 : TIME; IN2 : TIME; END_VAR RETURN; END_FUNCTION
 FUNCTION SUB_DATE_DATE : TIME VAR_INPUT IN1 : DATE; IN2 : DATE; END_VAR RETURN; END_FUNCTION
+FUNCTION SUB : TIME VAR_INPUT IN1 : DATE; IN2 : DATE; END_VAR RETURN; END_FUNCTION
 FUNCTION SUB_TOD_TIME : TOD VAR_INPUT IN1 : TOD; IN2 : TIME; END_VAR RETURN; END_FUNCTION
+FUNCTION SUB : TOD VAR_INPUT IN1 : TOD; IN2 : TIME; END_VAR RETURN; END_FUNCTION
 FUNCTION SUB_TOD_TOD : TIME VAR_INPUT IN1 : TOD; IN2 : TOD; END_VAR RETURN; END_FUNCTION
+FUNCTION SUB : TIME VAR_INPUT IN1 : TOD; IN2 : TOD; END_VAR RETURN; END_FUNCTION
 FUNCTION SUB_DT_TIME : DT VAR_INPUT IN1 : DT; IN2 : TIME; END_VAR RETURN; END_FUNCTION
+FUNCTION SUB : DT VAR_INPUT IN1 : DT; IN2 : TIME; END_VAR RETURN; END_FUNCTION
 FUNCTION SUB_DT_DT : TIME VAR_INPUT IN1 : DT; IN2 : DT; END_VAR RETURN; END_FUNCTION
+FUNCTION SUB : TIME VAR_INPUT IN1 : DT; IN2 : DT; END_VAR RETURN; END_FUNCTION