public string[] ToArgs()
        {
            List <string> args = new List <string>();

            if (LowerLimit != 0 || UpperLimit != 0)
            {
                args.Add("LIMIT");
                args.Add(LowerLimit.ToString());
                args.Add(UpperLimit.ToString());
            }
            if (Lexographically)
            {
                args.Add("ALPHA");
            }
            if (!string.IsNullOrEmpty(By))
            {
                args.Add("BY");
                args.Add(By);
            }
            if (!string.IsNullOrEmpty(Get))
            {
                args.Add("GET");
                args.Add(Get);
            }
            return(args.ToArray());
        }
        /// <summary>
        /// Chart 설정 또는 변량에 대해 XML 속성으로 생성합니다.
        /// </summary>
        /// <param name="writer">xml writer</param>
        public override void GenerateXmlAttributes(XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (SetAdaptiveMin.HasValue)
            {
                writer.WriteAttributeString("SetAdaptiveMin", SetAdaptiveMin.GetHashCode().ToString());
            }
            if (UpperLimit.HasValue)
            {
                writer.WriteAttributeString("UpperLimit", UpperLimit.ToString());
            }
            if (LowerLimit.HasValue)
            {
                writer.WriteAttributeString("LowerLimit", LowerLimit.ToString());
            }
            if (UpperLimitDisplay.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("UpperLimitDisplay", UpperLimitDisplay);
            }
            if (LowerLimitDisplay.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("LowerLimitDisplay", LowerLimitDisplay);
            }
        }
        void ShowParameterLimits()
        {
            if (ShowAlarmLimits)
            {
                ShowParameterAlarmLimits();
            }
            ShowLimits = !ShowLimits;

            if (ShowLimits)
            {
                txtUpperLimit.Visibility = Visibility.Visible;
                txtLowerLimit.Visibility = Visibility.Visible;
            }
            else
            {
                bool result1 = double.TryParse(txtUpperLimit.Text, out double ul);
                bool result2 = double.TryParse(txtLowerLimit.Text, out double ll);
                if (result1 && result2)
                {
                    UpperLimit = ul;
                    LowerLimit = ll;
                }
                else
                {
                    txtUpperLimit.Text = UpperLimit.ToString();
                    txtLowerLimit.Text = LowerLimit.ToString();
                }
                txtUpperLimit.Visibility = Visibility.Collapsed;
                txtLowerLimit.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #4
0
        public override int GetHashCode()
        {
            int hashCode = -1304306776;

            hashCode = hashCode * -1521134295 + _value.GetHashCode();
            hashCode = hashCode * -1521134295 + LowerLimit.GetHashCode();
            hashCode = hashCode * -1521134295 + UpperLimit.GetHashCode();
            return(hashCode);
        }
Beispiel #5
0
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
        public override bool Equals(object obj)
        {
            if (!base.Equals(obj))
            {
                return(false);
            }
            RangeCategory <T> otherRange = (RangeCategory <T>)obj;

            return(LowerLimit.Equals(otherRange.LowerLimit) && UpperLimit.Equals(otherRange.UpperLimit));
        }
Beispiel #6
0
        /// <summary>
        ///     Determines whether whether a specified interval is contained by the current interval.
        /// </summary>
        /// <param name="other">The interval to check.</param>
        /// <returns>
        ///     <see langword="true"/> if the specified interval <paramref name="other"/> is inside,
        ///     and not equal to, the current interval; otherwise, <see langword="false"/>.
        /// </returns>
        public bool IsProperSupersetOf(Interval <T> other)
        {
            if (other == null)
            {
                return(true);
            }

            return(LowerLimit.LessThan(other.LowerLimit, Position.Lower) &&
                   UpperLimit.GreaterThan(other.UpperLimit, Position.Upper));
        }
Beispiel #7
0
        /// <summary>
        ///     Determines whether whether the current interval is contained by a specified interval.
        /// </summary>
        /// <param name="other">The interval to check.</param>
        /// <returns>
        ///     <see langword="true"/> if the current interval is inside, or equal to, the specified
        ///     interval <paramref name="other"/>; otherwise, <see langword="false"/>.
        /// </returns>
        public bool IsSubsetOf(Interval <T> other)
        {
            if (other == null)
            {
                return(false);
            }

            return(LowerLimit.GreaterThanOrEqual(other.LowerLimit, Position.Lower) &&
                   UpperLimit.LessThanOrEqual(other.UpperLimit, Position.Upper));
        }
Beispiel #8
0
        /// <summary>
        ///     Serves as the default hash function.
        /// </summary>
        /// <returns>A hash code for the current interval.</returns>
        public override int GetHashCode()
        {
            unchecked
            {
                int h1 = LowerLimit != null?LowerLimit.GetHashCode() : 0;

                int h2 = UpperLimit != null?UpperLimit.GetHashCode() : 0;

                return(((h1 << 5) + h1) ^ h2);
            }
        }
Beispiel #9
0
        /// <summary> </summary>
        public override int GetHashCode()
        {
            int hashCode = base.GetHashCode() ^ ObdGuid.GetHashCode()
                           ^ LowerLimit.GetHashCode() ^ UpperLimit.GetHashCode()
                           ^ StringAlgorithm.GetHashCode();

            if (DateRange != null)
            {
                hashCode ^= DateRange.GetHashCode();
            }

            if (!String.IsNullOrEmpty(StringInput))
            {
                hashCode ^= StringInput.GetHashCode();
            }
            return(hashCode);
        }
Beispiel #10
0
        private void Update(EvaluationContext context)
        {
            var list = Input.GetValue(context);

            if (list == null || list.Count == 0)
            {
                return;
            }
            var lowerLimit = Math.Max(0, LowerLimit.GetValue(context));
            var upperLimit = Math.Min(list.Count, UpperLimit.GetValue(context));
            var sum        = 0f;

            for (var index = lowerLimit; index < upperLimit; index++)
            {
                sum += list[index];
            }
            Selected.Value = sum;
        }
Beispiel #11
0
        private void Update(EvaluationContext context)
        {
            var fft = FftInput.GetValue(context);

            if (fft == null || fft.Count == 0)
            {
                return;
            }

            _bpmRangeMin = LowestBpm.GetValue(context);
            if (_bpmRangeMin < 50)
            {
                _bpmRangeMin = 50;
            }
            else if (_bpmRangeMin > 200)
            {
                _bpmRangeMin = 200;
            }

            _bpmRangeMax = HighestBpm.GetValue(context);
            if (_bpmRangeMax < _bpmRangeMin)
            {
                _bpmRangeMax = _bpmRangeMin + 1;
            }
            else if (_bpmRangeMax > 200)
            {
                _bpmRangeMax = 200;
            }

            if (_bpmEnergies.Count != _bpmRangeMax - _bpmRangeMin)
            {
                _bpmEnergies = new List <float>(new float[_bpmRangeMax - _bpmRangeMin]);
            }

            var bufferDuration = (int)BufferDurationSec.GetValue(context) * 60;

            if (bufferDuration < 60)
            {
                bufferDuration = 60;
            }
            else if (bufferDuration > 60 * 60)
            {
                bufferDuration = 60 * 60;
            }

            _bufferLength = bufferDuration;
            _lockInFactor = LockItFactor.GetValue(context);

            UpdateBuffer(fft, LowerLimit.GetValue(context), UpperLimit.GetValue(context));
            SmoothBuffer(ref _smoothedBuffer, _buffer);

            var bestBpm         = 0f;
            var bestMeasurement = float.PositiveInfinity;


            for (var bpm = _bpmRangeMin; bpm < _bpmRangeMax; bpm++)
            {
                var m = MeasureEnergyDifference(bpm) / ComputeFocusFactor(bpm, _currentBpm, 4, _lockInFactor);
                if (m < bestMeasurement)
                {
                    bestMeasurement = m;
                    bestBpm         = bpm;
                }

                _bpmEnergies[bpm - _bpmRangeMin] = m;
            }


            foreach (var offset in _searchOffsets)
            {
                var bpm = _currentBpm + offset;
                if (bpm < 70 || bpm > 160)
                {
                    continue;
                }

                var m = MeasureEnergyDifference(bpm) / ComputeFocusFactor(bpm, _currentBpm, 2, 0.01f);
                if (!(m < bestMeasurement))
                {
                    continue;
                }
                bestMeasurement = m;
                bestBpm         = bpm;
            }


            DetectedBpm.Value  = bestBpm;
            _currentBpm        = bestBpm;
            Measurements.Value = _bpmEnergies;
        }
Beispiel #12
0
        public string Action(string action, string parameter)
        {
            action    = action.ToLower();
            parameter = parameter.ToLower();

            if (action == "status")
            {
                return(Digest);
            }
            else if (action == "debug")
            {
                _debugging = Convert.ToBoolean(parameter);
                return(JsonConvert.SerializeObject(_debugging));
            }
            else if (action == "move")
            {
                switch (parameter)
                {
                case "up":
                    Move(Direction.Up);
                    break;

                case "down":
                    Move(Direction.Down);
                    break;

                case "all-up":
                    Move(Direction.AllUp);
                    break;

                case "all-down":
                    Move(Direction.AllDown);
                    break;

                default:
                    uint target = 0;

                    if (UInt32.TryParse(parameter, out target))
                    {
                        Move(target);
                    }
                    else
                    {
                        return(string.Format("Bad parameter \"{0}\" to Action(\"move\")", parameter));
                    }
                    break;
                }
                return("ok");
            }
            else if (action == "halt" || action == "stop")
            {
                Halt(reason: parameter);
                return("ok");
            }
            else if (action == "limit")
            {
                switch (parameter)
                {
                case "lower":
                    return(LowerLimit.ToString());

                case "upper":
                    return(UpperLimit.ToString());
                }
                return("ok");
            }
            else
            {
                throw new ASCOM.ActionNotImplementedException("Action " + action +
                                                              " is not implemented by this driver");
            }
        }
Beispiel #13
0
 /// <summary>
 /// Gets the hash code.
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(unchecked (base.GetHashCode() + LowerLimit.GetHashCode() + UpperLimit.GetHashCode()));
 }
Beispiel #14
0
 /// <summary>
 ///     Returns a string that represents the current interval.
 /// </summary>
 /// <returns>A string that represents the current interval.</returns>
 public override string ToString()
 {
     return($"{LowerLimit.GetString(Position.Lower)},{UpperLimit.GetString(Position.Upper)}");
 }