Пример #1
0
        public static Radio[] Scan()
        {
            int devs = Pal.GetNumDevices();
            if (devs == 0) return null;

            Radio[] radios = new Radio[devs];

            for (uint i = 0; i < devs; i++)
            {
                uint model;
                uint sn;
                if(!Pal.GetDeviceInfo(i, out model, out sn))
                    return null;

                Model m = Model.FLEX5000;
                if (model == 3)
                    m = Model.FLEX3000;

                string serial = FWCEEPROM.SerialToString(sn);

                radios[i] = new Radio(m, i, serial, true);
            }

            return radios;
        }
Пример #2
0
        public int CompareTo(object obj) // to implement the IComparable interface
        {
            Radio r = (Radio)obj;

            if (this.model != r.model)
            {
                return(this.model.CompareTo(r.model));
            }

            if (this.nickname != r.nickname)
            {
                return(this.nickname.CompareTo(r.nickname));
            }

            return(this.serial_number.CompareTo(r.serial_number));
        }
Пример #3
0
        public static bool RemoveRadio(Radio r)
        {
            bool found = false;

            foreach (DataRow dr in ds.Tables["Radios"].Rows)
            {
                if ((string)dr["Model"] == r.Model.ToString() && // model match
                    (string)dr["Serial"] == r.SerialNumber)      // serial number match
                {
                    found = true;
                    ds.Tables["Radios"].Rows.Remove(dr);
                    break;
                }
            }

            return(found);
        }
Пример #4
0
        public static bool RadioDetach(Radio radio)
        {
            foreach (Radio r in list)
            {
                // if radio is in the list, make present = false
                if (r.Model == radio.Model)
                {
                    bool match = false;
                    switch (r.Model)
                    {
                    case Model.FLEX1500:
                        if (r.AccessObj != null && radio.AccessObj != null)
                        {
                            if ((IntPtr)r.AccessObj == (IntPtr)radio.AccessObj)
                            {
                                match = true;
                            }
                        }
                        break;

                    case Model.FLEX5000:
                        if (radio.AccessObj != null)
                        {
                            if ((uint)r.AccessObj == (uint)radio.AccessObj)
                            {
                                match = true;
                            }
                        }
                        break;
                    }

                    if (match)
                    {
                        r.Present   = false;
                        r.AccessObj = null;
                        return(true);
                    }
                }
            }

            return(false);
        }
        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
        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();
            }
        }
Пример #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
        public static bool AddRadio(Radio radio)
        {
            foreach (Radio r in list)
            {
                // if radio is already in the list, update it
                if (r.SerialNumber == radio.SerialNumber &&
                    r.Model == radio.Model)
                {
                    if (!r.Present)
                    {
                        r.Present = radio.Present;
                        if (radio.AccessObj != null)
                            r.AccessObj = radio.AccessObj;
                    }
                    return false;
                }
            }

            list.Add(radio);

            return true;
        }
Пример #9
0
        public static bool AddRadio(Radio radio)
        {
            foreach (Radio r in list)
            {
                // if radio is already in the list, update it
                if (r.SerialNumber == radio.SerialNumber &&
                    r.Model == radio.Model)
                {
                    if (!r.Present)
                    {
                        r.Present = radio.Present;
                        if (radio.AccessObj != null)
                        {
                            r.AccessObj = radio.AccessObj;
                        }
                    }
                    return(false);
                }
            }

            list.Add(radio);

            return(true);
        }
Пример #10
0
        public static Radio[] Scan()
        {
            int devs = Pal.GetNumDevices();                 // get numer of radios found

            //    System.Diagnostics.Trace.WriteLine("pal=============================");

            if (devs == 0)
            {
                return(null);
            }

            Radio[] radios = new Radio[devs];

            for (uint i = 0; i < devs; i++)
            {
                uint model;
                uint sn;

                if (!Pal.GetDeviceInfo(i, out model, out sn))
                {
                    return(null);
                }

                Model m = Model.FLEX5000;
                if (model == 3)
                {
                    m = Model.FLEX3000;
                }

                string serial = FWCEEPROM.SerialToString(sn);   // radios serial#

                radios[i] = new Radio(m, i, serial, true);
            }

            return(radios);
        } // Scan()
Пример #11
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);
            }
        }
Пример #12
0
        /// <summary>
        /// Adds/Updates the master file with a single radio
        /// </summary>
        /// <param name="r">Radio to add/update</param>
        /// <returns>True if radio was already in the list</returns>
        public static bool AddRadio(Radio r)
        {
            if (production && r.Model != Model.DEMO) return false;
            bool found = false;
            foreach (DataRow dr in ds.Tables["Radios"].Rows)
            {
                if ((string)dr["Serial"] == r.SerialNumber) // serial number match
                {
                    Model m = (Model)Enum.Parse(typeof(Model), (string)dr["Model"]);
                    if (r.Model == m) // Model match
                    {
                        found = true;
                        dr["Nickname"] = r.Nickname;
                        break;
                    }
                }
            }

            if (!found)
            {
                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);
            }

            return found;
        }
Пример #13
0
        /// <summary>
        /// Adds/Updates the master file with a list of radios
        /// </summary>
        /// <param name="radios">Array of radios to add/update</param>
        /// <returns>True if all radios added were already in the list, otherwise returns false</returns>
        public static bool AddRadio(Radio[] radios)
        {
            bool found = true;
            foreach (Radio r in radios)
            {
                bool b = AddRadio(r);
                if (!b) found = b;
            }

            return found;
        }
Пример #14
0
        public static bool RadioDetach(Radio radio)
        {
            foreach (Radio r in list)
            {
                // if radio is in the list, make present = false
                if (r.Model == radio.Model)
                {
                    bool match = false;
                    switch (r.Model)
                    {
                        case Model.FLEX1500:
                            if (r.AccessObj != null && radio.AccessObj != null)
                            {
                                if ((IntPtr)r.AccessObj == (IntPtr)radio.AccessObj)
                                    match = true;
                            }
                            break;
                        case Model.FLEX5000:
                            if (radio.AccessObj != null)
                            {
                                if ((uint)r.AccessObj == (uint)radio.AccessObj)
                                    match = true;
                            }
                            break;
                    }

                    if (match)
                    {
                        r.Present = false;
                        r.AccessObj = null;
                        return true;
                    }
                }
            }

            return false;
        }
Пример #15
0
 public static bool AddRadios(Radio[] radios)
 {
     foreach (Radio radio in radios)
         AddRadio(radio);
     return true;
 }
Пример #16
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            Radio r = RadiosAvailable.RadioList[e.RowIndex];

            //DataGridViewRow row = dataGridView1.Rows[e.RowIndex];

            if (e.ColumnIndex == dataGridView1.Columns["Use"].Index) // Use clicked
            {
                if (r.Present)
                {
                    //MessageBox.Show("Use " + r.Model.ToString() + " " + r.SerialNumber);

                    switch (r.Model)
                    {
                    case Model.FLEX5000:
                    case Model.FLEX3000:
                        Pal.SelectDevice((uint)r.AccessObj);
                        break;

                    case Model.FLEX1500:
                        Flex1500.SetActiveRadio((IntPtr)r.AccessObj);
                        break;

                    case Model.SDR1000:
                    case Model.SOFTROCK40:
                    case Model.DEMO:
                        break;
                    }

                    console.DBFileName = console.AppDataPath + r.GetDBFilename();
                    console.RadioToUse = r;

                    this.Close();
                }
            }

            if (e.ColumnIndex == dataGridView1.Columns["Remove"].Index) // Remove clicked
            {
                if (r.Model == Model.DEMO)
                {
                    return;
                }

                DialogResult dr = MessageBox.Show("Are you sure you want to remove " + r.Model.ToString() + ": " + r.SerialNumber + " from the list?",
                                                  "Remove radio?",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question,
                                                  MessageBoxDefaultButton.Button2);

                if (dr == DialogResult.No)
                {
                    return;
                }

                Master.RemoveRadio(r);
                RadiosAvailable.RadioList.Remove(r);
            }
        }
Пример #17
0
 public static bool RemoveRadio(Radio r)
 {
     bool found = false;
     foreach (DataRow dr in ds.Tables["Radios"].Rows)
     {
         if ((string)dr["Model"] == r.Model.ToString() && // model match
             (string)dr["Serial"] == r.SerialNumber) // serial number match
         {                    
             found = true;
             ds.Tables["Radios"].Rows.Remove(dr);
             break;
         }
     }        
     
     return found;
 }
Пример #18
0
        // ======================================================
        // Constructor and Destructor
        // ======================================================
        public Console(string[] args)
        {
            //			HiPerfTimer t1 = new HiPerfTimer();
            //			Debug.WriteLine("timer_freq: "+t1.GetFreq());

            //fwc_init = FWC.Open1394Driver();

            CmdLineArgs = args;

            Splash.ShowSplashScreen();							// Start splash screen

            Splash.SetStatus("Initializing Components");		// Set progress point
            InitializeComponent();								// Windows Forms Generated Code

            Splash.SetStatus("Initializing Database");			// Set progress point
            DB.Init();											// Initialize the database

            Splash.SetStatus("Initializing Hardware");				// Set progress point
            // check model in Options table
            ArrayList list = DB.GetOptions();						// Get the saved list of controls
            DB.GetIQ();

            list.Sort();
            /*			foreach(string s in list)
            {
                if(s.StartsWith("radGenModelFLEX5000") && s.IndexOf("True") >= 0)
                    fwc_init = true;
            }

            if(fwc_init)
            {
                int count = 0;
                while(!(fwc_init = FWCMidi.Open()))
                {
                    if(count++ > 15)
                    {
                        Splash.HideForm();
                        DialogResult dr = MessageBox.Show("Error communicating with FLEX-5000.  Would you like to switch\n"+
                            "to Demo (no hardware) mode?  If not, check that the unit has\n"+
                            "power and FireWire connections and try again.",
                            "FLEX-5000 Not Found: Switch to Demo mode?",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Error);
                        if(dr == DialogResult.Yes)
                        {
                            ArrayList a = new ArrayList();
                            a.Add("radGenModelFLEX5000/False");
                            a.Add("radGenModelDemoNone/True");
                            DB.SaveOptions(ref a);
                            DB.Exit();
                            DB.Init();
                            fwc_init = false;
                        }
                        else
                        {
                            foreach(Control c in this.Controls)
                                c.Enabled = false;
                            Splash.CloseForm();
                            //Thread.CurrentThread.Abort();
                            Process.GetCurrentProcess().Kill();
                            return;
                        }
                        break;
                    }
                    Thread.Sleep(1000);
                }
            }
            else if(list.Count == 0)
            {
                fwc_init = FWCMidi.Open();
            }

            if(fwc_init)
            {
                FWCEEPROM.Init();
                InitFLEX5000();
            }

            if(fwc_init && current_model == Model.FLEX5000)
            {
                if(FWCEEPROM.RX2OK)
                {
                    chkRX2.Visible = true;
                    lblAntRX2.Visible = true;
                    panelRX2Divider.Visible = true;
                }
                else
                {
                    this.Height -= (grpRX2Filter.Height+16);
                    if(chkRX2.Checked) chkRX2.Checked = false;
                }
            }
            */
            Splash.SetStatus("Initializing Radio");				// Set progress point
            radio = new Radio();								// Initialize the Radio processor

            Splash.SetStatus("Initializing PortAudio");			// Set progress point
            PA19.PA_Initialize();								// Initialize the audio interface

            Splash.SetStatus("Loading Main Form");				// Set progress point
            Splash.SplashForm.Owner = this;						// So that main form will show/focus when splash disappears
            break_in_timer = new HiPerfTimer();

            InitConsole();										// Initialize all forms and main variables

            Splash.SetStatus("Finished");						// Set progress point
            // Activates double buffering
            SetStyle(ControlStyles.DoubleBuffer, true);

            Splash.CloseForm();									// End splash screen

            if(File.Exists("extended.edf"))						// Check for extended capabilities file
            {
                ArrayList a = DB.GetVars("State");
                a.Sort();
                ArrayList names = new ArrayList();
                ArrayList vals = new ArrayList();

                foreach(string s in a)
                {
                    string[] str = s.Split('/');
                    if(str.Length > 2)
                    {
                        for(int j=2; j<str.Length; j++)
                            str[1] += "/"+str[j];
                    }
                    names.Add(str[0]);
                    vals.Add(str[1]);
                }

                int i = names.BinarySearch("extended");
                if(i < 0) // If not found, prompt for logon info
                {
                    LogOn LogOnForm = new LogOn(this);
                    LogOnForm.ShowDialog();
                }
                else  // If found, check for existing logon info
                {
                    string text = (string)vals[i];

                    StreamReader sr = File.OpenText("extended.edf");
                    string data = sr.ReadLine();
                    sr.Close();

                    if(text == data)
                        extended = true;
                    else	// Logon information found, but doesn't match
                    {
                        MessageBox.Show("Error reading logon information.", "Logon Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        LogOn LogOnForm = new LogOn(this);
                        LogOnForm.ShowDialog();
                    }
                }
            }

            if(this.Text.IndexOf("SVN") >= 0)
            {
                if(File.Exists(Application.StartupPath+"\\.svn\\entries"))
                {
                    try
                    {
                        string temp = this.Text;
                        StreamReader reader = new StreamReader(Application.StartupPath+"\\.svn\\entries");
                        for(int i=0; i<3; i++)
                            reader.ReadLine();

                        string current_rev = reader.ReadLine();
                        reader.Close();

                        int svn_rev = int.Parse(current_rev);
                        int title_rev = int.Parse(temp.Substring(temp.IndexOf(":")+2, 4));
                        if(title_rev < svn_rev)
                            this.Text = temp.Replace(title_rev.ToString(), svn_rev.ToString());
                    }
                    catch(Exception)
                    {
                        // do nothing
                    }
                }

                if(show_alpha_warning)
                {
                    AlphaWarnForm form = new AlphaWarnForm(this);
                    form.ShowDialog();
                }

                mnuReportBug.Visible = true;
            }

            if(run_setup_wizard)
            {
                SetupWizard w = new SetupWizard(this, 0);
                w.ShowDialog();
                if(fwc_init && current_model == Model.FLEX5000)
                {
                    SetupForm.ResetFLEX5000();
                    CheckFLEX5000CalData();
                    for(int i=0; i<8; i++)
                        flex5000DebugForm.SetPAPot(i, (byte)pa_bias_table[0][i]);
                    RX1Band = RX2Band = TXBand = rx1_band;
                    fwcAntForm.SetBand(rx1_band);
                    fwcAntForm.CurrentAntMode = current_ant_mode;
                    fwcAntForm.RX1Ant = rx1_ant;
                    fwcAntForm.RX1Loop = rx1_loop;
                    fwcAntForm.RX2Ant = rx2_ant;
                    fwcAntForm.TXAnt = tx_ant;
                    CheckRX2CalData();
                }
            }

            if(rx1_meter_cal_offset == 0.0f)
            {
                switch(current_soundcard)
                {
                    case SoundCard.SANTA_CRUZ:
                        rx1_meter_cal_offset = -26.39952f;
                        break;
                    case SoundCard.AUDIGY_2_ZS:
                        rx1_meter_cal_offset = 1.024933f;
                        break;
                    case SoundCard.MP3_PLUS:
                        rx1_meter_cal_offset = -33.40224f;
                        break;
                    case SoundCard.EXTIGY:
                        rx1_meter_cal_offset = -29.30501f;
                        break;
                    case SoundCard.DELTA_44:
                        rx1_meter_cal_offset = -25.13887f;
                        break;
                    case SoundCard.FIREBOX:
                        rx1_meter_cal_offset = -20.94611f;
                        break;
                    case SoundCard.EDIROL_FA_66:
                        rx1_meter_cal_offset = -46.82864f;
                        break;
                    case SoundCard.UNSUPPORTED_CARD:
                        rx1_meter_cal_offset = -22.43533f;
                        break;
                }
            }

            if(rx1_display_cal_offset == 0.0f)
            {
                switch(current_soundcard)
                {
                    case SoundCard.SANTA_CRUZ:
                        RX1DisplayCalOffset = -56.56675f;
                        break;
                    case SoundCard.AUDIGY_2_ZS:
                        RX1DisplayCalOffset = -29.20928f;
                        break;
                    case SoundCard.MP3_PLUS:
                        RX1DisplayCalOffset = -62.84578f;
                        break;
                    case SoundCard.EXTIGY:
                        RX1DisplayCalOffset = -62.099f;
                        break;
                    case SoundCard.DELTA_44:
                        RX1DisplayCalOffset = -57.467f;
                        break;
                    case SoundCard.FIREBOX:
                        RX1DisplayCalOffset = -54.019f;
                        break;
                    case SoundCard.EDIROL_FA_66:
                        RX1DisplayCalOffset = -80.429f;
                        break;
                    case SoundCard.UNSUPPORTED_CARD:
                        RX1DisplayCalOffset = -48.62103f;
                        break;
                }
            }

            /*if(notify_on_beta || notify_on_release)
            {
                Thread t = new Thread(new ThreadStart(CheckForUpdates));
                t.IsBackground = true;
                t.Priority = ThreadPriority.Lowest;
                t.Name = "Update Check Thread";
                t.Start();
            }*/

            foreach(string s in CmdLineArgs)
            {
                if(s == "-autostart")
                    chkPower.Checked = true;
            }

            //			if((current_model == Model.FLEX5000) && !fwc_init)
            //				MessageBox.Show("Error opening FLEX-5000 driver.", "Driver Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            if(!fwc_init || current_model != Model.FLEX5000)
            {
                if(console_basis_size.Height > (this.Height - (grpRX2Filter.Height+16)))
                    console_basis_size.Height -= (grpRX2Filter.Height+16);
                this.MinimumSize = new Size(console_basis_size.Width, console_basis_size.Height);
                this.Height -= (grpRX2Filter.Height+16);
                if(chkRX2.Checked) chkRX2.Checked = false;
            }
            #if(DEBUG)
            button1.Visible = true;
            #endif
            #if (SWEEPGEN && !DEBUG)
            button1.Visible = true;
            #endif
            /*
            byte HSUSB_Data;

            HSUSB.InitI2C();

            HSUSB_Data = 0x55;
            HSUSB.SetI2CAddr(&HSUSB_Data);
            HSUSB_Data = 0x00;
            HSUSB.GetI2CAddr(&HSUSB_Data);

            HSUSB_Data = 0x01;
            HSUSB.WriteI2C(&HSUSB_Data);
            //			HSUSB_Data = 0x00;
            //			HSUSB.ReadI2C(&HSUSB_Data);

            HSUSB_Data = 0x00;
            HSUSB.GetRDY(&HSUSB_Data);

            HSUSB_Data = 0x00;
            HSUSB.SetCtrlLine(&HSUSB_Data);
            HSUSB_Data = 0xFF;
            HSUSB.GetCtrlLine(&HSUSB_Data);

            HSUSB_Data = 0x01;
            HSUSB.SetCtrlLine(&HSUSB_Data);
            HSUSB_Data = 0x00;
            HSUSB.GetCtrlLine(&HSUSB_Data);

            HSUSB_Data = 0x02;
            HSUSB.SetCtrlLine(&HSUSB_Data);
            HSUSB_Data = 0x00;
            HSUSB.GetCtrlLine(&HSUSB_Data);

            HSUSB_Data = 0x04;
            HSUSB.SetCtrlLine(&HSUSB_Data);
            HSUSB_Data = 0x00;
            HSUSB.GetCtrlLine(&HSUSB_Data);

            HSUSB_Data = 0xB0;
            HSUSB.SetPortA(&HSUSB_Data);
            HSUSB_Data = 0x00;
            HSUSB.GetPortA(&HSUSB_Data);

            HSUSB_Data = 0xC0;
            HSUSB.SetPortB(&HSUSB_Data);
            HSUSB_Data = 0x00;
            HSUSB.GetPortB(&HSUSB_Data);

            HSUSB_Data = 0xD0;
            HSUSB.SetPortD(&HSUSB_Data);
            HSUSB_Data = 0x00;
            HSUSB.GetPortD(&HSUSB_Data);
            */
            initializing = false;
        }