Example #1
0
 /// <summary>
 /// 过滤VOB板卡正常灯位消息
 /// </summary>
 /// <param name="cr"></param>
 public void ProcessFilter(VOBTestResponse vvr)
 {
     if (vvr.ExpectedCode != vvr.RealCode)
     {
         FiltedVOBTestResponse fr = new FiltedVOBTestResponse(vvr);
         rxMsgQueue.Push(fr);
     }
 }
Example #2
0
        public int smallCycleBoard; //小周期号

        #endregion Fields

        #region Methods

        public override List<BaseResponse> Decode(BasePackage bp, OriginalBytes obytes)
        {
            base.Decode(bp, obytes);
            Cabinet cabinet = SpringHelper.GetObject<Cabinet>("cabinet");
            List<BaseResponse> list = new List<BaseResponse>();
            Board communicatinBoard = cabinet.GetCommunicationBoard(bp.RemoteIpEndPoint);
            //应用区数据格式:rack(1)+slot(1)+boardtype(1)+smallcycle(1)+lightport(2) +[采集到的码字(4)*16] +[错误次数(4)*16]
            if (bp.AppData.Length == 6 + 4 * 16 + 4 * 16)
            {
                byte rackNo = bp.AppData[0];
                byte slotNo = bp.AppData[1];
                byte boardType = bp.AppData[2];
                byte smallCycle = bp.AppData[3];
                UInt32[] realCodes = new UInt32[16];
                Int32[] errorTimes = new Int32[16];
                for (int i = 0; i < 16; i++)
                {
                    realCodes[i] = System.BitConverter.ToUInt32(bp.AppData, 6 + i * 4);
                    errorTimes[i] = System.BitConverter.ToInt32(bp.AppData, 6 + 64 + i * 4);
                }

                int a = (int)(((bp.AppData[4] << 8) & 0xFF00) | (bp.AppData[5] & 0x00FF));
                byte[] eqId = new byte[] { 0x05, rackNo, slotNo, 0xFF, 0xFF };
                //byte[] eqId = GetEqId(rackNo, slotNo);
                for (int i = 0; i < 16; ++i)
                {
                    if (((a >> i) & 0x01) == 0x01)//error
                    {
                        //例如 02 04 02 05 01 00
                        //表示 1 机笼 4槽道 VOB16板卡 01 00 ->0000 0001 0000 0000 : 第9个灯位有问题
                        int posk = (rackNo - 2) * 12 * 16 + (slotNo - 2) * 16 + i;
                        if (boardType == 0x01)//VIB
                        {
                            VIBTestResponse vibR = new VIBTestResponse();
                            vibR.CommunicatinBoard = communicatinBoard;
                            vibR.DtTime = DateTime.Now;
                            vibR.OriginalBytes = obytes;
                            vibR.Board = cabinet.FindEq(eqId) as Board;
                            vibR.Board.BoardType = "VIB";
                            vibR.LightPos = i + 1;
                            vibR.ExpectedCode = Util.vib_true[posk];
                            vibR.RealCode = realCodes[i];
                            vibR.ErrorTimes = errorTimes[i];
                            int readableSmallCycle = (int)smallCycle + 1;
                            vibR.smallCycleBoard = readableSmallCycle;
                            list.Add(vibR);
                        }
                        else if (boardType == 0x02)//VOB
                        {
                            VOBTestResponse vobR = new VOBTestResponse();
                            vobR.CommunicatinBoard = communicatinBoard;
                            vobR.DtTime = DateTime.Now;
                            vobR.OriginalBytes = obytes;
                            vobR.Board = cabinet.FindEq(eqId) as Board;
                            vobR.Board.BoardType = "VOB";
                            vobR.LightPos = i + 1;
                            vobR.RealCode = realCodes[i];
                            vobR.ErrorTimes = errorTimes[i];

                            byte[] cycleNo = new byte[2];
                            Array.Copy(obytes.Data, 3, cycleNo, 0, 2);//帧协议中周期号四个字节中的低两位作为是否有输出
                            uint value = (uint)(((cycleNo[0] << 8) & 0xFF00) | (cycleNo[1] & 0x00FF));
                            int readableSmallCycle = (int)smallCycle;
                            vobR.smallCycleBoard = readableSmallCycle;
                            if (((value >> i) & 0x01) == 0x01)//有输出
                            {
                                //VOB板卡第i个灯位错误,且当前灯位亮的状态(有输出)
                                vobR.OutPut = true;
                                vobR.ErrorCode = false;
                                if (readableSmallCycle == 2)
                                {
                                    vobR.ExpectedCode = Util.vob_ock_even[posk];
                                    vobR.OCK = true;
                                }
                                else if (readableSmallCycle == 0 || readableSmallCycle == 4 ||
                                    readableSmallCycle == 6 || readableSmallCycle == 8)
                                {
                                    vobR.ExpectedCode = Util.vob_true_even;
                                    vobR.OCK = false;
                                }
                                else if (readableSmallCycle == 1)
                                {
                                    vobR.ExpectedCode = Util.vob_ock_odd[posk];
                                    vobR.OCK = true;
                                }
                                else if (readableSmallCycle == 3 || readableSmallCycle == 5 ||
                                    readableSmallCycle == 7 || readableSmallCycle == 9)
                                {
                                    vobR.ExpectedCode = Util.vob_true_odd;
                                    vobR.OCK = false;
                                }
                            }
                            else
                            {
                                //当前的灯位灭的状态(无输出)
                                vobR.OutPut = false;
                                vobR.ErrorCode = true;
                                if (readableSmallCycle == 0 || readableSmallCycle == 2 ||
                                    readableSmallCycle == 4 || readableSmallCycle == 6 ||
                                    readableSmallCycle == 8)
                                {
                                    vobR.ExpectedCode = Util.vob_ckWord_even[posk];
                                }
                                else if (readableSmallCycle == 1 || readableSmallCycle == 3 ||
                                    readableSmallCycle == 5 || readableSmallCycle == 7 ||
                                    readableSmallCycle == 9)
                                {
                                    vobR.ExpectedCode = Util.vob_ckWord_odd[posk];
                                }
                            }
                            list.Add(vobR);
                        }
                    }
                }
            }
            return list;
        }
Example #3
0
 public FiltedVOBTestResponse(VOBTestResponse vob)
     : base()
 {
     this.CommunicatinBoard = vob.CommunicatinBoard;
     this.DtTime = vob.DtTime;
     this.OriginalBytes = vob.OriginalBytes;
     this.Board = vob.Board;
     this.smallCycleBoard = vob.smallCycleBoard;
     this.OCK = vob.OCK;
     this.OutPut = vob.OutPut;
     this.ErrorCode = vob.ErrorCode;
     this.LightPos = vob.LightPos;
     this.ExpectedCode = vob.ExpectedCode;
     this.RealCode = vob.RealCode;
     this.ErrorTimes = vob.ErrorTimes;
 }