|
|
@ -46,29 +46,41 @@ public class ASDU : APCI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void ParseHeader(IByteBuffer byteBuffer, ASDU asdu)
|
|
|
|
public static void ParseHeader(byte[] data, ASDU asdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var start = ChargerConst.StartChar.Length - 1;
|
|
|
|
IByteBuffer byteBuffer = Unpooled.WrappedBuffer(data);
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var start = ChargerConst.StartChar.Length - 1;
|
|
|
|
|
|
|
|
|
|
|
|
asdu.PackLen = byteBuffer.GetUnsignedShortLE(start + 1);
|
|
|
|
asdu.PackLen = byteBuffer.GetUnsignedShortLE(start + 1);
|
|
|
|
asdu.CtlArea = byteBuffer.GetUnsignedInt(start + 3);
|
|
|
|
asdu.CtlArea = byteBuffer.GetUnsignedInt(start + 3);
|
|
|
|
asdu.DestAddr = new[]
|
|
|
|
asdu.DestAddr = new[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byteBuffer.GetByte(start + 7),
|
|
|
|
|
|
|
|
byteBuffer.GetByte(start + 8),
|
|
|
|
|
|
|
|
byteBuffer.GetByte(start + 9),
|
|
|
|
|
|
|
|
byteBuffer.GetByte(start + 10)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
asdu.SrcAddr = byteBuffer.GetUnsignedInt(start + 11);
|
|
|
|
|
|
|
|
asdu.FrameTypeNo = byteBuffer.GetByte(start + 15);
|
|
|
|
|
|
|
|
asdu.MsgBodyCount = byteBuffer.GetByte(start + 16);
|
|
|
|
|
|
|
|
asdu.TransReason = byteBuffer.GetUnsignedShortLE(start + 17);
|
|
|
|
|
|
|
|
asdu.PublicAddr = byteBuffer.GetUnsignedShortLE(start + 19);
|
|
|
|
|
|
|
|
asdu.MsgBodyAddr = new[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byteBuffer.GetByte(start + 21),
|
|
|
|
|
|
|
|
byteBuffer.GetByte(start + 22),
|
|
|
|
|
|
|
|
byteBuffer.GetByte(start + 23)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
byteBuffer.GetByte(start + 7),
|
|
|
|
throw e;
|
|
|
|
byteBuffer.GetByte(start + 8),
|
|
|
|
}
|
|
|
|
byteBuffer.GetByte(start + 9),
|
|
|
|
finally
|
|
|
|
byteBuffer.GetByte(start + 10)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
asdu.SrcAddr = byteBuffer.GetUnsignedInt(start + 11);
|
|
|
|
|
|
|
|
asdu.FrameTypeNo = byteBuffer.GetByte(start + 15);
|
|
|
|
|
|
|
|
asdu.MsgBodyCount = byteBuffer.GetByte(start + 16);
|
|
|
|
|
|
|
|
asdu.TransReason = byteBuffer.GetUnsignedShortLE(start + 17);
|
|
|
|
|
|
|
|
asdu.PublicAddr = byteBuffer.GetUnsignedShortLE(start + 19);
|
|
|
|
|
|
|
|
asdu.MsgBodyAddr = new[]
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
byteBuffer.GetByte(start + 21),
|
|
|
|
byteBuffer.Release();
|
|
|
|
byteBuffer.GetByte(start + 22),
|
|
|
|
}
|
|
|
|
byteBuffer.GetByte(start + 23)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|