public static TreeViewItem CreateTreeViewItem(SimulationScope scope) { TreeViewItem item = new TreeViewItem(); item.Tag = scope; item.Items.Add("zzz"); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; BitmapImage b_img = new BitmapImage(new Uri("/Waveform;component/icons/Chip.png", UriKind.Relative)); Image img = new Image() { Source = b_img, Width = 16, Height = 16, }; TextBlock text = new TextBlock() { Text = scope.Name }; text.Tag = scope; panel.Children.Add(img); panel.Children.Add(text); item.Header = panel; return(item); }
/// <summary> /// The $scope section defines the scope of which the variables belong in. /// </summary> /// <param name="Words"></param> private void OnScope(string[] Words) { VCDScope sc = VCDScope.Parse(Words); CurrentVCDScope.Push(sc); CurrentScope = CurrentScope.AddNewScope(sc.Name); }
private void TreeViewScopes_Expanded(object sender, RoutedEventArgs e) { TreeViewItem item = (TreeViewItem)e.OriginalSource; item.Items.Clear(); if (item.Tag is SimulationScope) { SimulationScope scope = item.Tag as SimulationScope; foreach (SimulationScope sc in scope.Items) { item.Items.Add(CreateTreeViewItem(sc)); } foreach (IValueProvider var in scope.Variables) { if (var is Signal) { item.Items.Add(CreateTreeViewItem(var as Signal)); } } } if (item.Tag is Signal) { Signal selectedSignal = item.Tag as Signal; foreach (Signal s in selectedSignal.Childrens) { item.Items.Add(CreateTreeViewItem(s)); } } }
private void Init() { timescale = new Timescale(1, TimeUnit.fs); variables = new List <VCD_Variable>(); CurrentVCDScope = new Stack <VCDScope>(); CurrentScope = dump; CurrentTime = 0; }
public ValueDumpWriter(SimulationScope dump, Stream stream) { timescale = new Timescale(1, TimeUnit.fs); Date = DateTime.Now.ToString(); version = System.Reflection.Assembly.GetExecutingAssembly().FullName; this.stream = stream; this.dump = dump; }
public ValueDumpWriter(SimulationScope dump, String FileName) { timescale = new Timescale(1, TimeUnit.fs); Date = DateTime.Now.ToString(); version = System.Reflection.Assembly.GetExecutingAssembly().FullName; stream = new FileStream(FileName, System.IO.FileMode.Create, FileAccess.Write, FileShare.None, 2 << 24, FileOptions.None); this.dump = dump; }
public ValueDumpWriter(SimulationScope dump, System.IO.Stream stream, Timescale Timescale, string Date, string Version) { this.version = Version; this.timescale = Timescale; this.date = Date; this.stream = stream; this.dump = dump; }
public ValueDumpWriter(SimulationScope dump, String FileName, Timescale Timescale, string Date, string Version) { this.version = Version; this.timescale = Timescale; this.date = Date; this.stream = new FileStream(FileName, System.IO.FileMode.Create, FileAccess.Write, FileShare.None, 2 << 24, FileOptions.None); this.dump = dump; }
public WaveformCore(WaveformUserControl waveformUserControl) { this.waveformUserControl = waveformUserControl; dump = new SimulationScope("Root", null); timescale = new Timescale(1, TimeUnit.fs); currentDump = new ObservableCollection <My_Variable>(); entity = new Entity(); bookMarks = new ObservableCollection <BookMark>(); timeMeasureList = new ObservableCollection <TimeMeasureData>(); }
public ValueDumpReader(String FileName) { try { stream = new System.IO.FileStream(FileName, System.IO.FileMode.Open); dump = new SimulationScope("Root", null); } catch (Exception ex) { MessageBox.Show(string.Format("Message: {0}\n StackTrace: {1}\n TargetSite: {2}\n Source: {3}", ex.Message, ex.StackTrace, ex.TargetSite, ex.Source), "Error :(", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void FormDefaultResultScope() { result_scope = new SimulationScope("root", null); List <VHDL.Object.Signal> signals = architecture.Scope.GetListOfObjects <VHDL.Object.Signal>(); foreach (VHDL.Object.Signal s in signals) { Signal signal = Signal.CreateSignal(s); signalScope.Add(signal); currentScope.Add(signal); result_scope.Variables.Add(signal); } }
/// <summary> /// Загрузка VCD файла /// </summary> /// <param name="FileName"></param> public void LoadVCDFile(Stream stream, string confPath) { VCDReader vcd = new VCDReader(stream); dump.Clear(); Schematix.Core.UserControls.ProgressWindow.Window.RunProcess(vcd); dump = vcd.Dump; timescale = vcd.Timescale; summaryInfo = vcd.SummaryInfo; LoadConfiguration(confPath); }
/// <summary> /// Загрузка VCD файла /// </summary> /// <param name="FileName"></param> public void LoadVCDFile(string FileName) { VCDReader vcd = new VCDReader(FileName); dump.Clear(); Schematix.Core.UserControls.ProgressWindow.Window.RunProcess(vcd); dump = vcd.Dump; timescale = vcd.Timescale; summaryInfo = vcd.SummaryInfo; string confPath = System.IO.Path.ChangeExtension(FileName, "conf"); LoadConfiguration(confPath); }
public ModelingSystemCore(VHDL.libraryunit.Architecture architecture, VHDL.LibraryDeclarativeRegion library, VHDL.RootDeclarativeRegion rootDeclarationRegion, SimulationScope scope) { ExpressionEvaluator.DefaultEvaluator = new ExpressionEvaluator(this); this.architecture = architecture; this.library = library; this.rootDeclarationRegion = rootDeclarationRegion; functionAnalyser = new FunctionAnalyser(architecture.Scope); currentScope = new List <IValueProvider>(); signalScope = new List <Signal>(); now = new TIME_VALUE(0); result_scope = scope; foreach (var s in scope.Variables) { if (s is Signal) { signalScope.Add(s as Signal); currentScope.Add(s as Signal); } } }
private void TreeViewScopes_Expanded(object sender, RoutedEventArgs e) { TreeViewItem item = (TreeViewItem)e.OriginalSource; item.Items.Clear(); if (item.Tag is SimulationScope) { SimulationScope scope = item.Tag as SimulationScope; foreach (SimulationScope sc in scope.Items) { item.Items.Add(WaveformUserControl.CreateTreeViewItem(sc)); } foreach (IValueProvider var in scope.Variables) { if (var is Signal) { item.Items.Add(WaveformUserControl.CreateTreeViewItem(var as Signal)); } } } if (item.Tag is Signal) { Signal selectedSignal = item.Tag as Signal; foreach (Signal s in selectedSignal.Childrens) { TreeViewItem item_var = new TreeViewItem(); item_var.Header = s.Name; item_var.Tag = s; if (((s as Signal).Childrens != null) && ((s as Signal).Childrens.Count != 0)) { item_var.Items.Add("zzz"); } item.Items.Add(item_var); } } }
/// <summary> /// Запись в дамп переменных (с одновременной инициализацией списка переменны[) /// </summary> /// <param name="scope"></param> private void WriteScopeVariables(SimulationScope scope) { if (scope.Parent != null) { writer.WriteLine(string.Format("$scope module {0} $end", scope.Name)); } string str_identifier = new string(new char[] { (char)identifier }); foreach (IValueProvider var in scope.Variables) { if (var is Signal) { VCD_Variable vcd_var = new VCD_Variable((var as Signal), str_identifier); variables.Add(vcd_var); identifier++; StringBuilder newIdentf = new StringBuilder(); for (int i = identifier; i > 0; i /= 256) { newIdentf.Append((char)(i % 256)); } str_identifier = newIdentf.ToString(); writer.WriteLine(string.Format("$var {0} $end", vcd_var.VCDVariableDeclaration)); } } foreach (SimulationScope s in scope.Items) { WriteScopeVariables(s); } if (scope.Parent != null) { writer.WriteLine("$upscope $end"); } }
/// <summary> /// The $upscope section indicates a scope change to a higher level in the hierachy. /// </summary> /// <param name="Words"></param> private void OnUpScope(string[] Words) { CurrentVCDScope.Pop(); CurrentScope = CurrentScope.Parent; }
public ValueDumpReader(String FileName) { stream = new System.IO.FileStream(FileName, System.IO.FileMode.Open); dump = new SimulationScope("Root", null); }
public VCDWriter(SimulationScope dump, String FileName, Timescale Timescale, string Date, string Version) : base(dump, FileName, Timescale, Date, Version) { writer = new StreamWriter(stream); variables = new List <VCD_Variable>(); }
public VCDWriter(SimulationScope dump, System.IO.Stream stream) : base(dump, stream) { variables = new List <VCD_Variable>(); writer = new StreamWriter(stream); }
public VCDWriter(SimulationScope dump, String FileName) : base(dump, FileName) { variables = new List <VCD_Variable>(); writer = new StreamWriter(stream); }
public ValueDumpReader(System.IO.Stream stream) { this.stream = stream; dump = new SimulationScope("Root", null); }
public async Task<IHttpActionResult> Get(SimulationScope scope) { var result = new SimulationsDto(); var userId = User.Identity.GetUserId(); var dateTo = DateTime.Now; DateTime dateFrom; string format; var dates = new List<string>(); DateTime dateI; switch (scope) { case SimulationScope.Daily: format = "{0:dd-MM-yyyy}"; dateFrom = dateTo.AddDays(-30); dateI = dateFrom; for (var i = 0; i < 31; i++) { dates.Add(String.Format(format, dateI)); dateI = dateI.AddDays(1); } break; case SimulationScope.Yearly: format = "{0:yyyy}"; dateFrom = dateTo.AddYears(-2); dateI = dateFrom; for (var i = 0; i < 3; i++) { dates.Add(String.Format(format, dateI)); dateI = dateI.AddYears(1); } break; default: format = "{0:MM-yyyy}"; dateFrom = dateTo.AddMonths(-6); dateI = dateFrom; for (var i = 0; i < 7; i++) { dates.Add(String.Format(format, dateI)); dateI = dateI.AddMonths(1); } break; } var expenses = await _db.Expenses.Where(i => i.DateOfExpense >= dateFrom && i.DateOfExpense <= dateTo && i.UserId == userId).Distinct().ToListAsync(); var groupedPastIncomes = expenses.Where(i => i.Cost >= 0).GroupBy(i => String.Format(format, i.DateOfExpense)).ToList(); var groupedPastOutcomes = expenses.Where(i => i.Cost < 0).GroupBy(i => String.Format(format, i.DateOfExpense)).ToList(); var incomesSum = new List<decimal>(); groupedPastIncomes.ForEach(i => incomesSum.Add(i.Any() ? i.Sum(j => j.Cost) : 0)); var outcomesSum = new List<decimal>(); groupedPastOutcomes.ForEach(i => outcomesSum.Add(i.Any() ? i.Sum(j => j.Cost) : 0)); var estimatedIncome = incomesSum.Any() ? incomesSum.Average() : 0; var estimatedOutcome = outcomesSum.Any() ? outcomesSum.Average(): 0; var summaryDto = new SimulationsDto() { PastIncomes = AssignToDates(dates, groupedPastIncomes), PastOutcomes = AssignToDates(dates, groupedPastOutcomes), Dates = dates, EstimatedIncome = estimatedIncome, EstimatedOutcome = -estimatedOutcome }; return Ok(summaryDto); }