mbusRecordGetType (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

LX4,NX-400

Firmware version:

1.94.00


This function returns the type of the record, indicating which functions can be used to read it.

 

 

Input:

handle : SYSHANDLE

A handle to the connection

 

index : INT

The index of the record.

 

Returns: INT

_MBUS_TYPE_TIME

- Time, can be read with mbusRecordGetLinsec and mbusRecordGetBuffer.

_MBUS_TYPE_TEXT

- Text, can be read with mbusRecordGetString and mbusRecordGetBuffer.

_MBUS_TYPE_FLOAT

- Float, can be read with mbusRecordGetFloat and mbusRecordGetBuffer.

_MBUS_TYPE_INT64

- Large integer, can be read with mbusRecordGetIntLarge and mbusRecordGetBuffer.

_MBUS_TYPE_INT32

- Integer, can be read with mbusRecordGetInt and mbusRecordGetBuffer.

_MBUS_TYPE_BUFFER

- Buffer, can be read with mbusRecordGetBuffer.

0

- Not supported / unknown type.

-1

- Invalid handle

-3

- No data found.

 

Declaration:

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