mbusRecordGetInfo (Functionblock)

Top  Previous  Next

Architecture:

NX32L

Device support:

LX4,NX-400

Firmware version:

1.94.00


This function block will provide information about the records requested with mbusDataRequest or received with mbusDataReceive.

 

The VIF describes the unit and multiplier for the value, e.g. a VIF of 0x15 indicates that the value is in W and must be multiplied by 10.

Please refer to the M-Bus documentation for details about the VIF/VIFE tables etc.

 

 

 

Input:

handle : SYSHANDLE

A handle to the connection
 

index : INT

The index of the record to read, starting with index 1. mbusRecordCount can be used to get the total number of records.

 

Output:

type : SINT

The record type:

1

- Fixed data structure.

2

- Variable data structure.

3

- Application error. Error code can be found as value in the record.

 

address: STRING

The address associated with this record. For simple packages it will match the slave address, but other times, the record may have been forwarded from another meter with this address.

 

VIF : USINT

Value Information Field, indicates the type of value the record contains, e.g. the unit and multiplier.

Bit 7 is the extension bit. If it is set, the VIF is extended with the contents of VIFE[1].

If bit 0-6 is less than 0x7B, the primary VIF table must be used.

If the VIF is 0xFD or 0xFB, the extension VIF tables must be used to look up the value of VIFE[1].

If the VIF is 0x7F or 0xFF, the data is manufacturer specific.

If the VIF is 0x7C/0xFC, a custom string is used for the VIF, which can be found in the text variable.

 

VIFE : ARRAY [1..10] OF USINT

VIF Extension, indicates the type of value the record contains, e.g. the unit and multiplier, if the extension bit is set in the VIF.

If the extension bit is set in VIFE[n], VIFE[n+1] is valid.

 

text : STRING

String describing the unit and multiplier. If VIF is 0x7C, this was sent from the slave, otherwise this is the result of a table lookup, which does not know all the manufacturer specific values.

 

func : SINT

The type of value.

0

- Instantaneous value

1

- Minimum value

2

- Maximum value

3

- Value during error state

 

device : INT

Index of the sub device the record belongs to.

 

tariff : DINT

The tariff value for the record.

 

storage : DINT

The storage value for the record (lower 32 bits).

 

storage_upper : UINT

The storage value for the record (upper 9 bits, will normally be 0).

 

ready : BOOL

TRUE if the information is available, FALSE if not.

 

 

Declaration:

FUNCTION_BLOCK mbusRecordGetInfo;
VAR_INPUT
  handle : SYSHANDLE;
  index   : INT;
END_VAR;
VAR_OUTPUT
  tariff   : DINT;
  storage  : DINT;
  storage_upper: UINT;
  text     : STRING;
  address  : STRING;
  device   : INT;
  func     : SINT;
  type     : SINT;
  VIFE     : ARRAY[1..10] OF USINT;
  VIF      : USINT;
  ready    : BOOL;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  mb : SYSHANDLE;
  recInfo   : mbusRecordGetInfo;
END_VAR;

 
FUNCTION DumpRecords;
VAR
  rc    : INT;
  count : INT;
  i     : INT;
  str, unit : STRING;
  scale : FLOAT;
  type  : INT;
  d     : DINT;
END_VAR;
  count := mbusRecordCount(handle:=mb);
  DebugFmt(message:=" Records: \1", v1:=count);
 
 
  FOR i := 0 TO count DO
    recInfo(handle:=mb, index:=i);
    IF recInfo.ready THEN
        str := "  Record "+intToStr(v:=i)+", Type: " + intToStr(v:=recInfo.type);
 
        scale:=1.0;
        unit:="";
 
        str := str + ", VIF: "+sintToHex(v:=recInfo.VIF)+", VIFE: "
           + sintToHex(v:=recInfo.VIFE[1])+" "+sintToHex(v:=recInfo.VIFE[2]);
        DebugFmt(message:=str);
        DebugFmt(message:="   Addr: "+recInfo.address);
        DebugFmt(message:="   Dev: \1, Func: \2, Tar \4, Stor: "+dintToStr(v:=recInfo.storage),
                          v1:=recInfo.device, v2:=recInfo.func, v4:=recInfo.tariff);
 
        DebugFmt(message:="   Type: "+recInfo.text);
 
        type := mbusRecordGetType(handle:=mb, index:=i);
        DebugFmt(message:="   Data Type: \1", v1:=type);
 
        IF recInfo.VIF = 16#14 THEN
          // Volume [1e-2  m^3]
          unit := "m^3";
          scale := 0.01;
        END_IF;
 
 
        IF type = _MBUS_TYPE_INT32 THEN
          rc := mbusRecordGetInt(handle:=mb, index:=i, value:=d);
          DebugMsg(message:="   Value:     "+floatToStr(v:=FLOAT(d)*scale)+" "+unit);
        END_IF;
 
    END_IF;
  END_FOR;
END_FUNCTION;
 
...