コード例 #1
0
ファイル: Module.cs プロジェクト: ekorpinen/WhalesTale
        /// <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);
            }));
        }
コード例 #2
0
        /// <summary>
        ///     Calibrate module temperature by setting offset registers.
        ///     Offsets are subtracted from the measured value to create the reported value.
        ///     Example:  module is actually @ 25C.
        ///     The reported temperature is 35C.
        ///     You would call this method CalibrateModuleTemperature(10.0,10.0)
        /// </summary>
        /// <param name="offsetAt0C"></param>
        /// <param name="offsetAt75C"></param>
        public async Task <bool> CalibrateModuleTemperatureAsync(double offsetAt0C, double offsetAt75C)
        {
            return(await Task.Run(async() =>
            {
                //scale offset temperatures to counts
                var offset0C = BitConverter
                               .GetBytes((short)(offsetAt0C / Qsfp100GRegister.Page4.TemperatureOffset0C.Register.Scale))
                               .Reverse().ToArray();
                var offset75C = BitConverter
                                .GetBytes((short)(offsetAt75C / Qsfp100GRegister.Page4.TemperatureOffset75C.Register.Scale))
                                .Reverse().ToArray();

                // write values and update cal
                await Device.SetRegAsync(Qsfp100GRegister.Page4.TemperatureOffset0C, offset0C);
                await Device.SetRegAsync(Qsfp100GRegister.Page4.TemperatureOffset75C, offset75C);
                await Update_CalibrationAsync().ConfigureAwait(false);


                const int startConfigAddress = 192;
                const int endConfigAddress = 254;
                var writeData = new byte[Qsfp100GRegister.Page4.CiscoSpecificNvr.EndAddress -
                                         Qsfp100GRegister.Page4.CiscoSpecificNvr.StartAddress + 1];
                var readBackData = new byte[Qsfp100GRegister.Page4.CiscoSpecificNvr.EndAddress -
                                            Qsfp100GRegister.Page4.CiscoSpecificNvr.StartAddress + 1];

                var page4Data = GetPage(Memory.Pages.NonVolatile.P4Upper);
                Array.Copy(page4Data, startConfigAddress - 128, writeData, 0, endConfigAddress - startConfigAddress);

                var checkSum = UtilityFunctions.ComputeCheckSum(writeData);
                _ = await Device.SetRegAsync(Qsfp100GRegister.Page4.ModuleConfigCheckSum, checkSum).ConfigureAwait(false);
                await Update_CalibrationAsync().ConfigureAwait(false);

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

                page4Data = GetPage(Memory.Pages.NonVolatile.P4Upper);
                Array.Copy(page4Data, startConfigAddress - 128, readBackData, 0, endConfigAddress - startConfigAddress);

                return readBackData.SequenceEqual(writeData);
            }));
        }
コード例 #3
0
ファイル: Module.cs プロジェクト: ekorpinen/WhalesTale
        /// <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);
            }));
        }