public List <Tuple <string, string> > ToTupleString() { var lst = new List <Tuple <string, string> >(); lst.Add(new Tuple <string, string>("startfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StartFreqUnit, "mhz", StartFrequency)))); lst.Add(new Tuple <string, string>("stopfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(EndFreqUnit, "mhz", EndFrequency)))); double step = Step; switch (StepUnit.ToUpper()) { case "GHZ": step = step * 1000000; break; case "MHZ": step = step * 1000; break; case "HZ": step = step / 1000; break; } lst.Add(new Tuple <string, string>("step", string.Format("{0}kHz", step))); double ifbw = Ifbw; switch (IfbwUnit.ToUpper()) { case "GHZ": ifbw = ifbw * 1000000; break; case "MHZ": ifbw = ifbw * 1000; break; case "HZ": ifbw = ifbw / 1000; break; } lst.Add(new Tuple <string, string>("ifbw", string.Format("{0}kHz", ifbw))); lst.Add(new Tuple <string, string>("detector", RmtpDefaultCollection.DetectorSource[DetectionMode].ToString())); lst.Add(new Tuple <string, string>("polarization", RmtpDefaultCollection.PolarizationSource[Polarization].ToString())); lst.Add(new Tuple <string, string>("statwindowtime", Statwindowtime.ToString())); lst.Add(new Tuple <string, string>("storage", Storage ? "on" : "off")); if (HasThreshold) { string signalthreshold = string.Format("{0}dBμV", SignalThreshold); lst.Add(new Tuple <string, string>("thresholdtype", Thresholdtype)); lst.Add(new Tuple <string, string>("signalthreshold", signalthreshold)); } lst.Add(new Tuple <string, string>("ifbwmode", "xdb")); lst.Add(new Tuple <string, string>("ifbwparam", "26")); return(lst); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { object v = value; string t = parameter as string; if (t != null) { _converterUnit = t; } if (!string.IsNullOrWhiteSpace(_converterUnit)) { switch (_converterUnit.ToUpper()) { case "GHZ": v = WMonitorUtile.ConvertFreqValue("hz", "ghz", System.Convert.ToDouble(value)); break; case "MHZ": v = WMonitorUtile.ConvertFreqValue("hz", "mhz", System.Convert.ToDouble(value)); break; case "KHZ": v = WMonitorUtile.ConvertFreqValue("hz", "khz", System.Convert.ToDouble(value)); break; case "HZ": v = MathNoRound(System.Convert.ToDouble(value), 0); break; } } return(v); }
public List <Tuple <string, string> > ToList() { Debug.Assert(!string.IsNullOrWhiteSpace(FrequencyUnit) && !string.IsNullOrWhiteSpace(IfbwUnit) && !string.IsNullOrWhiteSpace(SpanUnit) && !string.IsNullOrWhiteSpace(DemodMode) && !string.IsNullOrWhiteSpace(IfbwMode)); var paramList = new List <Tuple <string, string> > { new Tuple <string, string>("frequency", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(FrequencyUnit, "mhz", Frequency))), new Tuple <string, string>("ifbw", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(IfbwUnit, "khz", Ifbw))), new Tuple <string, string>("span", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(SpanUnit, "khz", Span))), new Tuple <string, string>("squelchthreshold", HasSquelchThreshold?string.Format("{0}dBuV", SquelchThreshold):"off"), new Tuple <string, string>("demodmode", DemodMode), new Tuple <string, string>("rfattenuation", HasRfattenuation?string.Format("{0}dB", Rfattenuation):"off"), new Tuple <string, string>("polarization", RmtpDefaultCollection.PolarizationSource[Polarization].ToString()), new Tuple <string, string>("detector", RmtpDefaultCollection.DetectorSource[Detector].ToString()), new Tuple <string, string>("itu", Itu?"on":"off"), new Tuple <string, string>("ifbwmode", IfbwMode.ToLower()), new Tuple <string, string>("ifbwparam", string.Format("{0}{1}", IfbwParam, IfbwMode.ToLower() == "xdb" ? "db" : "%")), new Tuple <string, string>("audio", Audio?"on":"off"), new Tuple <string, string>("storage", "on"), new Tuple <string, string>("gainmode", RmtpDefaultCollection.GainModeSource[GainMode].ToString()), }; if (RmtpDefaultCollection.GainModeSource[GainMode] == Rmtp.GainMode.mgc) { paramList.Add(new Tuple <string, string>("gainparam", string.Format("{0}dBuV", GainParam))); } return(paramList); }
private void UpdateValue() { if (_xRectValue == null || _xRectMaxValueHistory == null) { return; } int v = (int)WMonitorUtile.ViewToScreen(Value, ValueRangePanelWidth, 0, MaxValue, MinValue); _xRectValue.Width = Math.Abs(v); int m = (int)WMonitorUtile.ViewToScreen(_maxValueHistory, ValueRangePanelWidth, 0, MaxValue, MinValue); Canvas.SetLeft(_xRectMaxValueHistory, Math.Abs(m)); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double v; if (!double.TryParse(value.ToString(), out v)) { return(null); } if (parameter != null) { _converterUnit = parameter.ToString(); } if (!string.IsNullOrWhiteSpace(_converterUnit)) { switch (_converterUnit.ToUpper()) { case "GHZ": v = WMonitorUtile.ConvertFreqValue("ghz", "hz", v); break; case "MHZ": v = WMonitorUtile.ConvertFreqValue("mhz", "hz", v); break; case "KHZ": v = WMonitorUtile.ConvertFreqValue("khz", "hz", v); break; case "HZ": break; } } return(v); }
/// <summary> /// 绘制谱图 /// </summary> /// <param name="data">频率、值</param> public void DrawData(Dictionary <double, short> data, int pRemainder, DateTime?pTime = null) { if (_writeableBmp == null) { return; } if (!_receiveData) { return; } if (_writeableBmp.PixelHeight == 0 || _writeableBmp.PixelWidth == 0) { _writeableBmp = new WriteableBitmap((int)uxWaterfall.Width, (int)uxWaterfall.Height, 96, 96, PixelFormats.Pbgra32, null); _writeableBmp.FillRectangle(0, 0, (int)uxWaterfall.Width, (int)uxWaterfall.Height, Colors.Transparent); uxWaterfall.Source = _writeableBmp; } foreach (var fv in data) { if (_maxColumn == 0 || _maxColumn < _writeableBmp.PixelWidth) { _maxColumn = _writeableBmp.PixelWidth; } _cachedDatas[fv.Key] = fv.Value; } _writeableBmp.Clear(Colors.Transparent); var c = (_maxRow * (_timestampCount - 1) / _writeableBmp.PixelHeight) % _timestampCount; if (c != c1) { Timestamps.RemoveAt(0); Timestamps.Insert(_timestampCount - 1, pTime == null ? "--:--:--" : pTime.Value.ToLongTimeString()); c1 = c; } if (_isCompletion) { _maxRow += 1; } else { _maxRow = _cachedDatas.Count; } _writeableBmp.FillRectangle(0, 0, _writeableBmp.PixelWidth, _maxRow > _writeableBmp.PixelHeight ? _writeableBmp.PixelHeight : _maxRow, Color.FromArgb(210, 22, 22, 255)); _row = _maxRow; foreach (var tuple in _cachedDatas) { if (tuple.Key < XAxisMinimum || tuple.Key > XAxisMaximum) { continue; } var currFreq = Math.Floor(tuple.Key); var xAxisMaximumKhz = WMonitorUtile.ConvertFreqValue("mhz", "khz", XAxisMaximum); var xAxisMinimumKhz = WMonitorUtile.ConvertFreqValue("mhz", "khz", XAxisMinimum); var xKey = WMonitorUtile.ConvertFreqValue("mhz", "khz", tuple.Key); //if (currFreq.Equals(Math.Floor(XAxisMaximum)) || WMonitorUtile.ConvertFreqValue("mhz", "khz", tuple.Key).Equals(XAxisMaximumKhz - pRemainder))//起始减去终止频率除以步进有余数时,瀑布图显示一半的bug //if (currFreq.Equals(Math.Floor(XAxisMaximum)) || (xAxisMaximumKhz - xKey) < pRemainder) //{ _isCompletion = true; //} var col = (int)((tuple.Key - XAxisMinimum) * XUnitLength) + 1; if (col < EdgeMargin) { col = EdgeMargin; } if (col > _writeableBmp.PixelWidth) { col = _writeableBmp.PixelWidth - 1; } var y = tuple.Value; if (y <= YAxisMinimum || y < ThresholdValue) //门限 { continue; } if (_cachedColors.Keys.Contains(y)) { _writeableBmp.DrawLine(col, 0, col, _row, _cachedColors[y]); } else { _cachedColors[y] = GetColorAtPoint(uxYAxisRect, new Point(uxYAxisRect.ActualWidth, uxYAxisRect.ActualHeight - Math.Abs(y - YAxisMinimum) * _yUnitLength)); _writeableBmp.DrawLine(col, 0, col, _row, _cachedColors[y]); } if (!IsCompletion || _maxRow >= _cachedDatas.Count) { _row--; } } // _writeableBmp.Invalidate(); }
public List <Tuple <string, string> > ToList() { var paramList = new List <Tuple <string, string> > { new Tuple <string, string>("startfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StartFreqUnit, "mhz", StartFreq))), new Tuple <string, string>("stopfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StopFreqUnit, "mhz", StopFreq))), new Tuple <string, string>("rbw", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(RbwUnit, "khz", Rbw))), new Tuple <string, string>("polarization", RmtpDefaultCollection.PolarizationSource[Polarization].ToString()), new Tuple <string, string>("smoothmode", RmtpDefaultCollection.SmoothWaySource[SmoothMode].ToString()), new Tuple <string, string>("storage", Storage?"on":"off"), new Tuple <string, string>("gainmode", RmtpDefaultCollection.GainModeSource[GainMode].ToString()), }; if (RmtpDefaultCollection.SmoothWaySource[SmoothMode] != SmoothWay.none) { paramList.Add(new Tuple <string, string>("smoothparam", SmoothParam.ToString(CultureInfo.InvariantCulture))); } if (RmtpDefaultCollection.GainModeSource[GainMode] == Rmtp.GainMode.mgc) { paramList.Add(new Tuple <string, string>("gainparam", string.Format("{0}dBuV", GainParam))); } if (!IsStudy) { if (HasThreshold) { var tt = RmtpDefaultCollection.SignalSholdSource[ThresholdType].ToString(); string signalthreshold; if (tt == "horizontal") { signalthreshold = string.Format("{0}dBμV", SignalThreshold); paramList.Add(new Tuple <string, string>("thresholdtype", tt)); paramList.Add(new Tuple <string, string>("signalthreshold", signalthreshold)); } else if (tt == "background") { //自定义门限 paramList.Add(new Tuple <string, string>("thresholdtype", "custom")); paramList.Add(new Tuple <string, string>("thresholddesc", ThresholdDesc)); paramList.Add(new Tuple <string, string>("customthreshold", CustomThresholdValues)); } else if (tt == "noise") { paramList.Add(new Tuple <string, string>("thresholdtype", tt)); } if (tt != "horizontal") { paramList.Add(new Tuple <string, string>("margin", Margin.ToString(CultureInfo.InvariantCulture))); } } } if (ChannelizeBands.Count > 0) { var sb = new StringBuilder(); foreach (var cb in ChannelizeBands) { sb.AppendFormat("{0};", cb); } if (sb.Length > 0) { sb = sb.Remove(sb.Length - 1, 1); } paramList.Add(new Tuple <string, string>("channelizebands", sb.ToString())); } return(paramList); }
public List <Tuple <string, string> > ToTupleString() { var paramList = new List <Tuple <string, string> >(); paramList.Add(new Tuple <string, string>("startfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StartFreqUnit, "mhz", StartFreq)))); paramList.Add(new Tuple <string, string>("stopfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StopFreqUnit, "mhz", StopFreq)))); paramList.Add(new Tuple <string, string>("step", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(StepUnit, "khz", Step)))); paramList.Add(new Tuple <string, string>("ifbw", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(IfbwUnit, "khz", Ifbw)))); paramList.Add(new Tuple <string, string>("polarization", RmtpDefaultCollection.PolarizationSource[Polarization].ToString())); paramList.Add(new Tuple <string, string>("detector", RmtpDefaultCollection.DetectorSource[SmoothMode].ToString())); //paramList.Add(new Tuple<string, string>("storage", Storage ? "on" : "off")); paramList.Add(new Tuple <string, string>("storage", "on")); if (RmtpDefaultCollection.DetectorSource[SmoothMode] != Detector.fast && RmtpDefaultCollection.DetectorSource[SmoothMode] != Detector.qbk && RmtpDefaultCollection.DetectorSource[SmoothMode] != Detector.avg) { paramList.Add(new Tuple <string, string>("smoothparam", SmoothParam.ToString(CultureInfo.InvariantCulture))); } paramList.Add(new Tuple <string, string>("ifbwmode", "xdb")); paramList.Add(new Tuple <string, string>("ifbwparam", "26")); paramList.Add(new Tuple <string, string>("statwindowtime", 5.ToString())); paramList.Add(new Tuple <string, string>("gainmode", RmtpDefaultCollection.GainModeSource[GainMode].ToString())); if (RmtpDefaultCollection.GainModeSource[GainMode] == Rmtp.GainMode.mgc) { paramList.Add(new Tuple <string, string>("gainparam", string.Format("{0}dBuV", GainParam))); } if (!IsStudy) { if (HasThreshold) { if (ConfigurationManager.AppSettings["FscanSignalShold"].Equals("1")) { var tt = RmtpDefaultCollection.SignalSholdSource[ThresholdType].ToString(); string signalthreshold; if (tt == "horizontal") { signalthreshold = string.Format("{0}dBμV", SignalThreshold); paramList.Add(new Tuple <string, string>("thresholdtype", tt)); paramList.Add(new Tuple <string, string>("signalthreshold", signalthreshold)); } else if (tt == "background") { //自定义门限 paramList.Add(new Tuple <string, string>("thresholdtype", "custom")); paramList.Add(new Tuple <string, string>("thresholddesc", ThresholdDesc)); paramList.Add(new Tuple <string, string>("customthreshold", CustomThresholdValues)); } else if (tt == "noise") { paramList.Add(new Tuple <string, string>("thresholdtype", tt)); } if (tt != "horizontal") { //paramList.Add(new Tuple<string, string>("margin", Margin.ToString(CultureInfo.InvariantCulture))); paramList.Add(new Tuple <string, string>("signalthreshold", Margin.ToString(CultureInfo.InvariantCulture))); } } else { string signalthreshold = string.Format("{0}dBμV", SignalThreshold); paramList.Add(new Tuple <string, string>("thresholdtype", ThresholdType)); paramList.Add(new Tuple <string, string>("signalthreshold", signalthreshold)); } } } return(paramList); }