summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandom Hacker <random_hacker@xapek.org>2010-08-27 19:45:58 +0200
committerRandom Hacker <random_hacker@xapek.org>2010-08-27 19:45:58 +0200
commitdef9c7873cd3a42fbb7b0b4b21ae364e4c9d61c8 (patch)
tree18e3e72fcc6d7104f1ca591d97b10d73a4eeea03
parent842a845c199726629f1ac45f8b06312d2e78423b (diff)
downloadebus-alt-def9c7873cd3a42fbb7b0b4b21ae364e4c9d61c8.tar.gz
ebus-alt-def9c7873cd3a42fbb7b0b4b21ae364e4c9d61c8.zip
timestamp issue
-rw-r--r--ebus/model/sql.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/ebus/model/sql.py b/ebus/model/sql.py
index de13239..219cfbc 100644
--- a/ebus/model/sql.py
+++ b/ebus/model/sql.py
@@ -33,7 +33,9 @@ class Value(ModelBase):
discriminator = Column('type', String(50))
__mapper_args__ = {'polymorphic_on': discriminator}
- def __init__(self, sensor, timestamp=datetime.now()):
+ def __init__(self, sensor, timestamp=None):
+ if not timestamp:
+ timestamp = datetime.now()
self.timestamp = timestamp
self.sensor = sensor
@@ -48,7 +50,7 @@ class ValueFloat(Value):
__mapper_args__ = {'polymorphic_identity': 'float'}
value_float = Column(Float(precision=4))
- def __init__(self, sensor, value, timestamp=datetime.now()):
+ def __init__(self, sensor, value, timestamp=None):
Value.__init__(self, sensor, timestamp)
self.value_float = value
@@ -59,7 +61,7 @@ class ValueInt(Value):
__mapper_args__ = {'polymorphic_identity': 'int'}
value_int = Column(Integer)
- def __init__(self, sensor, value, timestamp=datetime.now()):
+ def __init__(self, sensor, value, timestamp=None):
Value.__init__(self, sensor, timestamp)
self.value_int = value
@@ -70,7 +72,7 @@ class ValueString(Value):
__mapper_args__ = {'polymorphic_identity': 'string'}
value_string = Column(String)
- def __init__(self, sensor, value, timestamp=datetime.now()):
+ def __init__(self, sensor, value, timestamp=None):
Value.__init__(self, sensor, timestamp)
self.value_string = value
@@ -110,19 +112,19 @@ class EbusSQL(object):
yield ValueInt(sensor, \
model.Word(name, offset).value(packet.data))
elif field.tag == "data1b":
- yield ValueInt(sensor, \
+ yield ValueFloat(sensor, \
model.Data1b(name, offset).value(packet.data))
elif field.tag == "data1c":
- yield ValueInt(sensor, \
+ yield ValueFloat(sensor, \
model.Data1c(name, offset).value(packet.data))
elif field.tag == "data2b":
- yield ValueInt(sensor, \
+ yield ValueFloat(sensor, \
model.Data2b(name, offset).value(packet.data))
elif field.tag == "data2c":
- yield ValueInt(sensor,
+ yield ValueFloat(sensor,
model.Data2c(name, offset).value(packet.data))
elif field.tag == "bcd":
- yield ValueString(sensor,
+ yield ValueInt(sensor,
model.Bcd(name, offset).value(packet.data))
elif field.tag == "byteEnum":
options = dict(map(lambda opt: ( int(opt.get("value")[2:],16), opt.get("name")),