private void BtnAddSignal_Click([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { var isOk = CmbSignalVariable.SelectedItem != null; if (string.IsNullOrEmpty(TxtTriggerLevelOff.Text)) { isOk = false; } if (string.IsNullOrEmpty(TxtTriggerLevelOn.Text)) { isOk = false; } if (string.IsNullOrEmpty(TxtSignalValue.Text)) { isOk = false; } if (!isOk) { Logger.Error("All fields need to be filled in to add a signal."); return; } var lt = (Variable)CmbSignalVariable.SelectedItem; var off = Utili.ConvertToDoubleWithMessage(TxtTriggerLevelOff.Text); var on = Utili.ConvertToDoubleWithMessage(TxtTriggerLevelOn.Text); var value = Utili.ConvertToDoubleWithMessage(TxtSignalValue.Text); Presenter.ThisStorage.AddSignal(lt, on, off, value); LstSignals.ResizeColummns(); }
private void BtnAddLoad_Click([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { if (CmbLoadTypes.SelectedItem == null) { return; } if (string.IsNullOrWhiteSpace(TxtMaximumPower.Text)) { Logger.Warning("No maximum power defined."); return; } if (string.IsNullOrWhiteSpace(TxtStandardDeviation.Text)) { Logger.Warning("No standard deviation defined."); return; } var loadType = (VLoadType)CmbLoadTypes.SelectedItem; var maxpower = Utili.ConvertToDoubleWithMessage(TxtMaximumPower.Text); var standardDeviation = Utili.ConvertToDoubleWithMessage(TxtStandardDeviation.Text); var averageYearlyConsumption = Utili.ConvertToDoubleWithMessage(TxtAverageYearlyConsumption.Text); Presenter.AddRealDeviceLoadType(loadType, maxpower, standardDeviation, averageYearlyConsumption); }
private static void ReadFile([JetBrains.Annotations.NotNull] string fullName, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, [CanBeNull] int?limit) { using (var sr = new StreamReader(fullName)) { var header = sr.ReadLine(); if (header == null) { throw new LPGException("File " + fullName + " was empty."); } var headers = header.Split(';'); foreach (var s in headers) { var col = new Column(s); columns.Add(col); } var line = 0; var maxline = int.MaxValue; if (limit != null) { maxline = (int)limit; } while (!sr.EndOfStream && line < maxline) { line++; if (line % 1000 == 0) { Logger.Info("Merged Activity Plot Reading Line: " + line); } var s = sr.ReadLine(); if (s == null) { throw new LPGException(fullName + " was empty."); } var cols = s.Split(';'); for (var i = 0; i < cols.Length; i++) { if (i != 1 && i != 500) { if (!string.IsNullOrWhiteSpace(cols[i].Trim())) { var col = columns[i]; var val = cols[i]; var mydouble = Utili.ConvertToDoubleWithMessage(val, "Col " + i); col.Values.Add(mydouble); } } } } sr.Close(); } // columns.RemoveAt(columns.Count - 1); // last column is empty columns.RemoveAt(1); // 2nd column is dates var colsTodelete = columns.Where(x => string.IsNullOrWhiteSpace(x.Name)).ToList(); foreach (var column in colsTodelete) { columns.Remove(column); } }
private void BtnAddVariableOpClick([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { if (CmbOpVariable.SelectedItem == null) { return; } if (string.IsNullOrEmpty(TxtOpVariableValue.Text)) { return; } if (CmbOpAction.SelectedItem == null) { return; } if (CmbOpExecutionTime.SelectedItem == null) { return; } Location loc = null; if (CmbOpLocation.SelectedItem != null) { loc = (Location)CmbOpLocation.SelectedItem; } var mode = VariableLocationModeHelper.ConvertToVariableAction((string)CmbOpLocationMode.SelectedItem); var val = Utili.ConvertToDoubleWithMessage(TxtOpVariableValue.Text); var va = (Variable)CmbOpVariable.SelectedItem; var variableAction = VariableActionHelper.ConvertToVariableAction((string)CmbOpAction.SelectedItem); var executionTime = VariableExecutionTimeHelper.ConvertToEnum((string)CmbOpExecutionTime.SelectedItem); Presenter.ThisSubAffordance.AddVariableOperation(val, mode, loc, variableAction, va, executionTime); }
protected override FileProcessingResult MakeOnePlot(ResultFileEntry rfe) { Profiler.StartPart(Utili.GetCurrentMethodAndClass()); string plotName = "Location Statistics " + rfe.HouseholdNumberString; var persons = new List <PersonEntry>(); if (rfe.FullFileName == null) { throw new LPGException("filename was null"); } using (var sr = new StreamReader(rfe.FullFileName)) { PersonEntry lastPerson = null; while (!sr.EndOfStream) { var s = sr.ReadLine(); if (s == null) { throw new LPGException("File " + rfe.FullFileName + " was empty."); } if (s.StartsWith("----", StringComparison.CurrentCulture)) { var s2 = sr.ReadLine(); if (s2 == null) { throw new LPGException("readline failed"); } lastPerson = new PersonEntry(s2); persons.Add(lastPerson); } else { if (lastPerson == null) { throw new LPGException("lastperson was null"); } var cols = s.Split(Parameters.CSVCharacterArr, StringSplitOptions.None); var val = Utili.ConvertToDoubleWithMessage(cols[2], "LocationStatisticsPlot"); if (val > 0) { lastPerson.Percentages.Add(cols[0], val); } } } } foreach (var entry in persons) { var plotModel1 = new PlotModel { LegendBorderThickness = 0, LegendOrientation = LegendOrientation.Horizontal, LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomCenter }; if (Parameters.ShowTitle) { plotModel1.Title = plotName; } var pieSeries1 = new PieSeries { InsideLabelColor = OxyColors.White, InsideLabelPosition = 0.8, StrokeThickness = 2, AreInsideLabelsAngled = true }; foreach (var tuple in entry.Percentages) { var name = tuple.Key.Trim(); if (name.Length > 30) { name = name.Substring(0, 20) + "..."; } var slice = new PieSlice(name, tuple.Value); pieSeries1.Slices.Add(slice); } plotModel1.Series.Add(pieSeries1); var newfilename = "LocationStatistics." + entry.CleanName; Save(plotModel1, plotName, rfe.FullFileName, Parameters.BaseDirectory, CalcOption.LocationsFile, newfilename); } Profiler.StopPart(Utili.GetCurrentMethodAndClass()); return(FileProcessingResult.ShouldCreateFiles); }