Пример #1
0
        private static void NewMaster()
        {
            // add dataset and write it to file
            ds.Tables.Add("Radios");
            ds.Tables["Radios"].Columns.Add("Model", typeof(string));
            ds.Tables["Radios"].Columns.Add("Serial", typeof(string));
            ds.Tables["Radios"].Columns.Add("Nickname", typeof(string));

            Radio r = new Radio(Model.DEMO, null, true);

            DataRow dr = ds.Tables["Radios"].NewRow();

            dr["Model"]    = r.Model.ToString();
            dr["Serial"]   = r.SerialNumber;
            dr["Nickname"] = r.Nickname;

            ds.Tables["Radios"].Rows.Add(dr);

            RadiosAvailable.AddRadio(r);

            try
            {
                ds.WriteXml(file_name, XmlWriteMode.WriteSchema);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An initial Master database write to file operation failed.  " +
                                "The exception error was:\n\n" + ex.Message,
                                "ERROR: Master Database Write Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private static void detachCallback(WDU_DEVICE_HANDLE pDev)
 {
     Debug.WriteLine("detach");
     RadiosAvailable.RadioDetach(new Radio(Model.FLEX1500, pDev));
     if (pDev == r)
     {
         r = IntPtr.Zero;
     }
 }
Пример #3
0
        private void PollRadios()
        {
            bool pal_init = false;

            while (!closing)
            {
                if (!pal_init)
                {
                    pal_init = Pal.Init();
                }
                else
                {
                    pal_init = RadiosAvailable.ScanPal();
                }

                RadiosAvailable.Scan1500();
                Thread.Sleep(1000);
            }
        }
Пример #4
0
        public static bool ScanPal()
        {
            Radio[] radios = PalManager.Instance.Scan()
                             .Select(sr => new Radio(sr.Model, sr.AccessObject, sr.SerialNumber, sr.Nickname, sr.Present))
                             .ToArray();

            if (radios == null)
            {
                foreach (Radio r in list)
                {
                    if (r.Model == Model.FLEX5000 || r.Model == Model.FLEX3000)
                    {
                        r.Present = false;
                    }
                }
                return(false);
            }

            RadiosAvailable.AddRadios(radios);

            foreach (Radio r in list)
            {
                if (r.Model == Model.FLEX5000 || r.Model == Model.FLEX3000)
                {
                    bool match = false;
                    for (int i = 0; i < radios.Length; i++)
                    {
                        if (r.SerialNumber == radios[i].SerialNumber)
                        {
                            match = true;
                            break;
                        }
                    }

                    if (!match)
                    {
                        r.Present = false;
                    }
                }
            }

            return(true);
        }
        private void LegacyForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (chkSDR1000.Checked || chkSoftRock.Checked)
            {
                if (chkSDR1000.Checked)
                {
                    Radio r = new Radio(Model.SDR1000, null, txtSDR1000SN.Text, true);
                    Master.AddRadio(r);
                    RadiosAvailable.AddRadio(r);
                }

                if (chkSoftRock.Checked)
                {
                    Radio r = new Radio(Model.SOFTROCK40, null, txtSoftRockSN.Text, true);
                    Master.AddRadio(r);
                    RadiosAvailable.AddRadio(r);
                }

                Master.Commit();
            }
        }
Пример #6
0
        public static bool ScanPal()
        {
            Radio[] radios = Pal.Scan();
            if (radios == null)
            {
                foreach (Radio r in list)
                {
                    if (r.Model == Model.FLEX5000 || r.Model == Model.FLEX3000)
                    {
                        r.Present = false;
                    }
                }
                return(false);
            }

            RadiosAvailable.AddRadios(radios);

            foreach (Radio r in list)
            {
                if (r.Model == Model.FLEX5000 || r.Model == Model.FLEX3000)
                {
                    bool match = false;
                    for (int i = 0; i < radios.Length; i++)
                    {
                        if (r.SerialNumber == radios[i].SerialNumber)
                        {
                            match = true;
                            break;
                        }
                    }

                    if (!match)
                    {
                        r.Present = false;
                    }
                }
            }

            return(true);
        }
Пример #7
0
        private static void NewMaster()
        {
            // add dataset and write it to file
            ds.Tables.Add("Radios");
            ds.Tables["Radios"].Columns.Add("Model", typeof(string));
            ds.Tables["Radios"].Columns.Add("Serial", typeof(string));
            ds.Tables["Radios"].Columns.Add("Nickname", typeof(string));

            Radio r = new Radio(Model.DEMO, null, true);

            DataRow dr = ds.Tables["Radios"].NewRow();

            dr["Model"]    = r.Model.ToString();
            dr["Serial"]   = r.SerialNumber;
            dr["Nickname"] = r.Nickname;

            ds.Tables["Radios"].Rows.Add(dr);

            RadiosAvailable.AddRadio(r);

            ds.WriteXml(file_name, XmlWriteMode.WriteSchema);
        }
Пример #8
0
        /// <summary>
        /// Initializes the master file and populates the RadiosAvailable list
        /// </summary>
        public static void Init()
        {
            if (ds.Tables.Count > 0)
            {
                return;                      // don't allow init to run more than once
            }
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                          + "\\FlexRadio Systems\\";

            file_name = path + "master.xml";

            if (File.Exists(path + "production"))
            {
                production = true;
            }

            if (File.Exists(file_name))
            {
                try
                {
                    ds.ReadXml(file_name);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("The Master database schema is corrupted and unusable.\n" +
                                    "Exception error was:\n\n" + ex.Message + "\n\n" + "A new Master database will be created",
                                    "ERROR: Master DB is Unusable",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);

                    ds = new DataSet("Master");
                    NewMaster();
                }
            }
            else // file doesn't exist -- create a new master
            {
                NewMaster();
            }

            foreach (DataRow dr in ds.Tables["Radios"].Rows)
            {
                try
                {
                    Model  m       = (Model)Enum.Parse(typeof(Model), (string)dr["Model"]);
                    string sn      = (string)dr["Serial"];
                    string nick    = (string)dr["Nickname"];
                    bool   present = false;

                    switch (m)
                    {
                    case Model.DEMO:
                        present = true;
                        break;

                    default:
                        break;
                    }

                    RadiosAvailable.AddRadio(new Radio(m, null, sn, nick, present));
                }
                catch (Exception)
                {
                    // catch CDRX values here
                }
            }
        }
 private static void attachCallback(WDU_DEVICE_HANDLE pDev)
 {
     Debug.WriteLine("attach");
     RadiosAvailable.AddPending1500(pDev);
     Init();
 }