StartUploadRequest.cs 978 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using Core.Communication.Transport;
  2. using PLC.Siemens.Protocol.Common;
  3. using PLC.Siemens.Protocol.Header;
  4. using PLC.Siemens.O;
  5. namespace PLC.Siemens.Protocol.Upload
  6. {
  7. public class StartUploadRequest:IBuildRequest
  8. {
  9. public HeaderPacket Header { get; set; }
  10. public StartUploadParamsRequest Params { get; set; }
  11. public BlockType BlockType { get; set; }
  12. public ushort BlockNum { get; set; }
  13. public StartUploadRequest()
  14. {
  15. Header = new HeaderPacket();
  16. Params=new StartUploadParamsRequest();
  17. }
  18. public void Build()
  19. {
  20. Params.Build(BlockType, BlockNum);
  21. Header.Build(PduType.Request, Params.PacketLength, 0x000);
  22. }
  23. public ByteBuffer GetBuffer()
  24. {
  25. ByteBuffer buffer = ByteBuffer.Allocate();
  26. Header.GetByteBuffer(buffer);
  27. Params.GetByteBuffer(buffer);
  28. return buffer;
  29. }
  30. }
  31. }