Ejemplo n.º 1
0
        public void StatusUpdate(string s)
        {
            bool set_radio_ack = false;

            string[] words = s.Split(' ');

            foreach (string kv in words)
            {
                string[] tokens = kv.Split('=');
                if (tokens.Length != 2)
                {
                    Debug.WriteLine("Display::StatusUpdate: Invalid key/value pair (" + kv + ")");
                    continue;
                }

                string key   = tokens[0];
                string value = tokens[1];

                switch (key.ToLower())
                {
                case "average":
                {
                    int  temp;
                    bool b = int.TryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _average = temp;
                    RaisePropertyChanged("Average");
                }
                break;

                case "ant_list":
                {
                    // We don't want to raise the property if the list did not change.  However, checking
                    // for this causes a race condition that brings up duplicate slices for some reason.
                    //if (_rx_antenna_list != null && _rx_antenna_list.SequenceEqual(value.Split(',')))
                    //    continue;

                    _rx_antenna_list = value.Split(',');
                    RaisePropertyChanged("RXAntennaList");
                }
                break;

                case "band":
                {
                    string temp;
                    //TODO: Maybe add checks but we can read the string value without parsing
                    temp = value;

                    _band = temp;
                    RaisePropertyChanged("Band");
                }
                break;

                case "bandwidth":
                {
                    double temp;
                    bool   b = StringHelper.DoubleTryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _bandwidth = temp;         // in MHz
                    RaisePropertyChanged("Bandwidth");
                }
                break;

                case "center":
                {
                    double temp;
                    bool   b = StringHelper.DoubleTryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _centerFreq = temp;         // in MHz
                    RaisePropertyChanged("CenterFreq");

                    //Debug.WriteLine("Status: Pan 0x" + _stream_id.ToString("X") + " Freq:" + _centerFreq.ToString("f6"));
                }
                break;

                case "daxiq":
                {
                    uint temp;
                    bool b = uint.TryParse(value, out temp);

                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _radio.ClearIQStreamPan(_daxIQChannel, this);

                    _daxIQChannel = (int)temp;
                    RaisePropertyChanged("DAXIQChannel");

                    _radio.SetIQStreamPan(_daxIQChannel, this);
                }
                break;

                case "fps":
                {
                    int  temp;
                    bool b = int.TryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _fps = temp;
                    RaisePropertyChanged("FPS");
                }
                break;

                case "loopa":
                {
                    byte temp;
                    bool b = byte.TryParse(value, out temp);
                    if (!b || temp > 1)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate -- loopa: Invalid value (" + kv + ")");
                        continue;
                    }

                    _loopA = Convert.ToBoolean(temp);
                    RaisePropertyChanged("LoopA");
                }
                break;

                case "loopb":
                {
                    byte temp;
                    bool b = byte.TryParse(value, out temp);
                    if (!b || temp > 1)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate -- loopb: Invalid value (" + kv + ")");
                        continue;
                    }

                    _loopB = Convert.ToBoolean(temp);
                    RaisePropertyChanged("LoopB");
                }
                break;

                case "min_bw":
                {
                    double temp;
                    bool   b = StringHelper.DoubleTryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _minBandwidth = temp;
                    RaisePropertyChanged("MinBandwidth");
                }
                break;

                case "min_dbm":
                {
                    double temp;
                    bool   b = StringHelper.DoubleTryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _lowDbm = temp;
                    RaisePropertyChanged("LowDbm");
                }
                break;

                case "max_bw":
                {
                    double temp;
                    bool   b = StringHelper.DoubleTryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _maxBandwidth = temp;
                    RaisePropertyChanged("MaxBandwidth");
                }
                break;

                case "max_dbm":
                {
                    double temp;
                    bool   b = StringHelper.DoubleTryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _highDbm = temp;
                    RaisePropertyChanged("HighDbm");
                }
                break;

                case "wnb":
                {
                    uint temp;
                    bool b = uint.TryParse(value, out temp);
                    if (!b || temp > 1)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    if (_wnb_on == Convert.ToBoolean(temp))
                    {
                        continue;
                    }

                    _wnb_on = Convert.ToBoolean(temp);
                    RaisePropertyChanged("WNBOn");
                }
                break;

                case "wnb_level":
                {
                    uint temp;
                    bool b = uint.TryParse(value, out temp);
                    if (!b || temp > 100)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    if (_wnb_level == (int)temp)
                    {
                        continue;
                    }

                    _wnb_level = (int)temp;
                    RaisePropertyChanged("WNBLevel");
                }
                break;

                case "wnb_updating":
                {
                    uint temp;
                    bool b = uint.TryParse(value, out temp);
                    if (!b || temp > 1)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    if (_wnb_updating == Convert.ToBoolean(temp))
                    {
                        continue;
                    }

                    _wnb_updating = Convert.ToBoolean(temp);
                    RaisePropertyChanged("WNBUpdating");
                }
                break;

                case "pre":
                {
                    _preamp = value;
                    RaisePropertyChanged("Preamp");
                }
                break;

                case "rfgain":
                {
                    int  temp;
                    bool b = int.TryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _rfGain = temp;
                    RaisePropertyChanged("RFGain");
                }
                break;

                case "rxant":
                {
                    _rxant = value;
                    RaisePropertyChanged("RXAnt");
                }
                break;

                case "waterfall":
                {
                    uint fall_id;
                    bool b = uint.TryParse(value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out fall_id);

                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _childWaterfallStreamID = fall_id;


                    if (!_radio_ack)
                    {
                        set_radio_ack = true;
                    }
                    //RaisePropertyChanged("ChildWaterfallStreamID");
                }
                break;

                case "weighted_average":
                {
                    byte temp;
                    bool b = byte.TryParse(value, out temp);

                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    _weightedAverage = Convert.ToBoolean(temp);
                    RaisePropertyChanged("WeightedAverage");
                }
                break;

                case "wide":
                {
                    byte temp;
                    bool b = byte.TryParse(value, out temp);
                    if (!b || temp > 1)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate -- wide: Invalid value (" + kv + ")");
                        continue;
                    }

                    _wide = Convert.ToBoolean(temp);
                    RaisePropertyChanged("Wide");
                }
                break;

                case "x_pixels":
                {
                    uint temp;
                    bool b = uint.TryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    if ((int)temp != _width)
                    {
                        //Size = new Size((int)temp, _size.Height);
                        //if (buf.Length < _size.Width)
                        //  buf = new ushort[(int)_size.Width];

                        //RaisePropertyChanged("Size");
                    }
                }
                break;

                case "xvtr":
                {
                    _xvtr = value;
                    RaisePropertyChanged("XVTR");
                }
                break;


                case "y_pixels":
                {
                    uint temp;
                    bool b = uint.TryParse(value, out temp);
                    if (!b)
                    {
                        Debug.WriteLine("Panadapter::StatusUpdate: Invalid value (" + kv + ")");
                        continue;
                    }

                    if ((int)temp != _height)
                    {
                        //Size = new Size(_size.Width, (int)temp);
                        //if (buf.Length < _size.Width)
                        //  buf = new ushort[(int)_size.Width];
                        // RaisePropertyChanged("Size");
                    }
                }
                break;

                case "daxiq_rate":
                case "capacity":
                case "available":
                    // keep these from showing up in the debug output
                    break;

                default:
                    Debug.WriteLine("Panadapter::StatusUpdate: Key not parsed (" + kv + ")");
                    break;
                }
            }

            if (set_radio_ack)
            {
                checkRadioACK();
            }
        }