The Reset button: reset an alarm

An axis might run into a problem and an error occurs. When this happens, the axis stops and an alarm is triggered. The method of this button is BtnReset_Click (MainWindow.xaml.cs). When Reset is clicked, we call the ResetAxis method (MainWindowViewModel.cs).

private async void BtnReset_Click(object sender, RoutedEventArgs e)
{
   try
   {
      await ViewModel.ResetAxis();
   }
   catch (Exception ex)
   {
      MessageBox.Show(ex.ToString());
   }
}

 

To reset the alarm, use IAxis.Reset. Because an axis needs some time to be reset, we give IAxis.Reset 5,000 milliseconds to finish its job. If it is not done within the time span, the task will be cancelled.

public async Task ResetAxis()
{
   //Reset errors.
   await SelectedAxis.Reset().WaitAsync(5000, true);
}