Package: iflag
iflagA Python library for the Itron / Actaris IFLAG and Corus protocolInstallingInstall via pip, python 3.6+ onlypip install iflagAboutiflag is a library focused on reading and writing data to devices using the IFLAG or
Corus protocol. Mainly Itron / Actaris gas volume converters. Communication is done over
TCP/IPFeaturesThe library is now only focused on using Single Address Mode (SAM) of the Corus protocol
to access data. SEVC-D parameters of I-FLAG is not supported.Read parametersWrite parametersRead databases (logs), event log not yet implementedUsageDifferent firmware versions have different ID for each parameter. But the
parameter_id_map is always on id0x5e.
So the mapping should be known beforehand or it should be read from the device before
reading more values.Different firmware versions also have different database record layout. You will need
to supply a mapping of how the databases looks like for the meters you want to read.
A default mapping is not supplied since it would infer opinionated interpretation of
some values.You should create a mapping like:Dict[str, Dict[int, List[DatabaseRecordParameter]]]intervalis the database and52is the length of the database record. A list ofDatabaseRecordParameterin the order they are appearing in the data base record
will make it possible to convert the bytes into python values.Ex:{"interval":{52:[DatabaseRecordParameter(name="record_duration",data_class=data.Byte),DatabaseRecordParameter(name="status",data_class=data.Byte),DatabaseRecordParameter(name="end_date",data_class=data.Date),DatabaseRecordParameter(name="consumption_interval_unconverted",data_class=data.Word,affected_by_pulse_input=True,),DatabaseRecordParameter(name="consumption_interval_converted",data_class=data.ULong,affected_by_pulse_input=True,),DatabaseRecordParameter(name="counter_interval_unconverted",data_class=data.Word,affected_by_pulse_input=True,),DatabaseRecordParameter(name="counter_interval_converted",data_class=data.ULong,affected_by_pulse_input=True,),DatabaseRecordParameter(name="temperature_interval_minimum",data_class=data.Float1),DatabaseRecordParameter(name="temperature_interval_maximum",data_class=data.Float1),DatabaseRecordParameter(name="temperature_interval_average",data_class=data.Float1),DatabaseRecordParameter(name="pressure_interval_minimum",data_class=data.Float2),DatabaseRecordParameter(name="pressure_interval_maximum",data_class=data.Float2),DatabaseRecordParameter(name="pressure_interval_average",data_class=data.Float2),DatabaseRecordParameter(name="flowrate_unconverted_interval_minimum",data_class=data.Float3,affected_by_pulse_input=True,),DatabaseRecordParameter(name="flowrate_unconverted_interval_maximum",data_class=data.Float3,affected_by_pulse_input=True,),DatabaseRecordParameter(name="flowrate_converted_interval_minimum",data_class=data.Float3,affected_by_pulse_input=True,),DatabaseRecordParameter(name="flowrate_converted_interval_maximum",data_class=data.Float3,affected_by_pulse_input=True,),DatabaseRecordParameter(name="none_data_1",data_class=data.Null4),DatabaseRecordParameter(name="flowrate_unconverted_interval_average",data_class=data.Float3,affected_by_pulse_input=True,),DatabaseRecordParameter(name="flowrate_converted_interval_average",data_class=data.Float3,affected_by_pulse_input=True,),DatabaseRecordParameter(name="start_date",data_class=data.Date),DatabaseRecordParameter(name="none_data_2",data_class=data.Null2),]}}Good to know: There are several different float formats due to memory constraints in
the protocol and device. All floats are handled asdecimal.Decimalin Python to
not have float rounding errors.Read parameters:``pythonfrom iflag import CorusClient
from iflag.data import CorusString, Index
from iflag.parse import IFlagParameter
from decimal import Decimalclient = CorusClient.with_tcp_transport(address=("localhost", 4000))Read single valueclient.read_parameters([IFlagParameter(id=0x5e, data_class=CorusString)]){0x5e: "FL_b0040"}Read multiple valuesclient.read_parameters(
[
IFlagParameter(id=0x5e, data_class=CorusString),
IFlagParameter(id=48, data_class=Index),
IFlagParameter(id=49, data_class=Index)
]
){0x5e: "FL_b0040", 48: Decimal("234567.982"), 49: Decimal("222222.982")}### Write parameters

```python
from iflag import CorusClient, TcpTransport
from iflag.data import Date
from iflag.parse import IFlagParameter
from datetime import datetime

transport = TcpTransport(address=('localhost', 4000))
client = CorusClient(transport=transport)
client.write_parameters([(IFlagParameter(id=106, data_class=Date), datetime.now())])Read databasefromiflagimportCorusClientfromdatetimeimportdatetime,timedeltaclient=CorusClient.with_tcp_transport(address=('localhost',4000),database_layout=MY_DATABASE_LAYOUT)client.read_database(database='interval',start=datetime.now(),stop=(datetime.now()-timedelta(hours=4)))When reading databases you will need to know theinput_pulse_weight. If it is not
set on the client at initiation or on theread_databasecall the client will read it
from the meter automatically.ChangelogAll notable changes to this project will be documented in this file.The format is based onKeep a Changelog,
and this project adheres toSemantic Versioning.[Unreleased]AddedChangedDeprecatedRemovedFixedSecurity[1.0.1] - 2020-10-07FixedIndex9 was not parsed correctly due to misinterpretation of documentation.[1.0.0] - 2020-10-07ChangedSince different Corus firmware version have different parameter ids and different
data database layouts the library is rewritten to be less opinionated and work with
all firmwares. This means the user needs to know what ID represents what data and
how it is interpreted and how databases the they will read are structured.[0.2.0] - 2020-01-14RemovedRemoved internal session handling as it was in the way of optimizing running several actions
directly after each other. Instead now you need to callclient.startup()in the
beginning andclient.shutdown()when you are done.[0.1.2] - 2020-01-14ChangedSeparated value identification in parsing config for the different databases so that
it is possible to know if for example an average value is the monthly or hourly average.[0.1.1] - 2020-01-08FixedFixed error in setup.py that listed the wrong dependency. (attr instead of attrs)[0.1.0] - 2020-01-08 [YANKED]AddedInitial implementation of reading and writing data to Corus device.