/// <summary> /// /// </summary> /// <param name="mainForm"></param> /// <param name="fileDirectory"></param> /// <param name="belt"></param> public TempSpatForm(MainForm mainForm, string fileDirectory, HapticBelt belt) { InitializeComponent(); wirelessBelt = belt; this._fileDirectory = fileDirectory; patternPlayback = new List<PatternElement>(2); // start with 2 element and grow try { error_t response = wirelessBelt.Query_All(); if (response != error_t.ESUCCESS) MessageBox.Show(wirelessBelt.getErrorMsg(response)); else { // brackets reqd for casting int array to string array String[] motor = { wirelessBelt.getMotors(QueryType.PREVIOUS).ToString() }; String[] rhythm = wirelessBelt.getRhythm(false, QueryType.PREVIOUS); String[] magnitude = wirelessBelt.getMagnitude(false, QueryType.PREVIOUS); // Reset Combo Boxes mainForm.ResetAllComboBoxes(); // Add to TempSpatForm mainForm.AddToComboBox(MainForm.dataTypes.MTR, motor, comboBoxMotor); mainForm.AddToComboBox(MainForm.dataTypes.RHY, rhythm, comboBoxRhy); mainForm.AddToComboBox(MainForm.dataTypes.MAG, magnitude, comboBoxMag); comboBoxCycles.Items.Add("1"); comboBoxCycles.Items.Add("2"); comboBoxCycles.Items.Add("3"); comboBoxCycles.Items.Add("4"); comboBoxCycles.Items.Add("5"); comboBoxCycles.Items.Add("6"); comboBoxCycles.Items.Add("Run"); comboBoxTempo.Items.Add("5"); // Fastest Tempo (div by 1.5) comboBoxTempo.Items.Add("4"); // Faster Tempo (div by 1.25) comboBoxTempo.Items.Add("3"); // Default as entered by user comboBoxTempo.Items.Add("2"); // Slower Tempo (multiply by 1.25) comboBoxTempo.Items.Add("1"); // Slowest Tempo (multiply by 1.5) comboBoxRhy.SelectedIndex = 0; comboBoxMag.SelectedIndex = 0; comboBoxCycles.SelectedIndex = 0; comboBoxTempo.SelectedIndex = 2; //midline for default tempo } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
/// <summary> /// /// </summary> /// <param name="inbound"></param> /// <param name="outbound"></param> /// <param name="readTimeout"></param> /// <param name="fileDirectory"></param> /// <param name="belt"></param> public SettingsForm(string inbound, string outbound, int readTimeout, string fileDirectory, HapticBelt belt) { InitializeComponent(); // Setup ports inboundPort = inbound; outboundPort = outbound; textBoxTimeout.Text = readTimeout.ToString(); textBoxFileDirectory.Text = fileDirectory; string[] ports = belt.GetSerialPortNames();//SerialPort.GetPortNames(); // ComboBox 1 = inbound ports comboBoxInbound.Items.Add("NO PORT SELECTED"); for (int i = 0; i < ports.Length; i++) { comboBoxInbound.Items.Add(ports[i]); } // ComboBox 2 = outbound ports comboBoxOutbound.Items.Add("NO PORT SELECTED"); for (int i = 0; i < ports.Length; i++) { comboBoxOutbound.Items.Add(ports[i]); } // Selection of port names if (comboBoxInbound.Items.Contains(inboundPort)) comboBoxInbound.SelectedItem = inboundPort; else comboBoxInbound.SelectedIndex = 0; if (comboBoxOutbound.Items.Contains(outboundPort)) comboBoxOutbound.SelectedItem = outboundPort; else comboBoxOutbound.SelectedIndex = 0; // TODO future work Setup other Serial port settings such as Parity, Stop bits ,etc. // CONVERT TO FOR LOOP (foreach is not efficient on embedded processor) //foreach (string str in Enum.GetNames(typeof(StopBits))) //{ // ((ComboBox)obj).Items.Add(str); //} // CONVERT TO FOR LOOP (foreach is not efficient on embedded processor) //foreach (string str in Enum.GetNames(typeof(Parity))) //{ // ((ComboBox)obj).Items.Add(str); //} }
HapticBelt wirelessBelt; // = new HapticBelt(); #endregion Fields #region Constructors /// <summary> /// /// </summary> public MainForm() { InitializeComponent(); labelStatusMsg.Text = "Ports not set."; comboBoxCycles.Items.Add("1"); comboBoxCycles.Items.Add("2"); comboBoxCycles.Items.Add("3"); comboBoxCycles.Items.Add("4"); comboBoxCycles.Items.Add("5"); comboBoxCycles.Items.Add("6"); comboBoxCycles.Items.Add("Run"); wirelessBelt = new HapticBelt(); magnitude_table = new string[HapticBelt.MAG_MAX_NO]; // Subscribe event handler to the function ReceiveData( ) // This works like a C++ function pointer wirelessBelt.DataReceivedFxn = this.UpdateTxtLog; }
/// <summary> /// /// </summary> /// <param name="belt"></param> public PatternProgForm(HapticBelt belt) { InitializeComponent(); wirelessBelt = belt; txtLogProg.Enabled = true; // Display current belt information try { error_t response = wirelessBelt.Query_All(); if (wirelessBelt.getDataRecvType() == (byte)HapticDriver.MessageType.INCOMING) { string line = wirelessBelt.getDataRecvBuffer(); UpdateTxtLog(line); } } catch (Exception ex) { MessageBox.Show(ex.Message); } //comboBoxMagSel.Items.Add(" "); comboBoxMagSel.SelectedIndex = 0; comboBoxRhySel.SelectedIndex = 0; }
public Mediator(string port1, string port2) { wirelessBelt = new HapticBelt(); inPort = port1; outPort = port2; }