Пример #1
0
 //TODO: in Visual Studio go to View/Task List and then select "Comments" - this shows a list of all comments starting with TODO - like this one for example
 //TODO: suggestions what to build:
 //TODO: first implement a simple "message composer". Imaging dropdown-menus to select the ParticipantIDs and MessageType of the first three bytes and then a textbox where you can enter the rest of the message (using ~ as a placeholder for \t and then string.Replace('~', '\t') before sending the message
 //      this first component is useful for Sayantan to test the software on the Arduino
 //TODO: next implement to receive data/readings from the scale
 //TODO: then implement automatic calibration stuff...
 public ViewModel()
 {
     SetSteppingSpeed = new RelayCommand(delegate
     {
         PrimarySerial.SendString(string.Format("STEPS_PER_MINUTE\t{0}", StepsPerMinute));
     });
 }
Пример #2
0
 public ViewModel()
 {
     PrimarySerial.NewMessageReceived += PrimarySerial_NewMessageReceived;
     SendMessageCommand = new RelayCommand(delegate
     {
         SendMessage();
     });
 }
Пример #3
0
 public SerialIO()
 {
     Current = this;
     _SendTimer.Elapsed += _SendTimer_Elapsed;
     //ports
     CommandRefreshPorts = new RelayCommand(delegate
     {
         var ports = SerialPort.GetPortNames().ToList();
         PortNames = ports.ToArray();
         SelectedPort = 0;
     });
     CommandRefreshPorts.Execute(null);
 }
Пример #4
0
 public Experiment()
 {
     saveTimer.Tick += delegate
     {
         Save();
     };
     DeleteExperimentCommand = new RelayCommand(async delegate
     {
         bool delete = (await CustomMessageBox.ShowAsync("Deleting an Experiment", string.Format("Do you want to delete {0} ?", DisplayName), System.Windows.MessageBoxImage.Warning, 0, "Keep the experiment", string.Format("Delete {0}", this.Title)) == 1);
         if (delete)
             try
             {
                 Directory.Delete(BaseDirectory, true);
             }
             catch { }
     });
 }
Пример #5
0
 public MCPSettings()
 {
     ChangeHomeDirectoryCommand = new RelayCommand(delegate
     {
         string previousPath = HomeDirectoryPath;
         FolderBrowserDialog fbd = new FolderBrowserDialog() { Description = "Select Home Directory" };
         if (!string.IsNullOrWhiteSpace(previousPath))
             fbd.SelectedPath = previousPath;
         else
             fbd.RootFolder = Environment.SpecialFolder.MyComputer;
         fbd.ShowDialog();
         if (fbd.SelectedPath != previousPath)
         {
             if (fbd.SelectedPath.EndsWith("MCP"))
                 HomeDirectoryPath = fbd.SelectedPath;
             else
                 HomeDirectoryPath = Path.Combine(fbd.SelectedPath, "MCP");
         }
     });
     BrowseHomeDirectoryCommand = new RelayCommand(delegate
     {
         try
         {
             System.Diagnostics.Process.Start(HomeDirectoryPath);
         }
         catch { }
     });
     //
     DispatcherTimer dt = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(20) };
     dt.Tick += async delegate
     {
         dt.Stop();
         if (string.IsNullOrWhiteSpace(HomeDirectoryPath))
         {
             int sel = await CustomMessageBox.ShowAsync("Setup", "Welcome to the MCP!\r\n\r\nBefore you can start you must set a home directory where files will be saved.\r\n\r\nYou may set or change the home directory under \"Settings\".", System.Windows.MessageBoxImage.Information, 0, "Select Home Directory", "Okay");
             if (sel == 0)
                 ChangeHomeDirectoryCommand.Execute(null);
         }
         else
             InitializeHomeDirectory();
     };
     dt.Start();
 }
Пример #6
0
 public ExperimentLibrary()
 {
     AddExperimentCommand = new RelayCommand(async delegate
     {
         Experiment exp = new Experiment();
         ExperimentInformationWindow eiw = new ExperimentInformationWindow("Create Experimet", true) { DataContext = exp };
         List<ParticipantID> selectedReactors = await eiw.ShowAsync();
         if (eiw.Confirmed)
         {
             foreach (ParticipantID selectedReactor in selectedReactors)
                 Directory.CreateDirectory(Path.Combine(experimentsDirectory, exp.DisplayName, selectedReactor.ToString()));
             exp.BaseDirectory = Path.Combine(experimentsDirectory, exp.DisplayName);//this authorizes the experiment to be saved or save itself (when a property changes)
             exp.Save();
         }
     });
     scanTimer.Tick += delegate 
     {
         scanTimer.Stop();
         ScanExperimentsDirectory();
     };
 }
Пример #7
0
        public Calibrator()
        {
            FinalizeCommand = new RelayCommand(delegate
            {
                var si = PrepareResults();
                ShowResults(si);
            });
            CopyCommand = new RelayCommand(delegate
            {
                var si = PrepareResults();
                // now copy the response points 
                var outputTabbed = "Raw\tsRaw\tOD\r\n";
                foreach (BiomassResponseData rd in si.ResponseCurve)
	            {
		            outputTabbed += string.Format("{0}\t{1}\t{2}\r\n", rd.Analog, rd.AnalogStd, rd.OD);
                }                    
                outputTabbed = outputTabbed.TrimEnd('\n', '\r');
                try
                {
                    System.Windows.Clipboard.SetDataObject(outputTabbed, true);
                }
                catch (Exception ex)
                {
                    Task t = CustomMessageBox.ShowAsync("Error", "Export to Clipboard failed.\n\nPlease try again.", MessageBoxImage.Warning, 0, "Ok");
                }
            });
            OpenFileCommand = new RelayCommand(delegate
            {
                LoadCalibrationFile();
            });
            progressTimer.Tick += delegate
            {
                foreach (Subcalibration sub in Subcalibrations)
                    sub.Tick();
            };
            progressTimer.Start();
            //Initialize
            UpdateNumberOfSubcalibrations();
        }
Пример #8
0
 public Transformer()
 {
     OpenFileCommand = new RelayCommand(delegate
     {
         LoadCalibrationFile();
         //TODO: load calibration file implementieren
         //      response curve regression aus der datei laden
         //      file info text anzeigen
         //      laden von log-dateien implementieren
         //      transformation implementieren
         //      speichern implementieren
     });
     LoadRawFileCommand = new RelayCommand(delegate
         {
             LoadLogFile(RawDataPoints);
             TransformToODCommand.RaiseCanExecuteChanged();
             OnPropertyChanged("InfoRaw");
         });
      TransformToODCommand = new RelayCommand(delegate
         {
             SimulatePostprocessing();
         }, new Func<bool>(() => BiomassSensorInfo != null && RawDataPoints.Count > 0));
 }
Пример #9
0
 public Subcalibration(GasSensorResponseData sensorRD, string symbol, string unit)
 {
     this.ResponsePoint = sensorRD;
     this.Symbol = symbol;
     this.Unit = unit;
     CaptureCommand = new RelayCommand(delegate
     {
         OnRequestCaptureEvent(this, new EventArgs());
     }, () => State != SubcalibrationState.Running);
     AbortCommand = new RelayCommand(delegate
     {
         SensorDataSet.Clear();
         if (!finishTask.IsCompleted)
             finishTask.Start();
     }, () => State == SubcalibrationState.Running);
 }
Пример #10
0
		//TODO: commands to delete pumps or reactors
			
        #endregion


        public Inventory()
        {
            Current = this;
            ImportPumpCommand = new RelayCommand(delegate
            {
                OpenFileDialog ofd = new OpenFileDialog() { Filter = "Pump Calibration Files|*.pump" };
                DialogResult result = ofd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    FileInfo fi = new FileInfo(ofd.FileName);
                    try
                    {
                        File.Copy(ofd.FileName, Path.Combine(pumpDirectory, fi.Name));
                    }
                    catch (Exception ex)
                    {
                        Task mb = CustomMessageBox.ShowAsync("Can't import", "There was an error:\r\n\r\n" + ex.Message, System.Windows.MessageBoxImage.Error, 0, "Ok");
                    }
                }
            });
            ImportSensorCommand = new RelayCommand(delegate
            {
                OpenFileDialog ofd = new OpenFileDialog() { Filter = "Sensor Calibration Files|*.biomass;*.sensor" };
                DialogResult result = ofd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    FileInfo fi = new FileInfo(ofd.FileName);
                    try
                    {
                        File.Copy(ofd.FileName, Path.Combine(sensorDirectory, fi.Name));
                    }
                    catch (Exception ex)
                    {
                        Task mb = CustomMessageBox.ShowAsync("Can't import", "There was an error:\r\n\r\n" + ex.Message, System.Windows.MessageBoxImage.Error, 0, "Ok");
                    }
                }
            });
            AddReactorCommand = new RelayCommand(async delegate
            {
                ReactorInformation newReactor = new ReactorInformation();
                ReactorInformationWindow piw = new ReactorInformationWindow("Add New Reactor", true, Pumps.Values, BiomassSensors.Values, GasSensors.Values) { DataContext = newReactor };
                piw.Show();
                await piw.WaitTask;
                if (piw.Confirmed)
                {
                    newReactor.SaveTo(reactorDirectory);
                }
            });
            ImportReactorCommand = new RelayCommand(delegate
            {
                OpenFileDialog ofd = new OpenFileDialog() { Filter = "Reactor Files|*.reactor" };
                DialogResult result = ofd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    FileInfo fi = new FileInfo(ofd.FileName);
                    try
                    {
                        File.Copy(ofd.FileName, Path.Combine(reactorDirectory, fi.Name));
                    }
                    catch (Exception ex)
                    {
                        Task mb = CustomMessageBox.ShowAsync("Can't import", "There was an error:\r\n\r\n" + ex.Message, System.Windows.MessageBoxImage.Error, 0, "Ok");
                    }
                }
            });
        }
Пример #11
0
 public Calibrator()
 {
     StartOverCommand = new RelayCommand(delegate
     {
         Subcalibrations.Clear();
         foreach (GasSensorResponseData gsrd in CalibrationProfiles.Profiles[CalibrationTarget][CalibrationMode])
             Subcalibrations.Add(new Subcalibration(gsrd, CalibrationProfiles.Symbols[CalibrationTarget], CalibrationProfiles.Units[CalibrationTarget]) { Target = CalibrationTarget });
         foreach (Subcalibration sub in Subcalibrations)
         {
             sub.RequestCapture += sub_RequestCapture;
             sub.CaptureEnded += sub_CaptureEnded;
         }
     }, () => ActiveCalibrationSub == null);
     FinalizeCommand = new RelayCommand(delegate
     {
         PrepareResults();
     });
     OpenFileCommand = new RelayCommand(delegate
     {
         LoadCalibrationFile();
     });
     progressTimer.Tick += delegate
     {
         foreach (Subcalibration sub in Subcalibrations)
             sub.Tick();
     };
     progressTimer.Start();
     //Initialize
     StartOverCommand.Execute(null);
 }
Пример #12
0
 public Calibrator()
 {
     StartCalibrationCommand = new RelayCommand(async delegate
         {
             SpeechIO.Speak(string.Format("Starting {0} calibration.", CalibrationMode));
             Subcalibrations.Clear();
             foreach (int[] pair in CalibrationProfiles.Profiles[CalibrationTarget][CalibrationMode])
                 Subcalibrations.Add(new Subcalibration(pair[0], pair[1], CalibrationProfiles.Symbols[CalibrationTarget], CalibrationProfiles.Units[CalibrationTarget]) { Target = CalibrationTarget });
             foreach (Subcalibration sub in Subcalibrations)
             {
                 ActiveCalibrationSub = sub;
                 if (!await sub.RunAsync())
                 {
                     SpeechIO.Speak("Calibration cancelled.");
                     ActiveCalibrationSub = null;
                     return;
                 }    
             }
             ActiveCalibrationSub = null;
             SpeechIO.Speak("Calibration finished.");
             PrepareResults();
         }, () => ActiveCalibrationSub == null);
     AbortCalibrationCommand = new RelayCommand(delegate
         {
             foreach (Subcalibration sub in Subcalibrations)
                 sub.Abort();
         }, () => ActiveCalibrationSub != null);
     progressTimer.Tick += delegate
     {
         OnPropertyChanged("ProgressPercent");
         OnPropertyChanged("RemainingCalibrationTime");
     };
     progressTimer.Start();
 }