コード例 #1
0
        /// <summary>
        /// Update the Bottom Track series with the latest depth.
        /// </summary>
        /// <param name="btSeries">Bottom Track series to update.</param>
        /// <param name="reader">Database reader.</param>
        /// <param name="ensIndex">Index in the plot based off the reader.</param>
        private void ParseBtData(ref AreaSeries btSeries, DbDataReader reader, int ensIndex)
        {
            try
            {
                // Convert to a JSON object
                string  jsonEnsemble = reader["EnsembleDS"].ToString();
                JObject ensData      = JObject.Parse(jsonEnsemble);
                int     numBins      = ensData["NumBins"].ToObject <int>();

                // Update the bottom track line series
                //int rangeBin = GetRangeBin(reader);
                int rangeBin = DbDataHelper.GetRangeBin(reader);
                if (rangeBin == DbDataHelper.BAD_BOTTOM_BIN && _prevGoodBottomBin != DbDataHelper.BAD_BOTTOM_BIN)
                {
                    // Use the backup value if bad
                    rangeBin = _prevGoodBottomBin;
                }

                // Store as backup
                if (rangeBin != DbDataHelper.BAD_BOTTOM_BIN)
                {
                    _prevGoodBottomBin = rangeBin;
                }


                // Only plot the range if it is found
                if (rangeBin > 0)
                {
                    // Create a new data point for the bottom track line
                    // This will be the (ensemble count, range bin)
                    btSeries.Points.Add(new DataPoint(ensIndex, rangeBin));

                    // Add the second point for the shaded area
                    if (rangeBin < numBins)
                    {
                        // Less then the number of bins, so go to the end of the number of bins
                        btSeries.Points2.Add(new DataPoint(ensIndex, numBins));
                    }
                    else
                    {
                        // This is the deepest point
                        btSeries.Points2.Add(new DataPoint(ensIndex, rangeBin));
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error parsing Bottom Track data", e);
                return;
            }
        }
コード例 #2
0
        /// <summary>
        /// Process the row from the DB.  A row represents an ensemble.
        /// </summary>
        /// <param name="reader">Database connection data.</param>
        /// <returns>Magnitude data for a row.</returns>
        private double[] ParseAmpData(DbDataReader reader)
        {
            try
            {
                // Get Range Bin if marking bad below bottom
                int rangeBin = BAD_BOTTOM_BIN;
                if (IsMarkBadBelowBottom)
                {
                    //rangeBin = GetRangeBin(reader);
                    rangeBin = DbDataHelper.GetRangeBin(reader);
                    if (rangeBin == DbDataHelper.BAD_BOTTOM_BIN && _prevGoodBottomBin != DbDataHelper.BAD_BOTTOM_BIN)
                    {
                        // Use the backup value if bad
                        rangeBin = _prevGoodBottomBin;
                    }

                    // Store as backup
                    if (rangeBin != DbDataHelper.BAD_BOTTOM_BIN)
                    {
                        _prevGoodBottomBin = rangeBin;
                    }
                }

                // Get the data as a JSON string
                string jsonData = reader["AmplitudeDS"].ToString();

                if (!string.IsNullOrEmpty(jsonData))
                {
                    // Convert to a JSON object
                    JObject ensData = JObject.Parse(jsonData);

                    // Get the number of bins
                    int numBins  = ensData["NumElements"].ToObject <int>();
                    int numBeams = ensData["ElementsMultiplier"].ToObject <int>();

                    double[] data = new double[numBins];
                    for (int bin = 0; bin < numBins; bin++)
                    {
                        int    avgCnt = 0;
                        double avg    = 0.0;

                        // Average the amplitude for each beam data together
                        for (int beam = 0; beam < numBeams; beam++)
                        {
                            if (ensData["AmplitudeData"][bin][beam].ToObject <double>() != BAD_VELOCITY)
                            {
                                avgCnt++;
                                avg += ensData["AmplitudeData"][bin][beam].ToObject <double>();
                            }
                        }

                        // Check if Mark bad below bottom
                        if (_IsMarkBadBelowBottom && rangeBin > BAD_BOTTOM_BIN && bin >= rangeBin)
                        {
                            // Mark bad below bottom
                            data[bin] = BAD_AMPLITUDE;
                        }
                        // Add average data to the array
                        else if (avgCnt > 0)
                        {
                            data[bin] = avg / avgCnt;
                        }
                        else
                        {
                            data[bin] = BAD_AMPLITUDE;
                        }
                    }

                    return(data);
                }

                return(null);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error parsing the Amplitude data row", e);
                return(null);
            }
        }