public PumpInformationWindow(string title, bool canEditID, PumpInformation context)
 {
     InitializeComponent();
         this.Title = title;
         pumpIDbox.IsEnabled = canEditID;
         if (!canEditID)
             saveButton.IsEnabled = false;
         this.DataContext = context;
         plotter.Legend.HorizontalAlignment = HorizontalAlignment.Left;
         plotter.AddLineChart(context.DataSource).WithDescription("Response Curve").WithStroke(new SolidColorBrush(DesignColors.Blue)).WithStrokeThickness(2);
         context.LoadResponseCurve();
 }
Пример #2
0
 private void ScanPumpDirectory()
 {
     Dictionary<string, PumpInformation> newPumps = new Dictionary<string, PumpInformation>();
     foreach (string file in Directory.EnumerateFiles(pumpDirectory, "*.pump"))
     {
         PumpInformation pump = PumpInformation.LoadFromFile(file);
         if (pump != null)
         {
             pump.EditPumpCommand = new RelayCommand(async delegate
             {
                 PumpInformation newPump = new PumpInformation()
                 {
                     PumpID = pump.PumpID,
                     ResponseCurve = pump.ResponseCurve
                 };
                 PumpInformationWindow piw = new PumpInformationWindow("Edit Pump", false, newPump);
                 piw.Show();
                 await piw.WaitTask;
                 if (piw.Confirmed)
                 {
                     pump.SaveTo(pumpDirectory);
                 }
             });
             newPumps.Add(pump.PumpID, pump);
         }
     }
     Pumps = newPumps;
 }
Пример #3
0
        private async void PrepareResults()
        {
            switch (CalibrationTarget)
            {
                case CalibrationTarget.Pump:
                    PumpInformation newPump = new PumpInformation();
                    foreach (Subcalibration sub in Subcalibrations)
                    {
                        double[] resp = sub.AbsoluteChangePerHour;
                        newPump.ResponseCurve.Add(new PumpResponseData() { Setpoint = sub.Setpoint, Response = resp[0], Std = resp[1] });
                    }
                    PumpInformationWindow piw = new PumpInformationWindow("Save Pump Calibration", true, newPump);
                    piw.Show();
                    await piw.WaitTask;
                    if (piw.Confirmed)
                    {
                        System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
                        fbd.ShowDialog();
                        if (Directory.Exists(fbd.SelectedPath))
                        {
                            newPump.SaveTo(fbd.SelectedPath);
                        }
                    }
                    break;
                case CalibrationTarget.Stirrer:
                    System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
                    sfd.AddExtension = true;
                    sfd.Filter = "log files (*.log)|*.log";
                    sfd.ShowDialog();
                    if (!string.IsNullOrWhiteSpace(sfd.FileName))
                    {
                        try
                        {
                            var writer = File.CreateText(sfd.FileName);
                            writer.WriteLine("Setpoint   [n]\tResponse   [rpm]");
                            foreach (Subcalibration sub in Subcalibrations)
                                writer.WriteLine(string.Format("{0}\t{1}", sub.Setpoint, sub.IncrementalChangePerMinute));
                            writer.Flush();
                            writer.Dispose();
                        }
                        catch
                        {

                        }
                    }
                    break;
            }
        }