private void playAnimation() { double spf; int counterInterval = 1; animationCounter = 0; int snapShotCount = SnapshotsToAnimate.Count(); if (FPSAnimation <= FPSMax) { spf = 1 / FPSAnimation; } else { spf = (double)1 / FPSMax; counterInterval = Convert.ToInt32(FPSAnimation / FPSMax); } while (animationCounter < snapShotCount && !AnimationStopped) { stopwatch.Restart(); while (animationCounter < snapShotCount) { if (AnimationPaused) { stopwatch.Stop(); } if (AnimationResumed) { stopwatch.Start(); AnimationResumed = false; } if (AnimationStopped) { stopwatch.Stop(); break; } if (stopwatch.Elapsed.TotalSeconds > spf) { SnapshotSelected = SnapshotsToAnimate.ElementAt(animationCounter); animationCounter += counterInterval; break; } } } }
public ShellViewModel() { string inputDir = @"C:\CSSLWaferFab\Input\"; string outputDir = @"C:\CSSLWaferFab\Output\WaferFabGUI"; string eptParameterFile = @"FittedEPTParameters - 2019-6-1.csv"; WaferFabSim = new ShellModel(outputDir); WaferFabSim.ReadSimulationResults(); WaferFabSim.PropertyChanged += ShellModel_PropertyChanged; // Link relay commands RunSimulationCommand = new RelayCommand(RunSimulationAsync, () => true); ClearAllWIPDataCommand = new RelayCommand(ClearAllWIPPlots, () => CanClearWIPData); ClearLastWIPDataCommand = new RelayCommand(ClearLastWIPPlot, () => CanClearWIPData); PlayAnimationCommand = new RelayCommand(PlayAnimationAsync, () => (SnapshotsToAnimate != null && SnapshotsToAnimate.Any() && !isAnimationRunning) || AnimationPaused); PauseAnimationCommand = new RelayCommand(PauseAnimation, () => isAnimationRunning && !AnimationPaused); StopAnimationCommand = new RelayCommand(StopAnimation, () => isAnimationRunning); LoadRealSnapshotsCommand = new RelayCommand(LoadRealSnapshotsAsync, () => true); // Initialize properties DispatcherTypes = new ObservableCollection <string>() { "BQF", "EPTOvertaking", "Random", "MIVS" }; SelectedDispatcherType = DispatcherTypes.Last(); WorkCenters = new ObservableCollection <WorkCenterData>(); LotStartQtys = new ObservableCollection <LotStartQty>(); XAxisLotSteps = new ObservableCollection <CheckBoxLotStep>(); WIPBarChart = new PlotModel { Title = "WIP balance" }; dialogCoordinator = DialogCoordinator.Instance; inputDirectory = inputDir; FPSAnimation = 5; FPSMax = 5; waferThresholdQty = 1; // Initialize Experiment Settings experimentSettings = new ExperimentSettings(); experimentSettings.NumberOfReplications = 1; experimentSettings.LengthOfReplication = 1 * 24 * 60 * 60; experimentSettings.LengthOfWarmUp = 0 * 60 * 60; Settings.WriteOutput = true; // Initialize Waferfab Settings this.reader = new AutoDataReader(inputDirectory + @"\CSVs", inputDir + @"\SerializedFiles"); waferFabSettings = this.reader.ReadWaferFabSettings(eptParameterFile, false, true, DispatcherBase.Type.EPTOVERTAKING); waferFabSettings.WIPTargets = this.reader.ReadWIPTargets(waferFabSettings.LotSteps, "WIPTargets.csv"); waferFabSettings.UseRealLotStartsFlag = true; waferFabSettings.SampleInterval = 60 * 60; initializeGUIWaferFabSettings(waferFabSettings); // TEMPORARY var reader = new ManualDataReader(inputDirectory + @"\Manual"); var settings = reader.ReadWaferFabSettings(); // Initialize bar chart SimulationSnapshots = new ObservableCollection <SimulationSnapshot>(WaferFabSim.MySimResults.SimulationSnapshots); foreach (var step in waferFabSettings.LotSteps.OrderBy(x => x.Value.Id)) { XAxisLotSteps.Add(new CheckBoxLotStep(settings.LotSteps.ContainsKey(step.Key), $"{step.Key}")); } xAxis = new CategoryAxis() { Angle = 60, ItemsSource = XAxisLotSteps.Where(x => x.Selected).Select(x => x.Name) }; WIPBarChart.Axes.Add(xAxis); yAxis = new LinearAxis() { Minimum = 0 }; yAxis.Maximum = 400; WIPBarChart.Axes.Add(yAxis); }