summaryrefslogtreecommitdiffstats
path: root/shack/strom/main.py
diff options
context:
space:
mode:
authoreuer <root@euer.krebsco.de>2012-12-23 00:32:03 +0100
committereuer <root@euer.krebsco.de>2012-12-23 00:32:03 +0100
commit8de83da090cb7e430658291f01bca171213982b9 (patch)
tree4a0e04850d0d2c7f0175161e620cc0aef17e7bac /shack/strom/main.py
parent149989cc4f217ccc10a3237292537d7cb5021a6a (diff)
//shack is now part of //god
all modules operate with the outside world somehow and can be considered god mudules. sorry for your inconvenience
Diffstat (limited to 'shack/strom/main.py')
-rw-r--r--shack/strom/main.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/shack/strom/main.py b/shack/strom/main.py
deleted file mode 100644
index e1a85d02..00000000
--- a/shack/strom/main.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#! /usr/bin/python
-# -*- coding utf-8 -*-
-
-from __future__ import division
-
-import re
-
-
-class Reader(object):
- _re = re.compile(r'^(?P<field>\d-\d:\d+\.\d+\.\d+\*\d+)\((?P<value>\S+?)(?:\*[VAW])?\)$')
-
- def _convert_periode(value):
- return int(value, 16) / 100
-
- fields = {
- '1-0:1.8.0*255': ('overall', float),
- '1-0:31.7.0*255': ('l1_strom', float),
- '1-0:32.7.0*255': ('l1_spannung', float),
- '1-0:51.7.0*255': ('l2_strom', float),
- '1-0:52.7.0*255': ('l2_spannung', float),
- '1-0:71.7.0*255': ('l3_strom', float),
- '1-0:72.7.0*255': ('l3_spannung', float),
- '1-0:96.50.0*1': ('periode', _convert_periode),
- }
-
- def __init__(self, f):
- self._file = f
-
- def __iter__(self):
- data = {}
- for line in self._file:
- line = line.strip()
- if line == '!':
- yield data
- data = {}
- continue
- r = self._re.match(line)
- if not r:
- continue
- field = self.fields.get(r.group('field'))
- if field:
- data[field[0]] = field[1](r.group('value'))
- #uncomment to print unmapped values
- #else:
- # print r.groups()
-
-
-data_file = open('testdata')
-for data in Reader(data_file):
- print data