def fieldReflection(msg, field): fieldFnName = field["Name"] fieldCount = MsgParser.fieldCount(field) if MsgParser.fieldCount(field) != 1 and MsgParser.fieldUnits(field) == "ASCII" and (field["Type"] == "uint8" or field["Type"] == "int8"): fieldFnName = field["Name"]+"String" fieldCount = 1 fieldInfo = "{"+\ 'name:"'+field["Name"] + '",'+\ 'type:"'+reflectionInterfaceType(field) + '",'+\ 'units:"'+MsgParser.fieldUnits(field) + '",'+\ 'minVal:"'+str(MsgParser.fieldMin(field)) + '",'+\ 'maxVal:"'+str(MsgParser.fieldMax(field)) + '",'+\ 'description:"'+MsgParser.fieldDescription(field) + '",'+\ 'get:"Get' + fieldFnName + '",'+\ 'set:"Set' + fieldFnName + '",'+\ 'count:'+str(fieldCount) + ', ' if "Bitfields" in field: bitfieldInfo = [] for bits in field["Bitfields"]: bitfieldInfo.append(" " + bitfieldReflection(msg, field, bits)) fieldInfo += "bitfieldInfo : [\n" + ",\n".join(bitfieldInfo) + "], " else: fieldInfo += "bitfieldInfo : [], " if "Enum" in field: fieldInfo += "enumLookup : [<MSGSHORTNAME>." + field["Enum"]+", " + "<MSGSHORTNAME>.Reverse" + field["Enum"]+"]}" else: fieldInfo += "enumLookup : []}" return fieldInfo
def fieldReflection(msg, field): fieldFnName = field["Name"] fieldCount = MsgParser.fieldCount(field) if MsgParser.fieldCount(field) != 1 and MsgParser.fieldUnits(field) == "ASCII" and (field["Type"] == "uint8" or field["Type"] == "int8"): fieldFnName = field["Name"]+"String" fieldCount = 1 fieldInfo = "["+\ '"name":"'+field["Name"] + '",'+\ '"type":"'+reflectionInterfaceType(field) + '",'+\ '"units":"'+MsgParser.fieldUnits(field) + '",'+\ '"minVal":"'+str(MsgParser.fieldMin(field)) + '",'+\ '"maxVal":"'+str(MsgParser.fieldMax(field)) + '",'+\ '"description":"'+MsgParser.fieldDescription(field) + '",'+\ '"get":"Get' + fieldFnName + '",'+\ '"set":"Set' + fieldFnName + '",'+\ '"count":'+str(fieldCount) + ', ' if "Bitfields" in field: bitfieldInfo = [] for bits in field["Bitfields"]: bitfieldInfo.append(" " + bitfieldReflection(msg, field, bits)) fieldInfo += '"bitfieldInfo" : [\n' + ",\n".join(bitfieldInfo) + "], " else: fieldInfo += '"bitfieldInfo" : [], ' if "Enum" in field: fieldInfo += '"enumLookup" : [' + field["Enum"]+"Enum, " + "Reverse" + field["Enum"]+"Enum]]" else: fieldInfo += '"enumLookup" : []]' return fieldInfo
def fieldReflection(msg, field): fieldInfo = "FieldInfo("+\ 'name="'+field["Name"] + '",'+\ 'type="'+reflectionInterfaceType(field) + '",'+\ 'units="'+MsgParser.fieldUnits(field) + '",'+\ 'minVal="'+str(MsgParser.fieldMin(field)) + '",'+\ 'maxVal="'+str(MsgParser.fieldMax(field)) + '",'+\ 'description="'+MsgParser.fieldDescription(field) + '",'+\ 'get='+"Get" + field["Name"] + ','+\ 'set='+"Set" + field["Name"] + ','+\ 'count='+str(pythonFieldCount(field)) + ', ' if "IDBits" in field: fieldInfo += "idbits="+str(field["IDBits"])+"," if "Bitfields" in field: bitfieldInfo = [] for bits in field["Bitfields"]: bitfieldInfo.append(" " + bitfieldReflection(msg, field, bits)) fieldInfo += "bitfieldInfo = [\n" + ",\n".join(bitfieldInfo) + "], " else: fieldInfo += "bitfieldInfo = [], " if "Enum" in field: fieldInfo += "enum = [" + field["Enum"]+", " + "Reverse" + field["Enum"]+"])" else: fieldInfo += "enum = [])" return fieldInfo
def fieldBitsReflection(field, bits, bitOffset, numBits): loc = str(MsgParser.fieldLocation(field)) params = "FieldInfo"; params += "(" params += '"'+bits["Name"] + '"' params += ', "' + MsgParser.fieldDescription(bits) + '"' params += ', "' + MsgParser.fieldUnits(bits) + '"' params += ", " + str(MsgParser.fieldCount(bits)) params += ")" return params
def fieldReflection(field): loc = str(MsgParser.fieldLocation(field)) params = "FieldInfo"; params += "(" params += '"'+field["Name"] + '"' params += ', "' + MsgParser.fieldDescription(field) + '"' params += ', "' + MsgParser.fieldUnits(field) + '"' params += ", " + str(MsgParser.fieldCount(field)) params += ")" return params
def bitfieldReflection(msg, field, bits): name = bits["Name"] ret = "["+\ '"name":"'+name + '",'+\ '"type":"'+bitsReflectionInterfaceType(bits) + '",'+\ '"units":"'+MsgParser.fieldUnits(bits) + '",'+\ '"minVal":"'+str(MsgParser.fieldMin(bits)) + '",'+\ '"maxVal":"'+str(MsgParser.fieldMax(bits)) + '",'+\ '"description":"'+MsgParser.fieldDescription(bits) + '",'+\ '"get":"Get' + name + '",'+\ '"set":"Set' + name + '", ' if "Enum" in bits: ret += '"enumLookup" : ['+ bits["Enum"]+"Enum, " + "Reverse" + bits["Enum"]+"Enum]]" else: ret += '"enumLookup" : []]' return ret
def bitfieldReflection(msg, field, bits): name = bits["Name"] ret = "{"+\ 'name:"'+name + '",'+\ 'type:"'+bitsReflectionInterfaceType(bits) + '",'+\ 'units:"'+MsgParser.fieldUnits(bits) + '",'+\ 'minVal:"'+str(MsgParser.fieldMin(bits)) + '",'+\ 'maxVal:"'+str(MsgParser.fieldMax(bits)) + '",'+\ 'description:"'+MsgParser.fieldDescription(bits) + '",'+\ 'get:"Get' + name + '",'+\ 'set:"Set' + name + '", ' if "Enum" in bits: ret += "enumLookup : [<MSGSHORTNAME>."+ bits["Enum"]+", " + "<MSGSHORTNAME>.Reverse" + bits["Enum"]+"]}" else: ret += "enumLookup : []}" return ret
def bitfieldReflection(msg, field, bits): name = bits["Name"] ret = "BitFieldInfo("+\ 'name="'+name + '",'+\ 'type="'+bitsReflectionInterfaceType(bits) + '",'+\ 'units="'+MsgParser.fieldUnits(bits) + '",'+\ 'minVal="'+str(MsgParser.fieldMin(bits)) + '",'+\ 'maxVal="'+str(MsgParser.fieldMax(bits)) + '",'+\ 'description="'+MsgParser.fieldDescription(bits) + '",'+\ 'get='+"Get" + name + ','+\ 'set='+"Set" + name + ', ' if "IDBits" in bits: ret += "idbits="+str(bits["IDBits"])+"," if "Enum" in bits: ret += "enum = ["+ bits["Enum"]+", " + "Reverse" + bits["Enum"]+"])" else: ret += "enum = [])" return ret
def fieldReflection(field): loc = str(MsgParser.fieldLocation(field)) type = fieldReflectionType(field) params = type; params += "(" params += '"'+field["Name"] + '"' params += ', "' + MsgParser.fieldDescription(field) + '"' params += ', "' + MsgParser.fieldUnits(field) + '"' params += ", " + loc params += ", " + str(MsgParser.fieldSize(field)) params += ", " + str(MsgParser.fieldCount(field)) if "Offset" in field or "Scale" in field: if "Scale" in field: params += ", " + str(field["Scale"]) else: params += ", 1.0" if "Offset" in field: params += ", " + str(field["Offset"]) else: params += ", 0.0" params += ")" return params
def fieldBitsReflection(field, bits, bitOffset, numBits): loc = str(MsgParser.fieldLocation(field)) type = fieldReflectionBitsType(field, bits) params = type; params += "(" params += '"'+bits["Name"] + '"' params += ', "' + MsgParser.fieldDescription(bits) + '"' params += ', "' + MsgParser.fieldUnits(bits) + '"' params += ", " + loc params += ", " + str(MsgParser.fieldSize(field)) params += ", " + str(MsgParser.fieldCount(bits)) if "Offset" in bits or "Scale" in bits: if "Scale" in bits: params += ", " + str(bits["Scale"]) else: params += ", 1.0" if "Offset" in bits: params += ", " + str(bits["Offset"]) else: params += ", 0.0" params += ", " + str(bitOffset) params += ", " + str(numBits) params += ")" return params
def fieldBitsReflection(field, bits, offset, bitOffset, numBits): loc = str(offset) type = fieldReflectionBitsType(field, bits) params = type params += "(" params += '"' + bits["Name"] + '"' params += ', "' + MsgParser.fieldDescription(bits) + '"' params += ', "' + MsgParser.fieldUnits(bits) + '"' params += ", " + loc params += ", " + str(MsgParser.fieldSize(field)) params += ", " + str(MsgParser.fieldCount(bits)) if "Offset" in bits or "Scale" in bits: if "Scale" in bits: params += ", " + str(bits["Scale"]) else: params += ", 1.0" if "Offset" in bits: params += ", " + str(bits["Offset"]) else: params += ", 0.0" params += ", " + str(bitOffset) params += ", " + str(numBits) params += ")" return params
def fnHdr(field): ret = "// %s %s, (%s to %s)" % (MsgParser.fieldDescription(field), MsgParser.fieldUnits(field), MsgParser.fieldMin(field), MsgParser.fieldMax(field)) return ret
def fnHdr(field, offset, count, name): param = "self" if str.find(name, "Set") == 0: param += ", value" if count > 1: param += ", idx" if str.find(name, "Set") != 0: if "Enum" in field: param += ", enumAsInt=0" min = MsgParser.fieldMin(field) max = MsgParser.fieldMax(field) try: fieldSize = MsgParser.fieldSize(field) if MsgParser.fieldUnits(field) == "ASCII" and (field["Type"] == "uint8" or field["Type"] == "int8"): count = MsgParser.fieldCount(field) except KeyError: fieldSize = 0 ret = '''\ @msg.units('%s') @msg.default('%s') @msg.minVal('%s') @msg.maxVal('%s') @msg.offset('%s') @msg.size('%s') @msg.count(%s) def %s(%s): """%s"""''' % (MsgParser.fieldUnits(field), str(MsgParser.fieldDefault(field)), str(min), str(max), str(offset), str(fieldSize), str(count), name, param, MsgParser.fieldDescription(field)) return ret
def fnHdr(field, offset, count, name): param = "self" if str.find(name, "Set") == 0: param += ", value" if count > 1: param += ", idx" if str.find(name, "Set") != 0: if "Enum" in field: param += ", enumAsInt=0" min = MsgParser.fieldMin(field) max = MsgParser.fieldMax(field) try: fieldSize = MsgParser.fieldSize(field) except KeyError: fieldSize = 0 ret = '''\ @msg.units('%s') @msg.default('%s') @msg.minVal('%s') @msg.maxVal('%s') @msg.offset('%s') @msg.size('%s') @msg.count(%s) def %s(%s): """%s"""''' % (MsgParser.fieldUnits(field), str(MsgParser.fieldDefault(field)), str(min), str(max), str(offset), str(fieldSize), str(count), name, param, MsgParser.fieldDescription(field)) return ret