diff options
author | yvesf <yvesf-git@xapek.org> | 2010-08-15 22:54:27 +0200 |
---|---|---|
committer | yvesf <yvesf-git@xapek.org> | 2010-08-15 22:54:27 +0200 |
commit | 7ff580a6fe60f7e3ea160f7b181ff0fa934453ce (patch) | |
tree | 55ea82fdffaaf50ed099f3bc663cb083952d1fc5 /ebus/model/__init__.py | |
parent | 3e70cb0892a703888e913ee5a1545f488a22a4a3 (diff) | |
download | ebus-alt-7ff580a6fe60f7e3ea160f7b181ff0fa934453ce.tar.gz ebus-alt-7ff580a6fe60f7e3ea160f7b181ff0fa934453ce.zip |
So 15. Aug 22:54:27 CEST 2010
Diffstat (limited to 'ebus/model/__init__.py')
-rw-r--r-- | ebus/model/__init__.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ebus/model/__init__.py b/ebus/model/__init__.py index ecdf3bc..1e2d080 100644 --- a/ebus/model/__init__.py +++ b/ebus/model/__init__.py @@ -1,3 +1,4 @@ +# -*- coding:utf8 -*- class DataField(object): def __init__(self, name, offset): self.name = name @@ -5,20 +6,20 @@ class DataField(object): def value(self,data): raise NotImplemented() - class Data1b(DataField): - """ +class Data1b(DataField): + """ Beispiel für die Berechnung: if ((x & 80h) == 80h) // y negativ y = - [dez(!x) + 1] else y = dez(x) """ - def value(self,data): - x = ord(data[self.offset]) - if x & 0x80 == 0x80: - return (-1) * (0xff^x + 1) - else: - return x + def value(self,data): + x = ord(data[self.offset]) + if x & 0x80 == 0x80: + return (-1) * (0xff^x + 1) + else: + return x class Data1c(DataField): def value(self,data): @@ -81,7 +82,7 @@ class Byte(DataField): class ByteEnum(DataField): def __init__(self, name, offset, values): - fields.DataField.__init__(self, name, offset) + DataField.__init__(self, name, offset) self.values = values def value(self, data): |