Example #1
0
        public static Memory <byte> TranslateToMemory(S7CommSetupAckDataDatagram datagram)
        {
            var result = S7AckDataDatagram.TranslateToMemory(datagram.Header);

            S7CommSetupParameterDatagram.TranslateToMemory(datagram.Parameter, result.Slice(datagram.Header.GetParameterOffset()));
            return(result);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #5
0
        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);
        }