--- 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",
--- 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;
--- 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 @@
<connectionPointOut>
<relPosition x="68" y="13"/>
</connectionPointOut>
- <expression>16#60E0</expression>
+ <expression>16#60E1</expression>
</inVariable>
<inVariable localId="8" height="27" width="33">
<position x="390" y="203"/>
@@ -1025,7 +1025,7 @@
<connectionPointOut>
<relPosition x="68" y="13"/>
</connectionPointOut>
- <expression>16#60E0</expression>
+ <expression>16#60E1</expression>
</inVariable>
<inVariable localId="8" height="27" width="33">
<position x="186" y="203"/>