private static void CommandMotor(Object source, ElapsedEventArgs e) { if (IsConnected()) { SerialPortControl._WriteData((int)motor_com, COMMAND_MOTOR); SerialPortControl._WriteData((int)motor_com, COMMAND_MOTOR_CONFIRM); } }
private void SpeedRadioButton_Checked(object sender, RoutedEventArgs e) { if (!IsConnected()) { return; } CommandStart(); SerialPortControl._WriteData(2, COMMAND_MODE); }
private void Dslider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (String.IsNullOrEmpty(e.NewValue.ToString())) { return; } else { d_slider_value = Convert.ToDouble(e.NewValue.ToString()); D_SliderTextBlock.Text = (d_slider_value / 1000).ToString(); SerialPortControl._WriteData((int)d_slider_value, PARAMETER_D); } }
private void SimRadioButton_Checked(object sender, RoutedEventArgs e) { if (slider_control) { _timer.Stop(); _timer.Dispose(); slider_control = false; } if (!IsConnected()) { return; } SetTimer(tick_send_command, WriteStart); SerialPortControl._WriteData(2, COMMAND_MODE); }
private void StopRadioButton_Checked(object sender, RoutedEventArgs e) { if (sim_control | slider_control) { _timer.Stop(); _timer.Dispose(); sim_control = false; slider_control = false; } if (!IsConnected()) { return; } MotorSimlator.StopSimulation(); SerialPortControl._WriteData(1, COMMAND_STOP); }
private void SliderSendStart(Object source, ElapsedEventArgs e) { if (IsConnected()) { if (SerialPortControl.Register[START_REPLY] == 0) { Console.WriteLine("wait"); SerialPortControl._WriteData(123, COMMAND_START); } else { SerialPortControl.Register[START_REPLY] = 0; _timer.Stop(); _timer.Dispose(); SetTimer(tick_send_command, SliderControl); } } }
private void LEDButton_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.Button b = (sender as System.Windows.Controls.Button); if (!IsConnected()) { return; } if (b.Content.ToString() == "OFF") { SerialPortControl._WriteData(0, COMMAND_LED); b.Content = "ON"; } else { SerialPortControl._WriteData(1, COMMAND_LED); b.Content = "OFF"; } }
private void WriteStart(Object source, ElapsedEventArgs e) { if (IsConnected()) { if (SerialPortControl.Register[START_REPLY] == 0) { Console.WriteLine("wait"); SerialPortControl._WriteData(123, COMMAND_START); } else { SerialPortControl.Register[START_REPLY] = 0; _timer.Stop(); _timer.Dispose(); //MotorSimlator.StartFlapping(); MotorSimlator.StartSimulation(); } } }
private void SliderControl(Object source, ElapsedEventArgs e) { motor_com = (int)motor_slider_value; SerialPortControl._WriteData((int)(motor_slider_value), COMMAND_MOTOR); SerialPortControl._WriteData((int)(motor_slider_value), COMMAND_MOTOR_CONFIRM); }
private void ParameterApplyButton_Click(object sender, RoutedEventArgs e) { SerialPortControl._WriteData((int)p_slider_value, PARAMETER_P); SerialPortControl._WriteData((int)i_slider_value, PARAMETER_I); SerialPortControl._WriteData((int)d_slider_value, PARAMETER_D); }