From 730fbfce4c64a0cac1b7f96ca75fc329d4d13ba1 Mon Sep 17 00:00:00 2001 From: Ioannis Papamanoglou Date: Tue, 3 Jan 2023 16:09:59 +0100 Subject: [PATCH] Add KFM5KAIFA support --- iec62056/grammar.lark | 2 +- iec62056/objects.py | 2 +- iec62056/parser.py | 2 +- iec62056/samples.py | 58 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/iec62056/grammar.lark b/iec62056/grammar.lark index 46c852b..7e09e72 100644 --- a/iec62056/grammar.lark +++ b/iec62056/grammar.lark @@ -59,7 +59,7 @@ DATETIME : DIGIT~12 DST : "S" | "W" -CHARACTER : "A".."Z" | "a".."z" | "0".."9" | "." | "-" | "_" +CHARACTER : "A".."Z" | "a".."z" | "0".."9" | "." | "-" | "_" | " " STRING : CHARACTER+ // we don't need CRLF. Besides, Kamstrup multical lacks trailing CRLF on last object diff --git a/iec62056/objects.py b/iec62056/objects.py index 2ab65c6..d103c58 100644 --- a/iec62056/objects.py +++ b/iec62056/objects.py @@ -57,7 +57,7 @@ def factory(cls, reference, timestamp, raw, unit): value = vcls(raw) name = n return cls(reference, name, timestamp, value, unit) - raise NotImplementedError('OBIS reference {} is not implemented'.format(repr(eeference))) + raise NotImplementedError('OBIS reference {} is not implemented'.format(repr(reference))) def __repr__(self): if self.timestamp is not None: diff --git a/iec62056/parser.py b/iec62056/parser.py index 66496ef..f3bbd92 100644 --- a/iec62056/parser.py +++ b/iec62056/parser.py @@ -87,7 +87,7 @@ def profilegeneric(self, tree): n = int(tree.pop(0)) reference = tree.pop(0) entries = tree - assert len(entries) == n + #assert len(entries) == n return [iec62056.objects.Register.factory(reference, timestamp, value, unit) for timestamp, value, unit in entries] def log(self, tree): diff --git a/iec62056/samples.py b/iec62056/samples.py index 10e3907..62e7407 100644 --- a/iec62056/samples.py +++ b/iec62056/samples.py @@ -252,3 +252,61 @@ b'!83A5\r\n' ) ALL.append(('ZIV_5CTA3', ZIV_5CTA3)) + +KFM5KAIFA = ( + '/KFM5KAIFA-METER\r\n' + '\r\n' + '1-3:0.2.8(40)\r\n' + '0-0:1.0.0(150117185916W)\r\n' + '0-0:96.1.1(0001)\r\n' + '1-0:1.8.1(000671.578*kWh)\r\n' + '1-0:1.8.2(000842.472*kWh)\r\n' + '1-0:2.8.1(000111.000*kWh)\r\n' + '1-0:2.8.2(000000.111*kWh)\r\n' + '0-0:96.14.0(0001)\r\n' + '1-0:1.7.0(00.333*kW)\r\n' + '1-0:2.7.0(00.000*kW)\r\n' + '0-0:17.0.0(999.9*kW)\r\n' + '0-0:96.3.10(1)\r\n' + '0-0:96.7.21(00008)\r\n' + '0-0:96.7.9(00007)\r\n' + '1-0:99.97.0(1)(0-0:96.7.19)\r\n' + '1-0:32.32.0(00001)\r\n' + '1-0:52.32.0(00002)\r\n' + '1-0:72.32.0(00003)\r\n' + '1-0:32.36.0(00004)\r\n' + '1-0:52.36.0(00005)\r\n' + '1-0:72.36.0(00006)\r\n' + '0-0:96.13.1(short message)\r\n' + '0-0:96.13.0(long message 0000000000000000000000000000000000000000000000000000000000000000000000000000)\r\n' + '1-0:32.7.0(380.000*V)\r\n' + '1-0:52.7.0(381.000*V)\r\n' + '1-0:72.7.0(382.000*V)\r\n' + '1-0:31.7.0(003*A)\r\n' + '1-0:51.7.0(002*A)\r\n' + '1-0:71.7.0(001*A)\r\n' + '1-0:21.7.0(00.332*kW)\r\n' + '1-0:41.7.0(00.333*kW)\r\n' + '1-0:61.7.0(00.334*kW)\r\n' + '1-0:22.7.0(00.010*kW)\r\n' + '1-0:42.7.0(00.020*kW)\r\n' + '1-0:62.7.0(00.030*kW)\r\n' + '0-1:24.1.0(003)\r\n' + '0-1:96.1.0(GAS0000000000000000000000000000000)\r\n' + '0-1:24.2.1(150117160000W)(00473.789*m3)\r\n' + '0-1:24.4.0(1)\r\n' + '0-3:24.1.0(003)\r\n' + '0-3:96.1.0(HEAT000000000000000000000000000000)\r\n' + '0-3:24.2.1(150117170000W)(00473.789*GJ)\r\n' + '0-3:24.4.0(1)\r\n' + '0-2:24.1.0(003)\r\n' + '0-2:96.1.0(WATER000000000000000000000000000000)\r\n' + '0-2:24.2.1(150117180000W)(00473.789*m3)\r\n' + '0-2:24.4.0(1)\r\n' + '0-4:24.1.0(003)\r\n' + '0-4:96.1.0(SLAVE00000000000000000000000000000)\r\n' + '0-4:24.2.1(150117190000W)(00473.789*m3)\r\n' + '0-4:24.4.0(1)\r\n' + '!E6FF\r\n' +) +ALL.append(('KFM5KAIFA', KFM5KAIFA))