Exemple #1
0
    def test_power_event_log_empty_2(self):
        pef_parser = ProfileGenericParser(BUFFER_TYPES, PG_HEAD_PARSERS, PG_UNIDENTIFIED_BUFFERTYPE_PARSERS)
        object_type = ProfileGenericObject

        # Power Event Log with 0 items and no object type
        pefl_line = r'1-0:99.97.0(0)()\r\n'
        testitem = pef_parser.parse(pefl_line)

        assert isinstance(testitem, object_type)
        assert testitem.buffer_length == 0
        assert testitem.buffer_type is None
        buffer = testitem.buffer
        assert isinstance(testitem.buffer, list)
        assert len(buffer) == 0
        assert testitem.values == [{'value': 0, 'unit': None}, {'value': None, 'unit': None}]
        json = testitem.to_json()
        assert json == '{"buffer_length": 0, "buffer_type": null, "buffer": []}'
Exemple #2
0
    def test_power_event_log_null_values(self):
        pef_parser = ProfileGenericParser(BUFFER_TYPES, PG_HEAD_PARSERS, PG_UNIDENTIFIED_BUFFERTYPE_PARSERS)
        object_type = ProfileGenericObject

        # Power Event Log with 1 item and no object type and nno values for the item
        pefl_line = r'1-0:99.97.0(1)()()()\r\n'
        testitem = pef_parser.parse(pefl_line)

        assert isinstance(testitem, object_type)
        assert testitem.buffer_length == 1
        assert testitem.buffer_type is None
        buffer = testitem.buffer
        assert isinstance(testitem.buffer, list)
        assert len(buffer) == 1
        assert testitem.values == [{'value': 1, 'unit': None}, {'value': None, 'unit': None},
                                   {'value': None, 'unit': None}, {'value': None, 'unit': None}]
        json = testitem.to_json()
        assert json == \
               '{"buffer_length": 1, "buffer_type": null, "buffer": [{"datetime": null, "value": null, "unit": null}]}'
Exemple #3
0
    def test_power_event_log_brackets_only(self):
        # POWER_EVENT_FAILURE_LOG (1-0:99.97.0)
        # Issue 57
        # Test of an ill formatted empty POWER_EVENT_FAILURE_LOG, observed on some smartmeters
        # The idea is that instead of failing, the parser converts it to an empty POWER_EVENT_FAILURE_LOG
        pef_parser = ProfileGenericParser(BUFFER_TYPES, PG_HEAD_PARSERS, PG_UNIDENTIFIED_BUFFERTYPE_PARSERS)
        object_type = ProfileGenericObject

        pefl_line = r'1-0:99.97.0()\r\n'
        testitem = pef_parser.parse(pefl_line)

        assert isinstance(testitem, object_type)
        assert testitem.buffer_length == 0
        assert testitem.buffer_type is None
        buffer = testitem.buffer
        assert isinstance(testitem.buffer, list)
        assert len(buffer) == 0
        assert testitem.values == [{'value': 0, 'unit': None}, {'value': None, 'unit': None}]
        json = testitem.to_json()
        assert json == '{"buffer_length": 0, "buffer_type": null, "buffer": []}'
 obis.ELECTRICITY_DELIVERED_TARIFF_1:
 CosemParser(ValueParser(Decimal)),
 obis.ELECTRICITY_DELIVERED_TARIFF_2:
 CosemParser(ValueParser(Decimal)),
 obis.ELECTRICITY_ACTIVE_TARIFF:
 CosemParser(ValueParser(str)),
 obis.CURRENT_ELECTRICITY_USAGE:
 CosemParser(ValueParser(Decimal)),
 obis.CURRENT_ELECTRICITY_DELIVERY:
 CosemParser(ValueParser(Decimal)),
 obis.SHORT_POWER_FAILURE_COUNT:
 CosemParser(ValueParser(int)),
 obis.LONG_POWER_FAILURE_COUNT:
 CosemParser(ValueParser(int)),
 obis.POWER_EVENT_FAILURE_LOG:
 ProfileGenericParser(BUFFER_TYPES, PG_HEAD_PARSERS,
                      PG_UNIDENTIFIED_BUFFERTYPE_PARSERS),
 obis.VOLTAGE_SAG_L1_COUNT:
 CosemParser(ValueParser(int)),
 obis.VOLTAGE_SAG_L2_COUNT:
 CosemParser(ValueParser(int)),
 obis.VOLTAGE_SAG_L3_COUNT:
 CosemParser(ValueParser(int)),
 obis.VOLTAGE_SWELL_L1_COUNT:
 CosemParser(ValueParser(int)),
 obis.VOLTAGE_SWELL_L2_COUNT:
 CosemParser(ValueParser(int)),
 obis.VOLTAGE_SWELL_L3_COUNT:
 CosemParser(ValueParser(int)),
 obis.TEXT_MESSAGE_CODE:
 CosemParser(ValueParser(int)),
 obis.TEXT_MESSAGE: