Пример #1
0
        //初始化网络数据流
        private void InitNetStream()
        {
            int buffSize = 1024;

            byte[] tempBuf       = new byte[buffSize];
            byte[] fileNameArray = new byte[FileNameMaxLength];
            _netStream = new Utilities.NetStreamProcess();

            try
            {
                byte[] fileBytes = System.Text.Encoding.ASCII.GetBytes(this._fileName);
                fileBytes.CopyTo(fileNameArray, 0);
                _netStream.PushBytes(fileNameArray);
                _netStream.PushInt32(this._slot);
                _netStream.PushInt32(this._type == EndType.FPGA ? 1 : 2);
                //把fileStream的内容添加到MemoryStream
                _fileStream.Seek(0, SeekOrigin.Begin);
                while (true)
                {
                    int retSize = _fileStream.Read(tempBuf, 0, buffSize);
                    if (retSize == 0)
                    {
                        break;
                    }
                    _netStream.PushBytes(tempBuf, retSize);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("InitNetStream:" + e.Message);
            }
        }
Пример #2
0
            public int GetLength(Byte[] headBytes)
            {
                var nsp = new Utilities.NetStreamProcess(headBytes);

                nsp.PopInt32();
                nsp.PopInt32();
                return(nsp.PopInt32());
            }
Пример #3
0
            private void ParsePacket(Byte[] bytes)
            {
                var nsp = new Utilities.NetStreamProcess(bytes);

                base._Pack_StartCode = (uint)nsp.PopInt32();
                base._Pack_Version   = (uint)nsp.PopInt32();
                base._Pack_Length    = (uint)nsp.PopInt32();

                base._Pack_CmdID   = (uint)nsp.PopInt32();
                this._Pack_Result  = (uint)nsp.PopInt32();
                base._Pack_Data    = nsp.PopBytes((int)base._Pack_Length - _minSize);
                base._Pack_EndCode = (uint)nsp.PopInt32();

                _lastCmdId = base._Pack_CmdID;
            }
Пример #4
0
            private void InitNetStream()
            {
                _netStream = new Utilities.NetStreamProcess();
                var cmdStream = _tcpCmd.GetNetStream();

                _netStream.PushInt32((int)base._Pack_StartCode);
                _netStream.PushInt32((int)base._Pack_Version);
                _netStream.PushInt32((int)base._Pack_Length);
                _netStream.PushInt32((int)(base._Pack_CmdID));

                _netStream.PushInt32((int)this._Pack_CmdCode);
                _netStream.PushInt32(0);
                if (cmdStream != null)
                {
                    cmdStream.WriteTo(_netStream);
                }
                _netStream.PushInt32((int)base._Pack_EndCode);
            }