1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/tools/python/villas/msg.py

24 lines
525 B
Python

from . import ts
class Message:
"""Parsing a VILLASnode sample from a file (not a UDP package!!)"""
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):
return '%s %s' % (self.ts, " ".join(map(str, self.values)))
def __cmp__(self, other):
return cmp(self.ts, other.ts)