1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-30 00:00:11 +01:00
VILLASnode/python/villas/human/message.py

30 lines
722 B
Python

import villas.human.timestamp as ts
from functools import total_ordering
@total_ordering
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(cls, 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 __eq__(self, other):
return self.ts == other.ts
def __lt__(self, other):
return self.ts < other.ts