2012-07-04 20:44:53 -03:00
class Parameter ( object ) :
2018-09-19 07:33:24 -03:00
def __init__ ( self , name , real_path ) :
2012-07-04 20:44:53 -03:00
self . name = name
2018-09-19 07:33:24 -03:00
self . real_path = real_path
2016-07-31 07:22:06 -03:00
2012-07-04 20:44:53 -03:00
class Vehicle ( object ) :
2021-05-12 01:45:27 -03:00
def __init__ ( self , name , path , reference = None ) :
2012-07-04 20:44:53 -03:00
self . name = name
self . path = path
2021-05-12 01:45:27 -03:00
self . reference = reference
if reference is None :
self . reference = self . truename
2012-07-04 20:44:53 -03:00
self . params = [ ]
2016-07-31 07:22:06 -03:00
2012-07-04 20:44:53 -03:00
class Library ( object ) :
2023-02-11 01:32:02 -04:00
def __init__ ( self , name , reference = None , not_rst = False , check_duplicates = False ) :
2021-05-12 01:45:27 -03:00
self . set_name ( name )
2012-07-04 20:44:53 -03:00
self . params = [ ]
2023-02-08 20:25:06 -04:00
if reference is not None :
self . reference = reference
2023-02-08 21:53:11 -04:00
self . not_rst = not_rst
2023-02-11 01:32:02 -04:00
self . check_duplicates = check_duplicates
2016-07-31 07:22:06 -03:00
2021-05-12 01:45:27 -03:00
def set_name ( self , name ) :
self . name = name
self . reference = name
2023-02-11 01:32:02 -04:00
def has_param ( self , pname ) :
for p in self . params :
if pname == p . name :
return True
return False
2012-07-04 20:44:53 -03:00
known_param_fields = [
' Description ' ,
' DisplayName ' ,
' Values ' ,
' Range ' ,
' Units ' ,
' Increment ' ,
2015-05-29 03:35:33 -03:00
' User ' ,
2015-06-04 21:19:26 -03:00
' RebootRequired ' ,
2016-02-28 19:35:40 -04:00
' Bitmask ' ,
' Volatile ' ,
2016-07-31 07:22:06 -03:00
' ReadOnly ' ,
2020-02-01 20:56:29 -04:00
' Calibration ' ,
2012-07-04 21:42:38 -03:00
]
2017-05-02 07:36:14 -03:00
# Follow SI units conventions from:
# http://physics.nist.gov/cuu/Units/units.html
# http://physics.nist.gov/cuu/Units/outside.html
# and
# http://physics.nist.gov/cuu/Units/checklist.html
# http://www.bipm.org/en/publications/si-brochure/
# http://www1.bipm.org/en/CGPM/db/3/2/ g_n unit for G-force
# one further constrain is that only printable (7bit) ASCII characters are allowed
known_units = {
# abreviation : full-text (used in .html .rst and .wiki files)
# time
' s ' : ' seconds ' ,
' ds ' : ' deciseconds ' ,
' cs ' : ' centiseconds ' ,
' ms ' : ' milliseconds ' ,
2020-06-06 11:59:51 -03:00
' us ' : ' microseconds ' ,
2017-05-02 21:10:22 -03:00
' PWM ' : ' PWM in microseconds ' , # should be microseconds, this is NOT a SI unit, but follows https://github.com/ArduPilot/ardupilot/pull/5538#issuecomment-271943061
2017-05-02 07:36:14 -03:00
' Hz ' : ' hertz ' ,
2017-07-15 18:46:50 -03:00
' kHz ' : ' kilohertz ' ,
2020-12-11 07:35:35 -04:00
' 1/s ' : ' per second ' , # Not SI but in some situations more user-friendly than hertz
2017-05-02 07:36:14 -03:00
# distance
2017-05-02 21:10:22 -03:00
' km ' : ' kilometers ' , # metre is the SI unit name, meter is the american spelling of it
' m ' : ' meters ' , # metre is the SI unit name, meter is the american spelling of it
' m/s ' : ' meters per second ' , # metre is the SI unit name, meter is the american spelling of it
' m/s/s ' : ' meters per square second ' , # metre is the SI unit name, meter is the american spelling of it
' m/s/s/s ' : ' meters per cubic second ' , # metre is the SI unit name, meter is the american spelling of it
' cm ' : ' centimeters ' , # metre is the SI unit name, meter is the american spelling of it
' cm/s ' : ' centimeters per second ' , # metre is the SI unit name, meter is the american spelling of it
' cm/s/s ' : ' centimeters per square second ' , # metre is the SI unit name, meter is the american spelling of it
' cm/s/s/s ' : ' centimeters per cubic second ' , # metre is the SI unit name, meter is the american spelling of it
' mm ' : ' millimeters ' , # metre is the SI unit name, meter is the american spelling of it
2017-05-02 07:36:14 -03:00
# temperature
2017-05-15 20:18:50 -03:00
' degC ' : ' degrees Celsius ' , # Not SI, but Kelvin is too cumbersome for most users
2017-05-02 07:36:14 -03:00
# angle
2017-05-15 20:18:50 -03:00
' deg ' : ' degrees ' , # Not SI, but is some situations more user-friendly than radians
' deg/s ' : ' degrees per second ' , # Not SI, but is some situations more user-friendly than radians
2017-12-30 00:58:05 -04:00
' deg/s/s ' : ' degrees per square second ' , # Not SI, but is some situations more user-friendly than radians
2017-05-15 20:18:50 -03:00
' cdeg ' : ' centidegrees ' , # Not SI, but is some situations more user-friendly than radians
' cdeg/s ' : ' centidegrees per second ' , # Not SI, but is some situations more user-friendly than radians
' cdeg/s/s ' : ' centidegrees per square second ' , # Not SI, but is some situations more user-friendly than radians
2017-05-02 07:36:14 -03:00
' rad ' : ' radians ' ,
' rad/s ' : ' radians per second ' ,
' rad/s/s ' : ' radians per square second ' ,
# electricity
' A ' : ' ampere ' ,
' V ' : ' volt ' ,
' W ' : ' watt ' ,
# magnetism
' Gauss ' : ' gauss ' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here
' Gauss/s ' : ' gauss per second ' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here
' mGauss ' : ' milligauss ' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here
# pressure
' Pa ' : ' pascal ' ,
2019-09-15 21:00:58 -03:00
' hPa ' : ' hectopascal ' ,
2017-05-02 07:36:14 -03:00
# ratio
' % ' : ' percent ' ,
' % /s ' : ' percent per second ' ,
2017-05-02 21:10:22 -03:00
' d % ' : ' decipercent ' , # decipercent is strange, but "per-mille" is even more exotic
2017-12-11 06:30:35 -04:00
' dB ' : ' decibel ' ,
2017-05-02 07:36:14 -03:00
# compound
2018-05-07 19:00:45 -03:00
' kB ' : ' kilobytes ' ,
2020-06-02 06:04:19 -03:00
' MB ' : ' megabyte ' ,
2017-05-02 21:10:22 -03:00
' m.m/s/s ' : ' square meter per square second ' ,
' deg/m/s ' : ' degrees per meter per second ' ,
2017-05-02 07:36:14 -03:00
' m/s/m ' : ' meters per second per meter ' , # Why not use Hz here ????
' mGauss/A ' : ' milligauss per ampere ' ,
2018-05-25 19:47:27 -03:00
' mAh ' : ' milliampere hour ' ,
2017-05-02 07:36:14 -03:00
' A/V ' : ' ampere per volt ' ,
' m/V ' : ' meters per volt ' ,
' gravities ' : ' standard acceleration due to gravity ' , # g_n would be a more correct unit, but IMHO no one understands what g_n means
2018-05-22 14:32:34 -03:00
' octal ' : ' octal ' ,
2019-08-29 20:58:17 -03:00
' RPM ' : ' Revolutions Per Minute ' ,
2020-12-11 07:35:35 -04:00
' kg/m/m ' : ' kilograms per square meter ' , # metre is the SI unit name, meter is the american spelling of it
2022-03-29 22:24:33 -03:00
' kg/m/m/m ' : ' kilograms per cubic meter ' ,
2017-05-02 07:36:14 -03:00
}
2013-05-21 04:01:13 -03:00
required_param_fields = [
' Description ' ,
' DisplayName ' ,
2016-07-31 07:22:06 -03:00
' User ' ,
2013-05-21 04:01:13 -03:00
]
2022-08-11 20:32:31 -03:00
required_library_param_fields = [
' Description ' ,
' DisplayName ' ,
]
2012-07-04 21:42:38 -03:00
known_group_fields = [
2016-07-31 07:22:06 -03:00
' Path ' ,
2013-05-21 04:01:13 -03:00
]