Exemple #1
0
        private Byte[] GetFullBufferCommandArrayBytes(Full64BufferMessage pm)
        {
            Byte[] locabBuffer = new Byte[64];
            message64 = Buffer64BytesHandler.Message64;
            int sizeMessage = Marshal.SizeOf(message64);

            message64 = pm;
            IntPtr pnt = Marshal.AllocHGlobal(64);

            try
            {
                // Copy the struct to unmanaged memory.
                Marshal.StructureToPtr(message64, pnt, false);



                Marshal.Copy(pnt, locabBuffer, 0, 64);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pnt);
            }
            return(locabBuffer);
        }
Exemple #2
0
        public Byte[] CreateCommandFlapperValveMessage(Byte[] p)
        {
            // var size = Marshal.SizeOf(singleTaskMessage);
            buffer = new Byte[64];
            buffer.Initialize();

            //  Buffer64BytesHandler datagram = new CommandHeader();
            //    SingleTaskCommand order = datagram.order;

            //  order.task = Commands.CommandFlapperValve;

            message64             = Buffer64BytesHandler.Message64;
            message64.header.task = Commands.CommandFlapperValve;
            local_buffer          = new byte[2];
            local_buffer          = p;
            //   Buffer.BlockCopy(local_buffer, 0, message64.content, 0, 2);
            //   datagram.order = order;
            //     SingleTaskMessage m;
            //      m.header = order;
            //    m.description = p;
            var sizeMessage = Marshal.SizeOf(singleTaskCommand);

            Buffer.BlockCopy(GetSingleTaskCommandArrayBytes(message64.header), 0, buffer, 0, sizeMessage);
            Buffer.BlockCopy(local_buffer, 0, buffer, sizeMessage, 2);
            return(buffer);
        }
Exemple #3
0
 public Buffer64BytesHandler()
 {
     handler           = this;
     commandHeader     = new CommandHeader();
     message64         = new Full64BufferMessage();
     message64.header  = commandHeader.order;
     remainingSize     = 64 - Marshal.SizeOf(message64.header);
     message64.content = new Byte[remainingSize];
 }
Exemple #4
0
        public Byte[] CreateCompressorMessage(Byte[] p)
        {
            buffer = new Byte[64];
            buffer.Initialize();
            message64             = Buffer64BytesHandler.Message64;
            message64.header.task = Commands.EnableCompressor;
            local_buffer          = new byte[4];
            local_buffer          = p;
            var sizeMessage = Marshal.SizeOf(singleTaskCommand);

            Buffer.BlockCopy(GetSingleTaskCommandArrayBytes(message64.header), 0, buffer, 0, sizeMessage);
            Buffer.BlockCopy(local_buffer, 0, buffer, sizeMessage, 4);
            return(buffer);
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public Byte[] CreateSetpointFlapperValveMessage(Byte[] p)
        {
            buffer = new Byte[64];
            buffer.Initialize();
            message64             = Buffer64BytesHandler.Message64;
            message64.header.task = Commands.SetPointFlapperValve;
            local_buffer          = new byte[2];
            local_buffer          = p;
            var sizeMessage = Marshal.SizeOf(singleTaskCommand);

            Buffer.BlockCopy(GetSingleTaskCommandArrayBytes(message64.header), 0, buffer, 0, sizeMessage);
            Buffer.BlockCopy(local_buffer, 0, buffer, sizeMessage, 2);
            return(buffer);
        }