Ejemplo n.º 1
0
 /// <summary>
 /// Attempts to connect to a Tctec Device then to a FTDI device if unable to find a Tctec device
 /// </summary>
 /// <returns></returns>
 private bool InitializeRelayDevice()
 {
     // Attempt to connect to a Tctec Device
     relayDevice = InitializeTctecDevice();
     if (relayDevice == null)
     {
         // If unable to connect to Tctec, try connecting as FTDI device
         relayDevice = InitializeFTDIDevice();
         if (relayDevice == null)
         {
             MessageBox.Show("Unable to locate a relay device. Please reconnect and try again.");
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Disconnects the current device and attempts to reconnect
        /// </summary>
        private void RefreshDevice()
        {
            if (relayDevice != null)
            {
                // Stop checking for schedules to prevent attempts to set a relay while refreshing
                relayDevice.StopScheduleTimer();
                relayDevice.Close();
                relayDevice = null;
            }

            // Attempt to initialize the relays again
            if (InitializeRelayDevice())
            {
                textBoxDeviceAddress.Text = relayDevice.GetSerialNumber();
                relayDevice.StartScheduleTimer();
            }
        }