Path: blob/master/Tools/autotest/param_metadata/param.py
9594 views
# flake8: noqa123class Parameter(object):4def __init__(self, name, real_path):5self.name = name6self.real_path = real_path78def change_name(self, name):9self.name = name101112class Vehicle(object):13def __init__(self, name, path, reference=None):14self.name = name15self.path = path16self.reference = reference17if reference is None:18self.reference = self.truename19self.params = []202122class Library(object):23def __init__(self, name, reference=None, not_rst=False, check_duplicates=False):24self.set_name(name)25self.params = []26if reference is not None:27self.reference = reference28self.not_rst = not_rst29self.check_duplicates = check_duplicates3031def set_name(self, name):32self.name = name33self.reference = name3435def has_param(self, pname):36for p in self.params:37if pname == p.name:38return True39return False4041known_param_fields = [42'Description',43'DisplayName',44'Values',45'Range',46'Units',47'Increment',48'User',49'RebootRequired',50'Bitmask',51'Volatile',52'ReadOnly',53'Calibration',54'Vector3Parameter',55'SortValues',56'Legacy',57]5859# Follow SI units conventions from:60# http://physics.nist.gov/cuu/Units/units.html61# http://physics.nist.gov/cuu/Units/outside.html62# and63# http://physics.nist.gov/cuu/Units/checklist.html64# http://www.bipm.org/en/publications/si-brochure/65# http://www1.bipm.org/en/CGPM/db/3/2/ g_n unit for G-force66# one further constrain is that only printable (7bit) ASCII characters are allowed67known_units = {68# abbreviation : full-text (used in .html .rst and .wiki files)69# time70's' : 'seconds' ,71'ds' : 'deciseconds' ,72'cs' : 'centiseconds' ,73'ms' : 'milliseconds' ,74'us' : 'microseconds' ,75'PWM' : 'PWM in microseconds' , # should be microseconds, this is NOT a SI unit, but follows https://github.com/ArduPilot/ardupilot/pull/5538#issuecomment-27194306176'Hz' : 'hertz' ,77'kHz' : 'kilohertz' ,78'1/s' : 'per second' , # Not SI but in some situations more user-friendly than hertz79# distance80'km' : 'kilometers' , # metre is the SI unit name, meter is the american spelling of it81'm' : 'meters' , # metre is the SI unit name, meter is the american spelling of it82'm/s' : 'meters per second' , # metre is the SI unit name, meter is the american spelling of it83'm/s/s' : 'meters per square second' , # metre is the SI unit name, meter is the american spelling of it84'm/s/s/s' : 'meters per cubic second' , # metre is the SI unit name, meter is the american spelling of it85'cm' : 'centimeters' , # metre is the SI unit name, meter is the american spelling of it86'cm/s' : 'centimeters per second' , # metre is the SI unit name, meter is the american spelling of it87'cm/s/s' : 'centimeters per square second', # metre is the SI unit name, meter is the american spelling of it88'cm/s/s/s': 'centimeters per cubic second' , # metre is the SI unit name, meter is the american spelling of it89'mm' : 'millimeters' , # metre is the SI unit name, meter is the american spelling of it90# temperature91'degC' : 'degrees Celsius' , # Not SI, but Kelvin is too cumbersome for most users92# angle93'deg' : 'degrees' , # Not SI, but is some situations more user-friendly than radians94'deg/s' : 'degrees per second' , # Not SI, but is some situations more user-friendly than radians95'deg/s/s' : 'degrees per square second', # Not SI, but is some situations more user-friendly than radians96'deg/s/s/s' : 'degrees per cube second', # Not SI, but is some situations more user-friendly than radians97'cdeg' : 'centidegrees' , # Not SI, but is some situations more user-friendly than radians98'cdeg/s' : 'centidegrees per second', # Not SI, but is some situations more user-friendly than radians99'cdeg/s/s': 'centidegrees per square second' , # Not SI, but is some situations more user-friendly than radians100'rad' : 'radians' ,101'rad/s' : 'radians per second' ,102'rad/s/s' : 'radians per square second' ,103# electricity104'A' : 'ampere' ,105'V' : 'volt' ,106'W' : 'watt' ,107# magnetism108'Gauss' : 'gauss' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here109'Gauss/s' : 'gauss per second' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here110'mGauss' : 'milligauss' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here111# pressure112'Pa' : 'pascal' ,113'hPa' : 'hectopascal' ,114# ratio115'%' : 'percent' ,116'%/s' : 'percent per second' ,117'd%' : 'decipercent' , # decipercent is strange, but "per-mille" is even more exotic118'dB' : 'decibel' ,119# compound120121'kB' : 'kilobytes' ,122'KiB' : 'kibibytes',123'MB' : 'megabyte' ,124'm.m/s/s' : 'square meter per square second',125'deg/m/s' : 'degrees per meter per second' ,126'm/s/m' : 'meters per second per meter' , # Why not use Hz here ????127'mGauss/A': 'milligauss per ampere' ,128'mAh' : 'milliampere hour' ,129'Ah' : 'ampere hour' ,130'A/V' : 'ampere per volt' ,131'm/V' : 'meters per volt' ,132'gravities': 'standard acceleration due to gravity' , # g_n would be a more correct unit, but IMHO no one understands what g_n means133'octal' : 'octal' ,134'RPM' : 'Revolutions Per Minute',135'kg' : 'kilograms',136'kg/m/m' : 'kilograms per square meter', # metre is the SI unit name, meter is the american spelling of it137'kg/m/m/m': 'kilograms per cubic meter',138'litres' : 'litres',139'Ohm' : 'Ohm',140'N' : 'Newtons',141}142143required_param_fields = [144'Description',145'DisplayName',146'User',147]148149required_library_param_fields = [150'Description',151'DisplayName',152]153154known_group_fields = [155'Path',156]157158159