Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5719
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] Konstanten in Struct-Form in Python |
| Date | Sat, 20 Feb 2021 09:37:05 +0100 |
| Lines | 43 |
| Message-ID | <mailman.98.1613810234.14271.python-de@python.org> (permalink) |
| References | <i9a065FttstU1@mid.individual.net> <27c6feec-669a-8d30-822c-d612d7cc464f@web.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de HY2ktI7CkYxvopRlA+bqGAQAB4EMEWpq24F8fh3cirpg== |
| Return-Path | <gcpgg-python-de@m.gmane-mx.org> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| Authentication-Results | mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral |
| X-Injected-Via-Gmane | http://gmane.org/ |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 |
| In-Reply-To | <i9a065FttstU1@mid.individual.net> |
| Content-Language | en-US |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.34 |
| Precedence | list |
| List-Id | Die Deutsche Python Mailingliste <python-de.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe> |
| List-Archive | <https://mail.python.org/pipermail/python-de/> |
| List-Post | <mailto:python-de@python.org> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <27c6feec-669a-8d30-822c-d612d7cc464f@web.de> |
| X-Mailman-Original-References | <i9a065FttstU1@mid.individual.net> |
| Xref | csiph.com de.comp.lang.python:5719 |
Show key headers only | View raw
On 19/02/2021 15:27, Michael S. wrote:
> Hallo Leute,
> Ich möchte ein Python Toolset schreiben, mit dem ich sehr einfach auf
> Signale in CAN-Botschaften zugreifen kann, die als CAN-Trace vorliegen.
> Das parsen des Traces läuft. Nun möchte ich aber die ganzen Infos zu den
> CAN-Signalen in einem "Include"-File möglichst einfach zugänglich machen.
> Daran scheitere ich.
>
>
> Tatsächlich gibt es zu jeder CAN-Botschaft mehrere Eigenschaften. Ich
> hatte das erstmal so codiert:
>
> class CAN_AC_Voltage:
> def __init__(self):
> self.ID = 16FC8B11
> self.BitOffset = 48
> self.BitLength = 8
> self.Gain = 1
> self.ValueOffset = 0
> self.Unit = "V"
> self.Rate = 0.5
>
>
> Dann könnte ich so zugreifen:
> CAN_ACV = CAN_AC_Voltage()
>
> ID = CAN_ACV.ID
> Unit = CAN_ACV.Unit
>
> Was mich dran nervt ist, dass jede einzelne CAN-Botschaft eine eigene
> Klasse ist und ich die im Code erstmal instanzieren muss, bevor ich sie
> nutzen kann. Das muss doch auch einfacher gehen.
from types import SimpleNamespace
CAN_AC_Voltage = SimpleNamespace(
ID=16FC8B11
BitOffset=48
BitLength=8,
...
)
Back to de.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Konstanten in Struct-Form in Python "Michael S." <michaely@bigfoot.de> - 2021-02-19 15:27 +0100
Re: [Python-de] Konstanten in Struct-Form in Python Hartmut Goebel <h.goebel@crazy-compilers.com> - 2021-02-19 15:43 +0100
Re: [Python-de] Konstanten in Struct-Form in Python Peter Otten <__peter__@web.de> - 2021-02-20 09:37 +0100
Re: Konstanten in Struct-Form in Python "Michael S." <michaely@bigfoot.de> - 2021-02-22 07:00 +0100
Re: Konstanten in Struct-Form in Python Marc 'BlackJack' Rintsch <marc@rintsch.de> - 2021-04-28 10:04 +0000
csiph-web