etherlab/plc_ds402node.c
changeset 2041 ce3727171207
parent 2036 7c31fab22c74
equal deleted inserted replaced
2040:d676082c1d2f 2041:ce3727171207
    17 %(MCL_headers)s
    17 %(MCL_headers)s
    18 
    18 
    19 IEC_UINT __InactiveMask = 0x4f;
    19 IEC_UINT __InactiveMask = 0x4f;
    20 IEC_UINT __ActiveMask = 0x6f;
    20 IEC_UINT __ActiveMask = 0x6f;
    21 IEC_UINT __PowerMask = 0x10;
    21 IEC_UINT __PowerMask = 0x10;
       
    22 IEC_BOOL __FirstTick = 1;
    22 
    23 
    23 typedef enum {
    24 typedef enum {
    24 	__Unknown,
    25 	__Unknown,
    25 	__NotReadyToSwitchOn,
    26 	__NotReadyToSwitchOn,
    26 	__SwitchOnDisabled,
    27 	__SwitchOnDisabled,
    42 
    43 
    43 %(extern_located_variables_declaration)s
    44 %(extern_located_variables_declaration)s
    44 
    45 
    45 int __init_%(location)s()
    46 int __init_%(location)s()
    46 {
    47 {
    47 %(init_entry_variables)s;
    48 %(init_entry_variables)s
    48 *__IW%(location)s_0 = __MK_AllocAxis(&(__DS402Node_%(location)s.axis));
    49 	*__IW%(location)s_0 = __MK_AllocAxis(&(__DS402Node_%(location)s.axis));
    49 	return 0;
    50 	return 0;
    50 }
    51 }
    51 
    52 
    52 void __cleanup_%(location)s()
    53 void __cleanup_%(location)s()
    53 {
    54 {
    55 
    56 
    56 void __retrieve_%(location)s()
    57 void __retrieve_%(location)s()
    57 {
    58 {
    58 	IEC_UINT statusword_inactive = *(__DS402Node_%(location)s.StatusWord) & __InactiveMask;
    59 	IEC_UINT statusword_inactive = *(__DS402Node_%(location)s.StatusWord) & __InactiveMask;
    59 	IEC_UINT statusword_active = *(__DS402Node_%(location)s.StatusWord) & __ActiveMask;
    60 	IEC_UINT statusword_active = *(__DS402Node_%(location)s.StatusWord) & __ActiveMask;
       
    61 
       
    62 	if (__FirstTick) {
       
    63 %(init_axis_params)s
       
    64 		_FirstTick = 0;
       
    65 	}
    60 
    66 
    61 	// DS402 node state computation
    67 	// DS402 node state computation
    62 	__DS402Node_%(location)s.state = __Unknown;
    68 	__DS402Node_%(location)s.state = __Unknown;
    63 	switch (statusword_inactive) {
    69 	switch (statusword_inactive) {
    64 		case 0x00:
    70 		case 0x00: