mbusRecordCount (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

LX4,NX-400

Firmware version:

1.94.00


This function returns the number of records available from the slave, requested with mbusDataRequest.

 

 

Input:

handle : SYSHANDLE

A handle to the connection

 

Returns: INT

>0

- The number of records

0

- Not supported.

-1

- Invalid handle

-3

- No data found.

 

Declaration:

FUNCTION mbusRecordCount : INT;
VAR_INPUT
  handle   : SYSHANDLE;
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;
 
...