# HG changeset patch # User etisserant # Date 1184232463 -7200 # Node ID e7d67b27877ff6591412de6932e3ec567fd5feb3 # Parent d0ee8397dc4cf440a130aca6c73a89b38d8bbf45 Changes in the std library + std lib PLCOpen test (broken) diff -r d0ee8397dc4c -r e7d67b27877f examples/STD_TEST.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/STD_TEST.xml Thu Jul 12 11:27:43 2007 +0200 @@ -0,0 +1,1331 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STRRES + + + + + + + TESTNR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INTRES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + IN2 + + + + + + + IN3 + + + + + + + IN1 + + + + + + + IN1 + + + + + + + IN1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + L + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + L + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + P + + + + + + + L + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + IN2 + + + + + + + IN3 + + + + + + + IN1 + + + + + + + IN2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + P + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + L + + + + + + + P + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + IN2 + + + + + + + L + + + + + + + P + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IN1 + + + + + + + IN2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + The STRING test machine + + + + + + + 10 + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STR1 + + + + + + + STR2 + + + + + + + STR3 + + + + + + + INT1 + + + + + + + INT2 + + + + + + + INT3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TEST_NB + + + + + + + + + + + + + RES_STR + + + + + + + + + + + + + RES_INT + + + + + + + + + + + + + + + + + + + + + + + + diff -r d0ee8397dc4c -r e7d67b27877f generate_IEC_std.py --- a/generate_IEC_std.py Tue Jul 10 19:22:42 2007 +0200 +++ b/generate_IEC_std.py Thu Jul 12 11:27:43 2007 +0200 @@ -1,3 +1,19 @@ +""" + + THIS CODE GENARATES C++ CODE FOR IEC2CC COMPILER + GENERATED CODE IS : + +function_type_decl.h - the long enumeration of std function types +get_function_type_decl.c - the funct that return enumerated according function name +st_code_gen.c - part of generate_cc_st_c::visit(function_invocation) + responsible to generate C code for std lib calls +il_code_gen.c - part of generate_cc_il_c::visit(il_function_call) + responsible to generate C code for std lib calls +search_type_code.c - called by search_expression_type_c::visit(function_invocation) + return type symbol for std function invocation + +""" + # Get definitions from plcopen.structures import * @@ -373,6 +389,29 @@ ################################################################### ################################################################### """ +Generate the standard_function_names[] for inclusion in bizon generated code +""" +standard_function_names = """ +/**** + * IEC 61131-3 standard function lib + * generated code, do not edit by hand + */ + +const char *standard_function_names[] = { +""" +for fname, fdecls in [ (fname,std_fdecls[fname]) for fname in official_order ]: + standard_function_names += "\""+fname+"\",\n" +standard_function_names += """ +/* end of array marker! Do not remove! */ +NULL +}; + +""" + +################################################################### +################################################################### +################################################################### +""" Generate the C implementation of the IEC standard function library. """ iec_std_lib_generated = """ @@ -401,14 +440,19 @@ sys.exit(0) # Now, print that out, or write to files from sys.argv -for name, ext in [ - ('function_type_decl','h'), - ('get_function_type_decl','c'), - ('st_code_gen','c'), - ('il_code_gen','c'), - ('search_type_code','c')#, - #('iec_std_lib_generated','h') +for path, name, ext in [ + ('stage4/generate_cc','function_type_decl','h'), + ('stage4/generate_cc','get_function_type_decl','c'), + ('stage4/generate_cc','st_code_gen','c'), + ('stage4/generate_cc','il_code_gen','c'), + ('stage4/generate_cc','search_type_code','c'), + ('stage1_2','standard_function_names','c'), + ('lib', 'iec_std_lib_generated','h') ]: - fd = open(os.path.join(sys.argv[1],name+'.'+ext),'w') + fd = open(os.path.join(sys.argv[1], path, name+'.'+ext),'w') fd.write(eval(name)) fd.close() + +#print "/* Code to eventually paste in iec_std_lib.h if type hierarchy changed */" +#print "/* you also have to change iec_std_lib.h according to new types */\n\n" +#print iec_std_lib_generated diff -r d0ee8397dc4c -r e7d67b27877f plcopen/iec_std.csv --- a/plcopen/iec_std.csv Tue Jul 10 19:22:42 2007 +0200 +++ b/plcopen/iec_std.csv Thu Jul 12 11:27:43 2007 +0200 @@ -1,7 +1,7 @@ Standard_functions_variables_types;name;type;comment;;;;;; -;N;UINT;Number of bits to be shifted;;;;;; -;L;UINT;Left position within character string;;;;;; -;P;UINT;Position within character string;;;;;; +;N;ANY_INT;Number of bits to be shifted;;;;;; +;L;ANY_INT;Left position within character string;;;;;; +;P;ANY_INT;Position within character string;;;;;; ;G;BOOL;Selection out of 2 inputs (gate);;;;;; ;K;ANY_INT;Selection out of n inputs;;;;;; ;MN;ANY;Minimum value for limitation;;;;;;