public async void SaveTestBench()
        {
            //NeedsScreenshot = false;
            await TestBench.SaveAsync();

            NeedsScreenshot = true;
        }
        private async void Compute()
        {
            Computing = true;
            await TestBench.ComputeIfNeededAsync(default(CancellationToken));

            if (TestBench.Structure.IsValid)
            {
                SetAllQuickValues();
            }
            Computing = false;
        }
        //public StructureSceneViewModel Scene { get; set; }

        public TestBenchViewModel(TestBench testBench)
        {
            TestBench = testBench;

            StructureParameterList = new StructureParameterListViewModel(TestBench);
            //Scene = new StructureSceneViewModel(TestBench);

            //BiasSliderMaxValue = TestBench.MaxVoltage.Volts;
            //BiasSliderMinValue = testBench.MinVoltage.Volts;

            TitleText = TestBench.Name;
            Compute();
        }
        public void UpdateSettings(string minVoltageText, string maxVoltageText, string stepSizeText)
        {
            double minVoltage;
            double maxVoltage;
            double stepSize;

            if (double.TryParse(minVoltageText, out minVoltage) &&
                double.TryParse(maxVoltageText, out maxVoltage) &&
                double.TryParse(stepSizeText, out stepSize))
            {
                TestBench.SetRange(new ElectricPotential(minVoltage), new ElectricPotential(maxVoltage),
                                   new ElectricPotential(stepSize));
            }
        }
        private async void TestBench_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "Name":
                TitleText = TestBench.Name;
                SaveTestBench();
                break;

            case "NeedsCompute":
                if (TestBench.NeedsCompute)
                {
                    if (tokenSource != null)
                    {
                        tokenSource.Cancel();
                    }

                    tokenSource = new CancellationTokenSource();
                    Computing   = true;
                    await TestBench.ComputeIfNeededAsync(tokenSource.Token);

                    if (tokenSource.IsCancellationRequested)
                    {
                        return;
                    }

                    SetAllQuickValues();
                    SaveTestBench();
                    Computing = false;
                }
                break;

            case "NoSolution":
                NoSolution = TestBench.NoSolution;
                break;

            case "Steps":
                UpdatePlot();
                break;

            case "CurrentIndex":
                CstackText = TestBench.CurrentStructure
                             .StackCapacitance.MicroFaradsPerSquareCentimeterToString("{0:F3} μF/cm\xB2");
                break;
            }
        }
        private void UpdatePlot()
        {
            if (TestBench.Steps.Count == 0)
            {
                return;
            }

            var animationAxis = new PlotAxis
            {
                Max       = TestBench.MaxVoltage.Volts,
                Min       = TestBench.MinVoltage.Volts,
                MajorSpan = TestBench.StepSize.Volts,
                Title     = "Bias (V)"
            };

            PlotGroup = new PlotAnimationGrouping(animationAxis,
                                                  d => CreatePlot(TestBench.GetStep(new ElectricPotential(d))));

            NeedsScreenshot = true;
        }
示例#7
0
        public StructureParameterListViewModel(TestBench testBench)
        {
            Parameters = new List <StructureParameterItemViewModel>();

            TestBench = testBench;
        }
 public void SetSelectedBias(double bias)
 {
     // Set the current voltage to the snapped voltage.
     TestBench.SetBias(new ElectricPotential(bias));
 }