mbusRecordGetType (Function)

Top  Previous  Next

Architecture:

NX32L

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;
   strunit : 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:=mbindex:=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.devicev2:=recInfo.funcv4:=recInfo.tariff);
 
         DebugFmt(message:="   Type: "+recInfo.text);
 
         type := mbusRecordGetType(handle:=mbindex:=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:=mbindex:=ivalue:=d);
            DebugMsg(message:="   Value:     "+floatToStr(v:=FLOAT(d)*scale)+" "+unit);
         END_IF;
 
      END_IF;
   END_FOR;
END_FUNCTION;
 
...