Ejemplo n.º 1
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     // validate form is setup correctly
     if (isMetaDataValid())
     {
         DialogResult = DialogResult.OK;
         try
         {
             TurnRelayOff();
         }
         catch (Exception inner)
         {
             string            errMsg = "Settings.btnClose_Click : Unable to turn relays off prior to testing.";
             SettingsException ex     = new SettingsException(errMsg, inner);
             log.Error(errMsg, ex);
             DisplayError(errMsg, ex);
         }
     }
     else
     {
         DialogResult = DialogResult.Retry;
         MessageBox.Show("Cannot begin testing until all fields are filled in and connection to relay controller is opened.", "Warning");
     }
     SaveMetaData();
     this.Close();
 }
Ejemplo n.º 2
0
 private void TurnRelayOn()
 {
     try
     {
         relayCtrl.SetRelay0Status(true);
         relayCtrl.SetRelay1Status(true);
     }
     catch (Exception inner)
     {
         string            errMsg = "Settings.TurnRelayOn : Unable to turn relays on, exception occured";
         SettingsException ex     = new SettingsException(errMsg, inner);
         log.Error(errMsg, ex);
         throw ex;
     }
 }
Ejemplo n.º 3
0
 private void btnTestRelayOn_Click(object sender, EventArgs e)
 {
     if (relayCtrl.IsOpen)
     {
         try
         {
             TurnRelayOn();
         }
         catch (Exception inner)
         {
             string            errMsg = "Settings.btnTestRelayOn_Click : Unable to turn relay on.";
             SettingsException ex     = new SettingsException(errMsg, inner);
             log.Error(errMsg, ex);
             DisplayError(errMsg, ex);
         }
     }
     else
     {
         string            errMsg = "Settings.btnTestRelayOn_Click : Relay controller connection is not opened.";
         SettingsException ex     = new SettingsException(errMsg);
         log.Error(errMsg, ex);
         DisplayError(errMsg, ex);
     }
 }
Ejemplo n.º 4
0
        private void btnOpenRelay_Click(object sender, EventArgs e)
        {
            int portNum;

            try
            {
                portNum = Convert.ToInt32(nudPortNum.Value);
            }
            catch (Exception inner)
            {
                string            errMsg = "Settings.btnOpenRelay_Click : Exception thrown converting nudPortNum.Value to integer.";
                SettingsException ex     = new SettingsException(errMsg, inner);
                log.Error(errMsg, ex);
                DisplayError(errMsg, ex);
                return;
            }

            try
            {
                relayCtrl.Open(portNum);
            }
            catch (Exception inner)
            {
                string            errMsg = "Settings.btnOpenRelay_Click : Error connecting to relay controller.";
                SettingsException ex     = new SettingsException(errMsg, inner);
                log.Error(errMsg, ex);
                DisplayError(errMsg, ex);
                return;
            }

            // turn USB relay off
            USBRelayController usb_relay = USBRelayController.Instance;

            usb_relay.SetRelay0Status(false);
            usb_relay.SetRelay1Status(false);
        }