Exemplo n.º 1
0
        /// <summary>
        /// 不会改变运行状态,只重新初始化数据.
        /// </summary>
        public void Reset()
        {
            Buffer = new CycleList <byte>(PackageLengthMax * 2);
            Buffer.OnThrowObeject += new CycleList <byte> .ThrowObeject(Buffer_OnThrowObeject);

            ReceiveFrame = new CycleList <ZFrame>(5);
            ReceiveFrame.OnThrowObeject += new CycleList <ZFrame> .ThrowObeject(ReceiveFrame_OnThrowObeject);

            ReceiveBlock = new CycleList <ZBlock>(50);
            ReceiveBlock.OnThrowObeject += new CycleList <ZBlock> .ThrowObeject(ReceiveBlock_OnThrowObeject);

            ZFrame SendFrame = new ZFrame();

            SendBlock  = new CycleList <ZBlock>(BlockNumMax);
            SendBuffer = new byte[PackageLengthMax];

            _ReceiveFrameNum = 0;
            _ReceiveBlockNum = 0;
            _LostByteNum     = 0;
            _LostFrameNum    = 0;
            _LostBlockNum    = 0;
            _ErrorFrameNum   = 0;
            _ErrorBlockNum   = 0;
        }
 void ReceiveFrame_OnThrowObeject(ZFrame ThrowedObject)
 {
     _LostFrameNum++;
     //UNDONE:发出提示
 }
 /// <summary>
 /// 写待发送帧头
 /// </summary>
 ///<param name="zFrame">帧头必须符合规范</param>
 public void WriteFrame(ZFrame zFrame)
 {
     SendFrame = zFrame;
 }
        /// <summary>
        /// 不会改变运行状态,只重新初始化数据.
        /// </summary>
        public void Reset()
        {
            Buffer = new CycleList<byte>(PackageLengthMax * 2);
            Buffer.OnThrowObeject += new CycleList<byte>.ThrowObeject(Buffer_OnThrowObeject);

            ReceiveFrame = new CycleList<ZFrame>(5);
            ReceiveFrame.OnThrowObeject += new CycleList<ZFrame>.ThrowObeject(ReceiveFrame_OnThrowObeject);

            ReceiveBlock = new CycleList<ZBlock>(50);
            ReceiveBlock.OnThrowObeject += new CycleList<ZBlock>.ThrowObeject(ReceiveBlock_OnThrowObeject);

            ZFrame SendFrame = new ZFrame();
            SendBlock = new CycleList<ZBlock>(BlockNumMax);
            SendBuffer = new byte[PackageLengthMax];

            _ReceiveFrameNum = 0;
            _ReceiveBlockNum = 0;
            _LostByteNum = 0;
            _LostFrameNum = 0;
            _LostBlockNum = 0;
            _ErrorFrameNum = 0;
            _ErrorBlockNum = 0;
        }
Exemplo n.º 5
0
        void ZProtocolProcessObj_OnReceviceFrame()
        {
            while (ZProtocolProcessObj.BufferFrameNum > 0)
            {
                ZFrame z = ZProtocolProcessObj.FetchFrame();//取出数据
                //更新显示
                tbSourceShow.Text  = z.Source.ToString();
                tbTargetShow.Text  = z.Target.ToString();
                tbReserveShow.Text = z.Reserve.ToString();
                //TODO:0Block事件处理
                if (z.PackageNum == 0)
                {
                    string s;
                    switch (z.Reserve)
                    {
                    case 0x05:
                        s = "OKFPGA";
                        break;

                    case 0xE5:
                        s = "ErrFPGA";
                        break;

                    case 0x10:
                        s = "MODEManual";
                        break;

                    case 0x11:
                        s = "MODEMix";
                        break;

                    case 0x12:
                        s = "MODETarget0";
                        break;

                    case 0x13:
                        s = "MODETargetP";
                        break;

                    case 0x14:
                        s = "MODETargetV";
                        break;

                    case 0x15:
                        s = "MODETargetX";
                        break;

                    case 0x16:
                        s = "MODEFactory";
                        break;

                    case 0x20:
                        s = "中位数据采集完成";
                        break;

                    default:
                        s = "UnknowEventID:0x" + z.Reserve.ToString("X");
                        break;
                    }
                    WriteLine(DateTime.Now.ToLongTimeString() + "-" + s);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 写待发送帧头
 /// </summary>
 ///<param name="zFrame">帧头必须符合规范</param>
 public void WriteFrame(ZFrame zFrame)
 {
     SendFrame = zFrame;
 }
Exemplo n.º 7
0
 void ReceiveFrame_OnThrowObeject(ZFrame ThrowedObject)
 {
     _LostFrameNum++;
     //UNDONE:发出提示
 }