Example #1
0
        private void Update(DataSet.EnsembleVelocityVectors vectors)
        {
            int width  = _maxEnsembles;                         // Max number of ensembles
            int height = vectors.Vectors.Length;                // Number of bins in the vector array

            // If this is the first entry
            // The plot needs to be created
            // Need to know the number of bins to create the arrays
            if (_isNewPlot)
            {
                CreatePlot(width, height);
            }

            // Create a 3d point based off each magnitude in the vector
            for (int bin = 0; bin < vectors.Vectors.Length; bin++)
            {
                // Get the magnitude
                double mag = vectors.Vectors[bin].Magnitude;

                // Set the color based off the magnitude
                Material material = MaterialHelper.CreateMaterial(GenerateColor(mag));

                // Check if the magnitude is bad
                // If its bad, set the height to 0
                if (mag != DataSet.Ensemble.BAD_VELOCITY)
                {
                    ScaleTransforms[_ens, bin] = new ScaleTransform3D(1, 1, mag);
                }
                else
                {
                    ScaleTransforms[_ens, bin] = new ScaleTransform3D(1, 1, 0);
                }

                var translation = new TranslateTransform3D((bin - (height - 1) * 0.5) * Distance, _ens * Distance, 0);
                var tg          = new Transform3DGroup();
                tg.Children.Add(ScaleTransforms[_ens, bin]);
                tg.Children.Add(translation);
                Models[_ens, bin] = new GeometryModel3D(Geometry, material)
                {
                    Transform = tg
                };
                ((Model3DGroup)Content).Children.Add(Models[_ens, bin]);
            }

            if (_ens + 1 < _maxEnsembles)
            {
                _ens++;
            }
            else
            {
                ShiftPlot(width, height);
                RemoveFirstEnsemble(height);
            }
        }
Example #2
0
        /// <summary>
        /// Add a new vector to the list.
        /// This must be called by the dispatcher because
        /// if we are plotting immediately after.  This will ensure
        /// the thread stay in sync with data being added and plotted.
        ///
        /// Limit the size of the list to MaxEnsembles.
        /// </summary>
        /// <param name="vectors">Vector to add to the list.</param>
        private void AddVectors(DataSet.EnsembleVelocityVectors vectors)
        {
            // Add the vectors to the list
            _vectors.Add(vectors);

            // Limit the size
            while (_vectors.Count > MaxEnsembles)
            {
                _vectors.RemoveAt(0);
            }
        }
Example #3
0
        /// <summary>
        /// Plot the 3D velocity plot.
        /// Get the velocity vectors from the ensemble.
        /// </summary>
        private void Plot3dVelocityPlot()
        {
            if (_ensemble != null && _ensemble.IsEnsembleAvail && _ensemble.IsEarthVelocityAvail && _ensemble.EarthVelocityData.IsVelocityVectorAvail)
            {
                // Create struct to hold the data
                DataSet.EnsembleVelocityVectors ensVec = new DataSet.EnsembleVelocityVectors();
                ensVec.Id      = _ensemble.EnsembleData.UniqueId;
                ensVec.Vectors = _ensemble.EarthVelocityData.VelocityVectors;

                Profile3dPlot.AddData(ensVec);
            }
        }
Example #4
0
            /// <summary>
            /// Create an struct to hold bin vectors for the velocity data
            /// based off the ensemble given.  This will remove the
            /// Bottom Track velocity from the velocity data then
            /// create  a vector representing the
            /// water velocity.
            /// Removing Ship Speed:
            /// BT Good, GPS Good or Bad = BT velocities
            /// BT Bad, GPS Good = GPS velocity
            /// BT Bad, GPS Bad = Previous Good BT
            /// BT Bad, Gps Bad, Previous BT Bad = None
            ///
            /// </summary>
            /// <param name="adcpData">Ensemble to generate vector values.</param>
            /// <returns>Vectors for each bin in ensemble.</returns>
            public static DataSet.EnsembleVelocityVectors GenerateInstrumentVelocityVectors(DataSet.Ensemble adcpData)
            {
                // Create the velocity vector data
                DataSet.VelocityVectorHelper.CreateVelocityVector(ref adcpData);

                // Create struct to hold the data
                DataSet.EnsembleVelocityVectors ensVec = new DataSet.EnsembleVelocityVectors();
                ensVec.Id = adcpData.EnsembleData.UniqueId;

                if (adcpData.IsInstrumentVelocityAvail && adcpData.InstrumentVelocityData.IsVelocityVectorAvail)
                {
                    ensVec.Vectors = adcpData.InstrumentVelocityData.VelocityVectors;
                }

                return(ensVec);
            }
Example #5
0
        /// <summary>
        /// For each bin, create a arrow.  Set the arrow location to the
        /// column location of the bin.  Set the lenght of the arrow based off
        /// the magnitude and a scale factor.  Set the color of the arrow based
        /// off the magnitude.  If the arrow is selected, set the color to the
        /// selection color.  Then rotate the arrow based off the angle in the
        /// vector.  Then add the arrow to the model.
        ///
        /// A North arrow will be created to know where North is relative
        /// to the scene.
        /// </summary>
        /// <param name="vectors">Vectors to display.</param>
        private void DrawPlot(DataSet.EnsembleVelocityVectors vectors)
        {
            // Ensure the data is good
            if (vectors.Vectors != null)
            {
                var group   = new Model3DGroup();
                int numBins = vectors.Vectors.Length;

                // Go through each bin
                for (int bin = 0; bin < numBins; bin++)
                {
                    // Get the magnitude and direction
                    double mag         = vectors.Vectors[bin].Magnitude;
                    double angleYNorth = vectors.Vectors[bin].DirectionXNorth;

                    // If the magnitude is bad, do not create an arrow
                    if (mag != DataSet.Ensemble.BAD_VELOCITY)
                    {
                        // Add the bin arrow to the model
                        group.Children.Add(CreateBin(bin, mag, angleYNorth));
                    }
                }

                // If the ensemble changed, reset the base
                if (numBins != _prevNumBins)
                {
                    CreateBase(vectors.Vectors.Length);

                    _prevNumBins = numBins;
                }

                // Create the North and East arrow
                group.Children.Add(_northArrow);
                group.Children.Add(_eastArrow);

                // Origin tube
                group.Children.Add(_originTube);

                // Last item to add
                group.Children.Add(_cylinder);

                Content = group;
            }
        }
Example #6
0
            /// <summary>
            /// Create an EnsembleVelocityVector based off the ensemble.
            /// If the Velocity Vectors do not exist, create the vectors.
            /// </summary>
            /// <param name="adcpData">Ensemble data.</param>
            /// <returns>EnsembleVelocityVector with the velocity vector data.</returns>
            public static DataSet.EnsembleVelocityVectors GetShipVelocityVectors(DataSet.Ensemble adcpData)
            {
                // Create struct to hold the data
                DataSet.EnsembleVelocityVectors ensVec = new DataSet.EnsembleVelocityVectors();
                ensVec.Id = adcpData.EnsembleData.UniqueId;

                // Check, if velocity vectors exist
                if (adcpData.IsShipVelocityAvail && adcpData.ShipVelocityData.IsVelocityVectorAvail)
                {
                    ensVec.Vectors = adcpData.ShipVelocityData.VelocityVectors;
                }
                else if (adcpData.IsShipVelocityAvail)
                {
                    // Create the velocity vector data
                    DataSet.VelocityVectorHelper.CreateVelocityVector(ref adcpData);

                    ensVec.Vectors = adcpData.ShipVelocityData.VelocityVectors;
                }

                return(ensVec);
            }
Example #7
0
 /// <summary>
 /// Receive a list of vectors and add
 /// it to the list.  Limit the size of the list
 /// of vectors.
 /// </summary>
 /// <param name="vectors">Vectors to add to the list.</param>
 public void AddIncomingData(DataSet.EnsembleVelocityVectors vectors)
 {
     //Application.Current.Dispatcher.BeginInvoke(new Action(() => Update(vectors)));
     Application.Current.Dispatcher.BeginInvoke(new Action(() => AddVectors(vectors)));
     Application.Current.Dispatcher.BeginInvoke(new Action(() => DrawPlot()));
 }
 public void AddData(DataSet.EnsembleVelocityVectors ensVec)
 {
     Task.Run(() => VelPlot.AddIncomingData(ensVec));
 }
Example #9
0
            /// <summary>
            /// Create an struct to hold bin vectors for the amplitude data.
            /// Average the amplitude value for each bin and store as the magnitude value.
            /// </summary>
            /// <param name="ensemble">Ensemble to generate vector values.</param>
            /// <returns>Vectors for each bin in ensemble.</returns>
            public static DataSet.EnsembleVelocityVectors GenerateAmplitudeVectors(DataSet.Ensemble ensemble)
            {
                RTI.DataSet.VelocityVector[] vv = null;

                if (ensemble.IsAmplitudeAvail)
                {
                    // Create Velocity Vector with averaged amplitude data
                    vv = new RTI.DataSet.VelocityVector[ensemble.AmplitudeData.NumElements];

                    // Create a vector for each bin
                    // Take the average of the amplitude for the bin value
                    for (int bin = 0; bin < ensemble.EarthVelocityData.NumElements; bin++)
                    {
                        // Get the average for each bin
                        float avg   = 0;
                        int   count = 0;
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_0_INDEX] != DataSet.Ensemble.BAD_VELOCITY)
                        {
                            avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_0_INDEX]; count++;
                        }
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_1_INDEX] != DataSet.Ensemble.BAD_VELOCITY)
                        {
                            avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_1_INDEX]; count++;
                        }
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_2_INDEX] != DataSet.Ensemble.BAD_VELOCITY)
                        {
                            avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_2_INDEX]; count++;
                        }
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_3_INDEX] != DataSet.Ensemble.BAD_VELOCITY)
                        {
                            avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_3_INDEX]; count++;
                        }

                        // Ensure values were found
                        if (count > 0)
                        {
                            avg /= count;
                        }

                        vv[bin]                 = new VelocityVector();
                        vv[bin].Magnitude       = avg;
                        vv[bin].DirectionXNorth = 0;
                        vv[bin].DirectionYNorth = 0;
                    }
                }


                // Create struct to hold the data
                DataSet.EnsembleVelocityVectors ensVec = new DataSet.EnsembleVelocityVectors();
                ensVec.Id = ensemble.EnsembleData.UniqueId;

                if (vv != null)
                {
                    ensVec.Vectors = vv;
                }
                else
                {
                    // Put an BAD velocity entry
                    vv = new DataSet.VelocityVector[1];
                    vv[0].Magnitude       = DataSet.Ensemble.BAD_VELOCITY;
                    vv[0].DirectionXNorth = DataSet.Ensemble.BAD_VELOCITY;
                    vv[0].DirectionYNorth = DataSet.Ensemble.BAD_VELOCITY;

                    ensVec.Vectors = vv;
                }

                return(ensVec);
            }
Example #10
0
        /// <summary>
        /// For each bin, create a arrow.  Set the arrow location to the
        /// column location of the bin.  Set the lenght of the arrow based off
        /// the magnitude and a scale factor.  Set the color of the arrow based
        /// off the magnitude.  If the arrow is selected, set the color to the
        /// selection color.  Then rotate the arrow based off the angle in the
        /// vector.  Then add the arrow to the model.
        ///
        /// A North arrow will be created to know where North is relative
        /// to the scene.
        /// </summary>
        /// <param name="vectors">Vectors to display.</param>
        /// <param name="IsDownwardLooking">Flag if upward or downward looking ADCP.</param>
        private void DrawPlot(DataSet.EnsembleVelocityVectors vectors, bool IsDownwardLooking)
        {
            // Ensure the data is good
            if (vectors.Vectors != null)
            {
                var group   = new Model3DGroup();
                int numBins = vectors.Vectors.Length;

                // Go through each bin
                for (int bin = 0; bin < numBins; bin++)
                {
                    // If Downward looking, start bin from top going downward
                    // If Upward looking, start bin at the bottom going up.
                    // This resets the bin location based on orientation
                    int binLoc = bin;
                    if (!IsDownwardLooking)
                    {
                        binLoc = (numBins - 1) - bin;
                    }

                    // Get the magnitude and direction
                    double mag         = DataSet.Ensemble.BAD_VELOCITY;
                    double angleYNorth = DataSet.Ensemble.BAD_VELOCITY;
                    if (vectors.Vectors[binLoc] != null)
                    {
                        mag         = vectors.Vectors[binLoc].Magnitude;
                        angleYNorth = vectors.Vectors[binLoc].DirectionXNorth;
                    }

                    // If the magnitude is bad, do not create an arrow
                    if (mag != DataSet.Ensemble.BAD_VELOCITY)
                    {
                        // Add the bin arrow to the model
                        group.Children.Add(CreateBin(bin, mag, angleYNorth));
                    }
                }

                // If the ensemble changed, reset the base
                if (numBins != _prevNumBins)
                {
                    CreateBase(vectors.Vectors.Length);

                    _prevNumBins = numBins;
                }

                // Create the North and East arrow
                if (_northArrow != null)
                {
                    group.Children.Add(_northArrow);
                }
                if (_eastArrow != null)
                {
                    group.Children.Add(_eastArrow);
                }

                // Origin tube
                if (_originTube != null)
                {
                    group.Children.Add(_originTube);
                }

                // Last item to add
                if (_cylinder != null)
                {
                    group.Children.Add(_cylinder);
                }

                Content = group;
            }
        }
Example #11
0
            /// <summary>
            /// Create an EnsembleVelocityVector based off the ensemble.
            /// If the Velocity Vectors do not exist, create the vectors.
            /// </summary>
            /// <param name="adcpData">Ensemble data.</param>
            /// <returns>EnsembleVelocityVector with the velocity vector data.</returns>
            public static DataSet.EnsembleVelocityVectors GetInstrumentVelocityVectors(DataSet.Ensemble adcpData)
            {
                // Create struct to hold the data
                DataSet.EnsembleVelocityVectors ensVec = new DataSet.EnsembleVelocityVectors();
                ensVec.Id = adcpData.EnsembleData.UniqueId;

                // Check, if velocity vectors exist
                if (adcpData.IsInstrumentVelocityAvail && adcpData.InstrumentVelocityData.IsVelocityVectorAvail)
                {
                    ensVec.Vectors = adcpData.InstrumentVelocityData.VelocityVectors;
                }
                else if (adcpData.IsInstrumentVelocityAvail)
                {
                    // Create the velocity vector data
                    DataSet.VelocityVectorHelper.CreateVelocityVector(ref adcpData);

                    ensVec.Vectors = adcpData.InstrumentVelocityData.VelocityVectors;
                }

                return ensVec;
            }
Example #12
0
 /// <summary>
 /// Receive a list of vectors and add
 /// it to the list.  Limit the size of the list
 /// of vectors.
 /// </summary>
 /// <param name="vectors">Vectors to add to the list.</param>
 public async Task AddIncomingData(DataSet.EnsembleVelocityVectors vectors)
 {
     _prevVectors = vectors;
     await Application.Current.Dispatcher.BeginInvoke(new Action(() => DrawPlot(vectors)));
 }
 /// <summary>
 /// Receive a vector and add
 /// it to the list.  Limit the size of the list
 /// of vectors.
 /// </summary>
 /// <param name="vectors">Vectors to add to the list.</param>
 public void AddIncomingData(DataSet.EnsembleVelocityVectors vectors)
 {
     _plot.AddIncomingData(vectors);
     //PropertyChangeVelocityScales();
 }
Example #14
0
            /// <summary>
            /// Create an struct to hold bin vectors for the amplitude data.
            /// Average the amplitude value for each bin and store as the magnitude value.
            /// </summary>
            /// <param name="ensemble">Ensemble to generate vector values.</param>
            /// <returns>Vectors for each bin in ensemble.</returns>
            public static DataSet.EnsembleVelocityVectors GenerateAmplitudeVectors(DataSet.Ensemble ensemble)
            {
                RTI.DataSet.VelocityVector[] vv = null;

                if (ensemble.IsAmplitudeAvail)
                {
                    // Create Velocity Vector with averaged amplitude data
                    vv = new RTI.DataSet.VelocityVector[ensemble.AmplitudeData.NumElements];

                    // Create a vector for each bin
                    // Take the average of the amplitude for the bin value
                    for (int bin = 0; bin < ensemble.EarthVelocityData.NumElements; bin++)
                    {
                        // Get the average for each bin
                        float avg = 0;
                        int count = 0;
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_0_INDEX] != DataSet.Ensemble.BAD_VELOCITY) { avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_0_INDEX]; count++; }
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_1_INDEX] != DataSet.Ensemble.BAD_VELOCITY) { avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_1_INDEX]; count++; }
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_2_INDEX] != DataSet.Ensemble.BAD_VELOCITY) { avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_2_INDEX]; count++; }
                        if (ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_3_INDEX] != DataSet.Ensemble.BAD_VELOCITY) { avg += ensemble.AmplitudeData.AmplitudeData[bin, DataSet.Ensemble.BEAM_3_INDEX]; count++; }

                        // Ensure values were found
                        if (count > 0)
                        {
                            avg /= count;
                        }

                        vv[bin] = new VelocityVector();
                        vv[bin].Magnitude = avg;
                        vv[bin].DirectionXNorth = 0;
                        vv[bin].DirectionYNorth = 0;
                    }

                }

                // Create struct to hold the data
                DataSet.EnsembleVelocityVectors ensVec = new DataSet.EnsembleVelocityVectors();
                ensVec.Id = ensemble.EnsembleData.UniqueId;

                if (vv != null)
                {
                    ensVec.Vectors = vv;
                }
                else
                {
                    // Put an BAD velocity entry
                    vv = new DataSet.VelocityVector[1];
                    vv[0].Magnitude = DataSet.Ensemble.BAD_VELOCITY;
                    vv[0].DirectionXNorth = DataSet.Ensemble.BAD_VELOCITY;
                    vv[0].DirectionYNorth = DataSet.Ensemble.BAD_VELOCITY;

                    ensVec.Vectors = vv;
                }

                return ensVec;
            }
Example #15
0
 /// <summary>
 /// Receive a list of vectors and add
 /// it to the list.  Limit the size of the list
 /// of vectors.
 /// </summary>
 /// <param name="vectors">Vectors to add to the list.</param>
 /// <param name="isDownwardLooking">Flag if the ADCP is upward or downward looking.  By default it assumes downward looking.</param>
 public async Task AddIncomingData(DataSet.EnsembleVelocityVectors vectors, bool isDownwardLooking = true)
 {
     _prevVectors           = vectors;
     _prevIsDownwardLooking = isDownwardLooking;
     await Application.Current.Dispatcher.BeginInvoke(new Action(() => DrawPlot(vectors, isDownwardLooking)));
 }
 /// <summary>
 /// Receive a list of vectors and add
 /// it to the list.  Limit the size of the list 
 /// of vectors.
 /// </summary>
 /// <param name="vectors">Vectors to add to the list.</param>
 public void AddIncomingData(DataSet.EnsembleVelocityVectors vectors)
 {
     _prevVectors = vectors;
     Application.Current.Dispatcher.BeginInvoke(new Action(() => DrawPlot(vectors)));
 }
Example #17
0
            /// <summary>
            /// Create an struct to hold bin vectors for the velocity data
            /// based off the ensemble given.  This will remove the
            /// Bottom Track velocity from the velocity data then
            /// create  a vector representing the
            /// water velocity.
            /// Removing Ship Speed:
            /// BT Good, GPS Good or Bad = BT velocities
            /// BT Bad, GPS Good = GPS velocity
            /// BT Bad, GPS Bad = Previous Good BT
            /// BT Bad, Gps Bad, Previous BT Bad = None
            /// 
            /// </summary>
            /// <param name="adcpData">Ensemble to generate vector values.</param>
            /// <returns>Vectors for each bin in ensemble.</returns>
            public static DataSet.EnsembleVelocityVectors GenerateEarthVelocityVectors(DataSet.Ensemble adcpData)
            {
                // Create the velocity vector data
                DataSet.VelocityVectorHelper.CreateVelocityVector(ref adcpData);

                // Create struct to hold the data
                DataSet.EnsembleVelocityVectors ensVec = new DataSet.EnsembleVelocityVectors();
                ensVec.Id = adcpData.EnsembleData.UniqueId;

                if (adcpData.IsEarthVelocityAvail && adcpData.EarthVelocityData.IsVelocityVectorAvail)
                {
                    ensVec.Vectors = adcpData.EarthVelocityData.VelocityVectors;
                }

                return ensVec;
            }