Fix definition of BCD to ANY_UINT and ANY_UINT to BCD conversion standard functions
authorLaurent Bessard
Thu, 08 Nov 2012 12:10:52 +0100
changeset 704 1adc8df05d2b
parent 703 48d106ffc2ca
child 705 f2323f79252e
Fix definition of BCD to ANY_UINT and ANY_UINT to BCD conversion standard functions
lib/create_standard_function_txt.sh
lib/iec_std_lib.h
lib/standard_functions.txt
stage4/generate_c/generate_c_sfc.cc
--- a/lib/create_standard_function_txt.sh	Tue Nov 06 19:56:23 2012 +0100
+++ b/lib/create_standard_function_txt.sh	Thu Nov 08 12:10:52 2012 +0100
@@ -273,7 +273,9 @@
 /*******************/
 /*   *_TO_BCD_*    */
 /*******************/
-#define __iec_(to_TYPENAME,from_TYPENAME) __function_1p(from_TYPENAME##_TO_BCD_##to_TYPENAME, to_TYPENAME, IN, from_TYPENAME)
+#define __iec_(to_TYPENAME,from_TYPENAME)\
+__function_1p(from_TYPENAME##_TO_BCD_##to_TYPENAME, to_TYPENAME, IN, from_TYPENAME)  /* explicitly typed function */\
+__function_1p(from_TYPENAME##_TO_BCD, to_TYPENAME, IN, from_TYPENAME)                /* overloaded function */ 
 __ANY_UINT(__to_anynbit_)
 #undef __iec_
 
@@ -281,7 +283,10 @@
 /*******************/
 /*   *_BCD_TO_*    */
 /*******************/
-#define __iec_(to_TYPENAME,from_TYPENAME) __function_1p(from_TYPENAME##_BCD_TO_##to_TYPENAME, to_TYPENAME, IN, from_TYPENAME)
+#define __iec_(to_TYPENAME,from_TYPENAME)\
+__function_1p(from_TYPENAME##_BCD_TO_##to_TYPENAME, to_TYPENAME, IN, from_TYPENAME)  /* explicitly typed function */\
+__function_1p(BCD_TO_##to_TYPENAME, to_TYPENAME, IN, from_TYPENAME)                  /* overloaded function */ 
+
 __ANY_NBIT(__to_anyuint_)
 #undef __iec_
 
--- a/lib/iec_std_lib.h	Tue Nov 06 19:56:23 2012 +0100
+++ b/lib/iec_std_lib.h	Thu Nov 08 12:10:52 2012 +0100
@@ -906,21 +906,27 @@
 #undef __iec_
 
 
-/********   _TO_BCD   ************/ 
+/********   _TO_BCD   ************/
 #define __iec_(to_TYPENAME,from_TYPENAME) \
 static inline to_TYPENAME from_TYPENAME##_TO_BCD_##to_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   TEST_EN(to_TYPENAME)\
   return (to_TYPENAME)__uint_to_bcd(op);\
+}\
+static inline to_TYPENAME from_TYPENAME##_TO_BCD__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
+  return from_TYPENAME##_TO_BCD_##to_TYPENAME(EN_ENO, op);\
 }
 __ANY_UINT(__to_anynbit_)
 #undef __iec_
 
 
-/********   BCD_TO_   ************/ 
+/********   BCD_TO_   ************/
 #define __iec_(to_TYPENAME,from_TYPENAME) \
 static inline to_TYPENAME from_TYPENAME##_BCD_TO_##to_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   TEST_EN(to_TYPENAME)\
   return (to_TYPENAME)__bcd_to_uint(op);\
+}\
+static inline to_TYPENAME BCD_TO_##to_TYPENAME##__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
+  return from_TYPENAME##_BCD_TO_##to_TYPENAME(EN_ENO, op);\
 }
 __ANY_NBIT(__to_anyuint_)
 #undef __iec_
--- a/lib/standard_functions.txt	Tue Nov 06 19:56:23 2012 +0100
+++ b/lib/standard_functions.txt	Thu Nov 08 12:10:52 2012 +0100
@@ -455,52 +455,70 @@
 FUNCTION TRUNC : UINT VAR_INPUT IN : LREAL; END_VAR RETURN; END_FUNCTION
 FUNCTION TRUNC : UDINT VAR_INPUT IN : LREAL; END_VAR RETURN; END_FUNCTION
 FUNCTION TRUNC : ULINT VAR_INPUT IN : LREAL; END_VAR RETURN; END_FUNCTION
-
-
-
-
-
-
-
 FUNCTION USINT_TO_BCD_BYTE : BYTE VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
+FUNCTION USINT_TO_BCD : BYTE VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
 FUNCTION USINT_TO_BCD_WORD : WORD VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
+FUNCTION USINT_TO_BCD : WORD VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
 FUNCTION USINT_TO_BCD_DWORD : DWORD VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
+FUNCTION USINT_TO_BCD : DWORD VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
 FUNCTION USINT_TO_BCD_LWORD : LWORD VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
+FUNCTION USINT_TO_BCD : LWORD VAR_INPUT IN : USINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UINT_TO_BCD_BYTE : BYTE VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UINT_TO_BCD : BYTE VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UINT_TO_BCD_WORD : WORD VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UINT_TO_BCD : WORD VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UINT_TO_BCD_DWORD : DWORD VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UINT_TO_BCD : DWORD VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UINT_TO_BCD_LWORD : LWORD VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UINT_TO_BCD : LWORD VAR_INPUT IN : UINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UDINT_TO_BCD_BYTE : BYTE VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UDINT_TO_BCD : BYTE VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UDINT_TO_BCD_WORD : WORD VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UDINT_TO_BCD : WORD VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UDINT_TO_BCD_DWORD : DWORD VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UDINT_TO_BCD : DWORD VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
 FUNCTION UDINT_TO_BCD_LWORD : LWORD VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
+FUNCTION UDINT_TO_BCD : LWORD VAR_INPUT IN : UDINT; END_VAR RETURN; END_FUNCTION
 FUNCTION ULINT_TO_BCD_BYTE : BYTE VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
+FUNCTION ULINT_TO_BCD : BYTE VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
 FUNCTION ULINT_TO_BCD_WORD : WORD VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
+FUNCTION ULINT_TO_BCD : WORD VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
 FUNCTION ULINT_TO_BCD_DWORD : DWORD VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
+FUNCTION ULINT_TO_BCD : DWORD VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
 FUNCTION ULINT_TO_BCD_LWORD : LWORD VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
-
-
-
-
-
-
-
+FUNCTION ULINT_TO_BCD : LWORD VAR_INPUT IN : ULINT; END_VAR RETURN; END_FUNCTION
 FUNCTION BYTE_BCD_TO_USINT : USINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_USINT : USINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
 FUNCTION BYTE_BCD_TO_UINT : UINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UINT : UINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
 FUNCTION BYTE_BCD_TO_UDINT : UDINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UDINT : UDINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
 FUNCTION BYTE_BCD_TO_ULINT : ULINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_ULINT : ULINT VAR_INPUT IN : BYTE; END_VAR RETURN; END_FUNCTION
 FUNCTION WORD_BCD_TO_USINT : USINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_USINT : USINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
 FUNCTION WORD_BCD_TO_UINT : UINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UINT : UINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
 FUNCTION WORD_BCD_TO_UDINT : UDINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UDINT : UDINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
 FUNCTION WORD_BCD_TO_ULINT : ULINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_ULINT : ULINT VAR_INPUT IN : WORD; END_VAR RETURN; END_FUNCTION
 FUNCTION DWORD_BCD_TO_USINT : USINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_USINT : USINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION DWORD_BCD_TO_UINT : UINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UINT : UINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION DWORD_BCD_TO_UDINT : UDINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UDINT : UDINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION DWORD_BCD_TO_ULINT : ULINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_ULINT : ULINT VAR_INPUT IN : DWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION LWORD_BCD_TO_USINT : USINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_USINT : USINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION LWORD_BCD_TO_UINT : UINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UINT : UINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION LWORD_BCD_TO_UDINT : UDINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_UDINT : UDINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION LWORD_BCD_TO_ULINT : ULINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
+FUNCTION BCD_TO_ULINT : ULINT VAR_INPUT IN : LWORD; END_VAR RETURN; END_FUNCTION
 FUNCTION ABS_REAL : REAL VAR_INPUT IN : REAL; END_VAR RETURN; END_FUNCTION
 FUNCTION ABS : REAL VAR_INPUT IN : REAL; END_VAR RETURN; END_FUNCTION
 FUNCTION ABS_LREAL : LREAL VAR_INPUT IN : LREAL; END_VAR RETURN; END_FUNCTION
--- a/stage4/generate_c/generate_c_sfc.cc	Tue Nov 06 19:56:23 2012 +0100
+++ b/stage4/generate_c/generate_c_sfc.cc	Thu Nov 08 12:10:52 2012 +0100
@@ -625,9 +625,7 @@
             s4o.indent_left();
             s4o.print(s4o.indent_spaces + "}\n");
             if (strcmp(qualifier, "DS") == 0) {
-              s4o.print(s4o.indent_spaces + "if (");
-              s4o.print("desactivated");
-              s4o.print(") {\n");
+              s4o.print(s4o.indent_spaces + "if (desactivated) {\n");
               s4o.indent_right();
               s4o.print(s4o.indent_spaces);
               print_action_argument(current_action, "set_remaining_time");