private static void HandleAccessResponse(GXDLMSSettings settings, GXReplyData reply)
{
int start = reply.Data.Position - 1;
//Get invoke id.
UInt32 invokeId = reply.Data.GetUInt32();
reply.Time = DateTime.MinValue;
int len = reply.Data.GetUInt8();
byte[] tmp = null;
// If date time is given.
if (len != 0)
{
tmp = new byte[len];
reply.Data.Get(tmp);
reply.Time = (GXDateTime)GXDLMSClient.ChangeType(tmp, DataType.DateTime);
}
if (reply.Xml != null)
{
reply.Xml.AppendStartTag(Command.AccessResponse);
reply.Xml.AppendLine(TranslatorTags.LongInvokeId, "Value", reply.Xml.IntegerToHex(invokeId, 8));
reply.Xml.AppendLine(TranslatorTags.DateTime, "Value", GXCommon.ToHex(tmp, false));
//access-request-specification OPTIONAL
reply.Data.GetUInt8();
len = GXCommon.GetObjectCount(reply.Data);
reply.Xml.AppendStartTag(TranslatorTags.AccessResponseBody);
reply.Xml.AppendStartTag(
TranslatorTags.AccessResponseListOfData, "Qty",
reply.Xml.IntegerToHex(len, 2));
for (int pos = 0; pos != len; ++pos)
{
if (reply.Xml.OutputType == TranslatorOutputType.StandardXml)
{
reply.Xml.AppendStartTag(Command.WriteRequest,
SingleReadResponse.Data);
}
GXDataInfo di = new GXDataInfo();
di.xml = reply.Xml;
GXCommon.GetData(settings, reply.Data, di);
if (reply.Xml.OutputType == TranslatorOutputType.StandardXml)
{
reply.Xml.AppendEndTag(Command.WriteRequest,
SingleReadResponse.Data);
}
}
reply.Xml.AppendEndTag(TranslatorTags.AccessResponseListOfData);
//access-response-specification
int err;
len = GXCommon.GetObjectCount(reply.Data);
reply.Xml.AppendStartTag(TranslatorTags.ListOfAccessResponseSpecification, "Qty", reply.Xml.IntegerToHex(len, 2));
for (int pos = 0; pos != len; ++pos)
{
AccessServiceCommandType type = (AccessServiceCommandType)reply.Data.GetUInt8();
err = reply.Data.GetUInt8();
if (err != 0)
{
err = reply.Data.GetUInt8();
}
reply.Xml.AppendStartTag(
TranslatorTags.AccessResponseSpecification);
reply.Xml.AppendStartTag(Command.AccessResponse, type);
reply.Xml.AppendLine(TranslatorTags.Result, null,
GXDLMSTranslator.ErrorCodeToString(reply.Xml.OutputType,
(ErrorCode)err));
reply.Xml.AppendEndTag(Command.AccessResponse, type);
reply.Xml.AppendEndTag(
TranslatorTags.AccessResponseSpecification);
}
reply.Xml.AppendEndTag(
TranslatorTags.ListOfAccessResponseSpecification);
reply.Xml.AppendEndTag(TranslatorTags.AccessResponseBody);
reply.Xml.AppendEndTag(Command.AccessResponse);
}
else
{
//Skip access-request-specification
reply.Data.GetUInt8();
}
}