public static S7ReadJobAckDatagram TranslateFromMemory(Memory <byte> data) { var span = data.Span; var result = new S7ReadJobAckDatagram { Header = S7AckDataDatagram.TranslateFromMemory(data), }; var offset = result.Header.GetParameterOffset(); result.Function = span[offset++]; result.ItemCount = span[offset++]; for (var i = 0; i < result.ItemCount; i++) { var res = S7DataItemSpecification.TranslateFromMemory(data.Slice(offset)); result.Data.Add(res); offset += res.GetSpecificationLength(); if (offset % 2 != 0) { offset++; } } return(result); }
public static Memory <byte> TranslateToMemory(S7CommSetupAckDataDatagram datagram) { var result = S7AckDataDatagram.TranslateToMemory(datagram.Header); S7CommSetupParameterDatagram.TranslateToMemory(datagram.Parameter, result.Slice(datagram.Header.GetParameterOffset())); return(result); }
public static Memory <byte> TranslateToMemory(S7AckDataDatagram datagram) { var result = S7HeaderDatagram.TranslateToMemory(datagram.Header); S7HeaderErrorCodesDatagram.TranslateToMemory(datagram.Error, result.Slice(datagram.Header.GetHeaderSize())); return(result); }
public static IMemoryOwner <byte> TranslateToMemory(S7AckDataDatagram datagram, out int memoryLength) { var result = S7HeaderDatagram.TranslateToMemory(datagram.Header, datagram.Header.GetHeaderSize() + datagram.Error.GetSize() + datagram.Header.ParamLength + datagram.Header.DataLength, out memoryLength); var take = memoryLength - datagram.Header.GetHeaderSize(); S7HeaderErrorCodesDatagram.TranslateToMemory(datagram.Error, result.Memory.Slice(datagram.Header.GetHeaderSize(), take)); return(result); }
public static IMemoryOwner <byte> TranslateToMemory(S7CommSetupAckDataDatagram datagram, out int memoryLength) { var result = S7AckDataDatagram.TranslateToMemory(datagram.Header, out memoryLength); var take = memoryLength - datagram.Header.GetParameterOffset(); S7CommSetupParameterDatagram.TranslateToMemory(datagram.Parameter, result.Memory.Slice(datagram.Header.GetParameterOffset(), take)); return(result); }
public static S7CommSetupAckDataDatagram TranslateFromMemory(Memory <byte> data) { var result = new S7CommSetupAckDataDatagram { Header = S7AckDataDatagram.TranslateFromMemory(data), }; result.Parameter = S7CommSetupParameterDatagram.TranslateFromMemory(data.Slice(result.Header.GetParameterOffset())); return(result); }
public static S7AckDataDatagram TranslateFromMemory(Memory <byte> data) { var result = new S7AckDataDatagram { Header = S7HeaderDatagram.TranslateFromMemory(data) }; result.Error = S7HeaderErrorCodesDatagram.TranslateFromMemory(data.Slice(result.Header.GetHeaderSize())); return(result); }
public static Memory <byte> TranslateToMemory(S7ReadJobAckDatagram datagram) { var result = S7AckDataDatagram.TranslateToMemory(datagram.Header); var span = result.Span; var offset = datagram.Header.Header.GetHeaderSize(); span[offset++] = datagram.Function; span[offset++] = datagram.ItemCount; foreach (var item in datagram.Data) { S7DataItemSpecification.TranslateToMemory(item, result.Slice(offset)); offset += item.GetSpecificationLength(); } return(result); }
public static IMemoryOwner <byte> TranslateToMemory(S7WriteJobAckDatagram datagram, out int memoryLength) { var result = S7AckDataDatagram.TranslateToMemory(datagram.Header, out memoryLength); var mem = result.Memory.Slice(0, memoryLength); var span = mem.Span; var offset = datagram.Header.Header.GetHeaderSize(); span[offset++] = datagram.Function; span[offset++] = datagram.ItemCount; foreach (var item in datagram.Data) { S7DataItemWriteResult.TranslateToMemory(item, mem.Slice(offset)); offset += item.GetSpecificationLength(); } return(result); }
public static IMemoryOwner <byte> TranslateToMemory(S7ReadJobAckDatagram datagram, out int memoryLength) { var result = S7AckDataDatagram.TranslateToMemory(datagram.Header, out memoryLength); var take = memoryLength - datagram.Header.GetParameterOffset(); var mem = result.Memory.Slice(datagram.Header.GetParameterOffset(), take); var span = mem.Span; var offset = 0; span[offset++] = datagram.Function; span[offset++] = datagram.ItemCount; foreach (var item in datagram.Data) { S7DataItemSpecification.TranslateToMemory(item, mem.Slice(offset)); offset += item.GetSpecificationLength(); if (offset % 2 != 0) { offset++; } } return(result); }