private bool SetDutRxPRBS(byte bprbsLength)
        {
            lock (syncRoot)
            {
                UInt16[] buff = new UInt16[1];
                try
                {
                    buff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA012, IOPort.MDIOSoftHard.SOFTWARE, 1);

                    buff[0] = Convert.ToUInt16(buff[0] & 0XCFFF);

                    switch (bprbsLength)
                    {
                    case 7:    //00
                    case 9:    //00

                        buff[0] = Convert.ToUInt16(buff[0] | (0x00 << 12));
                        IOPort.WriteMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA013, IOPort.MDIOSoftHard.SOFTWARE, buff);
                        break;

                    case 15:    //01
                        buff[0] = Convert.ToUInt16(buff[0] | (0x01 << 12));
                        IOPort.WriteMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA013, IOPort.MDIOSoftHard.SOFTWARE, buff);
                        break;

                    case 23:    //10
                        buff[0] = Convert.ToUInt16(buff[0] | (0x10 << 12));
                        IOPort.WriteMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA013, IOPort.MDIOSoftHard.SOFTWARE, buff);
                        break;

                    case 31:    //11
                        buff[0] = Convert.ToUInt16(buff[0] | (0x11 << 12));
                        IOPort.WriteMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA013, IOPort.MDIOSoftHard.SOFTWARE, buff);
                        break;

                    default:    //11
                        break;
                    }
                    return(true);
                    // IOPort.WriteMDIO(deviceIndex, 1, phycialAdress, 0xA013, IOPort.MDIOSoftHard.SOFTWARE, buff);
                }
                catch (InnoExCeption error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw error;
                }

                catch (Exception error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw new InnoExCeption(ExceptionDictionary.Code._Funtion_Fatal_0x05002, error.StackTrace);
                    // throw new InnoExCeption(ex);
                }
            }
        }
        public bool EdGatingStart(bool bSwitch)
        {
            lock (syncRoot)
            {
                UInt16[] buff = new UInt16[1];
                try
                {
                    Engmod();
                    //   SetDutRxPRBS(prbsLength);
                    // sn = CFP.ReadSn(deviceIndex, 1, 0x8044, phycialAdress, 1);
                    ushort[] buff2 = IOPort.ReadMDIO(0, 1, 7, 0x8044, IOPort.MDIOSoftHard.SOFTWARE, 16);
                    buff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA012, IOPort.MDIOSoftHard.SOFTWARE, 1);

                    buff[0] = Convert.ToUInt16(buff[0] & 0XBFFF);

                    switch (bSwitch)
                    {
                    case false:    //此时已经是关闭状态
                        //buff[0] = Convert.ToUInt16(buff[0] | (0x0 << 12));
                        break;

                    default:    //开启
                        buff[0] = Convert.ToUInt16(buff[0] | (0x1 << 14));
                        break;
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        IOPort.WriteMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA012, IOPort.MDIOSoftHard.SOFTWARE, buff);
                        Thread.Sleep(100);
                        ushort[] Readbuff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA012, IOPort.MDIOSoftHard.SOFTWARE, 1);

                        if (Readbuff[0] == buff[0])
                        {
                            return(true);
                        }
                    }

                    Log.SaveLogToTxt("Operat ED Check False");
                    return(false);
                }
                catch (InnoExCeption error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw error;
                }

                catch (Exception error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw new InnoExCeption(ExceptionDictionary.Code._Funtion_Fatal_0x05002, error.StackTrace);
                    // throw new InnoExCeption(ex);
                }
            }
        }
        public override double RapidErrorRate(int syn = 0)
        {
            lock (syncRoot)
            {
                UInt16[] buff = new UInt16[1];

                double ErrorRate = 1;


                UInt16 Mantissa;
                UInt16 Exponent;
                try
                {
                    EdGatingStart(false);
                    Thread.Sleep(50);
                    EdGatingStart(true);

                    Thread.Sleep(edGatingTime * 1000);

                    switch (MyParameter.MoudleChannel)
                    {
                    case 1:
                        buff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA290, IOPort.MDIOSoftHard.SOFTWARE, 1);
                        break;

                    case 2:
                        buff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA291, IOPort.MDIOSoftHard.SOFTWARE, 1);
                        break;

                    case 3:
                        buff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA292, IOPort.MDIOSoftHard.SOFTWARE, 1);
                        break;

                    case 4:
                        buff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA293, IOPort.MDIOSoftHard.SOFTWARE, 1);
                        break;

                    default:
                        buff = IOPort.ReadMDIO(MyParameter.deviceIndex, 1, MyParameter.phycialAdress, 0xA290, IOPort.MDIOSoftHard.SOFTWARE, 1);
                        break;
                    }

                    Exponent = Convert.ToUInt16(buff[0] >> 10);   //Hig  6bit

                    Mantissa = Convert.ToUInt16(buff[0] & 0x3FF); //Low  10bit

                    ErrorRate = Mantissa * (Math.Pow(2, Exponent)) / (MyParameter.dDataRate * MyParameter.GatingTime * 1E+9);

                    return(ErrorRate);
                }
                catch (InnoExCeption error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw error;
                }

                catch (Exception error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw new InnoExCeption(ExceptionDictionary.Code._Funtion_Fatal_0x05002, error.StackTrace);
                    // throw new InnoExCeption(ex);
                }
            }
        }