Exemplo n.º 1
0
        public ISpectrum CreateSpectrum(WaveSpectrumConditionKey key)
        {
            CustomWaveSpectrumExample.CustomSpectrumConditionKey customSpectrumConditionKey = key as CustomWaveSpectrumExample.CustomSpectrumConditionKey;
            if (customSpectrumConditionKey == null)
            {
                throw new InvalidCastException("Spectrum condition key is null or not the correct type");
            }
            float num     = customSpectrumConditionKey.WindSpeed;
            float windDir = customSpectrumConditionKey.WindDir;

            return(new CustomWaveSpectrumExample.CustomSpectrum(num, windDir));
        }
Exemplo n.º 2
0
            /// <summary>
            /// You need to check here if two keys are the same.
            /// You only need to compare your settings. The base 
            /// class will do the comparison for the other settings 
            /// and only call the Matches function if they do match.
            /// </summary>
            /// <param name="k">another key</param>
            /// <returns>If this key has the same settings as the other key</returns>
            protected override bool Matches(WaveSpectrumConditionKey k)
            {
                //Cast the key to your type.
                CustomSpectrumConditionKey key = k as CustomSpectrumConditionKey;

                //If the key is not of the same type return false
                if (key == null) return false;
                //If the key does not match your settings return false.
                if (WindSpeed != key.WindSpeed) return false;

                //else they have the same setting so would generate the same spectrum data so return true.
                return true;

            }
        protected override bool Matches(WaveSpectrumConditionKey k)
        {
            PhillipsSpectrumConditionKey key = k as PhillipsSpectrumConditionKey;

            if (key == null)
            {
                return(false);
            }
            if (WindSpeed != key.WindSpeed)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// You need to create a class (see below) that implements the ISpectrum 
        /// interface and is what will be used by the SpectrumTask script to generate the
        /// spectrum data. The task will call the Spectrum function from a separate
        /// thread as its being created so it need to be thread safe.
        /// </summary>
        public ISpectrum CreateSpectrum(WaveSpectrumConditionKey key)
        {
            //Cast from base class to your key type
            CustomSpectrumConditionKey k = key as CustomSpectrumConditionKey;

            //If this happens something has gone wrong. 
            //Check what your returning in the CreateKey function.
            if (k == null)
                throw new InvalidCastException("Spectrum condition key is null or not the correct type");

            //Get the settings the spectrum will be created from the key.
            float windSpeed = k.WindSpeed;
            float windDir = k.WindDir;

            //return a new spectrum.
            return new CustomSpectrum(windSpeed, windDir);
        }
Exemplo n.º 5
0
        protected override bool Matches(WaveSpectrumConditionKey k)
        {
            UnifiedSpectrumConditionKey key = k as UnifiedSpectrumConditionKey;

            if (key == null)
            {
                return(false);
            }
            if (WindSpeed != key.WindSpeed)
            {
                return(false);
            }
            if (WaveAge != key.WaveAge)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 6
0
        private void CreateConditions()
        {
            int size = this.m_bufferSettings.size;
            WaveSpectrumConditionKey waveSpectrumConditionKey = this.NewSpectrumConditionKey(size, this.windSpeed, this.m_ocean.windDir, this.waveAge);

            if (this.m_conditions[0] == null)
            {
                if (this.m_conditionCache.ContainsKey(waveSpectrumConditionKey))
                {
                    this.m_conditions[0] = this.m_conditionCache[waveSpectrumConditionKey];
                    this.m_conditionCache.Remove(waveSpectrumConditionKey);
                }
                else
                {
                    this.m_conditions[0] = this.NewSpectrumCondition(size, this.windSpeed, this.m_ocean.windDir, this.waveAge);
                    IThreadedTask createSpectrumConditionTask = this.m_conditions[0].GetCreateSpectrumConditionTask();
                    createSpectrumConditionTask.Start();
                    createSpectrumConditionTask.Run();
                    createSpectrumConditionTask.End();
                }
            }
            else if (this.m_conditions[1] != null && this.m_conditions[1].Done)
            {
                this.CacheCondition(this.m_conditions[0]);
                this.m_conditions[0] = this.m_conditions[1];
                this.m_conditions[1] = null;
            }
            else if (this.m_conditions[1] == null && this.m_conditions[0].Done && waveSpectrumConditionKey != this.m_conditions[0].Key)
            {
                if (this.m_conditionCache.ContainsKey(waveSpectrumConditionKey))
                {
                    this.m_conditions[0] = this.m_conditionCache[waveSpectrumConditionKey];
                    this.m_conditionCache.Remove(waveSpectrumConditionKey);
                }
                else
                {
                    this.m_conditions[1] = this.NewSpectrumCondition(size, this.windSpeed, this.m_ocean.windDir, this.waveAge);
                    IThreadedTask createSpectrumConditionTask2 = this.m_conditions[1].GetCreateSpectrumConditionTask();
                    this.m_scheduler.Add(createSpectrumConditionTask2);
                }
            }
        }
Exemplo n.º 7
0
 protected override bool Matches(WaveSpectrumConditionKey k)
 {
     CustomWaveSpectrumExample.CustomSpectrumConditionKey customSpectrumConditionKey = k as CustomWaveSpectrumExample.CustomSpectrumConditionKey;
     return(!(customSpectrumConditionKey == null) && this.WindSpeed == customSpectrumConditionKey.WindSpeed);
 }
        protected override bool Matches(WaveSpectrumConditionKey k)
        {
            UnifiedSpectrumConditionKey unifiedSpectrumConditionKey = k as UnifiedSpectrumConditionKey;

            return(!(unifiedSpectrumConditionKey == null) && this.WindSpeed == unifiedSpectrumConditionKey.WindSpeed && this.WaveAge == unifiedSpectrumConditionKey.WaveAge);
        }
        protected override bool Matches(WaveSpectrumConditionKey k)
        {
            PhillipsSpectrumConditionKey phillipsSpectrumConditionKey = k as PhillipsSpectrumConditionKey;

            return(!(phillipsSpectrumConditionKey == null) && this.WindSpeed == phillipsSpectrumConditionKey.WindSpeed);
        }