Esempio n. 1
0
        public Byte[] BuilAliveMessage()
        {
            var size = Marshal.SizeOf(typeof(SingleTaskCommand));

            buffer = new Byte[size];
            IntPtr pnt = Marshal.AllocHGlobal(size);

            buffer.Initialize();
            CommandHeader     datagram = new CommandHeader();
            SingleTaskCommand order    = datagram.order;

            // datagram.order.task = 'I';
            order.command  = Commands.KeepConnected;
            datagram.order = order;
            try
            {
                // Copy the struct to unmanaged memory.
                Marshal.StructureToPtr(order, pnt, false);
                Marshal.Copy(pnt, buffer, 0, size);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pnt);
            }


            return(buffer);
        }
Esempio n. 2
0
        public Byte[] BuildAliveMessage()
        {
            CommandHeader     datagram = new CommandHeader();
            SingleTaskCommand order    = datagram.order;

            // datagram.order.task = 'I';
            order.command  = Commands.KeepConnected;
            datagram.order = order;
            buffer.Initialize();

            Buffer.BlockCopy(datagram.GetOrderArrayBytes(), 0, buffer, 0, buffer.Length);
            return(buffer);
        }
Esempio n. 3
0
        public Byte[] CreateFansStatusRequestMessage()
        {
            buffer = new Byte[sizeStruct];
            CommandHeader     datagram = new CommandHeader();
            SingleTaskCommand order    = datagram.order;

            order.task     = Commands.ReadFansStatus;
            datagram.order = order;
            SingleTaskMessage m;

            m.header      = order;
            m.description = 0;
            buffer.Initialize();
            Buffer.BlockCopy(GetSingleTaskCommandArrayBytes(m), 0, buffer, 0, sizeStruct);
            return(buffer);
        }
Esempio n. 4
0
        public Byte[] CreateEnableScavengeMessage(Byte p)
        {
            var size = Marshal.SizeOf(singleTaskMessage);

            buffer = new Byte[size];
            CommandHeader     datagram = new CommandHeader();
            SingleTaskCommand order    = datagram.order;

            order.task     = Commands.EnableScavenge;
            datagram.order = order;
            SingleTaskMessage m;

            m.header      = order;
            m.description = p;
            buffer.Initialize();
            Buffer.BlockCopy(GetSingleTaskCommandArrayBytes(m), 0, buffer, 0, size);
            return(buffer);
        }
Esempio n. 5
0
        public Byte[] CreateDataLogRequestMessage(UInt32 address)
        {
            var size = Marshal.SizeOf(dataLogAddress);

            buffer = new Byte[size];
            CommandHeader     datagram = new CommandHeader();
            SingleTaskCommand order    = datagram.order;

            order.task     = Commands.ReadDataLog;
            datagram.order = order;
            DataLogAddressMessage m;

            m.header  = order;
            m.address = address;
            buffer.Initialize();
            Buffer.BlockCopy(GetDataLogAddressArrayBytes(m), 0, buffer, 0, size);
            return(buffer);
        }
Esempio n. 6
0
        public Byte[] GetSingleTaskCommandArrayBytes(SingleTaskCommand pm)
        {
            int sizeMessage = Marshal.SizeOf(singleTaskCommand);

            Byte[] localBuffer = new Byte[sizeMessage];
            singleTaskCommand = pm;
            IntPtr pnt = Marshal.AllocHGlobal(sizeMessage);

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


                Marshal.Copy(pnt, localBuffer, 0, sizeMessage);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pnt);
            }
            return(localBuffer);
        }