def __init__(self, pid: int, name: str, parser, fields: [list, str]):
"""
A class representing an FMSPID and its conversion
:param pid: The PID
:param name: A friendly name of this PID
:param parser: a function that turns a byte array of at most length 8 into one or more readable values
:param fields: the friendly name of the outputs of this PID eg. 'RPM'
"""
self.pid = pid
self.name = name
self.parser = parser
if type(fields) is str:
self.fields = [fields]
else:
self.fields = fields
self.fieldnames = ['{} ({})'.format(name, unit) for pid_name, unit in
zip(cycle([self.name]), self.fields)]
评论列表
文章目录