コード例 #1
0
        public static Memory <byte> TranslateToMemory(S7AckDataDatagram datagram)
        {
            var result = S7HeaderDatagram.TranslateToMemory(datagram.Header);

            S7HeaderErrorCodesDatagram.TranslateToMemory(datagram.Error, result.Slice(datagram.Header.GetHeaderSize()));
            return(result);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public static Memory <byte> TranslateToMemory(S7HeaderErrorCodesDatagram datagram, Memory <byte> memory)
        {
            var result = memory.IsEmpty ? new Memory <byte>(new byte[2]) : memory;  // check if we could use ArrayBuffer
            var span   = result.Span;

            span[0] = datagram.ErrorClass;
            span[1] = datagram.ErrorCode;

            return(result);
        }
コード例 #4
0
        public static S7HeaderErrorCodesDatagram TranslateFromMemory(Memory <byte> data)
        {
            var span   = data.Span;
            var result = new S7HeaderErrorCodesDatagram
            {
                ErrorClass = span[0],
                ErrorCode  = span[1]
            };

            return(result);
        }
コード例 #5
0
        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);
        }