Beispiel #1
0
        internal SearchConnectUSB(SearchDevicesUSB RefPadre)
        {
            MS_WAIT_ACK      = 100;
            MS_WAIT_FIRMWARE = 100;

            m_StatusConnect          = StatusConnect.StopSearch;
            m_Timer_Search.Interval  = MS_WAIT_SEARCH;
            m_Timer_Search.AutoReset = false;
            m_Timer_Search.Enabled   = false;
            m_Timer_Search.Elapsed  += Timer_Search_Elapsed;
        }
        /// <summary>
        /// Start searching connected stations.
        /// </summary>
        /// <param name="searchMode">Select the connection type</param>
        /// <remarks></remarks>
        internal void StartSearch(SearchMode searchMode = default(SearchMode))
        {
            switch (searchMode)
            {
            case SearchMode.ALL:
                m_StationSearcherUSB = new SearchDevicesUSB();
                m_StationSearcherUSB.NewConnection += StationSearcherUSB_NewConnection;
                m_StationSearcherTCP = new CSearchDevicesTCP(null);
                m_StationSearcherTCP.NewConnection += StationSearcherTCP_NewConnection;
                break;

            case SearchMode.USB:
                m_StationSearcherUSB = new SearchDevicesUSB();
                m_StationSearcherUSB.NewConnection += StationSearcherUSB_NewConnection;
                break;

            case SearchMode.ETH:
                m_StationSearcherTCP = new CSearchDevicesTCP(null);
                m_StationSearcherTCP.NewConnection += StationSearcherTCP_NewConnection;
                break;
            }
        }
        /// <summary>
        /// Stop searching connected stations.
        /// </summary>
        /// <param name="searchMode">Select the connection type</param>
        /// <remarks></remarks>
        internal void StopSearch(SearchMode searchMode)
        {
            switch (searchMode)
            {
            case SearchMode.ALL:
                if (m_StationSearcherUSB != null)
                {
                    m_StationSearcherUSB.Eraser();
                    m_StationSearcherUSB.NewConnection -= StationSearcherUSB_NewConnection;
                    m_StationSearcherUSB = null;
                }
                if (m_StationSearcherTCP != null)
                {
                    m_StationSearcherTCP.Dispose();
                    m_StationSearcherTCP.NewConnection -= StationSearcherTCP_NewConnection;
                    m_StationSearcherTCP = null;
                }
                break;

            case SearchMode.USB:
                if (m_StationSearcherUSB != null)
                {
                    m_StationSearcherUSB.Eraser();
                    m_StationSearcherUSB.NewConnection -= StationSearcherUSB_NewConnection;
                    m_StationSearcherUSB = null;
                }
                break;

            case SearchMode.ETH:
                if (m_StationSearcherTCP != null)
                {
                    m_StationSearcherTCP.Dispose();
                    m_StationSearcherTCP.NewConnection -= StationSearcherTCP_NewConnection;
                    m_StationSearcherTCP = null;
                }
                break;
            }
        }