# HG changeset patch
# User Laurent Bessard
# Date 1353105825 -3600
# Node ID 72b74099b873120fecb1df6c8df569bcfd006076
# Parent 3fdf9d56d803e591b2dfd7a132f5b176ec505142
Fix bug in support for Etherlab specific fieldbus interface function blocks
diff -r 3fdf9d56d803 -r 72b74099b873 etherlab/etherlab.py
--- a/etherlab/etherlab.py Fri Nov 16 00:23:35 2012 +0100
+++ b/etherlab/etherlab.py Fri Nov 16 23:43:45 2012 +0100
@@ -209,20 +209,22 @@
]
EXTRA_NODE_VARIABLES_DICT = dict([("Enable" + name, value) for name, value in EXTRA_NODE_VARIABLES])
- BLOCK_INPUT_TEMPLATE = " __SET_VAR(%(blockname)s.,%(input_name)s, %(input_value)s);"
- BLOCK_OUTPUT_TEMPLATE = " __SET_VAR(data__->,%(output_name)s, __GET_VAR(%(blockname)s.%(output_name)s));"
+ BLOCK_INPUT_TEMPLATE = " __SET_VAR(%(blockname)s->,%(input_name)s, %(input_value)s);"
+ BLOCK_OUTPUT_TEMPLATE = " __SET_VAR(data__->,%(output_name)s, __GET_VAR(%(blockname)s->%(output_name)s));"
BLOCK_FUNCTION_TEMPLATE = """
extern void ETHERLAB%(ucase_blocktype)s_body__(ETHERLAB%(ucase_blocktype)s* data__);
void __%(blocktype)s_%(location)s(MC_%(ucase_blocktype)s *data__) {
- extern ETHERLAB%(ucase_blocktype)s %(blockname)s;
+ __DECLARE_GLOBAL_PROTOTYPE(ETHERLAB%(ucase_blocktype)s, %(blockname)s);
+ ETHERLAB%(ucase_blocktype)s* %(blockname)s = __GET_GLOBAL_%(blockname)s();
%(extract_inputs)s
- ETHERLAB%(ucase_blocktype)s_body__(&%(blockname)s);
+ ETHERLAB%(ucase_blocktype)s_body__(%(blockname)s);
%(return_outputs)s
}
"""
- BLOCK_FUNTION_DEFINITION_TEMPLATE = " __CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s = &(__%(blocktype)s_%(location)s);"
+ BLOCK_FUNTION_DEFINITION_TEMPLATE = """ if (!__CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s)
+ __CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s = __%(blocktype)s_%(location)s;"""
GLOBAL_INSTANCES = [
{"blocktype": "GetTorqueLimit",
diff -r 3fdf9d56d803 -r 72b74099b873 etherlab/plc_cia402node.c
--- a/etherlab/plc_cia402node.c Fri Nov 16 00:23:35 2012 +0100
+++ b/etherlab/plc_cia402node.c Fri Nov 16 23:43:45 2012 +0100
@@ -11,6 +11,7 @@
#include "iec_std_lib.h"
#endif
+#include "accessor.h"
#include "POUS.h"
IEC_INT beremiz__IW%(location)s_0;
@@ -57,7 +58,6 @@
%(init_entry_variables)s
*__IW%(location)s_0 = __MK_Alloc_AXIS_REF();
__CIA402Node_%(location)s.axis = __MK_GetPublic_AXIS_REF(*__IW%(location)s_0);
-%(fieldbus_interface_definition)s
__MK_Set_AXIS_REF_Pos(*__IW%(location)s_0, %(slave_pos)d);
*(__CIA402Node_%(location)s.ModesOfOperation) = 0x08;
return 0;
@@ -69,6 +69,8 @@
void __retrieve_%(location)s()
{
+%(fieldbus_interface_definition)s
+
IEC_UINT statusword_inactive = *(__CIA402Node_%(location)s.StatusWord) & __InactiveMask;
IEC_UINT statusword_active = *(__CIA402Node_%(location)s.StatusWord) & __ActiveMask;
diff -r 3fdf9d56d803 -r 72b74099b873 etherlab/pous.xml
--- a/etherlab/pous.xml Fri Nov 16 00:23:35 2012 +0100
+++ b/etherlab/pous.xml Fri Nov 16 23:43:45 2012 +0100
@@ -516,7 +516,7 @@
- 16#60E0
+ 16#60E1
@@ -1025,7 +1025,7 @@
- 16#60E0
+ 16#60E1