I checked read-method of TGXP Program and found it same of GetObjectsRequest to get sender data to meter.
When I send Activity Calendar data day profile ( array, structure of unsigned, Structure of octet string and long unsigned) to get responding data from meter, I got data using "TGXDLMSClient.GetData(reply: TBytes; data: TGXReplyData)" and it contained various kind of data like this;
resultval := Common.GetData(Reply.Data, info);
--> resultval is Tvalue data type.
Reply.Data of TGXByteBuffer is as bellows;
01 0A // Array data type, 10ea
02 02 // Structure data type, member varialbe 2ea
11 00 // Unsigned data type
01 0c // array data type 12ea
...
when I extract data from resultval of Tvalue like this
"extractdata := resultval.AsType<Tbytes>",
function TValue.AsType<T>: T;
begin
if not TryAsType<T>(Result) then
raise EInvalidCast.CreateRes(@SInvalidCast);
end;
"Invalid class typecast" exception error is occurred.
The reason of exception error is seemed to containing various data type of resultval (Tvalue type).
How can I solve this status to extract data from resultval?
Is there any function of parsing day profile of Activity Calendar?
Client.ParseObjects(GetReqReply.Data, True) in TGXProgram as bellows;
Reply.Data =
01 0A // Array data type, 10ea
02 02 // Structure data type, member varialbe 2ea
11 00 // Unsigned data type
01 0c // array data type 12ea
...
and enters TGXDLMSClient.ParseLNObjects(Reply.Data, true); in Gurux.DLMS.GXDLMSClient.pas.
procedure TGXDLMSClient.ParseLNObjects(buff : TGXByteBuffer; onlyKnownObjects : Boolean);
var
ot, cnt, objectCnt: Integer;
objects: TArray<TValue>;
comp : TGXDLMSObject;
info: TGXDataInfo;
begin
cnt := buff.GetUInt8(); //Check that data is in the array.
if cnt <> 1 Then
raise TGXDLMSException.Create('Invalid response.');
//Some meters give wrong item count.
while (buff.Position <> buff.Size) and (cnt <> objectCnt) do
begin
info.Clear();
objects := TGXCommon.GetData(buff, info).AsType<TArray<TValue>>;
if Length(objects) <> 4 Then
raise TGXDLMSException.Create('Invalid structure format.');
....
like above sentence, "Invalid structure Format" error is occurred, but actual result Length ( objects ) is two.
to continue ParseLNObjects function,
I disabled
"if Length(objects) <> 4 Then
raise TGXDLMSException.Create('Invalid structure format.');
but I faced in other error from
comp := CreateDLMSObject(ot, objects[1].AsType<WORD>, 0, Hobjects[2], Hobjects[3]);
by error of objects[1].AsType<WORD> by invalid type.
Sir I applied above Reply
Sir I applied above Reply.data to
Client.ParseObjects(GetReqReply.Data, True) in TGXProgram as bellows;
Reply.Data =
01 0A // Array data type, 10ea
02 02 // Structure data type, member varialbe 2ea
11 00 // Unsigned data type
01 0c // array data type 12ea
...
and enters TGXDLMSClient.ParseLNObjects(Reply.Data, true); in Gurux.DLMS.GXDLMSClient.pas.
procedure TGXDLMSClient.ParseLNObjects(buff : TGXByteBuffer; onlyKnownObjects : Boolean);
var
ot, cnt, objectCnt: Integer;
objects: TArray<TValue>;
comp : TGXDLMSObject;
info: TGXDataInfo;
begin
cnt := buff.GetUInt8(); //Check that data is in the array.
if cnt <> 1 Then
raise TGXDLMSException.Create('Invalid response.');
//Get object count
cnt := TGXCommon.GetObjectCount(buff);
objectCnt := 0;
info := TGXDataInfo.Create();
try
//Some meters give wrong item count.
while (buff.Position <> buff.Size) and (cnt <> objectCnt) do
begin
info.Clear();
objects := TGXCommon.GetData(buff, info).AsType<TArray<TValue>>;
if Length(objects) <> 4 Then
raise TGXDLMSException.Create('Invalid structure format.');
....
like above sentence, "Invalid structure Format" error is occurred, but actual result Length ( objects ) is two.
to continue ParseLNObjects function,
I disabled
"if Length(objects) <> 4 Then
raise TGXDLMSException.Create('Invalid structure format.');
but I faced in other error from
comp := CreateDLMSObject(ot, objects[1].AsType<WORD>, 0, Hobjects[2], Hobjects[3]);
by error of objects[1].AsType<WORD> by invalid type.
Please let me know its exact solution about it.
Hi,
Hi,
I have answered for your question here:
https://www.gurux.fi/node/13899
Please, don't create multiple topics from the same question.
BR,
Mikko
I got it. Thanks a lot
I got it. Thanks a lot