示例#1
0
        public Calibrate(BoardTypes boardtype, RelayControler relay_controller, TelnetConnection telnet_connection, MultiMeter meter)
        {
            BoardType = boardtype;

            _relay_ctrl = relay_controller;
            _telnet_connection = telnet_connection;
            _meter = meter;
        }
示例#2
0
 /// <summary>
 /// Handles relay controller event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="relay_controller"></param>
 void calibration_Relay_Event(object sender, RelayControler relay_controller)
 {
     relaysShowSetttings();
 }
示例#3
0
 /// <summary>
 /// Invokes the settings dialog
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void toolStripMenuItem_Settings(object sender, EventArgs e)
 {
     Form_Settings dlg = new Form_Settings();
     DialogResult rc = dlg.ShowDialog();
     if (rc == DialogResult.OK)
     {
         // DIO controller type
         Properties.Settings.Default.Relay_Controller_Type = dlg.comboBox_DIOCtrollerTypes.Text;
         RelayControler.Device_Types rdevtype = (RelayControler.Device_Types)Enum.Parse(typeof(RelayControler.Device_Types),
             Properties.Settings.Default.Relay_Controller_Type);
         _relay_ctrl = new RelayControler(rdevtype);
     }
     else
     {
         Properties.Settings.Default.Reload();
     }
 }
示例#4
0
        /// <summary>
        /// Invokes the FTDI test dialog.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void toolStripMenuItem_FT232H(object sender, EventArgs e)
        {
            if (_relay_ctrl == null || _relay_ctrl.Device_Type != RelayControler.Device_Types.FT232H)
            {
                RelayControler.Device_Types rdevtype = (RelayControler.Device_Types)Enum.Parse(
                    typeof(RelayControler.Device_Types), Properties.Settings.Default.Relay_Controller_Type);
                _relay_ctrl = new RelayControler(rdevtype);
            }

            try
            {
                _relay_ctrl.OpenIfClosed();
                Form_FT232H_DIO_Test dlg = new Form_FT232H_DIO_Test(_relay_ctrl);
                dlg.ShowDialog();
            }
            catch
            {
                throw;
            }
            finally
            {
                _relay_ctrl.Close();
            }
        }
示例#5
0
        /// <summary>
        /// Initializes the relay controller
        /// </summary>
        void initRelayController()
        {
            string msg;
            RelayControler.Device_Types rdevtype = (RelayControler.Device_Types)Enum.Parse(
                typeof(RelayControler.Device_Types), Properties.Settings.Default.Relay_Controller_Type);
            try
            {
                _relay_ctrl = new RelayControler(rdevtype);

                // In this version we are adding a new lines for Honeycomb
                // So lets refresh the file as to not to have conflicts with older versions
                // Should not cause any problems unless someone rewired the relay controller
                _relay_ctrl.ClearDictionaries();
                _relay_ctrl.RecreateSettingsFile();

                _relay_ctrl.Open();
                initRelayController_Lines();
                msg = string.Format("Relay controller \"{0}:{1}\" ready.", rdevtype, _relay_ctrl.SerialNumber);
                updateOutputStatus(msg);
            }
            catch (Exception ex)
            {
                msg = string.Format("{0}\r\nTry unplugging and re-plugging the USB device.\r\nThen try to change relay controller in settings dialog", ex.Message);
                showDialogMsg(msg);

                msg = string.Format("Unable to init relay controller \"{0}\".  Switching to Manual relay mode", rdevtype);
                updateOutputStatus(msg);

                _relay_ctrl = new RelayControler(RelayControler.Device_Types.Manual);
                initRelayController_Lines();
                Properties.Settings.Default.Relay_Controller_Type = _relay_ctrl.Device_Type.ToString();
                Properties.Settings.Default.Save();

                Form_Settings dlg = new Form_Settings();
                dlg.TabControl.SelectedTab = dlg.TabControl.TabPages["tabPageDIO"];
                DialogResult rc = dlg.ShowDialog();
                if (rc == DialogResult.OK)
                {
                    // DIO controller type
                    Properties.Settings.Default.Relay_Controller_Type = dlg.comboBox_DIOCtrollerTypes.Text;
                    rdevtype = (RelayControler.Device_Types)Enum.Parse(typeof(RelayControler.Device_Types),
                        Properties.Settings.Default.Relay_Controller_Type);
                    _relay_ctrl = new RelayControler(rdevtype);
                }
                else
                {
                    Properties.Settings.Default.Reload();
                }

            }
            //_relay_ctrl.WriteAll(false);
            _relay_ctrl.Close();
        }