public void DeactivateMode(CanvasStates nextMode) { for (int i = 0; i < _canvasModes.Count; i++) { if (!_canvasModes[i].ActiveStates.Contains(nextMode)) { _canvasModes[i].Deactivate(); } } }
public void ActivateMode(CanvasStates newMode) { for (int i = 0; i < _canvasModes.Count; i++) { if (_canvasModes[i].ActiveStates.Contains(newMode)) { _canvasModes[i].Activate(this); } } if (OnStateActive != null) { OnStateActive.Invoke(newMode); } }
//Function that will enable or disable a canvas depending on the desired state public void HandleCanvas(GameObject canvasToEnable, CanvasStates desiredCanvasState) { //Check if the desired state is disabled if (desiredCanvasState == CanvasStates.disabled) { //Disable the canvas canvasToEnable.SetActive(false); } //Check if the desired state is enabled else if (desiredCanvasState == CanvasStates.enabled) { //Enable the canvas canvasToEnable.SetActive(true); } }
public GraphWindow() { try { InitializeComponent(); CanvasStates.Clear(); canvas.Children.Clear(); canvasGraph.Children.Clear(); if (ConfigurationHelper.ComputeCharts || ConfigurationHelper.ComputeGraph || ConfigurationHelper.ComputeEquations) { System.Diagnostics.Stopwatch myStopwatch = new System.Diagnostics.Stopwatch(); myStopwatch.Start(); var elementInf = new List <ElementInformation>(); foreach (var elm in ConfigurationHelper.Modules.DistinctBy(b => b.Name)) { elementInf.Add(new ElementInformation() { M = elm.M, L = elm.L, Name = elm.Name, AllRepairCount = ConfigurationHelper.UseRepairModules ? elm.RepairCount : 0 }); } var systemState = new SystemState(elementInf, ConfigurationHelper.WorkCondition, ConfigurationHelper.Modules.Count); systemState.GetDistinctSystemStates(elementInf); var connections = systemState.SystemStates.Sum(s => s.BaseStates.Count) + systemState.SystemStates.Sum(s => s.ChildStates.Count); dateGrid.ItemsSource = systemState.SystemStates; var textArray = new string[] { "", $"Modules: {systemState.CountModule}", $"CurrentRepairCount: {systemState.SystemElements.First().AllRepairCount}", $"SystemStates: {systemState.SystemStates.Count}", $"connections: {connections}", "" }; File.AppendAllLines(@"C:\Users\cemiv\Desktop\1.txt", textArray); SystemState = systemState; myStopwatch.Stop(); var ms = myStopwatch.Elapsed; Presenters.Path.logFormElements.Add($"Get system states {ms} ms."); } if (ConfigurationHelper.ComputeGraph) { System.Diagnostics.Stopwatch myStopwatch = new System.Diagnostics.Stopwatch(); myStopwatch.Start(); //todo ShowGraph(); myStopwatch.Stop(); var ms = myStopwatch.Elapsed; Presenters.Path.logFormElements.Add($"Get graph {ms} ms."); } if (ConfigurationHelper.ComputeEquations) { System.Diagnostics.Stopwatch myStopwatch = new System.Diagnostics.Stopwatch(); myStopwatch.Start(); var result = GetEquations(); dateGridQ.ItemsSource = result; myStopwatch.Stop(); var ms = myStopwatch.Elapsed; Presenters.Path.logFormElements.Add($"Get sysytem equations {ms} ms."); } if (ConfigurationHelper.ComputeCharts) { System.Diagnostics.Stopwatch myStopwatch = new System.Diagnostics.Stopwatch(); myStopwatch.Start(); List <double> workValues = new List <double>(); List <double> downTimeValues = new List <double>(); List <double> errorTimeValues = new List <double>(); List <double> timeList = new List <double>(); baseValues[0] = 1; System.Diagnostics.Stopwatch myStopwatch1 = new System.Diagnostics.Stopwatch(); myStopwatch1.Start(); // var result1 = ConfigurationHelper.MatLabContext.ComputeDifferentialEquations(equations, baseValues, ConfigurationHelper.Step, 0, (int)ConfigurationHelper.MaxTime); //var aaa = $"F=@(t,p) [{String.Join("; ", equations).Replace(",", ".")}]; [t p]=ode45(F,[{1} : {1} : {1}], [{String.Join(" ", baseValues)}]);"; myStopwatch1.Stop(); System.Diagnostics.Stopwatch myStopwatch2 = new System.Diagnostics.Stopwatch(); myStopwatch2.Start(); var result1 = new List <List <double> >(); //var result1 = ConfigurationHelper.MatLabContext.ComputeDifferentialEquations(equations, baseValues, ConfigurationHelper.Step, 0, (int)ConfigurationHelper.MaxTime); var result12 = RungeKuttaMethod.RungeKuttaMethods(equations.Count, (int)ConfigurationHelper.Step, (int)ConfigurationHelper.MaxTime, equationCoefficients, baseValues.Select(s => (double)s).ToArray()); var baseValuesq = baseValues.Select(s => (double)s).ToList(); result1.Add(baseValuesq); result1.AddRange(result12); myStopwatch2.Stop(); double startTime = 0; ConfigurationHelper.RungeKutteStringTable.Clear(); // Add columns var headers = new List <string>(); var gridView = new GridView(); this.listView.View = gridView; gridView.Columns.Add(new GridViewColumn { Header = $"{Properties.Resources.Time}", DisplayMemberBinding = new Binding($"{Properties.Resources.Time}") }); headers.Add(Properties.Resources.Time); for (var i = 0; i <= SystemState.SystemStates.Count; i++) { gridView.Columns.Add(new GridViewColumn { Header = $"S{i+1}", DisplayMemberBinding = new Binding($"S{i+1}") }); headers.Add($"S{i + 1}"); } gridView.Columns.Add(new GridViewColumn { Header = $"{Properties.Resources.SumWorkingStates}", DisplayMemberBinding = new Binding($"Working") }); headers.Add(Properties.Resources.SumWorkingStates); gridView.Columns.Add(new GridViewColumn { Header = $"{Properties.Resources.SumDownTiimeStates}", DisplayMemberBinding = new Binding($"Downtime") }); headers.Add(Properties.Resources.SumDownTiimeStates); gridView.Columns.Add(new GridViewColumn { Header = $"{Properties.Resources.SumRefusalStates}", DisplayMemberBinding = new Binding($"Refusal") }); headers.Add(Properties.Resources.SumRefusalStates); ConfigurationHelper.RungeKutteStringTable.AppendLine(String.Join(", ", headers)); var workDictionary = new Dictionary <double, double>(); var downTimeDictionary = new Dictionary <double, double>(); var refusalDictionary = new Dictionary <double, double>(); double indexCount = 0; foreach (var item in result1) { var ListViewObject = new System.Dynamic.ExpandoObject() as IDictionary <string, Object>; timeList.Add(startTime); double workValue = 0; double downTimeValue = 0; for (var index = 0; index < item.Count; index++) { if (SystemState.WorkStateIndexList.Contains(index)) { workValue += item[index]; } if (SystemState.DownTimeStateIndexList.Contains(index)) { downTimeValue += item[index]; } ListViewObject.Add($"S{index + 1}", Math.Round(item[index], 15)); } workValues.Add(workValue); downTimeValues.Add(downTimeValue); var sum = downTimeValue + workValue; errorTimeValues.Add(1 - sum); workDictionary.Add(indexCount, workValue); downTimeDictionary.Add(indexCount, downTimeValue); refusalDictionary.Add(indexCount, 1 - sum); indexCount += ConfigurationHelper.Step; ListViewObject.Add("Time", startTime); ListViewObject.Add("Working", Math.Round(workValue, 15)); ListViewObject.Add("Downtime", Math.Round(downTimeValue, 15)); ListViewObject.Add("Refusal", Math.Round(1 - sum, 15)); var tableValues = new List <string>(); tableValues.Add(Math.Round(workValue, 15).ToString()); tableValues.AddRange(item.Select(s => Math.Round(s, 15).ToString()).ToList()); tableValues.Add(Math.Round(workValue, 15).ToString()); tableValues.Add(downTimeValue.ToString()); tableValues.Add(Math.Round(1 - sum, 15).ToString()); ConfigurationHelper.RungeKutteStringTable.AppendLine(String.Join(", ", tableValues)); // Populate list this.listView.Items.Add(ListViewObject); startTime += ConfigurationHelper.Step; } var RectangleMethodWork = Integral.RectangleMethod(workDictionary, 0, ConfigurationHelper.MaxTime, (int)(ConfigurationHelper.MaxTime / ConfigurationHelper.Step)); var TrapeziumMethodWork = Integral.TrapeziumMethod(workDictionary, 0, ConfigurationHelper.MaxTime, (int)(ConfigurationHelper.MaxTime / ConfigurationHelper.Step)); this.T_work.Content = $"{Properties.Resources.AverageWorkTime} = {Math.Round(TrapeziumMethodWork,6)}"; var RectangleMethodDownTime = Integral.RectangleMethod(downTimeDictionary, 0, ConfigurationHelper.MaxTime, (int)(ConfigurationHelper.MaxTime / ConfigurationHelper.Step)); var TrapeziumMethodDownTime = Integral.TrapeziumMethod(downTimeDictionary, 0, ConfigurationHelper.MaxTime, (int)(ConfigurationHelper.MaxTime / ConfigurationHelper.Step)); this.T_down.Content = $"{Properties.Resources.AverageDowntimeTime} = {Math.Round(TrapeziumMethodDownTime, 6)}"; var RectangleMethodRefusal = Integral.RectangleMethod(refusalDictionary, 0, ConfigurationHelper.MaxTime, (int)(ConfigurationHelper.MaxTime / ConfigurationHelper.Step)); var TrapeziumMethodRefusal = Integral.TrapeziumMethod(refusalDictionary, 0, ConfigurationHelper.MaxTime, (int)(ConfigurationHelper.MaxTime / ConfigurationHelper.Step)); this.T_error.Content = $"{Properties.Resources.AverageRefusalTime} = {Math.Round(TrapeziumMethodRefusal, 6)}"; var yDataSource = new EnumerableDataSource <double>(workValues); var suumm = RectangleMethodWork + RectangleMethodDownTime + RectangleMethodRefusal; var suumm1 = TrapeziumMethodWork + TrapeziumMethodDownTime + TrapeziumMethodRefusal; yDataSource.SetYMapping(Y => Y); var xDataSource = new EnumerableDataSource <double>(timeList); xDataSource.SetXMapping(X => X); CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource); // plotterWork.AddHandler(CircleElementPointMarker.ToolTipTextProperty, s => String.Format("Y-Data : {0}\nX-Data : {1}", s.Y, s.X)); plotterWork.Children.RemoveAll(typeof(LineGraph)); plotterWork.AddLineGraph(compositeDataSource, new Pen(Brushes.Green, 2), new PenDescription("Work Line")); plotterWork.FitToView(); yDataSource = new EnumerableDataSource <double>(downTimeValues); yDataSource.SetYMapping(Y => Y); xDataSource = new EnumerableDataSource <double>(timeList); xDataSource.SetXMapping(X => X); compositeDataSource = new CompositeDataSource(xDataSource, yDataSource); plotterDownTime.Children.RemoveAll(typeof(LineGraph)); plotterDownTime.AddLineGraph(compositeDataSource, new Pen(Brushes.Orange, 2), new PenDescription("Down Time Line")); plotterDownTime.FitToView(); yDataSource = new EnumerableDataSource <double>(errorTimeValues); yDataSource.SetYMapping(Y => Y); xDataSource = new EnumerableDataSource <double>(timeList); xDataSource.SetXMapping(X => X); compositeDataSource = new CompositeDataSource(xDataSource, yDataSource); plotterErrorTime.Children.RemoveAll(typeof(LineGraph)); plotterErrorTime.AddLineGraph(compositeDataSource, new Pen(Brushes.Red, 2), new PenDescription("Error Time Line")); plotterErrorTime.FitToView(); myStopwatch.Stop(); var ms = myStopwatch.Elapsed; Presenters.Path.logFormElements.Add($"Get charts of reliability time ex. {ms} ms."); } } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }
private void Start() { Time.timeScale = 0.0f; canvasStates = canvas.GetComponent <CanvasStates>(); }
private IEnumerator doSceneChange(string sceneName, CanvasStates nextMode) { yield return(SceneManager.LoadSceneAsync(sceneName)); CanvasManager.instance.ActivateMode(nextMode); }