예제 #1
0
        /// <summary>
        /// Gets the TDSampleRate for the TimeDomain Channel
        /// Calls TD SampleRateConvert from ConfigConversions class
        /// Checks for disabled time domain channels and returns proper sample rate or disabled for disabled channels
        /// </summary>
        /// <param name="sampleRateIsEnabled">Either true or false depending on value for Time Domain Channel IsEnabled value from config file</param>
        /// <param name="localModel">Sense model</param>
        /// <returns>If the sampleRateIsEnabled variable is set to false, then it returns the TdSampleRates.Disabled. Otherwise it returns the correct TdSampleRates variable for the corresponding TD sample rate from the config file</returns>
        private TdSampleRates GetTDSampleRate(bool sampleRateIsEnabled, SenseModel localModel)
        {
            TdSampleRates the_sample_rate = ConfigConversions.TDSampleRateConvert(localModel.Sense.TDSampleRate);

            if (!sampleRateIsEnabled)
            {
                the_sample_rate = TdSampleRates.Disabled;
            }
            return(the_sample_rate);
        }
예제 #2
0
        /// <summary>
        /// Gets the power band bins and actual hz values. Program shuts down if can't compute
        /// </summary>
        /// <param name="localModel">SenseModel</param>
        /// <returns>List of PowerBandModel class</returns>
        public List <PowerBandModel> GetPowerBands(SenseModel localModel)
        {
            List <PowerBandModel> powerBandsList = new List <PowerBandModel>();

            try
            {
                CalculateFFTBins(ConfigConversions.FftSizesConvert(localModel.Sense.FFT.FftSize), ConfigConversions.TDSampleRateConvert(localModel.Sense.TDSampleRate));
                binWidth = bins[1] - bins[0];
                CalculateUpperBins();
                CalculateLowerBins();
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            for (int i = 0; i < 8;)
            {
                try
                {
                    PowerBandModel powerBandModel = new PowerBandModel();
                    //Gets the lower index value and upper index value based from the config file value.
                    powerBandModel.lowerIndexBand0 = GetLowerIndex(localModel.Sense.PowerBands[i].ChannelPowerBand[0]);
                    powerBandModel.upperIndexBand0 = GetUpperIndex(localModel.Sense.PowerBands[i].ChannelPowerBand[1]);
                    //This checks to make sure that the upper power bin index is bigger than the lower; cannot have upper index that is less than lower index
                    //if the upper index value is not bigger than the lower, then the upper index is set to lower index for error handling
                    powerBandModel.upperIndexBand0 = CheckThatUpperPowerBandGreaterThanLowerPowerBand(powerBandModel.lowerIndexBand0, powerBandModel.upperIndexBand0);
                    //Actual lower and upper power values are calculated from the users estimated power values from the config file
                    //This is done in the CalculatePowerBins class.  Below saves the actual lower and upper power values in each array to 2 decimal places.
                    //These arrays are instantiated in MainViewModel.cs
                    powerBandModel.lowerActualValueHzBand0 = Math.Round(ActualLowerPowerValue, 2);
                    powerBandModel.UpperActualValueHzBand0 = Math.Round(ActualUpperPowerValue, 2);
                    //increment i so that the next power band can be set. There are 8 (0-7). There are 4 power channels (0-3);
                    i++;
                    //Repeat this step for next power band
                    powerBandModel.lowerIndexBand1         = GetLowerIndex(localModel.Sense.PowerBands[i].ChannelPowerBand[0]);
                    powerBandModel.upperIndexBand1         = GetUpperIndex(localModel.Sense.PowerBands[i].ChannelPowerBand[1]);
                    powerBandModel.upperIndexBand1         = CheckThatUpperPowerBandGreaterThanLowerPowerBand(powerBandModel.lowerIndexBand1, powerBandModel.upperIndexBand1);
                    powerBandModel.lowerActualValueHzBand1 = Math.Round(ActualLowerPowerValue, 2);
                    powerBandModel.upperActualValueHzBand1 = Math.Round(ActualUpperPowerValue, 2);
                    i++;
                    powerBandsList.Add(powerBandModel);
                }
                catch (Exception e)
                {
                    HandleException(e);
                }
            }
            return(powerBandsList);
        }