예제 #1
0
        private async void Btn_startTrainer_Click(object sender, RoutedEventArgs e)
        {
            if (HasStarted)
            {
                TrainerCtrl.Stop();
                ((Button)sender).IsEnabled = false;
            }
            else
            {
                ((Button)sender).Content = "Stop";
                await StartAsync();

                ((Button)sender).Content = "Start";
            }
        }
예제 #2
0
        private async Task StartAsync()
        {
            var dataFileName      = Cmb_dataFileName.SelectedValue.ToString();
            var pDataFileName     = Cmb_processedDataFileName.SelectedValue.ToString();
            var modelFileName     = Txt_modelFileName.Text;
            var testPDataFileName = Cmb_testDataFileName.SelectedValue.ToString();

            if (string.IsNullOrWhiteSpace(dataFileName) || string.IsNullOrWhiteSpace(pDataFileName) ||
                string.IsNullOrWhiteSpace(modelFileName) || string.IsNullOrWhiteSpace(testPDataFileName))
            {
                throw new InvalidOperationException("Carefully select all the required values");
            }

            try
            {
                EnableControls(false);
                if (ModelFilesStorageCtrl.Exists(modelFileName))
                {
                    throw new InvalidOperationException("FAE");
                }
                if (!DataFilesStorageCtrl.Exists(dataFileName))
                {
                    throw new InvalidOperationException("DFDNE");
                }
                if (!DataFilesStorageCtrl.Exists(testPDataFileName))
                {
                    throw new InvalidOperationException("TDFDNE");
                }

                if (dataFileName == testPDataFileName)
                {
                    throw new InvalidOperationException("SameName");
                }

                TrainerCtrl.OnPhaseChangedEvent   += OnTrainerPhaseChanged;
                TrainerCtrl.OnPreprocessorChanged += OnPreprocessorChanged;

                await TrainerCtrl.Start(options =>
                {
                    options.DataFileName          = dataFileName;
                    options.ProcessedDataFileName = pDataFileName;
                    options.MLModelFileName       = modelFileName;
                    options.TestDataFileName      = testPDataFileName;
                });
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message == "FAE")
                {
                    MessageBox.Show(
                        "ML file already exists. Use a different name",
                        "File already exists",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else if (ex.Message == "DFDNE")
                {
                    MessageBox.Show(
                        "Data file does not exists",
                        "File not found",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else if (ex.Message == "TDFDNE")
                {
                    MessageBox.Show(
                        "Test data file does not exists",
                        "File not found",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else if (ex.Message == "SameName")
                {
                    MessageBox.Show(
                        "Data file and the test data file cannot have the same name",
                        "File not found",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else
                {
                    MessageBox.Show("Unexpected error occured", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unexpected error occured", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                EnableControls();
            }
        }