2015-10-21 12:22:59 +02:00
|
|
|
from . import ts
|
|
|
|
|
|
|
|
class Message:
|
2016-06-08 23:21:42 +02:00
|
|
|
"""Parsing a VILLASnode sample from a file (not a UDP package!!)"""
|
2015-10-21 12:22:59 +02:00
|
|
|
|
|
|
|
def __init__(self, ts, values, source = None):
|
|
|
|
self.source = source
|
|
|
|
self.ts = ts
|
|
|
|
self.values = values
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def parse(self, line, source = None):
|
|
|
|
csv = line.split()
|
|
|
|
|
|
|
|
t = ts.Timestamp.parse(csv[0])
|
|
|
|
v = map(float, csv[1:])
|
|
|
|
|
|
|
|
return Message(t, v, source)
|
|
|
|
|
|
|
|
def __str__(self):
|
2015-10-21 12:41:26 +02:00
|
|
|
return '%s %s' % (self.ts, " ".join(map(str, self.values)))
|
2015-10-21 12:22:59 +02:00
|
|
|
|
|
|
|
def __cmp__(self, other):
|
2015-10-21 12:41:26 +02:00
|
|
|
return cmp(self.ts, other.ts)
|