Re: Konstanten in Struct-Form in Python

"Michael S." <michaely-jG/[email protected]>
Newsgroups gmane.comp.python.general.german
Message-ID <[email protected]>
Am 19.02.2021 um 15:27 schrieb Michael S.:

> Das muss doch auch einfacher gehen.
> 
> Ideen?

Ich habs jetzt so gemacht. Da muss ich in der Anwendung nur die 
CAN-Signals_Klasse instanzieren, dafür halt in der Lib jeweils jedes 
eigene Signal. Aber die Lib wird eh automatisch generiert.

class C_frequency:
	def __init__(self):
		self.ID = "10FC80FC"
		self.BitOffset = 48
		self.BitLength = 8
		self.Gain = 1
		self.ValueOffset = 0
		self.Unit = "Hz"
		self.Rate = 0.5

class C_OutputVoltage:
	def __init__(self):
		self.ID = "25FF1250"
		self.BitOffset = 32
		self.BitLength = 16
		self.Gain = 0.1
		self.ValueOffset = 0
		self.Unit = "V"
		self.Rate = 0.25

class C_Cable_temp:
	def __init__(self):
		self.ID = "12FA5AFC"
		self.BitOffset = 0
		self.BitLength = 8
		self.Gain = 1
		self.ValueOffset = -40
		self.Unit = "°C"
		self.Rate = 10
		
class CAN_Signals:
	def __init__(self):
		self.frequency = C_frequency()
		self.OutputVoltage = C_OutputVoltage()
		self.Cable_temp = C_Cable_temp()



-- 
Michael
_______________________________________________
python-de maillist  -  [email protected]
https://mail.python.org/mailman/listinfo/python-de
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.