public static void JesdConfigRx1CaptureTest([Values(Mykonos.RXCHANNEL.RX1, Mykonos.RXCHANNEL.RX2)] Mykonos.RXCHANNEL channel, [Values(JESDAlphaTests.MYK_DATAPATH_MODE.RX1TX1OBS1)] MYK_DATAPATH_MODE DataPath,
                                                    [Values(MYK_JESD_LANE_CFG.RL1OBSL2TL2, MYK_JESD_LANE_CFG.RL1OBSL2TL4,
                                                            MYK_JESD_LANE_CFG.RL2OBSL2TL2, MYK_JESD_LANE_CFG.RL2OBSL2TL4)] MYK_JESD_LANE_CFG LaneCfg,
                                                    [Values(12, 32)] byte framerK,
                                                    [Values(12, 32)] byte obsRxframerK,
                                                    [Values(20, 32)] byte deframerK)
        {
            //Define Test Signal Parameters
            int amp_dbm1   = -20;
            int OffSet1    = 10;
            int IQExptVal1 = 20000;

            //Based on Test Parameters Determin Jesd Settings
            ConfigJesdParams(DataPath, LaneCfg, framerK, obsRxframerK, deframerK);
            //Configure Chip and Data Paths with Test Specific JESD Settings
            TestSetup.TestSetupInit(settings);
            //Enable System, Apply Signal, Analysis Captured Data
            TxLoopbackRxCapture(channel, amp_dbm1, OffSet1, IQExptVal1);
        }
        public void TestJESDAlfaParam([Values(JESDAlphaTests.MYK_DATAPATH_MODE.RX2TX2OBS1, MYK_DATAPATH_MODE.RX1TX2OBS1,
                                              MYK_DATAPATH_MODE.RX2TX1OBS1, MYK_DATAPATH_MODE.RX1TX1OBS1)] MYK_DATAPATH_MODE DataPath,
                                      [Values(MYK_JESD_LANE_CFG.RL1OBSL0TL2, MYK_JESD_LANE_CFG.RL1OBSL0TL4,
                                              MYK_JESD_LANE_CFG.RL1OBSL2TL2, MYK_JESD_LANE_CFG.RL1OBSL2TL4,
                                              MYK_JESD_LANE_CFG.RL2OBSL0TL2, MYK_JESD_LANE_CFG.RL2OBSL0TL4,
                                              MYK_JESD_LANE_CFG.RL2OBSL2TL2, MYK_JESD_LANE_CFG.RL2OBSL2TL4)] MYK_JESD_LANE_CFG LaneCfg,
                                      [Values(16, 32)] byte framerK,
                                      [Values(16, 32)] byte obsRxframerK,
                                      [Values(20, 32)] byte deframerK)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            Link.Mykonos.resetDevice();

            Mykonos.RXCHANNEL rxChannels = Mykonos.RXCHANNEL.RX1_RX2;
            Mykonos.TXCHANNEL txChannels = Mykonos.TXCHANNEL.TX1_TX2;
            byte Obsrxchannels           = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;

            byte deframerM       = 0;
            byte desLanesEnabled = 0;

            byte framerM = 0;
            byte serializerLanesEnabled = 0;

            byte obsRxframerM = 0;
            byte obsRxserializerLanesEnabled = 0;
            byte invalidTest = 0;

            switch (DataPath)
            {
            case MYK_DATAPATH_MODE.RX2TX2OBS1:
                //Data Path Configuration
                rxChannels = Mykonos.RXCHANNEL.RX1_RX2;
                framerM    = 4;

                txChannels = Mykonos.TXCHANNEL.TX1_TX2;
                deframerM  = 4;

                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsRxframerM  = 2;
                //Lane Config
                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL2:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            case MYK_DATAPATH_MODE.RX1TX2OBS1:
                //Data Path Configuration
                rxChannels    = Mykonos.RXCHANNEL.RX1;
                framerM       = 2;
                txChannels    = Mykonos.TXCHANNEL.TX1_TX2;
                deframerM     = 4;
                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsRxframerM  = 2;
                //Lane Config
                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL1OBSL2TL4:
                    serializerLanesEnabled      = 0x01;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL0TL4:
                    serializerLanesEnabled      = 0x01;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL4:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            case MYK_DATAPATH_MODE.RX2TX1OBS1:
                rxChannels    = Mykonos.RXCHANNEL.RX1_RX2;
                framerM       = 4;
                txChannels    = Mykonos.TXCHANNEL.TX1;
                deframerM     = 2;
                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsRxframerM  = 2;

                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL2OBSL2TL2:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x03;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL2:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x03;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL4:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            case MYK_DATAPATH_MODE.RX1TX1OBS1:
                rxChannels    = Mykonos.RXCHANNEL.RX1;
                framerM       = 2;
                txChannels    = Mykonos.TXCHANNEL.TX1;
                deframerM     = 2;
                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsRxframerM  = 2;
                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL1OBSL2TL2:
                    serializerLanesEnabled      = 0x01;
                    desLanesEnabled             = 0x03;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL0TL2:
                    serializerLanesEnabled      = 0x01;
                    desLanesEnabled             = 0x03;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL2TL4:
                    serializerLanesEnabled      = 0x01;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL0TL4:
                    serializerLanesEnabled      = 0x01;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL2:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x03;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL2:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x03;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL4:
                    serializerLanesEnabled      = 0x03;
                    desLanesEnabled             = 0x0F;
                    obsRxserializerLanesEnabled = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            default:
                break;
            }
            if (invalidTest != 1)
            {
                byte deframerF    = (byte)(2 * (int)deframerM / ConvertMaskToCount(desLanesEnabled));
                byte framerF      = (byte)(2 * (int)framerM / ConvertMaskToCount(serializerLanesEnabled));
                byte obsRxframerF = (byte)(2 * (int)obsRxframerM / ConvertMaskToCount(obsRxserializerLanesEnabled));

                DateTime timeStamp = DateTime.Now;

                string text = "Tx M: " + deframerM + ", Tx K: " + deframerK +
                              ", Tx lanes: " + string.Format("{0:X}", desLanesEnabled) + ", Tx F: " + deframerF +
                              ", Rx M: " + framerM + ", Rx K: " + framerK +
                              ", Rx lanes: " + string.Format("{0:X}", serializerLanesEnabled) + ", Rx F: " + framerF +
                              ", ORx M: " + obsRxframerM + ", ORx K: " + obsRxframerK +
                              ", ORx lanes: " + string.Format("{0:X}", obsRxserializerLanesEnabled) +
                              ", ORx F: " + obsRxframerF + "  " + timeStamp.ToString();

                using (System.IO.StreamWriter file = new System.IO.StreamWriter(resFilePathAlpha, true))
                {
                    file.WriteLine(text);
                }

                //Initialize(rxChannels, txChannels, Obsrxchannels, deframerM, deframerK, desLanesEnabled, framerM, framerK, serializerLanesEnabled, obsRxframerM, obsRxframerK, obsRxserializerLanesEnabled);
                JESDTestInit(deframerM, deframerK, desLanesEnabled, framerM, framerK, serializerLanesEnabled, obsRxframerM, obsRxframerK, obsRxserializerLanesEnabled);
                Console.WriteLine("Rx Profile: " + settings.mykSettings.rxProfileName);
                Console.WriteLine("Tx Profile: " + settings.mykSettings.txProfileName);
                Console.WriteLine("ORx Profile: " + settings.mykSettings.orxProfileName);
                TestSetup.JESDTestSetupInit(settings, rxChannels, txChannels, Obsrxchannels);

                mykonosUnitTest.Helper.EnableRxFramerLink_JESD(resFilePathAlpha);
                mykonosUnitTest.Helper.EnableORxFramerLink_JESD(resFilePathAlpha);
                mykonosUnitTest.Helper.EnableTxLink_JESD(resFilePathAlpha);
            }
        }
        public static byte ConfigJesdParams(MYK_DATAPATH_MODE DataPath,
                                            MYK_JESD_LANE_CFG LaneCfg,
                                            [Values(12, 32)] byte framerK,
                                            [Values(12, 32)] byte obsRxframerK,
                                            [Values(20, 32)] byte deframerK)
        {
            Mykonos.RXCHANNEL rxChannels = Mykonos.RXCHANNEL.RX1_RX2;
            Mykonos.TXCHANNEL txChannels = Mykonos.TXCHANNEL.TX1_TX2;
            byte Obsrxchannels           = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;

            byte deframerM = 0;
            byte desLaneEn = 0;

            byte framerM   = 0;
            byte serLaneEn = 0;

            byte obsFramerM   = 0;
            byte obsSerLaneEn = 0;

            byte invalidTest = 0;

            switch (DataPath)
            {
            case MYK_DATAPATH_MODE.RX2TX2OBS1:
                //Data Path Configuration
                rxChannels = Mykonos.RXCHANNEL.RX1_RX2;
                framerM    = 4;

                txChannels = Mykonos.TXCHANNEL.TX1_TX2;
                deframerM  = 4;

                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsFramerM    = 2;
                //Lane Config
                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL2:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x03;
                    obsSerLaneEn = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            case MYK_DATAPATH_MODE.RX1TX2OBS1:
                //Data Path Configuration
                rxChannels    = Mykonos.RXCHANNEL.RX1;
                framerM       = 2;
                txChannels    = Mykonos.TXCHANNEL.TX1_TX2;
                deframerM     = 4;
                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsFramerM    = 2;
                //Lane Config
                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL1OBSL2TL4:
                    serLaneEn    = 0x01;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL0TL4:
                    serLaneEn    = 0x01;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL4:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            case MYK_DATAPATH_MODE.RX2TX1OBS1:
                rxChannels    = Mykonos.RXCHANNEL.RX1_RX2;
                framerM       = 4;
                txChannels    = Mykonos.TXCHANNEL.TX1;
                deframerM     = 2;
                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsFramerM    = 2;

                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL2OBSL2TL2:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x03;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL2:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x03;
                    obsSerLaneEn = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL4:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            case MYK_DATAPATH_MODE.RX1TX1OBS1:
                rxChannels    = Mykonos.RXCHANNEL.RX1;
                framerM       = 2;
                txChannels    = Mykonos.TXCHANNEL.TX1;
                deframerM     = 2;
                Obsrxchannels = (byte)Mykonos.OBSRXCHANNEL_ENABLE.MYK_ORX1;
                obsFramerM    = 2;
                switch (LaneCfg)
                {
                case MYK_JESD_LANE_CFG.RL1OBSL2TL2:
                    serLaneEn    = 0x01;
                    desLaneEn    = 0x03;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL0TL2:
                    serLaneEn    = 0x01;
                    desLaneEn    = 0x03;
                    obsSerLaneEn = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL2TL4:
                    serLaneEn    = 0x01;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL1OBSL0TL4:
                    serLaneEn    = 0x01;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL2:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x03;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL2:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x03;
                    obsSerLaneEn = 0x0;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL2TL4:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0xC;
                    break;

                case MYK_JESD_LANE_CFG.RL2OBSL0TL4:
                    serLaneEn    = 0x03;
                    desLaneEn    = 0x0F;
                    obsSerLaneEn = 0x0;
                    break;

                default:
                    invalidTest = 1;
                    break;
                }
                break;

            default:
                break;
            }
            if (invalidTest != 1)
            {
                byte deframerF  = (byte)((2 * (int)deframerM) / (int)ConvertMaskToCount(desLaneEn));
                byte framerF    = (byte)(2 * (int)framerM / ConvertMaskToCount(serLaneEn));
                byte obsFramerF = (byte)(2 * (int)obsFramerM / ConvertMaskToCount(obsSerLaneEn));

                settings.mykSettings.rxChannel  = rxChannels;
                settings.mykSettings.txChannel  = txChannels;
                settings.mykSettings.orxChannel = (Mykonos.OBSRXCHANNEL_ENABLE)Obsrxchannels;
                settings.mykTxDeFrmrCfg.M       = deframerM;
                settings.mykTxDeFrmrCfg.K       = deframerK;
                settings.mykTxDeFrmrCfg.deserializerLanesEnabled = desLaneEn;

                settings.mykRxFrmrCfg.M = framerM;
                settings.mykRxFrmrCfg.K = framerK;
                settings.mykRxFrmrCfg.serializerLanesEnabled = serLaneEn;

                settings.mykObsRxFrmrCfg.M = obsFramerM;
                settings.mykObsRxFrmrCfg.K = obsRxframerK;
                settings.mykObsRxFrmrCfg.serializerLanesEnabled = obsSerLaneEn;

                return(0);
            }
            return(1);
        }