示例#1
0
 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);
     }
 }
示例#2
0
 private void SpeedRadioButton_Checked(object sender, RoutedEventArgs e)
 {
     if (!IsConnected())
     {
         return;
     }
     CommandStart();
     SerialPortControl._WriteData(2, COMMAND_MODE);
 }
示例#3
0
 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);
     }
 }
示例#4
0
 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);
 }
示例#5
0
 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);
 }
示例#6
0
 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);
         }
     }
 }
示例#7
0
 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";
     }
 }
示例#8
0
 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();
         }
     }
 }
示例#9
0
 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);
 }
示例#10
0
 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);
 }