public void Tick()
 {
     if (m_dev.PortConnected)
     {
         m_dev.ProcessReceivedString(true, out m_receive_buf);
     }
 }
Ejemplo n.º 2
0
 private void btnConnectRFExplorer_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     if (comboBoxPortsRFExplorer.Items.Count > 0)
     {
         m_objRFE.ConnectPort(comboBoxPortsRFExplorer.SelectedValue.ToString(), Convert.ToInt32(comboBoxBaudrateRFExplorer.SelectedItem.ToString()));
         if (m_objRFE.PortConnected)
         {
             m_objRFE.SendCommand_RequestConfigData();
         }
         Thread.Sleep(2000);
         m_objRFE.ProcessReceivedString(true, out m_sRFEReceivedString);
     }
     UpdateButtonStatus();
     Cursor.Current = Cursors.Default;
 }
Ejemplo n.º 3
0
    public void DoConnect2()
    {
        String strPort;
        int    idx;

        idx = m_dropDownPort.value;

        strPort = m_dropDownPort.options[idx].text;

        m_objRFE = new RFECommunicator(true);
        m_objRFE.PortClosedEvent                += new EventHandler(OnRFE_PortClosed);
        m_objRFE.ReportInfoAddedEvent           += new EventHandler(OnRFE_ReportLog);
        m_objRFE.ReceivedConfigurationDataEvent += new EventHandler(OnRFE_ReceivedConfigData);
        m_objRFE.UpdateDataEvent                += new EventHandler(OnRFE_UpdateData);

        m_objRFE.ConnectPort(strPort, 500000);

        if (!m_objRFE.PortConnected)
        {
            return;
        }

        m_panelConnect.SetActive(false);

        m_objRFE.SendCommand_RequestConfigData();

        Thread.Sleep(500);


        // Set calc mode to "average"
        m_objRFE.SendCommand("C+\x02");

        if (DSP_MODE_FAST == m_iDSPMode)
        {
            // Set DSP mode to "fast"
            m_objRFE.SendCommand("Cp\x02");
        }
        else
        {
            // Set DSP mode to "filter"
            m_objRFE.SendCommand("Cp\x01");
        }


        m_iAdvanceCounter = m_iNumStepsToAdvance;

        String sRFEReceivedString;

        m_objRFE.ProcessReceivedString(true, out sRFEReceivedString);
    }
Ejemplo n.º 4
0
    public void ProcessData()
    {
        if (null == m_objRFE)
        {
            return;
        }

        if (!m_objRFE.PortConnected)
        {
            return;
        }

        if (m_bPause)
        {
            return;
        }

        String sRFEReceivedString;

        m_objRFE.ProcessReceivedString(true, out sRFEReceivedString);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// During this time process, user can write on the keyboard if it is active and it is checking keyboard.
        /// If there is any new setting, it will sending it to the device
        /// If bCountActive is active and g_nTotalFiles, number of files .csv created is equal to 0, then the function ends.
        /// </summary>
        /// <param name="nSeconds"></param>
        /// <param name="bCheckKeyboard"></param>
        /// <param name="bCountActive"> This means "/count:" is an argument. False by default </param>
        static void WaitAndProcess(int nSeconds, bool bCheckKeyboard = true, bool bCountActive = false)
        {
            bool bRunForever = false;

            if (nSeconds == -1)
            {
                bRunForever = true;
            }

            DateTime objTimeStart = DateTime.Now;

            do
            {
                string sDummy; //we do not use the string in this loop
                //Process all pending messages received from device
                g_objRFE.ProcessReceivedString(true, out sDummy);

                if (bCountActive && g_nTotalFiles == 0)
                {
                    break;
                }
                //check if user pressed any key
                if (bCheckKeyboard && Console.KeyAvailable)
                {
                    ConsoleKeyInfo cki = new ConsoleKeyInfo();
                    cki = Console.ReadKey(true);
                    bool   bChangeSettings = false;
                    double fStartMHz       = g_objRFE.StartFrequencyMHZ;
                    double fSpanMHZ        = g_objRFE.CalculateFrequencySpanMHZ();
                    switch (cki.Key)
                    {
                    case ConsoleKey.Escape:
                    case ConsoleKey.Q:
                        //finish function and therefore end up closing the application
                        Trace.WriteLine("<Q> - Closing the application...");
                        return;

                    case ConsoleKey.LeftArrow:
                        Trace.WriteLine("<LEFT> - Updating scan to lower frequency...");
                        Trace.WriteLine("Current configuration - Start:" + g_objRFE.StartFrequencyMHZ.ToString("f3") + "MHZ, Stop: " + g_objRFE.StopFrequencyMHZ.ToString("f3") + "MHz, Span:" + fSpanMHZ.ToString("f3"));
                        //Set new start frequency, keeping same span
                        fStartMHz = fStartMHz - fSpanMHZ;
                        //Check start frequency is in valid device range
                        if (fStartMHz < g_objRFE.MinFreqMHZ)
                        {
                            fStartMHz = g_objRFE.MinFreqMHZ;
                        }
                        bChangeSettings = true;
                        break;

                    case ConsoleKey.RightArrow:
                        Trace.WriteLine("<RIGHT> - Updating scan to higher frequency...");
                        Trace.WriteLine("Current configuration - Start:" + g_objRFE.StartFrequencyMHZ.ToString("f3") + "MHZ, Stop: " + g_objRFE.StopFrequencyMHZ.ToString("f3") + "MHz, Span:" + fSpanMHZ.ToString("f3"));
                        //Set new start frequency, keeping same span
                        fStartMHz = fStartMHz + fSpanMHZ;
                        //Check start frequency is in valid device range
                        if ((fStartMHz + fSpanMHZ) > g_objRFE.MaxFreqMHZ)
                        {
                            fStartMHz = g_objRFE.MaxFreqMHZ - fSpanMHZ;
                        }
                        bChangeSettings = true;
                        break;

                    default:
                        Trace.WriteLine("Ignored key.");
                        break;
                    }
                    if (bChangeSettings)
                    {
                        //Send new configuration
                        g_fStartMHZ = fStartMHz; //change flag value to recognize when new configuration is already in place
                        g_fStopMHZ  = fStartMHz + fSpanMHZ;
                        Trace.WriteLine("New configuration - Start:" + g_fStartMHZ.ToString("f3") + "MHZ, Stop: " + g_fStopMHZ.ToString("f3") + "MHz");
                        g_bIgnoreSweeps = true;
                        g_objRFE.UpdateDeviceConfig(fStartMHz, g_fStopMHZ, g_objRFE.AmplitudeTopDBM, g_objRFE.AmplitudeBottomDBM);
                    }
                }
            } while ((bRunForever || ((DateTime.Now - objTimeStart).TotalSeconds < nSeconds)));
            //save file before closing, if any.
            SaveRFEFile();
        }