Example #1
0
        public Task <(bool success, TimeSpan dataReadyTime)> WaitForDataReady(TimeSpan timeOut)
        {
            Task <(bool interruptStatus, TimeSpan sbttopwatch)> policyResult = Policy
                                                                               .Handle <Exception>()
                                                                               .Retry(3, (exception, retryCount) =>
            {
                Debug.WriteLine($"BootTime error: retry {retryCount} : {exception.Message})");
                Task.Delay(2000).Wait();
            })
                                                                               .Execute(async() =>
            {
                var stopwatch = Stopwatch.StartNew();
                bool dataNotReadyStatus;
                do
                {
                    dataNotReadyStatus = await Qsfp100G.DataNotReadyAsync();
                    await Task.Delay(10);
                    Debug.WriteLine(
                        $" DataReadyTime : {stopwatch.Elapsed.TotalMilliseconds} mS, dataNotReadyStatus: {dataNotReadyStatus}");
                    if (stopwatch.Elapsed > timeOut)
                    {
                        throw new TimeoutException(
                            $"Module failed to get to Valid DataNotReady state  in {timeOut}");
                    }
                } while (dataNotReadyStatus && stopwatch.Elapsed < timeOut);

                stopwatch.Stop();

                return(stopwatch.Elapsed > timeOut
                        ? (false, stopwatch.Elapsed)
                        : (!dataNotReadyStatus, stopwatch.Elapsed));
            });

            return(policyResult);
        }
Example #2
0
        public async Task <bool> WaitDutTemperatureStable(double allowableChange, TimeSpan window, TimeSpan updateRate,
                                                          TimeSpan timeout)
        {
            var numberOfPoint  = window.Seconds / updateRate.Seconds;
            var data           = new List <double>();
            var timerStopwatch = Stopwatch.StartNew();

            do
            {
                data.Add(await Qsfp100G.TemperatureAsync());
                if (data.Count() > numberOfPoint)
                {
                    data.RemoveAt(0);
                    Debug.WriteLine($"Max {data.Max()}, Min {data.Min()}, Delta {data.Max() - data.Min()}");
                    if (data.Max() - data.Min() <= allowableChange)
                    {
                        return(true);
                    }
                }

                await Task.Delay(updateRate);
            } while (timerStopwatch.Elapsed < timeout);

            return(false);
        }
Example #3
0
        public async Task <(bool success, TimeSpan bootTime, int error, int exError)> ResetWaitTillReadyWithErrorCheck(
            TimeSpan assertTime, TimeSpan timeOut, IProgress <TmgProgressReporting> progress = null)
        {
            progress?.Report(new TmgProgressReporting(DateTime.Now, $"Module Reset : Assert {assertTime}"));

            var bootTimeTask = Task.Run(() => BootTime(Reset, timeOut));
            await Task.WhenAll(bootTimeTask).ConfigureAwait(false);

            var dataReadyTask = Task.Run(() => WaitForDataReady(timeOut));
            await Task.WhenAll(dataReadyTask).ConfigureAwait(false);

            var errorCode = await Qsfp100G.ErrorCodeAsync().ConfigureAwait(false);

            var errorCodeOptional = await Qsfp100G.ErrorOptionalDataAsync().ConfigureAwait(false);

            var success2 = bootTimeTask.Result.success & (errorCode == 0);

            var progressMessage =
                $"Completed Reset : status {bootTimeTask.Result.success}, DataReady {dataReadyTask.Result.success}, " +
                $"Error Code {errorCode}, " +
                $"ErrorCodeOptional Code {errorCodeOptional}, " +
                $"in boot time: {bootTimeTask.Result.bootTime.TotalMilliseconds} mS, " +
                $"in data ready time: {dataReadyTask.Result.dataReadyTime.TotalMilliseconds} mS ";

            Debug.WriteLine(progressMessage);

            progress?.Report(new TmgProgressReporting(DateTime.Now, progressMessage));

            return(success2, bootTimeTask.Result.bootTime, errorCode, errorCodeOptional);
        }
Example #4
0
        /// <summary>
        ///     Calibrate module temperature by passing in current heat sink temperature.
        ///     Offsets are subtracted from the measured value to create the reported value.
        ///     Example:  heat sink is @ 25C.
        ///     You would call this method CalibrateModuleTemperature(25.0)
        ///     Note: both offsets (0C and 75C are set the same)
        /// </summary>
        /// <param name="heatSinkTemperature"></param>
        /// <param name="zeroOffsetsFirst"></param>
        public async Task <bool> CalibrateModuleTemperature(double heatSinkTemperature, bool zeroOffsetsFirst = false)
        {
            return(await Task.Run(async() =>
            {
                if (zeroOffsetsFirst)
                {
                    await Qsfp100G.SetModuleTemperatureOffsetsAsync(0, 0).ConfigureAwait(false);
                    await Task.Delay(3000).ConfigureAwait(false); // allow sometime overcome module internal smoothing
                }

                var temperatureOffset = await Qsfp100G.TemperatureAsync() - heatSinkTemperature;

                var writtenData = await Qsfp100G.SetModuleTemperatureOffsetsAsync(temperatureOffset, temperatureOffset)
                                  .ConfigureAwait(false);
                var checkSum = UtilityFunctions.ComputeCheckSum(Qsfp100G.GetCiscoSpecificConfiguration());
                await Device.SetRegAsync(Qsfp100GRegister.Page4.ModuleConfigCheckSum, checkSum);
                await Qsfp100G.Update_CalibrationAsync().ConfigureAwait(false);

                // validate page 4 upper NVR after device reset.
                var res = await DutGpio.Reset(TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(2500));
                var(success, bootTime) =
                    await ResetWaitTillIntL(TimeSpan.FromMilliseconds(1000), TimeSpan.FromSeconds(10));

                var readBackData = Qsfp100G.GetCiscoSpecificConfiguration();
                return readBackData.SequenceEqual(writtenData);
            }));
        }
Example #5
0
        public void TestInit()
        {
            var policies = new Policies();

            var sub20Interfaces = new Sub20Interfaces();

            _s20 = new CSub20(Sub20SerialNumber, sub20Interfaces);

            II2C i2C = new Sub20I2C(_s20);
            var  gpioConfiguration = new GpioConfiguration(0x00380000, 0x00380000);
            var  gpio = new Sub20Gpio(_s20, gpioConfiguration);

            gpio.GpioInitialize();
            var dutGpio = new DutGpio.DutGpio(null, gpio, new DutGpioBits(16, 17, 18));

            var modPres = dutGpio.ModPresentAsserted;

            Assert.IsTrue(modPres);

            var deviceIO    = new DeviceIO(i2C, dutGpio, policies.PolicyWrap);
            var cyclops     = new Cyclops(deviceIO);
            var qsfp100GFRS = new Qsfp100G(deviceIO);
            var maCom       = new MaCom(deviceIO);

            _module = new Module(deviceIO, qsfp100GFRS, cyclops, maCom, policies.PolicyWrap);
        }
Example #6
0
        public static Module ModuleFactory(ISub20 sub20, AsyncPolicyWrap policyWrap)
        {
            var i2C = new Sub20I2C(sub20);

            var   gpioConfiguration = new GpioConfiguration(0x00380000, 0x00380000);
            IGpio gpio = new Sub20Gpio(sub20, gpioConfiguration);

            gpio.GpioInitialize();
            var dutGpio = new DutGpio.DutGpio(null, gpio, new DutGpioBits(16, 17, 18));

            var deviceIO    = new DeviceIO(i2C, dutGpio, policyWrap);
            var cyclops     = new Cyclops.Cyclops(deviceIO);
            var qsfp100GFRS = new Qsfp100G(deviceIO);
            var macom       = new MaCom.MaCom(deviceIO);
            var module      = new Module(deviceIO, qsfp100GFRS, cyclops, macom, policyWrap);

            return(module);
        }
Example #7
0
        /// <summary>
        ///     Calibrate module temperature by passing in current heat sink temperature.
        ///     Offsets are subtracted from the measured value to create the reported value.
        ///     Example:  heat sink is @ 25C.
        ///     You would call this method CalibrateModuleTemperature(25.0)
        ///     Note: both offsets (0C and 75C are set the same)
        /// </summary>
        /// <param name="caseHotspotTemperature"></param>
        /// <param name="slope"></param>
        /// <param name="zeroOffsetsFirst"></param>
        public async Task <bool> CalibrateModuleTemperature2(double caseHotspotTemperature, double slope,
                                                             bool zeroOffsetsFirst = false)
        {
            return(await Task.Run(async() =>
            {
                if (zeroOffsetsFirst)
                {
                    await Qsfp100G.SetModuleTemperatureOffsetsAsync(0, 0).ConfigureAwait(false);
                    await Task.Delay(3000).ConfigureAwait(false); // allow sometime overcome module internal smoothing
                    var result2 = await WaitDutTemperatureStable(0.5, TimeSpan.FromSeconds(30),
                                                                 TimeSpan.FromSeconds(2), TimeSpan.FromMinutes(5));
                }

                var temperatureOffsetAtCaseHotspotTemp = await Qsfp100G.TemperatureAsync() - caseHotspotTemperature;

                var fixedOffset = temperatureOffsetAtCaseHotspotTemp - caseHotspotTemperature *slope;

                //                    fixed offset temp dependent offset
                var offsetAt0C = fixedOffset + 0.0 * slope;
                var offsetAt70C = fixedOffset + 70.0 * slope;


                var writtenData = await Qsfp100G.SetModuleTemperatureOffsetsAsync(offsetAt0C, offsetAt70C)
                                  .ConfigureAwait(false);
                var checkSum = UtilityFunctions.ComputeCheckSum(Qsfp100G.GetCiscoSpecificConfiguration());
                await Device.SetRegAsync(Qsfp100GRegister.Page4.ModuleConfigCheckSum, checkSum);
                await Qsfp100G.Update_CalibrationAsync().ConfigureAwait(false);

                // validate page 4 upper NVR after device reset.
                var res = await DutGpio.Reset(TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(2500));
                var(success, _) = await ResetWaitTillIntL(TimeSpan.FromMilliseconds(1000), TimeSpan.FromSeconds(10));
                if (!success)
                {
                    throw new ArgumentException("ResetWaitTillIntL failed");
                }
                var readBackData = Qsfp100G.GetCiscoSpecificConfiguration();
                return readBackData.SequenceEqual(writtenData);
            }));
        }