107 valueRangeContent = "" |
107 valueRangeContent = "" |
108 strDefine = "\n#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */" |
108 strDefine = "\n#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */" |
109 strSwitch = """ case valueRange_EMC: |
109 strSwitch = """ case valueRange_EMC: |
110 if (*(UNS8*)value != (UNS8)0) return OD_VALUE_RANGE_EXCEEDED; |
110 if (*(UNS8*)value != (UNS8)0) return OD_VALUE_RANGE_EXCEEDED; |
111 break;\n""" |
111 break;\n""" |
112 internal_types["valueRange_EMC"] = ("UNS8", "", "valueRange_EMC") |
112 internal_types["valueRange_EMC"] = ("UNS8", "", "valueRange_EMC", True) |
113 num = 0 |
113 num = 0 |
114 for index in rangelist: |
114 for index in rangelist: |
115 rangename = Node.GetEntryName(index) |
115 rangename = Node.GetEntryName(index) |
116 result = range_model.match(rangename) |
116 result = range_model.match(rangename) |
117 if result: |
117 if result: |
122 internal_types[rangename] = (typeinfos[0], typeinfos[1], "valueRange_%d"%num) |
122 internal_types[rangename] = (typeinfos[0], typeinfos[1], "valueRange_%d"%num) |
123 minvalue = Node.GetEntry(index, 2) |
123 minvalue = Node.GetEntry(index, 2) |
124 maxvalue = Node.GetEntry(index, 3) |
124 maxvalue = Node.GetEntry(index, 3) |
125 strDefine += "\n#define valueRange_%d 0x%02X /* Type %s, %s < value < %s */"%(num,index,typeinfos[0],str(minvalue),str(maxvalue)) |
125 strDefine += "\n#define valueRange_%d 0x%02X /* Type %s, %s < value < %s */"%(num,index,typeinfos[0],str(minvalue),str(maxvalue)) |
126 strSwitch += " case valueRange_%d:\n"%(num) |
126 strSwitch += " case valueRange_%d:\n"%(num) |
127 if typeinfos[4] and minvalue <= 0: |
127 if typeinfos[3] and minvalue <= 0: |
128 strSwitch += " /* Negative or null low limit ignored because of unsigned type */;\n" |
128 strSwitch += " /* Negative or null low limit ignored because of unsigned type */;\n" |
129 else: |
129 else: |
130 strSwitch += " if (*(%s*)value < (%s)%s) return OD_VALUE_TOO_LOW;\n"%(typeinfos[0],typeinfos[0],str(minvalue)) |
130 strSwitch += " if (*(%s*)value < (%s)%s) return OD_VALUE_TOO_LOW;\n"%(typeinfos[0],typeinfos[0],str(minvalue)) |
131 strSwitch += " if (*(%s*)value > (%s)%s) return OD_VALUE_TOO_HIGH;\n"%(typeinfos[0],typeinfos[0],str(maxvalue)) |
131 strSwitch += " if (*(%s*)value > (%s)%s) return OD_VALUE_TOO_HIGH;\n"%(typeinfos[0],typeinfos[0],str(maxvalue)) |
132 strSwitch += " break;\n" |
132 strSwitch += " break;\n" |