diff --git a/HashingCmd/Program.cs b/HashingCmd/Program.cs index 4312d075b94040dbf2f8fe7e328169e618ee263c..c8d1ad3857b5263d4e1a6ab82fd7b4ebc83e22b1 100644 --- a/HashingCmd/Program.cs +++ b/HashingCmd/Program.cs @@ -170,11 +170,11 @@ hashingcmd.exe { var args = evt.ValidationEventArgs; if (severity == XmlSeverityType.Error) { - throw new Exception(string.Format("Validation error: {0}" + Environment.NewLine + - "Line: {1}", args.Message, args.Exception.LineNumber), evt.Exception); + throw new Exception($"Validation error: {args.Message}{Environment.NewLine}" + + $"Line: {args.Exception.LineNumber}", evt.Exception); } else { - Console.Error.WriteLine("Validation warning: {0}" + Environment.NewLine + - "Line: {1}", args.Message, args.Exception.LineNumber); + Console.Error.WriteLine("Validation warning: {0}{2}Line: {1}", + args.Message, args.Exception.LineNumber, Environment.NewLine); } } @@ -258,7 +258,7 @@ hashingcmd.exe { var hashingLib = Assembly.LoadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VectoHashing.dll")) .GetName(); - WriteLine(string.Format(@"HashingLibrary: {0}", hashingLib.Version)); + WriteLine($@"HashingLibrary: {hashingLib.Version}"); } } } \ No newline at end of file diff --git a/HashingTool/Helper/HashingHelper.cs b/HashingTool/Helper/HashingHelper.cs index a747b2e64d4bc53f648e4efae548d8ea9a35fce8..b9bffa7867358816115723c619b72329a3dda691 100644 --- a/HashingTool/Helper/HashingHelper.cs +++ b/HashingTool/Helper/HashingHelper.cs @@ -56,8 +56,8 @@ namespace HashingTool.Helper } var valid = x.DocumentElement.LocalName == XMLNames.VectoManufacturerReport; if (!valid) { - errorLog.LogError(String.Format("Invalid XML file given ({0}). Expected Manufacturer Report XML ({1})!", - x.DocumentElement.LocalName, XMLNames.VectoManufacturerReport)); + errorLog.LogError($"Invalid XML file given ({x.DocumentElement.LocalName}). " + + $"Expected Manufacturer Report XML ({XMLNames.VectoManufacturerReport})!"); } return valid; } @@ -69,8 +69,8 @@ namespace HashingTool.Helper } var valid = x.DocumentElement != null && x.DocumentElement.LocalName == XMLNames.VectoCustomerReport; if (!valid) { - errorLog.LogError(String.Format("Invalid XML file given ({0}). Expected Customer Report XML ({1})!", - x.DocumentElement.LocalName, XMLNames.VectoCustomerReport)); + errorLog.LogError($"Invalid XML file given ({x.DocumentElement.LocalName}). " + + $"Expected Customer Report XML ({XMLNames.VectoCustomerReport})!"); } return valid; } @@ -83,9 +83,8 @@ namespace HashingTool.Helper var valid = x.DocumentElement.LocalName == XMLNames.VectoInputDeclaration && x.DocumentElement.FirstChild.LocalName == XMLNames.Component_Vehicle; if (!valid) { - errorLog.LogError(String.Format("Invalid XML file given ({0}/{1}). Expected Vehicle XML ({2}/{3})!", - x.DocumentElement.LocalName, x.DocumentElement.FirstChild.LocalName, XMLNames.VectoInputDeclaration, - XMLNames.Component_Vehicle)); + errorLog.LogError($"Invalid XML file given ({x.DocumentElement.LocalName}/{x.DocumentElement.FirstChild.LocalName}). " + + $"Expected Vehicle XML ({XMLNames.VectoInputDeclaration}/{XMLNames.Component_Vehicle})!"); } return valid; } @@ -97,8 +96,8 @@ namespace HashingTool.Helper } if (x.DocumentElement.LocalName != XMLNames.VectoInputDeclaration) { - errorLog.LogError(String.Format("Invalid XML file given ({0}). Expected Component XML ({1})!", - x.DocumentElement.LocalName, XMLNames.VectoInputDeclaration)); + errorLog.LogError($"Invalid XML file given ({x.DocumentElement.LocalName}). " + + $"Expected Component XML ({XMLNames.VectoInputDeclaration})!"); return false; } @@ -110,8 +109,8 @@ namespace HashingTool.Helper }; var valid = components.Where(c => c.XMLElementName() == localName).Any(); if (!valid) { - errorLog.LogError(String.Format("Invalid XML file given ({0}). Expected Component XML ({1})!", - localName, String.Join(", ", components.Select(c => c.XMLElementName())))); + errorLog.LogError($"Invalid XML file given ({localName}). " + + $"Expected Component XML ({String.Join(", ", components.Select(c => c.XMLElementName()))})!"); } return valid; } diff --git a/HashingTool/MainWindow.xaml.cs b/HashingTool/MainWindow.xaml.cs index 228940f9436e7b52cacbf781a2422b34e7dbb0a6..34680d35ec702702471214ab103d460410f044f0 100644 --- a/HashingTool/MainWindow.xaml.cs +++ b/HashingTool/MainWindow.xaml.cs @@ -65,7 +65,7 @@ namespace HashingTool var myAppPath = AppDomain.CurrentDomain.BaseDirectory; if (File.Exists(myAppPath + @"User Manual\HashingToolHelp.html")) { var defaultBrowserPath = BrowserHelper.GetDefaultBrowserPath(); - Process.Start(defaultBrowserPath, string.Format("\"file://{0}{1}\"", myAppPath, @"User Manual\HashingToolHelp.html")); + Process.Start(defaultBrowserPath, $"\"file://{myAppPath}{@"User Manual\HashingToolHelp.html"}\""); } else { MessageBox.Show("User Manual not found!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } diff --git a/HashingTool/ViewModel/ApplicationViewModel.cs b/HashingTool/ViewModel/ApplicationViewModel.cs index 853602d021649472a7c41df99477573005fa7d07..1b5696ac3592a61f74cef97ca854067d4266ff97 100644 --- a/HashingTool/ViewModel/ApplicationViewModel.cs +++ b/HashingTool/ViewModel/ApplicationViewModel.cs @@ -75,14 +75,11 @@ namespace HashingTool.ViewModel } } - public List<IMainView> MainViewModels - { - get { return AvailableViews ?? (AvailableViews = new List<IMainView>()); } - } + public List<IMainView> MainViewModels => AvailableViews ?? (AvailableViews = new List<IMainView>()); public IMainView CurrentViewModel { - get { return _currentView; } + get => _currentView; set { if (_currentView == value) { return; @@ -92,15 +89,9 @@ namespace HashingTool.ViewModel } } - public ICommand ChangeViewCommand - { - get { return _changeViewCommand ?? (_changeViewCommand = new RelayCommand<IMainView>(ChangeViewModel)); } - } + public ICommand ChangeViewCommand => _changeViewCommand ?? (_changeViewCommand = new RelayCommand<IMainView>(ChangeViewModel)); - public ICommand ShowHomeViewCommand - { - get { return HomeView; } - } + public ICommand ShowHomeViewCommand => HomeView; private void ChangeViewModel(IMainView mainView) @@ -112,9 +103,6 @@ namespace HashingTool.ViewModel CurrentViewModel = MainViewModels.FirstOrDefault(mv => mv == mainView); } - public string VersionInformation - { - get { return string.Format("Vecto Hashing Tool {0} / Hashing Library {1}", _myVersion, _hashingLib); } - } + public string VersionInformation => $"Vecto Hashing Tool {_myVersion} / Hashing Library {_hashingLib}"; } } diff --git a/HashingTool/ViewModel/HashComponentDataViewModel.cs b/HashingTool/ViewModel/HashComponentDataViewModel.cs index e65a6bb0f254f837f6b38b9d89ed0ba0ae1e1951..01641b30662e1801e6db9c0a5dfff0118ba66763 100644 --- a/HashingTool/ViewModel/HashComponentDataViewModel.cs +++ b/HashingTool/ViewModel/HashComponentDataViewModel.cs @@ -69,14 +69,11 @@ namespace HashingTool.ViewModel } - public ICommand ShowHomeViewCommand - { - get { return ApplicationViewModel.HomeView; } - } + public ICommand ShowHomeViewCommand => ApplicationViewModel.HomeView; public string DigestValue { - get { return _digestValue; } + get => _digestValue; set { if (_digestValue == value) { return; @@ -86,10 +83,7 @@ namespace HashingTool.ViewModel } } - public ICommand SaveHashedDocument - { - get { return _saveCommand; } - } + public ICommand SaveHashedDocument => _saveCommand; private void SourceChanged(object sender, PropertyChangedEventArgs e) { @@ -100,8 +94,7 @@ namespace HashingTool.ViewModel private void SaveDocument() { - string filename; - var stream = IoService.SaveData(null, ".xml", "VECTO XML file|*.xml", out filename); + var stream = IoService.SaveData(null, ".xml", "VECTO XML file|*.xml", out var filename); if (stream == null) { return; } @@ -117,7 +110,7 @@ namespace HashingTool.ViewModel public bool? ComponentDataValid { - get { return _componentDataValid; } + get => _componentDataValid; private set { if (_componentDataValid == value) { return; @@ -163,14 +156,14 @@ namespace HashingTool.ViewModel var validator = new AsyncXMLValidator(XmlReader.Create(ms), r => { ComponentDataValid = r; }, (s, e) => { Application.Current.Dispatcher.Invoke(() => _xmlFile.LogError( - string.Format("Validation {0} Line {2}: {1}", s == XmlSeverityType.Warning ? "WARNING" : "ERROR", + string.Format("Validation {0} Line {2}: {1}", + s == XmlSeverityType.Warning ? "WARNING" : "ERROR", e.ValidationEventArgs == null - ? e.Exception.Message + - (e.Exception.InnerException != null ? Environment.NewLine + e.Exception.InnerException.Message : "") + ? e.Exception.Message + (e.Exception.InnerException != null ? Environment.NewLine + e.Exception.InnerException.Message : "") : e.ValidationEventArgs.Message, - e.ValidationEventArgs == null ? 0 : e.ValidationEventArgs.Exception.LineNumber))); + e.ValidationEventArgs?.Exception.LineNumber ?? 0))); }); - await validator.ValidateXML(TUGraz.VectoCore.Utils.XmlDocumentType.DeclarationComponentData); + await validator.ValidateXML(XmlDocumentType.DeclarationComponentData); } if (ComponentDataValid != null && ComponentDataValid.Value) { //var c14N = XMLHashProvider.DefaultCanonicalizationMethod.ToArray(); @@ -204,7 +197,7 @@ namespace HashingTool.ViewModel public DateTime? Date { - get { return _date; } + get => _date; set { if (_date == value) { diff --git a/HashingTool/ViewModel/HomeViewModel.cs b/HashingTool/ViewModel/HomeViewModel.cs index 13cfe588d2b565fd38b0d26f5e949e3826fb948f..8154fcdf3298c35b7d6fc692079a61657a8e810c 100644 --- a/HashingTool/ViewModel/HomeViewModel.cs +++ b/HashingTool/ViewModel/HomeViewModel.cs @@ -38,22 +38,11 @@ namespace HashingTool.ViewModel { - public string Name - { - get { return "Home"; } - } + public string Name => "Home"; - public List<IMainView> MainViewModels - { - get { return ApplicationViewModel.AvailableViews; } - } + public List<IMainView> MainViewModels => ApplicationViewModel.AvailableViews; - - - public ICommand ShowHomeViewCommand - { - get { return ApplicationViewModel.HomeView; } - } + public ICommand ShowHomeViewCommand => ApplicationViewModel.HomeView; } } diff --git a/HashingTool/ViewModel/UserControl/CustomerReportXMLFile.cs b/HashingTool/ViewModel/UserControl/CustomerReportXMLFile.cs index 22fc7ba3282ff7593154660ac6da2d17e513af28..73665e0bd4b32a69cb20e5c3b4532705fa6a6b56 100644 --- a/HashingTool/ViewModel/UserControl/CustomerReportXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/CustomerReportXMLFile.cs @@ -57,7 +57,7 @@ namespace HashingTool.ViewModel.UserControl public ManufacturerReportXMLFile ManufacturerReport { - get { return _manufacturerReport; } + get => _manufacturerReport; set { if (_manufacturerReport == value) { return; @@ -69,7 +69,7 @@ namespace HashingTool.ViewModel.UserControl public string[] ManufacturerReportCanonicalizationMethodRead { - get { return _manufacturerReportCanonicalizationMethodRead; } + get => _manufacturerReportCanonicalizationMethodRead; set { if (_manufacturerReportCanonicalizationMethodRead == value) { @@ -82,7 +82,7 @@ namespace HashingTool.ViewModel.UserControl public string ManufacturerReportDigestMethodRead { - get { return _manufacturerReportDigestMethodRead; } + get => _manufacturerReportDigestMethodRead; set { if (_manufacturerReportDigestMethodRead == value) { @@ -95,7 +95,7 @@ namespace HashingTool.ViewModel.UserControl public string ManufacturerReportDigestValueRead { - get { return _manufacturerReportDigestValueRead; } + get => _manufacturerReportDigestValueRead; set { if (_manufacturerReportDigestValueRead == value) { @@ -108,7 +108,7 @@ namespace HashingTool.ViewModel.UserControl public bool ManufacturerReportMatchesReport { - get { return _manufacturerReportMatchesReport; } + get => _manufacturerReportMatchesReport; set { if (_manufacturerReportMatchesReport == value) { @@ -121,7 +121,7 @@ namespace HashingTool.ViewModel.UserControl public string ManufacturerReportDigestValueComputed { - get { return _manufacturerReportDigestValueComputed; } + get => _manufacturerReportDigestValueComputed; set { if (_manufacturerReportDigestValueComputed == value) { @@ -134,7 +134,7 @@ namespace HashingTool.ViewModel.UserControl public bool ManufacturerReportDigestValid { - get { return _manufacturerReportDigestValid; } + get => _manufacturerReportDigestValid; set { if (_manufacturerReportDigestValid == value) { return; diff --git a/HashingTool/ViewModel/UserControl/HashedXMLFile.cs b/HashingTool/ViewModel/UserControl/HashedXMLFile.cs index 08c3df85d1b966798f3c482cff0c6be48651d868..7eaba6870d6751ae044193c82cc701306c55da34 100644 --- a/HashingTool/ViewModel/UserControl/HashedXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/HashedXMLFile.cs @@ -48,7 +48,7 @@ namespace HashingTool.ViewModel.UserControl public string DigestValueRead { - get { return _digestValueRead; } + get => _digestValueRead; internal set { if (_digestValueRead == value) { return; @@ -78,7 +78,7 @@ namespace HashingTool.ViewModel.UserControl public DateTime? Date { - get { return _date; } + get => _date; internal set { if (_date == value) { return; diff --git a/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs b/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs index 9dc4b67f71d85a50e926e2c4d9aa57cba8b2da39..0afd5f209648af4ac094b3b033b462a855255425 100644 --- a/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs @@ -100,7 +100,7 @@ namespace HashingTool.ViewModel.UserControl var entry = new ComponentEntry { Component = component.Count == 1 ? component.Entry.XMLElementName() - : string.Format("{0} ({1})", component.Entry.XMLElementName(), i + 1), + : $"{component.Entry.XMLElementName()} ({i + 1})", DigestValue = ReadElementValue(node, XMLNames.DI_Signature_Reference_DigestValue), CertificationMethod = ReadElementValue(node, XMLNames.Report_Component_CertificationMethod), }; @@ -137,16 +137,16 @@ namespace HashingTool.ViewModel.UserControl var digestMismatch = componentData.Where(x => x.DigestValueMatchesJobComponent == null || !x.DigestValueMatchesJobComponent.Value).ToArray(); if (jobComponents.Any()) { foreach (var entry in certificationNumberMismatch) { - _validationErrors.Add( - string.Format( - "Verifying Manufacturer Report: Certification number for component '{0}' does not match! Job-file: '{1}', Report: '{2}'", - entry.Component, entry.CertificationNumberExpected, entry.CertificationNumber)); + _validationErrors.Add("Verifying Manufacturer Report: " + + $"Certification number for component '{entry.Component}' does not match! " + + $"Job-file: '{entry.CertificationNumberExpected}', " + + $"Report: '{entry.CertificationNumber}'"); } foreach (var entry in digestMismatch) { - _validationErrors.Add( - string.Format( - "Verifying Manufacturer Report: Digest Value for component '{0}' does not match! Job-file: '{1}', Report: '{2}'", - entry.Component, entry.DigestValueExpected, entry.DigestValue)); + _validationErrors.Add("Verifying Manufacturer Report: " + + $"Digest Value for component '{entry.Component}' does not match! " + + $"Job-file: '{entry.DigestValueExpected}', " + + $"Report: '{entry.DigestValue}'"); } } @@ -155,7 +155,7 @@ namespace HashingTool.ViewModel.UserControl public bool ManufacturerReportValid { - get { return _manufacturerReportValid; } + get => _manufacturerReportValid; set { if (_manufacturerReportValid == value) { return; @@ -167,7 +167,7 @@ namespace HashingTool.ViewModel.UserControl private string ReadElementValue(XmlNode xmlNode, string elementName) { - var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName)); + var node = xmlNode.SelectSingleNode($"./*[local-name()='{elementName}']"); if (node == null) { return null; } diff --git a/HashingTool/ViewModel/UserControl/ReportXMLFile.cs b/HashingTool/ViewModel/UserControl/ReportXMLFile.cs index 6e3ec84c19cba3603558173bb72c901615af194f..3c77576e142890c90f3110acc35561ab3a5a79e4 100644 --- a/HashingTool/ViewModel/UserControl/ReportXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/ReportXMLFile.cs @@ -57,10 +57,7 @@ namespace HashingTool.ViewModel.UserControl _xmlFile.PropertyChanged += ReportChanged; } - public ObservableCollection<string> ValidationErrors - { - get { return _validationErrors; } - } + public ObservableCollection<string> ValidationErrors => _validationErrors; public VectoJobFile JobData { @@ -110,13 +107,15 @@ namespace HashingTool.ViewModel.UserControl var vinMatch = _jobData.VehicleIdentificationNumber == ReportVIN; if (!digestMatch) { - _validationErrors.Add(string.Format("Job Digest Value mismatch! Computed job digest: '{0}', digest read: '{1}'", - _jobDigestComputed, JobDigestValueRead)); + _validationErrors.Add("Job Digest Value mismatch! " + + $"Computed job digest: '{_jobDigestComputed}', " + + $"digest read: '{JobDigestValueRead}'"); } if (!vinMatch) { - _validationErrors.Add(string.Format("VIN mismatch! VIN from job data: '{0}', VIN from report: '{1}'", - _jobData.VehicleIdentificationNumber, ReportVIN)); + _validationErrors.Add("VIN mismatch! " + + $"VIN from job data: '{_jobData.VehicleIdentificationNumber}', " + + $"VIN from report: '{ReportVIN}'"); } JobDigestMatchesReport = vinMatch @@ -150,7 +149,7 @@ namespace HashingTool.ViewModel.UserControl public string ReportVIN { - get { return _reportVin; } + get => _reportVin; set { if (_reportVin == value) { return; @@ -162,7 +161,7 @@ namespace HashingTool.ViewModel.UserControl public string JobDigestMethodRead { - get { return _jobDigestMethodRead; } + get => _jobDigestMethodRead; set { if (_jobDigestMethodRead == value) { return; @@ -174,7 +173,7 @@ namespace HashingTool.ViewModel.UserControl public string[] JobCanonicalizationMethodRead { - get { return _jobCanonicalizationMethodRead; } + get => _jobCanonicalizationMethodRead; set { if (_jobCanonicalizationMethodRead == value) { return; @@ -186,7 +185,7 @@ namespace HashingTool.ViewModel.UserControl public string JobDigestValueRead { - get { return _jobDigestValueReadRead; } + get => _jobDigestValueReadRead; internal set { if (_jobDigestValueReadRead == value) { return; @@ -198,7 +197,7 @@ namespace HashingTool.ViewModel.UserControl public string JobDigestValueComputed { - get { return _jobDigestComputed; } + get => _jobDigestComputed; protected set { if (_jobDigestComputed == value) { return; @@ -210,7 +209,7 @@ namespace HashingTool.ViewModel.UserControl public bool JobDigestMatchesReport { - get { return _jobDigestMatchesReport; } + get => _jobDigestMatchesReport; protected set { if (_jobDigestMatchesReport == value) { return; diff --git a/HashingTool/ViewModel/UserControl/VectoJobFile.cs b/HashingTool/ViewModel/UserControl/VectoJobFile.cs index 57fb7a4ae60b1418bc9acd0a2e9a9886eb2086df..c8f1a7a5ada6fcd8cae74d8bf60a115b5e96d7dc 100644 --- a/HashingTool/ViewModel/UserControl/VectoJobFile.cs +++ b/HashingTool/ViewModel/UserControl/VectoJobFile.cs @@ -62,7 +62,7 @@ namespace HashingTool.ViewModel.UserControl public bool? JobDataValid { - get { return _componentDataValid; } + get => _componentDataValid; set { if (_componentDataValid == value) { return; @@ -77,7 +77,7 @@ namespace HashingTool.ViewModel.UserControl public string JobValidToolTip { - get { return _jobValidToolTip; } + get => _jobValidToolTip; set { if (_jobValidToolTip == value) { return; @@ -89,7 +89,7 @@ namespace HashingTool.ViewModel.UserControl public string VehicleIdentificationNumber { - get { return _vin; } + get => _vin; set { if (_vin == value) { return; @@ -101,7 +101,7 @@ namespace HashingTool.ViewModel.UserControl public DateTime? JobCreationDate { - get { return _jobDate; } + get => _jobDate; set { if (_jobDate == value) { return; @@ -129,7 +129,7 @@ namespace HashingTool.ViewModel.UserControl !_xmlFile.ContentValid.Value) { return null; } - var nodes = _xmlFile.Document.SelectNodes(string.Format("//*[local-name()='{0}']", XMLNames.Component_Date)); + var nodes = _xmlFile.Document.SelectNodes($"//*[local-name()='{XMLNames.Component_Date}']"); if (nodes == null || nodes.Count == 0) { return null; } @@ -142,7 +142,7 @@ namespace HashingTool.ViewModel.UserControl !_xmlFile.ContentValid.Value) { return ""; } - var node = _xmlFile.Document.SelectSingleNode(string.Format("//*[local-name()='{0}']", XMLNames.Vehicle_VIN)); + var node = _xmlFile.Document.SelectSingleNode($"//*[local-name()='{XMLNames.Vehicle_VIN}']"); if (node == null) { return ""; } @@ -175,7 +175,7 @@ namespace HashingTool.ViewModel.UserControl var entry = new ComponentEntry(); entry.Component = component.Count == 1 ? component.Entry.XMLElementName() - : string.Format("{0} ({1})", component.Entry.XMLElementName(), i + 1); + : $"{component.Entry.XMLElementName()} ({i + 1})"; entry.Valid = h.ValidateHash(component.Entry, i); entry.CanonicalizationMethod = h.GetCanonicalizationMethods(component.Entry, i).ToArray(); entry.DigestMethod = h.GetDigestMethod(component.Entry, i); @@ -184,10 +184,9 @@ namespace HashingTool.ViewModel.UserControl entry.CertificationNumber = h.GetCertificationNumber(component.Entry, i); entry.CertificationDate = h.GetCertificationDate(component.Entry, i); if (!entry.Valid) { - _xmlFile.LogError( - string.Format( - "Digest Value mismatch for component \"{0}\". Read digest value: \"{1}\", computed digest value \"{2}\"", - entry.Component, entry.DigestValueRead, entry.DigestValueComputed)); + _xmlFile.LogError($"Digest Value mismatch for component \"{entry.Component}\". " + + $"Read digest value: \"{entry.DigestValueRead}\", " + + $"computed digest value \"{entry.DigestValueComputed}\""); } Components.Add(entry); allValid &= entry.Valid; diff --git a/HashingTool/ViewModel/UserControl/VectoXMLFile.cs b/HashingTool/ViewModel/UserControl/VectoXMLFile.cs index 564582ca54b838b529c8412d9cf59ef0fd9d656b..04659ff390d74748b01462ad8a06ba26e80b43d8 100644 --- a/HashingTool/ViewModel/UserControl/VectoXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/VectoXMLFile.cs @@ -79,14 +79,11 @@ namespace HashingTool.ViewModel.UserControl } - public XMLFileSelector XMLFile - { - get { return _xmlFile; } - } + public XMLFileSelector XMLFile => _xmlFile; public string Name { - get { return _name; } + get => _name; private set { if (_name == value) { return; @@ -109,7 +106,7 @@ namespace HashingTool.ViewModel.UserControl public string DigestMethod { - get { return _digestMethod; } + get => _digestMethod; set { if (_digestMethod == value) { return; @@ -122,7 +119,7 @@ namespace HashingTool.ViewModel.UserControl public string DigestValueComputed { - get { return _digestValueComputed; } + get => _digestValueComputed; internal set { if (_digestValueComputed == value) { return; @@ -135,7 +132,7 @@ namespace HashingTool.ViewModel.UserControl public bool? FileIntegrityValid { - get { return _fileIntegrityValid; } + get => _fileIntegrityValid; internal set { if (_fileIntegrityValid == value) { return; @@ -147,7 +144,7 @@ namespace HashingTool.ViewModel.UserControl public string FileIntegrityTooltip { - get { return _tooltip; } + get => _tooltip; set { if (_tooltip == value) { return; @@ -159,7 +156,7 @@ namespace HashingTool.ViewModel.UserControl public string Component { - get { return _componentType; } + get => _componentType; set { if (_componentType == value) { return; diff --git a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs index cee9c493599fbaecc86a292104202672ab0cde57..30d3d6be33af60b0ad2dca905997508f73f2cea9 100644 --- a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs +++ b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs @@ -90,7 +90,7 @@ namespace HashingTool.ViewModel.UserControl public XmlDocument Document { - get { return _document; } + get => _document; private set { if (_document == value) { return; @@ -102,7 +102,7 @@ namespace HashingTool.ViewModel.UserControl public string Source { - get { return _source; } + get => _source; private set { if (_source == value) { return; @@ -113,14 +113,11 @@ namespace HashingTool.ViewModel.UserControl } } - public bool ValidateInput - { - get { return _validate; } - } + public bool ValidateInput => _validate; public XmlFileStatus IsValid { - get { return _isValid; } + get => _isValid; private set { if (_isValid == value) { return; @@ -162,10 +159,7 @@ namespace HashingTool.ViewModel.UserControl public ObservableCollection<string> XMLValidationErrors { get; set; } - public ICommand BrowseFileCommand - { - get { return _browseFileCommand; } - } + public ICommand BrowseFileCommand => _browseFileCommand; public ICommand SetXMLFileCommnd { @@ -194,9 +188,8 @@ namespace HashingTool.ViewModel.UserControl private async void BrowseXMLFile() { - string filename; try { - using (var stream = IoService.OpenFileDialog(null, ".xml", "VECTO XML file|*.xml", out filename)) { + using (var stream = IoService.OpenFileDialog(null, ".xml", "VECTO XML file|*.xml", out var filename)) { if (stream == null) { return; } @@ -258,14 +251,14 @@ namespace HashingTool.ViewModel.UserControl public void LogError(string message) { - XMLValidationErrors.Add(String.Format("{0}: {1}", _prefix, message)); + XMLValidationErrors.Add($"{_prefix}: {message}"); } public bool HasContentValidation { get; private set; } public bool? ContentValid { - get { return _contentValid; } + get => _contentValid; set { if (_contentValid == value) { return; @@ -285,9 +278,7 @@ namespace HashingTool.ViewModel.UserControl () => { if (e.ValidationEventArgs == null) { LogError( - string.Format( - "XML file does not validate against a supported version of {0}", - _expectedDocumentType.ToString())); + $"XML file does not validate against a supported version of {_expectedDocumentType.ToString()}"); } else { LogError( string.Format( @@ -299,7 +290,7 @@ namespace HashingTool.ViewModel.UserControl ? Environment.NewLine + e.Exception.InnerException.Message : "") : e.ValidationEventArgs.Message, - e.ValidationEventArgs == null ? 0 : e.ValidationEventArgs.Exception.LineNumber)); + e.ValidationEventArgs?.Exception.LineNumber ?? 0)); } } ); diff --git a/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs b/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs index 5c7a86160fe55ea84581561571817d4228b17136..8e6e5fff620a051a7889cd9156c681592e971dba 100644 --- a/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs +++ b/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs @@ -54,14 +54,11 @@ namespace HashingTool.ViewModel _xmlFile.PropertyChanged += ComponentFilechanged; } - public ICommand ShowHomeViewCommand - { - get { return ApplicationViewModel.HomeView; } - } + public ICommand ShowHomeViewCommand => ApplicationViewModel.HomeView; public string CertificationNumber { - get { return _certificationNumber; } + get => _certificationNumber; private set { if (_certificationNumber == value) return; diff --git a/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs b/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs index 76f3e2cd47e2a0af55a66af1e11c9b717b584fad..cd93f29c03181ee3841b6524d50d2af49353eb62 100644 --- a/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs +++ b/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs @@ -40,14 +40,8 @@ namespace HashingTool.ViewModel public VerifyJobInputDataViewModel() : base("Verify VECTO Job", HashingHelper.IsJobFile, HashingHelper.HashJobFile) {} - public ICommand ShowHomeViewCommand - { - get { return ApplicationViewModel.HomeView; } - } + public ICommand ShowHomeViewCommand => ApplicationViewModel.HomeView; - public XMLFileSelector JobFile - { - get { return _xmlFile; } - } + public XMLFileSelector JobFile => _xmlFile; } } diff --git a/HashingTool/ViewModel/VerifyResultDataViewModel.cs b/HashingTool/ViewModel/VerifyResultDataViewModel.cs index 3b438aaca0fea75f55e3d84933a3b20827b6acaa..cc36f19cb97d49f4c2ee9518e190dc8bc4639c07 100644 --- a/HashingTool/ViewModel/VerifyResultDataViewModel.cs +++ b/HashingTool/ViewModel/VerifyResultDataViewModel.cs @@ -87,31 +87,16 @@ namespace HashingTool.ViewModel } - public string Name - { - get { return "Verify Result Data"; } - } + public string Name => "Verify Result Data"; - public ICommand ShowHomeViewCommand - { - get { return ApplicationViewModel.HomeView; } - } + public ICommand ShowHomeViewCommand => ApplicationViewModel.HomeView; - public VectoJobFile JobFile - { - get { return _jobFile; } - } + public VectoJobFile JobFile => _jobFile; - public CustomerReportXMLFile CustomerReport - { - get { return _customerReport; } - } + public CustomerReportXMLFile CustomerReport => _customerReport; - public ManufacturerReportXMLFile ManufacturerReport - { - get { return _manufacturerReport; } - } + public ManufacturerReportXMLFile ManufacturerReport => _manufacturerReport; public ObservableCollection<VectoXMLFile> Files { get; private set; } diff --git a/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml.cs b/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml.cs index be093a99198faedb633f7853ffc98c6a62f668db..144739de085eed25a5c391af50c2cab9d357b7f3 100644 --- a/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml.cs +++ b/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml.cs @@ -55,8 +55,8 @@ namespace HashingTool.Views public ICollection XMLErrors { - get { return (ICollection)GetValue(XMLErrorsProperty); } - set { SetValue(XMLErrorsProperty, value); } + get => (ICollection)GetValue(XMLErrorsProperty); + set => SetValue(XMLErrorsProperty, value); } public int ErrorCount @@ -68,7 +68,7 @@ namespace HashingTool.Views } return 0; } - set { SetValue(ErrorCountProperty, value); } + set => SetValue(ErrorCountProperty, value); } private void btnCopy_Click(object sender, RoutedEventArgs e) diff --git a/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs b/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs index a560bda97f5fba11f76eca8db32d819a191dd88e..1b163bbdb75e0c37be2f08bb8981cfda72362152 100644 --- a/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs +++ b/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs @@ -52,8 +52,8 @@ namespace HashingTool.Views public XMLFileSelector XMLFile { - get { return (XMLFileSelector)GetValue(XMLFileProperty); } - set { SetValue(XMLFileProperty, value); } + get => (XMLFileSelector)GetValue(XMLFileProperty); + set => SetValue(XMLFileProperty, value); } private void btnDetails_Click(object sender, RoutedEventArgs e) diff --git a/VECTO.sln.DotSettings b/VECTO.sln.DotSettings index 5838ac913881193f6c1c9fcfdc398240c300bd8a..2443e9b1d0456a0103167234864b09daabfcdb3e 100644 --- a/VECTO.sln.DotSettings +++ b/VECTO.sln.DotSettings @@ -125,6 +125,20 @@ <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsWrapperSettingsUpgrader/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EVB_002ECodeStyle_002ESettingsUpgrade_002EVBSpaceAfterUnaryMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EXml_002ECodeStyle_002EFormatSettingsUpgrade_002EXmlMoveToCommonFormatterSettingsUpgrade/@EntryIndexedValue">True</s:Boolean> +<<<<<<< HEAD <s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002A_002Evdri/@EntryIndexedValue">False</s:Boolean> <s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002Evdri/@EntryIndexedValue">False</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=RESS/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> +======= + <s:Boolean x:Key="/Default/UserDictionary/Words/=Graz/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Overspeed/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Padd/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Paux/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Powertrain/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Pwheel/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=RESS/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Underload/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=vair/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=vdri/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Vecto/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> +>>>>>>> develop diff --git a/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb b/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb index 404ba55f17134af57477828df5886f6e3d13dbd3..d615f5d200746f792df9d1bb115a98fde1ef04f6 100644 --- a/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb +++ b/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb @@ -14,18 +14,11 @@ Imports System.ComponentModel Imports System.Windows.Forms Imports System.Drawing Imports System.IO -Imports System.Linq Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON -Imports TUGraz.VectoCore.InputData.Impl Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.Util Imports TUGraz.VectoCore.OutputData.FileIO @@ -807,7 +800,7 @@ Public Class frmAuxiliaryConfig result = BusAuxWriter.SaveAuxConfig(auxConfig, FilePathUtils.ResolveFilePath(aauxPath, auxFile)) ' auxConfig.Save(FilePathUtils.ResolveFilePath(aauxPath, auxFile)) - If Not result Then MessageBox.Show(String.Format("Unable to Save the file '{0}'", auxFile)) + If Not result Then MessageBox.Show($"Unable to Save the file '{auxFile}'") Return result End Function diff --git a/VECTO/BusAuxiliaries/UI/frmCombinedAlternators.vb b/VECTO/BusAuxiliaries/UI/frmCombinedAlternators.vb index 19e457bc1b67911cafdf423136817da16c3a98fa..b854d6d9b3a83801c8de6943a658c63f226b3e5c 100644 --- a/VECTO/BusAuxiliaries/UI/frmCombinedAlternators.vb +++ b/VECTO/BusAuxiliaries/UI/frmCombinedAlternators.vb @@ -310,7 +310,7 @@ Public Class frmCombinedAlternators Select Case gvAlternators.Columns(e.ColumnIndex).Name Case "Delete" - Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete '{0}' ?", alternatorName), "", + Dim dr As DialogResult = MessageBox.Show($"Do you want to delete '{alternatorName}' ?", "", MessageBoxButtons.YesNo) If dr = Windows.Forms.DialogResult.Yes Then 'If combinedAlt.DeleteAlternator(alternatorName, feedback, True) Then @@ -411,9 +411,7 @@ Public Class frmCombinedAlternators combinedAlt.Alternators.Where( Function(f) f.AlternatorName <> altName AndAlso f.AlternatorName = txtAlternatorName.Text).Count > 0 Then MessageBox.Show( - String.Format( - "The lternator '{0}' name you are using to update the alternator '{1}' already exists, operation aborted", - txtAlternatorName.Text, altName)) + $"The alternator '{txtAlternatorName.Text}' name you are using to update the alternator '{altName}' already exists, operation aborted") Return End If diff --git a/VECTO/BusAuxiliaries/UI/frmHVACTool.vb b/VECTO/BusAuxiliaries/UI/frmHVACTool.vb index db4e4d73ed544e5cf44b15ef294908a225866924..fd6426e8fc4f8ae2976d45299cca27f25efadd07 100644 --- a/VECTO/BusAuxiliaries/UI/frmHVACTool.vb +++ b/VECTO/BusAuxiliaries/UI/frmHVACTool.vb @@ -4,12 +4,9 @@ Imports System.ComponentModel Imports System.Drawing Imports System.Globalization Imports System.IO -Imports System.Linq -Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.Util Imports TUGraz.VectoCore.Models.Declaration Imports TUGraz.VectoCore.OutputData.FileIO @@ -1065,7 +1062,7 @@ Public Class frmHVACTool Case "Delete" - Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete benefit '{0}' ?", benefit), "", + Dim dr As DialogResult = MessageBox.Show($"Do you want to delete benefit '{benefit}' ?", "", MessageBoxButtons.YesNo) If dr = Windows.Forms.DialogResult.Yes Then 'If ssmTOOL.TechList.Delete(New TechListBenefitLine With {.BenefitName = benefit, .Category = category}, feedback) _ diff --git a/VECTO/File Browser/FileBrowserDialog.vb b/VECTO/File Browser/FileBrowserDialog.vb index dbc210f44c56a79171843a9cc6e197ca85eace9e..8cc48694109058979b1d1ec28f06a1aabc21b073 100644 --- a/VECTO/File Browser/FileBrowserDialog.vb +++ b/VECTO/File Browser/FileBrowserDialog.vb @@ -11,7 +11,6 @@ Option Infer On Imports System.IO -Imports System.Linq Imports System.Text Imports Microsoft.VisualBasic.FileIO Imports System.Runtime.InteropServices @@ -499,7 +498,7 @@ Public Class FileBrowserDialog TextBoxPath.Text = "" Else If ListViewFiles.SelectedItems.Count > 1 Then - TextBoxPath.Text = String.Format("<{0} Files selected>", ListViewFiles.SelectedItems.Count) + TextBoxPath.Text = $"<{ListViewFiles.SelectedItems.Count} Files selected>" Else TextBoxPath.Text = ListViewFiles.SelectedItems.Item(0).Text TextBoxPath.SelectionStart = TextBoxPath.Text.Length diff --git a/VECTO/GUI/AboutBox.Designer.vb b/VECTO/GUI/AboutBox.Designer.vb index e01ee360b7820748a4c1d3712eb00dc31644cea2..b4d710c38e159301631e1ac33d783e49c7b9287e 100644 --- a/VECTO/GUI/AboutBox.Designer.vb +++ b/VECTO/GUI/AboutBox.Designer.vb @@ -10,7 +10,6 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.ComponentModel Imports Microsoft.VisualBasic.CompilerServices -Imports TUGraz.VECTO.My.Resources <DesignerGenerated()> _ Partial Class AboutBox diff --git a/VECTO/GUI/BatteryForm.vb b/VECTO/GUI/BatteryForm.vb index 44e98bd13d7ebd7a84464631bb6f40308a4ab933..a09bde5f59111a5162cb83fb323881e61a4b619d 100644 --- a/VECTO/GUI/BatteryForm.vb +++ b/VECTO/GUI/BatteryForm.vb @@ -5,14 +5,10 @@ Imports System.IO Imports System.Linq Imports System.Windows.Forms.DataVisualization.Charting Imports TUGraz.VectoCommon.InputData -Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.SimulationComponent.Data Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Battery -Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Imports TUGraz.VectoCore.Utils ' Copyright 2017 European Union. ' Licensed under the EUPL (the 'Licence'); @@ -129,8 +125,7 @@ Public Class BatteryForm Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() - Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html#engine-editor"))) + Process.Start(defaultBrowserPath,$"""file://{Path.Combine(MyAppPath, "User Manual\help.html#engine-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/GUI/BusAuxiliariesEngParametersForm.vb b/VECTO/GUI/BusAuxiliariesEngParametersForm.vb index 422152ca1a55b2248db37232fc07d276b2f322fa..3691148f067ac00255794cf2b8bfdca258d3cb50 100644 --- a/VECTO/GUI/BusAuxiliariesEngParametersForm.vb +++ b/VECTO/GUI/BusAuxiliariesEngParametersForm.vb @@ -1,19 +1,11 @@  -Imports System.Collections.Generic -Imports System.Drawing.Imaging + Imports System.IO Imports System.Linq -Imports System.Windows.Forms.DataVisualization.Charting Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON -Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.SimulationComponent.Data -Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Battery -Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine -Imports TUGraz.VectoCore.Utils ' Copyright 2017 European Union. ' Licensed under the EUPL (the 'Licence'); ' @@ -128,7 +120,7 @@ Public Class BusAuxiliariesEngParametersForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html#engine-editor"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#engine-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/GUI/ElectricMotorForm.Designer.vb b/VECTO/GUI/ElectricMotorForm.Designer.vb index 1bfd1b48fbfb928a4622bd8b5038722f6a856ad3..12c33f543aff4316cd5c2d88d916ef9f66083196 100644 --- a/VECTO/GUI/ElectricMotorForm.Designer.vb +++ b/VECTO/GUI/ElectricMotorForm.Designer.vb @@ -464,9 +464,9 @@ Partial Class ElectricMotorForm Me.lblContTqUnit.AutoSize = true Me.lblContTqUnit.Location = New System.Drawing.Point(182, 8) Me.lblContTqUnit.Name = "lblContTqUnit" - Me.lblContTqUnit.Size = New System.Drawing.Size(24, 13) + Me.lblContTqUnit.Size = New System.Drawing.Size(29, 13) Me.lblContTqUnit.TabIndex = 24 - Me.lblContTqUnit.Text = "[W]" + Me.lblContTqUnit.Text = "[Nm]" ' 'tbContTq ' @@ -604,9 +604,9 @@ Partial Class ElectricMotorForm Me.lblOverloadTqUnit.AutoSize = true Me.lblOverloadTqUnit.Location = New System.Drawing.Point(182, 8) Me.lblOverloadTqUnit.Name = "lblOverloadTqUnit" - Me.lblOverloadTqUnit.Size = New System.Drawing.Size(24, 13) + Me.lblOverloadTqUnit.Size = New System.Drawing.Size(29, 13) Me.lblOverloadTqUnit.TabIndex = 24 - Me.lblOverloadTqUnit.Text = "[W]" + Me.lblOverloadTqUnit.Text = "[Nm]" ' 'tbOverloadTq ' diff --git a/VECTO/GUI/ElectricMotorForm.vb b/VECTO/GUI/ElectricMotorForm.vb index a5ab7cdec231ca8633a010d2014de43fb58641f3..ece27531a97576ee310df851e03b536817367ece 100644 --- a/VECTO/GUI/ElectricMotorForm.vb +++ b/VECTO/GUI/ElectricMotorForm.vb @@ -4,14 +4,11 @@ Imports System.IO Imports System.Linq Imports System.Windows.Forms.DataVisualization.Charting Imports TUGraz.VectoCommon.InputData -Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.Declaration Imports TUGraz.VectoCore.Models.SimulationComponent.Data Imports TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor -Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Imports TUGraz.VectoCore.Utils ' Copyright 2017 European Union. ' Licensed under the EUPL (the 'Licence'); @@ -121,7 +118,7 @@ Public Class ElectricMotorForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html#engine-editor"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#engine-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -178,7 +175,7 @@ Public Class ElectricMotorForm tbInertia.Text = engine.Inertia.ToGUIFormat() tbOverloadTq.Text = If(engine.OverloadTorque?.Value().ToGUIFormat(), "") - tbOvlSpeed.Text = If(engine.OverloadTestSpeed?.Value().ToGUIFormat(), "") + tbOvlSpeed.Text = If(engine.OverloadTestSpeed?.AsRPM.ToGUIFormat(), "") tbOvlTime.Text = engine.OverloadTime.Value().ToGUIFormat() tbContTq.Text = engine.ContinuousTorque.ToGUIFormat() tbRatedSpeed.Text = engine.ContinuousTorqueSpeed.AsRPM.ToGUIFormat() diff --git a/VECTO/GUI/EngineForm.vb b/VECTO/GUI/EngineForm.vb index 0c911de2b4b178b541735e693cc974dfbf17e014..e058b3223b0e79a65d33b23667fc63c2d354481f 100644 --- a/VECTO/GUI/EngineForm.vb +++ b/VECTO/GUI/EngineForm.vb @@ -165,7 +165,7 @@ Public Class EngineForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", path.Combine(MyAppPath, "User Manual\help.html#engine-editor"))) + $"""file://{path.Combine(MyAppPath, "User Manual\help.html#engine-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -593,10 +593,7 @@ Public Class EngineForm series.Name = "Motoring (" & Path.GetFileNameWithoutExtension(TbMAP.Text) & ")" chart.Series.Add(series) - engineCharacteristics += - String.Format("Max. Torque: {0:F0} Nm; Max. Power: {1:F1} kW; n_rated: {2:F0} rpm; n_95h: {3:F0} rpm", - fullLoadCurve.MaxTorque.Value(), fullLoadCurve.MaxPower.Value() / 1000, fullLoadCurve.RatedSpeed.AsRPM, - fullLoadCurve.N95hSpeed.AsRPM) + engineCharacteristics += $"Max. Torque: {fullLoadCurve.MaxTorque.Value():F0} Nm; Max. Power: {(fullLoadCurve.MaxPower.Value()/1000):F1} kW; n_rated: {fullLoadCurve.RatedSpeed.AsRPM:F0} rpm; n_95h: {fullLoadCurve.N95hSpeed.AsRPM:F0} rpm" End If If Not fcMap2 Is Nothing Then diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb index 8081448153cda0389e2628aed595625250397835..d261178ed42e1a51d5c1b723e38b526813b9d858 100644 --- a/VECTO/GUI/GearboxForm.vb +++ b/VECTO/GUI/GearboxForm.vb @@ -182,7 +182,7 @@ Public Class GearboxForm If File.Exists(Path.Combine(MyAppPath,"User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath,"User Manual\help.html#gearbox-editor"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#gearbox-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/GUI/GearboxGearDialog.vb b/VECTO/GUI/GearboxGearDialog.vb index 5a6537aa275d1d1345413622216e50adce16a953..2506e64ff8fa88987a23cde60b73d6f737120b47 100644 --- a/VECTO/GUI/GearboxGearDialog.vb +++ b/VECTO/GUI/GearboxGearDialog.vb @@ -16,7 +16,6 @@ Imports System.Windows.Forms Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.InputData.Reader.ComponentData Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox diff --git a/VECTO/GUI/GraphForm.vb b/VECTO/GUI/GraphForm.vb index fd5b658e2a183fbaf75c547c5fdc15ad6fc5cfe3..5bb42a55d7f5903cba439f0b20878269f54f3e8d 100644 --- a/VECTO/GUI/GraphForm.vb +++ b/VECTO/GUI/GraphForm.vb @@ -13,7 +13,6 @@ Imports System.Collections.Generic Imports System.Drawing.Imaging Imports System.IO Imports System.Linq -Imports System.Text.RegularExpressions Imports System.Windows.Forms.DataVisualization.Charting Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Utils @@ -548,7 +547,7 @@ Public Class GraphForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath,"User Manual\help.html#graph-window"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#graph-window")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/GUI/HybridStrategyParamsForm.vb b/VECTO/GUI/HybridStrategyParamsForm.vb index f7f00c57e19c374dc464c2490f7e8b77798fbc81..c672b3b46e3226aff88d99c30150afc67b6f5762 100644 --- a/VECTO/GUI/HybridStrategyParamsForm.vb +++ b/VECTO/GUI/HybridStrategyParamsForm.vb @@ -1,18 +1,9 @@  -Imports System.Drawing.Imaging + Imports System.IO -Imports System.Linq -Imports System.Windows.Forms.DataVisualization.Charting Imports TUGraz.VectoCommon.InputData -Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON -Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.SimulationComponent.Data -Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Battery -Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine -Imports TUGraz.VectoCore.Utils ' Copyright 2017 European Union. ' Licensed under the EUPL (the 'Licence'); ' @@ -121,7 +112,7 @@ Public Class HybridStrategyParamsForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html#engine-editor"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#engine-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index 62de88d5180c0a27d6d7b0a354dd49030e0bc7bd..b560e734f54aefceae56a062712bdc44b9672b90 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -33,7 +33,6 @@ Imports System.Collections.Generic Imports System.ComponentModel Imports System.IO Imports System.Linq -Imports System.Reflection Imports TUGraz.VectoCore.Models.Simulation.Impl Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports System.Text @@ -49,10 +48,6 @@ Imports TUGraz.VectoCommon.Resources Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore Imports TUGraz.VectoCore.InputData.FileIO.XML -Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration -Imports TUGraz.VectoCore.InputData.FileIO.XML.Engineering -Imports TUGraz.VectoCore.Models.Simulation -Imports TUGraz.VectoCore.Models.Declaration Imports TUGraz.VectoCore.Models.SimulationComponent.Data Imports TUGraz.VectoCore.OutputData Imports TUGraz.VectoCore.OutputData.FileIO @@ -692,7 +687,7 @@ Imports TUGraz.VectoCore.Utils Private Sub UpdateJobTabText() Dim count As Integer = LvGEN.Items.Count - TabPageGEN.Text = String.Format("Job Files ( {0} / {1} )", _genChecked, count) + TabPageGEN.Text = $"Job Files ( {_genChecked} / {count} )" _genCheckAllLock = True @@ -778,7 +773,7 @@ Imports TUGraz.VectoCore.Utils Handles UserManualToolStripMenuItem.Click If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() - Process.Start(defaultBrowserPath, String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html"))) + Process.Start(defaultBrowserPath, $"""file://{Path.Combine(MyAppPath, "User Manual\help.html")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -1055,7 +1050,7 @@ Imports TUGraz.VectoCore.Utils .Message = "Finished Reading Data for job: " + jobFile}) Catch ex As Exception - MsgBox(String.Format("ERROR running job {0}: {1}", jobFile, ex.Message), MsgBoxStyle.Critical) + MsgBox($"ERROR running job {jobFile}: {ex.Message}", MsgBoxStyle.Critical) sender.ReportProgress(0, New VectoProgress With {.Target = "ListBoxError", .Message = ex.Message}) Return End Try @@ -1066,13 +1061,13 @@ Imports TUGraz.VectoCore.Utils sender.ReportProgress(0, New VectoProgress _ With {.Target = "ListBox", - .Message = String.Format("Detected Cycle {0}: {1}", cycle.Name, cycle.CycleType)}) + .Message = $"Detected Cycle {cycle.Name}: {cycle.CycleType}"}) Next sender.ReportProgress(0, New VectoProgress With {.Target = "ListBox", .Message = _ - String.Format("Starting Simulation ({0} Jobs, {1} Runs)", JobFileList.Count, - jobContainer.GetProgress().Count)}) + $"Starting Simulation ({JobFileList.Count} Jobs, {jobContainer.GetProgress().Count _ + } Runs)"}) jobContainer.Execute(True) @@ -1091,14 +1086,8 @@ Imports TUGraz.VectoCore.Utils sender.ReportProgress(Convert.ToInt32((sumProgress*100.0)/progress.Count), New VectoProgress With {.Target = "Status", - .Message = _ - String.Format("Duration: {0:0}s, Current Progress: {1:P} ({2})", duration, - sumProgress/progress.Count, - String.Join(", ", - progress.Select( - Function(pair) _ - String.Format("{0,4:P}", - pair.Value.Progress))))}) + .Message = $"Duration: {duration:0}s, Current Progress: {(sumProgress/progress.Count):P} ({ _ + String.Join(", ", progress.Select(Function(pair) $"{pair.Value.Progress,4:P}"))})"}) Dim justFinished As Dictionary(Of Integer, JobContainer.ProgressEntry) = progress.Where(Function(proc) proc.Value.Done AndAlso Not finishedRuns.Contains(proc.Key)). @@ -1121,9 +1110,7 @@ Imports TUGraz.VectoCore.Utils For Each progressEntry As KeyValuePair(Of Integer, JobContainer.ProgressEntry) In jobContainer.GetProgress() sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", .Message = String.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", - String.Format("{0} {1} {2}", progressEntry.Value.RunName, - progressEntry.Value.CycleName, - progressEntry.Value.RunSuffix), + $"{progressEntry.Value.RunName} {progressEntry.Value.CycleName} {progressEntry.Value.RunSuffix}", progressEntry.Value.Progress, progressEntry.Value.ExecTime/1000.0, IIf(progressEntry.Value.Success, "Success", "Aborted"))}) @@ -1143,9 +1130,7 @@ Imports TUGraz.VectoCore.Utils {w.XMLVTPReportName, "VTP Report"}, {w.XMLMonitoringReportName, "XML Monitoring Report"}} If File.Exists(entry.Key) Then sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", - .Message = - String.Format("{2} for '{0}' written to {1}", Path.GetFileName(job), - entry.Key, entry.Value), + .Message = String.Format("{2} for '{0}' written to {1}", Path.GetFileName(job),entry.Key, entry.Value), .Link = "<XML>" + entry.Key}) End If Next @@ -1153,13 +1138,12 @@ Imports TUGraz.VectoCore.Utils If File.Exists(sumFileWriter.SumFileName) Then sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", - .Message = String.Format("Sum File written to {0}", sumFileWriter.SumFileName), + .Message = $"Sum File written to {sumFileWriter.SumFileName}", .Link = sumFileWriter.SumFileName}) End If sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", - .Message = - String.Format("Simulation Finished in {0:0}s", (DateTime.Now() - start).TotalSeconds)}) + .Message = $"Simulation Finished in {(DateTime.Now() - start).TotalSeconds:0}s"}) #if CERTIFICATION_RELEASE dim message as string = nothing @@ -1201,27 +1185,20 @@ Imports TUGraz.VectoCore.Utils p.Value.RunSuffix + If(Cfg.Mod1Hz, "_1Hz", "")) - Dim runName As String = String.Format("{0} {1} {2}", p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix) + Dim runName As String = $"{p.Value.RunName} {p.Value.CycleName} {p.Value.RunSuffix}" If Not p.Value.Error Is Nothing Then VectoWorkerV3.ReportProgress(0, New VectoProgress With {.Target = "ListBoxError", - .Message = - String.Format("Finished Run {0} with ERROR: {1}", runName, - p.Value.Error.Message), + .Message = $"Finished Run {runName} with ERROR: {p.Value.Error.Message}", .Link = modFilename}) Else - VectoWorkerV3.ReportProgress(0, - New VectoProgress _ - With {.Target = "ListBox", - .Message = String.Format("Finished Run {0} successfully.", runName)}) + VectoWorkerV3.ReportProgress(0, New VectoProgress With {.Target = "ListBox", + .Message = $"Finished Run {runName} successfully."}) End If If (File.Exists(modFilename)) Then VectoWorkerV3.ReportProgress(0, New VectoProgress With {.Target = "ListBox", - .Message = - String.Format("Run {0}: Modal Results written to {1}", runName, - modFilename), .Link = modFilename - }) + .Message = $"Run {runName}: Modal Results written to {modFilename}", .Link = modFilename}) End If Next End Sub diff --git a/VECTO/GUI/Settings.Designer.vb b/VECTO/GUI/Settings.Designer.vb index c524bbe19000e429d379e179aa79f91d0dbc4dc9..730a54d2621bec084afce282a49cd755dc768178 100644 --- a/VECTO/GUI/Settings.Designer.vb +++ b/VECTO/GUI/Settings.Designer.vb @@ -1,6 +1,5 @@ Imports System.ComponentModel Imports Microsoft.VisualBasic.CompilerServices -Imports TUGraz.VECTO.My.Resources <DesignerGenerated()> _ Partial Class Settings diff --git a/VECTO/GUI/Settings.vb b/VECTO/GUI/Settings.vb index edd9fddb68769b45561729780986e1d6ddd888c7..e371c1239469f3e03f7abcc48755732b235130fc 100644 --- a/VECTO/GUI/Settings.vb +++ b/VECTO/GUI/Settings.vb @@ -9,7 +9,6 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.IO -Imports System.Text.RegularExpressions Imports TUGraz.VectoCommon.Utils ''' <summary> @@ -75,7 +74,7 @@ Public Class Settings If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath,"User Manual\help.html#settings"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#settings")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index 785f68654cf1e623f5f7c15235e1ae8345dd89de..ea8d2b071c40946bb083ffb9768ebcf46a27020e 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -382,7 +382,7 @@ Public Class VectoJobForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html#job-editor"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#job-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -1154,9 +1154,9 @@ Public Class VectoJobForm If gearbox Is Nothing Then Return - TbGbxTxt.Text = String.Format("{0}-Speed {1} {2}", gearbox.Gears.Count, gearbox.Type.ShortName(), gearbox.Model) + TbGbxTxt.Text = $"{gearbox.Gears.Count}-Speed {gearbox.Type.ShortName()} {gearbox.Model}" - If Cfg.DeclMode Then + If Cfg.DeclMode Then For i = 1 To gearbox.Gears.Count 'If FLD0.Init(ENG0.Nidle) Then '' use engine from below... @@ -1275,10 +1275,9 @@ Public Class VectoJobForm pmax = fullLoadCurve.MaxPower.Value() / 1000 'FLD0.Pfull(FLD0.EngineRatedSpeed) - TbEngTxt.Text = String.Format("{0} l {1} kw {2}", (engine.Displacement.Value() * 1000).ToString("0.0"), - pmax.ToString("#"), engine.Model) + TbEngTxt.Text = $"{(engine.Displacement.Value()*1000).ToString("0.0")} l {pmax.ToString("#")} kw {engine.Model}" - Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.EngineModes.First().Fuels.First().FuelConsumptionMap) + Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.EngineModes.First().Fuels.First().FuelConsumptionMap) s = New Series s.Points.DataBindXY(fuelConsumptionMap.Entries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), @@ -1305,10 +1304,10 @@ Public Class VectoJobForm chart.Series.Add(s) Dim engineCharacteristics As String = - String.Format("Max. Torque: {0:F0} Nm; Max. Power: {1:F1} kW; n_rated: {2:F0} rpm; n_95h: {3:F0} rpm", - fullLoadCurve.MaxTorque.Value(), fullLoadCurve.MaxPower.Value() / 1000, fullLoadCurve.RatedSpeed.AsRPM, - fullLoadCurve.N95hSpeed.AsRPM) - lblEngineCharacteristics.Text = engineCharacteristics + $"Max. Torque: {fullLoadCurve.MaxTorque.Value():F0} Nm; Max. Power: { _ + (fullLoadCurve.MaxPower.Value()/1000):F1} kW; n_rated: {fullLoadCurve.RatedSpeed.AsRPM:F0} rpm; n_95h: { _ + fullLoadCurve.N95hSpeed.AsRPM:F0} rpm" + lblEngineCharacteristics.Text = engineCharacteristics End Sub Private Sub UpdateVehiclePic() @@ -1353,8 +1352,8 @@ Public Class VectoJobForm PicVehicle.Image = ConvPicPath(HDVclass, False) _ 'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False)) - TbHVCclass.Text = String.Format("HDV Group {0}", HDVclass) - TbVehCat.Text = vehicle.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True) + TbHVCclass.Text = $"HDV Group {HDVclass}" + TbVehCat.Text = vehicle.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True) TbMass.Text = (vehicle.GrossVehicleMassRating.Value() / 1000) & " t" TbAxleConf.Text = vehicle.AxleConfiguration.GetName() 'ConvAxleConf(VEH0.AxleConf) End Sub diff --git a/VECTO/GUI/VectoVTPJobForm.vb b/VECTO/GUI/VectoVTPJobForm.vb index 828de00c9c791af6bd90786996d037c764ea13e2..6e347e7d6f4c143cd60f2b95721952e26bee70aa 100644 --- a/VECTO/GUI/VectoVTPJobForm.vb +++ b/VECTO/GUI/VectoVTPJobForm.vb @@ -135,7 +135,7 @@ Public Class VectoVTPJobForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath,"User Manual\help.html#job-editor"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#job-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -583,7 +583,7 @@ Public Class VectoVTPJobForm If gearbox Is Nothing Then Return - TbGbxTxt.Text = String.Format("{0}-Speed {1} {2}", gearbox.Gears.Count, gearbox.Type.ShortName(), gearbox.Model) + TbGbxTxt.Text = $"{gearbox.Gears.Count}-Speed {gearbox.Type.ShortName()} {gearbox.Model}" End Sub Private Sub UpdateEnginePic(ByRef chart As Chart) @@ -644,8 +644,7 @@ Public Class VectoVTPJobForm pmax = fullLoadCurve.MaxPower.Value()/1000 'FLD0.Pfull(FLD0.EngineRatedSpeed) - TbEngTxt.Text = String.Format("{0} l {1} kw {2}", (engine.Displacement.Value()*1000).ToString("0.0"), - pmax.ToString("#"), engine.Model) + TbEngTxt.Text = $"{(engine.Displacement.Value()*1000).ToString("0.0")} l {pmax.ToString("#")} kw {engine.Model}" Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.EngineModes.First().Fuels.First().FuelConsumptionMap) @@ -659,10 +658,9 @@ Public Class VectoVTPJobForm chart.Series.Add(s) Dim engineCharacteristics As String = - String.Format("Max. Torque: {0:F0} Nm; Max. Power: {1:F1} kW; n_rated: {2:F0} rpm; n_95h: {3:F0} rpm", - fullLoadCurve.MaxTorque.Value(), fullLoadCurve.MaxPower.Value()/1000, - fullLoadCurve.RatedSpeed.AsRPM, - fullLoadCurve.N95hSpeed.AsRPM) + $"Max. Torque: {fullLoadCurve.MaxTorque.Value():F0} Nm; Max. Power: { _ + (fullLoadCurve.MaxPower.Value()/1000):F1} kW; n_rated: {fullLoadCurve.RatedSpeed.AsRPM:F0} rpm; n_95h: { _ + fullLoadCurve.N95hSpeed.AsRPM:F0} rpm" lblEngineCharacteristics.Text = engineCharacteristics End Sub @@ -703,7 +701,7 @@ Public Class VectoVTPJobForm PicVehicle.Image = ConvPicPath(HDVclass, False) _ 'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False)) - TbHVCclass.Text = String.Format("HDV Group {0}", HDVclass) + TbHVCclass.Text = $"HDV Group {HDVclass}" TbVehCat.Text = vehicle.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True) TbMass.Text = (vehicle.GrossVehicleMassRating.Value()/1000) & " t" TbAxleConf.Text = vehicle.AxleConfiguration.GetName() 'ConvAxleConf(VEH0.AxleConf) diff --git a/VECTO/GUI/VehicleAuxiliariesDialog.Designer.vb b/VECTO/GUI/VehicleAuxiliariesDialog.Designer.vb index 62070078e062f14b95e310119d12a58e06aa70fe..5db90ec58a56da973e5f2d5decf6daa7203889ca 100644 --- a/VECTO/GUI/VehicleAuxiliariesDialog.Designer.vb +++ b/VECTO/GUI/VehicleAuxiliariesDialog.Designer.vb @@ -10,7 +10,6 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.ComponentModel Imports Microsoft.VisualBasic.CompilerServices -Imports TUGraz.VECTO.My.Resources <DesignerGenerated()> _ Partial Class VehicleAuxiliariesDialog diff --git a/VECTO/GUI/VehicleAuxiliariesDialog.vb b/VECTO/GUI/VehicleAuxiliariesDialog.vb index c9bc543bf0c89976a647d12412bcdb74fb65f938..86f073055b8b71496ecde051b781fbba32ac716a 100644 --- a/VECTO/GUI/VehicleAuxiliariesDialog.vb +++ b/VECTO/GUI/VehicleAuxiliariesDialog.vb @@ -13,7 +13,6 @@ Option Infer On Imports System.Linq Imports System.Windows.Forms Imports TUGraz.VectoCommon.Models -Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.Models.Declaration diff --git a/VECTO/GUI/VehicleAxleDialog.vb b/VECTO/GUI/VehicleAxleDialog.vb index f4d93b0e3450f45c60c33cd288de74c59324fa99..6be084378d58d2ebb4cbbc6909d75bd1b91fbd86 100644 --- a/VECTO/GUI/VehicleAxleDialog.vb +++ b/VECTO/GUI/VehicleAxleDialog.vb @@ -18,7 +18,6 @@ Imports System.Linq Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.InputData.Impl Imports TUGraz.VectoCore.Models.Declaration diff --git a/VECTO/GUI/VehicleForm.vb b/VECTO/GUI/VehicleForm.vb index 30cc6872eae4f881473d70aa472aaa5d80f26e09..800a4f30475892f273c28ae7ba8b0b10ba5f20af 100644 --- a/VECTO/GUI/VehicleForm.vb +++ b/VECTO/GUI/VehicleForm.vb @@ -13,14 +13,12 @@ Imports System.Collections.Generic Imports System.IO Imports System.Linq -Imports System.Text.RegularExpressions Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Impl Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.SimulationComponent.Data ''' <summary> ''' Vehicle Editor. @@ -302,7 +300,7 @@ Public Class VehicleForm If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() Process.Start(defaultBrowserPath, - String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html#vehicle-editor"))) + $"""file://{Path.Combine(MyAppPath, "User Manual\help.html#vehicle-editor")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/GUI/WelcomeDialog.vb b/VECTO/GUI/WelcomeDialog.vb index 75a9ae4dc246dcfb7d52e1a586db0078f13cd532..916fb0b2ce060041e58549d12cebf397cb969c86 100644 --- a/VECTO/GUI/WelcomeDialog.vb +++ b/VECTO/GUI/WelcomeDialog.vb @@ -9,7 +9,6 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.IO -Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.Utils ''' <summary> @@ -41,7 +40,7 @@ Public Class WelcomeDialog Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If File.Exists(Path.Combine(MyAppPath, "User Manual\help.html")) Then Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath() - Process.Start(defaultBrowserPath, String.Format("""file://{0}""", Path.Combine(MyAppPath, "User Manual\help.html"))) + Process.Start(defaultBrowserPath, $"""file://{Path.Combine(MyAppPath, "User Manual\help.html")}""") Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If diff --git a/VECTO/Input Files/Battery.vb b/VECTO/Input Files/Battery.vb index d44d9888c0626bccfec7525210a52ee597f16b4e..e1923b4a0c0540f21da66f60f4cfba116cd59926 100644 --- a/VECTO/Input Files/Battery.vb +++ b/VECTO/Input Files/Battery.vb @@ -8,7 +8,6 @@ Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.Models.SimulationComponent.Data Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Battery Imports TUGraz.VectoCore.Utils @@ -203,7 +202,7 @@ Public Class Battery End Property Public ReadOnly Property CertificationNumber As String Implements IComponentInputData.CertificationNumber Get - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property Public ReadOnly Property DigestValue As DigestData Implements IComponentInputData.DigestValue diff --git a/VECTO/Input Files/ElectricMachine.vb b/VECTO/Input Files/ElectricMachine.vb index d19172a9789d1ceb122087e88c38ecdc73add5ec..e67059c6e868c7c51cc2305c8d321aaeb6e16719 100644 --- a/VECTO/Input Files/ElectricMachine.vb +++ b/VECTO/Input Files/ElectricMachine.vb @@ -7,9 +7,6 @@ Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.SimulationComponent Imports TUGraz.VectoCore.Models.SimulationComponent.Data Imports TUGraz.VectoCore.Utils @@ -189,7 +186,7 @@ Public Class ElectricMachine End Property Public ReadOnly Property CertificationNumber As String Implements IComponentInputData.CertificationNumber Get - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property Public ReadOnly Property DigestValue As DigestData Implements IComponentInputData.DigestValue diff --git a/VECTO/Input Files/Engine.vb b/VECTO/Input Files/Engine.vb index 22992910309679fb26be528ee45ef286d74f417a..62bb68afdce76805f448c577fc0090f8a757943c 100644 --- a/VECTO/Input Files/Engine.vb +++ b/VECTO/Input Files/Engine.vb @@ -13,7 +13,6 @@ Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq Imports System.Xml -Imports Newtonsoft.Json.Linq Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Exceptions @@ -267,7 +266,7 @@ Public Class Engine Public ReadOnly Property Manufacturer As String Implements IComponentInputData.Manufacturer Get ' Just for the interface. Value is not available in GUI yet. - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property @@ -292,7 +291,7 @@ Public Class Engine Public ReadOnly Property CertificationNumber As String Implements IComponentInputData.CertificationNumber Get ' Just for the interface. Value is not available in GUI yet. - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index 317fdaaa86da67c5f78b3aa552b9f9c4cf419bab..871ee38e8f8c6e34ede42617e054ffc37d8c5e05 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -351,7 +351,7 @@ Public Class Gearbox Public ReadOnly Property Manufacturer As String Implements IComponentInputData.Manufacturer Get ' Just for the interface. Value is not available in GUI yet. - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property @@ -378,7 +378,7 @@ Public Class Gearbox Public ReadOnly Property CertificationNumber As String Implements IComponentInputData.CertificationNumber Get ' Just for the interface. Value is not available in GUI yet. - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property diff --git a/VECTO/Input Files/HybridStrategyParams.vb b/VECTO/Input Files/HybridStrategyParams.vb index a7dae0588f99a6e0f714445d82c790bd8f4b7ec3..e2bac2b5b7aa66bea927884b0773780e6fa801a2 100644 --- a/VECTO/Input Files/HybridStrategyParams.vb +++ b/VECTO/Input Files/HybridStrategyParams.vb @@ -2,7 +2,6 @@ Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq -Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils diff --git a/VECTO/Input Files/SuperCap.vb b/VECTO/Input Files/SuperCap.vb index b3354b548244f3cf6521d94760e094ea04c577c1..efeadb4c0eca19d4de31d6f41e534cb0e285061d 100644 --- a/VECTO/Input Files/SuperCap.vb +++ b/VECTO/Input Files/SuperCap.vb @@ -82,7 +82,7 @@ Public Class SuperCap End Property Public ReadOnly Property CertificationNumber As String Implements IComponentInputData.CertificationNumber Get - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property Public ReadOnly Property DigestValue As DigestData Implements IComponentInputData.DigestValue diff --git a/VECTO/Input Files/VectoEPTPJob.vb b/VECTO/Input Files/VectoEPTPJob.vb index b4de68efadcafe26ee374866b29c6b0540706f38..ebe6a6293960996d935e4b2a0fcd9bd9666bcd07 100644 --- a/VECTO/Input Files/VectoEPTPJob.vb +++ b/VECTO/Input Files/VectoEPTPJob.vb @@ -3,7 +3,6 @@ Imports System.Collections.Generic Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq -Imports System.Xml Imports Ninject Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.Exceptions @@ -12,9 +11,7 @@ Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore -Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.FileIO.XML -Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration Imports TUGraz.VectoCore.InputData.Impl Imports TUGraz.VectoCore.Models.Declaration Imports TUGraz.VectoCore.Utils diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index 4254f25dd2af3c01d9480c5d6afce72f3f78c89c..654e6e209cc6a48951f30227f67a13e65664b543 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -15,7 +15,6 @@ Imports System.Collections.Generic Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq -Imports System.Text Imports System.Xml.Linq Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.Exceptions diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index c2259f8da151268f021b380cb99c489f3220deb8..461806f4af203971f63d252c74479b56ec4e8a7e 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -20,7 +20,6 @@ Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Impl Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter Imports TUGraz.VectoCore.Models.Declaration @@ -305,14 +304,14 @@ Public Class Vehicle Public ReadOnly Property Manufacturer As String Implements IComponentInputData.Manufacturer Get ' Just for the interface. Value is not available in GUI yet. - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property Public ReadOnly Property Model As String Implements IComponentInputData.Model Get ' Just for the interface. Value is not available in GUI yet. - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property @@ -338,7 +337,7 @@ Public Class Vehicle Public ReadOnly Property CertificationNumber As String Implements IComponentInputData.CertificationNumber Get ' Just for the interface. Value is not available in GUI yet. - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property @@ -376,7 +375,7 @@ Public Class Vehicle Public ReadOnly Property VIN As String Implements IVehicleDeclarationInputData.VIN Get - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property @@ -408,7 +407,7 @@ Public Class Vehicle Public ReadOnly Property ManufacturerAddress As String Implements IVehicleDeclarationInputData.ManufacturerAddress Get - Return TUGraz.VectoCore.Configuration.Constants.NOT_AVailABLE + Return TUGraz.VectoCore.Configuration.Constants.NOT_AVAILABLE End Get End Property diff --git a/VECTO/My Project/Resources.Designer.vb b/VECTO/My Project/Resources.Designer.vb index 18e818830ce2c76c8432566cec85871f45d265ff..ac8c679590fa4fdaea25570214d4e2389169657e 100644 --- a/VECTO/My Project/Resources.Designer.vb +++ b/VECTO/My Project/Resources.Designer.vb @@ -11,7 +11,6 @@ Option Strict On Option Explicit On -Imports System Namespace My.Resources diff --git a/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb b/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb index 6183be0eeb3262df5143b97c1cf215c95097675c..05de179604b4cb0e122f3ff5c4b555e4e400e5e5 100644 --- a/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb +++ b/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb @@ -5,7 +5,6 @@ Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader.ComponentData Imports TUGraz.VectoCore.Models.BusAuxiliaries Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Namespace IntegrationTests <TestFixture> diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb index 03712ad620c5936d2943be4a2e916751a61466bb..e17a389cf2b0e8347a65c48b29798c80b296aaf9 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb @@ -1,8 +1,6 @@  Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics Namespace Mocks diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb index 41f60531186a2a5c45b089e2de515853035ee905..78ed9431f2a2809be147bae679eecc4aa4558c05 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb @@ -1,7 +1,5 @@  -Imports System.ComponentModel -Imports TUGraz.VectoCommon.BusAuxiliaries -Imports TUGraz.VectoCommon.Utils + Namespace Mocks 'Public Class ElectricalConsumerMock diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb index cf279b7bcf2c2f1c5074d497e89d4d98d32139f4..0f064bb5a9cb4352d275abe8c5542b397418038e 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb @@ -1,7 +1,6 @@  Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.Models.Declaration Public Class MockFuel50PC Implements IFuelConsumptionMap diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb index 2675bc3e2b12373fed208c08c1d51315a813ee5c..1a412cd89e3438d850b5567faa0daa56ef5d7986 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb @@ -3,9 +3,6 @@ Imports NUnit.Framework Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb index 317f91ab48a995833fccb14330a975867cba1762..c8acb0f2d1657496bf4f724d43247770c8f20ccd 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb @@ -3,13 +3,8 @@ Imports System.IO Imports NUnit.Framework Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.Configuration -Imports TUGraz.VectoCore.Models.BusAuxiliaries Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces -Imports TUGraz.VectoCore.Models.Declaration Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentPersistanceTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentPersistanceTests.vb index 3bd686beafe0a69e60185d0bdc536328e617f6f5..1f71a3b9d7885b69defc63c2802e85f3ee4dd500 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentPersistanceTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentPersistanceTests.vb @@ -3,7 +3,6 @@ Imports System.IO Imports NUnit.Framework Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCore.InputData.FileIO.JSON -Imports TUGraz.VectoCore.Models.BusAuxiliaries Imports TUGraz.VectoCore.OutputData.FileIO diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb index 1284027f43e81c021c810ac7a1174c12185164ca..a997f9f13fa3d49048be8324b145639a2c3209f5 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb @@ -7,11 +7,8 @@ Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.Reader.ComponentData Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter Imports TUGraz.VectoCore.Models.BusAuxiliaries -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces -Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.Simulation.Data Imports TUGraz.VectoCore.Models.SimulationComponent.Data Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb index 595db1d73d3ad3ee550e3acb65df27faf0d74cec..8cdba6dc628892520e6ee82c2d3a8250dd12c3c9 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb @@ -3,11 +3,9 @@ Imports NUnit.Framework Imports TUGraz.VectoCommon.Utils Imports System.IO -Imports Newtonsoft.Json Imports TUGraz.VectoCore.InputData.Reader.ComponentData Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics -Imports TUGraz.VectoCore.Models.Declaration Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb index f2a8cdc1af1bad101694ecda9f54a0dc3dc8ea43..bc542b6bff41505c91bea17b7c5881c49919fd48 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb @@ -4,7 +4,6 @@ Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb index 3127a6ddc389019e4612f46d450e217626012951..2a23c7904dfc85ded9931533e125729245a424f6 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb @@ -1,11 +1,6 @@  Imports System.IO Imports NUnit.Framework -Imports TUGraz.VectoCommon.BusAuxiliaries -Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.Models.BusAuxiliaries -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics -Imports TUGraz.VectoCore.Models.Declaration <TestFixture()> diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb index b1c9d3c1fd7b80c99e582563cf436460e9341e66..372e0a0aa296ce3ee57c212e4a0a9124325e4bb4 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb @@ -1,9 +1,6 @@  Imports NUnit.Framework -Imports TUGraz.VectoCore.Configuration -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics Namespace UnitTests <TestFixture()> diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb index 738ccbab2a5ee479e21364ba17090a6f7131a0cd..650de6b3c1d4152f434338e42b27cb8097d55efc 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb @@ -1,20 +1,14 @@ Imports System.IO Imports NUnit.Framework Imports TUGraz.VectoCommon.BusAuxiliaries -Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON -Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC -Imports TUGraz.VectoCore.Models.SimulationComponent.Data Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb index d105b72d978cf37c95db18b485f302bdc3275675..cb275e66c2bef27a80f0c53e3691c7ba5c780264 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb @@ -6,7 +6,6 @@ Imports TUGraz.VectoCore.InputData.Reader.ComponentData Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC Imports Signals = TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.Signals diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb index 7d1f1d15ac99522915e510f77a7f8e95c13c0742..5d00a7e2810723ad556cf4fcafec0d696ad50065 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb @@ -4,7 +4,6 @@ Imports Moq Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb index 242b1cfa23b98281e55b03a4a7677e7a3de805b6..09fa2496066e4769e617a75fb719e09ca2d0be35 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb @@ -5,17 +5,11 @@ Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC -Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.SimulationComponent.Data Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb index a70794170c160c78634e30919418d7ca1351e8b9..db3991edd8a74e4a4712eceae37521514ec0230e 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb @@ -5,16 +5,11 @@ Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC -Imports TUGraz.VectoCore.Models.SimulationComponent.Data Namespace UnitTests diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb index 5df16ed012dcd9bf82da94ce42c222b1a890fd89..1fbe62b3dbd8b60472f53a9b8144b5ea856ae0ea 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb @@ -3,17 +3,13 @@ Imports System.IO Imports NUnit.Framework Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC Imports TUGraz.VectoCore.Models.Declaration -Imports TUGraz.VectoCore.Models.SimulationComponent.Data Namespace UnitTests <TestFixture()> diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb index 807df02d177ef792fa7dac624ac10f478615fe44..cb891fb1ed93cff7ca57b84b370143e97bde8752 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb @@ -4,7 +4,6 @@ Imports Moq Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/PneumaticActuationsMapTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/PneumaticActuationsMapTests.vb index 4381f932ec2056acf6eaf5ea3bff7836915f326e..9c11434d3576a119d79d0916e82bd6a5f2298ec9 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/PneumaticActuationsMapTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/PneumaticActuationsMapTests.vb @@ -1,10 +1,8 @@  Imports NUnit.Framework Imports System.IO -Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCore.InputData.Reader.ComponentData -Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics Namespace Pneumatics <TestFixture()> diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb index a2c8195bc288abf46750a4bb63b1bf9d2ee8a0f9..6246be2f4eaf64be7e9eec8f9be92d31b7aad0a2 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb @@ -5,7 +5,6 @@ Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON -Imports TUGraz.VectoCore.InputData.Reader.ComponentData Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.HVAC diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/Utils.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/Utils.vb index 9bcf3b9f811f9730537501cd7711db352278ed92..1ac1af2911b8bad8de87d356e68a84fb1771a0ad 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/Utils.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/Utils.vb @@ -7,7 +7,6 @@ Imports TUGraz.VectoCore.Models.BusAuxiliaries Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC Imports TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics -Imports TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Imports TUGraz.VectoCore.Models.Declaration Imports TUGraz.VectoCore.Models.SimulationComponent.Data diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index e643884fb20226ba65ef2781423d63e64baaa711..87e4208c309831e89ab666fc92042f20381a571e 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -85,10 +85,7 @@ namespace TUGraz.VectoCommon.InputData public string SourceVersion { get; set; } - public string SourcePath - { - get { return SourceFile != null ? Path.GetDirectoryName(Path.GetFullPath(SourceFile)) : null; } - } + public string SourcePath => SourceFile != null ? Path.GetDirectoryName(Path.GetFullPath(SourceFile)) : null; } public interface IVehicleDeclarationInputData : IComponentInputData diff --git a/VectoCommon/VectoCommon/Models/AlternatorType.cs b/VectoCommon/VectoCommon/Models/AlternatorType.cs index 5419938e1c226828a48b93de5891a0eb01f1797c..7ed133da17a6fbe4bfdcad4aea8b3648380d96a1 100644 --- a/VectoCommon/VectoCommon/Models/AlternatorType.cs +++ b/VectoCommon/VectoCommon/Models/AlternatorType.cs @@ -24,7 +24,7 @@ namespace TUGraz.VectoCommon.Models return "no alternator"; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); - }; + } } public static string GetLabel(this AlternatorType type) diff --git a/VectoCommon/VectoCommon/Models/GearshiftPosition.cs b/VectoCommon/VectoCommon/Models/GearshiftPosition.cs index be262755f4401675da2efa43d35cefeebc203f25..2d8e6983f160c737608b267c9350d85f2a1a9ce6 100644 --- a/VectoCommon/VectoCommon/Models/GearshiftPosition.cs +++ b/VectoCommon/VectoCommon/Models/GearshiftPosition.cs @@ -24,17 +24,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return Name; } - public string Name - { - get { - return $"{Gear}{(Gear == 0 ? "" : (TorqueConverterLocked.HasValue ? (TorqueConverterLocked.Value ? "L" : "C") : ""))}"; - } - } + public string Name => $"{Gear}{(Gear == 0 ? "" : (TorqueConverterLocked.HasValue ? (TorqueConverterLocked.Value ? "L" : "C") : ""))}"; - public bool Engaged - { - get { return Gear != 0; } - } + public bool Engaged => Gear != 0; public override bool Equals(object x) { diff --git a/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs b/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs index 7d508a59c2aaf810e2358b9b1df09c849187749b..b2a328ef07f269023ee673192327a9702ce807da 100644 --- a/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs +++ b/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs @@ -44,14 +44,9 @@ namespace TUGraz.VectoCommon.Models { public IResponse Response { get; set; } - public double Score - { - get - { - return (FuelCosts + EquivalenceFactor * (BatCosts + ICEStartPenalty1) * SoCPenalty + ICEStartPenalty2 + - RampUpPenalty) / GearshiftPenalty; - } - } + public double Score => + (FuelCosts + EquivalenceFactor * (BatCosts + ICEStartPenalty1) * SoCPenalty + ICEStartPenalty2 + + RampUpPenalty) / GearshiftPenalty; public double FuelCosts { get; set; } diff --git a/VectoCommon/VectoCommon/Models/IResponse.cs b/VectoCommon/VectoCommon/Models/IResponse.cs index 58f31382fea8bed036428516c871c276a83ed73e..15984e37ff64f469a95d3031c59a3b431becf25d 100644 --- a/VectoCommon/VectoCommon/Models/IResponse.cs +++ b/VectoCommon/VectoCommon/Models/IResponse.cs @@ -44,8 +44,7 @@ namespace TUGraz.VectoCommon.Models public override string ToString() { var t = GetType(); - return string.Format("{0}{{{1}}}", t.Name, - string.Join(", ", t.GetProperties().Select(p => string.Format("{0}: {1}", p.Name, p.GetValue(this))))); + return $"{t.Name}{{{string.Join(", ", t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}"))}}}"; } } diff --git a/VectoCommon/VectoCommon/Models/LoggingObject.cs b/VectoCommon/VectoCommon/Models/LoggingObject.cs index 671fdd5ceb4c5341ec9c927045fbd4032d130225..3792016149502efda3d321da952530ff9c50db8e 100644 --- a/VectoCommon/VectoCommon/Models/LoggingObject.cs +++ b/VectoCommon/VectoCommon/Models/LoggingObject.cs @@ -68,8 +68,8 @@ namespace TUGraz.VectoCommon.Models public static bool LogEnabled { - get { return _logEnabled.Value; } - set { _logEnabled.Value = value; } + get => _logEnabled.Value; + set => _logEnabled.Value = value; } private readonly Logger _log; @@ -189,9 +189,6 @@ namespace TUGraz.VectoCommon.Models } } - protected LoggingObject Log - { - get { return this; } - } + protected LoggingObject Log => this; } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Models/OperatingPoint.cs b/VectoCommon/VectoCommon/Models/OperatingPoint.cs index 97b7858fb60f3e5d4224471ef98fa0e90e9205c0..ec6565b5c814fa13d4711c4f4ff1148e89c0f8c5 100644 --- a/VectoCommon/VectoCommon/Models/OperatingPoint.cs +++ b/VectoCommon/VectoCommon/Models/OperatingPoint.cs @@ -55,7 +55,7 @@ namespace TUGraz.VectoCommon.Models public override string ToString() { - return string.Format("a: {0}, dt: {1}, ds: {2}", Acceleration, SimulationInterval, SimulationDistance); + return $"a: {Acceleration}, dt: {SimulationInterval}, ds: {SimulationDistance}"; } } diff --git a/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs b/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs index fa5f6a62c8477d34bbd4f9ec80b3a4607de4ae75..f728d8ed7886209d96d6e5220a1dd46571b4d273 100644 --- a/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs +++ b/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs @@ -15,8 +15,7 @@ namespace TUGraz.VectoCommon.Models { public override string ToString() { - return string.Format("n_out: {0}, n_in: {1}, tq_out: {2}, tq_in {3}, nu: {4}, my: {5}", OutAngularVelocity, - InAngularVelocity, OutTorque, InTorque, SpeedRatio, TorqueRatio); + return $"n_out: {OutAngularVelocity}, n_in: {InAngularVelocity}, tq_out: {OutTorque}, tq_in {InTorque}, nu: {SpeedRatio}, my: {TorqueRatio}"; } } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs index ec23fbdfbde32334ce94b3e2091c375f60fec1ac..f910671d7f185611ba557de40a23dc012fb82553 100644 --- a/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs @@ -77,7 +77,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsRelativeEqual(this double expected, double actual, - double toleranceFactor = DoubleExtensionMethods.ToleranceFactor) + double toleranceFactor = ToleranceFactor) { if (double.IsNaN(expected)) { return double.IsNaN(actual); diff --git a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs index 91fc0e370f766495a5f96e2b0aae6654199bce5c..71ce8990d59211bd8d31b4e49ab1fc450bf5794d 100644 --- a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs @@ -163,8 +163,7 @@ namespace TUGraz.VectoCommon.Utils /// <example>GetSection(data => data.X < searchedX); //returns the pair where first < searchedX and second >= searchedX</example>> public static Tuple<T, T> GetSection<T>(this IEnumerable<T> self, Func<T, bool> predicate, string message = null) { - int unused; - return self.GetSection(predicate, out unused, message); + return self.GetSection(predicate, out var unused, message); } public static TSource MinBy<TSource>(this IEnumerable<TSource> source, diff --git a/VectoCommon/VectoCommon/Utils/SI.cs b/VectoCommon/VectoCommon/Utils/SI.cs index 20f87411af63df03583ad3aa8359576c6c2c879f..8a17596554c75fb33b6a808f768e664d7eff6000 100644 --- a/VectoCommon/VectoCommon/Utils/SI.cs +++ b/VectoCommon/VectoCommon/Utils/SI.cs @@ -106,7 +106,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private Newton(double val) : base(val, Units) { } - public override string UnitString { get { return "N"; } } + public override string UnitString => "N"; [DebuggerHidden] public static NewtonMeter operator *(Newton newton, Meter meter) @@ -261,7 +261,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private KilogramPerMeter(double val) : base(val, Units) { } - public override string UnitString { get { return "kg/m"; } } + public override string UnitString => "kg/m"; public static KilogramPerMeterMass operator /(KilogramPerMeter kpm, Kilogram kg) { @@ -283,7 +283,7 @@ namespace TUGraz.VectoCommon.Utils private LiterPerSecond(double val) : base(val, 0.001, Units) { } - public override string UnitString { get { return "l/s"; } } + public override string UnitString => "l/s"; [DebuggerHidden] public static Liter operator *(LiterPerSecond l, Second second) @@ -370,7 +370,7 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private Liter(double val) : base(val , 0.001, Units) { } - public override string UnitString { get { return "l"; } } + public override string UnitString => "l"; public static Kilogram operator *(Liter liter, KilogramPerCubicMeter kilogramPerCubicMeter) { @@ -388,7 +388,7 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private NormLiter(double val) : base(val , 0.001, Units) { } - public override string UnitString { get { return "Nl"; } } + public override string UnitString => "Nl"; public static NormLiterPerSecond operator /(NormLiter nl, Second s) { @@ -403,7 +403,7 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private NormLiterPerKilogram(double val) : base(val , 0.001, Units) { } - public override string UnitString { get { return "Nl/kg"; } } + public override string UnitString => "Nl/kg"; public static NormLiter operator *(NormLiterPerKilogram nlpkg, Kilogram kg) { @@ -419,7 +419,7 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private NormLiterPerKilogramMeter(double val) : base(val , 0.001, Units) { } - public override string UnitString { get { return "Nl/kgm"; } } + public override string UnitString => "Nl/kgm"; public static NormLiterPerKilogram operator *(NormLiterPerKilogramMeter nlpkgm, Meter m) { @@ -437,7 +437,7 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private NormLiterPerSecond(double val) : base(val, 0.001, Units) { } - public override string UnitString { get { return "Nl/s"; } } + public override string UnitString => "Nl/s"; public static NormLiter operator *(NormLiterPerSecond nips, Second s) { @@ -557,7 +557,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private KilogramPerCubicMeter(double value) : base(value, Units) { } - public override string UnitString { get { return "kg/m^3"; } } + public override string UnitString => "kg/m^3"; [DebuggerHidden] public static Kilogram operator *(KilogramPerCubicMeter kilogramPerCubicMeter, CubicMeter cubicMeter) @@ -578,7 +578,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private KilogramPerWattSecond(double val) : base(val, Units) { } - public override string UnitString { get { return "kg/Ws"; } } + public override string UnitString => "kg/Ws"; public static Kilogram operator *(KilogramPerWattSecond kpws, WattSecond ws) { @@ -597,7 +597,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private WattSecond(double val) : base(val, Units) { } - public override string UnitString { get { return "Ws"; } } + public override string UnitString => "Ws"; [DebuggerHidden] public static Watt operator /(WattSecond wattSecond, Second second) @@ -632,7 +632,7 @@ namespace TUGraz.VectoCommon.Utils private WattPerKelvinSquareMeter(double val) : base(val, Units) { } - public override string UnitString { get { return "W/Km^2"; } } + public override string UnitString => "W/Km^2"; } public class WattPerSquareMeter : SIBase<WattPerSquareMeter> @@ -646,7 +646,7 @@ namespace TUGraz.VectoCommon.Utils { return SIBase<Watt>.Create(wpsqm.Val * sqm.Value()); } - public override string UnitString { get { return "W/m^2"; } } + public override string UnitString => "W/m^2"; } @@ -657,7 +657,7 @@ namespace TUGraz.VectoCommon.Utils private WattPerCubicMeter(double val) : base(val, Units) { } - public override string UnitString { get { return "W/m^3"; } } + public override string UnitString => "W/m^3"; public static Watt operator *(WattPerCubicMeter wpcm, CubicMeter cm) { @@ -675,7 +675,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private Watt(double val) : base(val, Units) { } - public override string UnitString { get { return "W"; } } + public override string UnitString => "W"; /// <summary> /// Implements the operator /. @@ -747,7 +747,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private Joule(double val) : base(val, Units) { } - public override string UnitString { get { return "J"; } } + public override string UnitString => "J"; public static implicit operator Joule(WattSecond self) { @@ -782,10 +782,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private JoulePerNormLiter(double val) : base(val, Units) { } - public override string UnitString - { - get { return "J/Nl"; } - } + public override string UnitString => "J/Nl"; public static Watt operator *(JoulePerNormLiter jpnl, NormLiterPerSecond nlps) { @@ -802,7 +799,7 @@ namespace TUGraz.VectoCommon.Utils private JoulePerKilogramm(double val) : base(val, Units) { } - public override string UnitString { get { return "J/kg"; } } + public override string UnitString => "J/kg"; public static Joule operator *(Kilogram kg, JoulePerKilogramm jpg) { @@ -839,7 +836,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private JoulePerMeter(double val) : base(val, Units) { } - public override string UnitString { get { return "J/m"; } } + public override string UnitString => "J/m"; public static KilogramPerMeter operator /(JoulePerMeter jpm, JoulePerKilogramm jpkg) { @@ -869,10 +866,7 @@ namespace TUGraz.VectoCommon.Utils return SIBase<MeterPerSecond>.Create(perSecond.Val * meter.Value()); } - public double AsRPM - { - get { return Val * 60 / (2 * Math.PI); } - } + public double AsRPM => Val * 60 / (2 * Math.PI); } /// <summary> @@ -886,10 +880,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private MeterPerSecond(double val) : base(val, Units) { } - public double AsKmph - { - get { return Val * 3.6; } - } + public double AsKmph => Val * 3.6; /// <summary> /// Implements the operator /. @@ -957,7 +948,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private NewtonMeter(double val) : base(val, Units) { } - public override string UnitString { get { return "Nm"; } } + public override string UnitString => "Nm"; [DebuggerHidden] public static Watt operator *(NewtonMeter newtonMeter, PerSecond perSecond) @@ -1011,7 +1002,7 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { 1, 2, -1, 0, 0, 0, 0 }; private NewtonMeterSecond(double val) : base(val, Units) { } - public override string UnitString { get { return "Nms"; } } + public override string UnitString => "Nms"; } public class Kelvin : SIBase<Kelvin> @@ -1020,10 +1011,7 @@ namespace TUGraz.VectoCommon.Utils private Kelvin(double val) : base(val, Units) { } - public double AsDegCelsius - { - get { return Val - 273.16; } - } + public double AsDegCelsius => Val - 273.16; public static KelvinSquareMeter operator *(Kelvin k, SquareMeter sq) { @@ -1090,11 +1078,9 @@ namespace TUGraz.VectoCommon.Utils private AmpereSecond(double val) : base(val, Units) { } - public override string UnitString { get { return "As"; } } - public double AsAmpHour - { - get { return Val / 3600.0; } - } + public override string UnitString => "As"; + + public double AsAmpHour => Val / 3600.0; public static Ampere operator /(AmpereSecond ampereSecond, Second t) { @@ -1120,7 +1106,7 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { 1, 2, -3, -1, 0, 0, 0 }; private Volt(double val) : base(val, Units) { } - public override string UnitString { get { return "V"; } } + public override string UnitString => "V"; public static Watt operator *(Volt volt, Ampere ampere) { @@ -1149,7 +1135,7 @@ namespace TUGraz.VectoCommon.Utils private Ohm(double val) : base(val, Units) { } - public override string UnitString { get { return "Ω"; } } + public override string UnitString => "Ω"; } public class Farad : SIBase<Farad> @@ -1158,10 +1144,7 @@ namespace TUGraz.VectoCommon.Utils private Farad(double val) : base(val, Units) {} - public override string UnitString - { - get { return "F"; } - } + public override string UnitString => "F"; public static Volt operator /(AmpereSecond charge, Farad capacity) { @@ -1179,7 +1162,7 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { 0, 2, 0, 0, 0, 0, 0 }; private VolumePerMeter(double val) : base(val, Units) { } - public override string UnitString { get { return "m^3/m"; } } + public override string UnitString => "m^3/m"; public static VolumePerMeterMass operator /(VolumePerMeter vpm, Kilogram kg) { @@ -1199,7 +1182,7 @@ namespace TUGraz.VectoCommon.Utils private VolumePerMeterMass(double val) : base (val, Units) { } - public override string UnitString { get { return "m^3/kgm"; } } + public override string UnitString => "m^3/kgm"; } public class VolumePerMeterVolume : SIBase<VolumePerMeterVolume> @@ -1208,7 +1191,7 @@ namespace TUGraz.VectoCommon.Utils private VolumePerMeterVolume(double val) : base (val, Units) { } - public override string UnitString { get { return "m^3/kgm^3"; } } + public override string UnitString => "m^3/kgm^3"; } public class KilogramPerMeterCubicMeter : SIBase<KilogramPerMeterCubicMeter> @@ -1217,7 +1200,7 @@ namespace TUGraz.VectoCommon.Utils private KilogramPerMeterCubicMeter(double val) : base(val, Units) { } - public override string UnitString { get { return "kg/(m m^3)"; } } + public override string UnitString => "kg/(m m^3)"; } @@ -1227,7 +1210,7 @@ namespace TUGraz.VectoCommon.Utils private KilogramPerMeterMass(double val) : base(val, Units) { } - public override string UnitString { get { return "kg/(m kg)"; } } + public override string UnitString => "kg/(m kg)"; } public class SpecificFuelConsumption : SIBase<SpecificFuelConsumption> @@ -1236,7 +1219,7 @@ namespace TUGraz.VectoCommon.Utils private SpecificFuelConsumption(double val) : base(val, Units) { } - public override string UnitString { get { return "kg/Ws"; } } + public override string UnitString => "kg/Ws"; } /// <summary> @@ -1517,10 +1500,7 @@ namespace TUGraz.VectoCommon.Utils return new SI(Val * UnitFactor, _units); } - protected double AsBasicUnit - { - get { return Val * UnitFactor; } - } + protected double AsBasicUnit => Val * UnitFactor; /// <summary> @@ -1616,7 +1596,7 @@ namespace TUGraz.VectoCommon.Utils } } catch (DivideByZeroException ex) { throw new VectoException( - string.Format("Can not compute division by zero ([{0}] / 0[{1}])", si1.UnitString, si2.UnitString), ex); + $"Can not compute division by zero ([{si1.UnitString}] / 0[{si2.UnitString}])", ex); } var unitArray = SIUtils.CombineUnits(si1._units, SIUtils.MultiplyUnits(si2._units, -1)); @@ -1628,7 +1608,7 @@ namespace TUGraz.VectoCommon.Utils public static SI operator /(SI si1, double d) { if (d.IsEqual(0)) { - throw new VectoException(string.Format("Can not compute division by zero ([{0}] / 0)", si1.UnitString), new DivideByZeroException()); + throw new VectoException($"Can not compute division by zero ([{si1.UnitString}] / 0)", new DivideByZeroException()); } return new SI(si1.Val / d, si1); @@ -1638,7 +1618,7 @@ namespace TUGraz.VectoCommon.Utils public static SI operator /(double d, SI si1) { if (si1.IsEqual(0)) { - throw new VectoException(string.Format("Can not compute division by zero (x / 0[{0}])", si1.UnitString), + throw new VectoException($"Can not compute division by zero (x / 0[{si1.UnitString}])", new DivideByZeroException()); } @@ -1774,16 +1754,10 @@ namespace TUGraz.VectoCommon.Utils } - public virtual string SerializedValue - { - get { return ToString(); } - } + public virtual string SerializedValue => ToString(); [JsonIgnore] - public virtual string UnitString - { - get { return GetUnitString(_units); } - } + public virtual string UnitString => GetUnitString(_units); private string ToString(string format) { diff --git a/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs index f25905cc4fd67dcc7bd5f1ffd4df37d88b814a11..32bc88d9b6c3784687fa872f2cc2240f463ef41c 100644 --- a/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs @@ -50,7 +50,7 @@ namespace TUGraz.VectoCommon.Utils return Units; } - public double Value { get { return _value; } } + public double Value => _value; protected bool Equals(ConvertedSI other) { @@ -63,7 +63,7 @@ namespace TUGraz.VectoCommon.Utils return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) + if (obj.GetType() != GetType()) return false; return Equals((ConvertedSI)obj); } diff --git a/VectoCommon/VectoCommon/Utils/SIUtils.cs b/VectoCommon/VectoCommon/Utils/SIUtils.cs index 51584d1c9025b6acb3f04851a9eca898efe85926..aa6fcf2944d5933dbd94579698d0f660870d147e 100644 --- a/VectoCommon/VectoCommon/Utils/SIUtils.cs +++ b/VectoCommon/VectoCommon/Utils/SIUtils.cs @@ -312,10 +312,7 @@ namespace TUGraz.VectoCommon.Utils /// <summary> /// [-]. Defines radian. Only virtual. Has no real SI unit. /// </summary> - public UnitInstance Radian - { - get { return this; } - } + public UnitInstance Radian => this; /// <summary> /// [-]. Converts to/from Radiant. Internally everything is stored in radian. diff --git a/VectoCommon/VectoCommon/Utils/Validation.cs b/VectoCommon/VectoCommon/Utils/Validation.cs index 63765792b2942057cfbfd4bba725766cce6b710f..ebfe5f6b5d21df369c3ba563e091211e249aaae4 100644 --- a/VectoCommon/VectoCommon/Utils/Validation.cs +++ b/VectoCommon/VectoCommon/Utils/Validation.cs @@ -62,7 +62,7 @@ namespace TUGraz.VectoCommon.Utils bool emsCycle) { if (entity == null) { - return new[] { new ValidationResult(string.Format("null value given for {0}", typeof(T))) }; + return new[] { new ValidationResult($"null value given for {typeof(T)}") }; } var context = new ValidationContext(entity); context.ServiceContainer.AddService(typeof(VectoValidationModeServiceContainer), @@ -185,11 +185,11 @@ namespace TUGraz.VectoCommon.Utils var validationService = validationContext.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; - var mode = validationService != null ? validationService.Mode : ExecutionMode.Declaration; + var mode = validationService?.Mode ?? ExecutionMode.Declaration; var gbxType = validationService != null ? validationService.GearboxType : GearboxType.MT; var isEmsCycle = validationService != null && validationService.IsEMSCycle; - var jobType = validationService != null ? validationService.JobType : VectoSimulationJobType.ConventionalVehicle; - var emPos = validationService != null ? validationService.EMPowertrainPosition : (PowertrainPosition?)null; + var jobType = validationService?.JobType ?? VectoSimulationJobType.ConventionalVehicle; + var emPos = validationService?.EMPowertrainPosition; var enumerable = value as IEnumerable; if (enumerable != null) { @@ -231,7 +231,7 @@ namespace TUGraz.VectoCommon.Utils return new ValidationResult(string.Join("\n", results), messages); } return new ValidationResult( - string.Format("{{{0}}} invalid: {1}", validationContext.DisplayName, string.Join("\n", results)), messages); + $"{{{validationContext.DisplayName}}} invalid: {string.Join("\n", results)}", messages); } return ValidationResult.Success; @@ -411,7 +411,7 @@ namespace TUGraz.VectoCommon.Utils } var validationService = validationContext.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; - var mode = validationService != null ? validationService.Mode : (ExecutionMode?)null; + var mode = validationService?.Mode; var emsMode = validationService != null && validationService.IsEMSCycle; if (!_emsMission.HasValue || _emsMission.Value == emsMode) { diff --git a/VectoCommon/VectoCommon/Utils/VectoMath.cs b/VectoCommon/VectoCommon/Utils/VectoMath.cs index c4e941db311fb3ae2f6e2eb38e3c6b906f3ba4ba..0932091c61b32ddc024de62493dd84db31879234 100644 --- a/VectoCommon/VectoCommon/Utils/VectoMath.cs +++ b/VectoCommon/VectoCommon/Utils/VectoMath.cs @@ -494,7 +494,7 @@ namespace TUGraz.VectoCommon.Utils var q = 1.0 / 8.0 * a * a * a - a * b / 2.0 + c; var r = -3.0 / 256.0 * a * a * a * a + a * a * b / 16.0 - a * c / 4.0 + d; if (q.IsEqual(0, 1e-12)) { - var solY = VectoMath.QuadraticEquationSolver(1, b, d); + var solY = QuadraticEquationSolver(1, b, d); var retVal = new List<double>(); foreach (var s in solY) { if (s < 0) { @@ -508,7 +508,7 @@ namespace TUGraz.VectoCommon.Utils return retVal.ToArray(); } - var solZ = VectoMath.Polynom3Solver(8.0, 20.0 * p, 16.0 * p * p - 8.0 * r, 4.0 * p * p * p - 4.0 * p * r - q * q); + var solZ = Polynom3Solver(8.0, 20.0 * p, 16.0 * p * p - 8.0 * r, 4.0 * p * p * p - 4.0 * p * r - q * q); if (solZ.Length == 0) { return new double[0]; @@ -521,8 +521,8 @@ namespace TUGraz.VectoCommon.Utils // no real-valued solution return new double[0]; } - var solY1 = VectoMath.QuadraticEquationSolver(1, -Math.Sqrt(u), q / (2.0 * Math.Sqrt(u)) + p + z); - var solY2 = VectoMath.QuadraticEquationSolver(1, Math.Sqrt(u), -q / (2.0 * Math.Sqrt(u)) + p + z); + var solY1 = QuadraticEquationSolver(1, -Math.Sqrt(u), q / (2.0 * Math.Sqrt(u)) + p + z); + var solY2 = QuadraticEquationSolver(1, Math.Sqrt(u), -q / (2.0 * Math.Sqrt(u)) + p + z); return solY1.Select(s => s - a / 4.0).Concat(solY2.Select(s => s - a / 4.0)).ToArray(); } } @@ -793,20 +793,11 @@ namespace TUGraz.VectoCommon.Utils P2 = p2; } - public Point Vector - { - get { return _vector ?? (_vector = P2 - P1); } - } + public Point Vector => _vector ?? (_vector = P2 - P1); - public double SlopeXY - { - get { return Vector.Y / Vector.X; } - } + public double SlopeXY => Vector.Y / Vector.X; - public double OffsetXY - { - get { return P2.Y - SlopeXY * P2.X; } - } + public double OffsetXY => P2.Y - SlopeXY * P2.X; #region Equality members diff --git a/VectoCommon/VectoHashing/Impl/XmlDsigVectoTransform.cs b/VectoCommon/VectoHashing/Impl/XmlDsigVectoTransform.cs index 5c8f092738f3f162cdfa0dcbc1349e8cc7538a86..41117ad78647154879a780e6189be763d2ee5153 100644 --- a/VectoCommon/VectoHashing/Impl/XmlDsigVectoTransform.cs +++ b/VectoCommon/VectoHashing/Impl/XmlDsigVectoTransform.cs @@ -78,15 +78,9 @@ namespace TUGraz.VectoHashing return _transform.GetOutput(type); } - public override Type[] InputTypes - { - get { return _transform.InputTypes; } - } + public override Type[] InputTypes => _transform.InputTypes; - public override Type[] OutputTypes - { - get { return _transform.OutputTypes; } - } + public override Type[] OutputTypes => _transform.OutputTypes; private static Stream ReadStream(string resourceName) { diff --git a/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs b/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs index bdebe2e948617b5722226c020b22d171193a8972..b8dac3e01db12e69c07f1fc649478763a705148b 100644 --- a/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs +++ b/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs @@ -55,10 +55,7 @@ namespace TUGraz.VectoHashing.Impl } } - public static string DefaultDigestMethod - { - get { return DigestMethodSha256; } - } + public static string DefaultDigestMethod => DigestMethodSha256; public static ICollection<string> SupportedCanonicalizationMethods { @@ -89,11 +86,11 @@ namespace TUGraz.VectoHashing.Impl var c14N = (canonicalization ?? DefaultCanonicalizationMethod).ToArray(); digestMethod = digestMethod ?? DefaultDigestMethod; if (!SupportedDigestMethods.Contains(digestMethod)) { - throw new Exception(string.Format("DigestMethod '{0}' not supported.", digestMethod)); + throw new Exception($"DigestMethod '{digestMethod}' not supported."); } var unsupported = c14N.Where(c => !SupportedCanonicalizationMethods.Contains(c)).ToArray(); if (unsupported.Any()) { - throw new Exception(string.Format("CanonicalizationMethod(s) {0} not supported!", string.Join(", ", unsupported))); + throw new Exception($"CanonicalizationMethod(s) {string.Join(", ", unsupported)} not supported!"); } var signedXml = new SignedXml(doc); @@ -123,7 +120,7 @@ namespace TUGraz.VectoHashing.Impl case DsigExcC14NTransform: return new XmlDsigExcC14NTransform(); } - throw new Exception(string.Format("Unsupported CanonicalizationMethod {0}", transformUrn)); + throw new Exception($"Unsupported CanonicalizationMethod {transformUrn}"); } } } diff --git a/VectoCommon/VectoHashing/VectoHash.cs b/VectoCommon/VectoHashing/VectoHash.cs index f4d9e03b24aeb0ffa36f6b7147ff51b851c1a5ff..f7e9cbaf24a0c5bf918d264651141ec90e61e144 100644 --- a/VectoCommon/VectoHashing/VectoHash.cs +++ b/VectoCommon/VectoHashing/VectoHash.cs @@ -90,34 +90,22 @@ namespace TUGraz.VectoHashing /// <summary> /// Get a list of all supported digest methods /// </summary> - public static ICollection<string> SupportedDigestMehods - { - get { return XMLHashProvider.SupportedDigestMethods; } - } + public static ICollection<string> SupportedDigestMehods => XMLHashProvider.SupportedDigestMethods; /// <summary> /// get the identifier of the default digest method /// </summary> - public static string DefaultDigestMethod - { - get { return XMLHashProvider.DefaultDigestMethod; } - } + public static string DefaultDigestMethod => XMLHashProvider.DefaultDigestMethod; /// <summary> /// get a list of all supported canonicalization methods /// </summary> - public static ICollection<string> SupportedCanonicalizationMethods - { - get { return XMLHashProvider.SupportedCanonicalizationMethods; } - } + public static ICollection<string> SupportedCanonicalizationMethods => XMLHashProvider.SupportedCanonicalizationMethods; /// <summary> /// get the sequence of the default canonicalization methods /// </summary> - public static IEnumerable<string> DefaultCanonicalizationMethod - { - get { return XMLHashProvider.DefaultCanonicalizationMethod; } - } + public static IEnumerable<string> DefaultCanonicalizationMethod => XMLHashProvider.DefaultCanonicalizationMethod; public IList<VectoComponents> GetContainigComponents() { @@ -125,7 +113,7 @@ namespace TUGraz.VectoHashing foreach (var component in EnumHelper.GetValues<VectoComponents>()) { var nodes = Document.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']", XMLNames.VectoInputDeclaration, component.XMLElementName())); - var count = nodes == null ? 0 : nodes.Count; + var count = nodes?.Count ?? 0; for (var i = 0; i < count; i++) { retVal.Add(component); } @@ -161,11 +149,10 @@ namespace TUGraz.VectoHashing var nodes = Document.SelectNodes(GetComponentQueryString(component)); if (nodes == null || nodes.Count == 0) { - throw new Exception(string.Format("Component {0} not found", component.XMLElementName())); + throw new Exception($"Component {component.XMLElementName()} not found"); } if (index >= nodes.Count) { - throw new Exception(string.Format("index exceeds number of components found! index: {0}, #components: {1}", index, - nodes.Count)); + throw new Exception($"index exceeds number of components found! index: {index}, #components: {nodes.Count}"); } var componentId = nodes[index].Attributes[XMLNames.Component_ID_Attr].Value; return GetHashValueFromSig(DoComputeHash(nodes[index], canonicalization, digestMethod), componentId); @@ -225,12 +212,12 @@ namespace TUGraz.VectoHashing public XDocument AddHash() { var component = GetComponentToHash(); - var query = string.Format("//*[local-name()='{0}']/*[local-name()='Data']", component.XMLElementName()); + var query = $"//*[local-name()='{component.XMLElementName()}']/*[local-name()='Data']"; var node = Document.SelectSingleNode(query); if (node == null) { - throw new Exception(string.Format("'Data' element for component '{0}' not found!", component.XMLElementName())); + throw new Exception($"'Data' element for component '{component.XMLElementName()}' not found!"); } - query = string.Format("//*[local-name()='{0}']/*[local-name()='Signature']", component.XMLElementName()); + query = $"//*[local-name()='{component.XMLElementName()}']/*[local-name()='Signature']"; var sigNodes = Document.SelectNodes(query); if (sigNodes != null && sigNodes.Count > 0) { throw new Exception("input data already contains a signature element"); @@ -257,8 +244,8 @@ namespace TUGraz.VectoHashing } query = component.IsReport() - ? string.Format("*/*[local-name()='Data']/*[local-name()='ApplicationInformation']/*[local-name()='Date']") - : string.Format("*/*[local-name()='{0}']/*/*[local-name()='Date']", component.XMLElementName()); + ? "*/*[local-name()='Data']/*[local-name()='ApplicationInformation']/*[local-name()='Date']" + : $"*/*[local-name()='{component.XMLElementName()}']/*/*[local-name()='Date']"; var dateNode = Document.SelectSingleNode(query); if (dateNode == null) { throw new Exception("Date-Element not found in input!"); @@ -373,9 +360,9 @@ namespace TUGraz.VectoHashing private string ReadElementValue(XmlNode xmlNode, string elementName) { - var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName)); + var node = xmlNode.SelectSingleNode($"./*[local-name()='{elementName}']"); if (node == null) { - throw new Exception(string.Format("Node '{0}' not found!", elementName)); + throw new Exception($"Node '{elementName}' not found!"); } return node.InnerText; } @@ -392,11 +379,10 @@ namespace TUGraz.VectoHashing if (nodes == null || nodes.Count == 0) { throw new Exception(component == null ? "No component found" - : string.Format("Component {0} not found", component.Value.XMLElementName())); + : $"Component {component.Value.XMLElementName()} not found"); } if (index >= nodes.Count) { - throw new Exception(string.Format("index exceeds number of components found! index: {0}, #components: {1}", index, - nodes.Count)); + throw new Exception($"index exceeds number of components found! index: {index}, #components: {nodes.Count}"); } return nodes; } @@ -420,8 +406,8 @@ namespace TUGraz.VectoHashing return "(//*[@id])[1]"; } return component == VectoComponents.Vehicle - ? string.Format("//*[local-name()='{0}']", component.Value.XMLElementName()) - : string.Format("//*[local-name()='{0}']/*[local-name()='Data']", component.Value.XMLElementName()); + ? $"//*[local-name()='{component.Value.XMLElementName()}']" + : $"//*[local-name()='{component.Value.XMLElementName()}']/*[local-name()='Data']"; } private static string GetHashValueFromSig(XmlDocument hashed, string elementId) diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index d25b95d95e28f93c9a8719ce3f0c3e1d4e3a748f..e14008517b96205a4d3f4737d9c7cc8fe6877051 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -209,7 +209,7 @@ Examples: break; case ".xml": var xDocument = XDocument.Load(file); - var rootNode = xDocument == null ? "" : xDocument.Root.Name.LocalName; + var rootNode = xDocument?.Root.Name.LocalName ?? ""; switch (rootNode) { case "VectoInputEngineering": dataProvider = inputReader.CreateEngineering(file); @@ -222,7 +222,7 @@ Examples: } if (dataProvider == null) { - WriteLine(string.Format(@"failed to read job: '{0}'", file)); + WriteLine($@"failed to read job: '{file}'"); continue; } @@ -241,7 +241,7 @@ Examples: WriteLine(@"Detected cycles:", ConsoleColor.White); foreach (var cycle in _jobContainer.GetCycleTypes()) { - WriteLineStdOut(string.Format(@" {0}: {1}", cycle.Name, cycle.CycleType)); + WriteLineStdOut($@" {cycle.Name}: {cycle.CycleType}"); } WriteLine(); @@ -355,8 +355,8 @@ Examples: private static void ShowVersionInformation() { - WriteLine(string.Format(@"VectoConsole: {0}", Assembly.GetExecutingAssembly().GetName().Version)); - WriteLine(string.Format(@"VectoCore: {0}", VectoSimulationCore.VersionNumber)); + WriteLine($@"VectoConsole: {Assembly.GetExecutingAssembly().GetName().Version}"); + WriteLine($@"VectoCore: {VectoSimulationCore.VersionNumber}"); } private static void PrintProgress(Dictionary<int, JobContainer.ProgressEntry> progessData, @@ -381,10 +381,9 @@ Examples: } var timingString = ""; if (showTiming && progressEntry.Value.ExecTime > 0) { - timingString = string.Format("{0,9:F2}s", progressEntry.Value.ExecTime / 1000.0); + timingString = $"{progressEntry.Value.ExecTime / 1000.0,9:F2}s"; } - var runName = string.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, - progressEntry.Value.RunSuffix); + var runName = $"{progressEntry.Value.RunName} {progressEntry.Value.CycleName} {progressEntry.Value.RunSuffix}"; Console.WriteLine(@"{0,-60} {1,8:P}{2}", runName, progressEntry.Value.Progress, timingString); Console.ResetColor(); sumProgress += progressEntry.Value.Progress; diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index d8ce3583060d09bb4cc052dc804316accf33135c..5dca2e72d78652308bac51eb4077ff0443e5d73c 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -36,7 +36,7 @@ namespace TUGraz.VectoCore.Configuration { public static class Constants { - public const string NOT_AVailABLE = "N/A"; + public const string NOT_AVAILABLE = "N/A"; public static Second DefaultPowerShiftTime = 0.8.SI<Second>(); public const double RPMToRad = 2 * Math.PI / 60; diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs index 2f494bd06097f79c82cf4bbb8f29165ff45a50d6..4b1703719e38f3fcf8f989f0e7ed8782a513fea0 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs @@ -14,88 +14,34 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public JSONBatteryV1(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) { } - public string Manufacturer - { - get { return Constants.NOT_AVailABLE; } - } + public string Manufacturer => Constants.NOT_AVAILABLE; - public string Model - { - get { return Body.GetEx<string>("Model"); } - } + public string Model => Body.GetEx<string>("Model"); - public DateTime Date - { - get { return DateTime.MinValue; } - } + public DateTime Date => DateTime.MinValue; - public CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public CertificationMethod CertificationMethod => CertificationMethod.NotCertified; - public string CertificationNumber - { - get { return Constants.NOT_AVailABLE; } - } + public string CertificationNumber => Constants.NOT_AVAILABLE; - public DigestData DigestValue - { - get { return null; } - } + public DigestData DigestValue => null; - public double MinSOC - { - get { return Body.GetEx<double>("SOC_min") / 100.0; } - } + public double MinSOC => Body.GetEx<double>("SOC_min") / 100.0; - public double MaxSOC - { - get { return Body.GetEx<double>("SOC_max") / 100.0; } - } + public double MaxSOC => Body.GetEx<double>("SOC_max") / 100.0; - AmpereSecond IBatteryPackDeclarationInputData.Capacity - { - get { return Body.GetEx<double>("Capacity").SI(Unit.SI.Ampere.Hour).Cast<AmpereSecond>(); } - } + AmpereSecond IBatteryPackDeclarationInputData.Capacity => Body.GetEx<double>("Capacity").SI(Unit.SI.Ampere.Hour).Cast<AmpereSecond>(); - Farad ISuperCapDeclarationInputData.Capacity - { - get - { - return Body.GetEx<double>("Capacity").SI<Farad>(); - } - } + Farad ISuperCapDeclarationInputData.Capacity => Body.GetEx<double>("Capacity").SI<Farad>(); - public Ohm InternalResistance - { - get - { - return Body.GetEx<double>("InternalResistance").SI<Ohm>(); - } - } + public Ohm InternalResistance => Body.GetEx<double>("InternalResistance").SI<Ohm>(); - public Volt MinVoltage - { - get - { - return Body.GetEx<double>("U_min").SI<Volt>(); - } - } + public Volt MinVoltage => Body.GetEx<double>("U_min").SI<Volt>(); - public Volt MaxVoltage - { - get - { - return Body.GetEx<double>("U_max").SI<Volt>(); - } - } + public Volt MaxVoltage => Body.GetEx<double>("U_max").SI<Volt>(); - public Ampere MaxCurrentCharge - { - get{ return Math.Abs(Body.GetEx<double>("I_maxCharge")).SI<Ampere>(); } - } - public Ampere MaxCurrentDischarge { get { return Math.Abs(Body.GetEx<double>("I_maxDischarge")).SI<Ampere>(); } } + public Ampere MaxCurrentCharge => Math.Abs(Body.GetEx<double>("I_maxCharge")).SI<Ampere>(); + public Ampere MaxCurrentDischarge => Math.Abs(Body.GetEx<double>("I_maxDischarge")).SI<Ampere>(); public TableData InternalResistanceCurve { @@ -155,12 +101,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } - public REESSType StorageType - { - get - { - return Body["REESSType"] == null ? REESSType.Battery : Body.GetEx<string>("REESSType").ParseEnum<REESSType>(); - } - } + public REESSType StorageType => Body["REESSType"] == null ? REESSType.Battery : Body.GetEx<string>("REESSType").ParseEnum<REESSType>(); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBusAuxiliariesEngineeringData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBusAuxiliariesEngineeringData.cs index 698c705fb38092f84b7de81ae3ae66891c93a5d9..c3d651cefb23c9d5214325bd6ff3c238c4044ed6 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBusAuxiliariesEngineeringData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBusAuxiliariesEngineeringData.cs @@ -23,74 +23,38 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON _hvac = Body["HVAC"]; } - public IBusAuxPneumaticSystemEngineeringData PneumaticSystem - { - get { return this; } - } - - public IBusAuxElectricSystemEngineeringData ElectricSystem - { - get { return this; } - } - - public IBusAuxHVACData HVACData { get { return this; } } + public IBusAuxPneumaticSystemEngineeringData PneumaticSystem => this; + + public IBusAuxElectricSystemEngineeringData ElectricSystem => this; + + public IBusAuxHVACData HVACData => this; #region Implementation of IBusAuxPneumaticSystemEngineeringData - public TableData CompressorMap - { - get { return VectoCSVFile.Read(Path.Combine(BasePath, _pneumatic.GetEx<string>("CompressorMap"))); } - } + public TableData CompressorMap => VectoCSVFile.Read(Path.Combine(BasePath, _pneumatic.GetEx<string>("CompressorMap"))); - public NormLiterPerSecond AverageAirConsumed - { - get { return _pneumatic.GetEx<double>("AverageAirDemand").SI<NormLiterPerSecond>(); } - } + public NormLiterPerSecond AverageAirConsumed => _pneumatic.GetEx<double>("AverageAirDemand").SI<NormLiterPerSecond>(); - public bool SmartAirCompression - { - get { return _pneumatic.GetEx<bool>("SmartAirCompression"); } - } + public bool SmartAirCompression => _pneumatic.GetEx<bool>("SmartAirCompression"); - public double GearRatio - { - get { return _pneumatic.GetEx<double>("GearRatio"); } - } + public double GearRatio => _pneumatic.GetEx<double>("GearRatio"); #endregion #region Implementation of IBusAuxElectricSystemEngineeringData - public double AlternatorEfficiency - { - get { return _electric.GetEx<double>("AlternatorEfficiency"); } - } + public double AlternatorEfficiency => _electric.GetEx<double>("AlternatorEfficiency"); - public double DCDCConverterEfficiency - { - get - { - return _electric["DCDCConverterEfficiency"] == null ? 1 : _electric.GetEx<double>("DCDCConverterEfficiency"); - } - } + public double DCDCConverterEfficiency => _electric["DCDCConverterEfficiency"] == null ? 1 : _electric.GetEx<double>("DCDCConverterEfficiency"); - public Ampere CurrentDemand - { - get { return _electric.GetEx<double>("CurrentDemand").SI<Ampere>(); } - } + public Ampere CurrentDemand => _electric.GetEx<double>("CurrentDemand").SI<Ampere>(); - public Ampere CurrentDemandEngineOffDriving { get { return _electric.GetEx<double>("CurrentDemandEngineOffDriving").SI<Ampere>(); } } + public Ampere CurrentDemandEngineOffDriving => _electric.GetEx<double>("CurrentDemandEngineOffDriving").SI<Ampere>(); - public Ampere CurrentDemandEngineOffStandstill { get { return _electric.GetEx<double>("CurrentDemandEngineOffStandstill").SI<Ampere>(); } } + public Ampere CurrentDemandEngineOffStandstill => _electric.GetEx<double>("CurrentDemandEngineOffStandstill").SI<Ampere>(); - public AlternatorType AlternatorType - { - get - { - return _electric["AlternatorType"] == null ? AlternatorType.Conventional : _electric.GetEx<string>("AlternatorType").ParseEnum<AlternatorType>(); - } - } + public AlternatorType AlternatorType => _electric["AlternatorType"] == null ? AlternatorType.Conventional : _electric.GetEx<string>("AlternatorType").ParseEnum<AlternatorType>(); public WattSecond ElectricStorageCapacity { @@ -104,53 +68,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public Watt MaxAlternatorPower - { - get { return _electric.GetEx<double>("MaxAlternatorPower").SI<Watt>(); } - } + public Watt MaxAlternatorPower => _electric.GetEx<double>("MaxAlternatorPower").SI<Watt>(); - public bool ESSupplyFromHEVREESS - { - get - { - return _electric["ESSupplyFromHEVREESS"] == null ? false : _electric.GetEx<bool>("ESSupplyFromHEVREESS"); - } - } + public bool ESSupplyFromHEVREESS => _electric["ESSupplyFromHEVREESS"] == null ? false : _electric.GetEx<bool>("ESSupplyFromHEVREESS"); - public double ElectricStorageEfficiency - { - get - { - return _electric["BatteryEfficiency"] == null ? 1 : _electric.GetEx<double>("BatteryEfficiency"); - } - } + public double ElectricStorageEfficiency => _electric["BatteryEfficiency"] == null ? 1 : _electric.GetEx<double>("BatteryEfficiency"); #endregion #region Implementation of IBusAuxHVACData - public Watt ElectricalPowerDemand - { - get { return _hvac.GetEx<double>("ElectricPowerDemand").SI<Watt>(); } - } + public Watt ElectricalPowerDemand => _hvac.GetEx<double>("ElectricPowerDemand").SI<Watt>(); - public Watt MechanicalPowerDemand - { - get { return _hvac.GetEx<double>("MechanicalPowerDemand").SI<Watt>(); } - } + public Watt MechanicalPowerDemand => _hvac.GetEx<double>("MechanicalPowerDemand").SI<Watt>(); - public Joule AverageHeatingDemand - { - get { return _hvac.GetEx<double>("AverageHeatingDemand").SI(Unit.SI.Mega.Joule).Cast<Joule>(); } - } + public Joule AverageHeatingDemand => _hvac.GetEx<double>("AverageHeatingDemand").SI(Unit.SI.Mega.Joule).Cast<Joule>(); - public Watt AuxHeaterPower - { - get - { - return _hvac.GetEx<double>("AuxHeaterPower").SI<Watt>(); - } - } + public Watt AuxHeaterPower => _hvac.GetEx<double>("AuxHeaterPower").SI<Watt>(); #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs index b3521a3aba47e528532f0d1968704257c5a26800..e3f7a8f1957e7c24e92cd647383d7dac2d8bf463 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs @@ -103,82 +103,53 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON break; } - tmp.Switch() - .If<IVehicleEngineeringInputData>(c => VehicleData = c) - .If<IAirdragEngineeringInputData>(c => AirdragData = c) - .If<IEngineEngineeringInputData>(c => Engine = c) - .If<IGearboxEngineeringInputData>(c => Gearbox = c) - .If<IAxleGearInputData>(c => AxleGear = c) - .If<IRetarderInputData>(c => Retarder = c) - .If<ITorqueConverterEngineeringInputData>(c => TorqueConverterData = c) - .If<IAngledriveInputData>(c => Angledrive = c) - .If<IPTOTransmissionInputData>(c => PTOTransmission = c) - .If<IGearshiftEngineeringInputData>(c => GearshiftData = c) - .If<IAxlesDeclarationInputData>(c => _axleWheelsDecl = c) - .If<IAxlesEngineeringInputData>(c => _axleWheelsEng = c) - .If<IBatteryPackEngineeringInputData>(c => Battery = c) - .If<IElectricMotorEngineeringInputData>(c => { ElectricMotor = c; }) - .If<IHybridStrategyParameters>(c => HybridStrategyParameters = c) - .If<IBusAuxiliariesEngineeringData>(c => BusAux = c); + if(tmp is IVehicleEngineeringInputData x1) VehicleData = x1; + if(tmp is IAirdragEngineeringInputData x2) AirdragData = x2; + if(tmp is IEngineEngineeringInputData x3) Engine = x3; + if(tmp is IGearboxEngineeringInputData x4) Gearbox = x4; + if(tmp is IAxleGearInputData x5) AxleGear = x5; + if(tmp is IRetarderInputData x6) Retarder = x6; + if(tmp is ITorqueConverterEngineeringInputData x7) TorqueConverterData = x7; + if(tmp is IAngledriveInputData x8) Angledrive = x8; + if(tmp is IPTOTransmissionInputData x9) PTOTransmission = x9; + if(tmp is IGearshiftEngineeringInputData x10) GearshiftData = x10; + if(tmp is IAxlesDeclarationInputData x11) _axleWheelsDecl = x11; + if(tmp is IAxlesEngineeringInputData x12) _axleWheelsEng = x12; + if(tmp is IBatteryPackEngineeringInputData x13) Battery = x13; + if(tmp is IElectricMotorEngineeringInputData x14) ElectricMotor = x14; + if(tmp is IHybridStrategyParameters x15) HybridStrategyParameters = x15; + if(tmp is IBusAuxiliariesEngineeringData x16) BusAux = x16; _filename = filename; } - public IEngineeringJobInputData JobInputData - { - get { return this; } - } + public IEngineeringJobInputData JobInputData => this; - public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData - { - get { return null; } - } + public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData => null; - public XElement XMLHash - { - get { return new XElement(XMLNames.DI_Signature); } - } + public XElement XMLHash => new XElement(XMLNames.DI_Signature); - IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData - { - get { return this; } - } + IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData => this; - public IDriverEngineeringInputData DriverInputData - { - get { return this; } - } + public IDriverEngineeringInputData DriverInputData => this; public IOverSpeedEngineeringInputData OverSpeedData { get; } public IDriverAccelerationData AccelerationCurve { get; } public ILookaheadCoastingInputData Lookahead { get; } - public IGearshiftEngineeringInputData GearshiftInputData - { - get { return GearshiftData; } - } + public IGearshiftEngineeringInputData GearshiftInputData => GearshiftData; public IEngineStopStartEngineeringInputData EngineStopStartData { get; } public IEcoRollEngineeringInputData EcoRollData { get; } public IPCCEngineeringInputData PCCData { get; } - public DataSource DataSource + public DataSource DataSource => new DataSource { SourceType = DataSourceType.JSONFile, SourceFile = _filename }; - { - get { return new DataSource { SourceType = DataSourceType.JSONFile, SourceFile = _filename }; } - } - - public string AppVersion - { - get { return "VECTO-JSON"; } - } + public string AppVersion => "VECTO-JSON"; - public string Source - { - get { return _filename; } - } + public string Source => _filename; public bool SavedInDeclarationMode { get; private set; } public string Manufacturer { get; private set; } @@ -188,17 +159,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public string CertificationNumber { get; private set; } public DigestData DigestValue { get; private set; } - IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle - { - get { return Vehicle; } - } + IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle => Vehicle; public IHybridStrategyParameters HybridStrategyParameters { get; set; } - public IVehicleEngineeringInputData Vehicle - { - get { return VehicleData ?? this; } - } + public IVehicleEngineeringInputData Vehicle => VehicleData ?? this; public IList<ICycleData> Cycles { get; private set; } @@ -208,81 +173,37 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public TableData PTOCycleWhileDrive { get; private set; } - public string JobName - { - get { return ""; } - } + public string JobName => ""; - public string ShiftStrategy - { - get { return ""; } - } + public string ShiftStrategy => ""; - public string Identifier - { - get { return Vehicle.Identifier; } - } + public string Identifier => Vehicle.Identifier; - public bool ExemptedVehicle - { - get { return false; } - } + public bool ExemptedVehicle => false; - public string VIN - { - get { return VehicleData.VIN; } - } + public string VIN => VehicleData.VIN; - public LegislativeClass? LegislativeClass - { - get { return VehicleData.LegislativeClass; } - } + public LegislativeClass? LegislativeClass => VehicleData.LegislativeClass; - public VehicleCategory VehicleCategory - { - get { return VehicleData.VehicleCategory; } - } + public VehicleCategory VehicleCategory => VehicleData.VehicleCategory; - public AxleConfiguration AxleConfiguration - { - get { return VehicleData.AxleConfiguration; } - } + public AxleConfiguration AxleConfiguration => VehicleData.AxleConfiguration; - public Kilogram CurbMassChassis - { - get { return VehicleData.CurbMassChassis; } - } + public Kilogram CurbMassChassis => VehicleData.CurbMassChassis; - public Kilogram GrossVehicleMassRating - { - get { return VehicleData.GrossVehicleMassRating; } - } + public Kilogram GrossVehicleMassRating => VehicleData.GrossVehicleMassRating; - public IList<ITorqueLimitInputData> TorqueLimits - { - get { return VehicleData.TorqueLimits; } - } + public IList<ITorqueLimitInputData> TorqueLimits => VehicleData.TorqueLimits; - IAxlesDeclarationInputData IVehicleComponentsDeclaration.AxleWheels - { - get { return _axleWheelsDecl; } - } + IAxlesDeclarationInputData IVehicleComponentsDeclaration.AxleWheels => _axleWheelsDecl; - public IBusAuxiliariesDeclarationData BusAuxiliaries - { - get { return null; } - } + public IBusAuxiliariesDeclarationData BusAuxiliaries => null; - public IElectricStorageEngineeringInputData ElectricStorage - { - get - { - return new JSONElectricStorageEngineeringInputData { - REESSPack = Battery, - Count = 1 - }; - } - } + public IElectricStorageEngineeringInputData ElectricStorage => + new JSONElectricStorageEngineeringInputData { + REESSPack = Battery, + Count = 1 + }; public IElectricMachinesEngineeringInputData ElectricMachines { get { @@ -295,362 +216,155 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON }); } } - IElectricStorageDeclarationInputData IVehicleComponentsDeclaration.ElectricStorage - { - get { return ElectricStorage; } - } + IElectricStorageDeclarationInputData IVehicleComponentsDeclaration.ElectricStorage => ElectricStorage; - IElectricMachinesDeclarationInputData IVehicleComponentsDeclaration.ElectricMachines - { - get { return ElectricMachines; } - } + IElectricMachinesDeclarationInputData IVehicleComponentsDeclaration.ElectricMachines => ElectricMachines; - public Meter DynamicTyreRadius - { - get { return VehicleData.DynamicTyreRadius; } - } + public Meter DynamicTyreRadius => VehicleData.DynamicTyreRadius; - public bool Articulated - { - get { return VehicleData.Articulated; } - } + public bool Articulated => VehicleData.Articulated; - public Meter Height - { - get { return VehicleData.Height; } - } + public Meter Height => VehicleData.Height; - public TableData ElectricMotorTorqueLimits - { - get - { - return Vehicle.ElectricMotorTorqueLimits; - } - } + public TableData ElectricMotorTorqueLimits => Vehicle.ElectricMotorTorqueLimits; - public TableData MaxPropulsionTorque - { - get - { - return Vehicle.ElectricMotorTorqueLimits; - } - } + public TableData MaxPropulsionTorque => Vehicle.ElectricMotorTorqueLimits; - public bool? ATEcoRollReleaseLockupClutch - { - get { return VehicleData.ADAS.ATEcoRollReleaseLockupClutch; } - } + public bool? ATEcoRollReleaseLockupClutch => VehicleData.ADAS.ATEcoRollReleaseLockupClutch; - public XmlNode XMLSource - { - get { return null; } - } + public XmlNode XMLSource => null; - public Meter Length - { - get { return VehicleData.Length; } - } + public Meter Length => VehicleData.Length; - public Meter Width - { - get { return VehicleData.Width; } - } + public Meter Width => VehicleData.Width; - public Meter EntranceHeight - { - get { return null; } - } + public Meter EntranceHeight => null; - public ConsumerTechnology? DoorDriveTechnology - { - get { return VehicleData.DoorDriveTechnology; } - } + public ConsumerTechnology? DoorDriveTechnology => VehicleData.DoorDriveTechnology; public VehicleDeclarationType VehicleDeclarationType { get; } - IVehicleComponentsEngineering IVehicleEngineeringInputData.Components - { - get { return this; } - } + IVehicleComponentsEngineering IVehicleEngineeringInputData.Components => this; - XmlNode IVehicleDeclarationInputData.XMLSource - { - get { return null; } - } + XmlNode IVehicleDeclarationInputData.XMLSource => null; - IAdvancedDriverAssistantSystemsEngineering IVehicleEngineeringInputData.ADAS - { - get { return this; } - } + IAdvancedDriverAssistantSystemsEngineering IVehicleEngineeringInputData.ADAS => this; - public GearshiftPosition PTO_DriveGear - { - get { return VehicleData.PTO_DriveGear; } - } + public GearshiftPosition PTO_DriveGear => VehicleData.PTO_DriveGear; - public PerSecond PTO_DriveEngineSpeed - { - get { return VehicleData.PTO_DriveEngineSpeed; } - } + public PerSecond PTO_DriveEngineSpeed => VehicleData.PTO_DriveEngineSpeed; - public double InitialSOC - { - get { return VehicleData.InitialSOC; } - } + public double InitialSOC => VehicleData.InitialSOC; - public VectoSimulationJobType VehicleType - { - get { return VehicleData.VehicleType; } - } + public VectoSimulationJobType VehicleType => VehicleData.VehicleType; - public IAirdragEngineeringInputData AirdragInputData - { - get { return AirdragData; } - } + public IAirdragEngineeringInputData AirdragInputData => AirdragData; - public IGearboxEngineeringInputData GearboxInputData - { - get { return Gearbox; } - } + public IGearboxEngineeringInputData GearboxInputData => Gearbox; - public ITorqueConverterDeclarationInputData TorqueConverter - { - get { return TorqueConverterData; } - } + public ITorqueConverterDeclarationInputData TorqueConverter => TorqueConverterData; - public ITorqueConverterEngineeringInputData TorqueConverterInputData - { - get { return TorqueConverterData; } - } + public ITorqueConverterEngineeringInputData TorqueConverterInputData => TorqueConverterData; - IAxleGearInputData IVehicleComponentsDeclaration.AxleGearInputData - { - get { return AxleGear; } - } + IAxleGearInputData IVehicleComponentsDeclaration.AxleGearInputData => AxleGear; - IAngledriveInputData IVehicleComponentsDeclaration.AngledriveInputData - { - get { return Angledrive; } - } + IAngledriveInputData IVehicleComponentsDeclaration.AngledriveInputData => Angledrive; - public Kilogram CurbMassExtra - { - get { return Vehicle.CurbMassExtra; } - } + public Kilogram CurbMassExtra => Vehicle.CurbMassExtra; - public Kilogram Loading - { - get { return Vehicle.Loading; } - } + public Kilogram Loading => Vehicle.Loading; - IAxlesEngineeringInputData IVehicleComponentsEngineering.AxleWheels - { - get { return _axleWheelsEng; } - } + IAxlesEngineeringInputData IVehicleComponentsEngineering.AxleWheels => _axleWheelsEng; - public string ManufacturerAddress - { - get { return VehicleData.ManufacturerAddress; } - } + public string ManufacturerAddress => VehicleData.ManufacturerAddress; - public PerSecond EngineIdleSpeed - { - get { return VehicleData.EngineIdleSpeed; } - } + public PerSecond EngineIdleSpeed => VehicleData.EngineIdleSpeed; - IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData - { - get { return AirdragInputData; } - } + IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData => AirdragInputData; - IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData - { - get { return GearboxInputData; } - } + IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData => GearboxInputData; - ITorqueConverterDeclarationInputData IVehicleComponentsDeclaration.TorqueConverterInputData - { - get { return TorqueConverterInputData; } - } + ITorqueConverterDeclarationInputData IVehicleComponentsDeclaration.TorqueConverterInputData => TorqueConverterInputData; - IAxleGearInputData IVehicleComponentsEngineering.AxleGearInputData - { - get { return AxleGear; } - } + IAxleGearInputData IVehicleComponentsEngineering.AxleGearInputData => AxleGear; - IAngledriveInputData IVehicleComponentsEngineering.AngledriveInputData - { - get { return Angledrive; } - } + IAngledriveInputData IVehicleComponentsEngineering.AngledriveInputData => Angledrive; - public IEngineEngineeringInputData EngineInputData - { - get { return Engine; } - } + public IEngineEngineeringInputData EngineInputData => Engine; - IEngineDeclarationInputData IVehicleComponentsDeclaration.EngineInputData - { - get { return Engine; } - } + IEngineDeclarationInputData IVehicleComponentsDeclaration.EngineInputData => Engine; - IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData - { - get { throw new NotImplementedException(); } - } + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData => throw new NotImplementedException(); - IRetarderInputData IVehicleComponentsEngineering.RetarderInputData - { - get { return Retarder; } - } + IRetarderInputData IVehicleComponentsEngineering.RetarderInputData => Retarder; - IPTOTransmissionInputData IVehicleComponentsEngineering.PTOTransmissionInputData - { - get { return PTOTransmission; } - } + IPTOTransmissionInputData IVehicleComponentsEngineering.PTOTransmissionInputData => PTOTransmission; - public bool VocationalVehicle - { - get { return DeclarationData.Vehicle.VocationalVehicleDefault; } - } + public bool VocationalVehicle => DeclarationData.Vehicle.VocationalVehicleDefault; - public bool SleeperCab - { - get { return DeclarationData.Vehicle.SleeperCabDefault; } - } + public bool SleeperCab => DeclarationData.Vehicle.SleeperCabDefault; public bool? AirdragModifiedMultistage { get; } - public TankSystem? TankSystem - { - get { return DeclarationData.Vehicle.TankSystemDefault; } - } + public TankSystem? TankSystem => DeclarationData.Vehicle.TankSystemDefault; - public IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return this; } - } + public IAdvancedDriverAssistantSystemDeclarationInputData ADAS => this; - public bool ZeroEmissionVehicle - { - get { return DeclarationData.Vehicle.ZeroEmissionVehicleDefault; } - } + public bool ZeroEmissionVehicle => DeclarationData.Vehicle.ZeroEmissionVehicleDefault; - public bool HybridElectricHDV - { - get { return DeclarationData.Vehicle.HybridElectricHDVDefault; } - } + public bool HybridElectricHDV => DeclarationData.Vehicle.HybridElectricHDVDefault; - public bool DualFuelVehicle - { - get { return DeclarationData.Vehicle.DualFuelVehicleDefault; } - } + public bool DualFuelVehicle => DeclarationData.Vehicle.DualFuelVehicleDefault; - public Watt MaxNetPower1 - { - get { return null; } - } + public Watt MaxNetPower1 => null; - public Watt MaxNetPower2 - { - get { return null; } - } + public Watt MaxNetPower2 => null; - public string ExemptedTechnology - { - get { return null; } - } + public string ExemptedTechnology => null; - public RegistrationClass? RegisteredClass - { - get { return RegistrationClass.unknown; } - } + public RegistrationClass? RegisteredClass => RegistrationClass.unknown; - public int? NumberPassengerSeatsUpperDeck - { - get { return 0; } - } + public int? NumberPassengerSeatsUpperDeck => 0; - public int? NumberPassengerSeatsLowerDeck - { - get { return 0; } - } + public int? NumberPassengerSeatsLowerDeck => 0; - public int? NumberPassengersStandingLowerDeck - { - get { return 0; } - } - public int? NumberPassengersStandingUpperDeck - { - get { return 0; } - } + public int? NumberPassengersStandingLowerDeck => 0; - public CubicMeter CargoVolume - { - get { return VehicleData.CargoVolume; } - } + public int? NumberPassengersStandingUpperDeck => 0; - public VehicleCode? VehicleCode - { - get { return VectoCommon.Models.VehicleCode.NOT_APPLICABLE; } - } + public CubicMeter CargoVolume => VehicleData.CargoVolume; - public bool? LowEntry - { - get { return VehicleData.LowEntry; } - } + public VehicleCode? VehicleCode => VectoCommon.Models.VehicleCode.NOT_APPLICABLE; - IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components - { - get { return this; } - } + public bool? LowEntry => VehicleData.LowEntry; - IAuxiliariesEngineeringInputData IVehicleComponentsEngineering.AuxiliaryInputData - { - get { return this; } - } + IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components => this; - IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData - { - get { return Retarder; } - } + IAuxiliariesEngineeringInputData IVehicleComponentsEngineering.AuxiliaryInputData => this; - IPTOTransmissionInputData IVehicleComponentsDeclaration.PTOTransmissionInputData - { - get { return PTOTransmission; } - } + IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData => Retarder; + + IPTOTransmissionInputData IVehicleComponentsDeclaration.PTOTransmissionInputData => PTOTransmission; #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData - public bool EngineStopStart - { - get { return DeclarationData.Vehicle.ADAS.EngineStopStartDefault; } - } + public bool EngineStopStart => DeclarationData.Vehicle.ADAS.EngineStopStartDefault; - public EcoRollType EcoRoll - { - get { return DeclarationData.Vehicle.ADAS.EcoRoll; } - } + public EcoRollType EcoRoll => DeclarationData.Vehicle.ADAS.EcoRoll; - public PredictiveCruiseControlType PredictiveCruiseControl - { - get { return DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault; } - } + public PredictiveCruiseControlType PredictiveCruiseControl => DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault; #endregion #region Implementation of IAuxiliariesEngineeringInputData - public IAuxiliaryEngineeringInputData Auxiliaries { get { return new EngineeringAuxiliaryDataInputData();} } - public IBusAuxiliariesEngineeringData BusAuxiliariesData - { - get { return BusAux; } - } - public Watt ElectricAuxPower - { - get { return 0.SI<Watt>(); } - } + public IAuxiliaryEngineeringInputData Auxiliaries => new EngineeringAuxiliaryDataInputData(); + + public IBusAuxiliariesEngineeringData BusAuxiliariesData => BusAux; + + public Watt ElectricAuxPower => 0.SI<Watt>(); #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONElectricMotor.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONElectricMotor.cs index 91d04d538134f578cb748922973bbfbbeded4b7d..c843414f177a42b7d7565694a0bd723e8c8fac05 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONElectricMotor.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONElectricMotor.cs @@ -11,105 +11,50 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { { public JSONElectricMotorV2(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) { } - public override NewtonMeter ContinuousTorque { - get { return Body.GetEx<double>("ContinuousTorque").SI<NewtonMeter>(); } - } + public override NewtonMeter ContinuousTorque => Body.GetEx<double>("ContinuousTorque").SI<NewtonMeter>(); - public override PerSecond ContinuousTorqueSpeed { - get { return Body.GetEx<double>("ContinuousTorqueSpeed").RPMtoRad(); } - } + public override PerSecond ContinuousTorqueSpeed => Body.GetEx<double>("ContinuousTorqueSpeed").RPMtoRad(); - public override NewtonMeter OverloadTorque { - get { return Body.GetEx<double>("OverloadTorque").SI<NewtonMeter>(); } - } + public override NewtonMeter OverloadTorque => Body.GetEx<double>("OverloadTorque").SI<NewtonMeter>(); - public override PerSecond OverloadTestSpeed { - get { return Body.GetEx<double>("OverloadTorqueSpeed").RPMtoRad(); } - } + public override PerSecond OverloadTestSpeed => Body.GetEx<double>("OverloadTorqueSpeed").RPMtoRad(); } public class JSONElectricMotorV1 : JSONFile, IElectricMotorEngineeringInputData { public JSONElectricMotorV1(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) { } - public virtual string Manufacturer - { - get { return Constants.NOT_AVailABLE; } - } - public virtual string Model - { - get { return Body.GetEx<string>("Model"); } - } - public virtual DateTime Date { get { return DateTime.MinValue; } } - public virtual CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } - public string CertificationNumber - { - get { return Constants.NOT_AVailABLE; } - } - public DigestData DigestValue - { - get { return null; } - } - - public virtual TableData FullLoadCurve - { - get { return ReadTableData(Body.GetEx<string>("FullLoadCurve"), "ElectricMotor FullLoadCurve"); } - } - - public virtual TableData DragCurve - { - get { return ReadTableData(Body.GetEx<string>("DragCurve"), "ElectricMotor DragCurve"); } - } - - public virtual TableData EfficiencyMap - { - get { return ReadTableData(Body.GetEx<string>("EfficiencyMap"), "ElectricMotor Map"); } - } - - public virtual KilogramSquareMeter Inertia - { - get { return Body.GetEx<double>("Inertia").SI<KilogramSquareMeter>(); } - } - - public virtual Joule OverloadBuffer - { - get { return Body.GetValueOrDefault<double>("ThermalOverloadBuffer")?.SI(Unit.SI.Mega.Joule).Cast<Joule>() ?? 1e18.SI<Joule>(); } - } - - public virtual double OverloadRecoveryFactor - { - get - { - return Body.GetValueOrDefault<double>("ThermalOverloadRecoveryFactor") ?? 0.9; - } - } - - public virtual NewtonMeter ContinuousTorque - { - get { return (Body.GetValueOrDefault<double>("ContinuousPower")?.SI<Watt>() ?? 1e12.SI<Watt>()) / (Body.GetValueOrDefault<double>("ContinuousPowerSpeed")?.RPMtoRad() ?? 1.SI<PerSecond>()) ; } - } - - public virtual PerSecond ContinuousTorqueSpeed - { - get { return Body.GetValueOrDefault<double>("ContinuousPowerSpeed")?.RPMtoRad() ?? 0.RPMtoRad(); } - } - - public virtual NewtonMeter OverloadTorque { - get { return null; } - } - - public virtual PerSecond OverloadTestSpeed - { - get { return null; } - } - - public virtual Second OverloadTime - { - get { return Body.GetValueOrDefault<double>("OverloadTime")?.SI<Second>() ?? 0.SI<Second>(); } - } + public virtual string Manufacturer => Constants.NOT_AVAILABLE; + public virtual string Model => Body.GetEx<string>("Model"); + public virtual DateTime Date => DateTime.MinValue; + + public virtual CertificationMethod CertificationMethod => CertificationMethod.NotCertified; + + public string CertificationNumber => Constants.NOT_AVAILABLE; + + public DigestData DigestValue => null; + + public virtual TableData FullLoadCurve => ReadTableData(Body.GetEx<string>("FullLoadCurve"), "ElectricMotor FullLoadCurve"); + + public virtual TableData DragCurve => ReadTableData(Body.GetEx<string>("DragCurve"), "ElectricMotor DragCurve"); + + public virtual TableData EfficiencyMap => ReadTableData(Body.GetEx<string>("EfficiencyMap"), "ElectricMotor Map"); + + public virtual KilogramSquareMeter Inertia => Body.GetEx<double>("Inertia").SI<KilogramSquareMeter>(); + + public virtual Joule OverloadBuffer => Body.GetValueOrDefault<double>("ThermalOverloadBuffer")?.SI(Unit.SI.Mega.Joule).Cast<Joule>() ?? 1e18.SI<Joule>(); + + public virtual double OverloadRecoveryFactor => Body.GetValueOrDefault<double>("ThermalOverloadRecoveryFactor") ?? 0.9; + + public virtual NewtonMeter ContinuousTorque => (Body.GetValueOrDefault<double>("ContinuousPower")?.SI<Watt>() ?? 1e12.SI<Watt>()) / (Body.GetValueOrDefault<double>("ContinuousPowerSpeed")?.RPMtoRad() ?? 1.SI<PerSecond>()); + + public virtual PerSecond ContinuousTorqueSpeed => Body.GetValueOrDefault<double>("ContinuousPowerSpeed")?.RPMtoRad() ?? 0.RPMtoRad(); + + public virtual NewtonMeter OverloadTorque => null; + + public virtual PerSecond OverloadTestSpeed => null; + + public virtual Second OverloadTime => Body.GetValueOrDefault<double>("OverloadTime")?.SI<Second>() ?? 0.SI<Second>(); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs index 277c6edb47bf522870fde73cd6a263affd18bdb6..19d9c1519d80092faeafe8d4bfcad428c7340e9d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs @@ -83,16 +83,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Overrides of JSONEngineDataV3 - public override IWHRData WasteHeatRecoveryDataElectrical - { - get { return _elWHRData ?? (_elWHRData = ReadWHRData(Body["WHRCorrectionFactors"]?["Electrical"])); } - } + public override IWHRData WasteHeatRecoveryDataElectrical => _elWHRData ?? (_elWHRData = ReadWHRData(Body["WHRCorrectionFactors"]?["Electrical"])); - public override IWHRData WasteHeatRecoveryDataMechanical - { - get { return _mechWHRData ?? (_mechWHRData = ReadWHRData(Body["WHRCorrectionFactors"]?["Mechanical"])); } - } + public override IWHRData WasteHeatRecoveryDataMechanical => _mechWHRData ?? (_mechWHRData = ReadWHRData(Body["WHRCorrectionFactors"]?["Mechanical"])); public override WHRType WHRType { @@ -197,40 +191,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Implementation of IWHRData - public double UrbanCorrectionFactor - { - get { return CorrectionFactors?["Urban"]?.ToString().ToDouble() ?? 1.0; } - } + public double UrbanCorrectionFactor => CorrectionFactors?["Urban"]?.ToString().ToDouble() ?? 1.0; - public double RuralCorrectionFactor - { - get { return CorrectionFactors?["Rural"]?.ToString().ToDouble() ?? 1.0; } - } + public double RuralCorrectionFactor => CorrectionFactors?["Rural"]?.ToString().ToDouble() ?? 1.0; - public double MotorwayCorrectionFactor - { - get { return CorrectionFactors?["Motorway"]?.ToString().ToDouble() ?? 1.0; } - } + public double MotorwayCorrectionFactor => CorrectionFactors?["Motorway"]?.ToString().ToDouble() ?? 1.0; - public double BFColdHot - { - get { return CorrectionFactors?["ColdHotBalancingFactor"]?.ToString().ToDouble() ?? 1.0; } - } + public double BFColdHot => CorrectionFactors?["ColdHotBalancingFactor"]?.ToString().ToDouble() ?? 1.0; - public double CFRegPer - { - get { return CorrectionFactors?["CFRegPer"]?.ToString().ToDouble() ?? 1.0; } - } + public double CFRegPer => CorrectionFactors?["CFRegPer"]?.ToString().ToDouble() ?? 1.0; - public double EngineeringCorrectionFactor - { - get { return CorrectionFactors?["EngineeringCorrectionFactor"]?.ToString().ToDouble() ?? 1.0; } - } + public double EngineeringCorrectionFactor => CorrectionFactors?["EngineeringCorrectionFactor"]?.ToString().ToDouble() ?? 1.0; - public TableData GeneratedPower - { - get { return WHRMap; } - } + public TableData GeneratedPower => WHRMap; #endregion } @@ -245,31 +218,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public JSONEngineDataV4(JObject data, string fileName, bool tolerateMissing = false) : base(data, fileName, tolerateMissing) { } - public override Watt RatedPowerDeclared - { - get { return Body.GetEx<double>("RatedPower").SI<Watt>(); } - } + public override Watt RatedPowerDeclared => Body.GetEx<double>("RatedPower").SI<Watt>(); - public override PerSecond RatedSpeedDeclared - { - get { return Body.GetEx<double>("RatedSpeed").RPMtoRad(); } - } + public override PerSecond RatedSpeedDeclared => Body.GetEx<double>("RatedSpeed").RPMtoRad(); - public override NewtonMeter MaxTorqueDeclared - { - get { return Body.GetEx<double>("MaxTorque").SI<NewtonMeter>(); } - } + public override NewtonMeter MaxTorqueDeclared => Body.GetEx<double>("MaxTorque").SI<NewtonMeter>(); - public override double CorrectionFactorRegPer - { - get { return Body.GetEx<double>("CFRegPer"); } - } + public override double CorrectionFactorRegPer => Body.GetEx<double>("CFRegPer"); - public override FuelType FuelType - { - get { return Body.GetEx<string>("FuelType").ParseEnum<FuelType>(); } - } + public override FuelType FuelType => Body.GetEx<string>("FuelType").ParseEnum<FuelType>(); } @@ -281,23 +239,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public JSONEngineDataV3(JObject data, string fileName, bool tolerateMissing = false) : base(data, fileName, tolerateMissing) { } - public virtual CubicMeter Displacement - { - get { return Body.GetEx<double>(JsonKeys.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); } + public virtual CubicMeter Displacement => Body.GetEx<double>(JsonKeys.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); - // convert vom ccm to m^3} - } + // convert vom ccm to m^3} + public virtual PerSecond IdleSpeed => Body.GetEx<double>(JsonKeys.Engine_IdleSpeed).RPMtoRad(); - public virtual PerSecond IdleSpeed - { - get { return Body.GetEx<double>(JsonKeys.Engine_IdleSpeed).RPMtoRad(); } - } - - public virtual FuelType FuelType - { - get { return FuelType.DieselCI; } - } + public virtual FuelType FuelType => FuelType.DieselCI; public virtual TableData FuelConsumptionMap { @@ -334,45 +282,24 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - IList<IEngineFuelEngineeringInputData> IEngineModeEngineeringInputData.Fuels - { - get { return _fuels ?? (_fuels = ReadFuels()); } - } + IList<IEngineFuelEngineeringInputData> IEngineModeEngineeringInputData.Fuels => _fuels ?? (_fuels = ReadFuels()); - public virtual IList<IEngineFuelDeclarationInputData> Fuels - { - get { return (_fuels ?? (_fuels = ReadFuels())).Cast<IEngineFuelDeclarationInputData>().ToList(); } - } + public virtual IList<IEngineFuelDeclarationInputData> Fuels => (_fuels ?? (_fuels = ReadFuels())).Cast<IEngineFuelDeclarationInputData>().ToList(); protected virtual IList<IEngineFuelEngineeringInputData> ReadFuels() { return new IEngineFuelEngineeringInputData[] { this }; } - public virtual IWHRData WasteHeatRecoveryDataElectrical - { - get { return null; } - } + public virtual IWHRData WasteHeatRecoveryDataElectrical => null; - public virtual IWHRData WasteHeatRecoveryDataMechanical - { - get { return null; } - } + public virtual IWHRData WasteHeatRecoveryDataMechanical => null; - public virtual Watt RatedPowerDeclared - { - get { return 0.SI<Watt>(); } - } + public virtual Watt RatedPowerDeclared => 0.SI<Watt>(); - public virtual PerSecond RatedSpeedDeclared - { - get { return 0.RPMtoRad(); } - } + public virtual PerSecond RatedSpeedDeclared => 0.RPMtoRad(); - public virtual NewtonMeter MaxTorqueDeclared - { - get { return 0.SI<NewtonMeter>(); } - } + public virtual NewtonMeter MaxTorqueDeclared => 0.SI<NewtonMeter>(); IList<IEngineModeEngineeringInputData> IEngineEngineeringInputData.EngineModes { @@ -384,15 +311,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return new IEngineModeDeclarationInputData[] { this }; } } - public virtual WHRType WHRType - { - get { return WHRType.None; } - } + public virtual WHRType WHRType => WHRType.None; - public virtual KilogramSquareMeter Inertia - { - get { return Body.GetEx<double>(JsonKeys.Engine_Inertia).SI<KilogramSquareMeter>(); } - } + public virtual KilogramSquareMeter Inertia => Body.GetEx<double>(JsonKeys.Engine_Inertia).SI<KilogramSquareMeter>(); public virtual double WHTCEngineering { @@ -405,25 +326,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual Second EngineStartTime - { - get { return null; } - } + public virtual Second EngineStartTime => null; - public virtual double WHTCMotorway - { - get { return Body.GetEx<double>(JsonKeys.Engine_WHTC_Motorway); } - } + public virtual double WHTCMotorway => Body.GetEx<double>(JsonKeys.Engine_WHTC_Motorway); - public virtual double WHTCRural - { - get { return Body.GetEx<double>(JsonKeys.Engine_WHTC_Rural); } - } + public virtual double WHTCRural => Body.GetEx<double>(JsonKeys.Engine_WHTC_Rural); - public virtual double WHTCUrban - { - get { return Body.GetEx<double>(JsonKeys.Engine_WHTC_Urban); } - } + public virtual double WHTCUrban => Body.GetEx<double>(JsonKeys.Engine_WHTC_Urban); public double ColdHotBalancingFactor { @@ -436,41 +345,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual double CorrectionFactorRegPer - { - get { return 1; } - } + public virtual double CorrectionFactorRegPer => 1; - public virtual string Manufacturer - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string Manufacturer => Constants.NOT_AVAILABLE; - public virtual string Model - { - get { return Body.GetEx<string>(JsonKeys.Engine_ModelName); } - } + public virtual string Model => Body.GetEx<string>(JsonKeys.Engine_ModelName); - public virtual DateTime Date - { - get { return DateTime.MinValue; } - } + public virtual DateTime Date => DateTime.MinValue; - public virtual CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public virtual CertificationMethod CertificationMethod => CertificationMethod.NotCertified; - public virtual string CertificationNumber - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string CertificationNumber => Constants.NOT_AVAILABLE; - public virtual DigestData DigestValue - { - get { return null; } - } + public virtual DigestData DigestValue => null; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs index 9c653b1ac25ff427a819f0fce811c53553c0115f..87fdde345f47aa5dfca1c115617a0aa4ebf98ef1 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs @@ -49,10 +49,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public JSONGearboxDataV6(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) {} - public override GearboxType Type - { - get { return Body.GetEx<string>(JsonKeys.Gearbox_GearboxType).ParseEnum<GearboxType>(); } - } + public override GearboxType Type => Body.GetEx<string>(JsonKeys.Gearbox_GearboxType).ParseEnum<GearboxType>(); public override IList<ITransmissionInputData> Gears { @@ -87,7 +84,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public override double AxlegearRatio { get { return Ratio; } } + public override double AxlegearRatio => Ratio; } /// <summary> @@ -176,10 +173,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public AxleLineType LineType - { - get { return AxleLineType.SingleReductionAxle; } - } + public AxleLineType LineType => AxleLineType.SingleReductionAxle; #endregion @@ -202,10 +196,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual KilogramSquareMeter Inertia - { - get { return Body.GetEx<double>(JsonKeys.Gearbox_Inertia).SI<KilogramSquareMeter>(); } - } + public virtual KilogramSquareMeter Inertia => Body.GetEx<double>(JsonKeys.Gearbox_Inertia).SI<KilogramSquareMeter>(); public virtual TableData ShiftPolygon { @@ -224,10 +215,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public Second TractionInterruption - { - get { return Body.GetEx<double>(JsonKeys.Gearbox_TractionInterruption).SI<Second>(); } - } + public Second TractionInterruption => Body.GetEx<double>(JsonKeys.Gearbox_TractionInterruption).SI<Second>(); public virtual IList<ITransmissionInputData> Gears { @@ -251,8 +239,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public bool DifferentialIncluded { get { return false; } } - public virtual double AxlegearRatio { get { return double.NaN; } } + public bool DifferentialIncluded => false; + public virtual double AxlegearRatio => double.NaN; private TransmissionInputData CreateTorqueConverterGear(int gearNr, JToken gear, JToken nextGear) { @@ -274,12 +262,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON Ratio = nextRatio, LossMap = nextGear[JsonKeys.Gearbox_Gear_LossMapFile] != null ? ReadTableData(nextGear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), - string.Format("Gear {0} LossMap", gearNr)) + $"Gear {gearNr} LossMap") : null, Efficiency = nextEfficiency, - MaxTorque = gear["MaxTorque"] != null ? gear["MaxTorque"].Value<double>().SI<NewtonMeter>() : null, + MaxTorque = gear["MaxTorque"]?.Value<double>().SI<NewtonMeter>(), ShiftPolygon = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_ShiftPolygonFile), - string.Format("Gear {0} shiftPolygon", gearNr), false), + $"Gear {gearNr} shiftPolygon", false), }; } @@ -300,7 +288,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON if (lossMap != null) { try { retVal.LossMap = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), - string.Format("Gear {0} LossMap", gearNumber)); + $"Gear {gearNumber} LossMap"); } catch (Exception) { if (!TolerateMissing) { throw; @@ -317,7 +305,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON if (shiftPolygonFile != null && !string.IsNullOrWhiteSpace(shiftPolygonFile.Value<string>())) { try { retVal.ShiftPolygon = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_ShiftPolygonFile), - string.Format("Gear {0} shiftPolygon", gearNumber)); + $"Gear {gearNumber} shiftPolygon"); } catch (Exception) { retVal.ShiftPolygon = new TableData(Path.Combine(BasePath, shiftPolygonFile.Value<string>()) + MissingFileSuffix, DataSourceType.Missing); @@ -330,158 +318,102 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON return retVal; } - public virtual Second MinTimeBetweenGearshift - { - get { return Body.GetEx<double>(JsonKeys.Gearbox_ShiftTime).SI<Second>(); } - } + public virtual Second MinTimeBetweenGearshift => Body.GetEx<double>(JsonKeys.Gearbox_ShiftTime).SI<Second>(); - public virtual double TorqueReserve - { - get { return Body.GetEx<double>(JsonKeys.Gearbox_TorqueReserve) / 100.0; } - } + public virtual double TorqueReserve => Body.GetEx<double>(JsonKeys.Gearbox_TorqueReserve) / 100.0; - public virtual MeterPerSecond StartSpeed - { - get { return Body.GetEx<double>(JsonKeys.Gearbox_StartSpeed).SI<MeterPerSecond>(); } - } + public virtual MeterPerSecond StartSpeed => Body.GetEx<double>(JsonKeys.Gearbox_StartSpeed).SI<MeterPerSecond>(); - public virtual MeterPerSquareSecond StartAcceleration - { - get { return Body.GetEx<double>(JsonKeys.Gearbox_StartAcceleration).SI<MeterPerSquareSecond>(); } - } + public virtual MeterPerSquareSecond StartAcceleration => Body.GetEx<double>(JsonKeys.Gearbox_StartAcceleration).SI<MeterPerSquareSecond>(); - public virtual double StartTorqueReserve - { - get { return Body.GetEx<double>(JsonKeys.Gearbox_StartTorqueReserve) / 100.0; } - } + public virtual double StartTorqueReserve => Body.GetEx<double>(JsonKeys.Gearbox_StartTorqueReserve) / 100.0; - - public virtual ITorqueConverterEngineeringInputData TorqueConverter - { - get { return this; } - } - public Second DownshiftAfterUpshiftDelay - { - get { - return Body["DownshiftAfterUpshiftDelay"] == null - ? DeclarationData.Gearbox.DownshiftAfterUpshiftDelay - : Body.GetEx<double>("DownshiftAfterUpshiftDelay").SI<Second>(); - } - } + public virtual ITorqueConverterEngineeringInputData TorqueConverter => this; - public Second UpshiftAfterDownshiftDelay - { - get { - return Body["UpshiftAfterDownshiftDelay"] == null - ? DeclarationData.Gearbox.UpshiftAfterDownshiftDelay - : Body.GetEx<double>("UpshiftAfterDownshiftDelay").SI<Second>(); - } - } + public Second DownshiftAfterUpshiftDelay => + Body["DownshiftAfterUpshiftDelay"] == null + ? DeclarationData.Gearbox.DownshiftAfterUpshiftDelay + : Body.GetEx<double>("DownshiftAfterUpshiftDelay").SI<Second>(); - public MeterPerSquareSecond UpshiftMinAcceleration - { - get { - return Body["UpshiftMinAcceleration"] == null - ? DeclarationData.Gearbox.UpshiftMinAcceleration - : Body.GetEx<double>("UpshiftMinAcceleration").SI<MeterPerSquareSecond>(); - } - } + public Second UpshiftAfterDownshiftDelay => + Body["UpshiftAfterDownshiftDelay"] == null + ? DeclarationData.Gearbox.UpshiftAfterDownshiftDelay + : Body.GetEx<double>("UpshiftAfterDownshiftDelay").SI<Second>(); - public Second GearResidenceTime { get { return null; } } - public double? DnT99LHMin1 { get { return null; } } - public double? DnT99LHMin2 { get { return null; } } - public int? AllowedGearRangeUp { get { return null; } } - public int? AllowedGearRangeDown { get { return null; } } - public Second LookBackInterval { get { return null; } } - public Watt AvgCardanPowerThresholdPropulsion { get { return null; } } - public Watt CurrCardanPowerThresholdPropulsion { get { return null; } } - public double? TargetSpeedDeviationFactor { get { return null; } } - public double? EngineSpeedHighDriveOffFactor { get { return null; } } - public double? RatingFactorCurrentGear { get { return null; } } - public TableData AccelerationReserveLookup { get { return null; } } - public TableData ShareTorque99L { get { return null; } } - public TableData PredictionDurationLookup { get { return null; } } - public TableData ShareIdleLow { get { return null; } } - public TableData ShareEngineHigh { get { return null; } } - public Second DriverAccelerationLookBackInterval { get { return null; } } - public MeterPerSquareSecond DriverAccelerationThresholdLow { get { return null; } } - public double? RatioEarlyUpshiftFC { get { return null; } } - public double? RatioEarlyDownshiftFC { get { return null; } } - public int? AllowedGearRangeFC { get { return null; } } - - public PerSecond MinEngineSpeedPostUpshift { get { return null; } } - public Second ATLookAheadTime { get { return null; } } - public double[][] ShiftSpeedsTCToLocked { get { return null; } } - - public double? VeloictyDropFactor - { - get { return null; } - } + public MeterPerSquareSecond UpshiftMinAcceleration => + Body["UpshiftMinAcceleration"] == null + ? DeclarationData.Gearbox.UpshiftMinAcceleration + : Body.GetEx<double>("UpshiftMinAcceleration").SI<MeterPerSquareSecond>(); - public double? AccelerationFactor - { - get { return null; } - } + public Second GearResidenceTime => null; + public double? DnT99LHMin1 => null; + public double? DnT99LHMin2 => null; + public int? AllowedGearRangeUp => null; + public int? AllowedGearRangeDown => null; + public Second LookBackInterval => null; + public Watt AvgCardanPowerThresholdPropulsion => null; + public Watt CurrCardanPowerThresholdPropulsion => null; + public double? TargetSpeedDeviationFactor => null; + public double? EngineSpeedHighDriveOffFactor => null; + public double? RatingFactorCurrentGear => null; + public TableData AccelerationReserveLookup => null; + public TableData ShareTorque99L => null; + public TableData PredictionDurationLookup => null; + public TableData ShareIdleLow => null; + public TableData ShareEngineHigh => null; + public Second DriverAccelerationLookBackInterval => null; + public MeterPerSquareSecond DriverAccelerationThresholdLow => null; + public double? RatioEarlyUpshiftFC => null; + public double? RatioEarlyDownshiftFC => null; + public int? AllowedGearRangeFC => null; - public TableData LoadStageShiftLines { get { return null; } } - public IList<double> LoadStageThresholdsUp { get { return null; } } - public IList<double> LoadStageThresholdsDown { get { return null; } } + public PerSecond MinEngineSpeedPostUpshift => null; + public Second ATLookAheadTime => null; + public double[][] ShiftSpeedsTCToLocked => null; - public Second PowershiftShiftTime - { - get { - return Body["PowershiftShiftTime"] == null - ? Constants.DefaultPowerShiftTime - : Body.GetEx<double>("PowershiftShiftTime").SI<Second>(); - } - } + public double? VeloictyDropFactor => null; - #endregion + public double? AccelerationFactor => null; - #region ITorqueConverterInputData + public TableData LoadStageShiftLines => null; + public IList<double> LoadStageThresholdsUp => null; + public IList<double> LoadStageThresholdsDown => null; - public MeterPerSquareSecond CLUpshiftMinAcceleration - { - get { - return Body[JsonKeys.Gearbox_TorqueConverter] != null && - Body[JsonKeys.Gearbox_TorqueConverter]["CLUpshiftMinAcceleration"] != null - ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CLUpshiftMinAcceleration").SI<MeterPerSquareSecond>() - : UpshiftMinAcceleration; - } - } + public Second PowershiftShiftTime => + Body["PowershiftShiftTime"] == null + ? Constants.DefaultPowerShiftTime + : Body.GetEx<double>("PowershiftShiftTime").SI<Second>(); - public MeterPerSquareSecond CCUpshiftMinAcceleration - { - get { - return Body[JsonKeys.Gearbox_TorqueConverter] != null && - Body[JsonKeys.Gearbox_TorqueConverter]["CCUpshiftMinAcceleration"] != null - ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CCUpshiftMinAcceleration").SI<MeterPerSquareSecond>() - : UpshiftMinAcceleration; - } - } + #endregion - public virtual PerSecond ReferenceRPM - { - get { - return Body[JsonKeys.Gearbox_TorqueConverter] != null && - Body[JsonKeys.Gearbox_TorqueConverter][JsonKeys.Gearbox_TorqueConverter_ReferenceRPM] != null - ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter) - .GetEx<double>(JsonKeys.Gearbox_TorqueConverter_ReferenceRPM) - .RPMtoRad() - : null; - } - } + #region ITorqueConverterInputData - public PerSecond MaxInputSpeed - { - get { - return Body[JsonKeys.Gearbox_TorqueConverter] != null && - Body[JsonKeys.Gearbox_TorqueConverter]["MaxTCSpeed"] != null - ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("MaxTCSpeed").RPMtoRad() - : 5000.RPMtoRad(); - } - } + public MeterPerSquareSecond CLUpshiftMinAcceleration => + Body[JsonKeys.Gearbox_TorqueConverter] != null && + Body[JsonKeys.Gearbox_TorqueConverter]["CLUpshiftMinAcceleration"] != null + ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CLUpshiftMinAcceleration").SI<MeterPerSquareSecond>() + : UpshiftMinAcceleration; + + public MeterPerSquareSecond CCUpshiftMinAcceleration => + Body[JsonKeys.Gearbox_TorqueConverter] != null && + Body[JsonKeys.Gearbox_TorqueConverter]["CCUpshiftMinAcceleration"] != null + ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CCUpshiftMinAcceleration").SI<MeterPerSquareSecond>() + : UpshiftMinAcceleration; + + public virtual PerSecond ReferenceRPM => + Body[JsonKeys.Gearbox_TorqueConverter] != null && + Body[JsonKeys.Gearbox_TorqueConverter][JsonKeys.Gearbox_TorqueConverter_ReferenceRPM] != null + ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter) + .GetEx<double>(JsonKeys.Gearbox_TorqueConverter_ReferenceRPM) + .RPMtoRad() + : null; + + public PerSecond MaxInputSpeed => + Body[JsonKeys.Gearbox_TorqueConverter] != null && + Body[JsonKeys.Gearbox_TorqueConverter]["MaxTCSpeed"] != null + ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("MaxTCSpeed").RPMtoRad() + : 5000.RPMtoRad(); public virtual TableData TCData { @@ -503,48 +435,26 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - KilogramSquareMeter ITorqueConverterEngineeringInputData.Inertia - { - get { - return Body[JsonKeys.Gearbox_TorqueConverter] != null && - Body[JsonKeys.Gearbox_TorqueConverter][JsonKeys.Gearbox_TorqueConverter_Inertia] != null - ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter) - .GetEx<double>(JsonKeys.Gearbox_TorqueConverter_Inertia) - .SI<KilogramSquareMeter>() - : null; - } - } + KilogramSquareMeter ITorqueConverterEngineeringInputData.Inertia => + Body[JsonKeys.Gearbox_TorqueConverter] != null && + Body[JsonKeys.Gearbox_TorqueConverter][JsonKeys.Gearbox_TorqueConverter_Inertia] != null + ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter) + .GetEx<double>(JsonKeys.Gearbox_TorqueConverter_Inertia) + .SI<KilogramSquareMeter>() + : null; #endregion - public string Manufacturer - { - get { return Constants.NOT_AVailABLE; } - } + public string Manufacturer => Constants.NOT_AVAILABLE; - public string Model - { - get { return Body.GetEx<string>(JsonKeys.Gearbox_ModelName); } - } + public string Model => Body.GetEx<string>(JsonKeys.Gearbox_ModelName); - public DateTime Date - { - get { return DateTime.MinValue; } - } + public DateTime Date => DateTime.MinValue; - public CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public CertificationMethod CertificationMethod => CertificationMethod.NotCertified; - public string CertificationNumber - { - get { return Constants.NOT_AVailABLE; } - } + public string CertificationNumber => Constants.NOT_AVAILABLE; - public DigestData DigestValue - { - get { return null; } - } + public DigestData DigestValue => null; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONHybridStrategyParameters.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONHybridStrategyParameters.cs index a6becdc4b968c17c33f7fa1ccb39e1d4de0db104..88d689d7812466f37baf1bc36479ce8778e3f1c1 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONHybridStrategyParameters.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONHybridStrategyParameters.cs @@ -9,75 +9,28 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public JSONHybridStrategyParameters(JObject json, string filename, bool tolerateMissing) : base(json, filename, tolerateMissing) { } - public double EquivalenceFactorDischarge - { - get - { - return Body["EquivalenceFactor"] == null ? Body.GetEx<double>("EquivalenceFactorDischarge") : - Body.GetEx<double>("EquivalenceFactor"); - } - } + public double EquivalenceFactorDischarge => + Body["EquivalenceFactor"] == null ? Body.GetEx<double>("EquivalenceFactorDischarge") : + Body.GetEx<double>("EquivalenceFactor"); - public double EquivalenceFactorCharge { - get { - return Body["EquivalenceFactor"] == null ? Body.GetEx<double>("EquivalenceFactorCharge") : - Body.GetEx<double>("EquivalenceFactor"); - } - } + public double EquivalenceFactorCharge => + Body["EquivalenceFactor"] == null ? Body.GetEx<double>("EquivalenceFactorCharge") : + Body.GetEx<double>("EquivalenceFactor"); - public double MinSoC - { - get - { - return Body.GetEx<double>("MinSoC") / 100.0; - } - } + public double MinSoC => Body.GetEx<double>("MinSoC") / 100.0; - public double MaxSoC - { - get - { - return Body.GetEx<double>("MaxSoC") / 100.0; - } - } + public double MaxSoC => Body.GetEx<double>("MaxSoC") / 100.0; - public double TargetSoC - { - get - { - return Body.GetEx<double>("TargetSoC") / 100.0; - } - } + public double TargetSoC => Body.GetEx<double>("TargetSoC") / 100.0; - public Second MinimumICEOnTime - { - get { return Body.GetEx<double>("MinICEOnTime").SI<Second>(); } - } + public Second MinimumICEOnTime => Body.GetEx<double>("MinICEOnTime").SI<Second>(); - public Second AuxBufferTime - { - get { return Body.GetEx<double>("AuxBufferTime").SI<Second>(); } - } + public Second AuxBufferTime => Body.GetEx<double>("AuxBufferTime").SI<Second>(); - public Second AuxBufferChargeTime - { - get { return Body.GetEx<double>("AuxBufferChgTime").SI<Second>(); } - } + public Second AuxBufferChargeTime => Body.GetEx<double>("AuxBufferChgTime").SI<Second>(); - public double ICEStartPenaltyFactor - { - get - { - return Body["ICEStartPenaltyFactor"] == null ? 0 : Body.GetEx<double>("ICEStartPenaltyFactor"); - } - } + public double ICEStartPenaltyFactor => Body["ICEStartPenaltyFactor"] == null ? 0 : Body.GetEx<double>("ICEStartPenaltyFactor"); - public double CostFactorSOCExpponent - { - get - { - return Body["CostFactorSOCExponent"] == null ? double.NaN : Body.GetEx<double>("CostFactorSOCExponent"); - } - } + public double CostFactorSOCExpponent => Body["CostFactorSOCExponent"] == null ? double.NaN : Body.GetEx<double>("CostFactorSOCExponent"); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 9423f90afb9cab310a78fcb09c6af0f7a29e1f40..07b7db4ab710862123b087c404253d0929d8a5cd 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -78,29 +78,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON protected internal bool TolerateMissing { get; set; } - public DataSource DataSource - { - get { - return new DataSource { SourceType = DataSourceType.JSONFile, SourceFile = _sourceFile, SourceVersion = Version }; - } - } + public DataSource DataSource => new DataSource { SourceType = DataSourceType.JSONFile, SourceFile = _sourceFile, SourceVersion = Version }; - public string Source - { - get { return _sourceFile; } - } + public string Source => _sourceFile; - public virtual bool SavedInDeclarationMode - { - get { return Body.GetEx(JsonKeys.SavedInDeclMode).Value<bool>(); } - } + public virtual bool SavedInDeclarationMode => Body.GetEx(JsonKeys.SavedInDeclMode).Value<bool>(); - public virtual string AppVersion { get { return "VECTO-JSON"; } } + public virtual string AppVersion => "VECTO-JSON"; - internal string BasePath - { - get { return Path.GetDirectoryName(_sourceFile); } - } + internal string BasePath => Path.GetDirectoryName(_sourceFile); protected internal TableData ReadTableData(string filename, string tableType, bool required = true) { @@ -156,20 +142,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IGearshiftEngineeringInputData GearshiftInputData { get; internal set; } - public virtual IEngineStopStartEngineeringInputData EngineStopStartData - { - get { return null; } - } + public virtual IEngineStopStartEngineeringInputData EngineStopStartData => null; - public virtual IEcoRollEngineeringInputData EcoRollData - { - get { return null; } - } + public virtual IEcoRollEngineeringInputData EcoRollData => null; - public virtual IPCCEngineeringInputData PCCData - { - get { return null; } - } + public virtual IPCCEngineeringInputData PCCData => null; public IAxleGearInputData AxleGear { get; internal set; } @@ -183,15 +160,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON private IBusAuxiliariesEngineeringData _busAux; - public IAuxiliariesEngineeringInputData EngineeringAuxiliaries - { - get { return this; } - } + public IAuxiliariesEngineeringInputData EngineeringAuxiliaries => this; - public IAuxiliariesDeclarationInputData DeclarationAuxiliaries - { - get { return this; } - } + public IAuxiliariesDeclarationInputData DeclarationAuxiliaries => this; protected IVehicleEngineeringInputData ReadVehicle() { @@ -258,34 +229,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region IInputDataProvider - IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle - { - get { return VehicleInputData; } - } + IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle => VehicleInputData; - public virtual IHybridStrategyParameters HybridStrategyParameters - { - get { return null; } - } + public virtual IHybridStrategyParameters HybridStrategyParameters => null; - public virtual IEngineeringJobInputData JobInputData - { - get { return this; } - } + public virtual IEngineeringJobInputData JobInputData => this; - public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData { - get { return null; } - } + public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData => null; - public XElement XMLHash - { - get { return new XElement(XMLNames.DI_Signature); } - } + public XElement XMLHash => new XElement(XMLNames.DI_Signature); - IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData - { - get { return this; } - } + IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData => this; public virtual IVehicleEngineeringInputData VehicleInputData { @@ -315,25 +269,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual TableData PTOCycleWhileDrive - { - get { return null; } - } + public virtual TableData PTOCycleWhileDrive => null; - IDriverEngineeringInputData IEngineeringInputDataProvider.DriverInputData - { - get { return this; } - } + IDriverEngineeringInputData IEngineeringInputDataProvider.DriverInputData => this; - #endregion #region IJobInputData - public virtual IVehicleEngineeringInputData Vehicle - { - get { return VehicleData; } - } + public virtual IVehicleEngineeringInputData Vehicle => VehicleData; public virtual IList<ICycleData> Cycles { @@ -380,15 +324,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual VectoSimulationJobType JobType - { - get { return Body.GetEx(JsonKeys.Job_EngineOnlyMode).Value<bool>() ? VectoSimulationJobType.EngineOnlySimulation : VectoSimulationJobType.ConventionalVehicle; } - } + public virtual VectoSimulationJobType JobType => Body.GetEx(JsonKeys.Job_EngineOnlyMode).Value<bool>() ? VectoSimulationJobType.EngineOnlySimulation : VectoSimulationJobType.ConventionalVehicle; - public virtual string JobName - { - get { return _jobname; } - } + public virtual string JobName => _jobname; public string ShiftStrategy { @@ -547,15 +485,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region IAuxiliariesEngineeringInputData - IAuxiliaryEngineeringInputData IAuxiliariesEngineeringInputData.Auxiliaries - { - get { return new EngineeringAuxiliaryDataInputData() { + IAuxiliaryEngineeringInputData IAuxiliariesEngineeringInputData.Auxiliaries => + new EngineeringAuxiliaryDataInputData() { ElectricPowerDemand = Body["Padd_electric"] != null ? Body.GetEx<double>("Padd_electric").SI<Watt>() : 0.SI<Watt>(), ConstantPowerDemand = Body["Padd"] != null ? Body.GetEx<double>("Padd").SI<Watt>() : 0.SI<Watt>(), PowerDemandICEOffDriving = Body["Paux_ICEOff_Driving"] != null ? Body.GetEx<double>("Paux_ICEOff_Driving").SI<Watt>() : 0.SI<Watt>(), PowerDemandICEOffStandstill = Body["Paux_ICEOff_Standstill"] != null ? Body.GetEx<double>("Paux_ICEOff_Standstill").SI<Watt>() : 0.SI<Watt>() - }; } - } + }; public IBusAuxiliariesEngineeringData BusAuxiliariesData { @@ -569,10 +505,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - IList<IAuxiliaryDeclarationInputData> IAuxiliariesDeclarationInputData.Auxiliaries - { - get { return AuxData().Cast<IAuxiliaryDeclarationInputData>().ToList(); } - } + IList<IAuxiliaryDeclarationInputData> IAuxiliariesDeclarationInputData.Auxiliaries => AuxData().Cast<IAuxiliaryDeclarationInputData>().ToList(); protected virtual IList<IAuxiliaryDeclarationInputData> AuxData() { @@ -696,15 +629,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public JSONInputDataV4(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) { } - public override TableData PTOCycleWhileDrive - { - get { return Body["PTOCycleDuringDrive"] != null ? VectoCSVFile.Read(Path.Combine(BasePath, Body.GetEx<string>("PTOCycleDuringDrive"))) : null; } - } - public override IGearshiftEngineeringInputData GearshiftInputData { get { - return Body["TCU"] == null + public override TableData PTOCycleWhileDrive => Body["PTOCycleDuringDrive"] != null ? VectoCSVFile.Read(Path.Combine(BasePath, Body.GetEx<string>("PTOCycleDuringDrive"))) : null; + + public override IGearshiftEngineeringInputData GearshiftInputData => + Body["TCU"] == null ? null : JSONInputDataFactory.ReadShiftParameters(Path.Combine(BasePath, Body.GetEx<string>("TCU")), false); - } } } public class JSONVTPInputDataV4 : JSONFile, IVTPEngineeringInputDataProvider, IVTPEngineeringJobInputData, @@ -732,37 +662,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON _inputReader = kernel.Get<IXMLInputDataReader>(); } - public IVTPEngineeringJobInputData JobInputData - { - get { return this; } - } + public IVTPEngineeringJobInputData JobInputData => this; - public IManufacturerReport ManufacturerReportInputData - { - get { return this; } - } + public IManufacturerReport ManufacturerReportInputData => this; - public IVehicleDeclarationInputData Vehicle - { - get { - return _inputReader.CreateDeclaration( - Path.Combine(Path.GetFullPath(BasePath), Body["DeclarationVehicle"].Value<string>())).JobInputData.Vehicle; - } - } + public IVehicleDeclarationInputData Vehicle => + _inputReader.CreateDeclaration( + Path.Combine(Path.GetFullPath(BasePath), Body["DeclarationVehicle"].Value<string>())).JobInputData.Vehicle; public IVectoHash VectoJobHash { get; } public IVectoHash VectoManufacturerReportHash { get; } - public Meter Mileage - { - get { return Body.GetEx<double>("Mileage").SI(Unit.SI.Kilo.Meter).Cast<Meter>(); } - } + public Meter Mileage => Body.GetEx<double>("Mileage").SI(Unit.SI.Kilo.Meter).Cast<Meter>(); - string IManufacturerReport.Source - { - get { return Body["ManufacturerRecord"].Value<string>(); } - } + string IManufacturerReport.Source => Body["ManufacturerRecord"].Value<string>(); public IResultsInputData Results { @@ -803,17 +717,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx("FanPowerCoefficients").Select(entry => entry.ToString().ToDouble()).ToList(); } } - public Meter FanDiameter - { - get { return Body.GetEx<double>("FanDiameter").SI<Meter>(); } - } + public Meter FanDiameter => Body.GetEx<double>("FanDiameter").SI<Meter>(); #region Implementation of IVTPDeclarationInputDataProvider - IVTPDeclarationJobInputData IVTPDeclarationInputDataProvider.JobInputData - { - get { return JobInputData; } - } + IVTPDeclarationJobInputData IVTPDeclarationInputDataProvider.JobInputData => JobInputData; #endregion @@ -927,7 +835,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON x => new KeyValuePair<FuelType, JoulePerMeter>( x.Attributes.GetNamedItem(XMLNames.Report_Results_Fuel_Type_Attr).InnerText.ParseEnum<FuelType>(), x.SelectSingleNode( - string.Format("./*[local-name()='{0}' and @unit='MJ/km']", XMLNames.Report_Result_EnergyConsumption)) + $"./*[local-name()='{XMLNames.Report_Result_EnergyConsumption}' and @unit='MJ/km']") ?.InnerText .ToDouble().SI(Unit.SI.Mega.Joule.Per.Kilo.Meter).Cast<JoulePerMeter>())) .ToDictionary(x => x.Key, x => x.Value), @@ -970,58 +878,48 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Overrides of JSONInputDataV2 - public override IEngineStopStartEngineeringInputData EngineStopStartData - { - get { - return engineStopStartData ?? (engineStopStartData = new EngineStopStartInputData { - MaxEngineOffTimespan = Body["EngineStopStartMaxOffTimespan"] == null - ? null - : Body.GetEx<double>("EngineStopStartMaxOffTimespan").SI<Second>(), - UtilityFactorStandstill = Body["EngineStopStartUtilityFactor"] == null + public override IEngineStopStartEngineeringInputData EngineStopStartData => + engineStopStartData ?? (engineStopStartData = new EngineStopStartInputData { + MaxEngineOffTimespan = Body["EngineStopStartMaxOffTimespan"] == null + ? null + : Body.GetEx<double>("EngineStopStartMaxOffTimespan").SI<Second>(), + UtilityFactorStandstill = Body["EngineStopStartUtilityFactor"] == null + ? DeclarationData.Driver.EngineStopStart.UtilityFactor + : Body.GetEx<double>("EngineStopStartUtilityFactor"), + UtilityFactorDriving = Body["EngineStopStartUtilityFactorDriving"] == null + ? (Body["EngineStopStartUtilityFactor"] == null ? DeclarationData.Driver.EngineStopStart.UtilityFactor - : Body.GetEx<double>("EngineStopStartUtilityFactor"), - UtilityFactorDriving = Body["EngineStopStartUtilityFactorDriving"] == null - ? (Body["EngineStopStartUtilityFactor"] == null - ? DeclarationData.Driver.EngineStopStart.UtilityFactor - : Body.GetEx<double>("EngineStopStartUtilityFactor")) - : Body.GetEx<double>("EngineStopStartUtilityFactorDriving"), - ActivationDelay = Body["EngineStopStartAtVehicleStopThreshold"] == null - ? null - : Body.GetEx<double>("EngineStopStartAtVehicleStopThreshold").SI<Second>() - }); - } - } + : Body.GetEx<double>("EngineStopStartUtilityFactor")) + : Body.GetEx<double>("EngineStopStartUtilityFactorDriving"), + ActivationDelay = Body["EngineStopStartAtVehicleStopThreshold"] == null + ? null + : Body.GetEx<double>("EngineStopStartAtVehicleStopThreshold").SI<Second>() + }); - public override IEcoRollEngineeringInputData EcoRollData - { - get { - return ecoRollData ?? (ecoRollData = new EcoRollInputData { - UnderspeedThreshold = Body["EcoRollUnderspeedThreshold"] == null - ? null - : Body.GetEx<double>("EcoRollUnderspeedThreshold").KMPHtoMeterPerSecond(), - MinSpeed = Body["EcoRollMinSpeed"] == null - ? null - : Body.GetEx<double>("EcoRollMinSpeed").KMPHtoMeterPerSecond(), - ActivationDelay = Body["EcoRollActivationDelay"] == null - ? null - : Body.GetEx<double>("EcoRollActivationDelay").SI<Second>(), - AccelerationUpperLimit = Body["EcoRollMaxAcceleration"] == null? null : Body.GetEx<double>("EcoRollMaxAcceleration").SI<MeterPerSquareSecond>() - }); - } - } + public override IEcoRollEngineeringInputData EcoRollData => + ecoRollData ?? (ecoRollData = new EcoRollInputData { + UnderspeedThreshold = Body["EcoRollUnderspeedThreshold"] == null + ? null + : Body.GetEx<double>("EcoRollUnderspeedThreshold").KMPHtoMeterPerSecond(), + MinSpeed = Body["EcoRollMinSpeed"] == null + ? null + : Body.GetEx<double>("EcoRollMinSpeed").KMPHtoMeterPerSecond(), + ActivationDelay = Body["EcoRollActivationDelay"] == null + ? null + : Body.GetEx<double>("EcoRollActivationDelay").SI<Second>(), + AccelerationUpperLimit = Body["EcoRollMaxAcceleration"] == null? null : Body.GetEx<double>("EcoRollMaxAcceleration").SI<MeterPerSquareSecond>() + }); - public override IPCCEngineeringInputData PCCData - { - get { return pccData ?? (pccData = new PCCInputData() { + public override IPCCEngineeringInputData PCCData => + pccData ?? (pccData = new PCCInputData() { PCCEnabledSpeed = Body["PCCEnableSpeed"] == null ? null : Body.GetEx<double>("PCCEnableSpeed").KMPHtoMeterPerSecond(), MinSpeed = Body["PCCMinSpeed"] == null ? null : Body.GetEx<double>("PCCMinSpeed").KMPHtoMeterPerSecond(), Underspeed = Body["PCCUnderspeed"] == null ? null : Body.GetEx<double>("PCCUnderspeed").KMPHtoMeterPerSecond(), OverspeedUseCase3 = Body["PCCOverspeed"] == null ? null : Body.GetEx<double>("PCCOverspeed").KMPHtoMeterPerSecond(), PreviewDistanceUseCase1 = Body["PCCPreviewDistanceUC1"] == null ? null : Body.GetEx<double>("PCCPreviewDistanceUC1").SI<Meter>(), PreviewDistanceUseCase2 = Body["PCCPreviewDistanceUC2"] == null ? null : Body.GetEx<double>("PCCPreviewDistanceUC2").SI<Meter>() - }); } - } + }); #endregion } @@ -1101,7 +999,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Overrides of JSONFile - public override bool SavedInDeclarationMode { get { return true; } } + public override bool SavedInDeclarationMode => true; #endregion @@ -1114,21 +1012,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Implementation of IDeclarationInputDataProvider - public IDeclarationJobInputData JobInputData { get { return this; } } - public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData { get { return null; } } - public XElement XMLHash { get { return new XElement(XMLNames.DI_Signature); } } + public IDeclarationJobInputData JobInputData => this; + public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData => null; + public XElement XMLHash => new XElement(XMLNames.DI_Signature); #endregion #region Implementation of IDeclarationJobInputData - public IVehicleDeclarationInputData Vehicle { get { return PrimaryVehicle; } } + public IVehicleDeclarationInputData Vehicle => PrimaryVehicle; public string JobName { get; } - public string ShiftStrategy { get { return ""; } } - public VectoSimulationJobType JobType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public string ShiftStrategy => ""; + + public VectoSimulationJobType JobType => VectoSimulationJobType.ConventionalVehicle; #endregion } @@ -1168,13 +1064,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Overrides of JSONFile - public override bool SavedInDeclarationMode { get { return true; } } + public override bool SavedInDeclarationMode => true; #endregion #region Implementation of IDeclarationInputDataProvider - public IDeclarationJobInputData JobInputData { get { return this; } } + public IDeclarationJobInputData JobInputData => this; public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData { get; } public XElement XMLHash { get; } @@ -1184,11 +1080,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public IVehicleDeclarationInputData Vehicle { get; } public string JobName { get; } - public string ShiftStrategy { get { return ""; } } - public VectoSimulationJobType JobType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public string ShiftStrategy => ""; + + public VectoSimulationJobType JobType => VectoSimulationJobType.ConventionalVehicle; #endregion } @@ -1197,24 +1091,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { public JSONInputDataV8_Hybrid(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) { } - public override VectoSimulationJobType JobType - { - get - { - return VectoSimulationJobType.ParallelHybridVehicle; - } - } - - public override IHybridStrategyParameters HybridStrategyParameters - { - get - { - return Body["HybridStrategyParams"] == null - ? null : JSONInputDataFactory.ReadHybridStrategyParameters( - Path.Combine(BasePath, Body.GetEx<string>("HybridStrategyParams")), false); - } - } + public override VectoSimulationJobType JobType => VectoSimulationJobType.ParallelHybridVehicle; + public override IHybridStrategyParameters HybridStrategyParameters => + Body["HybridStrategyParams"] == null + ? null : JSONInputDataFactory.ReadHybridStrategyParameters( + Path.Combine(BasePath, Body.GetEx<string>("HybridStrategyParams")), false); } public class JSONInputDataV9_BEV : AbstractJSONInputData @@ -1233,17 +1115,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public override VectoSimulationJobType JobType - { - get { return VectoSimulationJobType.BatteryElectricVehicle; } - } + public override VectoSimulationJobType JobType => VectoSimulationJobType.BatteryElectricVehicle; - public override IGearshiftEngineeringInputData GearshiftInputData { - get { - return Body["TCU"] == null - ? null - : JSONInputDataFactory.ReadShiftParameters(Path.Combine(BasePath, Body.GetEx<string>("TCU")), false); - } - } + public override IGearshiftEngineeringInputData GearshiftInputData => + Body["TCU"] == null + ? null + : JSONInputDataFactory.ReadShiftParameters(Path.Combine(BasePath, Body.GetEx<string>("TCU")), false); } } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs index d3c28e7c63f292e7115c79a8c222f3b4c3c7eb94..592b5b345969242f525accddfd16a8365d490540 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs @@ -22,63 +22,36 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON Base = jsonFile; } - protected JObject Body - { - get { return Base.Body; } - } + protected JObject Body => Base.Body; protected TableData ReadTableData(string filename, string tableType, bool required = true) { return Base.ReadTableData(filename, tableType, required); } - protected string BasePath - { - get { return Base.BasePath; } - } - protected bool TolerateMissing - { - get { return Base.TolerateMissing; } - } + protected string BasePath => Base.BasePath; - public DataSource DataSource - { - get { return Base.DataSource; } - } - public bool SavedInDeclarationMode - { - get { return Base.SavedInDeclarationMode; } - } - public string Manufacturer - { - get { return Base.Manufacturer; } - } - public string Model - { - get { return Base.Model; } - } - public DateTime Date - { - get { return Base.Date; } - } - public string AppVersion - { - get { return Base.AppVersion; } - } - public CertificationMethod CertificationMethod - { - get { return Base.CertificationMethod; } - } - public string CertificationNumber - { - get { return Base.CertificationNumber; } - } - public DigestData DigestValue - { - get { return Base.DigestValue; } - } + protected bool TolerateMissing => Base.TolerateMissing; + + public DataSource DataSource => Base.DataSource; + + public bool SavedInDeclarationMode => Base.SavedInDeclarationMode; + + public string Manufacturer => Base.Manufacturer; + + public string Model => Base.Model; + + public DateTime Date => Base.Date; + + public string AppVersion => Base.AppVersion; + + public CertificationMethod CertificationMethod => Base.CertificationMethod; + + public string CertificationNumber => Base.CertificationNumber; + + public DigestData DigestValue => Base.DigestValue; - public virtual XmlNode XMLSource { get { return Base.XMLSource; } } + public virtual XmlNode XMLSource => Base.XMLSource; } // ################################################################### @@ -100,10 +73,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual double Ratio - { - get { return Body.GetEx(JsonKeys.Vehicle_Retarder).GetEx<double>(JsonKeys.Vehicle_Retarder_Ratio); } - } + public virtual double Ratio => Body.GetEx(JsonKeys.Vehicle_Retarder).GetEx<double>(JsonKeys.Vehicle_Retarder_Ratio); public virtual TableData LossMap { @@ -246,10 +216,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual double Efficiency - { - get { return Body.GetEx(JsonKeys.Vehicle_Angledrive).GetEx<double>(JsonKeys.Vehicle_Angledrive_Efficiency); } - } + public virtual double Efficiency => Body.GetEx(JsonKeys.Vehicle_Angledrive).GetEx<double>(JsonKeys.Vehicle_Angledrive_Efficiency); #endregion } @@ -263,36 +230,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Airdrag - public virtual SquareMeter AirDragArea - { - get - { - return Body[JsonKeys.Vehicle_DragCoefficient] == null - ? null - : Body.GetEx<double>(JsonKeys.Vehicle_DragCoefficient).SI<SquareMeter>(); - } - } + public virtual SquareMeter AirDragArea => + Body[JsonKeys.Vehicle_DragCoefficient] == null + ? null + : Body.GetEx<double>(JsonKeys.Vehicle_DragCoefficient).SI<SquareMeter>(); - public SquareMeter TransferredAirDragArea - { - get - { - return AirDragArea; - } - } + public SquareMeter TransferredAirDragArea => AirDragArea; - public SquareMeter AirDragArea_0 - { - get - { - return AirDragArea; - } - } + public SquareMeter AirDragArea_0 => AirDragArea; - public virtual CrossWindCorrectionMode CrossWindCorrectionMode - { - get { return CrossWindCorrectionModeHelper.Parse(Body.GetEx<string>("CdCorrMode")); } - } + public virtual CrossWindCorrectionMode CrossWindCorrectionMode => CrossWindCorrectionModeHelper.Parse(Body.GetEx<string>("CdCorrMode")); public virtual TableData CrosswindCorrectionMap { @@ -462,25 +409,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData - public virtual bool EngineStopStart - { - get { return DeclarationData.Vehicle.ADAS.EngineStopStartDefault; } - } + public virtual bool EngineStopStart => DeclarationData.Vehicle.ADAS.EngineStopStartDefault; - public virtual EcoRollType EcoRoll - { - get { return DeclarationData.Vehicle.ADAS.EcoRoll; } - } + public virtual EcoRollType EcoRoll => DeclarationData.Vehicle.ADAS.EcoRoll; - public virtual PredictiveCruiseControlType PredictiveCruiseControl - { - get { return DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault; } - } + public virtual PredictiveCruiseControlType PredictiveCruiseControl => DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault; - public virtual bool? ATEcoRollReleaseLockupClutch - { - get { return null; } - } + public virtual bool? ATEcoRollReleaseLockupClutch => null; #endregion @@ -494,20 +429,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Overrides of JSONADASInputDataV7 - public override bool EngineStopStart - { - get { return Body.GetEx<bool>("EngineStopStart"); } - } + public override bool EngineStopStart => Body.GetEx<bool>("EngineStopStart"); - public override EcoRollType EcoRoll - { - get { return EcorollTypeHelper.Parse(Body.GetEx<string>("EcoRoll")); } - } + public override EcoRollType EcoRoll => EcorollTypeHelper.Parse(Body.GetEx<string>("EcoRoll")); - public override PredictiveCruiseControlType PredictiveCruiseControl - { - get { return Body.GetEx<string>("PredictiveCruiseControl").ParseEnum<PredictiveCruiseControlType>(); } - } + public override PredictiveCruiseControlType PredictiveCruiseControl => Body.GetEx<string>("PredictiveCruiseControl").ParseEnum<PredictiveCruiseControlType>(); #endregion } @@ -518,10 +444,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { public JSONADASInputDataV9(JSONVehicleDataV7 vehicle) : base(vehicle) { } - public override bool? ATEcoRollReleaseLockupClutch - { - get { return Body["ATEcoRollReleaseLockupClutch"]?.Value<bool>(); } - } + public override bool? ATEcoRollReleaseLockupClutch => Body["ATEcoRollReleaseLockupClutch"]?.Value<bool>(); } // ------------------------------------------------------------------- @@ -530,15 +453,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { public JSONADASInputDataV10BEV(JSONVehicleDataV7 vehicle) : base(vehicle) { } - public override bool EngineStopStart - { - get { return false; } - } + public override bool EngineStopStart => false; - public override EcoRollType EcoRoll - { - get { return EcoRollType.None; } - } + public override EcoRollType EcoRoll => EcoRollType.None; } // ################################################################### @@ -552,52 +469,28 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Implementation of IBusAuxiliariesDeclarationData - public virtual string FanTechnology - { - get { return Body["Aux"]?.Value<string>("FanTechnology"); } - } + public virtual string FanTechnology => Body["Aux"]?.Value<string>("FanTechnology"); public virtual IList<string> SteeringPumpTechnology { get { return Body["Aux"]?["SteeringPumpTechnology"].Select(x => x.Value<string>()).ToList(); } } - public virtual IElectricSupplyDeclarationData ElectricSupply - { - get { return this; } - } + public virtual IElectricSupplyDeclarationData ElectricSupply => this; - public virtual IElectricConsumersDeclarationData ElectricConsumers - { - get { return this; } - } + public virtual IElectricConsumersDeclarationData ElectricConsumers => this; - public virtual IPneumaticSupplyDeclarationData PneumaticSupply - { - get { return this; } - } + public virtual IPneumaticSupplyDeclarationData PneumaticSupply => this; - public virtual IPneumaticConsumersDeclarationData PneumaticConsumers - { - get { return this; } - } + public virtual IPneumaticConsumersDeclarationData PneumaticConsumers => this; - public virtual IHVACBusAuxiliariesDeclarationData HVACAux - { - get { return this; } - } + public virtual IHVACBusAuxiliariesDeclarationData HVACAux => this; #endregion #region Implementation of IElectricSupplyDeclarationData - public virtual AlternatorType AlternatorTechnology - { - get - { - return Body["Aux"]?["ElectricSupply"]?.GetEx<string>("Technology").ParseEnum<AlternatorType>() ?? AlternatorType.Conventional; - } - } + public virtual AlternatorType AlternatorTechnology => Body["Aux"]?["ElectricSupply"]?.GetEx<string>("Technology").ParseEnum<AlternatorType>() ?? AlternatorType.Conventional; public virtual IList<IAlternatorDeclarationInputData> Alternators { @@ -633,40 +526,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Implementation of IElectricConsumersDeclarationData - public virtual bool? InteriorLightsLED - { - get { return false; } - } + public virtual bool? InteriorLightsLED => false; - public virtual bool? DayrunninglightsLED - { - get { return false; } - } + public virtual bool? DayrunninglightsLED => false; - public virtual bool? PositionlightsLED - { - get { return false; } - } + public virtual bool? PositionlightsLED => false; - public virtual bool? HeadlightsLED - { - get { return false; } - } + public virtual bool? HeadlightsLED => false; - public virtual bool? BrakelightsLED - { - get { return false; } - } + public virtual bool? BrakelightsLED => false; - public virtual bool SmartElectrics - { - get { return Body["Aux"]?["ElectricSupply"]?.GetEx<bool>("SmartElectrics") ?? false; } - } + public virtual bool SmartElectrics => Body["Aux"]?["ElectricSupply"]?.GetEx<bool>("SmartElectrics") ?? false; - public WattSecond ElectricStorageCapacity - { - get { return Body["Aux"]?["ElectricSupply"]?.GetEx<double>("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>() ?? null; } - } + public WattSecond ElectricStorageCapacity => Body["Aux"]?["ElectricSupply"]?.GetEx<double>("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>() ?? null; #endregion @@ -674,14 +546,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public CompressorDrive CompressorDrive { get; } public string Clutch { get; } - public virtual double Ratio { get { return Body["Aux"]?["PneumaticSupply"]?.GetEx<double>("Ratio") ?? 0.0; } } - public virtual string CompressorSize - { - get - { - return Body["Aux"]?["PneumaticSupply"]?.GetEx<string>("CompressorSize"); - } - } + public virtual double Ratio => Body["Aux"]?["PneumaticSupply"]?.GetEx<double>("Ratio") ?? 0.0; + + public virtual string CompressorSize => Body["Aux"]?["PneumaticSupply"]?.GetEx<string>("CompressorSize"); public bool SmartAirCompression { get; } public bool SmartRegeneration { get; } @@ -690,42 +557,31 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Implementation of IPneumaticConsumersDeclarationData - public virtual ConsumerTechnology AirsuspensionControl - { - get - { - return Body["Aux"]?["PneumaticConsumers"]?.GetEx<string>("AirsuspensionControl").ParseEnum<ConsumerTechnology>() ?? - ConsumerTechnology.Unknown; - } - } - public virtual ConsumerTechnology AdBlueDosing - { - get - { - return Body["Aux"]?["PneumaticConsumers"]?.GetEx<string>("AdBlueDosing").ParseEnum<ConsumerTechnology>() ?? - ConsumerTechnology.Unknown; - } - } + public virtual ConsumerTechnology AirsuspensionControl => + Body["Aux"]?["PneumaticConsumers"]?.GetEx<string>("AirsuspensionControl").ParseEnum<ConsumerTechnology>() ?? + ConsumerTechnology.Unknown; + + public virtual ConsumerTechnology AdBlueDosing => + Body["Aux"]?["PneumaticConsumers"]?.GetEx<string>("AdBlueDosing").ParseEnum<ConsumerTechnology>() ?? + ConsumerTechnology.Unknown; #endregion #region Implementation of IHVACBusAuxiliariesDeclarationData public virtual BusHVACSystemConfiguration? SystemConfiguration { get; set; } - public virtual HeatPumpType? HeatPumpTypeDriverCompartment { get { return null; } } - public virtual HeatPumpMode? HeatPumpModeDriverCompartment { get { return null; } } - public virtual IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments - { - get { return null; } - } - public virtual Watt AuxHeaterPower { get { return null; } } - public virtual bool? DoubleGlazing { get { return false; } } - public virtual bool HeatPump { get { return false; } } + public virtual HeatPumpType? HeatPumpTypeDriverCompartment => null; + public virtual HeatPumpMode? HeatPumpModeDriverCompartment => null; + + public virtual IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments => null; + public virtual Watt AuxHeaterPower => null; + public virtual bool? DoubleGlazing => false; + public virtual bool HeatPump => false; public bool? OtherHeatingTechnology { get; } - public virtual bool? AdjustableCoolantThermostat { get { return Body["Aux"]?["HVAC"]?.GetEx<bool>("AdjustableCoolantThermostat") ?? false; } } - public virtual bool? AdjustableAuxiliaryHeater { get { return false; } } - public virtual bool EngineWasteGasHeatExchanger { get { return Body["Aux"]?["HVAC"]?.GetEx<bool>("EngineWasteGasHeatExchanger") ?? false; } } - public virtual bool? SeparateAirDistributionDucts { get { return false; } } + public virtual bool? AdjustableCoolantThermostat => Body["Aux"]?["HVAC"]?.GetEx<bool>("AdjustableCoolantThermostat") ?? false; + public virtual bool? AdjustableAuxiliaryHeater => false; + public virtual bool EngineWasteGasHeatExchanger => Body["Aux"]?["HVAC"]?.GetEx<bool>("EngineWasteGasHeatExchanger") ?? false; + public virtual bool? SeparateAirDistributionDucts => false; public virtual bool? WaterElectricHeater { get; } public virtual bool? AirElectricHeater { get; } @@ -745,15 +601,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON _entries = entries; } - IList<ElectricMachineEntry<IElectricMotorDeclarationInputData>> IElectricMachinesDeclarationInputData.Entries - { - get { return _entries.Cast<ElectricMachineEntry<IElectricMotorDeclarationInputData>>().ToList(); } - } + IList<ElectricMachineEntry<IElectricMotorDeclarationInputData>> IElectricMachinesDeclarationInputData.Entries => _entries.Cast<ElectricMachineEntry<IElectricMotorDeclarationInputData>>().ToList(); - public virtual IList<ElectricMachineEntry<IElectricMotorEngineeringInputData>> Entries - { - get { return _entries; } - } + public virtual IList<ElectricMachineEntry<IElectricMotorEngineeringInputData>> Entries => _entries; } // ################################################################### diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONTCUData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONTCUData.cs index d10534f4a0f4183d32f242e9a657bd1e4e8f5aaa..7339282b3a2313174cd02a63b0d3bdd938108f5e 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONTCUData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONTCUData.cs @@ -18,142 +18,73 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Implementation of IGearshiftEngineeringInputData - public virtual Second MinTimeBetweenGearshift - { - get { - return Body[JsonKeys.Gearbox_ShiftTime] == null - ? DeclarationData.Gearbox.MinTimeBetweenGearshifts - : Body.GetEx<double>(JsonKeys.Gearbox_ShiftTime).SI<Second>(); - } - } + public virtual Second MinTimeBetweenGearshift => + Body[JsonKeys.Gearbox_ShiftTime] == null + ? DeclarationData.Gearbox.MinTimeBetweenGearshifts + : Body.GetEx<double>(JsonKeys.Gearbox_ShiftTime).SI<Second>(); - public virtual double TorqueReserve - { - get { return Body[JsonKeys.Gearbox_TorqueReserve] == null ? - DeclarationData.GearboxTCU.TorqueReserve - :Body.GetEx<double>(JsonKeys.Gearbox_TorqueReserve) / 100.0; } - } + public virtual double TorqueReserve => + Body[JsonKeys.Gearbox_TorqueReserve] == null ? + DeclarationData.GearboxTCU.TorqueReserve + :Body.GetEx<double>(JsonKeys.Gearbox_TorqueReserve) / 100.0; - public Second DownshiftAfterUpshiftDelay - { - get { - return Body["DownshiftAfterUpshiftDelay"] == null - ? DeclarationData.Gearbox.DownshiftAfterUpshiftDelay - : Body.GetEx<double>("DownshiftAfterUpshiftDelay").SI<Second>(); - } - } + public Second DownshiftAfterUpshiftDelay => + Body["DownshiftAfterUpshiftDelay"] == null + ? DeclarationData.Gearbox.DownshiftAfterUpshiftDelay + : Body.GetEx<double>("DownshiftAfterUpshiftDelay").SI<Second>(); - public Second UpshiftAfterDownshiftDelay - { - get { - return Body["UpshiftAfterDownshiftDelay"] == null - ? DeclarationData.Gearbox.UpshiftAfterDownshiftDelay - : Body.GetEx<double>("UpshiftAfterDownshiftDelay").SI<Second>(); - } - } + public Second UpshiftAfterDownshiftDelay => + Body["UpshiftAfterDownshiftDelay"] == null + ? DeclarationData.Gearbox.UpshiftAfterDownshiftDelay + : Body.GetEx<double>("UpshiftAfterDownshiftDelay").SI<Second>(); - public MeterPerSquareSecond UpshiftMinAcceleration - { - get { - return Body["UpshiftMinAcceleration"] == null - ? DeclarationData.Gearbox.UpshiftMinAcceleration - : Body.GetEx<double>("UpshiftMinAcceleration").SI<MeterPerSquareSecond>(); - } - } + public MeterPerSquareSecond UpshiftMinAcceleration => + Body["UpshiftMinAcceleration"] == null + ? DeclarationData.Gearbox.UpshiftMinAcceleration + : Body.GetEx<double>("UpshiftMinAcceleration").SI<MeterPerSquareSecond>(); - public MeterPerSquareSecond CLUpshiftMinAcceleration - { - get { - return Body[JsonKeys.Gearbox_TorqueConverter] != null && - Body[JsonKeys.Gearbox_TorqueConverter]["CLUpshiftMinAcceleration"] != null - ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CLUpshiftMinAcceleration").SI<MeterPerSquareSecond>() - : UpshiftMinAcceleration; - } - } + public MeterPerSquareSecond CLUpshiftMinAcceleration => + Body[JsonKeys.Gearbox_TorqueConverter] != null && + Body[JsonKeys.Gearbox_TorqueConverter]["CLUpshiftMinAcceleration"] != null + ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CLUpshiftMinAcceleration").SI<MeterPerSquareSecond>() + : UpshiftMinAcceleration; - public MeterPerSquareSecond CCUpshiftMinAcceleration - { - get { - return Body[JsonKeys.Gearbox_TorqueConverter] != null && - Body[JsonKeys.Gearbox_TorqueConverter]["CCUpshiftMinAcceleration"] != null - ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CCUpshiftMinAcceleration").SI<MeterPerSquareSecond>() - : UpshiftMinAcceleration; - } - } + public MeterPerSquareSecond CCUpshiftMinAcceleration => + Body[JsonKeys.Gearbox_TorqueConverter] != null && + Body[JsonKeys.Gearbox_TorqueConverter]["CCUpshiftMinAcceleration"] != null + ? Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<double>("CCUpshiftMinAcceleration").SI<MeterPerSquareSecond>() + : UpshiftMinAcceleration; - public virtual double StartTorqueReserve - { - get { - return Body[JsonKeys.Gearbox_StartTorqueReserve] == null - ? DeclarationData.GearboxTCU.TorqueReserveStart - : Body.GetEx<double>(JsonKeys.Gearbox_StartTorqueReserve) / 100.0; - } - } + public virtual double StartTorqueReserve => + Body[JsonKeys.Gearbox_StartTorqueReserve] == null + ? DeclarationData.GearboxTCU.TorqueReserveStart + : Body.GetEx<double>(JsonKeys.Gearbox_StartTorqueReserve) / 100.0; - public MeterPerSecond StartSpeed - { - get { return Body.GetValueOrDefault<double>(JsonKeys.Gearbox_StartSpeed)?.KMPHtoMeterPerSecond() ?? DeclarationData.GearboxTCU.StartSpeed; } - } + public MeterPerSecond StartSpeed => Body.GetValueOrDefault<double>(JsonKeys.Gearbox_StartSpeed)?.KMPHtoMeterPerSecond() ?? DeclarationData.GearboxTCU.StartSpeed; - public MeterPerSquareSecond StartAcceleration - { - get { return Body.GetValueOrDefault<double>(JsonKeys.Gearbox_StartAcceleration)?.SI<MeterPerSquareSecond>() ?? DeclarationData.GearboxTCU.StartAcceleration; } - } + public MeterPerSquareSecond StartAcceleration => Body.GetValueOrDefault<double>(JsonKeys.Gearbox_StartAcceleration)?.SI<MeterPerSquareSecond>() ?? DeclarationData.GearboxTCU.StartAcceleration; - public Second GearResidenceTime - { - get { return Body.GetValueOrDefault<double>("GearResidenceTime")?.SI<Second>(); } - } + public Second GearResidenceTime => Body.GetValueOrDefault<double>("GearResidenceTime")?.SI<Second>(); - public double? DnT99LHMin1 - { - get { return Body.GetValueOrDefault<double>("Dn_Tq99L_high_min_1"); } - } + public double? DnT99LHMin1 => Body.GetValueOrDefault<double>("Dn_Tq99L_high_min_1"); - public double? DnT99LHMin2 - { - get { return Body.GetValueOrDefault<double>("Dn_Tq99L_high_min_2"); } - } + public double? DnT99LHMin2 => Body.GetValueOrDefault<double>("Dn_Tq99L_high_min_2"); - public int? AllowedGearRangeUp - { - get { return Body.GetValueOrDefault<int>("GearRangeUp"); } - } + public int? AllowedGearRangeUp => Body.GetValueOrDefault<int>("GearRangeUp"); - public int? AllowedGearRangeDown - { - get { return Body.GetValueOrDefault<int>("GearRangeDown"); } - } + public int? AllowedGearRangeDown => Body.GetValueOrDefault<int>("GearRangeDown"); - public Second LookBackInterval - { - get { return Body.GetValueOrDefault<double>("LookBackDriver")?.SI<Second>(); } - } + public Second LookBackInterval => Body.GetValueOrDefault<double>("LookBackDriver")?.SI<Second>(); - public Watt AvgCardanPowerThresholdPropulsion - { - get { return Body.GetValueOrDefault<double>("P_card_avg_threshold")?.SI<Watt>(); } - } + public Watt AvgCardanPowerThresholdPropulsion => Body.GetValueOrDefault<double>("P_card_avg_threshold")?.SI<Watt>(); - public Watt CurrCardanPowerThresholdPropulsion - { - get { return Body.GetValueOrDefault<double>("P_card_curr_threshold")?.SI<Watt>(); } - } + public Watt CurrCardanPowerThresholdPropulsion => Body.GetValueOrDefault<double>("P_card_curr_threshold")?.SI<Watt>(); - public double? TargetSpeedDeviationFactor - { - get { return Body.GetValueOrDefault<double>("Diff_curr_targ_vel"); } - } + public double? TargetSpeedDeviationFactor => Body.GetValueOrDefault<double>("Diff_curr_targ_vel"); - public double? EngineSpeedHighDriveOffFactor - { - get { return Body.GetValueOrDefault<double>("EngineSpeedHighDriveOffFactor"); } - } + public double? EngineSpeedHighDriveOffFactor => Body.GetValueOrDefault<double>("EngineSpeedHighDriveOffFactor"); - public double? RatingFactorCurrentGear - { - get { return Body.GetValueOrDefault<double>("Rating_current_gear"); } - } + public double? RatingFactorCurrentGear => Body.GetValueOrDefault<double>("Rating_current_gear"); public TableData AccelerationReserveLookup { @@ -240,22 +171,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public Second DriverAccelerationLookBackInterval { get {return Body.GetValueOrDefault<double>("DriverAccelerationLookBackInterval")?.SI<Second>();} } - public MeterPerSquareSecond DriverAccelerationThresholdLow { get { return Body.GetValueOrDefault<double>("DriverAccelerationThresholdLow")?.SI<MeterPerSquareSecond>(); } } + public Second DriverAccelerationLookBackInterval => Body.GetValueOrDefault<double>("DriverAccelerationLookBackInterval")?.SI<Second>(); + public MeterPerSquareSecond DriverAccelerationThresholdLow => Body.GetValueOrDefault<double>("DriverAccelerationThresholdLow")?.SI<MeterPerSquareSecond>(); - public double? RatioEarlyUpshiftFC - { - get { - return Body.GetValueOrDefault<double>("RatioEarlyUpshiftFC"); - } - } + public double? RatioEarlyUpshiftFC => Body.GetValueOrDefault<double>("RatioEarlyUpshiftFC"); - public double? RatioEarlyDownshiftFC - { - get { - return Body.GetValueOrDefault<double>("RatioEarlyDownshiftFC"); - } - } + public double? RatioEarlyDownshiftFC => Body.GetValueOrDefault<double>("RatioEarlyDownshiftFC"); public int? AllowedGearRangeFC { diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index 6b4e9b9e9843af3c253d0ddfe9b813524c42b5c2..797041be78f2fd45254e191ee72792e4836f06f7 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -60,18 +60,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Overrides of JSONVehicleDataV7 - public override double InitialSOC - { - get { return Body.GetEx<double>("InitialSoC") / 100.0; } - } + public override double InitialSOC => Body.GetEx<double>("InitialSoC") / 100.0; - protected override IRetarderInputData GetRetarder - { - get - { - return _retarderInputData ?? (_retarderInputData = new JSONRetarderInputDataBEV(this)); - } - } + protected override IRetarderInputData GetRetarder => _retarderInputData ?? (_retarderInputData = new JSONRetarderInputDataBEV(this)); protected override IElectricMachinesEngineeringInputData GetElectricMachines() { @@ -139,27 +130,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON }; } - public override TableData ElectricMotorTorqueLimits - { - get - { - return Body["EMTorqueLimits"] == null - ? null - : ReadTableData(Path.Combine(BasePath, Body.GetEx<string>("EMTorqueLimits")), - "ElectricMotorTorqueLimits"); - } - } + public override TableData ElectricMotorTorqueLimits => + Body["EMTorqueLimits"] == null + ? null + : ReadTableData(Path.Combine(BasePath, Body.GetEx<string>("EMTorqueLimits")), + "ElectricMotorTorqueLimits"); - public override TableData MaxPropulsionTorque - { - get - { - return Body["MaxPropulsionTorque"] == null - ? null - : ReadTableData(Path.Combine(BasePath, Body.GetEx<string>("MaxPropulsionTorque")), - "MaxPropulsionTorque"); - } - } + public override TableData MaxPropulsionTorque => + Body["MaxPropulsionTorque"] == null + ? null + : ReadTableData(Path.Combine(BasePath, Body.GetEx<string>("MaxPropulsionTorque")), + "MaxPropulsionTorque"); #endregion } @@ -177,17 +158,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region Overrides of JSONVehicleDataV7 - public override IBusAuxiliariesDeclarationData BusAuxiliaries - { - get { return _busAuxiliariesData ?? (_busAuxiliariesData = new JSONBusAuxiliariesData(this)); } - } + public override IBusAuxiliariesDeclarationData BusAuxiliaries => _busAuxiliariesData ?? (_busAuxiliariesData = new JSONBusAuxiliariesData(this)); #region Overrides of JSONVehicleDataV7 - public override bool Articulated - { - get { return Body.GetEx<bool>("Articulated"); } - } + public override bool Articulated => Body.GetEx<bool>("Articulated"); protected override IAdvancedDriverAssistantSystemsEngineering GetADS() { @@ -209,10 +184,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON - public override TankSystem? TankSystem - { - get { return Body["TankSystem"]?.ToString().ParseEnum<TankSystem>(); } - } + public override TankSystem? TankSystem => Body["TankSystem"]?.ToString().ParseEnum<TankSystem>(); protected override IAdvancedDriverAssistantSystemsEngineering GetADS() { @@ -244,52 +216,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region IVehicleInputData - public virtual string Identifier - { - get { return Path.GetFileNameWithoutExtension(_sourceFile); } - } + public virtual string Identifier => Path.GetFileNameWithoutExtension(_sourceFile); - public virtual bool ExemptedVehicle - { - get { return false; } - } + public virtual bool ExemptedVehicle => false; - public virtual string VIN - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string VIN => Constants.NOT_AVAILABLE; - public virtual LegislativeClass? LegislativeClass - { - get { - return Body["LegislativeClass"] != null - ? Body["LegislativeClass"].Value<string>().ParseEnum<LegislativeClass>() - : VectoCommon.Models.LegislativeClass.Unknown; - } - } + public virtual LegislativeClass? LegislativeClass => + Body["LegislativeClass"]?.Value<string>().ParseEnum<LegislativeClass>() ?? VectoCommon.Models.LegislativeClass.Unknown; - public virtual VehicleCategory VehicleCategory - { - get { - return - (VehicleCategory)Enum.Parse(typeof(VehicleCategory), Body[JsonKeys.Vehicle_VehicleCategory].Value<string>(), true); - } - } + public virtual VehicleCategory VehicleCategory => (VehicleCategory)Enum.Parse(typeof(VehicleCategory), Body[JsonKeys.Vehicle_VehicleCategory].Value<string>(), true); - public virtual Kilogram CurbMassChassis - { - get { return Body.GetEx<double>(JsonKeys.Vehicle_CurbWeight).SI<Kilogram>(); } - } + public virtual Kilogram CurbMassChassis => Body.GetEx<double>(JsonKeys.Vehicle_CurbWeight).SI<Kilogram>(); - public virtual Kilogram CurbMassExtra - { - get { return Body.GetEx<double>(JsonKeys.Vehicle_CurbWeightExtra).SI<Kilogram>(); } - } + public virtual Kilogram CurbMassExtra => Body.GetEx<double>(JsonKeys.Vehicle_CurbWeightExtra).SI<Kilogram>(); - public virtual Kilogram GrossVehicleMassRating - { - get { return Body.GetEx<double>(JsonKeys.Vehicle_GrossVehicleMassRating).SI(Unit.SI.Ton).Cast<Kilogram>(); } - } + public virtual Kilogram GrossVehicleMassRating => Body.GetEx<double>(JsonKeys.Vehicle_GrossVehicleMassRating).SI(Unit.SI.Ton).Cast<Kilogram>(); public virtual IList<ITorqueLimitInputData> TorqueLimits { @@ -311,120 +253,60 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual Kilogram Loading - { - get { return Body.GetEx<double>(JsonKeys.Vehicle_Loading).SI<Kilogram>(); } - } + public virtual Kilogram Loading => Body.GetEx<double>(JsonKeys.Vehicle_Loading).SI<Kilogram>(); - public virtual Meter DynamicTyreRadius - { - get { return Body.GetEx<double>(JsonKeys.Vehicle_DynamicTyreRadius).SI(Unit.SI.Milli.Meter).Cast<Meter>(); } - } + public virtual Meter DynamicTyreRadius => Body.GetEx<double>(JsonKeys.Vehicle_DynamicTyreRadius).SI(Unit.SI.Milli.Meter).Cast<Meter>(); - public virtual bool Articulated { get { return false; } } + public virtual bool Articulated => false; - public virtual Meter Height - { - get { return Body["VehicleHeight"] == null ? null : Body.GetEx<double>("VehicleHeight").SI<Meter>(); } - } + public virtual Meter Height => Body["VehicleHeight"] == null ? null : Body.GetEx<double>("VehicleHeight").SI<Meter>(); - public virtual TableData ElectricMotorTorqueLimits - { - get { return null; } - } + public virtual TableData ElectricMotorTorqueLimits => null; - public virtual TableData MaxPropulsionTorque - { - get { return null; } - } + public virtual TableData MaxPropulsionTorque => null; - public virtual Meter Length - { - get { return null; } - } + public virtual Meter Length => null; - public virtual Meter Width - { - get { return null; } - } + public virtual Meter Width => null; - public virtual Meter EntranceHeight { get { return null; } } - public virtual ConsumerTechnology? DoorDriveTechnology { get { return ConsumerTechnology.Unknown; } } + public virtual Meter EntranceHeight => null; + public virtual ConsumerTechnology? DoorDriveTechnology => ConsumerTechnology.Unknown; public virtual VehicleDeclarationType VehicleDeclarationType { get; } - IVehicleComponentsEngineering IVehicleEngineeringInputData.Components - { - get { return this; } - } + IVehicleComponentsEngineering IVehicleEngineeringInputData.Components => this; - XmlNode IVehicleDeclarationInputData.XMLSource - { - get { return null; } - } + XmlNode IVehicleDeclarationInputData.XMLSource => null; - public GearshiftPosition PTO_DriveGear { get { - return Body["GearDuringPTODrive"] != null ? new GearshiftPosition(Body["GearDuringPTODrive"].Value<uint>()) : null; - } } + public GearshiftPosition PTO_DriveGear => Body["GearDuringPTODrive"] != null ? new GearshiftPosition(Body["GearDuringPTODrive"].Value<uint>()) : null; - public PerSecond PTO_DriveEngineSpeed { get { - return Body["EngineSpeedDuringPTODrive"] != null ? Body.GetEx<double>("EngineSpeedDuringPTODrive").RPMtoRad() : null; - } } + public PerSecond PTO_DriveEngineSpeed => Body["EngineSpeedDuringPTODrive"] != null ? Body.GetEx<double>("EngineSpeedDuringPTODrive").RPMtoRad() : null; - IAdvancedDriverAssistantSystemsEngineering IVehicleEngineeringInputData.ADAS - { - get { return GetADS(); } - } + IAdvancedDriverAssistantSystemsEngineering IVehicleEngineeringInputData.ADAS => GetADS(); - public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return GetADS(); } - } + public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADAS => GetADS(); protected virtual IAdvancedDriverAssistantSystemsEngineering GetADS() { return _adasInputData ?? (_adasInputData = new JSONADASInputDataV7(this)); } - public virtual double InitialSOC - { - get { return double.NaN; } - } + public virtual double InitialSOC => double.NaN; - public virtual VectoSimulationJobType VehicleType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public virtual VectoSimulationJobType VehicleType => VectoSimulationJobType.ConventionalVehicle; - public virtual AxleConfiguration AxleConfiguration - { - get { - return - AxleConfigurationHelper.Parse( - Body.GetEx(JsonKeys.Vehicle_AxleConfiguration).GetEx<string>(JsonKeys.Vehicle_AxleConfiguration_Type)); - } - } + public virtual AxleConfiguration AxleConfiguration => + AxleConfigurationHelper.Parse( + Body.GetEx(JsonKeys.Vehicle_AxleConfiguration).GetEx<string>(JsonKeys.Vehicle_AxleConfiguration_Type)); - public virtual IList<IAxleEngineeringInputData> AxlesEngineering - { - get { return AxleWheels().Cast<IAxleEngineeringInputData>().ToList(); } - } + public virtual IList<IAxleEngineeringInputData> AxlesEngineering => AxleWheels().Cast<IAxleEngineeringInputData>().ToList(); - public virtual string ManufacturerAddress - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string ManufacturerAddress => Constants.NOT_AVAILABLE; - public virtual PerSecond EngineIdleSpeed - { - get { return Body["IdlingSpeed"] != null ? Body.GetEx<double>("IdlingSpeed").RPMtoRad() : null; } - } + public virtual PerSecond EngineIdleSpeed => Body["IdlingSpeed"] != null ? Body.GetEx<double>("IdlingSpeed").RPMtoRad() : null; - IList<IAxleDeclarationInputData> IAxlesDeclarationInputData.AxlesDeclaration - { - get { return AxleWheels().Cast<IAxleDeclarationInputData>().ToList(); } - } + IList<IAxleDeclarationInputData> IAxlesDeclarationInputData.AxlesDeclaration => AxleWheels().Cast<IAxleDeclarationInputData>().ToList(); private IEnumerable<AxleInputData> AxleWheels() { @@ -456,224 +338,101 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region "VehicleComponents" - IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData - { - get { return _airdragInputData ?? (_airdragInputData = new JSONAirdragInputData(this)); } - } + IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData => _airdragInputData ?? (_airdragInputData = new JSONAirdragInputData(this)); - IAirdragEngineeringInputData IVehicleComponentsEngineering.AirdragInputData - { - get { return _airdragInputData ?? (_airdragInputData = new JSONAirdragInputData(this)); } - } + IAirdragEngineeringInputData IVehicleComponentsEngineering.AirdragInputData => _airdragInputData ?? (_airdragInputData = new JSONAirdragInputData(this)); - IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData - { - get { return Job.Gearbox; } - } + IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData => Job.Gearbox; - public virtual ITorqueConverterDeclarationInputData TorqueConverter - { - get { return Job.TorqueConverter; } - } + public virtual ITorqueConverterDeclarationInputData TorqueConverter => Job.TorqueConverter; - IGearboxEngineeringInputData IVehicleComponentsEngineering.GearboxInputData - { - get { return Job.Gearbox; } - } + IGearboxEngineeringInputData IVehicleComponentsEngineering.GearboxInputData => Job.Gearbox; - ITorqueConverterDeclarationInputData IVehicleComponentsDeclaration.TorqueConverterInputData - { - get { return Job.TorqueConverter; } - } + ITorqueConverterDeclarationInputData IVehicleComponentsDeclaration.TorqueConverterInputData => Job.TorqueConverter; - ITorqueConverterEngineeringInputData IVehicleComponentsEngineering.TorqueConverterInputData - { - get { return Job.TorqueConverter; } - } + ITorqueConverterEngineeringInputData IVehicleComponentsEngineering.TorqueConverterInputData => Job.TorqueConverter; - IAxleGearInputData IVehicleComponentsEngineering.AxleGearInputData - { - get { return Job.AxleGear; } - } + IAxleGearInputData IVehicleComponentsEngineering.AxleGearInputData => Job.AxleGear; - IAngledriveInputData IVehicleComponentsEngineering.AngledriveInputData - { - get { return _angledriveData ?? (_angledriveData = new JSONAngledriveInputData(this)); } - } + IAngledriveInputData IVehicleComponentsEngineering.AngledriveInputData => _angledriveData ?? (_angledriveData = new JSONAngledriveInputData(this)); - public virtual IEngineEngineeringInputData EngineInputData - { - get { return Job.Engine; } - } + public virtual IEngineEngineeringInputData EngineInputData => Job.Engine; - IAxleGearInputData IVehicleComponentsDeclaration.AxleGearInputData - { - get { return Job.AxleGear; } - } + IAxleGearInputData IVehicleComponentsDeclaration.AxleGearInputData => Job.AxleGear; - IAngledriveInputData IVehicleComponentsDeclaration.AngledriveInputData - { - get { return _angledriveData ?? (_angledriveData = new JSONAngledriveInputData(this)); } - } + IAngledriveInputData IVehicleComponentsDeclaration.AngledriveInputData => _angledriveData ?? (_angledriveData = new JSONAngledriveInputData(this)); - IEngineDeclarationInputData IVehicleComponentsDeclaration.EngineInputData - { - get { return Job.Engine; } - } + IEngineDeclarationInputData IVehicleComponentsDeclaration.EngineInputData => Job.Engine; - IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData - { - get { return Job.DeclarationAuxiliaries; } - } + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData => Job.DeclarationAuxiliaries; - IRetarderInputData IVehicleComponentsEngineering.RetarderInputData - { - get { return GetRetarder; } - } + IRetarderInputData IVehicleComponentsEngineering.RetarderInputData => GetRetarder; - IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData - { - get { return GetRetarder; } - } + IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData => GetRetarder; - protected virtual IRetarderInputData GetRetarder - { - get { - return _retarderInputData ?? (_retarderInputData = new JSONRetarderInputData(this)); - } - } + protected virtual IRetarderInputData GetRetarder => _retarderInputData ?? (_retarderInputData = new JSONRetarderInputData(this)); - IPTOTransmissionInputData IVehicleComponentsEngineering.PTOTransmissionInputData - { - get { return _ptoInputData ?? (_ptoInputData = new JSONPTOTransmissioninputData(this)); } - } + IPTOTransmissionInputData IVehicleComponentsEngineering.PTOTransmissionInputData => _ptoInputData ?? (_ptoInputData = new JSONPTOTransmissioninputData(this)); - IPTOTransmissionInputData IVehicleComponentsDeclaration.PTOTransmissionInputData - { - get { return _ptoInputData ?? (_ptoInputData = new JSONPTOTransmissioninputData(this)); } - } + IPTOTransmissionInputData IVehicleComponentsDeclaration.PTOTransmissionInputData => _ptoInputData ?? (_ptoInputData = new JSONPTOTransmissioninputData(this)); - IAxlesEngineeringInputData IVehicleComponentsEngineering.AxleWheels - { - get { return this; } - } + IAxlesEngineeringInputData IVehicleComponentsEngineering.AxleWheels => this; - IElectricStorageEngineeringInputData IVehicleComponentsEngineering.ElectricStorage - { - get { return GetElectricStorage(); } - } + IElectricStorageEngineeringInputData IVehicleComponentsEngineering.ElectricStorage => GetElectricStorage(); protected virtual IElectricStorageEngineeringInputData GetElectricStorage() { return null; } - IElectricMachinesEngineeringInputData IVehicleComponentsEngineering.ElectricMachines - { - get { return GetElectricMachines(); } - } + IElectricMachinesEngineeringInputData IVehicleComponentsEngineering.ElectricMachines => GetElectricMachines(); protected virtual IElectricMachinesEngineeringInputData GetElectricMachines() { return null; } - public virtual IBusAuxiliariesDeclarationData BusAuxiliaries - { - get { return null; } - } + public virtual IBusAuxiliariesDeclarationData BusAuxiliaries => null; - IElectricStorageDeclarationInputData IVehicleComponentsDeclaration.ElectricStorage - { - get { return GetElectricStorage(); } - } + IElectricStorageDeclarationInputData IVehicleComponentsDeclaration.ElectricStorage => GetElectricStorage(); - IElectricMachinesDeclarationInputData IVehicleComponentsDeclaration.ElectricMachines - { - get { return GetElectricMachines(); } - } + IElectricMachinesDeclarationInputData IVehicleComponentsDeclaration.ElectricMachines => GetElectricMachines(); - IAxlesDeclarationInputData IVehicleComponentsDeclaration.AxleWheels - { - get { return this; } - } + IAxlesDeclarationInputData IVehicleComponentsDeclaration.AxleWheels => this; - public virtual bool VocationalVehicle - { - get { return DeclarationData.Vehicle.VocationalVehicleDefault; } - } + public virtual bool VocationalVehicle => DeclarationData.Vehicle.VocationalVehicleDefault; - public virtual bool SleeperCab - { - get { return DeclarationData.Vehicle.SleeperCabDefault; } - } + public virtual bool SleeperCab => DeclarationData.Vehicle.SleeperCabDefault; public virtual bool? AirdragModifiedMultistage { get; } - public virtual TankSystem? TankSystem - { - get { return DeclarationData.Vehicle.TankSystemDefault; } - } + public virtual TankSystem? TankSystem => DeclarationData.Vehicle.TankSystemDefault; - - public virtual bool ZeroEmissionVehicle - { - get { return DeclarationData.Vehicle.ZeroEmissionVehicleDefault; } - } - public virtual bool HybridElectricHDV - { - get { return DeclarationData.Vehicle.HybridElectricHDVDefault; } - } + public virtual bool ZeroEmissionVehicle => DeclarationData.Vehicle.ZeroEmissionVehicleDefault; - public virtual bool DualFuelVehicle - { - get { return DeclarationData.Vehicle.DualFuelVehicleDefault; } - } + public virtual bool HybridElectricHDV => DeclarationData.Vehicle.HybridElectricHDVDefault; - public virtual Watt MaxNetPower1 - { - get { return null; } - } + public virtual bool DualFuelVehicle => DeclarationData.Vehicle.DualFuelVehicleDefault; - public virtual Watt MaxNetPower2 - { - get { return null; } - } + public virtual Watt MaxNetPower1 => null; - public string ExemptedTechnology - { - get { return null; } - } + public virtual Watt MaxNetPower2 => null; - public virtual RegistrationClass? RegisteredClass - { - get { return RegistrationClass.unknown; } - } + public virtual string ExemptedTechnology => null; - public virtual int? NumberPassengerSeatsUpperDeck - { - get { return 0; } - } + public virtual RegistrationClass? RegisteredClass => RegistrationClass.unknown; - public virtual int? NumberPassengerSeatsLowerDeck - { - get { return 0; } - } + public virtual int? NumberPassengerSeatsUpperDeck => 0; - public int? NumberPassengersStandingLowerDeck - { - get { return 0; } - } - public int? NumberPassengersStandingUpperDeck - { - get { return 0; } - } + public virtual int? NumberPassengerSeatsLowerDeck => 0; - public virtual CubicMeter CargoVolume { - get { return 0.SI<CubicMeter>(); } - } + public int? NumberPassengersStandingLowerDeck => 0; + + public int? NumberPassengersStandingUpperDeck => 0; + + public virtual CubicMeter CargoVolume => 0.SI<CubicMeter>(); public virtual TableData PTOCycleDuringStop { get { @@ -716,62 +475,30 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } } - public virtual VehicleCode? VehicleCode - { - get { return VectoCommon.Models.VehicleCode.NOT_APPLICABLE; } - } - - public virtual bool? LowEntry { get { return false; } } - - IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components - { - get { return this; } - } + public virtual VehicleCode? VehicleCode => VectoCommon.Models.VehicleCode.NOT_APPLICABLE; - IAuxiliariesEngineeringInputData IVehicleComponentsEngineering.AuxiliaryInputData - { - get { return Job.EngineeringAuxiliaries; } - } - - + public virtual bool? LowEntry => false; + IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components => this; - + IAuxiliariesEngineeringInputData IVehicleComponentsEngineering.AuxiliaryInputData => Job.EngineeringAuxiliaries; #endregion - public virtual string Manufacturer - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string Manufacturer => Constants.NOT_AVAILABLE; - public virtual string Model - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string Model => Constants.NOT_AVAILABLE; - public virtual DateTime Date - { - get { return DateTime.MinValue; } - } + public virtual DateTime Date => DateTime.MinValue; - public CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public CertificationMethod CertificationMethod => CertificationMethod.NotCertified; - public virtual string CertificationNumber - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string CertificationNumber => Constants.NOT_AVAILABLE; - public virtual DigestData DigestValue - { - get { return null; } - } + public virtual DigestData DigestValue => null; - public virtual XmlNode XMLSource { get { return null; } } + public virtual XmlNode XMLSource => null; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Common/AbstractXMLResource.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Common/AbstractXMLResource.cs index 555c5eb474b96f44d3e7d9b364df4d8f74a10ccb..057b4afd1e194aada2be9680a066c399ac4667fb 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Common/AbstractXMLResource.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Common/AbstractXMLResource.cs @@ -44,13 +44,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Common { SourceFile = source; } - public virtual DataSource DataSource - { - get { return new DataSource() { SourceFile = SourceFile, SourceVersion = SourceVersion, SourceType = SourceType }; } - } + public virtual DataSource DataSource => new DataSource() { SourceFile = SourceFile, SourceVersion = SourceVersion, SourceType = SourceType }; - protected string SourceVersion { get { return XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace); } } + protected string SourceVersion => XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace); protected abstract XNamespace SchemaNamespace { get; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractCommonComponentType.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractCommonComponentType.cs index 738587d46f046b76493db187f6c585cce18a7d3f..66c2a3d2c0549a660819c8baaaebb7db7ff9e6d0 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractCommonComponentType.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractCommonComponentType.cs @@ -43,30 +43,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { { protected AbstractCommonComponentType(XmlNode node, string source) : base(node, source) { } - public bool SavedInDeclarationMode - { - get { return true; } - } + public bool SavedInDeclarationMode => true; - public virtual string Manufacturer - { - get { return GetString(XMLNames.Component_Manufacturer); } - } + public virtual string Manufacturer => GetString(XMLNames.Component_Manufacturer); - public virtual string Model - { - get { return GetString(XMLNames.Component_Model); } - } + public virtual string Model => GetString(XMLNames.Component_Model); - public virtual DateTime Date - { - get { return XmlConvert.ToDateTime(GetString(XMLNames.Component_Date), XmlDateTimeSerializationMode.Utc); } - } + public virtual DateTime Date => XmlConvert.ToDateTime(GetString(XMLNames.Component_Date), XmlDateTimeSerializationMode.Utc); - public virtual string AppVersion - { - get { return GetString(XMLNames.Component_AppVersion); } - } + public virtual string AppVersion => GetString(XMLNames.Component_AppVersion); public virtual CertificationMethod CertificationMethod { @@ -76,16 +61,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { } } - public virtual string CertificationNumber - { - get { return GetString(XMLNames.Component_CertificationNumber); } - } + public virtual string CertificationNumber => GetString(XMLNames.Component_CertificationNumber); - public virtual DigestData DigestValue - { - get { return new DigestData(GetNode(XMLNames.DI_Signature, required:false)); } - } + public virtual DigestData DigestValue => new DigestData(GetNode(XMLNames.DI_Signature, required:false)); - public virtual XmlNode XMLSource { get { return BaseNode; } } + public virtual XmlNode XMLSource => BaseNode; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs index 2fb18c5c348305bf47e2aa8ea9b4fc1375800b58..c1f56eba06a93c8d8fff85d1246d42a0c1c6d800 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs @@ -57,10 +57,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAuxiliaryDeclarationInputData - public virtual AuxiliaryType Type - { - get { return _type ?? (_type = BaseNode.LocalName.ParseEnum<AuxiliaryType>()).Value; } - } + public virtual AuxiliaryType Type => _type ?? (_type = BaseNode.LocalName.ParseEnum<AuxiliaryType>()).Value; public virtual IList<string> Technology { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs index b718f1f21a347c54071146eec348bc3d0dff2b4a..41a8b121a6ab2305593a38642e34e9f1d367a9e7 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs @@ -55,10 +55,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -66,27 +63,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData - public virtual bool EngineStopStart - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EngineStopStart)); } - } + public virtual bool EngineStopStart => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EngineStopStart)); - public virtual EcoRollType EcoRoll - { - get { - return EcorollTypeHelper.Get( - XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EcoRollWithoutEngineStop)), - XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EcoRollWithEngineStopStart))); - } - } + public virtual EcoRollType EcoRoll => + EcorollTypeHelper.Get( + XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EcoRollWithoutEngineStop)), + XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EcoRollWithEngineStopStart))); - public virtual PredictiveCruiseControlType PredictiveCruiseControl - { - get { return PredictiveCruiseControlTypeHelper.Parse(GetString(XMLNames.Vehicle_ADAS_PCC)); } - } + public virtual PredictiveCruiseControlType PredictiveCruiseControl => PredictiveCruiseControlTypeHelper.Parse(GetString(XMLNames.Vehicle_ADAS_PCC)); - public virtual bool? ATEcoRollReleaseLockupClutch { get { return null; } } - + public virtual bool? ATEcoRollReleaseLockupClutch => null; #endregion } @@ -109,10 +95,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationADASDataProviderV21(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -150,9 +133,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs index ff2c9f12ad7dcf357557d62fadc26b8c2f9c4776..64c48bc78944c78321a5c8d12a1e7b851d627337 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs @@ -56,48 +56,28 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAirdragDeclarationInputData - public virtual SquareMeter AirDragArea - { - get { - return ElementExists(XMLNames.AirDrag_DeclaredCdxA) - ? GetDouble(XMLNames.AirDrag_DeclaredCdxA).SI<SquareMeter>() - : null; - } - } + public virtual SquareMeter AirDragArea => + ElementExists(XMLNames.AirDrag_DeclaredCdxA) + ? GetDouble(XMLNames.AirDrag_DeclaredCdxA).SI<SquareMeter>() + : null; - public virtual SquareMeter TransferredAirDragArea - { - get - { - return ElementExists(XMLNames.AirDrag_TransferredCDxA) - ? GetDouble(XMLNames.AirDrag_TransferredCDxA).SI<SquareMeter>() - : null; - } - } + public virtual SquareMeter TransferredAirDragArea => + ElementExists(XMLNames.AirDrag_TransferredCDxA) + ? GetDouble(XMLNames.AirDrag_TransferredCDxA).SI<SquareMeter>() + : null; - public virtual SquareMeter AirDragArea_0 - { - get - { - return ElementExists(XMLNames.AirDrag_CdxA_0) - ? GetDouble(XMLNames.AirDrag_CdxA_0).SI<SquareMeter>() - : null; - } - } + public virtual SquareMeter AirDragArea_0 => + ElementExists(XMLNames.AirDrag_CdxA_0) + ? GetDouble(XMLNames.AirDrag_CdxA_0).SI<SquareMeter>() + : null; - public override CertificationMethod CertificationMethod - { - get { return CertificationMethod.Measured; } - } + public override CertificationMethod CertificationMethod => CertificationMethod.Measured; #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -121,11 +101,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationAirdragDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } - + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -141,10 +117,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationAirdragDataProviderV28(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs index 6df8613817ce08c127bd6fa1a80995ec13d89929..bee76d3ee5a6070b5f3a671f18961918eba68522 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs @@ -62,38 +62,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAngledriveInputData - public virtual AngledriveType Type - { - get { return Vehicle.AngledriveType; } - } + public virtual AngledriveType Type => Vehicle.AngledriveType; - public virtual double Ratio - { - get { return GetDouble(XMLNames.AngleDrive_Ratio); } - } + public virtual double Ratio => GetDouble(XMLNames.AngleDrive_Ratio); - public virtual TableData LossMap - { - get { - return ReadTableData( - XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry, - AttributeMappings.TransmissionLossmapMapping); - } - } + public virtual TableData LossMap => + ReadTableData( + XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry, + AttributeMappings.TransmissionLossmapMapping); - public virtual double Efficiency - { - get { throw new VectoException("Efficiency not supported in Declaration Mode!"); } - } + public virtual double Efficiency => throw new VectoException("Efficiency not supported in Declaration Mode!"); #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -119,10 +103,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -141,17 +122,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractCommonComponentType - public override string CertificationNumber - { - get { return GetString(XMLNames.Component_CertificationNumber, required: false); } - } + public override string CertificationNumber => GetString(XMLNames.Component_CertificationNumber, required: false); #endregion - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs index 73edfd6ba6550568d2937fd05ead8c915ca2b288..3613e72919411f6fae4a69ab8a386f45bf79eb63 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs @@ -57,10 +57,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAuxiliariesDeclarationInputData - public virtual bool SavedInDeclarationMode - { - get { return true; } - } + public virtual bool SavedInDeclarationMode => true; public virtual IList<IAuxiliaryDeclarationInputData> Auxiliaries { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs index a07ffe3a345b5d9cb92ea9cc8cbdb5c50cf346f8..bef8672f8222816b6712368b09883c1297a8fd32 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs @@ -61,24 +61,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAxleDeclarationInputData - public virtual bool TwinTyres - { - get { - return _twinTyre ?? (_twinTyre = XmlConvert.ToBoolean(GetString(XMLNames.AxleWheels_Axles_Axle_TwinTyres))).Value; - } - } + public virtual bool TwinTyres => _twinTyre ?? (_twinTyre = XmlConvert.ToBoolean(GetString(XMLNames.AxleWheels_Axles_Axle_TwinTyres))).Value; - public virtual AxleType AxleType - { - get { - return _axleType ?? (_axleType = GetString(XMLNames.AxleWheels_Axles_Axle_AxleType).ParseEnum<AxleType>()).Value; - } - } + public virtual AxleType AxleType => _axleType ?? (_axleType = GetString(XMLNames.AxleWheels_Axles_Axle_AxleType).ParseEnum<AxleType>()).Value; - public virtual ITyreDeclarationInputData Tyre - { - get { return _tyre ?? (_tyre = Reader.Tyre); } - } + public virtual ITyreDeclarationInputData Tyre => _tyre ?? (_tyre = Reader.Tyre); #endregion @@ -91,10 +78,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -119,10 +103,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationAxleDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } - + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs index 8561242de3b64271da4effafc5e711d195be4c07..241830b52f72e322920bb2eca4909a8d811d3170 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs @@ -60,24 +60,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAxleGearInputData - public virtual double Ratio - { - get { return GetDouble(XMLNames.Axlegear_Ratio); } - } + public virtual double Ratio => GetDouble(XMLNames.Axlegear_Ratio); - public virtual TableData LossMap - { - get { - return ReadTableData( - XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry, - AttributeMappings.TransmissionLossmapMapping); - } - } + public virtual TableData LossMap => + ReadTableData( + XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry, + AttributeMappings.TransmissionLossmapMapping); - public virtual double Efficiency - { - get { throw new VectoException("Efficiency not supported in Declaration Mode!"); } - } + public virtual double Efficiency => throw new VectoException("Efficiency not supported in Declaration Mode!"); public virtual AxleLineType LineType { @@ -91,10 +81,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -120,10 +107,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } @@ -142,16 +126,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractCommonComponentType - public override string CertificationNumber - { - get { return GetString(XMLNames.Component_CertificationNumber, required: false); } - } + public override string CertificationNumber => GetString(XMLNames.Component_CertificationNumber, required: false); #endregion - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs index bc81ba80b3a323581b554c909b10bbcd8c9f98d6..4041fd877cfa3a749cee94e9ddbb89bd59259bbe 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs @@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public XmlNode XMLSource { get { return BaseNode; } } + public XmlNode XMLSource => BaseNode; #endregion @@ -111,10 +111,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion - protected virtual XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected virtual XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -133,10 +130,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } @@ -155,9 +149,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationBusAuxiliariesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationBusAuxiliariesDataProvider.cs index 44b1c188e4bf54803bbb918fa84b68e02e689474..521cc4b5fc3f4ca46cbffd916aa6c603994a63fc 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationBusAuxiliariesDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationBusAuxiliariesDataProvider.cs @@ -31,10 +31,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IBusAuxiliariesDeclarationData - public virtual XmlNode XMLSource - { - get { return BaseNode; } - } + public virtual XmlNode XMLSource => BaseNode; public virtual string FanTechnology { @@ -50,30 +47,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual IElectricSupplyDeclarationData ElectricSupply - { - get { return this; } - } + public virtual IElectricSupplyDeclarationData ElectricSupply => this; - public virtual IElectricConsumersDeclarationData ElectricConsumers - { - get { return null; } - } + public virtual IElectricConsumersDeclarationData ElectricConsumers => null; - public virtual IPneumaticSupplyDeclarationData PneumaticSupply - { - get { return this; } - } + public virtual IPneumaticSupplyDeclarationData PneumaticSupply => this; - public virtual IPneumaticConsumersDeclarationData PneumaticConsumers - { - get { return this; } - } + public virtual IPneumaticConsumersDeclarationData PneumaticConsumers => this; - public virtual IHVACBusAuxiliariesDeclarationData HVACAux - { - get { return this; } - } + public virtual IHVACBusAuxiliariesDeclarationData HVACAux => this; #endregion @@ -130,20 +112,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider get { return GetBool(new[] { XMLNames.BusAux_ElectricSystem, XMLNames.BusAux_ElectricSystem_SmartElectrics }); } } - public virtual Watt MaxAlternatorPower - { - get { return ElementExists("MaxAlternatorPower") ? GetDouble("MaxAlternatorPower").SI<Watt>() : null; } - } + public virtual Watt MaxAlternatorPower => ElementExists("MaxAlternatorPower") ? GetDouble("MaxAlternatorPower").SI<Watt>() : null; - public virtual WattSecond ElectricStorageCapacity - { - get - { - return ElementExists("ElectricStorageCapacity") - ? GetDouble("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>() - : null; - } - } + public virtual WattSecond ElectricStorageCapacity => + ElementExists("ElectricStorageCapacity") + ? GetDouble("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>() + : null; #endregion @@ -174,10 +148,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IPneumaticSupplyDeclarationData - public CompressorDrive CompressorDrive - { - get { return CompressorDriveHelper.Parse(GetString(XMLNames.CompressorDrive)); } - } + public CompressorDrive CompressorDrive => CompressorDriveHelper.Parse(GetString(XMLNames.CompressorDrive)); public virtual string Clutch { get { return GetString(new[] { XMLNames.BusAux_PneumaticSystem, "Clutch" }); } } @@ -211,66 +182,38 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IHVACBusAuxiliariesDeclarationData - public virtual BusHVACSystemConfiguration? SystemConfiguration - { - get { return BusHVACSystemConfiguration.Unknown; } - } + public virtual BusHVACSystemConfiguration? SystemConfiguration => BusHVACSystemConfiguration.Unknown; - public virtual HeatPumpType? HeatPumpTypeDriverCompartment { get { return null; } } - public virtual HeatPumpMode? HeatPumpModeDriverCompartment { get { return null; } } - public virtual IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments - { - get { return null; } - } + public virtual HeatPumpType? HeatPumpTypeDriverCompartment => null; + public virtual HeatPumpMode? HeatPumpModeDriverCompartment => null; - public virtual Watt AuxHeaterPower - { - get { return 0.SI<Watt>(); } - } + public virtual IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments => null; - public virtual bool? DoubleGlazing - { - get { return false; } - } + public virtual Watt AuxHeaterPower => 0.SI<Watt>(); - public virtual bool HeatPump - { - get { return false; } - } + public virtual bool? DoubleGlazing => false; - public virtual bool? OtherHeatingTechnology - { - get { return false; } - } + public virtual bool HeatPump => false; + + public virtual bool? OtherHeatingTechnology => false; public virtual bool? AdjustableCoolantThermostat { get { return GetBool(new[] { "HVAC", "AdjustableCoolantThermostat" }); } } - public virtual bool? AdjustableAuxiliaryHeater - { - get { return false; } - } + public virtual bool? AdjustableAuxiliaryHeater => false; public virtual bool EngineWasteGasHeatExchanger { get { return GetBool(new[] { "HVAC", "EngineWasteGasHeatExchanger" }); } } - public virtual bool? SeparateAirDistributionDucts - { - get { return false; } - } + public virtual bool? SeparateAirDistributionDucts => false; - public virtual bool? WaterElectricHeater - { - get { return false; } - } - public virtual bool? AirElectricHeater - { - get { return false; } - } + public virtual bool? WaterElectricHeater => false; + + public virtual bool? AirElectricHeater => false; #endregion } @@ -287,10 +230,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider : base(vehicle, componentNode, sourceFile) { } - public override XmlNode XMLSource - { - get { return BaseNode; } - } + public override XmlNode XMLSource => BaseNode; } public class XMLDeclarationCompleteBusAuxiliariesDataProviderV26 : XMLDeclarationPrimaryBusAuxiliariesDataProviderV26, IElectricConsumersDeclarationData @@ -308,60 +248,33 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider - public override IList<string> SteeringPumpTechnology { get { return null; } } + public override IList<string> SteeringPumpTechnology => null; - public override IElectricConsumersDeclarationData ElectricConsumers - { - get - { - return this; - } - } + public override IElectricConsumersDeclarationData ElectricConsumers => this; - public override IPneumaticSupplyDeclarationData PneumaticSupply { get { return null; } } + public override IPneumaticSupplyDeclarationData PneumaticSupply => null; //public override IPneumaticConsumersDeclarationData PneumaticConsumers { get { return null; } } - public override BusHVACSystemConfiguration? SystemConfiguration - { - get { return BusHVACSystemConfigurationHelper.Parse(GetString(XMLNames.Bus_SystemConfiguration)); } - } + public override BusHVACSystemConfiguration? SystemConfiguration => BusHVACSystemConfigurationHelper.Parse(GetString(XMLNames.Bus_SystemConfiguration)); - public override Watt AuxHeaterPower - { - get { return GetDouble(XMLNames.Bus_AuxiliaryHeaterPower).SI<Watt>(); } - } + public override Watt AuxHeaterPower => GetDouble(XMLNames.Bus_AuxiliaryHeaterPower).SI<Watt>(); - public override bool? DoubleGlazing - { - get { return GetBool(XMLNames.Bus_DoubleGlazing); } - } + public override bool? DoubleGlazing => GetBool(XMLNames.Bus_DoubleGlazing); - public override bool HeatPump - { - get { return GetBool(XMLNames.Bus_HeatPump); } - } + public override bool HeatPump => GetBool(XMLNames.Bus_HeatPump); public override bool? AdjustableCoolantThermostat { get { return GetBool(new[] { "HVAC", XMLNames.Bus_AdjustableCoolantThermostat }); } } - public override bool? AdjustableAuxiliaryHeater - { - get { return GetBool(XMLNames.Bus_AdjustableAuxiliaryHeater); } - } + public override bool? AdjustableAuxiliaryHeater => GetBool(XMLNames.Bus_AdjustableAuxiliaryHeater); - public override bool EngineWasteGasHeatExchanger - { - get { return false; } - } + public override bool EngineWasteGasHeatExchanger => false; - public override bool? SeparateAirDistributionDucts - { - get { return GetBool(XMLNames.Bus_SeparateAirDistributionDucts); } - } + public override bool? SeparateAirDistributionDucts => GetBool(XMLNames.Bus_SeparateAirDistributionDucts); #endregion @@ -400,31 +313,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider AirElectricHeater == null && OtherHeatingTechnology == null ; } - public override XmlNode XMLSource - { - get { return BaseNode; } - } + public override XmlNode XMLSource => BaseNode; - public override IHVACBusAuxiliariesDeclarationData HVACAux - { - get { return IsBusHVACTagEmpty() ? null : this; } - } + public override IHVACBusAuxiliariesDeclarationData HVACAux => IsBusHVACTagEmpty() ? null : this; - public override BusHVACSystemConfiguration? SystemConfiguration - { - get { return ElementExists(XMLNames.Bus_SystemConfiguration) - ? BusHVACSystemConfigurationHelper.Parse(GetString(XMLNames.Bus_SystemConfiguration)) : null; } - } + public override BusHVACSystemConfiguration? SystemConfiguration => + ElementExists(XMLNames.Bus_SystemConfiguration) + ? BusHVACSystemConfigurationHelper.Parse(GetString(XMLNames.Bus_SystemConfiguration)) : null; - public override HeatPumpType? HeatPumpTypeDriverCompartment - { - get - { - return ElementExists(XMLNames.Bus_HeatPumpTypeDriver) - ? HeatPumpTypeHelper.Parse(GetString(XMLNames.Bus_HeatPumpTypeDriver)) : (HeatPumpType?)null; - } - } + public override HeatPumpType? HeatPumpTypeDriverCompartment => + ElementExists(XMLNames.Bus_HeatPumpTypeDriver) + ? HeatPumpTypeHelper.Parse(GetString(XMLNames.Bus_HeatPumpTypeDriver)) : (HeatPumpType?)null; public override HeatPumpMode? HeatPumpModeDriverCompartment { @@ -440,15 +340,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider - public override IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments - { - get - { - return ElementExists(XMLNames.Bus_HeatPumpTypePassenger) - && ElementExists(XMLNames.Bus_HeatPumpModePassenger) - ? GetHeatPumpPassengerCompartments() : null; - } - } + public override IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments => + ElementExists(XMLNames.Bus_HeatPumpTypePassenger) + && ElementExists(XMLNames.Bus_HeatPumpModePassenger) + ? GetHeatPumpPassengerCompartments() : null; private IList<Tuple<HeatPumpType, HeatPumpMode>> GetHeatPumpPassengerCompartments() { @@ -471,69 +366,34 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider return heatPumps.Any() != true ? null : heatPumps; } - public override Watt AuxHeaterPower - { - get - { - return ElementExists(XMLNames.Bus_AuxiliaryHeaterPower) - ? GetDouble(XMLNames.Bus_AuxiliaryHeaterPower).SI<Watt>() : null; - } - } + public override Watt AuxHeaterPower => + ElementExists(XMLNames.Bus_AuxiliaryHeaterPower) + ? GetDouble(XMLNames.Bus_AuxiliaryHeaterPower).SI<Watt>() : null; - public override bool? DoubleGlazing - { - get - { - return ElementExists(XMLNames.Bus_DoubleGlazing) - ? GetBool(XMLNames.Bus_DoubleGlazing) : (bool?)null; - } - } + public override bool? DoubleGlazing => + ElementExists(XMLNames.Bus_DoubleGlazing) + ? GetBool(XMLNames.Bus_DoubleGlazing) : (bool?)null; - public override bool? AdjustableAuxiliaryHeater - { - get - { - return ElementExists(XMLNames.Bus_AdjustableAuxiliaryHeater) - ? GetBool(XMLNames.Bus_AdjustableAuxiliaryHeater) : (bool?)null; - } - } + public override bool? AdjustableAuxiliaryHeater => + ElementExists(XMLNames.Bus_AdjustableAuxiliaryHeater) + ? GetBool(XMLNames.Bus_AdjustableAuxiliaryHeater) : (bool?)null; - public override bool? SeparateAirDistributionDucts - { - get - { - return ElementExists(XMLNames.Bus_SeparateAirDistributionDucts) - ? GetBool(XMLNames.Bus_SeparateAirDistributionDucts) : (bool?)null; - } - } + public override bool? SeparateAirDistributionDucts => + ElementExists(XMLNames.Bus_SeparateAirDistributionDucts) + ? GetBool(XMLNames.Bus_SeparateAirDistributionDucts) : (bool?)null; - public override bool? WaterElectricHeater - { - get - { - return ElementExists(XMLNames.Bus_WaterElectricHeater) - ? GetBool(XMLNames.Bus_WaterElectricHeater) : (bool?)null; - } - } + public override bool? WaterElectricHeater => + ElementExists(XMLNames.Bus_WaterElectricHeater) + ? GetBool(XMLNames.Bus_WaterElectricHeater) : (bool?)null; - public override bool? AirElectricHeater - { - get - { - return ElementExists(XMLNames.Bus_AirElectricHeater) - ? GetBool(XMLNames.Bus_AirElectricHeater) : (bool?)null; - } - } + public override bool? AirElectricHeater => + ElementExists(XMLNames.Bus_AirElectricHeater) + ? GetBool(XMLNames.Bus_AirElectricHeater) : (bool?)null; - public override bool? OtherHeatingTechnology - { - get - { - return ElementExists(XMLNames.Bus_OtherHeatingTechnology) - ? GetBool(XMLNames.Bus_OtherHeatingTechnology) : (bool?)null; - } - } + public override bool? OtherHeatingTechnology => + ElementExists(XMLNames.Bus_OtherHeatingTechnology) + ? GetBool(XMLNames.Bus_OtherHeatingTechnology) : (bool?)null; private bool IsElectricConsumersTagEmpty() { @@ -542,10 +402,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } - public override IElectricConsumersDeclarationData ElectricConsumers - { - get { return IsElectricConsumersTagEmpty() ? null : this; } - } + public override IElectricConsumersDeclarationData ElectricConsumers => IsElectricConsumersTagEmpty() ? null : this; public override bool? InteriorLightsLED { @@ -598,29 +455,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } - public override IPneumaticSupplyDeclarationData PneumaticSupply - { - get { return null; } - } + public override IPneumaticSupplyDeclarationData PneumaticSupply => null; - public override IElectricSupplyDeclarationData ElectricSupply - { - get { return null; } - } + public override IElectricSupplyDeclarationData ElectricSupply => null; - public override IPneumaticConsumersDeclarationData PneumaticConsumers - { - get { return null; } - } + public override IPneumaticConsumersDeclarationData PneumaticConsumers => null; - public override string FanTechnology - { - get { return null; } - } + public override string FanTechnology => null; - public override IList<string> SteeringPumpTechnology - { - get { return null; } - } + public override IList<string> SteeringPumpTechnology => null; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs index 8fa63495e3114561f43772b3cdcd7fda86c700e5..3e651e48dbb667f38d36cc06ff709344e81b514a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs @@ -71,60 +71,30 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IVehicleComponentsDeclaration - public virtual IAirdragDeclarationInputData AirdragInputData - { - get { return _airdragInputData ?? (_airdragInputData = ComponentReader.AirdragInputData); } - } + public virtual IAirdragDeclarationInputData AirdragInputData => _airdragInputData ?? (_airdragInputData = ComponentReader.AirdragInputData); - public virtual IGearboxDeclarationInputData GearboxInputData - { - get { return _gearboxInputData ?? (_gearboxInputData = ComponentReader.GearboxInputData); } - } + public virtual IGearboxDeclarationInputData GearboxInputData => _gearboxInputData ?? (_gearboxInputData = ComponentReader.GearboxInputData); - public virtual ITorqueConverterDeclarationInputData TorqueConverterInputData - { - get { return _torqueconverterInputData ?? (_torqueconverterInputData = ComponentReader.TorqueConverterInputData); } - } + public virtual ITorqueConverterDeclarationInputData TorqueConverterInputData => _torqueconverterInputData ?? (_torqueconverterInputData = ComponentReader.TorqueConverterInputData); - public virtual IAxleGearInputData AxleGearInputData - { - get { return _axleGearInputData ?? (_axleGearInputData = ComponentReader.AxleGearInputData); } - } + public virtual IAxleGearInputData AxleGearInputData => _axleGearInputData ?? (_axleGearInputData = ComponentReader.AxleGearInputData); - public virtual IAngledriveInputData AngledriveInputData - { - get { return _angledriveInputData ?? (_angledriveInputData = ComponentReader.AngledriveInputData); } - } + public virtual IAngledriveInputData AngledriveInputData => _angledriveInputData ?? (_angledriveInputData = ComponentReader.AngledriveInputData); - public virtual IEngineDeclarationInputData EngineInputData - { - get { return _engineInputData ?? (_engineInputData = ComponentReader.EngineInputData); } - } + public virtual IEngineDeclarationInputData EngineInputData => _engineInputData ?? (_engineInputData = ComponentReader.EngineInputData); - IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData - { - get { return _auxInputData ?? (_auxInputData = ComponentReader.AuxiliaryData); } - } + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData => _auxInputData ?? (_auxInputData = ComponentReader.AuxiliaryData); - public virtual IRetarderInputData RetarderInputData - { - get { return _retarderInputData ?? (_retarderInputData = ComponentReader.RetarderInputData); } - } + public virtual IRetarderInputData RetarderInputData => _retarderInputData ?? (_retarderInputData = ComponentReader.RetarderInputData); - public virtual IPTOTransmissionInputData PTOTransmissionInputData - { - get { return _vehicle.PTOTransmissionInputData; } - } + public virtual IPTOTransmissionInputData PTOTransmissionInputData => _vehicle.PTOTransmissionInputData; - public virtual IAxlesDeclarationInputData AxleWheels - { - get { return _axleWheels ?? (_axleWheels = ComponentReader.AxlesDeclarationInputData); } - } + public virtual IAxlesDeclarationInputData AxleWheels => _axleWheels ?? (_axleWheels = ComponentReader.AxlesDeclarationInputData); - public virtual IBusAuxiliariesDeclarationData BusAuxiliaries { get { return null; } } - public virtual IElectricStorageDeclarationInputData ElectricStorage { get { return null; } } - public virtual IElectricMachinesDeclarationInputData ElectricMachines { get { return null; } } + public virtual IBusAuxiliariesDeclarationData BusAuxiliaries => null; + public virtual IElectricStorageDeclarationInputData ElectricStorage => null; + public virtual IElectricMachinesDeclarationInputData ElectricMachines => null; #endregion @@ -137,10 +107,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -162,10 +129,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -186,17 +150,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { } - IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData - { - get { return null; } - } + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData => null; - public override IBusAuxiliariesDeclarationData BusAuxiliaries { get { return _busAuxiliaries ?? (_busAuxiliaries = ComponentReader.BusAuxiliariesInputData); } } + public override IBusAuxiliariesDeclarationData BusAuxiliaries => _busAuxiliaries ?? (_busAuxiliaries = ComponentReader.BusAuxiliariesInputData); - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -216,21 +174,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of XMLDeclarationComponentsDataProviderV10 - public override IAxleGearInputData AxleGearInputData - { - get - { - return null; - //throw new NotSupportedException("No Axlegeardata available"); - } - } + public override IAxleGearInputData AxleGearInputData => null; + //throw new NotSupportedException("No Axlegeardata available"); #endregion - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -251,22 +200,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider vehicle, componentNode, sourceFile) { } - IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData - { - get { return null; } - } + IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData => null; - IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData - { - get { return null; } - } + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData => null; - public override IBusAuxiliariesDeclarationData BusAuxiliaries { get { return _busAuxiliaries ?? (_busAuxiliaries = ComponentReader.BusAuxiliariesInputData); } } + public override IBusAuxiliariesDeclarationData BusAuxiliaries => _busAuxiliaries ?? (_busAuxiliaries = ComponentReader.BusAuxiliariesInputData); - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } @@ -288,35 +228,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData - { - get { return this; } - } + IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData => this; - IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData - { - get { return null; } - } + IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData => null; - IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData - { - get { return null; } - } + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData => null; - public override IBusAuxiliariesDeclarationData BusAuxiliaries - { - get { return _busAuxiliaries ?? (_busAuxiliaries = ComponentReader.BusAuxiliariesInputData); } - } + public override IBusAuxiliariesDeclarationData BusAuxiliaries => _busAuxiliaries ?? (_busAuxiliaries = ComponentReader.BusAuxiliariesInputData); - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #region IRetarderInputData Interface Implementation - public RetarderType Type { get { return _vehicle.RetarderType; } } - public double Ratio { get { return _vehicle.RetarderRatio; } } + public RetarderType Type => _vehicle.RetarderType; + public double Ratio => _vehicle.RetarderRatio; public TableData LossMap { get; } #endregion @@ -354,45 +279,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } - public override IGearboxDeclarationInputData GearboxInputData - { - get { return null; } - } + public override IGearboxDeclarationInputData GearboxInputData => null; - public override ITorqueConverterDeclarationInputData TorqueConverterInputData - { - get { return null; } - } + public override ITorqueConverterDeclarationInputData TorqueConverterInputData => null; - public override IAxleGearInputData AxleGearInputData - { - get { return null; } - } + public override IAxleGearInputData AxleGearInputData => null; - public override IAngledriveInputData AngledriveInputData - { - get { return null; } - } + public override IAngledriveInputData AngledriveInputData => null; - public override IEngineDeclarationInputData EngineInputData - { - get { return null; } - } + public override IEngineDeclarationInputData EngineInputData => null; - public override IRetarderInputData RetarderInputData - { - get { return null; } - } + public override IRetarderInputData RetarderInputData => null; - public override IPTOTransmissionInputData PTOTransmissionInputData - { - get { return null; } - } + public override IPTOTransmissionInputData PTOTransmissionInputData => null; - public override IAxlesDeclarationInputData AxleWheels - { - get { return null; } - } + public override IAxlesDeclarationInputData AxleWheels => null; public override IBusAuxiliariesDeclarationData BusAuxiliaries diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs index 62ab6b540fd21635b28f2d4b06bf665e8f7baca7..933c79281c63f3b2dc2819ab5db2e336505ccffc 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs @@ -66,38 +66,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IEngineDeclarationInputData - public virtual CubicMeter Displacement - { - get { return GetDouble(XMLNames.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); } - } + public virtual CubicMeter Displacement => GetDouble(XMLNames.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); - public virtual Watt RatedPowerDeclared - { - get { return GetDouble(XMLNames.Engine_RatedPower).SI<Watt>(); } - } + public virtual Watt RatedPowerDeclared => GetDouble(XMLNames.Engine_RatedPower).SI<Watt>(); - public virtual PerSecond RatedSpeedDeclared - { - get { return GetDouble(XMLNames.Engine_RatedSpeed).RPMtoRad(); } - } + public virtual PerSecond RatedSpeedDeclared => GetDouble(XMLNames.Engine_RatedSpeed).RPMtoRad(); - public virtual NewtonMeter MaxTorqueDeclared - { - get { return GetDouble(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); } - } + public virtual NewtonMeter MaxTorqueDeclared => GetDouble(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); - public virtual IList<IEngineModeDeclarationInputData> EngineModes - { - get { - return _engineModes ?? - (_engineModes = new List<IEngineModeDeclarationInputData>() { new XMLSingleFuelEngineMode(BaseNode) }); - } - } + public virtual IList<IEngineModeDeclarationInputData> EngineModes => + _engineModes ?? + (_engineModes = new List<IEngineModeDeclarationInputData>() { new XMLSingleFuelEngineMode(BaseNode) }); - public virtual WHRType WHRType - { - get { return WHRType.None; } - } + public virtual WHRType WHRType => WHRType.None; public class XMLSingleFuelEngineMode : AbstractXMLType, IEngineModeDeclarationInputData @@ -106,37 +87,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLSingleFuelEngineMode(XmlNode baseNode) : base(baseNode) { } - public virtual PerSecond IdleSpeed - { - get { return GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } - } + public virtual PerSecond IdleSpeed => GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); - public virtual TableData FullLoadCurve - { - get { - return ReadTableData( - XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry, - AttributeMappings.EngineFullLoadCurveMapping); - } - } + public virtual TableData FullLoadCurve => + ReadTableData( + XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry, + AttributeMappings.EngineFullLoadCurveMapping); - public virtual IList<IEngineFuelDeclarationInputData> Fuels - { - get { - return FuelsList ?? - (FuelsList = new List<IEngineFuelDeclarationInputData>() { new XMLSingleFuelEngineFuel(BaseNode) }); - } - } + public virtual IList<IEngineFuelDeclarationInputData> Fuels => + FuelsList ?? + (FuelsList = new List<IEngineFuelDeclarationInputData>() { new XMLSingleFuelEngineFuel(BaseNode) }); - public virtual IWHRData WasteHeatRecoveryDataElectrical - { - get { return null; } - } + public virtual IWHRData WasteHeatRecoveryDataElectrical => null; - public virtual IWHRData WasteHeatRecoveryDataMechanical - { - get { return null; } - } + public virtual IWHRData WasteHeatRecoveryDataMechanical => null; } public class XMLSingleFuelEngineFuel : AbstractXMLType, IEngineFuelDeclarationInputData @@ -158,49 +122,27 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual TableData FuelConsumptionMap - { - get { - return ReadTableData( - XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, - AttributeMappings.FuelConsumptionMapMapping); - } - } + public virtual TableData FuelConsumptionMap => + ReadTableData( + XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, + AttributeMappings.FuelConsumptionMapMapping); - public virtual double WHTCMotorway - { - get { return GetDouble(XMLNames.Engine_WHTCMotorway); } - } + public virtual double WHTCMotorway => GetDouble(XMLNames.Engine_WHTCMotorway); - public virtual double WHTCRural - { - get { return GetDouble(XMLNames.Engine_WHTCRural); } - } + public virtual double WHTCRural => GetDouble(XMLNames.Engine_WHTCRural); - public virtual double WHTCUrban - { - get { return GetDouble(XMLNames.Engine_WHTCUrban); } - } + public virtual double WHTCUrban => GetDouble(XMLNames.Engine_WHTCUrban); - public virtual double ColdHotBalancingFactor - { - get { return GetDouble(XMLNames.Engine_ColdHotBalancingFactor); } - } + public virtual double ColdHotBalancingFactor => GetDouble(XMLNames.Engine_ColdHotBalancingFactor); - public virtual double CorrectionFactorRegPer - { - get { return GetDouble(XMLNames.Engine_CorrectionFactor_RegPer); } - } + public virtual double CorrectionFactorRegPer => GetDouble(XMLNames.Engine_CorrectionFactor_RegPer); } #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -224,10 +166,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -249,10 +188,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -272,10 +208,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #region Overrides of XMLDeclarationEngineDataProviderV10 @@ -408,9 +341,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider string.Join( "; ", missing.Select( - x => string.Format( - "n: {0}, T: {1}", x.Attributes?[XMLNames.Engine_FuelConsumptionMap_EngineSpeed_Attr]?.Value, - x.Attributes?[XMLNames.Engine_FuelConsumptionMap_Torque_Attr]?.Value)))); + x => $"n: {x.Attributes?[XMLNames.Engine_FuelConsumptionMap_EngineSpeed_Attr]?.Value}, " + + $"T: {x.Attributes?[XMLNames.Engine_FuelConsumptionMap_Torque_Attr]?.Value}"))); } if (correctionFactorNodes[0].ParentNode.ParentNode != whrFuelNode) { @@ -427,10 +359,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of XMLSingleFuelEngineFuel - public override FuelType FuelType - { - get { return GetAttribute(BaseNode, "type").ParseEnum<FuelType>(); } - } + public override FuelType FuelType => GetAttribute(BaseNode, "type").ParseEnum<FuelType>(); #endregion } @@ -449,52 +378,24 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IWHRData - public double UrbanCorrectionFactor - { - get { return GetNode(XMLNames.Engine_WHRCorrectionFactors_Urban, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; } - } + public double UrbanCorrectionFactor => GetNode(XMLNames.Engine_WHRCorrectionFactors_Urban, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - public double RuralCorrectionFactor - { - get { return GetNode(XMLNames.Engine_WHRCorrectionFactors_Rural, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; } - } + public double RuralCorrectionFactor => GetNode(XMLNames.Engine_WHRCorrectionFactors_Rural, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - public double MotorwayCorrectionFactor - { - get { - return GetNode(XMLNames.Engine_WHRCorrectionFactors_Motorway, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - } - } + public double MotorwayCorrectionFactor => GetNode(XMLNames.Engine_WHRCorrectionFactors_Motorway, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - public double BFColdHot - { - get { - return GetNode(XMLNames.Engine_WHRCorrectionFactors_BFColdHot, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - } - } + public double BFColdHot => GetNode(XMLNames.Engine_WHRCorrectionFactors_BFColdHot, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - public double CFRegPer - { - get { - return GetNode(XMLNames.Engine_WHRCorrectionFactors_CFRegPer, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - } - } + public double CFRegPer => GetNode(XMLNames.Engine_WHRCorrectionFactors_CFRegPer, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; - public double EngineeringCorrectionFactor - { - get { return 1.0; } - } + public double EngineeringCorrectionFactor => 1.0; - public TableData GeneratedPower - { - get { - return WHRPower ?? (WHRPower = BaseNode == null - ? null - : ReadTableData( - XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, - AttributeMappings.WHRPowerMapMapping)); - } - } + public TableData GeneratedPower => + WHRPower ?? (WHRPower = BaseNode == null + ? null + : ReadTableData( + XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, + AttributeMappings.WHRPowerMapMapping)); #endregion } @@ -514,18 +415,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationMultistagePrimaryVehicleBusEngineDataProviderV01(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - public override IList<IEngineModeDeclarationInputData> EngineModes - { - get - { - return _engineModes ?? - (_engineModes = new List<IEngineModeDeclarationInputData>() { new XMLSingleFuelEngineMode(BaseNode) }); - } - } + public override IList<IEngineModeDeclarationInputData> EngineModes => + _engineModes ?? + (_engineModes = new List<IEngineModeDeclarationInputData>() { new XMLSingleFuelEngineMode(BaseNode) }); - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs index 34ea16ecdca63337e3d70e4616845119d50acd66..58160826488a24e72aadd2fbbda5fa1a0164eaeb 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs @@ -66,10 +66,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -115,9 +112,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual bool DifferentialIncluded { get { return false; } } + public virtual bool DifferentialIncluded => false; - public virtual double AxlegearRatio { get { return double.NaN; } } + public virtual double AxlegearRatio => double.NaN; //public virtual ITorqueConverterDeclarationInputData TorqueConverter //{ @@ -145,10 +142,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -166,16 +160,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of XMLDeclarationGearboxDataProviderV10 - public override bool DifferentialIncluded { get { return GetBool(XMLNames.Gearbox_DifferentialIncluded); } } + public override bool DifferentialIncluded => GetBool(XMLNames.Gearbox_DifferentialIncluded); - public override double AxlegearRatio { get { return DifferentialIncluded ? GetDouble(XMLNames.Gearbox_AxlegearRatio) : double.NaN; } } + public override double AxlegearRatio => DifferentialIncluded ? GetDouble(XMLNames.Gearbox_AxlegearRatio) : double.NaN; #endregion - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -193,16 +184,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractCommonComponentType - public override string CertificationNumber - { - get { return GetString(XMLNames.Component_CertificationNumber, required: false); } - } + public override string CertificationNumber => GetString(XMLNames.Component_CertificationNumber, required: false); #endregion - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs index 73e3fa6d616312e7ce90e3e329d77fafdf76ff46..eceef33b4fdb270974a367550480665777da515f 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs @@ -71,10 +71,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -87,12 +84,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration #endregion - public virtual IDeclarationJobInputData JobInputData - { - get { return JobData ?? (JobData = Reader.JobData); } - } + public virtual IDeclarationJobInputData JobInputData => JobData ?? (JobData = Reader.JobData); - public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData { get { return null; } } + public virtual IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData => null; public virtual XElement XMLHash { get; private set; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs index 4e4303772327e119ea956e7be4ebb540f1fdef77..119c1e6dc82479ad25437bfdda817dbd215ac9e0 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs @@ -57,40 +57,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } + protected override DataSourceType SourceType => DataSourceType.XMLFile; #endregion #region Implementation of IDeclarationJobInputData - public virtual bool SavedInDeclarationMode - { - get { return true; } - } + public virtual bool SavedInDeclarationMode => true; - public virtual IVehicleDeclarationInputData Vehicle - { - get { return _vehicle ?? (_vehicle = Reader.CreateVehicle); } - } + public virtual IVehicleDeclarationInputData Vehicle => _vehicle ?? (_vehicle = Reader.CreateVehicle); - public virtual string JobName - { - get { return Vehicle.Identifier; } - } + public virtual string JobName => Vehicle.Identifier; - public virtual string ShiftStrategy { get { return null; } } - public VectoSimulationJobType JobType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public virtual string ShiftStrategy => null; + + public VectoSimulationJobType JobType => VectoSimulationJobType.ConventionalVehicle; #endregion @@ -115,10 +98,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationJobInputDataProviderV20(XmlNode node, IXMLDeclarationInputData inputProvider, string fileName) : base(node, inputProvider, fileName) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -139,24 +119,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { InputData = inputProvider; } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - public IVehicleDeclarationInputData Vehicle - { - get { return _vehicle ?? (_vehicle = Reader.CreateVehicle); } - } + public IVehicleDeclarationInputData Vehicle => _vehicle ?? (_vehicle = Reader.CreateVehicle); protected override DataSourceType SourceType { get; } public bool SavedInDeclarationMode { get; } public string JobName { get; } - public string ShiftStrategy { get{ return null; } } - public VectoSimulationJobType JobType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public string ShiftStrategy => null; + + public VectoSimulationJobType JobType => VectoSimulationJobType.ConventionalVehicle; public IXMLJobDataReader Reader { protected get; set; } public IXMLPrimaryVehicleBusInputData InputData { get; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationMultistageInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationMultistageInputData.cs index f2b32c8beb507f2f87106c30c27b6dd29df00ce2..c5ea9f4bbe0400b8bd3d26a8d043775fa47ca27a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationMultistageInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationMultistageInputData.cs @@ -37,26 +37,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider XMLHash = h.ComputeXmlHash(); } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } + protected override DataSourceType SourceType => DataSourceType.XMLFile; - public IDeclarationMultistageJobInputData JobInputData - { - get { return JobData ?? (JobData = Reader.JobData); } - } + public IDeclarationMultistageJobInputData JobInputData => JobData ?? (JobData = Reader.JobData); - IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData - { - get { throw new NotImplementedException(); } - } + IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData => throw new NotImplementedException(); public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData { get; } public XElement XMLHash { get; } @@ -90,39 +78,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider SourceType = DataSourceType.XMLFile; } - public IPrimaryVehicleInformationInputDataProvider PrimaryVehicle - { - get { return _primaryVehicle ?? (_primaryVehicle = Reader.PrimaryVehicle); } - } + public IPrimaryVehicleInformationInputDataProvider PrimaryVehicle => _primaryVehicle ?? (_primaryVehicle = Reader.PrimaryVehicle); - public IList<IManufacturingStageInputData> ManufacturingStages - { - get { return _manufacturingStages ?? (_manufacturingStages = Reader.ManufacturingStages); } - } + public IList<IManufacturingStageInputData> ManufacturingStages => _manufacturingStages ?? (_manufacturingStages = Reader.ManufacturingStages); - public IManufacturingStageInputData ConsolidateManufacturingStage - { - get { return _concolidateManfacturingStage ?? (_concolidateManfacturingStage = Reader.ConsolidateManufacturingStage); } - } + public IManufacturingStageInputData ConsolidateManufacturingStage => _concolidateManfacturingStage ?? (_concolidateManfacturingStage = Reader.ConsolidateManufacturingStage); - public VectoSimulationJobType JobType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public VectoSimulationJobType JobType => VectoSimulationJobType.ConventionalVehicle; + + public bool InputComplete => Reader.InputComplete; - public bool InputComplete - { - get { return Reader.InputComplete; } - } - public IXMLMultistageJobReader Reader { protected get; set; } public IXMLMultistageInputDataProvider InputData { get; } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } } @@ -156,44 +126,26 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider _signatureNode = xmlNode.LastChild; } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } + protected override DataSourceType SourceType => DataSourceType.XMLFile; - public IVehicleDeclarationInputData Vehicle - { - get { return _vehicle ?? (_vehicle = Reader.JobData.Vehicle); } - } + public IVehicleDeclarationInputData Vehicle => _vehicle ?? (_vehicle = Reader.JobData.Vehicle); - public DigestData PrimaryVehicleInputDataHash - { - get { return _primaryVehicleInputDataHash ?? - (_primaryVehicleInputDataHash = Reader.GetDigestData(GetNode("InputDataSignature")));} - } + public DigestData PrimaryVehicleInputDataHash => + _primaryVehicleInputDataHash ?? + (_primaryVehicleInputDataHash = Reader.GetDigestData(GetNode("InputDataSignature"))); - public DigestData VehicleSignatureHash - { - get { return _vehicleSignatureHash ?? - (_vehicleSignatureHash = Reader.GetDigestData(_signatureNode));} - } + public DigestData VehicleSignatureHash => + _vehicleSignatureHash ?? + (_vehicleSignatureHash = Reader.GetDigestData(_signatureNode)); - public DigestData ManufacturerRecordHash - { - get { return _manufacturerRecordHash ?? - (_manufacturerRecordHash = Reader.GetDigestData(GetNode("ManufacturerRecordSignature"))); } - } + public DigestData ManufacturerRecordHash => + _manufacturerRecordHash ?? + (_manufacturerRecordHash = Reader.GetDigestData(GetNode("ManufacturerRecordSignature"))); - public IResultsInputData ResultsInputData - { - get { return _resultsInputData ?? (_resultsInputData = Reader.ResultsInputData); } - } + public IResultsInputData ResultsInputData => _resultsInputData ?? (_resultsInputData = Reader.ResultsInputData); public IResult GetResult(VehicleClass vehicleClass, MissionType mission, string fuelMode, Kilogram payload) { @@ -203,20 +155,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider x.SimulationParameter.FuelMode.Equals(fuelMode, StringComparison.InvariantCultureIgnoreCase)); } - public XmlNode ResultsNode - { - get { return GetNode(XMLNames.Report_Results); } - } + public XmlNode ResultsNode => GetNode(XMLNames.Report_Results); - public IApplicationInformation ApplicationInformation - { - get { return _applicationInformation ?? (_applicationInformation = Reader.ApplicationInformation); } - } + public IApplicationInformation ApplicationInformation => _applicationInformation ?? (_applicationInformation = Reader.ApplicationInformation); - public XmlNode ApplicationInformationNode - { - get { return GetNode(XMLNames.Tag_ApplicationInformation); } - } + public XmlNode ApplicationInformationNode => GetNode(XMLNames.Tag_ApplicationInformation); public XElement XMLHash { get; } @@ -248,43 +191,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider _signatureXmlNode = xmlNode.LastChild; } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - public DigestData HashPreviousStage - { - get { return _hashPreviousStage ?? - (_hashPreviousStage = Reader.GetDigestData(GetNode("HashPreviousStage"))); } - } + protected override DataSourceType SourceType => DataSourceType.XMLFile; - public int StageCount - { - get { return Convert.ToInt32(GetAttribute(BaseNode, XMLNames.ManufacturingStage_StageCount)); } - } + public DigestData HashPreviousStage => + _hashPreviousStage ?? + (_hashPreviousStage = Reader.GetDigestData(GetNode("HashPreviousStage"))); - public IVehicleDeclarationInputData Vehicle - { - get { return _vehicle ?? (_vehicle = Reader.Vehicle); } - } + public int StageCount => Convert.ToInt32(GetAttribute(BaseNode, XMLNames.ManufacturingStage_StageCount)); - public IApplicationInformation ApplicationInformation - { - get - { - return _applicationInformation ?? (_applicationInformation = Reader.ApplicationInformation); - } - } + public IVehicleDeclarationInputData Vehicle => _vehicle ?? (_vehicle = Reader.Vehicle); - public DigestData Signature - { - get { return _signature ?? (_signature = Reader.GetDigestData(_signatureXmlNode)); } - } + public IApplicationInformation ApplicationInformation => _applicationInformation ?? (_applicationInformation = Reader.ApplicationInformation); + + public DigestData Signature => _signature ?? (_signature = Reader.GetDigestData(_signatureXmlNode)); public IXMLMultistageReader Reader { protected get; set; } } @@ -304,14 +225,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider _vehicleInput = vehicleInput; } - public IVehicleDeclarationInputData VehicleInputData - { - get { return _vehicleInput; } - } - public IMultistageBusInputDataProvider MultistageJobInputData - { - get { return _multistageJobInputData; } - } + public IVehicleDeclarationInputData VehicleInputData => _vehicleInput; + + public IMultistageBusInputDataProvider MultistageJobInputData => _multistageJobInputData; public DataSource DataSource { get; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs index 76d5a4369218e51550e01013616c4ebd6f7b101c..4d6bb336ca74b8905224e32044647b0fc5634ffa 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } var otherElements = GetString(XMLNames.Vehicle_PTO_OtherElements); - var ptoTech = string.Format("{0} - {1}", shaftGearWheels, otherElements); + var ptoTech = $"{shaftGearWheels} - {otherElements}"; if (DeclarationData.PTOTransmission.GetTechnologies().Contains(ptoTech)) { return ptoTech; } @@ -79,20 +79,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual TableData PTOLossMap - { - get { return null; } - } + public virtual TableData PTOLossMap => null; - public virtual TableData PTOCycleDuringStop - { - get { return null; } - } + public virtual TableData PTOCycleDuringStop => null; - public TableData PTOCycleWhileDriving - { - get { return null; } - } + public TableData PTOCycleWhileDriving => null; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusApplicationInformationDataProviderV01.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusApplicationInformationDataProviderV01.cs index 8c6ea37fca75d78cb60f5268afd4990336189229..98493d3b028df9b8eaa98cd29e828b8b65e96118 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusApplicationInformationDataProviderV01.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusApplicationInformationDataProviderV01.cs @@ -20,14 +20,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationMultistagePrimaryVehicleBusApplicationInformationDataProviderV01(XmlNode applicationNode) : base(applicationNode) { } - public string SimulationToolVersion - { - get { return GetString(XMLNames.Report_ApplicationInfo_SimulationToolVersion); } - } + public string SimulationToolVersion => GetString(XMLNames.Report_ApplicationInfo_SimulationToolVersion); - public DateTime Date - { - get { return XmlConvert.ToDateTime(GetString(XMLNames.Report_ApplicationInfo_Date), XmlDateTimeSerializationMode.Utc); } - } + public DateTime Date => XmlConvert.ToDateTime(GetString(XMLNames.Report_ApplicationInfo_Date), XmlDateTimeSerializationMode.Utc); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs index d21580a183a424ae4c23fb6fd68c9653292387a3..21ae0bdaed5b9af7f160bd03ddaa1ff917a57e64 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs @@ -28,15 +28,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { _resultsNode = resultsNode; } - public string Status - { - get { return GetString(XMLNames.Bus_Status); } - } + public string Status => GetString(XMLNames.Bus_Status); - public IList<IResult> Results - { - get { return _results ?? (_results = ReadResults()); } - } + public IList<IResult> Results => _results ?? (_results = ReadResults()); private IList<IResult> ReadResults() @@ -67,7 +61,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider .Cast<XmlNode>().Select(x => new KeyValuePair<FuelType, JoulePerMeter>( GetAttribute(x, XMLNames.Report_Results_Fuel_Type_Attr).ParseEnum<FuelType>(), x.SelectSingleNode( - string.Format(".//*[local-name()='{0}' and @unit='MJ/km']", XMLNames.Report_Result_EnergyConsumption))?.InnerText + $".//*[local-name()='{XMLNames.Report_Result_EnergyConsumption}' and @unit='MJ/km']")?.InnerText .ToDouble().SI(Unit.SI.Mega.Joule.Per.Kilo.Meter).Cast<JoulePerMeter>())).ToDictionary(x => x.Key, x => x.Value); diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs index 9f811e49873eb052ada7fcd762280d0d04aa7d66..e7206bfc712aaf41a3467c4ab4266687e190d4d9 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs @@ -60,33 +60,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IRetarderInputData - public virtual RetarderType Type - { - get { return Vehicle.RetarderType; } - } + public virtual RetarderType Type => Vehicle.RetarderType; - public virtual double Ratio - { - get { return Vehicle.RetarderRatio; } - } + public virtual double Ratio => Vehicle.RetarderRatio; - public virtual TableData LossMap - { - get { - return ReadTableData( - XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry, - AttributeMappings.RetarderLossmapMapping); - } - } + public virtual TableData LossMap => + ReadTableData( + XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry, + AttributeMappings.RetarderLossmapMapping); #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -107,9 +94,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs index a3052497b920bb106c7d09963ca54a71eda9e181..a3706df1d1704be79922b6355423e94ab8599393 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs @@ -58,23 +58,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of ITorqueconverterDeclarationInputData - public virtual TableData TCData - { - get { - return ReadTableData( - XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry, - AttributeMappings.TorqueConverterDataMapping); - } - } + public virtual TableData TCData => + ReadTableData( + XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry, + AttributeMappings.TorqueConverterDataMapping); #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -93,10 +86,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationTorqueConverterDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -113,16 +103,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractCommonComponentType - public override string CertificationNumber - { - get { return GetString(XMLNames.Component_CertificationNumber, required: false); } - } + public override string CertificationNumber => GetString(XMLNames.Component_CertificationNumber, required: false); #endregion - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs index 8ef3270d7ebc06d57c71c0a9a99d9a538d2cac74..f02cc722c86efd6e4c66493cdaf04b6197b3188d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs @@ -61,10 +61,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -72,22 +69,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of ITyreDeclarationInputData - public virtual string Dimension - { - get { return _dimension ?? (_dimension = GetString(XMLNames.AxleWheels_Axles_Axle_Dimension)); } - } + public virtual string Dimension => _dimension ?? (_dimension = GetString(XMLNames.AxleWheels_Axles_Axle_Dimension)); - public virtual double RollResistanceCoefficient - { - get { return _rrc ?? (_rrc = GetDouble(XMLNames.AxleWheels_Axles_Axle_RRCDeclared)).Value; } - } + public virtual double RollResistanceCoefficient => _rrc ?? (_rrc = GetDouble(XMLNames.AxleWheels_Axles_Axle_RRCDeclared)).Value; - public virtual Newton TyreTestLoad - { - get { return _fzIso ?? (_fzIso = GetDouble(XMLNames.AxleWheels_Axles_Axle_FzISO).SI<Newton>()); } - } + public virtual Newton TyreTestLoad => _fzIso ?? (_fzIso = GetDouble(XMLNames.AxleWheels_Axles_Axle_FzISO).SI<Newton>()); - public virtual string FuelEfficiencyClass { get { return DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); } } + public virtual string FuelEfficiencyClass => DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); #endregion } @@ -105,10 +93,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationTyreDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -124,10 +109,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationTyreDataProviderV22(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -143,11 +125,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationTyreDataProviderV23(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - public override string FuelEfficiencyClass { get { return GetString("FuelEfficiencyClass"); } } + public override string FuelEfficiencyClass => GetString("FuelEfficiencyClass"); } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs index 5924a4b9d723000d580c371328cd700925bf3245..ea13e3759db58378ab0701a775dfe9dc99851083 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs @@ -96,34 +96,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public virtual IXMLPTOReader PTOReader { protected get; set; } - public virtual XmlElement ADASNode - { - get { return _adasNode ?? (_adasNode = GetNode(XMLNames.Vehicle_ADAS, required: false) as XmlElement); } - } + public virtual XmlElement ADASNode => _adasNode ?? (_adasNode = GetNode(XMLNames.Vehicle_ADAS, required: false) as XmlElement); public virtual IXMLADASReader ADASReader { protected get; set; } public virtual IXMLDeclarationJobInputData Job { get; } - public virtual string Identifier - { - get { return GetAttribute(BaseNode, XMLNames.Component_ID_Attr); } - } + public virtual string Identifier => GetAttribute(BaseNode, XMLNames.Component_ID_Attr); - public virtual bool ExemptedVehicle - { - get { return ElementExists(XMLNames.Vehicle_HybridElectricHDV) && ElementExists(XMLNames.Vehicle_DualFuelVehicle); } - } + public virtual bool ExemptedVehicle => ElementExists(XMLNames.Vehicle_HybridElectricHDV) && ElementExists(XMLNames.Vehicle_DualFuelVehicle); - public virtual string VIN - { - get { return GetString(XMLNames.Vehicle_VIN); } - } + public virtual string VIN => GetString(XMLNames.Vehicle_VIN); - public virtual LegislativeClass? LegislativeClass - { - get { return GetString("LegislativeCategory").ParseEnum<LegislativeClass>(); } - } + public virtual LegislativeClass? LegislativeClass => GetString(XMLNames.Vehicle_LegislativeClass).ParseEnum<LegislativeClass>(); + //get { return GetString("LegislativeCategory").ParseEnum<LegislativeClass>(); } public virtual VehicleCategory VehicleCategory { @@ -137,16 +123,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual Kilogram CurbMassChassis - { - get { return GetDouble(XMLNames.Vehicle_CurbMassChassis).SI<Kilogram>(); } - } + public virtual Kilogram CurbMassChassis => GetDouble(XMLNames.Vehicle_CurbMassChassis).SI<Kilogram>(); - public virtual Kilogram GrossVehicleMassRating - { - get { return GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>(); } - } + public virtual Kilogram GrossVehicleMassRating => GetDouble(XMLNames.Vehicle_GrossVehicleMass).SI<Kilogram>(); + //get { return GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>(); } public virtual IList<ITorqueLimitInputData> TorqueLimits { @@ -168,30 +149,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual AxleConfiguration AxleConfiguration - { - get { return AxleConfigurationHelper.Parse(GetString(XMLNames.Vehicle_AxleConfiguration)); } - } + public virtual AxleConfiguration AxleConfiguration => AxleConfigurationHelper.Parse(GetString(XMLNames.Vehicle_AxleConfiguration)); - public virtual string ManufacturerAddress - { - get { return GetString(XMLNames.Component_ManufacturerAddress); } - } + public virtual string ManufacturerAddress => GetString(XMLNames.Component_ManufacturerAddress); - public virtual PerSecond EngineIdleSpeed - { - get { return GetDouble(XMLNames.Vehicle_IdlingSpeed).RPMtoRad(); } - } + public virtual PerSecond EngineIdleSpeed => GetDouble(XMLNames.Vehicle_IdlingSpeed).RPMtoRad(); - public virtual double RetarderRatio - { - get { return GetDouble(XMLNames.Vehicle_RetarderRatio); } - } + public virtual double RetarderRatio => GetDouble(XMLNames.Vehicle_RetarderRatio); - public virtual IPTOTransmissionInputData PTOTransmissionInputData - { - get { return _ptoData ?? (_ptoData = PTOReader.PTOInputData); } - } + public virtual IPTOTransmissionInputData PTOTransmissionInputData => _ptoData ?? (_ptoData = PTOReader.PTOInputData); public virtual RetarderType RetarderType { @@ -209,147 +175,70 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual AngledriveType AngledriveType - { - get { return GetString(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); } - } + public virtual AngledriveType AngledriveType => GetString(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); - public virtual bool VocationalVehicle - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_VocationalVehicle)); } - } + public virtual bool VocationalVehicle => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_VocationalVehicle)); - public virtual bool SleeperCab - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_SleeperCab)); } - } + public virtual bool SleeperCab => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_SleeperCab)); public virtual bool? AirdragModifiedMultistage { get; } - public virtual TankSystem? TankSystem - { - get { - return ElementExists(XMLNames.Vehicle_NgTankSystem) - ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) - : (TankSystem?)null; - } - } + public virtual TankSystem? TankSystem => + ElementExists(XMLNames.Vehicle_NgTankSystem) + ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) + : (TankSystem?)null; - public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return ADASReader.ADASInputData; } - } + public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADAS => ADASReader.ADASInputData; - public virtual bool ZeroEmissionVehicle - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ZeroEmissionVehicle)); } - } + public virtual bool ZeroEmissionVehicle => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ZeroEmissionVehicle)); - public virtual bool HybridElectricHDV - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_HybridElectricHDV)); } - } + public virtual bool HybridElectricHDV => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_HybridElectricHDV)); - public virtual bool DualFuelVehicle - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_DualFuelVehicle)); } - } + public virtual bool DualFuelVehicle => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_DualFuelVehicle)); - public virtual Watt MaxNetPower1 - { - get { - return ElementExists(XMLNames.Vehicle_MaxNetPower1) - ? GetDouble(XMLNames.Vehicle_MaxNetPower1).SI<Watt>() - : null; - } - } + public virtual Watt MaxNetPower1 => + ElementExists(XMLNames.Vehicle_MaxNetPower1) + ? GetDouble(XMLNames.Vehicle_MaxNetPower1).SI<Watt>() + : null; - public virtual Watt MaxNetPower2 - { - get { - return ElementExists(XMLNames.Vehicle_MaxNetPower2) - ? GetDouble(XMLNames.Vehicle_MaxNetPower2).SI<Watt>() - : null; - } - } + public virtual Watt MaxNetPower2 => + ElementExists(XMLNames.Vehicle_MaxNetPower2) + ? GetDouble(XMLNames.Vehicle_MaxNetPower2).SI<Watt>() + : null; - public virtual string ExemptedTechnology - { - get { return null; } - } + public virtual string ExemptedTechnology => null; - public virtual RegistrationClass? RegisteredClass - { - get { return RegistrationClass.unknown; } - } + public virtual RegistrationClass? RegisteredClass => RegistrationClass.unknown; - public virtual int? NumberPassengerSeatsUpperDeck - { - get { return 0; } - } + public virtual int? NumberPassengerSeatsUpperDeck => 0; - public virtual int? NumberPassengerSeatsLowerDeck - { - get { return 0; } - } + public virtual int? NumberPassengerSeatsLowerDeck => 0; - public virtual int? NumberPassengersStandingLowerDeck - { - get { return 0; } - } - public virtual int? NumberPassengersStandingUpperDeck - { - get { return 0; } - } + public virtual int? NumberPassengersStandingLowerDeck => 0; - public virtual CubicMeter CargoVolume - { - get { return 0.SI<CubicMeter>(); } - } + public virtual int? NumberPassengersStandingUpperDeck => 0; - public virtual VehicleCode? VehicleCode - { - get { return VectoCommon.Models.VehicleCode.NOT_APPLICABLE; } - } + public virtual CubicMeter CargoVolume => 0.SI<CubicMeter>(); - public virtual bool? LowEntry - { - get { return false; } - } + public virtual VehicleCode? VehicleCode => VectoCommon.Models.VehicleCode.NOT_APPLICABLE; - public virtual bool Articulated - { - get { return false; } - } + public virtual bool? LowEntry => false; - public virtual Meter Height - { - get { return null; } - } + public virtual bool Articulated => false; - public virtual Meter Length - { - get { return null; } - } + public virtual Meter Height => null; - public virtual Meter Width - { - get { return null; } - } + public virtual Meter Length => null; - public virtual Meter EntranceHeight - { - get { return null; } - } + public virtual Meter Width => null; + + public virtual Meter EntranceHeight => null; - public virtual ConsumerTechnology? DoorDriveTechnology { get { return ConsumerTechnology.Unknown; } } + public virtual ConsumerTechnology? DoorDriveTechnology => ConsumerTechnology.Unknown; public virtual VehicleDeclarationType VehicleDeclarationType { get; } - public virtual IVehicleComponentsDeclaration Components - { - get { return _components ?? (_components = ComponentReader.ComponentInputData); } - } + public virtual IVehicleComponentsDeclaration Components => _components ?? (_components = ComponentReader.ComponentInputData); #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData @@ -357,10 +246,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -385,84 +271,39 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationVehicleDataProviderV20(IXMLDeclarationJobInputData jobData, XmlNode xmlNode, string sourceFile) : base(jobData, xmlNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - public override bool VocationalVehicle - { - get { return false; } - } + public override bool VocationalVehicle => false; - public override bool SleeperCab - { - get { return true; } - } + public override bool SleeperCab => true; - public override TankSystem? TankSystem - { - get { return VectoCommon.InputData.TankSystem.Compressed; } - } + public override TankSystem? TankSystem => VectoCommon.InputData.TankSystem.Compressed; - public override IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return new ADASDefaultValues(); } - } + public override IAdvancedDriverAssistantSystemDeclarationInputData ADAS => new ADASDefaultValues(); - public override bool ZeroEmissionVehicle - { - get { return false; } - } + public override bool ZeroEmissionVehicle => false; - public override bool HybridElectricHDV - { - get { return false; } - } + public override bool HybridElectricHDV => false; - public override bool DualFuelVehicle - { - get { return false; } - } + public override bool DualFuelVehicle => false; - public override Watt MaxNetPower1 - { - get { return null; } - } + public override Watt MaxNetPower1 => null; - public override Watt MaxNetPower2 - { - get { return null; } - } + public override Watt MaxNetPower2 => null; public class ADASDefaultValues : IAdvancedDriverAssistantSystemDeclarationInputData { #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData - public bool EngineStopStart - { - get { return false; } - } + public bool EngineStopStart => false; - public EcoRollType EcoRoll - { - get { return EcoRollType.None; } - } + public EcoRollType EcoRoll => EcoRollType.None; - public PredictiveCruiseControlType PredictiveCruiseControl - { - get { return PredictiveCruiseControlType.None; } - } + public PredictiveCruiseControlType PredictiveCruiseControl => PredictiveCruiseControlType.None; - public bool? ATEcoRollReleaseLockupClutch - { - get { return null; } - } + public bool? ATEcoRollReleaseLockupClutch => null; - public XmlNode XMLSource - { - get { return null; } - } + public XmlNode XMLSource => null; #endregion } @@ -503,10 +344,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -528,10 +366,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -539,114 +374,51 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IVehicleDeclarationInputData - public override bool ExemptedVehicle - { - get { return true; } - } + public override bool ExemptedVehicle => true; - public override AxleConfiguration AxleConfiguration - { - get { return AxleConfiguration.AxleConfig_Undefined; } - } + public override AxleConfiguration AxleConfiguration => AxleConfiguration.AxleConfig_Undefined; - public override IList<ITorqueLimitInputData> TorqueLimits - { - get { return new List<ITorqueLimitInputData>(); } - } + public override IList<ITorqueLimitInputData> TorqueLimits => new List<ITorqueLimitInputData>(); - public override PerSecond EngineIdleSpeed - { - get { return null; } - } + public override PerSecond EngineIdleSpeed => null; - public override bool VocationalVehicle - { - get { return false; } - } + public override bool VocationalVehicle => false; - public override bool SleeperCab - { - get { return false; } - } + public override bool SleeperCab => false; - public override TankSystem? TankSystem - { - get { return null; } - } + public override TankSystem? TankSystem => null; - public override IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return null; } - } + public override IAdvancedDriverAssistantSystemDeclarationInputData ADAS => null; - public override bool ZeroEmissionVehicle - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ZeroEmissionVehicle)); } - } + public override bool ZeroEmissionVehicle => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ZeroEmissionVehicle)); - public override bool HybridElectricHDV - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_HybridElectricHDV)); } - } + public override bool HybridElectricHDV => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_HybridElectricHDV)); - public override bool DualFuelVehicle - { - get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_DualFuelVehicle)); } - } + public override bool DualFuelVehicle => XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_DualFuelVehicle)); - public override Watt MaxNetPower1 - { - get { return GetDouble(XMLNames.Vehicle_MaxNetPower1).SI<Watt>(); } - } + public override Watt MaxNetPower1 => GetDouble(XMLNames.Vehicle_MaxNetPower1).SI<Watt>(); - public override Watt MaxNetPower2 - { - get { return GetDouble(XMLNames.Vehicle_MaxNetPower2).SI<Watt>(); } - } + public override Watt MaxNetPower2 => GetDouble(XMLNames.Vehicle_MaxNetPower2).SI<Watt>(); - public override IVehicleComponentsDeclaration Components - { - get { return null; } - } + public override IVehicleComponentsDeclaration Components => null; #endregion #region Implementation of IXMLDeclarationVehicleData - public override XmlElement ComponentNode - { - get { return null; } - } + public override XmlElement ComponentNode => null; - public override XmlElement PTONode - { - get { return null; } - } + public override XmlElement PTONode => null; - public override XmlElement ADASNode - { - get { return null; } - } + public override XmlElement ADASNode => null; - public override AngledriveType AngledriveType - { - get { return AngledriveType.None; } - } + public override AngledriveType AngledriveType => AngledriveType.None; - public override RetarderType RetarderType - { - get { return RetarderType.None; } - } + public override RetarderType RetarderType => RetarderType.None; - public override double RetarderRatio - { - get { return 0; } - } + public override double RetarderRatio => 0; - public override IPTOTransmissionInputData PTOTransmissionInputData - { - get { return null; } - } + public override IPTOTransmissionInputData PTOTransmissionInputData => null; #endregion } @@ -673,68 +445,35 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of XMLDeclarationVehicleDataProviderV10 - public override bool SleeperCab - { - get { return false; } - } + public override bool SleeperCab => false; - public override IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return ADASReader.ADASInputData; } - } + public override IAdvancedDriverAssistantSystemDeclarationInputData ADAS => ADASReader.ADASInputData; - public override XmlElement PTONode - { - get { return null; } - } + public override XmlElement PTONode => null; #region Overrides of XMLDeclarationVehicleDataProviderV10 - public override LegislativeClass? LegislativeClass - { - get { return VectoCommon.Models.LegislativeClass.M3; } - } + public override LegislativeClass? LegislativeClass => VectoCommon.Models.LegislativeClass.M3; #endregion - public override IPTOTransmissionInputData PTOTransmissionInputData - { - get { return null; } - } + public override IPTOTransmissionInputData PTOTransmissionInputData => null; - public override VehicleCategory VehicleCategory - { - get { return VehicleCategory.HeavyBusPrimaryVehicle; } - } + public override VehicleCategory VehicleCategory => VehicleCategory.HeavyBusPrimaryVehicle; - public override bool Articulated - { - get { return GetBool(XMLNames.Vehicle_Articulated); } - } + public override bool Articulated => GetBool(XMLNames.Vehicle_Articulated); - public override Kilogram CurbMassChassis - { - get { return null; } - } + public override Kilogram CurbMassChassis => null; - public override Kilogram GrossVehicleMassRating - { - get { return GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>(); } - } + public override Kilogram GrossVehicleMassRating => GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>(); - public override Meter EntranceHeight - { - get { return null; } - } + public override Meter EntranceHeight => null; #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -872,30 +611,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of XMLDeclarationVehicleDataProviderV10 - public override bool SleeperCab - { - get { return false; } - } + public override bool SleeperCab => false; - public override bool VocationalVehicle - { - get { return false; } - } + public override bool VocationalVehicle => false; - public override IPTOTransmissionInputData PTOTransmissionInputData - { - get { return null; } - } + public override IPTOTransmissionInputData PTOTransmissionInputData => null; - public override XmlElement PTONode - { - get { return null; } - } + public override XmlElement PTONode => null; - public override Kilogram GrossVehicleMassRating - { - get { return GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>(); } - } + public override Kilogram GrossVehicleMassRating => GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>(); public override CubicMeter CargoVolume { @@ -913,10 +637,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -963,36 +684,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of XMLDeclarationVehicleDataProviderV10 - public override VehicleCategory VehicleCategory - { - get { return VehicleCategory.HeavyBusCompletedVehicle; } - } + public override VehicleCategory VehicleCategory => VehicleCategory.HeavyBusCompletedVehicle; - public override RegistrationClass? RegisteredClass - { - get { return RegistrationClassHelper.Parse(GetString(XMLNames.Vehicle_RegisteredClass)).First(); } - } + public override RegistrationClass? RegisteredClass => RegistrationClassHelper.Parse(GetString(XMLNames.Vehicle_RegisteredClass)).First(); - public override VehicleCode? VehicleCode - { - get { return GetString(XMLNames.Vehicle_VehicleCode).ParseEnum<VehicleCode>(); } - } + public override VehicleCode? VehicleCode => GetString(XMLNames.Vehicle_VehicleCode).ParseEnum<VehicleCode>(); //TechnicalPermissibleMaximumLadenMass - public override Kilogram GrossVehicleMassRating - { - get { return GetDouble(XMLNames.TPMLM).SI<Kilogram>(); } - } + public override Kilogram GrossVehicleMassRating => GetDouble(XMLNames.TPMLM).SI<Kilogram>(); - public override TankSystem? TankSystem - { - get - { - return ElementExists(XMLNames.Vehicle_NgTankSystem) - ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) - : (TankSystem?)null; - } - } + public override TankSystem? TankSystem => + ElementExists(XMLNames.Vehicle_NgTankSystem) + ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) + : (TankSystem?)null; public override int? NumberPassengerSeatsLowerDeck { @@ -1011,53 +715,29 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } //HeightIntegratedBody - public override Meter Height - { - get { return GetDouble(XMLNames.Bus_HeighIntegratedBody).SI<Meter>(); } - } + public override Meter Height => GetDouble(XMLNames.Bus_HeighIntegratedBody).SI<Meter>(); //VehicleLength - public override Meter Length - { - get { return GetDouble(XMLNames.Bus_VehicleLength).SI<Meter>(); } - } + public override Meter Length => GetDouble(XMLNames.Bus_VehicleLength).SI<Meter>(); //VehicleWidth - public override Meter Width - { - get { return GetDouble(XMLNames.Bus_VehicleWidth).SI<Meter>(); } - } + public override Meter Width => GetDouble(XMLNames.Bus_VehicleWidth).SI<Meter>(); - public override XmlElement PTONode - { - get { return null; } - } + public override XmlElement PTONode => null; #endregion - public override bool? LowEntry - { - get { return GetBool(XMLNames.Bus_LowEntry); } - } + public override bool? LowEntry => GetBool(XMLNames.Bus_LowEntry); - public override Meter EntranceHeight - { - get { return GetDouble(XMLNames.Bus_EntranceHeight).SI<Meter>(); } - } + public override Meter EntranceHeight => GetDouble(XMLNames.Bus_EntranceHeight).SI<Meter>(); + + public override ConsumerTechnology? DoorDriveTechnology => ConsumerTechnologyHelper.Parse(GetString(XMLNames.BusAux_PneumaticSystem_DoorDriveTechnology)); - public override ConsumerTechnology? DoorDriveTechnology - { - get { return ConsumerTechnologyHelper.Parse(GetString(XMLNames.BusAux_PneumaticSystem_DoorDriveTechnology)); } - } - #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -1089,90 +769,53 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractCommonComponentType - public override string Manufacturer - { - get { return GetString(XMLNames.ManufacturerPrimaryVehicle); } - } + public override string Manufacturer => GetString(XMLNames.ManufacturerPrimaryVehicle); - public string ManufacturerAddress - { - get { return GetString(XMLNames.ManufacturerAddressPrimaryVehicle); } - } + public string ManufacturerAddress => GetString(XMLNames.ManufacturerAddressPrimaryVehicle); #endregion #region IXMLDeclarationVehicleData interface - public string VIN - { - get { return GetString(XMLNames.Vehicle_VIN); } - } + public string VIN => GetString(XMLNames.Vehicle_VIN); public virtual LegislativeClass? LegislativeClass { get { return GetString(XMLNames.Bus_LegislativeCategory)?.ParseEnum<LegislativeClass>(); } } - public virtual VehicleCategory VehicleCategory - { - get { return VehicleCategoryHelper.Parse(GetString("ChassisConfiguration")); } - } + public virtual VehicleCategory VehicleCategory => VehicleCategoryHelper.Parse(GetString("ChassisConfiguration")); - public virtual AxleConfiguration AxleConfiguration - { - get { return AxleConfigurationHelper.Parse(GetString(XMLNames.Vehicle_AxleConfiguration)); } - } + public virtual AxleConfiguration AxleConfiguration => AxleConfigurationHelper.Parse(GetString(XMLNames.Vehicle_AxleConfiguration)); //TechnicalPermissibleMaximumLadenMass - public virtual Kilogram GrossVehicleMassRating - { - get { return GetDouble(XMLNames.TPMLM).SI<Kilogram>(); } - } + public virtual Kilogram GrossVehicleMassRating => GetDouble(XMLNames.TPMLM).SI<Kilogram>(); //IdlingSpeed - public virtual PerSecond EngineIdleSpeed - { - get { return GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } - } + public virtual PerSecond EngineIdleSpeed => GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); - public virtual RetarderType RetarderType - { - get { return GetString(XMLNames.Vehicle_RetarderType).ParseEnum<RetarderType>(); } - } + + public virtual RetarderType RetarderType => GetString(XMLNames.Vehicle_RetarderType).ParseEnum<RetarderType>(); - public virtual double RetarderRatio - { - get { return GetDouble(XMLNames.Vehicle_RetarderRatio); } - } + public virtual double RetarderRatio => GetDouble(XMLNames.Vehicle_RetarderRatio); - public virtual AngledriveType AngledriveType - { - get { return GetString(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); } - } + + public virtual AngledriveType AngledriveType => GetString(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); - public virtual bool ZeroEmissionVehicle - { - get { return GetBool(XMLNames.Vehicle_ZeroEmissionVehicle); } - } + + public virtual bool ZeroEmissionVehicle => GetBool(XMLNames.Vehicle_ZeroEmissionVehicle); - public virtual XmlElement ADASNode - { - get { return _adasNode ?? (_adasNode = GetNode(XMLNames.Vehicle_ADAS, required: false) as XmlElement); } - } + + public virtual XmlElement ADASNode => _adasNode ?? (_adasNode = GetNode(XMLNames.Vehicle_ADAS, required: false) as XmlElement); public virtual IXMLADASReader ADASReader { get; set; } - public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return _adas ?? (_adas = ADASReader.ADASInputData); } - } + + public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADAS => _adas ?? (_adas = ADASReader.ADASInputData); - public virtual IList<ITorqueLimitInputData> TorqueLimits - { - get { return ReadTorqueLimits(); } - } + public virtual IList<ITorqueLimitInputData> TorqueLimits => ReadTorqueLimits(); public virtual XmlElement ComponentNode { @@ -1191,18 +834,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public virtual Meter EntranceHeight { get; } - public virtual ConsumerTechnology? DoorDriveTechnology - { - get { return ConsumerTechnology.Unknown; } - } + public virtual ConsumerTechnology? DoorDriveTechnology => ConsumerTechnology.Unknown; public virtual VehicleDeclarationType VehicleDeclarationType { get; } - public virtual IVehicleComponentsDeclaration Components - { - get { return _components ?? (_components = ComponentReader.ComponentInputData); } - } + public virtual IVehicleComponentsDeclaration Components => _components ?? (_components = ComponentReader.ComponentInputData); #region Non seeded Properties @@ -1214,10 +851,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public int? NumberPassengersStandingLowerDeck { get; } public int? NumberPassengersStandingUpperDeck { get; } - public CubicMeter CargoVolume - { - get { return 0.SI<CubicMeter>(); } - } + public CubicMeter CargoVolume => 0.SI<CubicMeter>(); public Kilogram CurbMassChassis { get; } public bool VocationalVehicle { get; } public bool SleeperCab { get; } @@ -1232,7 +866,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public RegistrationClass? RegisteredClass { get; } public VehicleCode? VehicleCode { get; } public bool? LowEntry { get; } - public bool Articulated { get { return GetBool(XMLNames.Vehicle_Articulated); } } + public bool Articulated => GetBool(XMLNames.Vehicle_Articulated); public Meter Height { get; } public Meter Length { get; } public Meter Width { get; } @@ -1247,15 +881,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } + protected override DataSourceType SourceType => DataSourceType.XMLFile; #endregion @@ -1337,69 +965,43 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { get { - return ElementExists(new [] {XMLNames.Component_Vehicle, XMLNames.Component_Model}) + if (BaseNode.LocalName == XMLNames.Component_Vehicle) { + return BaseNode.SelectSingleNode($"./*[local-name()='{XMLNames.Component_Model}']")?.InnerText; + } + return ElementExists(new [] { XMLNames.Component_Vehicle, XMLNames.Component_Model}) ? GetString(new[] { XMLNames.Component_Vehicle, XMLNames.Component_Model }) : null; } } - public override LegislativeClass? LegislativeClass - { - get - { - return ElementExists(XMLNames.Bus_LegislativeCategory) - ? GetString(XMLNames.Bus_LegislativeCategory).ParseEnum<LegislativeClass>() - : (LegislativeClass?)null; - } - } - - public override Kilogram CurbMassChassis - { - get - { - return ElementExists(XMLNames.Bus_CorrectedActualMass) - ? GetDouble(XMLNames.Bus_CorrectedActualMass).SI<Kilogram>() - : null; - } - } - - public override Kilogram GrossVehicleMassRating - { - get { - return ElementExists(XMLNames.Vehicle_TPMLM) - ? GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>() - : null; - } - } + public override LegislativeClass? LegislativeClass => + ElementExists(XMLNames.Bus_LegislativeCategory) + ? GetString(XMLNames.Bus_LegislativeCategory).ParseEnum<LegislativeClass>() + : (LegislativeClass?)null; - public override bool? AirdragModifiedMultistage - { - get - { - return ElementExists(XMLNames.Bus_AirdragModifiedMultistage) - ? GetBool(XMLNames.Bus_AirdragModifiedMultistage) - : (bool?)null; - } - } + public override Kilogram CurbMassChassis => + ElementExists(XMLNames.Bus_CorrectedActualMass) + ? GetDouble(XMLNames.Bus_CorrectedActualMass).SI<Kilogram>() + : null; - public override RegistrationClass? RegisteredClass - { - get - { - return ElementExists(XMLNames.Vehicle_RegisteredClass) - ? RegistrationClassHelper.Parse(GetString(XMLNames.Vehicle_RegisteredClass)).First() - : null; - } - } + public override Kilogram GrossVehicleMassRating => + ElementExists(XMLNames.Vehicle_TPMLM) + ? GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>() + : null; - public override TankSystem? TankSystem - { - get - { - return ElementExists(XMLNames.Vehicle_NgTankSystem) - ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) - : (TankSystem?)null; - } - } + public override bool? AirdragModifiedMultistage => + ElementExists(XMLNames.Bus_AirdragModifiedMultistage) + ? GetBool(XMLNames.Bus_AirdragModifiedMultistage) + : (bool?)null; + + public override RegistrationClass? RegisteredClass => + ElementExists(XMLNames.Vehicle_RegisteredClass) + ? RegistrationClassHelper.Parse(GetString(XMLNames.Vehicle_RegisteredClass)).First() + : null; + + public override TankSystem? TankSystem => + ElementExists(XMLNames.Vehicle_NgTankSystem) + ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) + : (TankSystem?)null; public override int? NumberPassengerSeatsLowerDeck @@ -1448,89 +1050,45 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider - public override VehicleCode? VehicleCode - { - get - { - return ElementExists(XMLNames.Vehicle_BodyworkCode) - ? GetString(XMLNames.Vehicle_BodyworkCode).ParseEnum<VehicleCode>() - : (VehicleCode?)null; - } - } + public override VehicleCode? VehicleCode => + ElementExists(XMLNames.Vehicle_BodyworkCode) + ? GetString(XMLNames.Vehicle_BodyworkCode).ParseEnum<VehicleCode>() + : (VehicleCode?)null; - public override bool? LowEntry - { - get - { - return ElementExists(XMLNames.Bus_LowEntry) - ? GetBool(XMLNames.Bus_LowEntry) - : (bool?)null; - } - } + public override bool? LowEntry => + ElementExists(XMLNames.Bus_LowEntry) + ? GetBool(XMLNames.Bus_LowEntry) + : (bool?)null; - public override Meter Height - { - get - { - return ElementExists(XMLNames.Bus_HeighIntegratedBody) - ? GetDouble(XMLNames.Bus_HeighIntegratedBody).SI(Unit.SI.Milli.Meter).Cast<Meter>() - : null; - } - } + public override Meter Height => + ElementExists(XMLNames.Bus_HeighIntegratedBody) + ? GetDouble(XMLNames.Bus_HeighIntegratedBody).SI(Unit.SI.Milli.Meter).Cast<Meter>() + : null; - public override Meter Length - { - get - { - return ElementExists(XMLNames.Bus_VehicleLength) - ? GetDouble(XMLNames.Bus_VehicleLength).SI(Unit.SI.Milli.Meter).Cast<Meter>() - : null; - } - } + public override Meter Length => + ElementExists(XMLNames.Bus_VehicleLength) + ? GetDouble(XMLNames.Bus_VehicleLength).SI(Unit.SI.Milli.Meter).Cast<Meter>() + : null; - public override Meter Width - { - get - { - return ElementExists(XMLNames.Bus_VehicleWidth) - ? GetDouble(XMLNames.Bus_VehicleWidth).SI(Unit.SI.Milli.Meter).Cast<Meter>() - : null; - } - } + public override Meter Width => + ElementExists(XMLNames.Bus_VehicleWidth) + ? GetDouble(XMLNames.Bus_VehicleWidth).SI(Unit.SI.Milli.Meter).Cast<Meter>() + : null; - public override Meter EntranceHeight - { - get - { - return ElementExists(XMLNames.Bus_EntranceHeight) - ? GetDouble(XMLNames.Bus_EntranceHeight).SI(Unit.SI.Milli.Meter).Cast<Meter>() - : null; - } - } + public override Meter EntranceHeight => + ElementExists(XMLNames.Bus_EntranceHeight) + ? GetDouble(XMLNames.Bus_EntranceHeight).SI(Unit.SI.Milli.Meter).Cast<Meter>() + : null; - public override ConsumerTechnology? DoorDriveTechnology - { - get - { - return ElementExists(XMLNames.BusAux_PneumaticSystem_DoorDriveTechnology) - ? ConsumerTechnologyHelper.Parse(GetString(XMLNames.BusAux_PneumaticSystem_DoorDriveTechnology)) - : (ConsumerTechnology?)null; - } - } + public override ConsumerTechnology? DoorDriveTechnology => + ElementExists(XMLNames.BusAux_PneumaticSystem_DoorDriveTechnology) + ? ConsumerTechnologyHelper.Parse(GetString(XMLNames.BusAux_PneumaticSystem_DoorDriveTechnology)) + : (ConsumerTechnology?)null; - public override VehicleDeclarationType VehicleDeclarationType - { - get { return VehicleDeclarationTypeHelper.Parse(GetString(XMLNames.Bus_VehicleDeclarationType)); } - } + public override VehicleDeclarationType VehicleDeclarationType => VehicleDeclarationTypeHelper.Parse(GetString(XMLNames.Bus_VehicleDeclarationType)); - public override XmlElement ADASNode - { - get - { - return _adasNode ?? (_adasNode = GetNode(XMLNames.Vehicle_ADAS, required: false) as XmlElement); - } - } + public override XmlElement ADASNode => _adasNode ?? (_adasNode = GetNode(XMLNames.Vehicle_ADAS, required: false) as XmlElement); public override XmlElement ComponentNode @@ -1574,26 +1132,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public override XmlElement PTONode - { - get { return null; } - } + public override XmlElement PTONode => null; + #region Overrides of AbstractXMLResource + protected override DataSourceType SourceType => DataSourceType.XMLFile; - #region Overrides of AbstractXMLResource + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } - - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } - #endregion } @@ -1612,54 +1159,29 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider : base(jobData, xmlNode, sourceFile) {} - public override string Model - { - get - { - return ElementExists(XMLNames.Component_Model) - ? GetString(XMLNames.Component_Model) : null; - } - } + public override string Model => + ElementExists(XMLNames.Component_Model) + ? GetString(XMLNames.Component_Model) : null; - public override LegislativeClass? LegislativeClass - { - get - { - return ElementExists(XMLNames.Bus_LegislativeCategory) - ? GetString(XMLNames.Bus_LegislativeCategory).ParseEnum<LegislativeClass>() - : (LegislativeClass?)null; - } - } + public override LegislativeClass? LegislativeClass => + ElementExists(XMLNames.Bus_LegislativeCategory) + ? GetString(XMLNames.Bus_LegislativeCategory).ParseEnum<LegislativeClass>() + : (LegislativeClass?)null; - public override Kilogram CurbMassChassis - { - get - { - return ElementExists(XMLNames.Bus_CorrectedActualMass) - ? GetDouble(XMLNames.Bus_CorrectedActualMass).SI<Kilogram>() - : null; - } - } + public override Kilogram CurbMassChassis => + ElementExists(XMLNames.Bus_CorrectedActualMass) + ? GetDouble(XMLNames.Bus_CorrectedActualMass).SI<Kilogram>() + : null; - public override Kilogram GrossVehicleMassRating - { - get - { - return ElementExists(XMLNames.Vehicle_TPMLM) - ? GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>() - : null; - } - } - - public override RegistrationClass? RegisteredClass - { - get - { - return ElementExists(XMLNames.Vehicle_RegisteredClass) - ? RegistrationClassHelper.Parse(GetString(XMLNames.Vehicle_RegisteredClass)).First() - : null; - } - } + public override Kilogram GrossVehicleMassRating => + ElementExists(XMLNames.Vehicle_TPMLM) + ? GetDouble(XMLNames.Vehicle_TPMLM).SI<Kilogram>() + : null; + + public override RegistrationClass? RegisteredClass => + ElementExists(XMLNames.Vehicle_RegisteredClass) + ? RegistrationClassHelper.Parse(GetString(XMLNames.Vehicle_RegisteredClass)).First() + : null; public override int? NumberPassengerSeatsLowerDeck { @@ -1683,68 +1205,35 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public override VehicleCode? VehicleCode - { - get - { - return ElementExists(XMLNames.Vehicle_BodyworkCode) - ? GetString(XMLNames.Vehicle_BodyworkCode).ParseEnum<VehicleCode>() - : (VehicleCode?)null; - } - } + public override VehicleCode? VehicleCode => + ElementExists(XMLNames.Vehicle_BodyworkCode) + ? GetString(XMLNames.Vehicle_BodyworkCode).ParseEnum<VehicleCode>() + : (VehicleCode?)null; - public override bool? LowEntry - { - get - { - return ElementExists(XMLNames.Bus_LowEntry) - ? GetBool(XMLNames.Bus_LowEntry) - : (bool?)null; - } - } + public override bool? LowEntry => + ElementExists(XMLNames.Bus_LowEntry) + ? GetBool(XMLNames.Bus_LowEntry) + : (bool?)null; - public override Meter Height - { - get - { - return ElementExists(XMLNames.Bus_HeighIntegratedBody) - ? GetDouble(XMLNames.Bus_HeighIntegratedBody).SI(Unit.SI.Milli.Meter).Cast<Meter>() - : null; - } - } - - public override XmlElement PTONode - { - get { return null; } - } + public override Meter Height => + ElementExists(XMLNames.Bus_HeighIntegratedBody) + ? GetDouble(XMLNames.Bus_HeighIntegratedBody).SI(Unit.SI.Milli.Meter).Cast<Meter>() + : null; - public override XmlElement ComponentNode - { - get{ return null; } - } + public override XmlElement PTONode => null; - public override IVehicleComponentsDeclaration Components - { - get { return null; } - } + public override XmlElement ComponentNode => null; - public override bool ExemptedVehicle - { - get { return true; } - } + public override IVehicleComponentsDeclaration Components => null; + - #region Overrides of AbstractXMLResource + public override bool ExemptedVehicle => true; - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + #region Overrides of AbstractXMLResource - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; + protected override DataSourceType SourceType => DataSourceType.XMLFile; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs index 6a13d75d4bc3e7ad2faaf9597ad82006eaf8bad0..44a39085ca37faef4c22000be90398cc123d6091 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs @@ -54,33 +54,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public virtual string SourceFile { get; } - public virtual DataSource DataSource - { - get { - return _dataSource ?? (_dataSource = new DataSource() { - SourceFile = SourceFile, - SourceType = DataSourceType.XMLEmbedded, - SourceVersion = XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace) - }); - } - } + public virtual DataSource DataSource => + _dataSource ?? (_dataSource = new DataSource() { + SourceFile = SourceFile, + SourceType = DataSourceType.XMLEmbedded, + SourceVersion = XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace) + }); protected abstract XNamespace SchemaNamespace { get; } #region Implementation of ITransmissionInputData - public virtual int Gear - { - get { - return XmlConvert.ToUInt16( - BaseNode.Attributes?.GetNamedItem(XMLNames.Gearbox_Gear_GearNumber_Attr).InnerText ?? "0"); - } - } + public virtual int Gear => + XmlConvert.ToUInt16( + BaseNode.Attributes?.GetNamedItem(XMLNames.Gearbox_Gear_GearNumber_Attr).InnerText ?? "0"); - public virtual double Ratio - { - get { return GetString(XMLNames.Gearbox_Gear_Ratio).ToDouble(double.NaN); } - } + public virtual double Ratio => GetString(XMLNames.Gearbox_Gear_Ratio).ToDouble(double.NaN); public virtual TableData LossMap { @@ -91,25 +80,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual double Efficiency - { - get { return double.NaN; } - } + public virtual double Efficiency => double.NaN; - public virtual NewtonMeter MaxTorque - { - get { return GetNode(XMLNames.Gearbox_Gears_MaxTorque, required: false)?.InnerText.ToDouble().SI<NewtonMeter>(); } - } + public virtual NewtonMeter MaxTorque => GetNode(XMLNames.Gearbox_Gears_MaxTorque, required: false)?.InnerText.ToDouble().SI<NewtonMeter>(); - public virtual PerSecond MaxInputSpeed - { - get { return GetNode(XMLNames.Gearbox_Gear_MaxSpeed, required: false)?.InnerText.ToDouble().RPMtoRad(); } - } + public virtual PerSecond MaxInputSpeed => GetNode(XMLNames.Gearbox_Gear_MaxSpeed, required: false)?.InnerText.ToDouble().RPMtoRad(); - public virtual TableData ShiftPolygon - { - get { return null; } - } + public virtual TableData ShiftPolygon => null; #endregion } @@ -128,10 +105,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Overrides of XMLAbstractGearData - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } @@ -149,10 +123,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLGearDataV20(XmlNode gearNode, string sourceFile) : base(gearNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } @@ -169,10 +140,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLMultistagePrimaryVehicleBusTransmissionDataV01(XmlNode gearNode, string sourceFile) : base(gearNode, sourceFile) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataMultistageV01InjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataMultistageV01InjectModule.cs index aabae6c80c9e0cf060286df8a7516d4aea16478a..8f61766998e747ae0ca2b542dbf3a8f650fe4b6e 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataMultistageV01InjectModule.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataMultistageV01InjectModule.cs @@ -39,10 +39,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules Bind<IXMLPrimaryVehicleBusJobInputData>().To<XMLDeclarationMultistagePrimaryVehicleBusJobInputDataProviderV01>() .Named(XMLDeclarationMultistagePrimaryVehicleBusJobInputDataProviderV01.QUALIFIED_XSD_TYPE); - Bind<IXMLPrimaryVehicleBusJobInputData>().To<XMLDeclarationMultistageExemptedPrimaryVehicleBusJobInputDataProviderV01>() - .Named(XMLDeclarationMultistageExemptedPrimaryVehicleBusJobInputDataProviderV01.QUALIFIED_XSD_TYPE); + Bind<IXMLPrimaryVehicleBusJobInputData>().To<XMLDeclarationMultistageExemptedPrimaryVehicleBusJobInputDataProviderV01>() + .Named(XMLDeclarationMultistageExemptedPrimaryVehicleBusJobInputDataProviderV01.QUALIFIED_XSD_TYPE); - Bind<IXMLJobDataReader>().To<XMLJobDataMultistagePrimaryVehicleReaderV01>() + Bind<IXMLJobDataReader>().To<XMLJobDataMultistagePrimaryVehicleReaderV01>() .Named(XMLJobDataMultistagePrimaryVehicleReaderV01.QUALIFIED_XSD_TYPE); Bind<IXMLJobDataReader>().To<XMLJobDataMultistageExemptedPrimaryVehicleReaderV01>() diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs index e7e044d77d1ba68ac76e3c04339edd1f924ae77d..16c5fdc36b9dc5ca1e97b79cbbc6549ada8cf8a9 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl ? BaseNode : BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(component)); var dataNode = - componentNode?.SelectSingleNode(string.Format("./*[local-name()='{0}']", XMLNames.ComponentDataWrapper)); + componentNode?.SelectSingleNode($"./*[local-name()='{XMLNames.ComponentDataWrapper}']"); if (componentNode != null) { var type = (dataNode ?? componentNode).SchemaInfo.SchemaType; var version = XMLHelper.GetXsdType(type); diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs index 614537eb1166b186488a91af28e15aa49a5b0f2b..056042ee81e2209d64c64081500ec5059b83a58a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs @@ -63,10 +63,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl #region Implementation of IXMLADASReader - public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADASInputData - { - get { return _adas ?? (_adas = CreateComponent(XMLNames.Vehicle_ADAS, ADASCreator)); } - } + public virtual IAdvancedDriverAssistantSystemDeclarationInputData ADASInputData => _adas ?? (_adas = CreateComponent(XMLNames.Vehicle_ADAS, ADASCreator)); #endregion @@ -79,10 +76,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl return Factory.CreateADASData(version, Vehicle, componentNode, sourceFile); } - public virtual XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + public virtual XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -99,15 +93,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public XMLADASReaderV20(IXMLDeclarationVehicleData vehicle, XmlNode vehicleNode) : base( vehicle, vehicleNode) { } - public override IAdvancedDriverAssistantSystemDeclarationInputData ADASInputData - { - get { return _adas ?? (_adas = CreateComponent(XMLNames.Vehicle_ADAS, ADASCreator, true)); } - } + public override IAdvancedDriverAssistantSystemDeclarationInputData ADASInputData => _adas ?? (_adas = CreateComponent(XMLNames.Vehicle_ADAS, ADASCreator, true)); - public override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + public override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -123,10 +111,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public XMLADASReaderV21(IXMLDeclarationVehicleData vehicle, XmlNode vehicleNode) : base( vehicle, vehicleNode) { } - public override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + public override XNamespace SchemaNamespace => NAMESPACE_URI; } // --------------------------------------------------------------------------------------- @@ -143,9 +128,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl vehicle, vehicleNode) { } - public override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + public override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs index d7c7189f171db6b35ded6ffc9f5acd5ab976c902..a533e17847522120fbc05311db4ad8e9d45b6b33 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs @@ -91,26 +91,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl #region Implementation of IXMLComponentReader - public virtual IVehicleComponentsDeclaration ComponentInputData - { - get { return _components ?? (_components = CreateComponent(XMLNames.Vehicle_Components, ComponentsCreator)); } - } + public virtual IVehicleComponentsDeclaration ComponentInputData => _components ?? (_components = CreateComponent(XMLNames.Vehicle_Components, ComponentsCreator)); - public virtual IAirdragDeclarationInputData AirdragInputData - { - get - { - return _airdragInputData ?? (_airdragInputData = CreateComponent(XMLNames.Component_AirDrag, AirdragCreator, true)); - } - } + public virtual IAirdragDeclarationInputData AirdragInputData => _airdragInputData ?? (_airdragInputData = CreateComponent(XMLNames.Component_AirDrag, AirdragCreator, true)); - public virtual IGearboxDeclarationInputData GearboxInputData - { - get - { - return _gearboxInputData ?? (_gearboxInputData = CreateComponent(XMLNames.Component_Gearbox, GearboxCreator)); - } - } + public virtual IGearboxDeclarationInputData GearboxInputData => _gearboxInputData ?? (_gearboxInputData = CreateComponent(XMLNames.Component_Gearbox, GearboxCreator)); public virtual ITorqueConverterDeclarationInputData TorqueConverterInputData { @@ -125,7 +110,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl } } - public virtual IBusAuxiliariesDeclarationData BusAuxiliariesInputData { get { return null; } } + public virtual IBusAuxiliariesDeclarationData BusAuxiliariesInputData => null; public virtual ITransmissionInputData CreateGear(XmlNode gearNode) { @@ -173,62 +158,29 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl } - public virtual IAxleGearInputData AxleGearInputData - { - get - { - return _axlegearInputData ?? (_axlegearInputData = CreateComponent(XMLNames.Component_Axlegear, AxlegearCreator)); - } - } + public virtual IAxleGearInputData AxleGearInputData => _axlegearInputData ?? (_axlegearInputData = CreateComponent(XMLNames.Component_Axlegear, AxlegearCreator)); - public virtual IAngledriveInputData AngledriveInputData - { - get - { - return _angledriveInputData ?? - (_angledriveInputData = CreateComponent(XMLNames.Component_Angledrive, AngledriveCreator, true)); - } - } + public virtual IAngledriveInputData AngledriveInputData => + _angledriveInputData ?? + (_angledriveInputData = CreateComponent(XMLNames.Component_Angledrive, AngledriveCreator, true)); - public virtual IEngineDeclarationInputData EngineInputData - { - get { return _engineInputData ?? (_engineInputData = CreateComponent(XMLNames.Component_Engine, EngineCreator)); } - } + public virtual IEngineDeclarationInputData EngineInputData => _engineInputData ?? (_engineInputData = CreateComponent(XMLNames.Component_Engine, EngineCreator)); - public virtual IAuxiliariesDeclarationInputData AuxiliaryData - { - get - { - return _auxiliaryInputData ?? - (_auxiliaryInputData = CreateComponent(XMLNames.Component_Auxiliaries, AuxiliaryCreator)); - } - } + public virtual IAuxiliariesDeclarationInputData AuxiliaryData => + _auxiliaryInputData ?? + (_auxiliaryInputData = CreateComponent(XMLNames.Component_Auxiliaries, AuxiliaryCreator)); - public virtual IRetarderInputData RetarderInputData - { - get - { - return _retarderInputData ?? - (_retarderInputData = CreateComponent(XMLNames.Component_Retarder, RetarderCreator, true)); - } - } + public virtual IRetarderInputData RetarderInputData => + _retarderInputData ?? + (_retarderInputData = CreateComponent(XMLNames.Component_Retarder, RetarderCreator, true)); - public virtual IAxlesDeclarationInputData AxlesDeclarationInputData - { - get - { - return _axlesInputData ?? (_axlesInputData = CreateComponent(XMLNames.Component_AxleWheels, AxleWheelsCreator)); - } - } + public virtual IAxlesDeclarationInputData AxlesDeclarationInputData => _axlesInputData ?? (_axlesInputData = CreateComponent(XMLNames.Component_AxleWheels, AxleWheelsCreator)); - public virtual ITyreDeclarationInputData Tyre - { - get { return CreateComponent(XMLNames.AxleWheels_Axles_Axle_Tyre, TyreCreator); } - } + public virtual ITyreDeclarationInputData Tyre => CreateComponent(XMLNames.AxleWheels_Axles_Axle_Tyre, TyreCreator); #endregion @@ -384,7 +336,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl vehicle, componentsNode) { } - public override IBusAuxiliariesDeclarationData BusAuxiliariesInputData { get { return _busAuxInputData ?? (_busAuxInputData = CreateComponent(XMLNames.Component_Auxiliaries, BusAuxCreator)); } } + public override IBusAuxiliariesDeclarationData BusAuxiliariesInputData => _busAuxInputData ?? (_busAuxInputData = CreateComponent(XMLNames.Component_Auxiliaries, BusAuxCreator)); protected virtual IBusAuxiliariesDeclarationData BusAuxCreator(string version, XmlNode componentNode, string sourceFile) { @@ -411,33 +363,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public XMLMultistagePrimaryVehicleBusComponentReaderV01(IXMLDeclarationVehicleData vehicle, XmlNode componentsNode) : base(vehicle, componentsNode) { } - public override IGearboxDeclarationInputData GearboxInputData - { - get - { - return _gearboxInputData ?? (_gearboxInputData = CreateComponent(XMLNames.Component_Transmission, GearboxCreator)); - } - } + public override IGearboxDeclarationInputData GearboxInputData => _gearboxInputData ?? (_gearboxInputData = CreateComponent(XMLNames.Component_Transmission, GearboxCreator)); - public override IRetarderInputData RetarderInputData - { - get { return null; } - } + public override IRetarderInputData RetarderInputData => null; - public override IAirdragDeclarationInputData AirdragInputData - { - get { return null; } - } + public override IAirdragDeclarationInputData AirdragInputData => null; - public override IAuxiliariesDeclarationInputData AuxiliaryData - { - get { return null; } - } + public override IAuxiliariesDeclarationInputData AuxiliaryData => null; - public override IBusAuxiliariesDeclarationData BusAuxiliariesInputData - { - get { return _busAuxInputData ?? (_busAuxInputData = CreateComponent(XMLNames.Component_Auxiliaries, BusAuxCreator)); } - } + public override IBusAuxiliariesDeclarationData BusAuxiliariesInputData => _busAuxInputData ?? (_busAuxInputData = CreateComponent(XMLNames.Component_Auxiliaries, BusAuxCreator)); protected virtual IBusAuxiliariesDeclarationData BusAuxCreator(string version, XmlNode componentNode, string sourceFile) { @@ -463,7 +397,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl #region Overrides of XMLComponentReaderV10 - public override IAxleGearInputData AxleGearInputData { get { return null; } } + public override IAxleGearInputData AxleGearInputData => null; #endregion } @@ -506,64 +440,29 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl } - public override IAngledriveInputData AngledriveInputData - { - get { return null; } - } + public override IAngledriveInputData AngledriveInputData => null; - public override IAxleGearInputData AxleGearInputData - { - get { return null; } - } + public override IAxleGearInputData AxleGearInputData => null; - public override IAxlesDeclarationInputData AxlesDeclarationInputData - { - get { return null; } - } + public override IAxlesDeclarationInputData AxlesDeclarationInputData => null; - public override IEngineDeclarationInputData EngineInputData - { - get { return null; } - } + public override IEngineDeclarationInputData EngineInputData => null; - public override IGearboxDeclarationInputData GearboxInputData - { - get { return null; } - } + public override IGearboxDeclarationInputData GearboxInputData => null; - public override ITorqueConverterDeclarationInputData TorqueConverterInputData - { - get { return null; } - } + public override ITorqueConverterDeclarationInputData TorqueConverterInputData => null; - public override ITyreDeclarationInputData Tyre - { - get { return null; } - } + public override ITyreDeclarationInputData Tyre => null; - public override IRetarderInputData RetarderInputData - { - get { return null; } - } + public override IRetarderInputData RetarderInputData => null; - public override IAuxiliariesDeclarationInputData AuxiliaryData - { - get { return null; } - } + public override IAuxiliariesDeclarationInputData AuxiliaryData => null; - public override IAirdragDeclarationInputData AirdragInputData - { - get - { - return _airdragInputData ?? - (_airdragInputData = CreateComponent(XMLNames.Component_AirDrag, AirdragCreator)); - } - } - - public override IBusAuxiliariesDeclarationData BusAuxiliariesInputData - { - get { return _busAuxInputData ?? (_busAuxInputData = CreateComponent(XMLNames.Component_Auxiliaries, BusAuxCreator)); } - } + public override IAirdragDeclarationInputData AirdragInputData => + _airdragInputData ?? + (_airdragInputData = CreateComponent(XMLNames.Component_AirDrag, AirdragCreator)); + + public override IBusAuxiliariesDeclarationData BusAuxiliariesInputData => _busAuxInputData ?? (_busAuxInputData = CreateComponent(XMLNames.Component_Auxiliaries, BusAuxCreator)); protected virtual IBusAuxiliariesDeclarationData BusAuxCreator(string version, XmlNode componentNode, string sourceFile) { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationInputReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationInputReader.cs index 83f3379d34e424ef3c58988674c44da604027275..53508442353bedc68f3195a79a155685bf28601b 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationInputReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationInputReader.cs @@ -65,10 +65,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl #region Implementation of IXMLDeclarationInputReader - public virtual IDeclarationJobInputData JobData - { - get { return _jobData ?? (_jobData = CreateComponent(XMLNames.VectoInputDeclaration, JobCreator)); } - } + public virtual IDeclarationJobInputData JobData => _jobData ?? (_jobData = CreateComponent(XMLNames.VectoInputDeclaration, JobCreator)); #endregion diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs index 68273594630a18422c8763604bd4454567422158..0e64957144fe4821fc70761f291b12e5c37f622a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs @@ -43,10 +43,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl InputData = inputData; } - public IDeclarationMultistageJobInputData JobData - { - get { return _jobData ?? (_jobData = CreateComponent(XMLNames.VectoOutputMultistage, JobCreator)); } - } + public IDeclarationMultistageJobInputData JobData => _jobData ?? (_jobData = CreateComponent(XMLNames.VectoOutputMultistage, JobCreator)); protected virtual IDeclarationMultistageJobInputData JobCreator(string version, XmlNode node, string arg3) { @@ -86,10 +83,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl SetManufacturingStageNodes(); } - public IPrimaryVehicleInformationInputDataProvider PrimaryVehicle - { - get { return _primaryVehicle ?? (_primaryVehicle = CreateComponent(XMLNames.Bus_PrimaryVehicle, PrimaryVehicleCreator)); } - } + public IPrimaryVehicleInformationInputDataProvider PrimaryVehicle => _primaryVehicle ?? (_primaryVehicle = CreateComponent(XMLNames.Bus_PrimaryVehicle, PrimaryVehicleCreator)); protected IPrimaryVehicleInformationInputDataProvider PrimaryVehicleCreator(string version, XmlNode node, string arg3) @@ -141,10 +135,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl } } - public VectoSimulationJobType JobType - { - get { return InputData.JobType; } - } + public VectoSimulationJobType JobType => InputData.JobType; public bool InputComplete { @@ -198,10 +189,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl _multistageData = multistageData; } - public IVehicleDeclarationInputData Vehicle - { - get { return _vehicle ?? (_vehicle = CreateComponent(XMLNames.Tag_Vehicle, VehicleCreator)); } - } + public IVehicleDeclarationInputData Vehicle => _vehicle ?? (_vehicle = CreateComponent(XMLNames.Tag_Vehicle, VehicleCreator)); private IVehicleDeclarationInputData VehicleCreator(string version, XmlNode node, string arg3) { @@ -216,14 +204,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl return vehicle; } - public IApplicationInformation ApplicationInformation - { - get - { - return _applicationInformation ?? - (_applicationInformation = CreateComponent(XMLNames.Tag_ApplicationInformation, ApplicationCreator)); - } - } + public IApplicationInformation ApplicationInformation => + _applicationInformation ?? + (_applicationInformation = CreateComponent(XMLNames.Tag_ApplicationInformation, ApplicationCreator)); protected IApplicationInformation ApplicationCreator(string version, XmlNode node, string agr3) { @@ -264,13 +247,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl _primaryInputData = inputData; } - public virtual IDeclarationJobInputData JobData - { - get - { - return _jobData ?? (_jobData = CreateComponent(XMLNames.Tag_Vehicle, JobCreator)); - } - } + public virtual IDeclarationJobInputData JobData => _jobData ?? (_jobData = CreateComponent(XMLNames.Tag_Vehicle, JobCreator)); protected IDeclarationJobInputData JobCreator(string version, XmlNode node, string arg3) @@ -281,14 +258,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl return job; } - public IResultsInputData ResultsInputData - { - get - { - return _resultsInputData ?? - (_resultsInputData = CreateComponent(XMLNames.Report_Results, ResultsInputDataCreator)); - } - } + public IResultsInputData ResultsInputData => + _resultsInputData ?? + (_resultsInputData = CreateComponent(XMLNames.Report_Results, ResultsInputDataCreator)); protected IResultsInputData ResultsInputDataCreator(string version, XmlNode node, string arg3) { @@ -305,14 +277,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl return Factory.CreateApplicationInformationReader(version, node); } - public IApplicationInformation ApplicationInformation - { - get - { - return _applicationInformation ?? - (_applicationInformation = CreateComponent(XMLNames.Tag_ApplicationInformation, ApplicationCreator)); - } - } + public IApplicationInformation ApplicationInformation => + _applicationInformation ?? + (_applicationInformation = CreateComponent(XMLNames.Tag_ApplicationInformation, ApplicationCreator)); } // --------------------------------------------------------------------------------------- @@ -390,30 +357,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl _primaryVehicle = primaryVehicle; } - public DigestData HashPreviousStage - { - get { return _manufacturingStages.First().HashPreviousStage; } - } + public DigestData HashPreviousStage => _manufacturingStages.First().HashPreviousStage; - public int StageCount - { - get { return _manufacturingStages.First().StageCount; } - } + public int StageCount => _manufacturingStages.First().StageCount; - public IVehicleDeclarationInputData Vehicle - { - get { return GetConsolidatedVehicleData(); } - } + public IVehicleDeclarationInputData Vehicle => GetConsolidatedVehicleData(); - public IApplicationInformation ApplicationInformation - { - get { return _manufacturingStages.First().ApplicationInformation; } - } + public IApplicationInformation ApplicationInformation => _manufacturingStages.First().ApplicationInformation; - public DigestData Signature - { - get { return _manufacturingStages.First().Signature; } - } + public DigestData Signature => _manufacturingStages.First().Signature; public override bool IsInputDataComplete(VectoSimulationJobType jobType) { @@ -449,137 +401,58 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl #region ManufacturingStage mandatory properties - public string Manufacturer - { - get { return _manufacturingStages.First().Vehicle.Manufacturer; } - } + public string Manufacturer => _manufacturingStages.First().Vehicle.Manufacturer; - public string ManufacturerAddress - { - get { return _manufacturingStages.First().Vehicle.ManufacturerAddress; } - } - - public DateTime Date - { - get { return _manufacturingStages.First().Vehicle.Date; } - } + public string ManufacturerAddress => _manufacturingStages.First().Vehicle.ManufacturerAddress; - public string VIN - { - get { return _manufacturingStages.First().Vehicle.VIN; } - } + public DateTime Date => _manufacturingStages.First().Vehicle.Date; - public VehicleDeclarationType VehicleDeclarationType - { - get { return _manufacturingStages.First().Vehicle.VehicleDeclarationType; } - } + public string VIN => _manufacturingStages.First().Vehicle.VIN; + + public VehicleDeclarationType VehicleDeclarationType => _manufacturingStages.First().Vehicle.VehicleDeclarationType; #endregion #region ManufacturingStage optional properties - public string Model - { - get { return GetVehiclePropertyValue<string>(nameof(Model)); } - } + public string Model => GetVehiclePropertyValue<string>(nameof(Model)); - public LegislativeClass? LegislativeClass - { - get { return GetVehiclePropertyValue<LegislativeClass?>(nameof(LegislativeClass)); } - } + public LegislativeClass? LegislativeClass => GetVehiclePropertyValue<LegislativeClass?>(nameof(LegislativeClass)); - public Kilogram CurbMassChassis - { - get { return GetVehiclePropertyValue<Kilogram>(nameof(CurbMassChassis)); } - } + public Kilogram CurbMassChassis => GetVehiclePropertyValue<Kilogram>(nameof(CurbMassChassis)); - public Kilogram GrossVehicleMassRating - { - get - { - return GetVehiclePropertyValue<Kilogram>(nameof(GrossVehicleMassRating)); - } - } - - public bool? AirdragModifiedMultistage - { - get - { - return GetVehiclePropertyValue<bool?>(nameof(AirdragModifiedMultistage)); - } - } + public Kilogram GrossVehicleMassRating => GetVehiclePropertyValue<Kilogram>(nameof(GrossVehicleMassRating)); - public TankSystem? TankSystem - { - get { return GetVehiclePropertyValue<TankSystem?>(nameof(TankSystem)); } - } + public bool? AirdragModifiedMultistage => GetVehiclePropertyValue<bool?>(nameof(AirdragModifiedMultistage)); - public RegistrationClass? RegisteredClass - { - get { return GetVehiclePropertyValue<RegistrationClass?>(nameof(RegisteredClass)); } - } + public TankSystem? TankSystem => GetVehiclePropertyValue<TankSystem?>(nameof(TankSystem)); + public RegistrationClass? RegisteredClass => GetVehiclePropertyValue<RegistrationClass?>(nameof(RegisteredClass)); - public int? NumberPassengerSeatsUpperDeck - { - get { return GetVehiclePropertyValue<int?>(nameof(NumberPassengerSeatsUpperDeck)); } - } - public int? NumberPassengerSeatsLowerDeck - { - get { return GetVehiclePropertyValue<int?>(nameof(NumberPassengerSeatsLowerDeck)); } - } + public int? NumberPassengerSeatsUpperDeck => GetVehiclePropertyValue<int?>(nameof(NumberPassengerSeatsUpperDeck)); - public int? NumberPassengersStandingLowerDeck - { - get { return GetVehiclePropertyValue<int?>(nameof(NumberPassengersStandingLowerDeck)); } - } + public int? NumberPassengerSeatsLowerDeck => GetVehiclePropertyValue<int?>(nameof(NumberPassengerSeatsLowerDeck)); - public int? NumberPassengersStandingUpperDeck - { - get { return GetVehiclePropertyValue<int?>(nameof(NumberPassengersStandingUpperDeck)); } - } + public int? NumberPassengersStandingLowerDeck => GetVehiclePropertyValue<int?>(nameof(NumberPassengersStandingLowerDeck)); - public VehicleCode? VehicleCode - { - get { return GetVehiclePropertyValue<VehicleCode?>(nameof(VehicleCode)); } - } + public int? NumberPassengersStandingUpperDeck => GetVehiclePropertyValue<int?>(nameof(NumberPassengersStandingUpperDeck)); - public bool? LowEntry - { - get { return GetVehiclePropertyValue<bool?>(nameof(LowEntry)); } - } + public VehicleCode? VehicleCode => GetVehiclePropertyValue<VehicleCode?>(nameof(VehicleCode)); - public Meter Height - { - get { return GetVehiclePropertyValue<Meter>(nameof(Height)); } - } + public bool? LowEntry => GetVehiclePropertyValue<bool?>(nameof(LowEntry)); - public Meter Length - { - get { return GetVehiclePropertyValue<Meter>(nameof(Length)); } - } + public Meter Height => GetVehiclePropertyValue<Meter>(nameof(Height)); - public Meter Width - { - get { return GetVehiclePropertyValue<Meter>(nameof(Width)); } - } + public Meter Length => GetVehiclePropertyValue<Meter>(nameof(Length)); - public Meter EntranceHeight - { - get { return GetVehiclePropertyValue<Meter>(nameof(EntranceHeight)); } - } + public Meter Width => GetVehiclePropertyValue<Meter>(nameof(Width)); - public ConsumerTechnology? DoorDriveTechnology - { - get { return GetVehiclePropertyValue<ConsumerTechnology?>(nameof(DoorDriveTechnology)); } + public Meter EntranceHeight => GetVehiclePropertyValue<Meter>(nameof(EntranceHeight)); - } + public ConsumerTechnology? DoorDriveTechnology => GetVehiclePropertyValue<ConsumerTechnology?>(nameof(DoorDriveTechnology)); - public IAdvancedDriverAssistantSystemDeclarationInputData ADAS - { - get { return GetADAS(); } - } + public IAdvancedDriverAssistantSystemDeclarationInputData ADAS => GetADAS(); private IAdvancedDriverAssistantSystemDeclarationInputData GetADAS() { @@ -591,10 +464,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl } - public IVehicleComponentsDeclaration Components - { - get { return GetComponents(); } - } + public IVehicleComponentsDeclaration Components => GetComponents(); private IVehicleComponentsDeclaration GetComponents() { @@ -749,25 +619,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public ConsolidatedADASData(IEnumerable<IManufacturingStageInputData> manufacturingStages) : base(manufacturingStages) { } - public bool EngineStopStart - { - get { return GetADASPropertyValue<bool>(nameof(EngineStopStart)); } - } + public bool EngineStopStart => GetADASPropertyValue<bool>(nameof(EngineStopStart)); - public EcoRollType EcoRoll - { - get { return GetADASPropertyValue<EcoRollType>(nameof(EcoRoll)); } - } + public EcoRollType EcoRoll => GetADASPropertyValue<EcoRollType>(nameof(EcoRoll)); - public PredictiveCruiseControlType PredictiveCruiseControl - { - get { return GetADASPropertyValue<PredictiveCruiseControlType>(nameof(PredictiveCruiseControl)); } - } + public PredictiveCruiseControlType PredictiveCruiseControl => GetADASPropertyValue<PredictiveCruiseControlType>(nameof(PredictiveCruiseControl)); - public bool? ATEcoRollReleaseLockupClutch - { - get { return GetADASPropertyValue<bool?>(nameof(ATEcoRollReleaseLockupClutch)); } - } + public bool? ATEcoRollReleaseLockupClutch => GetADASPropertyValue<bool?>(nameof(ATEcoRollReleaseLockupClutch)); public XmlNode XMLSource { get; } @@ -808,10 +666,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl : base(manufacturingStages) { } - public IAirdragDeclarationInputData AirdragInputData - { - get { return GetAirdragInputData(); } - } + public IAirdragDeclarationInputData AirdragInputData => GetAirdragInputData(); private IAirdragDeclarationInputData GetAirdragInputData() { @@ -822,47 +677,25 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl (_consolidateAirdragData = new ConsolidatedAirdragData(_manufacturingStages)); } - public IGearboxDeclarationInputData GearboxInputData - { - get { return null; } - } - public ITorqueConverterDeclarationInputData TorqueConverterInputData - { - get { return null; } - } - public IAxleGearInputData AxleGearInputData - { - get { return null; } - } - public IAngledriveInputData AngledriveInputData - { - get { return null; } - } - public IEngineDeclarationInputData EngineInputData - { - get { return null; } - } - public IAuxiliariesDeclarationInputData AuxiliaryInputData - { - get { return null; } - } - public IRetarderInputData RetarderInputData - { - get { return null; } - } - public IPTOTransmissionInputData PTOTransmissionInputData - { - get { return null; } - } - public IAxlesDeclarationInputData AxleWheels - { - get { return null; } - } - - public IBusAuxiliariesDeclarationData BusAuxiliaries - { - get { return GetBusAuxiliaries(); } - } + public IGearboxDeclarationInputData GearboxInputData => null; + + public ITorqueConverterDeclarationInputData TorqueConverterInputData => null; + + public IAxleGearInputData AxleGearInputData => null; + + public IAngledriveInputData AngledriveInputData => null; + + public IEngineDeclarationInputData EngineInputData => null; + + public IAuxiliariesDeclarationInputData AuxiliaryInputData => null; + + public IRetarderInputData RetarderInputData => null; + + public IPTOTransmissionInputData PTOTransmissionInputData => null; + + public IAxlesDeclarationInputData AxleWheels => null; + + public IBusAuxiliariesDeclarationData BusAuxiliaries => GetBusAuxiliaries(); private IBusAuxiliariesDeclarationData GetBusAuxiliaries() { @@ -874,14 +707,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl } - public IElectricStorageDeclarationInputData ElectricStorage - { - get { return null; } - } - public IElectricMachinesDeclarationInputData ElectricMachines - { - get { return null; } - } + public IElectricStorageDeclarationInputData ElectricStorage => null; + + public IElectricMachinesDeclarationInputData ElectricMachines => null; private T GetComponentPropertyValue<T>(string propertyName) { @@ -935,56 +763,27 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl SetLastValidAirdragEntry(); } - public string Manufacturer - { - get { return AirdragEntry?.Manufacturer; } - } + public string Manufacturer => AirdragEntry?.Manufacturer; - public string Model - { - get { return AirdragEntry?.Model; } - } + public string Model => AirdragEntry?.Model; - public DateTime Date - { - get { return AirdragEntry.Date; } - } + public DateTime Date => AirdragEntry.Date; - public string AppVersion - { - get { return AirdragEntry?.AppVersion; } - } - public CertificationMethod CertificationMethod - { - get { return AirdragEntry.CertificationMethod; } - } - public string CertificationNumber - { - get { return AirdragEntry?.CertificationNumber; } - } - public DigestData DigestValue - { - get { return AirdragEntry?.DigestValue; } - } - public SquareMeter AirDragArea - { - get { return AirdragEntry?.AirDragArea; } - } + public string AppVersion => AirdragEntry?.AppVersion; - public SquareMeter TransferredAirDragArea - { - get { return AirdragEntry?.TransferredAirDragArea; } - } + public CertificationMethod CertificationMethod => AirdragEntry.CertificationMethod; - public SquareMeter AirDragArea_0 - { - get { return AirdragEntry.AirDragArea_0; } - } + public string CertificationNumber => AirdragEntry?.CertificationNumber; - public DataSource DataSource - { - get { return AirdragEntry?.DataSource; } - } + public DigestData DigestValue => AirdragEntry?.DigestValue; + + public SquareMeter AirDragArea => AirdragEntry?.AirDragArea; + + public SquareMeter TransferredAirDragArea => AirdragEntry?.TransferredAirDragArea; + + public SquareMeter AirDragArea_0 => AirdragEntry.AirDragArea_0; + + public DataSource DataSource => AirdragEntry?.DataSource; public bool SavedInDeclarationMode { get; } private void SetLastValidAirdragEntry() @@ -1026,27 +825,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public ConsolidatedBusAuxiliariesData(IEnumerable<IManufacturingStageInputData> manufacturingStages) : base(manufacturingStages) { } - public XmlNode XMLSource - { - get { return _xmlNode ?? (_xmlNode = GetBusAuxXMLSource()); } - } - public string FanTechnology - { - get { return null; } - } - public IList<string> SteeringPumpTechnology - { - get { return null; } - } - public IElectricSupplyDeclarationData ElectricSupply - { - get { return null; } - } + public XmlNode XMLSource => _xmlNode ?? (_xmlNode = GetBusAuxXMLSource()); - public IElectricConsumersDeclarationData ElectricConsumers - { - get { return GetElectricConsumers(); } - } + public string FanTechnology => null; + + public IList<string> SteeringPumpTechnology => null; + + public IElectricSupplyDeclarationData ElectricSupply => null; + + public IElectricConsumersDeclarationData ElectricConsumers => GetElectricConsumers(); private IElectricConsumersDeclarationData GetElectricConsumers() { @@ -1057,20 +844,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl (_consolidateElectricConsumerData = new ConsolidateElectricConsumerData(_manufacturingStages)); } - public IPneumaticSupplyDeclarationData PneumaticSupply - { - get { return null; } - } + public IPneumaticSupplyDeclarationData PneumaticSupply => null; - public IPneumaticConsumersDeclarationData PneumaticConsumers - { - get { return null; } - } + public IPneumaticConsumersDeclarationData PneumaticConsumers => null; - public IHVACBusAuxiliariesDeclarationData HVACAux - { - get { return GetHVACAux(); } - } + public IHVACBusAuxiliariesDeclarationData HVACAux => GetHVACAux(); private IHVACBusAuxiliariesDeclarationData GetHVACAux() { @@ -1146,30 +924,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public ConsolidateElectricConsumerData(IEnumerable<IManufacturingStageInputData> manufacturingStages) : base(manufacturingStages) { } - public bool? InteriorLightsLED - { - get { return GetElectricConsumerPropertyValue<bool?>(nameof(InteriorLightsLED)); } - } + public bool? InteriorLightsLED => GetElectricConsumerPropertyValue<bool?>(nameof(InteriorLightsLED)); - public bool? DayrunninglightsLED - { - get { return GetElectricConsumerPropertyValue<bool?>(nameof(DayrunninglightsLED)); } - } + public bool? DayrunninglightsLED => GetElectricConsumerPropertyValue<bool?>(nameof(DayrunninglightsLED)); - public bool? PositionlightsLED - { - get { return GetElectricConsumerPropertyValue<bool?>(nameof(PositionlightsLED)); } - } + public bool? PositionlightsLED => GetElectricConsumerPropertyValue<bool?>(nameof(PositionlightsLED)); - public bool? HeadlightsLED - { - get { return GetElectricConsumerPropertyValue<bool?>(nameof(HeadlightsLED)); } - } + public bool? HeadlightsLED => GetElectricConsumerPropertyValue<bool?>(nameof(HeadlightsLED)); - public bool? BrakelightsLED - { - get { return GetElectricConsumerPropertyValue<bool?>(nameof(BrakelightsLED)); } - } + public bool? BrakelightsLED => GetElectricConsumerPropertyValue<bool?>(nameof(BrakelightsLED)); private T GetElectricConsumerPropertyValue<T>(string propertyName) @@ -1206,93 +969,27 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public ConsolidatedHVACBusAuxiliariesData(IEnumerable<IManufacturingStageInputData> manufacturingStages) : base(manufacturingStages) { } - public BusHVACSystemConfiguration? SystemConfiguration - { - get - { - return GetHVACBusAuxPropertyValue<BusHVACSystemConfiguration?>(nameof(SystemConfiguration)); - } - } + public BusHVACSystemConfiguration? SystemConfiguration => GetHVACBusAuxPropertyValue<BusHVACSystemConfiguration?>(nameof(SystemConfiguration)); - public HeatPumpType? HeatPumpTypeDriverCompartment - { - get - { - return GetHVACBusAuxPropertyValue<HeatPumpType?>(nameof(HeatPumpTypeDriverCompartment)); - } - } + public HeatPumpType? HeatPumpTypeDriverCompartment => GetHVACBusAuxPropertyValue<HeatPumpType?>(nameof(HeatPumpTypeDriverCompartment)); - public HeatPumpMode? HeatPumpModeDriverCompartment - { - get - { - return GetHVACBusAuxPropertyValue<HeatPumpMode?>(nameof(HeatPumpModeDriverCompartment)); - } - } + public HeatPumpMode? HeatPumpModeDriverCompartment => GetHVACBusAuxPropertyValue<HeatPumpMode?>(nameof(HeatPumpModeDriverCompartment)); - public IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments - { - get - { - return GetHeatPumpPassengerCompartments(); - } - } + public IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments => GetHeatPumpPassengerCompartments(); - public Watt AuxHeaterPower - { - get - { - return GetHVACBusAuxPropertyValue<Watt>(nameof(AuxHeaterPower)); - } - } + public Watt AuxHeaterPower => GetHVACBusAuxPropertyValue<Watt>(nameof(AuxHeaterPower)); - public bool? DoubleGlazing - { - get - { - return GetHVACBusAuxPropertyValue<bool?>(nameof(DoubleGlazing)); - } - } + public bool? DoubleGlazing => GetHVACBusAuxPropertyValue<bool?>(nameof(DoubleGlazing)); - public bool? AdjustableAuxiliaryHeater - { - get - { - return GetHVACBusAuxPropertyValue<bool?>(nameof(AdjustableAuxiliaryHeater)); - } - } + public bool? AdjustableAuxiliaryHeater => GetHVACBusAuxPropertyValue<bool?>(nameof(AdjustableAuxiliaryHeater)); - public bool? SeparateAirDistributionDucts - { - get - { - return GetHVACBusAuxPropertyValue<bool?>(nameof(SeparateAirDistributionDucts)); - } - } + public bool? SeparateAirDistributionDucts => GetHVACBusAuxPropertyValue<bool?>(nameof(SeparateAirDistributionDucts)); - public bool? WaterElectricHeater - { - get - { - return GetHVACBusAuxPropertyValue<bool?>(nameof(WaterElectricHeater)); - } - } + public bool? WaterElectricHeater => GetHVACBusAuxPropertyValue<bool?>(nameof(WaterElectricHeater)); - public bool? AirElectricHeater - { - get - { - return GetHVACBusAuxPropertyValue<bool?>(nameof(AirElectricHeater)); - } - } + public bool? AirElectricHeater => GetHVACBusAuxPropertyValue<bool?>(nameof(AirElectricHeater)); - public bool? OtherHeatingTechnology - { - get - { - return GetHVACBusAuxPropertyValue<bool?>(nameof(OtherHeatingTechnology)); - } - } + public bool? OtherHeatingTechnology => GetHVACBusAuxPropertyValue<bool?>(nameof(OtherHeatingTechnology)); public bool? AdjustableCoolantThermostat { get; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLJobDataReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLJobDataReader.cs index 658adb7a5a912b5d6e818bc8fc8e3ce9523b8e50..52d4631c79bfe8d3da587b5e276c413af565dc2a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLJobDataReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLJobDataReader.cs @@ -66,10 +66,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl #region Implementation of IXMLJobDataReader - public virtual IVehicleDeclarationInputData CreateVehicle - { - get { return _vehicle ?? (_vehicle = CreateComponent(XMLNames.Component_Vehicle, VehicleCreator)); } - } + public virtual IVehicleDeclarationInputData CreateVehicle => _vehicle ?? (_vehicle = CreateComponent(XMLNames.Component_Vehicle, VehicleCreator)); #endregion @@ -130,7 +127,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl var vehicle = Factory.CreateVehicleData(version, JobData, vehicleNode, sourceFile); vehicle.ComponentReader = GetReader(vehicle, vehicle.ComponentNode, Factory.CreateComponentReader); - vehicle.ADASReader = GetReader(vehicle, vehicle.ADASNode, Factory.CreateADASReader); ; + vehicle.ADASReader = GetReader(vehicle, vehicle.ADASNode, Factory.CreateADASReader); vehicle.PTOReader = GetReader(vehicle, vehicle.PTONode, Factory.CreatePTOReader); return vehicle; @@ -162,10 +159,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl _primaryBusJobData = busJobData; } - public IVehicleDeclarationInputData CreateVehicle - { - get { return _vehicle ?? (_vehicle = CreateComponent(XMLNames.Component_Vehicle, VehicleCreator)); } - } + public IVehicleDeclarationInputData CreateVehicle => _vehicle ?? (_vehicle = CreateComponent(XMLNames.Component_Vehicle, VehicleCreator)); protected IVehicleDeclarationInputData VehicleCreator(string version, XmlNode vehicleNode, string sourceFile) { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLPTOReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLPTOReader.cs index 7d69d820d81f9a333eaaf4e6fda0e75342c783e5..b8d842dcce2f4d8a0609be5263db429fe1842900 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLPTOReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLPTOReader.cs @@ -63,10 +63,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl #region Implementation of IXMLPTOReader - public virtual IPTOTransmissionInputData PTOInputData - { - get { return _ptoInputData ?? (_ptoInputData = CreateComponent(XMLNames.Vehicle_PTO, PTOCreator)); } - } + public virtual IPTOTransmissionInputData PTOInputData => _ptoInputData ?? (_ptoInputData = CreateComponent(XMLNames.Vehicle_PTO, PTOCreator)); #endregion diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractCommonComponentType.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractCommonComponentType.cs index 3832c28e091ed63df7ce21b184c51a499acf4225..5784f124f3f62e7d9c131bc3f61df98cb8a632f6 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractCommonComponentType.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractCommonComponentType.cs @@ -45,46 +45,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public AbstractCommonComponentType(XmlNode node, string source) : base(node, source) { } - public bool SavedInDeclarationMode - { - get { return false; } - } + public bool SavedInDeclarationMode => false; - public string Manufacturer - { - get { return GetString(XMLNames.Component_Manufacturer); } - } + public string Manufacturer => GetString(XMLNames.Component_Manufacturer); - public string Model - { - get { return GetString(XMLNames.Component_Model); } - } + public string Model => GetString(XMLNames.Component_Model); - public DateTime Date - { - get { return XmlConvert.ToDateTime(GetString(XMLNames.Component_Date), XmlDateTimeSerializationMode.Utc); } - } + public DateTime Date => XmlConvert.ToDateTime(GetString(XMLNames.Component_Date), XmlDateTimeSerializationMode.Utc); - public virtual string AppVersion - { - get { return GetString(XMLNames.Component_AppVersion); } - } + public virtual string AppVersion => GetString(XMLNames.Component_AppVersion); - public virtual CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public virtual CertificationMethod CertificationMethod => CertificationMethod.NotCertified; - public virtual string CertificationNumber - { - get { return Constants.NOT_AVailABLE; } - } + public virtual string CertificationNumber => Constants.NOT_AVAILABLE; - public virtual DigestData DigestValue - { - get { return null; } - } + public virtual DigestData DigestValue => null; - public virtual XmlNode XMLSource { get { return BaseNode; } } + public virtual XmlNode XMLSource => BaseNode; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractEngineeringXMLComponentDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractEngineeringXMLComponentDataProvider.cs index e1bd6e91472da4fe38ae8763eebca23a1dee2edd..34eeb380a78a470c28d40affda9515bc16a535f7 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractEngineeringXMLComponentDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/AbstractEngineeringXMLComponentDataProvider.cs @@ -49,19 +49,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } - public override DigestData DigestValue - { - get { return null; } - } + public override DigestData DigestValue => null; - public override string CertificationNumber - { - get { return "N.A."; } - } + public override string CertificationNumber => "N.A."; - public override CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public override CertificationMethod CertificationMethod => CertificationMethod.NotCertified; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLDriverAcceleration.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLDriverAcceleration.cs index e1aea43fba67bc8c4aa67243b2d4e453940c8815..b5cd07385ad31b481e95c51e0acb7bc4820d0be7 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLDriverAcceleration.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLDriverAcceleration.cs @@ -62,18 +62,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider _accelerationCurve = new DriverAccelerationInputData() { AccelerationCurve = accCurve }; } - public virtual IDriverAccelerationData AccelerationCurve - { - get { - return BaseNode == null - ? _accelerationCurve - : new DriverAccelerationInputData() { - AccelerationCurve = XMLHelper.ReadEntriesOrResource( - BaseNode, DriverData.DataSource.SourcePath, null, XMLNames.DriverModel_DriverAccelerationCurve_Entry, - AttributeMappings.DriverAccelerationCurveMapping) - }; - } - } + public virtual IDriverAccelerationData AccelerationCurve => + BaseNode == null + ? _accelerationCurve + : new DriverAccelerationInputData() { + AccelerationCurve = XMLHelper.ReadEntriesOrResource( + BaseNode, DriverData.DataSource.SourcePath, null, XMLNames.DriverModel_DriverAccelerationCurve_Entry, + AttributeMappings.DriverAccelerationCurveMapping) + }; } internal class XMLDriverAccelerationV10 : XMLDriverAccelerationV07 diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAirdragDataProvider.cs index 55450db3f4dd33bead859bb32b77379994fc375d..237e68efade8621cf6970a141b41b76a0149bdf4 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAirdragDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAirdragDataProvider.cs @@ -59,38 +59,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider SourceType = (vehicle as IXMLResource).DataSource.SourceFile == fsBasePath ? DataSourceType.XMLEmbedded : DataSourceType.XMLFile; } - public virtual SquareMeter AirDragArea - { - get { return GetDouble(XMLNames.Vehicle_AirDragArea).SI<SquareMeter>(); } - } + public virtual SquareMeter AirDragArea => GetDouble(XMLNames.Vehicle_AirDragArea).SI<SquareMeter>(); - public virtual SquareMeter TransferredAirDragArea - { - get { return AirDragArea; } - } + public virtual SquareMeter TransferredAirDragArea => AirDragArea; - public virtual SquareMeter AirDragArea_0 - { - get { return AirDragArea; } - } + public virtual SquareMeter AirDragArea_0 => AirDragArea; - public virtual CrossWindCorrectionMode CrossWindCorrectionMode - { - get { return GetString(XMLNames.Vehicle_CrossWindCorrectionMode).ParseEnum<CrossWindCorrectionMode>(); } - } + public virtual CrossWindCorrectionMode CrossWindCorrectionMode => GetString(XMLNames.Vehicle_CrossWindCorrectionMode).ParseEnum<CrossWindCorrectionMode>(); - public virtual TableData CrosswindCorrectionMap - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.Vehicle_CrosswindCorrectionData, XMLNames.Vehicle_CrosswindCorrectionData_Entry, - AttributeMappings.CrossWindCorrectionMapping); - } - } + public virtual TableData CrosswindCorrectionMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.Vehicle_CrosswindCorrectionData, XMLNames.Vehicle_CrosswindCorrectionData_Entry, + AttributeMappings.CrossWindCorrectionMapping); #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -110,6 +94,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider IXMLEngineeringVehicleData vehicle, XmlNode axlegearNode, string fsBasePath) : base( vehicle, axlegearNode, fsBasePath) { } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAngledriveDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAngledriveDataProvider.cs index ed21b6748679162c4be895990706b9e0a34328aa..a68fb1a7ffb83fbc3eb4881e99def856a55d9b7a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAngledriveDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAngledriveDataProvider.cs @@ -58,25 +58,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider SourceType = (vehicle as IXMLResource).DataSource.SourceFile == fsBasePath ? DataSourceType.XMLEmbedded : DataSourceType.XMLFile; } - public virtual AngledriveType Type - { - get { return Vehicle.AngledriveType; } - } + public virtual AngledriveType Type => Vehicle.AngledriveType; - public virtual double Ratio - { - get { return GetDouble(XMLNames.AngleDrive_Ratio); } - } + public virtual double Ratio => GetDouble(XMLNames.AngleDrive_Ratio); - public virtual TableData LossMap - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, - XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry, - AttributeMappings.TransmissionLossmapMapping); - } - } + public virtual TableData LossMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, + XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry, + AttributeMappings.TransmissionLossmapMapping); public virtual double Efficiency { @@ -85,7 +75,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -103,7 +93,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLEngineeringAngledriveDataProviderV10( IXMLEngineeringVehicleData vehicle, XmlNode axlegearNode, string fsBasePath) : base( vehicle, axlegearNode, fsBasePath) { } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } - + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAuxiliariesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAuxiliariesDataProvider.cs index 288a4e82df6f8c13b8229df681cd06c8cfced9e1..bf1b144667593cc60bb407af2c6c0558b66af5b2 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAuxiliariesDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAuxiliariesDataProvider.cs @@ -67,14 +67,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider get; } - public IBusAuxiliariesEngineeringData BusAuxiliariesData - { - get - { - // TODO: MQ 20210211 - implement... - return null; - } - } + public IBusAuxiliariesEngineeringData BusAuxiliariesData => + // TODO: MQ 20210211 - implement... + null; public Watt ElectricAuxPower { get; } @@ -113,7 +108,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } - protected virtual XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected virtual XNamespace SchemaNamespace => NAMESPACE_URI; #region Implementation of IAuxiliaryEngineeringInputData @@ -142,6 +137,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLAuxiliaryEngineeringDataV10(XmlNode node, string basePath) : base(node, basePath) { } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlegearDataProvider.cs index 7d4c6ebf17fb730d9fad2d214227466983eb5769..99f25d10e85bebf22dc56d1ceb320f9b5dd91978 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlegearDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlegearDataProvider.cs @@ -59,19 +59,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } - public virtual double Ratio - { - get { return GetDouble(XMLNames.Axlegear_Ratio); } - } + public virtual double Ratio => GetDouble(XMLNames.Axlegear_Ratio); - public virtual TableData LossMap - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry, - AttributeMappings.TransmissionLossmapMapping); - } - } + public virtual TableData LossMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry, + AttributeMappings.TransmissionLossmapMapping); public virtual double Efficiency @@ -79,14 +72,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider get { return GetDouble(new[] { XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_Efficiency }, double.NaN); } } - public virtual AxleLineType LineType - { - get { return AxleLineType.SinglePortalAxle; } - } + public virtual AxleLineType LineType => AxleLineType.SinglePortalAxle; #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -108,14 +98,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider XmlNode axlegearNode, string fsBasePath) : base(vehicle, axlegearNode, fsBasePath) { } - public override AxleLineType LineType - { - get { - return GetNode(XMLNames.Axlegear_LineType, required: false)?.InnerText.ParseEnum<AxleLineType>() ?? - AxleLineType.SinglePortalAxle; - } - } + public override AxleLineType LineType => + GetNode(XMLNames.Axlegear_LineType, required: false)?.InnerText.ParseEnum<AxleLineType>() ?? + AxleLineType.SinglePortalAxle; - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs index c748e34eaee6162b438940b08bf5b7aa9d203eb1..eb4427ebc7ca8012eef059a74aa25708af067696 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs @@ -93,7 +93,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -115,7 +115,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of XMLEngineeringAxlesDataProviderV07 - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } @@ -137,70 +137,37 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IAxleDeclarationInputData - public virtual bool TwinTyres - { - get { return XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_TwinTyres)?.InnerText ?? ""); } - } + public virtual bool TwinTyres => XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_TwinTyres)?.InnerText ?? ""); - public virtual bool Steered - { - get { return XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_Steered)?.InnerText ?? ""); } - } + public virtual bool Steered => XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_Steered)?.InnerText ?? ""); - public virtual AxleType AxleType - { - get { return (GetNode(XMLNames.AxleWheels_Axles_Axle_AxleType)?.InnerText ?? "").ParseEnum<AxleType>(); } - } + public virtual AxleType AxleType => (GetNode(XMLNames.AxleWheels_Axles_Axle_AxleType)?.InnerText ?? "").ParseEnum<AxleType>(); - public virtual double AxleWeightShare - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_WeightShare)?.InnerText.ToDouble() ?? 0; } - } + public virtual double AxleWeightShare => GetNode(XMLNames.AxleWheels_Axles_Axle_WeightShare)?.InnerText.ToDouble() ?? 0; - public virtual ITyreEngineeringInputData Tyre - { - get { return this; } - } + public virtual ITyreEngineeringInputData Tyre => this; - ITyreDeclarationInputData IAxleDeclarationInputData.Tyre - { - get { throw new NotImplementedException(); } - } + ITyreDeclarationInputData IAxleDeclarationInputData.Tyre => throw new NotImplementedException(); #endregion #region Implementation of ITyreDeclarationInputData - public virtual string Dimension - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_Dimension)?.InnerText; } - } + public virtual string Dimension => GetNode(XMLNames.AxleWheels_Axles_Axle_Dimension)?.InnerText; - public virtual double RollResistanceCoefficient - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_RRCISO)?.InnerText.ToDouble() ?? double.NaN; } - } + public virtual double RollResistanceCoefficient => GetNode(XMLNames.AxleWheels_Axles_Axle_RRCISO)?.InnerText.ToDouble() ?? double.NaN; - public virtual Newton TyreTestLoad - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_FzISO)?.InnerText.ToDouble().SI<Newton>(); } - } + public virtual Newton TyreTestLoad => GetNode(XMLNames.AxleWheels_Axles_Axle_FzISO)?.InnerText.ToDouble().SI<Newton>(); - public virtual string FuelEfficiencyClass { get { return DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); } } + public virtual string FuelEfficiencyClass => DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); #endregion #region Implementation of ITyreEngineeringInputData - public virtual KilogramSquareMeter Inertia - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_Inertia)?.InnerText.ToDouble().SI<KilogramSquareMeter>(); } - } + public virtual KilogramSquareMeter Inertia => GetNode(XMLNames.AxleWheels_Axles_Axle_Inertia)?.InnerText.ToDouble().SI<KilogramSquareMeter>(); - public virtual Meter DynamicTyreRadius - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_DynamicTyreRadius)?.InnerText.ToDouble().SI(Unit.SI.Milli.Meter).Cast<Meter>(); } - } + public virtual Meter DynamicTyreRadius => GetNode(XMLNames.AxleWheels_Axles_Axle_DynamicTyreRadius)?.InnerText.ToDouble().SI(Unit.SI.Milli.Meter).Cast<Meter>(); #endregion @@ -208,7 +175,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -233,36 +200,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IAxleDeclarationInputData - public virtual bool TwinTyres - { - get { return XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_TwinTyres)?.InnerText ?? ""); } - } + public virtual bool TwinTyres => XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_TwinTyres)?.InnerText ?? ""); - public virtual bool Steered - { - get { return XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_Steered)?.InnerText ?? ""); } - } + public virtual bool Steered => XmlConvert.ToBoolean(GetNode(XMLNames.AxleWheels_Axles_Axle_Steered)?.InnerText ?? ""); - public virtual AxleType AxleType - { - get { return (GetNode(XMLNames.AxleWheels_Axles_Axle_AxleType)?.InnerText ?? "").ParseEnum<AxleType>(); } - } + public virtual AxleType AxleType => (GetNode(XMLNames.AxleWheels_Axles_Axle_AxleType)?.InnerText ?? "").ParseEnum<AxleType>(); - public virtual ITyreEngineeringInputData Tyre - { - get { return _tyre ?? (_tyre = Reader.Tyre); } - } + public virtual ITyreEngineeringInputData Tyre => _tyre ?? (_tyre = Reader.Tyre); - public virtual double AxleWeightShare - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_WeightShare)?.InnerText.ToDouble() ?? 0; } - } + public virtual double AxleWeightShare => GetNode(XMLNames.AxleWheels_Axles_Axle_WeightShare)?.InnerText.ToDouble() ?? 0; - ITyreDeclarationInputData IAxleDeclarationInputData.Tyre - { - get { return Tyre; } - } + ITyreDeclarationInputData IAxleDeclarationInputData.Tyre => Tyre; #endregion @@ -270,7 +219,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -286,11 +235,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLAxleEngineeringDataV10TEST(XmlNode node, IXMLEngineeringVehicleData vehicle) : base(node, vehicle) { } - public override bool TwinTyres - { - get { return XmlConvert.ToBoolean(GetNode("TwinTires")?.InnerText ?? ""); } - } + public override bool TwinTyres => XmlConvert.ToBoolean(GetNode("TwinTires")?.InnerText ?? ""); - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverDataProvider.cs index a31d8cb40a8d904d6b2df55e745c324a762db73b..712da3c650bf06a7abe714b86df5ce7ee7ec314a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverDataProvider.cs @@ -63,45 +63,24 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public IXMLDriverDataReader Reader { protected get; set; } - public virtual IDriverAccelerationData AccelerationCurve - { - get { return (_accCurve ?? (_accCurve = Reader.AccelerationCurveData)).AccelerationCurve; } - } + public virtual IDriverAccelerationData AccelerationCurve => (_accCurve ?? (_accCurve = Reader.AccelerationCurveData)).AccelerationCurve; - public virtual ILookaheadCoastingInputData Lookahead - { - get { return _lookahead ?? (_lookahead = Reader.LookAheadData); } - } + public virtual ILookaheadCoastingInputData Lookahead => _lookahead ?? (_lookahead = Reader.LookAheadData); - public virtual IGearshiftEngineeringInputData GearshiftInputData - { - get { return _shiftParameters ?? (_shiftParameters = Reader.ShiftParameters); } - } + public virtual IGearshiftEngineeringInputData GearshiftInputData => _shiftParameters ?? (_shiftParameters = Reader.ShiftParameters); - public virtual IEngineStopStartEngineeringInputData EngineStopStartData { get { return null; } } + public virtual IEngineStopStartEngineeringInputData EngineStopStartData => null; - public virtual IEcoRollEngineeringInputData EcoRollData - { - get { return null; } - } + public virtual IEcoRollEngineeringInputData EcoRollData => null; - public virtual IPCCEngineeringInputData PCCData - { - get { return null; } - } + public virtual IPCCEngineeringInputData PCCData => null; - public virtual IOverSpeedEngineeringInputData OverSpeedData - { - get { return _overspeed ?? (_overspeed = Reader.OverspeedData); } - } + public virtual IOverSpeedEngineeringInputData OverSpeedData => _overspeed ?? (_overspeed = Reader.OverspeedData); #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -128,26 +107,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider inputData, driverDataNode, fsBasePath) { } - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; - public override IEngineStopStartEngineeringInputData EngineStopStartData - { - get { return _engineStopStart ?? (_engineStopStart = Reader.EngineStopStartData); } - } + public override IEngineStopStartEngineeringInputData EngineStopStartData => _engineStopStart ?? (_engineStopStart = Reader.EngineStopStartData); - public override IEcoRollEngineeringInputData EcoRollData - { - get { return _ecoRollData ?? (_ecoRollData = Reader.EcoRollData); } - } + public override IEcoRollEngineeringInputData EcoRollData => _ecoRollData ?? (_ecoRollData = Reader.EcoRollData); - - public override IPCCEngineeringInputData PCCData - { - get { return _pccData ?? (_pccData = Reader.PCCData); } - } + + public override IPCCEngineeringInputData PCCData => _pccData ?? (_pccData = Reader.PCCData); } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverLookAhead.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverLookAhead.cs index 2b5ec07b1ecf0aa95868fa9b956f74771af06e3a..6143021e6901520a4a056a817ab538b614e9b294 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverLookAhead.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringDriverLookAhead.cs @@ -60,66 +60,39 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of ILookaheadCoastingInputData - public virtual bool Enabled - { - get { return GetBool(XMLNames.DriverModel_LookAheadCoasting_Enabled); } - } - - public virtual MeterPerSecond MinSpeed - { - get { - return GetNode(XMLNames.DriverModel_Overspeed_MinSpeed, required: false) - ?.InnerText.ToDouble().KMPHtoMeterPerSecond() ?? - DeclarationData.Driver.LookAhead.MinimumSpeed; - } - } - - public virtual double CoastingDecisionFactorOffset - { - get { - return GetNode(XMLNames.DriverModel_LookAheadCoasting_DecisionFactorOffset, required: false) - ?.InnerText.ToDouble() ?? - DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset; - } - } - - public virtual double CoastingDecisionFactorScaling - { - get { - return GetNode(XMLNames.DriverModel_LookAheadCoasting_DecisionFactorScaling, required: false) - ?.InnerText.ToDouble() ?? - DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling; - } - } - - public virtual double LookaheadDistanceFactor - { - get { - return GetNode(XMLNames.DriverModel_LookAheadCoasting_PreviewDistanceFactor, required: false) - ?.InnerText.ToDouble() ?? - DeclarationData.Driver.LookAhead.LookAheadDistanceFactor; - } - } - - public virtual TableData CoastingDecisionFactorTargetSpeedLookup - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DriverData.DataSource.SourcePath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, - XMLNames.LookAheadCoasting_SpeedDependentDecisionFactor_Entry, - AttributeMappings.CoastingDFTargetSpeedLookupMapping); - } - } - - public virtual TableData CoastingDecisionFactorVelocityDropLookup - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DriverData.DataSource.SourcePath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, - XMLNames.LookAheadCoasting_VelocityDropDecisionFactor_Entry, - AttributeMappings.CoastingDFVelocityDropLookupMapping); - } - } + public virtual bool Enabled => GetBool(XMLNames.DriverModel_LookAheadCoasting_Enabled); + + public virtual MeterPerSecond MinSpeed => + GetNode(XMLNames.DriverModel_Overspeed_MinSpeed, required: false) + ?.InnerText.ToDouble().KMPHtoMeterPerSecond() ?? + DeclarationData.Driver.LookAhead.MinimumSpeed; + + public virtual double CoastingDecisionFactorOffset => + GetNode(XMLNames.DriverModel_LookAheadCoasting_DecisionFactorOffset, required: false) + ?.InnerText.ToDouble() ?? + DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset; + + public virtual double CoastingDecisionFactorScaling => + GetNode(XMLNames.DriverModel_LookAheadCoasting_DecisionFactorScaling, required: false) + ?.InnerText.ToDouble() ?? + DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling; + + public virtual double LookaheadDistanceFactor => + GetNode(XMLNames.DriverModel_LookAheadCoasting_PreviewDistanceFactor, required: false) + ?.InnerText.ToDouble() ?? + DeclarationData.Driver.LookAhead.LookAheadDistanceFactor; + + public virtual TableData CoastingDecisionFactorTargetSpeedLookup => + XMLHelper.ReadEntriesOrResource( + BaseNode, DriverData.DataSource.SourcePath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, + XMLNames.LookAheadCoasting_SpeedDependentDecisionFactor_Entry, + AttributeMappings.CoastingDFTargetSpeedLookupMapping); + + public virtual TableData CoastingDecisionFactorVelocityDropLookup => + XMLHelper.ReadEntriesOrResource( + BaseNode, DriverData.DataSource.SourcePath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, + XMLNames.LookAheadCoasting_VelocityDropDecisionFactor_Entry, + AttributeMappings.CoastingDFVelocityDropLookupMapping); #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEcoRollDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEcoRollDataProvider.cs index 0bc99fc165a1fe42d22ba62763bde54d56e2c690..91721656a5fc5cec73bc23a4a176ca8ac9e1551f 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEcoRollDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEcoRollDataProvider.cs @@ -20,30 +20,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IEcoRollEngineeringInputData - public MeterPerSecond MinSpeed - { - get { return GetDouble("MinSpeed", DeclarationData.Driver.EcoRoll.MinSpeed.AsKmph).KMPHtoMeterPerSecond(); } - } - - public Second ActivationDelay - { - get { return GetDouble("ActivationDelay", DeclarationData.Driver.EcoRoll.ActivationDelay.Value()).SI<Second>(); } - } - - public MeterPerSecond UnderspeedThreshold - { - get { - return GetDouble("Underspeed", DeclarationData.Driver.EcoRoll.UnderspeedThreshold.AsKmph).KMPHtoMeterPerSecond(); - } - } - - public MeterPerSquareSecond AccelerationUpperLimit - { - get { - return GetDouble("MaxAcceleration", DeclarationData.Driver.EcoRoll.AccelerationUpperLimit.Value()) - .SI<MeterPerSquareSecond>(); - } - } + public MeterPerSecond MinSpeed => GetDouble("MinSpeed", DeclarationData.Driver.EcoRoll.MinSpeed.AsKmph).KMPHtoMeterPerSecond(); + + public Second ActivationDelay => GetDouble("ActivationDelay", DeclarationData.Driver.EcoRoll.ActivationDelay.Value()).SI<Second>(); + + public MeterPerSecond UnderspeedThreshold => GetDouble("Underspeed", DeclarationData.Driver.EcoRoll.UnderspeedThreshold.AsKmph).KMPHtoMeterPerSecond(); + + public MeterPerSquareSecond AccelerationUpperLimit => + GetDouble("MaxAcceleration", DeclarationData.Driver.EcoRoll.AccelerationUpperLimit.Value()) + .SI<MeterPerSquareSecond>(); #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs index 22319c5afe44092106ef7f8294200783fca3e7fe..abfd1c5c7eba0277f16e4dc818e94db0580a99e0 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs @@ -71,89 +71,40 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLEngineeringEngineDataProviderV07(XmlNode node, string sourceFile) : base(null, node, sourceFile) { } - public virtual CubicMeter Displacement - { - get { return GetDouble(XMLNames.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); } - } - - public virtual PerSecond IdleSpeed - { - get { return GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } - } + public virtual CubicMeter Displacement => GetDouble(XMLNames.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); - public virtual double WHTCEngineering - { - get { return GetDouble(XMLNames.Engine_WHTCEngineering); } - } + public virtual PerSecond IdleSpeed => GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); - IList<IEngineModeEngineeringInputData> IEngineEngineeringInputData.EngineModes - { - get { return _modes ?? (_modes = ReadEngineModes()); } - } + public virtual double WHTCEngineering => GetDouble(XMLNames.Engine_WHTCEngineering); - public virtual Second EngineStartTime - { - get { return null; } - } + IList<IEngineModeEngineeringInputData> IEngineEngineeringInputData.EngineModes => _modes ?? (_modes = ReadEngineModes()); - public virtual double WHTCMotorway - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } + public virtual Second EngineStartTime => null; - public virtual double WHTCRural - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } + public virtual double WHTCMotorway => throw new VectoException("Property not available in Engineering Mode"); - public virtual double WHTCUrban - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } + public virtual double WHTCRural => throw new VectoException("Property not available in Engineering Mode"); - public virtual double ColdHotBalancingFactor - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } + public virtual double WHTCUrban => throw new VectoException("Property not available in Engineering Mode"); - public virtual double CorrectionFactorRegPer - { - get { - return 1; + public virtual double ColdHotBalancingFactor => throw new VectoException("Property not available in Engineering Mode"); - //GetDoubleElementValue(XMLNames.Engine_CorrectionFactor_RegPer); - } - } + public virtual double CorrectionFactorRegPer => 1; - public virtual double CorrectionFactorNCV - { - get { return 1; } - } + //GetDoubleElementValue(XMLNames.Engine_CorrectionFactor_RegPer); + public virtual double CorrectionFactorNCV => 1; - public virtual FuelType FuelType - { - get { - return FuelType.DieselCI; //GetElementValue(XMLNames.Engine_FuelType).ParseEnum<FuelType>(); - } - } + public virtual FuelType FuelType => FuelType.DieselCI; //GetElementValue(XMLNames.Engine_FuelType).ParseEnum<FuelType>(); - public virtual TableData FuelConsumptionMap - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, - AttributeMappings.FuelConsumptionMapMapping); - } - } + public virtual TableData FuelConsumptionMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, + AttributeMappings.FuelConsumptionMapMapping); - public virtual TableData FullLoadCurve - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry, - AttributeMappings.EngineFullLoadCurveMapping); - } - } + public virtual TableData FullLoadCurve => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry, + AttributeMappings.EngineFullLoadCurveMapping); IList<IEngineFuelEngineeringInputData> IEngineModeEngineeringInputData.Fuels { @@ -165,65 +116,32 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider get { return new[] { this }.Cast<IEngineFuelDeclarationInputData>().ToList(); } } - public virtual IWHRData WasteHeatRecoveryDataElectrical - { - get { return null; } - } + public virtual IWHRData WasteHeatRecoveryDataElectrical => null; - public virtual IWHRData WasteHeatRecoveryDataMechanical - { - get { return null; } - } + public virtual IWHRData WasteHeatRecoveryDataMechanical => null; - public virtual Watt RatedPowerDeclared - { - get { - return null; //GetDoubleElementValue(XMLNames.Engine_RatedPower).SI<Watt>(); - } - } + public virtual Watt RatedPowerDeclared => null; //GetDoubleElementValue(XMLNames.Engine_RatedPower).SI<Watt>(); - public virtual PerSecond RatedSpeedDeclared - { - get { - return null; //GetDoubleElementValue(XMLNames.Engine_RatedSpeed).RPMtoRad(); - } - } + public virtual PerSecond RatedSpeedDeclared => null; //GetDoubleElementValue(XMLNames.Engine_RatedSpeed).RPMtoRad(); - public virtual NewtonMeter MaxTorqueDeclared - { - get { - return null; //GetDoubleElementValue(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); - } - } + public virtual NewtonMeter MaxTorqueDeclared => null; //GetDoubleElementValue(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); - public virtual IList<IEngineModeDeclarationInputData> EngineModes - { - get { return (_modes ?? (_modes = ReadEngineModes())).Cast<IEngineModeDeclarationInputData>().ToList(); } - } + public virtual IList<IEngineModeDeclarationInputData> EngineModes => (_modes ?? (_modes = ReadEngineModes())).Cast<IEngineModeDeclarationInputData>().ToList(); protected virtual IList<IEngineModeEngineeringInputData> ReadEngineModes() { return new IEngineModeEngineeringInputData[] { this }; } - public virtual WHRType WHRType - { - get { return WHRType.None; } - } + public virtual WHRType WHRType => WHRType.None; - public virtual KilogramSquareMeter Inertia - { - get { return GetString(XMLNames.Engine_Inertia, required: false)?.ToDouble().SI<KilogramSquareMeter>(); } - } + public virtual KilogramSquareMeter Inertia => GetString(XMLNames.Engine_Inertia, required: false)?.ToDouble().SI<KilogramSquareMeter>(); #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -245,17 +163,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider // engine-only constructor public XMLEngineeringEngineDataProviderV10(XmlNode node, string sourceFile) : base(node, sourceFile) { } - public override double WHTCEngineering - { - get { return GetDouble(XMLNames.Engine_FCCorrection, 1.0); } - } + public override double WHTCEngineering => GetDouble(XMLNames.Engine_FCCorrection, 1.0); #region Overrides of XMLEngineeringEngineDataProviderV07 - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } @@ -278,15 +190,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of XMLEngineeringEngineDataProviderV07 - public override PerSecond RatedSpeedDeclared - { - get { return GetString(XMLNames.Engine_RatedSpeed).Replace("rpm", "").ToDouble(0).RPMtoRad(); } - } + public override PerSecond RatedSpeedDeclared => GetString(XMLNames.Engine_RatedSpeed).Replace("rpm", "").ToDouble(0).RPMtoRad(); - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } @@ -349,38 +255,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IEngineModeDeclarationInputData - public PerSecond IdleSpeed { - get { return GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } - } - public TableData FullLoadCurve { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, Source.SourcePath, XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry, - AttributeMappings.EngineFullLoadCurveMapping); - } - } + public PerSecond IdleSpeed => GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); - IList<IEngineFuelEngineeringInputData> IEngineModeEngineeringInputData.Fuels - { - get { return _fuels ?? (_fuels = ReadFuels()); } - } + public TableData FullLoadCurve => + XMLHelper.ReadEntriesOrResource( + BaseNode, Source.SourcePath, XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry, + AttributeMappings.EngineFullLoadCurveMapping); - + IList<IEngineFuelEngineeringInputData> IEngineModeEngineeringInputData.Fuels => _fuels ?? (_fuels = ReadFuels()); - IList<IEngineFuelDeclarationInputData> IEngineModeDeclarationInputData.Fuels - { - get { return (_fuels ?? (_fuels = ReadFuels())).Cast<IEngineFuelDeclarationInputData>().ToList(); } - } - public virtual IWHRData WasteHeatRecoveryDataElectrical - { - get { return WHRData ?? (WHRData = ReadWHRData("Electrical")); } - } + IList<IEngineFuelDeclarationInputData> IEngineModeDeclarationInputData.Fuels => (_fuels ?? (_fuels = ReadFuels())).Cast<IEngineFuelDeclarationInputData>().ToList(); - public virtual IWHRData WasteHeatRecoveryDataMechanical - { - get { return WHRData ?? (WHRData = ReadWHRData("Mechanical")); } - } + public virtual IWHRData WasteHeatRecoveryDataElectrical => WHRData ?? (WHRData = ReadWHRData("Electrical")); + + public virtual IWHRData WasteHeatRecoveryDataMechanical => WHRData ?? (WHRData = ReadWHRData("Mechanical")); #endregion @@ -423,29 +312,26 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } } - public virtual double WHTCMotorway { get { return 1; } } + public virtual double WHTCMotorway => 1; - public virtual double WHTCRural { get { return 1; } } + public virtual double WHTCRural => 1; - public virtual double WHTCUrban { get { return 1; } } + public virtual double WHTCUrban => 1; - public virtual double ColdHotBalancingFactor { get { return 1; } } + public virtual double ColdHotBalancingFactor => 1; - public virtual double CorrectionFactorRegPer { get { return 1; } } + public virtual double CorrectionFactorRegPer => 1; - public virtual TableData FuelConsumptionMap { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, Source.SourcePath, XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, - AttributeMappings.FuelConsumptionMapMapping); - } - } + public virtual TableData FuelConsumptionMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, Source.SourcePath, XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, + AttributeMappings.FuelConsumptionMapMapping); #endregion #region Implementation of IEngineFuelEngineeringInputData - public double WHTCEngineering { get { return GetDouble(XMLNames.Engine_FCCorrection); } } + public double WHTCEngineering => GetDouble(XMLNames.Engine_FCCorrection); #endregion } @@ -462,21 +348,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IWHRData - public virtual double UrbanCorrectionFactor { get { return 1; } } - public virtual double RuralCorrectionFactor { get { return 1; } } - public virtual double MotorwayCorrectionFactor { get { return 1; } } - public virtual double BFColdHot { get { return 1; } } - public virtual double CFRegPer { get { return 1; } } - public virtual double EngineeringCorrectionFactor { get { return GetDouble(XMLNames.Engine_WHRCorrectionFactor); } } + public virtual double UrbanCorrectionFactor => 1; + public virtual double RuralCorrectionFactor => 1; + public virtual double MotorwayCorrectionFactor => 1; + public virtual double BFColdHot => 1; + public virtual double CFRegPer => 1; + public virtual double EngineeringCorrectionFactor => GetDouble(XMLNames.Engine_WHRCorrectionFactor); - public virtual TableData GeneratedPower - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, Source.SourcePath, XMLNames.Engine_WHRMap, XMLNames.Engine_WHRMap_Entry, - AttributeMappings.WHRPowerMapMapping); - } - } + public virtual TableData GeneratedPower => + XMLHelper.ReadEntriesOrResource( + BaseNode, Source.SourcePath, XMLNames.Engine_WHRMap, XMLNames.Engine_WHRMap_Entry, + AttributeMappings.WHRPowerMapMapping); #endregion } @@ -484,10 +366,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of XMLEngineeringEngineDataProviderV07 - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineStopStartDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineStopStartDataProvider.cs index c24014fa6be9ee2fef66e667e50fecc50376a796..a85532b12d1c37fe20ba40acb3b8a88915fac2ce 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineStopStartDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineStopStartDataProvider.cs @@ -17,26 +17,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider { public XMLEngineeringEngineStopStartDataProviderV10(IXMLEngineeringDriverData driverData, XmlNode node) : base(node) { } - public virtual Second ActivationDelay - { - get { return GetDouble("ActivationDelay", DeclarationData.Driver.EngineStopStart.ActivationDelay.Value()).SI<Second>(); } - } + public virtual Second ActivationDelay => GetDouble("ActivationDelay", DeclarationData.Driver.EngineStopStart.ActivationDelay.Value()).SI<Second>(); - public virtual Second MaxEngineOffTimespan - { - get { return GetDouble("MaxEngineOffTime", DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan.Value()).SI<Second>(); } - } + public virtual Second MaxEngineOffTimespan => GetDouble("MaxEngineOffTime", DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan.Value()).SI<Second>(); - public virtual double UtilityFactorStandstill - { - get { - return GetDouble("UtilityFactor", DeclarationData.Driver.EngineStopStart.UtilityFactor); - } - } + public virtual double UtilityFactorStandstill => GetDouble("UtilityFactor", DeclarationData.Driver.EngineStopStart.UtilityFactor); - public double UtilityFactorDriving { get { return GetDouble("UtilityFactorDriving", DeclarationData.Driver.EngineStopStart.UtilityFactor); } } - - protected XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + public double UtilityFactorDriving => GetDouble("UtilityFactorDriving", DeclarationData.Driver.EngineStopStart.UtilityFactor); + protected XNamespace SchemaNamespace => NAMESPACE_URI; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearboxDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearboxDataProvider.cs index 254f03bbb2b610ce83a82794ba8dcbfbbab09d14..3bdda5dee3c14c462997b48520cb9ff42d5b0128 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearboxDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearboxDataProvider.cs @@ -62,30 +62,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider SourceType = (vehicle as IXMLResource).DataSource.SourceFile == fsBasePath ? DataSourceType.XMLEmbedded : DataSourceType.XMLFile; } - public virtual GearboxType Type - { - get { return GetString(XMLNames.Gearbox_TransmissionType).ParseEnum<GearboxType>(); } - } + public virtual GearboxType Type => GetString(XMLNames.Gearbox_TransmissionType).ParseEnum<GearboxType>(); - public virtual KilogramSquareMeter Inertia - { - get { return GetDouble(XMLNames.Gearbox_Inertia).SI<KilogramSquareMeter>(); } - } + public virtual KilogramSquareMeter Inertia => GetDouble(XMLNames.Gearbox_Inertia).SI<KilogramSquareMeter>(); - public virtual Second TractionInterruption - { - get { return GetDouble(XMLNames.Gearbox_TractionInterruption).SI<Second>(); } - } + public virtual Second TractionInterruption => GetDouble(XMLNames.Gearbox_TractionInterruption).SI<Second>(); - public virtual Second PowershiftShiftTime - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_PowershiftShiftTime, - ((XMLEngineeringInputDataProviderV07)Vehicle.Job.InputData).Document.DocumentElement, required: false) - ?.InnerText.ToDouble().SI<Second>() ?? Constants.DefaultPowerShiftTime; - } - } + public virtual Second PowershiftShiftTime => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_PowershiftShiftTime, + ((XMLEngineeringInputDataProviderV07)Vehicle.Job.InputData).Document.DocumentElement, required: false) + ?.InnerText.ToDouble().SI<Second>() ?? Constants.DefaultPowerShiftTime; public virtual IList<ITransmissionInputData> Gears { @@ -104,15 +91,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } } - public virtual bool DifferentialIncluded { get { return false; } } - public virtual double AxlegearRatio { get { return double.NaN; } } + public virtual bool DifferentialIncluded => false; + public virtual double AxlegearRatio => double.NaN; public IXMLGearboxReader Reader { protected get; set; } #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -134,12 +121,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of XMLEngineeringGearboxDataProviderV07 - public override Second PowershiftShiftTime - { - get { return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_PowershiftShiftTime, required: false)?.InnerText.ToDouble().SI<Second>() ?? Constants.DefaultPowerShiftTime; } - } + public override Second PowershiftShiftTime => GetNode(XMLNames.DriverModel_ShiftStrategyParameters_PowershiftShiftTime, required: false)?.InnerText.ToDouble().SI<Second>() ?? Constants.DefaultPowerShiftTime; - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } @@ -155,30 +139,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider BasePath = basePath; } - public virtual int Gear - { - get { - return XmlConvert.ToUInt16( - BaseNode.Attributes?.GetNamedItem(XMLNames.Gearbox_Gear_GearNumber_Attr).InnerText ?? "0"); - } - } + public virtual int Gear => + XmlConvert.ToUInt16( + BaseNode.Attributes?.GetNamedItem(XMLNames.Gearbox_Gear_GearNumber_Attr).InnerText ?? "0"); - public virtual double Ratio - { - get { - return BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(XMLNames.Gearbox_Gear_Ratio))?.InnerText.ToDouble() ?? - double.NaN; - } - } + public virtual double Ratio => + BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(XMLNames.Gearbox_Gear_Ratio))?.InnerText.ToDouble() ?? + double.NaN; - public virtual TableData LossMap - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, BasePath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry, - AttributeMappings.TransmissionLossmapMapping); - } - } + public virtual TableData LossMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, BasePath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry, + AttributeMappings.TransmissionLossmapMapping); public virtual double Efficiency { @@ -188,10 +160,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } } - public virtual DataSource DataSource - { - get { return _dataSource ?? (_dataSource = new DataSource() { SourceFile = BasePath, SourceType = DataSourceType.XMLEmbedded, SourceVersion = XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace) }); } - } + public virtual DataSource DataSource => _dataSource ?? (_dataSource = new DataSource() { SourceFile = BasePath, SourceType = DataSourceType.XMLEmbedded, SourceVersion = XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace) }); protected abstract XNamespace SchemaNamespace { get; } } @@ -210,33 +179,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of ITransmissionInputData - public virtual NewtonMeter MaxTorque - { - get { - return GetNode(XMLNames.Gearbox_Gears_MaxTorque, required: false)?.InnerText - .ToDouble().SI<NewtonMeter>(); - } - } + public virtual NewtonMeter MaxTorque => + GetNode(XMLNames.Gearbox_Gears_MaxTorque, required: false)?.InnerText + .ToDouble().SI<NewtonMeter>(); - public virtual PerSecond MaxInputSpeed - { - get { return GetNode(XMLNames.Gearbox_Gear_MaxSpeed, required: false)?.InnerText.ToDouble().RPMtoRad(); } - } - - public virtual TableData ShiftPolygon - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, BasePath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry, - AttributeMappings.ShiftPolygonMapping); - } - } + public virtual PerSecond MaxInputSpeed => GetNode(XMLNames.Gearbox_Gear_MaxSpeed, required: false)?.InnerText.ToDouble().RPMtoRad(); + public virtual TableData ShiftPolygon => + XMLHelper.ReadEntriesOrResource( + BaseNode, BasePath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry, + AttributeMappings.ShiftPolygonMapping); #endregion - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } - + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } internal class XMLGearDataV10 : XMLGearDataV07 @@ -251,7 +207,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLGearDataV10(XmlNode gearNode, string basePath) : base(gearNode, basePath) { } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } - + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearshiftData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearshiftData.cs index 83d9beb92d4887ed4398c9197bc4ae2348fd589d..41fbabdf1763e837b6d36e7230c7522e5cb5221c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearshiftData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringGearshiftData.cs @@ -59,139 +59,92 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider // get { return GetNode(XMLNames.Gearbox_TractionInterruption)?.InnerText.ToDouble().SI<Second>(); } //} - public virtual Second MinTimeBetweenGearshift - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_TimeBetweenGearshift, required: false) - ?.InnerText.ToDouble().SI<Second>() ?? DeclarationData.Gearbox.MinTimeBetweenGearshifts; - } - } - - public virtual double TorqueReserve - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_TorqueReserve, required: false)?.InnerText.ToDouble() ?? - DeclarationData.GearboxTCU.TorqueReserve; - } - } - - public virtual MeterPerSecond StartSpeed - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_StartSpeed, required: false) - ?.InnerText.ToDouble().SI<MeterPerSecond>() ?? DeclarationData.GearboxTCU.StartSpeed; - } - } - - public virtual MeterPerSquareSecond StartAcceleration - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_StartAcceleration, required: false) - ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? DeclarationData.GearboxTCU.StartAcceleration; - } - } - - public virtual double StartTorqueReserve - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_StartTorqueReserve, required: false) - ?.InnerText.ToDouble() ?? - DeclarationData.GearboxTCU.TorqueReserveStart; - } - } - - public virtual Second DownshiftAfterUpshiftDelay - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_DownshiftAfterUpshiftDelay, required: false) - ?.InnerText.ToDouble().SI<Second>() ?? - DeclarationData.Gearbox.DownshiftAfterUpshiftDelay; - } - } - - public virtual Second UpshiftAfterDownshiftDelay - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_UpshiftAfterDownshiftDelay, required: false) - ?.InnerText.ToDouble().SI<Second>() ?? DeclarationData.Gearbox.UpshiftAfterDownshiftDelay; - } - } - - public virtual MeterPerSquareSecond UpshiftMinAcceleration - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_UpshiftMinAcceleration, required: false) - ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? DeclarationData.Gearbox.UpshiftMinAcceleration; - } - } - - public virtual Second GearResidenceTime { get { return null; } } - public virtual double? DnT99LHMin1 { get { return null; } } - public virtual double? DnT99LHMin2 { get { return null; } } - public virtual int? AllowedGearRangeUp { get { return null; } } - public virtual int? AllowedGearRangeDown { get { return null; } } - public virtual Second LookBackInterval { get { return null; } } - public virtual Watt AvgCardanPowerThresholdPropulsion { get { return null; } } - public virtual Watt CurrCardanPowerThresholdPropulsion { get { return null; } } - public virtual double? TargetSpeedDeviationFactor { get { return null; } } - public virtual double? EngineSpeedHighDriveOffFactor { get { return null; } } - public virtual double? RatingFactorCurrentGear { get { return null; } } - public virtual TableData AccelerationReserveLookup { get { return null; } } - public virtual TableData ShareTorque99L { get { return null; } } - public virtual TableData PredictionDurationLookup { get { return null; } } - public virtual TableData ShareIdleLow { get { return null; } } - public virtual TableData ShareEngineHigh { get { return null; } } - public virtual string Source { get { return null; } } - public virtual Second DriverAccelerationLookBackInterval { get { return null; } } - public virtual MeterPerSquareSecond DriverAccelerationThresholdLow { get { return null; } } - public virtual double? RatioEarlyUpshiftFC { get { return null; } } - public virtual double? RatioEarlyDownshiftFC { get { return null; } } - public int? AllowedGearRangeFC { get { return null; } } - - public double? VeloictyDropFactor { get { return null; } } - - public PerSecond MinEngineSpeedPostUpshift { get { return null; } } - public Second ATLookAheadTime { get { return null; } } - public double[][] ShiftSpeedsTCToLocked { get { return null; } } - - public double? AccelerationFactor - { - get { return null; } - } - - public virtual TableData LoadStageShiftLines { get { return null; } } - public virtual IList<double> LoadStageThresholdsUp { get { return null; } } - public virtual IList<double> LoadStageThresholdsDown { get { return null; } } - - public virtual Second PowershiftShiftTime - { - get { - return GetNode(XMLNames.DriverModel_ShiftStrategyParameters_PowershiftShiftTime, required: false) - ?.InnerText.ToDouble().SI<Second>() ?? 0.8.SI<Second>(); - } - } + public virtual Second MinTimeBetweenGearshift => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_TimeBetweenGearshift, required: false) + ?.InnerText.ToDouble().SI<Second>() ?? DeclarationData.Gearbox.MinTimeBetweenGearshifts; + + public virtual double TorqueReserve => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_TorqueReserve, required: false)?.InnerText.ToDouble() ?? + DeclarationData.GearboxTCU.TorqueReserve; + + public virtual MeterPerSecond StartSpeed => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_StartSpeed, required: false) + ?.InnerText.ToDouble().SI<MeterPerSecond>() ?? DeclarationData.GearboxTCU.StartSpeed; + + public virtual MeterPerSquareSecond StartAcceleration => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_StartAcceleration, required: false) + ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? DeclarationData.GearboxTCU.StartAcceleration; + + public virtual double StartTorqueReserve => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_StartTorqueReserve, required: false) + ?.InnerText.ToDouble() ?? + DeclarationData.GearboxTCU.TorqueReserveStart; + + public virtual Second DownshiftAfterUpshiftDelay => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_DownshiftAfterUpshiftDelay, required: false) + ?.InnerText.ToDouble().SI<Second>() ?? + DeclarationData.Gearbox.DownshiftAfterUpshiftDelay; + + public virtual Second UpshiftAfterDownshiftDelay => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_UpshiftAfterDownshiftDelay, required: false) + ?.InnerText.ToDouble().SI<Second>() ?? DeclarationData.Gearbox.UpshiftAfterDownshiftDelay; + + public virtual MeterPerSquareSecond UpshiftMinAcceleration => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_UpshiftMinAcceleration, required: false) + ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? DeclarationData.Gearbox.UpshiftMinAcceleration; + + public virtual Second GearResidenceTime => null; + public virtual double? DnT99LHMin1 => null; + public virtual double? DnT99LHMin2 => null; + public virtual int? AllowedGearRangeUp => null; + public virtual int? AllowedGearRangeDown => null; + public virtual Second LookBackInterval => null; + public virtual Watt AvgCardanPowerThresholdPropulsion => null; + public virtual Watt CurrCardanPowerThresholdPropulsion => null; + public virtual double? TargetSpeedDeviationFactor => null; + public virtual double? EngineSpeedHighDriveOffFactor => null; + public virtual double? RatingFactorCurrentGear => null; + public virtual TableData AccelerationReserveLookup => null; + public virtual TableData ShareTorque99L => null; + public virtual TableData PredictionDurationLookup => null; + public virtual TableData ShareIdleLow => null; + public virtual TableData ShareEngineHigh => null; + public virtual string Source => null; + public virtual Second DriverAccelerationLookBackInterval => null; + public virtual MeterPerSquareSecond DriverAccelerationThresholdLow => null; + public virtual double? RatioEarlyUpshiftFC => null; + public virtual double? RatioEarlyDownshiftFC => null; + public int? AllowedGearRangeFC => null; + + public double? VeloictyDropFactor => null; + + public PerSecond MinEngineSpeedPostUpshift => null; + public Second ATLookAheadTime => null; + public double[][] ShiftSpeedsTCToLocked => null; + + public double? AccelerationFactor => null; + + public virtual TableData LoadStageShiftLines => null; + public virtual IList<double> LoadStageThresholdsUp => null; + public virtual IList<double> LoadStageThresholdsDown => null; + + public virtual Second PowershiftShiftTime => + GetNode(XMLNames.DriverModel_ShiftStrategyParameters_PowershiftShiftTime, required: false) + ?.InnerText.ToDouble().SI<Second>() ?? 0.8.SI<Second>(); #endregion #region Implementation of ITorqueConverterEngineeringShiftParameterInputData - public virtual MeterPerSquareSecond CLUpshiftMinAcceleration - { - get { - return GetNode(XMLNames.TorqueConverter_CLUpshiftMinAcceleration, required: false) - ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? - DeclarationData.Gearbox.UpshiftMinAcceleration; - } - } - - public virtual MeterPerSquareSecond CCUpshiftMinAcceleration - { - get { - return GetNode(XMLNames.TorqueConverter_CCUpshiftMinAcceleration, required: false) - ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? - DeclarationData.Gearbox.UpshiftMinAcceleration; - } - } + public virtual MeterPerSquareSecond CLUpshiftMinAcceleration => + GetNode(XMLNames.TorqueConverter_CLUpshiftMinAcceleration, required: false) + ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? + DeclarationData.Gearbox.UpshiftMinAcceleration; + + public virtual MeterPerSquareSecond CCUpshiftMinAcceleration => + GetNode(XMLNames.TorqueConverter_CCUpshiftMinAcceleration, required: false) + ?.InnerText.ToDouble().SI<MeterPerSquareSecond>() ?? + DeclarationData.Gearbox.UpshiftMinAcceleration; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringInputDataProvider.cs index 5ffecf30c49ef2c01bb4696847d10ffcac99e254..5c8b3e2d7d29239c0406be2c442704a75a6d57ef 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringInputDataProvider.cs @@ -74,15 +74,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IEngineeringInputDataProvider - public virtual IEngineeringJobInputData JobInputData - { - get { return JobData ?? (JobData = Reader.JobData); } - } + public virtual IEngineeringJobInputData JobInputData => JobData ?? (JobData = Reader.JobData); - public virtual IDriverEngineeringInputData DriverInputData - { - get { return DriverData ?? (DriverData = Reader.DriverModel); } - } + public virtual IDriverEngineeringInputData DriverInputData => DriverData ?? (DriverData = Reader.DriverModel); //public virtual IGearshiftEngineeringInputData GearshiftInputData { get { return DriverInputData.GearshiftInputData; } } @@ -93,7 +87,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -110,7 +104,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLEngineeringInputDataProviderV10(XmlDocument xmldoc, string fileName) : base(xmldoc, fileName) { } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } - + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs index 74e816324725d92a4c5f010f9318a76597e2eef4..c69db5c51fa67e9ae9c1808d0ddf9f464150717a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs @@ -71,66 +71,38 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } - public virtual IHybridStrategyParameters HybridStrategyParameters - { - get { return null; } - } + public virtual IHybridStrategyParameters HybridStrategyParameters => null; - public virtual IList<ICycleData> Cycles - { - get { return (_cycles ?? (_cycles = Reader.CreateCycles)).Cycles; } - } + public virtual IList<ICycleData> Cycles => (_cycles ?? (_cycles = Reader.CreateCycles)).Cycles; - public virtual IEngineEngineeringInputData EngineOnly - { - get { return _engineOnly ?? (_engineOnly = Reader.CreateEngineOnly); } - } + public virtual IEngineEngineeringInputData EngineOnly => _engineOnly ?? (_engineOnly = Reader.CreateEngineOnly); - public virtual TableData PTOCycleWhileDrive { get { return null; } } + public virtual TableData PTOCycleWhileDrive => null; - public string ShiftStrategy { get { return null; } } + public string ShiftStrategy => null; public virtual VectoSimulationJobType JobType { get; } - public virtual string JobName - { - get { - return JobType == VectoSimulationJobType.EngineOnlySimulation - ? EngineOnly.Model - : (GetAttribute(BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(XMLNames.Component_Vehicle)), "id") ?? - Vehicle.Model + " " + Vehicle.Manufacturer); - } - } + public virtual string JobName => + JobType == VectoSimulationJobType.EngineOnlySimulation + ? EngineOnly.Model + : (GetAttribute(BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(XMLNames.Component_Vehicle)), "id") ?? + Vehicle.Model + " " + Vehicle.Manufacturer); - public virtual bool SavedInDeclarationMode - { - get { return false; } - } + public virtual bool SavedInDeclarationMode => false; - public virtual IVehicleEngineeringInputData Vehicle - { - get { return _vehicle ?? (_vehicle = Reader.CreateVehicle); } - } + public virtual IVehicleEngineeringInputData Vehicle => _vehicle ?? (_vehicle = Reader.CreateVehicle); - IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle - { - get { return Vehicle; } - } + IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle => Vehicle; - public string SourePath - { - get { return FileName == null ? null : Path.GetDirectoryName(Path.GetFullPath(FileName)); } - } + public string SourePath => FileName == null ? null : Path.GetDirectoryName(Path.GetFullPath(FileName)); - public IXMLEngineeringInputData InputData - { - get { return InputProvider; } - } + public IXMLEngineeringInputData InputData => InputProvider; #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -151,7 +123,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of XMLEngineeringJobInputDataProviderV07 - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringOverspeed.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringOverspeed.cs index 265403dfaa6fbf04ea132034c59bd2fc330f4025..1fbebfd71cb04e672c4f4f8b69a3ac51af8c3670 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringOverspeed.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringOverspeed.cs @@ -58,31 +58,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IOverSpeedEcoRollDeclarationInputData - public virtual bool Enabled - { - get { return GetNode(XMLNames.DriverModel_Overspeed_Mode, required: false)?.InnerText.Equals("Overspeed", StringComparison.InvariantCultureIgnoreCase) ?? false; } - } + public virtual bool Enabled => GetNode(XMLNames.DriverModel_Overspeed_Mode, required: false)?.InnerText.Equals("Overspeed", StringComparison.InvariantCultureIgnoreCase) ?? false; #endregion #region Implementation of IOverSpeedEcoRollEngineeringInputData - public virtual MeterPerSecond MinSpeed - { - get { return GetNode(XMLNames.DriverModel_Overspeed_MinSpeed, required: false)?.InnerText.ToDouble().KMPHtoMeterPerSecond(); } - } + public virtual MeterPerSecond MinSpeed => GetNode(XMLNames.DriverModel_Overspeed_MinSpeed, required: false)?.InnerText.ToDouble().KMPHtoMeterPerSecond(); - public virtual MeterPerSecond OverSpeed - { - get { return GetNode(XMLNames.DriverModel_Overspeed_AllowedOverspeed, required: false)?.InnerText.ToDouble().KMPHtoMeterPerSecond(); } - } + public virtual MeterPerSecond OverSpeed => GetNode(XMLNames.DriverModel_Overspeed_AllowedOverspeed, required: false)?.InnerText.ToDouble().KMPHtoMeterPerSecond(); - public virtual MeterPerSecond UnderSpeed - { - get { - return GetNode(XMLNames.DriverModel_Overspeed_AllowedUnderspeed, required: false)?.InnerText.ToDouble().KMPHtoMeterPerSecond(); - } - } + public virtual MeterPerSecond UnderSpeed => GetNode(XMLNames.DriverModel_Overspeed_AllowedUnderspeed, required: false)?.InnerText.ToDouble().KMPHtoMeterPerSecond(); #endregion } @@ -99,10 +85,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLEngineeringOverspeedV10(IXMLEngineeringDriverData driverData, XmlNode node) : base(driverData, node) { } - public override bool Enabled - { - get { return XmlConvert.ToBoolean(GetNode(XMLNames.DriverModel_Overspeed_Enabled, required: false)?.InnerText ?? "false"); } - } - + public override bool Enabled => XmlConvert.ToBoolean(GetNode(XMLNames.DriverModel_Overspeed_Enabled, required: false)?.InnerText ?? "false"); } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringPCCInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringPCCInputDataProvider.cs index 0d8c253b43067e457cd654c675586ee509cf81a0..c93814bfac028463e2932d447a8669ecb03a8f53 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringPCCInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringPCCInputDataProvider.cs @@ -19,41 +19,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider { #region Implementation of IPCCEngineeringInputData - public MeterPerSecond PCCEnabledSpeed - { - get { return GetDouble("EnablingSpeed", DeclarationData.Driver.PCC.PCCEnableSpeed.AsKmph).KMPHtoMeterPerSecond(); } - } - - public MeterPerSecond MinSpeed - { - get { return GetDouble("MinSpeed", DeclarationData.Driver.PCC.MinSpeed.AsKmph).KMPHtoMeterPerSecond(); } - } - - public Meter PreviewDistanceUseCase1 - { - get { - return GetDouble("PreviewDistanceUseCase1", DeclarationData.Driver.PCC.PreviewDistanceUseCase1.Value()).SI<Meter>(); - } - } - - public Meter PreviewDistanceUseCase2 - { - get { - return GetDouble("PreviewDistanceUseCase2", DeclarationData.Driver.PCC.PreviewDistanceUseCase2.Value()).SI<Meter>(); - } - } - - public MeterPerSecond Underspeed - { - get { return GetDouble("AllowedUnderspeed", DeclarationData.Driver.PCC.Underspeed.AsKmph).KMPHtoMeterPerSecond(); } - } - - public MeterPerSecond OverspeedUseCase3 - { - get { - return GetDouble("AllowedOverspeed", DeclarationData.Driver.PCC.OverspeedUseCase3.AsKmph).KMPHtoMeterPerSecond(); - } - } + public MeterPerSecond PCCEnabledSpeed => GetDouble("EnablingSpeed", DeclarationData.Driver.PCC.PCCEnableSpeed.AsKmph).KMPHtoMeterPerSecond(); + + public MeterPerSecond MinSpeed => GetDouble("MinSpeed", DeclarationData.Driver.PCC.MinSpeed.AsKmph).KMPHtoMeterPerSecond(); + + public Meter PreviewDistanceUseCase1 => GetDouble("PreviewDistanceUseCase1", DeclarationData.Driver.PCC.PreviewDistanceUseCase1.Value()).SI<Meter>(); + + public Meter PreviewDistanceUseCase2 => GetDouble("PreviewDistanceUseCase2", DeclarationData.Driver.PCC.PreviewDistanceUseCase2.Value()).SI<Meter>(); + + public MeterPerSecond Underspeed => GetDouble("AllowedUnderspeed", DeclarationData.Driver.PCC.Underspeed.AsKmph).KMPHtoMeterPerSecond(); + + public MeterPerSecond OverspeedUseCase3 => GetDouble("AllowedOverspeed", DeclarationData.Driver.PCC.OverspeedUseCase3.AsKmph).KMPHtoMeterPerSecond(); #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringRetarderDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringRetarderDataProvider.cs index 0cce5a065b51adabba1d461e62debf9ddc7555d7..f7a6d3883bf47085b91fcccd67f65a4abbdd8525 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringRetarderDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringRetarderDataProvider.cs @@ -57,28 +57,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider SourceType = (vehicle as IXMLResource).DataSource.SourceFile == fsBasePath ? DataSourceType.XMLEmbedded : DataSourceType.XMLFile; } - public virtual RetarderType Type - { - get { return Vehicle.RetarderType; } - } + public virtual RetarderType Type => Vehicle.RetarderType; - public virtual double Ratio - { - get { return Vehicle.RetarderRatio; } - } + public virtual double Ratio => Vehicle.RetarderRatio; - public virtual TableData LossMap - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry, - AttributeMappings.RetarderLossmapMapping); - } - } + public virtual TableData LossMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry, + AttributeMappings.RetarderLossmapMapping); #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -99,7 +89,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of XMLEngineeringRetarderDataProviderV07 - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringTorqueConverterDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringTorqueConverterDataProvider.cs index 0aef9b3f4952fae4737b16e9c1b3d698c8c44eb6..1cc396acd9102b341ee038a0b8cd1b21f890edf5 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringTorqueConverterDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringTorqueConverterDataProvider.cs @@ -60,54 +60,35 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Impl #region Implementation of ITorqueConverterDeclarationInputData - public virtual TableData TCData - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry, - AttributeMappings.TorqueConverterDataMapping); - } - } + public virtual TableData TCData => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry, + AttributeMappings.TorqueConverterDataMapping); #endregion #region Implementation of ITorqueConverterEngineeringInputData - public virtual PerSecond ReferenceRPM - { - get { - return GetNode(XMLNames.TorqueConverter_ReferenceRPM)?.InnerText.ToDouble().RPMtoRad() ?? - DeclarationData.TorqueConverter.ReferenceRPM; - } - } + public virtual PerSecond ReferenceRPM => + GetNode(XMLNames.TorqueConverter_ReferenceRPM)?.InnerText.ToDouble().RPMtoRad() ?? + DeclarationData.TorqueConverter.ReferenceRPM; - public virtual KilogramSquareMeter Inertia - { - get { - return GetNode(XMLNames.TorqueConverter_Inertia)?.InnerText.ToDouble().SI<KilogramSquareMeter>() ?? - 0.SI<KilogramSquareMeter>(); - } - } + public virtual KilogramSquareMeter Inertia => + GetNode(XMLNames.TorqueConverter_Inertia)?.InnerText.ToDouble().SI<KilogramSquareMeter>() ?? + 0.SI<KilogramSquareMeter>(); - public virtual TableData ShiftPolygon - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.TorqueConverter_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry, - AttributeMappings.ShiftPolygonMapping); - } - } + public virtual TableData ShiftPolygon => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.TorqueConverter_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry, + AttributeMappings.ShiftPolygonMapping); - public virtual PerSecond MaxInputSpeed - { - get { return GetNode(XMLNames.TorqueConverter_MaxInputSpeed)?.InnerText.ToDouble().RPMtoRad(); } - } + public virtual PerSecond MaxInputSpeed => GetNode(XMLNames.TorqueConverter_MaxInputSpeed)?.InnerText.ToDouble().RPMtoRad(); #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } #endregion @@ -127,7 +108,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Impl #region Overrides of XMLEngineeringTorqueConverterDataProviderV07 - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleComponentsDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleComponentsDataProvider.cs index def7f434d177cb2b5435073ec0d2fe5f0201fdb3..9f1de3fc1d4d04e85d8e8a9f20c1008b3f86ec7a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleComponentsDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleComponentsDataProvider.cs @@ -63,65 +63,36 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of IVehicleComponentsEngineering - public override DataSource DataSource - { - get { return ((IXMLResource)Vehicle).DataSource; } - } + public override DataSource DataSource => ((IXMLResource)Vehicle).DataSource; public IXMLComponentsReader ComponentReader { protected get; set; } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } - public virtual IAirdragEngineeringInputData AirdragInputData - { - get { return _airdragInputData ?? (_airdragInputData = ComponentReader.AirdragInputData); } - } + public virtual IAirdragEngineeringInputData AirdragInputData => _airdragInputData ?? (_airdragInputData = ComponentReader.AirdragInputData); - public virtual IGearboxEngineeringInputData GearboxInputData - { - get { return _gearboxInputData ?? (_gearboxInputData = ComponentReader.GearboxData); } - } - public virtual ITorqueConverterEngineeringInputData TorqueConverterInputData - { - get { return _torqueConverterInputData ?? (_torqueConverterInputData = ComponentReader.TorqueConverter); } - } + public virtual IGearboxEngineeringInputData GearboxInputData => _gearboxInputData ?? (_gearboxInputData = ComponentReader.GearboxData); - public virtual IAxleGearInputData AxleGearInputData - { - get { return _axleGearInputData ?? (_axleGearInputData = ComponentReader.AxleGearInputData); } - } - - public virtual IAngledriveInputData AngledriveInputData - { - get { return _angledriveInputData ?? (_angledriveInputData = ComponentReader.AngularGearInputData); } - } + public virtual ITorqueConverterEngineeringInputData TorqueConverterInputData => _torqueConverterInputData ?? (_torqueConverterInputData = ComponentReader.TorqueConverter); - public virtual IEngineEngineeringInputData EngineInputData - { - get { return _engineInputData ?? (_engineInputData = ComponentReader.EngineInputData); } - } + public virtual IAxleGearInputData AxleGearInputData => _axleGearInputData ?? (_axleGearInputData = ComponentReader.AxleGearInputData); - public virtual IAuxiliariesEngineeringInputData AuxiliaryInputData - { - get { return _auxInputData ?? (_auxInputData = ComponentReader.AuxiliaryData); } - } + public virtual IAngledriveInputData AngledriveInputData => _angledriveInputData ?? (_angledriveInputData = ComponentReader.AngularGearInputData); - public virtual IRetarderInputData RetarderInputData - { - get { return _retarderInputData ?? (_retarderInputData = ComponentReader.RetarderInputData); } - } + public virtual IEngineEngineeringInputData EngineInputData => _engineInputData ?? (_engineInputData = ComponentReader.EngineInputData); - public IPTOTransmissionInputData PTOTransmissionInputData { get { return Vehicle; } } + public virtual IAuxiliariesEngineeringInputData AuxiliaryInputData => _auxInputData ?? (_auxInputData = ComponentReader.AuxiliaryData); - public IAxlesEngineeringInputData AxleWheels - { - get { return _axleWheels ?? (_axleWheels = ComponentReader.AxlesEngineeringInputData); } - } + public virtual IRetarderInputData RetarderInputData => _retarderInputData ?? (_retarderInputData = ComponentReader.RetarderInputData); - public virtual IElectricStorageEngineeringInputData ElectricStorage { get { return null; } } - public virtual IElectricMachinesEngineeringInputData ElectricMachines { get { return null; } } + public IPTOTransmissionInputData PTOTransmissionInputData => Vehicle; + + public IAxlesEngineeringInputData AxleWheels => _axleWheels ?? (_axleWheels = ComponentReader.AxlesEngineeringInputData); + + public virtual IElectricStorageEngineeringInputData ElectricStorage => null; + public virtual IElectricMachinesEngineeringInputData ElectricMachines => null; #endregion @@ -142,7 +113,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLEngineeringVehicleComponentsDataProviderV10(IXMLEngineeringVehicleData vehicle, XmlNode baseNode, string source) : base(vehicle, baseNode, source) { } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } - + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs index e2fc9ac0e0478d775e7f9389a50c21822aa1bbde..30f573e8ee539531a322e797643f652666c36fe6 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs @@ -70,27 +70,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public IXMLComponentsReader ComponentReader { protected get; set; } - public virtual XmlElement ComponentNode - { - get { return _componentNode ?? (_componentNode = GetNode(XMLNames.Vehicle_Components) as XmlElement); } - } + public virtual XmlElement ComponentNode => _componentNode ?? (_componentNode = GetNode(XMLNames.Vehicle_Components) as XmlElement); #region Implementation of IComponentInputData - public override CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public override CertificationMethod CertificationMethod => CertificationMethod.NotCertified; - public override string CertificationNumber - { - get { return "N.A."; } - } + public override string CertificationNumber => "N.A."; - public override DigestData DigestValue - { - get { return null; } - } + public override DigestData DigestValue => null; #endregion @@ -98,165 +86,85 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public string Identifier { get; } - public bool ExemptedVehicle - { - get { return false; } - } + public bool ExemptedVehicle => false; - public virtual string VIN - { - get { return GetString(XMLNames.Vehicle_VIN); } - } + public virtual string VIN => GetString(XMLNames.Vehicle_VIN); - public virtual LegislativeClass? LegislativeClass - { - get { return GetString(XMLNames.Vehicle_LegislativeClass).ParseEnum<LegislativeClass>(); } - } + public virtual LegislativeClass? LegislativeClass => GetString(XMLNames.Vehicle_LegislativeClass).ParseEnum<LegislativeClass>(); - public virtual VehicleCategory VehicleCategory - { - get { - return GetNode(XMLNames.Vehicle_VehicleCategory, required: false)?.InnerText.ParseEnum<VehicleCategory>() ?? - VehicleCategory.Unknown; - } - } + public virtual VehicleCategory VehicleCategory => + GetNode(XMLNames.Vehicle_VehicleCategory, required: false)?.InnerText.ParseEnum<VehicleCategory>() ?? + VehicleCategory.Unknown; - public virtual AxleConfiguration AxleConfiguration - { - get { return AxleConfigurationHelper.Parse(GetString(XMLNames.Vehicle_AxleConfiguration)); } - } + public virtual AxleConfiguration AxleConfiguration => AxleConfigurationHelper.Parse(GetString(XMLNames.Vehicle_AxleConfiguration)); - public virtual Kilogram CurbMassChassis - { - get { return GetDouble(XMLNames.Vehicle_CurbMassChassis).SI<Kilogram>(); } - } + public virtual Kilogram CurbMassChassis => GetDouble(XMLNames.Vehicle_CurbMassChassis).SI<Kilogram>(); - public virtual Kilogram CurbMassExtra - { - get { return GetDouble(XMLNames.Vehicle_CurbMassExtra).SI<Kilogram>(); } - } + public virtual Kilogram CurbMassExtra => GetDouble(XMLNames.Vehicle_CurbMassExtra).SI<Kilogram>(); - public virtual Kilogram GrossVehicleMassRating - { - get { return GetDouble(XMLNames.Vehicle_GrossVehicleMass).SI<Kilogram>(); } - } + public virtual Kilogram GrossVehicleMassRating => GetDouble(XMLNames.Vehicle_GrossVehicleMass).SI<Kilogram>(); - public virtual string ManufacturerAddress - { - get { return GetString(XMLNames.Component_ManufacturerAddress); } - } + public virtual string ManufacturerAddress => GetString(XMLNames.Component_ManufacturerAddress); - public virtual PerSecond EngineIdleSpeed - { - get { return GetDouble(XMLNames.Vehicle_IdlingSpeed).RPMtoRad(); } - } + public virtual PerSecond EngineIdleSpeed => GetDouble(XMLNames.Vehicle_IdlingSpeed).RPMtoRad(); - public bool VocationalVehicle - { - get { return false; } - } + public bool VocationalVehicle => false; - public bool SleeperCab - { - get { return false; } - } + public bool SleeperCab => false; - public virtual bool? AirdragModifiedMultistage - { - get { return null; } - } + public virtual bool? AirdragModifiedMultistage => null; - public TankSystem? TankSystem - { - get { - return ElementExists(XMLNames.Vehicle_NgTankSystem) - ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) - : (TankSystem?)null; - } - } + public TankSystem? TankSystem => + ElementExists(XMLNames.Vehicle_NgTankSystem) + ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) + : (TankSystem?)null; - - public bool ZeroEmissionVehicle - { - get { return false; } - } - public bool HybridElectricHDV - { - get { return false; } - } + public bool ZeroEmissionVehicle => false; - public bool DualFuelVehicle - { - get { return false; } - } + public bool HybridElectricHDV => false; - public Watt MaxNetPower1 - { - get { return null; } - } + public bool DualFuelVehicle => false; - public Watt MaxNetPower2 - { - get { return null; } - } + public Watt MaxNetPower1 => null; + + public Watt MaxNetPower2 => null; public string ExemptedTechnology { get; } - public virtual RegistrationClass? RegisteredClass { get { return RegistrationClass.unknown;} } - public virtual int? NumberPassengerSeatsUpperDeck { get { return 0; } } - public virtual int? NumberPassengerSeatsLowerDeck { get { return 0; } } - public int? NumberPassengersStandingLowerDeck { get { return 0; } } - public int? NumberPassengersStandingUpperDeck { get { return 0; } } + public virtual RegistrationClass? RegisteredClass => RegistrationClass.unknown; + public virtual int? NumberPassengerSeatsUpperDeck => 0; + public virtual int? NumberPassengerSeatsLowerDeck => 0; + public int? NumberPassengersStandingLowerDeck => 0; + public int? NumberPassengersStandingUpperDeck => 0; public CubicMeter CargoVolume { get; } - public virtual VehicleCode? VehicleCode { get { return VectoCommon.Models.VehicleCode.NOT_APPLICABLE; } } - public virtual bool? LowEntry { get { return false; } } - public virtual bool Articulated { get { return false; } } - + public virtual VehicleCode? VehicleCode => VectoCommon.Models.VehicleCode.NOT_APPLICABLE; + public virtual bool? LowEntry => false; + public virtual bool Articulated => false; - public virtual Meter Width { get { return null; } } - public virtual Meter EntranceHeight { get { return null; } } - public ConsumerTechnology? DoorDriveTechnology { get { return ConsumerTechnology.Unknown; } } + + public virtual Meter Width => null; + public virtual Meter EntranceHeight => null; + public ConsumerTechnology? DoorDriveTechnology => ConsumerTechnology.Unknown; public virtual VehicleDeclarationType VehicleDeclarationType { get; } - public TableData MaxPropulsionTorque - { - get { return null; } - } + public TableData MaxPropulsionTorque => null; - IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components - { - get { return null; } - } + IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components => null; - IAdvancedDriverAssistantSystemDeclarationInputData IVehicleDeclarationInputData.ADAS - { - get { return null; } - } + IAdvancedDriverAssistantSystemDeclarationInputData IVehicleDeclarationInputData.ADAS => null; - public virtual GearshiftPosition PTO_DriveGear { get { return null; } } - public virtual PerSecond PTO_DriveEngineSpeed { get { return null; } } + public virtual GearshiftPosition PTO_DriveGear => null; + public virtual PerSecond PTO_DriveEngineSpeed => null; - public double InitialSOC - { - get { return double.NaN; } - } + public double InitialSOC => double.NaN; - public VectoSimulationJobType VehicleType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public VectoSimulationJobType VehicleType => VectoSimulationJobType.ConventionalVehicle; - public IAdvancedDriverAssistantSystemsEngineering ADAS - { - get { return null; } - } + public IAdvancedDriverAssistantSystemsEngineering ADAS => null; - public virtual Kilogram Loading - { - get { return GetDouble(XMLNames.Vehicle_Loading).SI<Kilogram>(); } - } + public virtual Kilogram Loading => GetDouble(XMLNames.Vehicle_Loading).SI<Kilogram>(); public virtual Meter DynamicTyreRadius { @@ -301,79 +209,47 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } - public virtual Meter Height - { - get { return GetNode("VehicleHeight")?.InnerText.ToDouble().SI<Meter>(); } - } + public virtual Meter Height => GetNode("VehicleHeight")?.InnerText.ToDouble().SI<Meter>(); - public TableData ElectricMotorTorqueLimits - { - get { return null; } - } + public TableData ElectricMotorTorqueLimits => null; - public virtual Meter Length { get { return null; } } + public virtual Meter Length => null; - public IVehicleComponentsEngineering Components - { - get { return _components ?? (_components = ComponentReader.ComponentInputData); } - } + public IVehicleComponentsEngineering Components => _components ?? (_components = ComponentReader.ComponentInputData); #endregion - public virtual RetarderType RetarderType - { - get { return GetString(XMLNames.Vehicle_RetarderType).ParseEnum<RetarderType>(); } - } + public virtual RetarderType RetarderType => GetString(XMLNames.Vehicle_RetarderType).ParseEnum<RetarderType>(); - public virtual double RetarderRatio - { - get { return GetDouble(XMLNames.Vehicle_RetarderRatio); } - } + public virtual double RetarderRatio => GetDouble(XMLNames.Vehicle_RetarderRatio); - public virtual AngledriveType AngledriveType - { - get { return GetString(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); } - } + public virtual AngledriveType AngledriveType => GetString(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); public virtual IXMLEngineeringJobInputData Job { get; } #region Implementation of IPTOTransmissionInputData - public virtual string PTOTransmissionType - { - get { return GetString(XMLNames.Vehicle_PTOType); } - } + public virtual string PTOTransmissionType => GetString(XMLNames.Vehicle_PTOType); - public virtual TableData PTOLossMap - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.Vehicle_PTOIdleLossMap, XMLNames.Vehicle_PTOIdleLossMap_Entry, - AttributeMappings.PTOLossMap); - } - } + public virtual TableData PTOLossMap => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.Vehicle_PTOIdleLossMap, XMLNames.Vehicle_PTOIdleLossMap_Entry, + AttributeMappings.PTOLossMap); - public virtual TableData PTOCycleDuringStop - { - get { - return XMLHelper.ReadEntriesOrResource( - BaseNode, DataSource.SourcePath, XMLNames.Vehicle_PTOCycle, XMLNames.Vehicle_PTOCycle_Entry, - AttributeMappings.PTOCycleMap); - } - } + public virtual TableData PTOCycleDuringStop => + XMLHelper.ReadEntriesOrResource( + BaseNode, DataSource.SourcePath, XMLNames.Vehicle_PTOCycle, XMLNames.Vehicle_PTOCycle_Entry, + AttributeMappings.PTOCycleMap); - public TableData PTOCycleWhileDriving { get { return null;} } + public TableData PTOCycleWhileDriving => null; #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -395,10 +271,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Overrides of XMLEngineeringVehicleDataProviderV07 - protected override XNamespace SchemaNamespace - { - get { return NAMESPACE_URI; } - } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; #endregion } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs index 3f7e1e631b54ef6345de61d0f877b69d640886af..b9b910eb1ca559ee042f35390c5fcd63999ba072 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs @@ -57,44 +57,27 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #region Implementation of ITyreDeclarationInputData - public virtual string Dimension - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_Dimension, required:false)?.InnerText; } - } + public virtual string Dimension => GetNode(XMLNames.AxleWheels_Axles_Axle_Dimension, required:false)?.InnerText; - public virtual double RollResistanceCoefficient - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_RRCISO, required: false)?.InnerText.ToDouble() ?? double.NaN; } - } + public virtual double RollResistanceCoefficient => GetNode(XMLNames.AxleWheels_Axles_Axle_RRCISO, required: false)?.InnerText.ToDouble() ?? double.NaN; - public virtual Newton TyreTestLoad - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_FzISO, required: false)?.InnerText.ToDouble().SI<Newton>(); } - } + public virtual Newton TyreTestLoad => GetNode(XMLNames.AxleWheels_Axles_Axle_FzISO, required: false)?.InnerText.ToDouble().SI<Newton>(); - public virtual string FuelEfficiencyClass { get { return DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); } } + public virtual string FuelEfficiencyClass => DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); #endregion #region Implementation of ITyreEngineeringInputData - public virtual KilogramSquareMeter Inertia - { - get { return GetNode(XMLNames.AxleWheels_Axles_Axle_Inertia, required: false)?.InnerText.ToDouble().SI<KilogramSquareMeter>(); } - } + public virtual KilogramSquareMeter Inertia => GetNode(XMLNames.AxleWheels_Axles_Axle_Inertia, required: false)?.InnerText.ToDouble().SI<KilogramSquareMeter>(); - public virtual Meter DynamicTyreRadius - { - get { - return GetNode(XMLNames.AxleWheels_Axles_Axle_DynamicTyreRadius, required: false)?.InnerText.ToDouble().SI(Unit.SI.Milli.Meter).Cast<Meter>(); - } - } + public virtual Meter DynamicTyreRadius => GetNode(XMLNames.AxleWheels_Axles_Axle_DynamicTyreRadius, required: false)?.InnerText.ToDouble().SI(Unit.SI.Milli.Meter).Cast<Meter>(); #endregion #region Overrides of AbstractXMLResource - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; protected override DataSourceType SourceType { get; } @@ -112,6 +95,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public XMLTyreEngineeringDataProviderV10TEST(IXMLEngineeringVehicleData vehicle, XmlNode baseNode, string source) : base(vehicle, baseNode, source) { } - protected override XNamespace SchemaNamespace { get { return NAMESPACE_URI; } } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs index 825bde69ac34d7c62058911123ccec2d27d1ef8e..43cbf36fbda6cc67828793ff11407b11498ab784 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs @@ -61,18 +61,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader ? BaseNode : BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(component)); var dataNode = requireDataNode - ? componentNode?.SelectSingleNode(string.Format("./*[local-name()='{0}']", XMLNames.ComponentDataWrapper)) + ? componentNode?.SelectSingleNode($"./*[local-name()='{XMLNames.ComponentDataWrapper}']") : componentNode; var componentResourceNode = componentNode?.SelectSingleNode( - string.Format( - "./*[local-name()='{0}' and @{3}='{4}']", XMLNames.ExternalResource, - XMLNames.ExtResource_Component_Attr, component, XMLNames.ExtResource_Type_Attr, - XMLNames.ExtResource_Type_Value_XML)) ?? + $"./*[local-name()='{XMLNames.ExternalResource}'" + + $" and @{XMLNames.ExtResource_Type_Attr}='{XMLNames.ExtResource_Type_Value_XML}']") ?? BaseNode?.SelectSingleNode( - string.Format( - "./*[local-name()='{0}' and @{1}='{2}' and @{3}='{4}']", XMLNames.ExternalResource, - XMLNames.ExtResource_Component_Attr, component, XMLNames.ExtResource_Type_Attr, - XMLNames.ExtResource_Type_Value_XML)); + $"./*[local-name()='{XMLNames.ExternalResource}'" + + $" and @{XMLNames.ExtResource_Component_Attr}='{component}'" + + $" and @{XMLNames.ExtResource_Type_Attr}='{XMLNames.ExtResource_Type_Value_XML}']"); if (dataNode != null && componentResourceNode == null) { var type = dataNode.SchemaInfo.SchemaType; var version = XMLHelper.GetXsdType(type); @@ -113,7 +110,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader ? componentDocument.DocumentElement : componentDocument.DocumentElement.SelectSingleNode(XMLHelper.QueryLocalName(component)); var docDataNode = - docComponentNode?.SelectSingleNode(string.Format("./*[local-name()='{0}']", XMLNames.ComponentDataWrapper)) ?? + docComponentNode?.SelectSingleNode($"./*[local-name()='{XMLNames.ComponentDataWrapper}']") ?? docComponentNode; var type = (docDataNode)?.SchemaInfo.SchemaType; diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLComponentsEngineeringReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLComponentsEngineeringReader.cs index 53ff2067b479310c6139a8a2c376497c7bd074e1..8b058dd1e629aba0a7efe5df7cad5243830a8ffe 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLComponentsEngineeringReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLComponentsEngineeringReader.cs @@ -90,81 +90,35 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader #region Implementation of IEngineeringComponentsFactory - public virtual IAxleGearInputData AxleGearInputData - { - get { - return _axleGearInputData ?? (_axleGearInputData = CreateComponent(XMLNames.Component_Axlegear, AxlegearCreator)); - } - } - - public virtual IAngledriveInputData AngularGearInputData - { - get { - return _angularGearInputData ?? (_angularGearInputData = CreateComponent( - XMLNames.Component_Angledrive, AngledriveCreator, false, true)); - } - } - - public virtual IEngineEngineeringInputData EngineInputData - { - get { return _engineInputData ?? (_engineInputData = CreateComponent(XMLNames.Component_Engine, EngineCreator)); } - } + public virtual IAxleGearInputData AxleGearInputData => _axleGearInputData ?? (_axleGearInputData = CreateComponent(XMLNames.Component_Axlegear, AxlegearCreator)); - public virtual IRetarderInputData RetarderInputData - { - get { - return _retarderInputData ?? (_retarderInputData = CreateComponent( - XMLNames.Component_Retarder, RetarderCreator, false, true)); - } - } + public virtual IAngledriveInputData AngularGearInputData => + _angularGearInputData ?? (_angularGearInputData = CreateComponent( + XMLNames.Component_Angledrive, AngledriveCreator, false, true)); - public virtual IAuxiliariesEngineeringInputData AuxiliaryData - { - get { - return _auxiliaryData ?? (_auxiliaryData = CreateComponent(XMLNames.Component_Auxiliaries, AuxiliariesCreator)); - } - } + public virtual IEngineEngineeringInputData EngineInputData => _engineInputData ?? (_engineInputData = CreateComponent(XMLNames.Component_Engine, EngineCreator)); - public virtual IGearboxEngineeringInputData GearboxData - { - get { return _gearboxData ?? (_gearboxData = CreateComponent(XMLNames.Component_Gearbox, GearboxCreator)); } - } + public virtual IRetarderInputData RetarderInputData => + _retarderInputData ?? (_retarderInputData = CreateComponent( + XMLNames.Component_Retarder, RetarderCreator, false, true)); - public virtual IPTOTransmissionInputData PTOData - { - get { return Vehicle; } - } + public virtual IAuxiliariesEngineeringInputData AuxiliaryData => _auxiliaryData ?? (_auxiliaryData = CreateComponent(XMLNames.Component_Auxiliaries, AuxiliariesCreator)); - public virtual IAirdragEngineeringInputData AirdragInputData - { - get { - return _airdragInputData ?? (_airdragInputData = CreateComponent(XMLNames.Component_AirDrag, AirdragCreator)); - } - } + public virtual IGearboxEngineeringInputData GearboxData => _gearboxData ?? (_gearboxData = CreateComponent(XMLNames.Component_Gearbox, GearboxCreator)); - public virtual IAxlesEngineeringInputData AxlesEngineeringInputData - { - get { return _axlesInputData ?? (_axlesInputData = CreateComponent(XMLNames.Component_AxleWheels, AxlesCreator)); } - } + public virtual IPTOTransmissionInputData PTOData => Vehicle; - public virtual ITorqueConverterEngineeringInputData TorqueConverter - { - get { - return _torqueConverterInputData ?? (_torqueConverterInputData = CreateComponent( - XMLNames.Component_TorqueConverter, TorqueConverterCreator, true, true)); - } - } + public virtual IAirdragEngineeringInputData AirdragInputData => _airdragInputData ?? (_airdragInputData = CreateComponent(XMLNames.Component_AirDrag, AirdragCreator)); - public virtual ITyreEngineeringInputData Tyre - { - get { return _tyre ?? (_tyre = CreateComponent(XMLNames.AxleWheels_Axles_Axle_Tyre, TyreCreator)); } - } + public virtual IAxlesEngineeringInputData AxlesEngineeringInputData => _axlesInputData ?? (_axlesInputData = CreateComponent(XMLNames.Component_AxleWheels, AxlesCreator)); - public virtual IVehicleComponentsEngineering ComponentInputData { get { - return _components ?? (_components = CreateComponent(XMLNames.Vehicle_Components, ComponentsCreator, requireDataNode:false)); - } } + public virtual ITorqueConverterEngineeringInputData TorqueConverter => + _torqueConverterInputData ?? (_torqueConverterInputData = CreateComponent( + XMLNames.Component_TorqueConverter, TorqueConverterCreator, true, true)); + public virtual ITyreEngineeringInputData Tyre => _tyre ?? (_tyre = CreateComponent(XMLNames.AxleWheels_Axles_Axle_Tyre, TyreCreator)); + public virtual IVehicleComponentsEngineering ComponentInputData => _components ?? (_components = CreateComponent(XMLNames.Vehicle_Components, ComponentsCreator, requireDataNode:false)); public IAxleEngineeringInputData CreateAxle(XmlNode axleNode) @@ -327,9 +281,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader public XMLComponentsEngineeringReaderV10TEST(IXMLEngineeringVehicleData vehicle, XmlNode componentsNode) : base(vehicle, componentsNode) { } - public override ITyreEngineeringInputData Tyre - { - get { return _tyre ?? (_tyre = CreateComponent("Tire", TyreCreator)); } - } + public override ITyreEngineeringInputData Tyre => _tyre ?? (_tyre = CreateComponent("Tire", TyreCreator)); } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLDriverDataReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLDriverDataReader.cs index f0fec049710b9777487bd48737e2d1d1b8c8a58d..eb77c9be25f6098680102f9545e702bd97916c10 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLDriverDataReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLDriverDataReader.cs @@ -109,13 +109,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader.Impl { } } - public IGearshiftEngineeringInputData ShiftParameters - { - get { - return CreateData( - XMLNames.DriverModel_ShiftStrategyParameters, ShiftParametersCreator, false); - } - } + public IGearshiftEngineeringInputData ShiftParameters => + CreateData( + XMLNames.DriverModel_ShiftStrategyParameters, ShiftParametersCreator, false); public IEngineStopStartEngineeringInputData EngineStopStartData { @@ -139,7 +135,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader.Impl { var node = GetNode(elementName, required); if (!required && node == null) { try { - return creator(null, node); + return creator(null, null); } catch (Exception e) { throw new VectoException("Failed to create dummy data provider", e); } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLEngineeringInputReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLEngineeringInputReader.cs index 3c8c64e719689a18450bab050a17e23a10b43e91..2c86710b5c15a2bfcd9f823e3b201f3924fdaf5c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLEngineeringInputReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLEngineeringInputReader.cs @@ -62,15 +62,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader InputData = inputData; } - public IEngineeringJobInputData JobData - { - get { return _jobData ?? (_jobData = CreateComponent(XMLNames.VectoInputEngineering, JobCreator, false, requireDataNode: false)); } - } + public IEngineeringJobInputData JobData => _jobData ?? (_jobData = CreateComponent(XMLNames.VectoInputEngineering, JobCreator, false, requireDataNode: false)); - public IDriverEngineeringInputData DriverModel - { - get { return _driverModel ?? (_driverModel = CreateComponent(XMLNames.Component_DriverModel, DriverModelCreator, requireDataNode:false)); } - } + public IDriverEngineeringInputData DriverModel => _driverModel ?? (_driverModel = CreateComponent(XMLNames.Component_DriverModel, DriverModelCreator, requireDataNode:false)); public IEngineeringJobInputData JobCreator(string version, XmlNode baseNode, string filename) { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLJobDataReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLJobDataReader.cs index b07eebb680587f2294fc1148211b8453381ca143..7eb709039190bb4d4c1351a1a6090f7eb259ef9f 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLJobDataReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/XMLJobDataReader.cs @@ -68,10 +68,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader get { return _engine ?? (_engine = CreateComponent(XMLNames.Component_Engine, (version, node, sourceFile) => Factory.CreateEngineOnlyEngine(version, node, sourceFile))); } } - public IVehicleEngineeringInputData CreateVehicle - { - get { return _vehicle ?? (_vehicle = CreateComponent(XMLNames.Component_Vehicle, VehicleCreator, requireDataNode: false)); } - } + public IVehicleEngineeringInputData CreateVehicle => _vehicle ?? (_vehicle = CreateComponent(XMLNames.Component_Vehicle, VehicleCreator, requireDataNode: false)); public IXMLCyclesDataProvider CreateCycles diff --git a/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs b/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs index b72c19dd30d27e7fc9b1bb39979317578e6d7e26..eb989f43c3fd7b0651857bce5c73f34f1b0599a2 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs @@ -46,7 +46,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration foreach (var component in EnumHelper.GetValues<VectoComponents>()) { var nodes = xmlDocument.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']/*[local-name()='Model']", XMLNames.VectoManufacturerReport, component.XMLElementName())); - var count = nodes == null ? 0 : nodes.Count; + var count = nodes?.Count ?? 0; for (var i = 0; i < count; i++) { retVal.Add(component); } @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration foreach (var component in new[] { XMLNames.AxleWheels_Axles_Axle }) { var nodes = xmlDocument.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']", XMLNames.VectoManufacturerReport, component)); - var count = nodes == null ? 0 : nodes.Count; + var count = nodes?.Count ?? 0; for (var i = 0; i < count; i++) { retVal.Add(VectoComponents.Tyre); } @@ -73,11 +73,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration { var nodes = xmlDocument.SelectNodes(GetComponentQueryString(component == VectoComponents.Tyre ? "Axle" : component.XMLElementName())); if (nodes == null || nodes.Count == 0) { - throw new Exception(string.Format("Component {0} not found", component)); + throw new Exception($"Component {component} not found"); } if (index >= nodes.Count) { - throw new Exception(string.Format("index exceeds number of components found! index: {0}, #components: {1}", index, - nodes.Count)); + throw new Exception($"index exceeds number of components found! index: {index}, " + + $"#components: {nodes.Count}"); } return nodes[index]; } @@ -87,12 +87,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration if (component == null) { return "(//*[@id])[1]"; } - return string.Format("//*[local-name()='{0}']", component); + return $"//*[local-name()='{component}']"; } static string ReadElementValue(XmlNode xmlNode, string elementName) { - var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName)); + var node = xmlNode.SelectSingleNode($"./*[local-name()='{elementName}']"); if (node == null) { return null; } diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs index a7df5c9d5f21dc070dcb577c193bd351a1e2ad38..8150668f0adabda1232946698ad7dd34c832e0b3 100644 --- a/VectoCore/VectoCore/InputData/Impl/InputData.cs +++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs @@ -111,10 +111,7 @@ namespace TUGraz.VectoCore.InputData.Impl public AxleType AxleType { get; internal set; } - ITyreDeclarationInputData IAxleDeclarationInputData.Tyre - { - get { return Tyre; } - } + ITyreDeclarationInputData IAxleDeclarationInputData.Tyre => Tyre; public ITyreEngineeringInputData Tyre { get; internal set; } @@ -236,10 +233,7 @@ namespace TUGraz.VectoCore.InputData.Impl public string Technology { get; } - public WattSecond ElectricStorageCapacity - { - get { return Capacity * Voltage; } - } + public WattSecond ElectricStorageCapacity => Capacity * Voltage; #endregion } @@ -260,10 +254,7 @@ namespace TUGraz.VectoCore.InputData.Impl #region Implementation of IBusAuxElectricStorageDeclarationInputData public string Technology { get; } - public WattSecond ElectricStorageCapacity - { - get { return Capacity * Voltage * Voltage / 2.0; } - } + public WattSecond ElectricStorageCapacity => Capacity * Voltage * Voltage / 2.0; #endregion } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/AlternatorReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/AlternatorReader.cs index 8dfbf81391f00f34b4b8b777137ad8af00e9eba7..cfb5c2d6b97f648a16c8fb3d520339c51fb7e12b 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/AlternatorReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/AlternatorReader.cs @@ -73,7 +73,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData row.ParseDouble(Fields.Efficiency), row.ParseDouble(Fields.PulleyRatio))); } - var g = map.GroupBy(x => x.AlternatorName); + var g = map.GroupBy(x => x.AlternatorName).ToList(); if (g.Any(x => x.Count() < 2)) { throw new ArgumentException( "Insufficient rows in csv to build a usable map for alternator {0}", diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs index 25ff21d243e816aa4ea17d93180e7b795e5e6ac3..72a14c618ceb8002b6feb9b33e3884e46cdc61a6 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs @@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData { } catch (Exception e) { - throw new VectoException(string.Format("EfficiencyMap - Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); + throw new VectoException($"EfficiencyMap - Line {data.Rows.IndexOf(row)}: {e.Message}", e); } } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs index 89b1f2847dc252e0fd8a6acf5a5670a8a701f423..448157e3b1054f9d65f33f9d90865283f3958c5a 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs @@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var data = VectoCSVFile.Read(fileName); return Create(data); } catch (Exception e) { - throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message), e); + throw new VectoException($"File {fileName}: {e.Message}", e); } } @@ -71,7 +71,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData (headerValid ? row.ParseDouble(Fields.EngineSpeed) : row.ParseDouble(0)).RPMtoRad().Value(), entry.FuelConsumption.Value()); } catch (Exception e) { - throw new VectoException(string.Format("FuelConsumptionMap - Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); + throw new VectoException($"FuelConsumptionMap - Line {data.Rows.IndexOf(row)}: {e.Message}", e); } } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs index 148820f493d408ccec4c2639795e99b9bcfcb0f9..884fa6506fb29afbc15ba320e81b94f0597b9361 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs @@ -87,17 +87,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData if (!extendLossMap) { return new TransmissionLossMap(entries, gearRatio, gearName); } - var orig = ""; - entries.ForEach( - x => - orig += - string.Format("{0},{1},{2}" + Environment.NewLine, x.InputSpeed.AsRPM, x.InputTorque.Value(), x.TorqueLoss.Value())); entries = ExtendLossMap(entries); - var extended = ""; - entries.ForEach( - x => - extended += - string.Format("{0},{1},{2}" + Environment.NewLine, x.InputSpeed.AsRPM, x.InputTorque.Value(), x.TorqueLoss.Value())); return new TransmissionLossMap(entries, gearRatio, gearName); } @@ -157,9 +147,9 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData if (speedBucket.Value.Count < 2) { continue; } - double k, d, r; - VectoMath.LeastSquaresFitting(speedBucket.Value, x => x.InputTorque.Value(), x => x.TorqueLoss.Value(), out k, out d, - out r); + + VectoMath.LeastSquaresFitting(speedBucket.Value, x => x.InputTorque.Value(), x => x.TorqueLoss.Value(), out var k, out var d, + out var r); for (var i = 2; i <= DeclarationData.LossMapExtrapolationFactor; i++) { var inTq = i * maxTorque; diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs index 4a4b209df19b1bcc8c249611aaddd91671f1c4ea..6fcb5dbe8ee91e83f0b4ab28b7017176131289c5 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs @@ -19,7 +19,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var data = VectoCSVFile.Read(fileName); return Create(data, type); } catch (Exception e) { - throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message), e); + throw new VectoException($"File {fileName}: {e.Message}", e); } } @@ -28,7 +28,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData string whrColumn = null; type = type & (WHRType.ElectricalOutput | WHRType.MechanicalOutputDrivetrain); switch (type) { - case WHRType.MechanicalOutputDrivetrain: + case WHRType.MechanicalOutputDrivetrain: whrColumn = Fields.MechanicalPower; break; case WHRType.ElectricalOutput: @@ -46,31 +46,30 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData } if (!headerValid && (type == WHRType.ElectricalOutput || type == WHRType.MechanicalOutputDrivetrain)) { - - throw new VectoException("expected column headers: {0}", string.Join(", ", whrColumn)); - } + throw new VectoException("expected column headers: {0}", string.Join(", ", whrColumn)); + } - if (!headerValid) { + if (!headerValid) { data.Columns[0].ColumnName = Fields.EngineSpeed; data.Columns[1].ColumnName = Fields.Torque; } var delaunayMap = new DelaunayMap(type.IsElectrical() ? "WHRMapEl" : "WHRMapMech"); - + foreach (DataRow row in data.Rows) { try { var engineSpeed = row.ParseDouble(Fields.EngineSpeed).RPMtoRad(); var torque = row.ParseDouble(Fields.Torque).SI<NewtonMeter>(); - var electricPower = row.ParseDouble(whrColumn).SI<Watt>(); + var electricPower = row.ParseDouble(whrColumn).SI<Watt>(); - delaunayMap?.AddPoint(torque.Value(),engineSpeed.Value(),electricPower.Value()); + delaunayMap?.AddPoint(torque.Value(), engineSpeed.Value(), electricPower.Value()); } catch (Exception e) { - throw new VectoException(string.Format("WHR Map - Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); + throw new VectoException($"WHR Map - Line {data.Rows.IndexOf(row)}: {e.Message}", e); } } delaunayMap.Triangulate(); - + return new WHRPowerMap(delaunayMap); } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index 04212c7685150d47348b492865bbc3c2fd924cba..e57bba31347a7a553c5692b4d80e76953d2df729 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -176,10 +176,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter protected virtual TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) { if (gear.LossMap != null) { - return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1), true); + return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, $"Gear {i + 1}", true); } if (useEfficiencyFallback) { - return TransmissionLossMapReader.Create(gear.Efficiency, gear.Ratio, string.Format("Gear {0}", i + 1)); + return TransmissionLossMapReader.Create(gear.Efficiency, gear.Ratio, $"Gear {i + 1}"); } throw new InvalidFileFormatException("Gear {0} LossMap missing.", i + 1); } @@ -203,7 +203,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter protected virtual void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) { gearData.TorqueConverterRatio = 1; - gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, string.Format("TCGear {0}", i + 1)); + gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, $"TCGear {i + 1}"); gearData.TorqueConverterShiftPolygon = shiftPolygon; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs index 8ade80f4d3a16da911cd3be7bdb8fa70a840bd99..e96fd6c86edfcba667b4efb628b1425bb8cfe4d4 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs @@ -82,7 +82,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { gearData.TorqueConverterRatio = 1; //gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(GearEfficiencyIndirectGear, 1, string.Format("TCGear {0}", i + 1)); - gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1.0, 1, string.Format("TCGear {0}", i + 1)); + gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1.0, 1, $"TCGear {i + 1}"); gearData.TorqueConverterShiftPolygon = shiftPolygon; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs index 4d2412e43fee7342e56f67e0c217aba6302d618f..3ed44c304530824451009012db15f6572993d0ab 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs @@ -62,7 +62,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter vehicleData.VehicleCode = completedVehicle.VehicleCode; if (vehicleData.TotalVehicleMass.IsGreater(vehicleData.GrossVehicleMass)) { - throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus specific ({0}/{1})", vehicleData.TotalVehicleMass, vehicleData.GrossVehicleMass); + throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus specific ({0}/{1})", + vehicleData.TotalVehicleMass, vehicleData.GrossVehicleMass); } return vehicleData; } @@ -294,11 +295,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter //ToDo FK COP calculation ssmInputs.HVACCompressorType = heatPumpTypePassengerCompartment; // use passenger compartment - ssmInputs.HVACTechnology = string.Format( - "{0} ({1})", busAux.SystemConfiguration.GetName(), - string.Join(", ", new[] { heatPumpTypePassengerCompartment.GetName(), heatPumpTypeDriverCompartment.GetName() })); - ; - ssmInputs.COP = DeclarationData.BusAuxiliaries.CalculateCOP( + ssmInputs.HVACTechnology = $"{busAux.SystemConfiguration.GetName()} " + + $"({string.Join(", ", heatPumpTypePassengerCompartment.GetName(), heatPumpTypeDriverCompartment.GetName())})"; + ssmInputs.COP = DeclarationData.BusAuxiliaries.CalculateCOP( coolingPower.Item1, heatPumpTypeDriverCompartment, coolingPower.Item2, heatPumpTypePassengerCompartment /* average */, floorType); diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs index bac7250881df05bb3fd71949d9bf92a0034e5901..44814cf8d562daa3135bdf9cfea721f04e55e0f5 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs @@ -381,9 +381,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter coolingPower.Item1, HeatPumpType.none, coolingPower.Item2, busParams.HVACCompressorType, busParams.VehicleCode.GetFloorType()); - retVal.HVACTechnology = string.Format( - "{0} ({1})", busParams.HVACConfiguration.GetName(), - string.Join(", ", new[] { busParams.HVACCompressorType.GetName(), HeatPumpType.none.GetName() })); + retVal.HVACTechnology = $"{busParams.HVACConfiguration.GetName()} " + + $"({string.Join(", ", busParams.HVACCompressorType.GetName(), HeatPumpType.none.GetName())})"; //SetHVACParameters(retVal, vehicleData, mission); diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs index dbfe126ca6db278b5688a2f9c9e6f58bb5d69257..7a122f0bdc5475bb6d01fc085556d96b61c8183b 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter protected override TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) { - return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1), true); + return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, $"Gear {i + 1}", true); } @@ -88,10 +88,6 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter public ISingleBusInputDataProvider SingleBusInputData { get; set; } - protected IVehicleDeclarationInputData CompletedVehicle - { - get { return SingleBusInputData?.CompletedVehicle; } - } - + protected IVehicleDeclarationInputData CompletedVehicle => SingleBusInputData?.CompletedVehicle; } } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 13e7cf0bf8dc5357230762b4ef61ebeb92d0d5bf..69f78b39bc97698c4aa192c722160dd20753b95a 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -204,7 +204,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter (gbx != null && gbx.Type.AutomaticTransmission() ? torqueConverter.Inertia : 0.SI<KilogramSquareMeter>()); retVal.EngineStartTime = engine.EngineStartTime ?? DeclarationData.Engine.DefaultEngineStartTime; var limits = torqueLimits.ToDictionary(e => e.Gear); - var numGears = gbx == null ? 0 : gbx.Gears.Count; + var numGears = gbx?.Gears.Count ?? 0; var fullLoadCurves = new Dictionary<uint, EngineFullLoadCurve>(numGears + 1); fullLoadCurves[0] = FullLoadCurveReader.Create(engine.EngineModes.First().FullLoadCurve); fullLoadCurves[0].EngineData = retVal; diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs index dbf57e760315e9ff244ba97f13539cbfe691c971..536bcd20d3881a9b16d9fe01442cc4aca7dc86c3 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs @@ -69,15 +69,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl Report = report; } - protected IVehicleDeclarationInputData PrimaryVehicle - { - get { return InputDataProvider.PrimaryVehicleData.Vehicle; } - } + protected IVehicleDeclarationInputData PrimaryVehicle => InputDataProvider.PrimaryVehicleData.Vehicle; - protected IVehicleDeclarationInputData CompletedVehicle - { - get { return InputDataProvider.JobInputData.Vehicle; } - } + protected IVehicleDeclarationInputData CompletedVehicle => InputDataProvider.JobInputData.Vehicle; public IEnumerable<VectoRunData> NextRun() { @@ -264,7 +258,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = _driverData, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Specific_" + loading.Key.ToString(), + ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Specific_" + loading.Key, Report = Report, Mission = mission, InputDataHash = InputDataProvider.XMLHash, @@ -311,7 +305,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = _driverData, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Generic_" + loading.Key.ToString(), + ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Generic_" + loading.Key, Report = Report, Mission = mission, InputDataHash = InputDataProvider.XMLHash, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs index f98dd58c4393ed2d15f0c77f5e96b2f4299392a9..97e31a63664974ba256b81edf5121a4d9f7e57f5 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs @@ -50,17 +50,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl - protected IVehicleDeclarationInputData PrimaryVehicle - { - get { return InputDataProvider.JobInputData.PrimaryVehicle.Vehicle; } - } - - protected IVehicleDeclarationInputData CompletedVehicle - { - get { return InputDataProvider.JobInputData.ConsolidateManufacturingStage.Vehicle; } - } - + protected IVehicleDeclarationInputData PrimaryVehicle => InputDataProvider.JobInputData.PrimaryVehicle.Vehicle; + protected IVehicleDeclarationInputData CompletedVehicle => InputDataProvider.JobInputData.ConsolidateManufacturingStage.Vehicle; public IEnumerable<VectoRunData> NextRun() @@ -284,7 +276,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = _driverData, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier,//?!? Jobname - ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Specific_" + loading.Key.ToString(), + ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Specific_{loading.Key}", Report = Report, Mission = mission, InputDataHash = InputDataProvider.XMLHash,// right hash?!? @@ -331,7 +323,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = _driverData, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier, - ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Generic_" + loading.Key.ToString(), + ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Generic_{loading.Key}", Report = Report, Mission = mission, InputDataHash = InputDataProvider.XMLHash, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs index 7a1382a8113bc322fb78da49fa896a68f0ac4d69..37545d3f370f03cb8a7a9b1c7f7facd584bb0ff1 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs @@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl #region Overrides of AbstractDeclarationVectoRunDataFactory - protected override IDeclarationDataAdapter DataAdapter { get { return _dao; } } + protected override IDeclarationDataAdapter DataAdapter => _dao; #endregion @@ -175,7 +175,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = _driverdata, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = (engineModes.Count > 1 ? string.Format("_EngineMode{0}_", modeIdx) : "") + loading.Key.ToString(), + ModFileSuffix = (engineModes.Count > 1 ? $"_EngineMode{modeIdx}_" : "") + loading.Key, Report = Report, Mission = mission, PTO = mission.MissionType == MissionType.MunicipalUtility diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeMultistageBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeMultistageBusVectoRunDataFactory.cs index 45a69fd65b749930a2c871025d6ff9761ddfaa67..c2c3e20b12a7ccff214dbb7455b067ca4042f1d7 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeMultistageBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeMultistageBusVectoRunDataFactory.cs @@ -26,15 +26,17 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { return new VectoRunData { - Exempted = true, + Exempted = InputDataProvider.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.ExemptedVehicle, + MultistageRun = true, + ExecutionMode = ExecutionMode.Declaration, Report = Report, Mission = new Mission { MissionType = MissionType.ExemptedMission }, - VehicleData = CreateExemptedVehicleData(InputDataProvider.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle), + VehicleData = CreateVehicleData(InputDataProvider.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle), MultistageVIFInputData = InputDataProvider }; } - private VehicleData CreateExemptedVehicleData(IVehicleDeclarationInputData data) + private VehicleData CreateVehicleData(IVehicleDeclarationInputData data) { var exempted = SetCommonVehicleData(data); exempted.VIN = data.VIN; diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs index 31de49f7708027e99af34e5faae4e896eb30c63f..5b54fb576f9f21e3bf02535fa314db9787acf377 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs @@ -22,10 +22,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl #region Overrides of AbstractDeclarationVectoRunDataFactory - protected override IDeclarationDataAdapter DataAdapter - { - get { return _dao; } - } + protected override IDeclarationDataAdapter DataAdapter => _dao; #endregion @@ -133,7 +130,8 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = _driverdata, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = (engineModes.Count > 1 ? string.Format("_EngineMode{0}_", modeIdx) : "") + "_" + mission.BusParameter.BusGroup.GetClassNumber() + "_" + loading.Key.ToString(), + ModFileSuffix = $"{(engineModes.Count > 1 ? $"_EngineMode{modeIdx}_" : "")}" + + $"_{mission.BusParameter.BusGroup.GetClassNumber()}_{loading.Key}", Report = Report, Mission = mission, InputDataHash = InputDataProvider.XMLHash, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs index bd665772cf6740688e677448df8f94f2f1a75d95..a4a9cd71a924becbcc9dbceb983a4ad6a7a0bc6e 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { #endregion - protected override IDeclarationDataAdapter DataAdapter { get { return _dao; } } + protected override IDeclarationDataAdapter DataAdapter => _dao; protected override VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) @@ -98,7 +98,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { DriverData = _driverdata, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = (engineModes.Count > 1 ? string.Format("_EngineMode{0}_", modeIdx) : "") + "_" + mission.BusParameter.BusGroup.GetClassNumber() + "-Single_" + loading.Key.ToString(), + ModFileSuffix = $"{(engineModes.Count > 1 ? $"_EngineMode{modeIdx}_" : "")}" + + $"_{mission.BusParameter.BusGroup.GetClassNumber()}-Single_{loading.Key}", Report = Report, Mission = mission, InputDataHash = InputDataProvider.XMLHash, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs index 72495949ad5a96d5839845ad2a0fb307b2ba6330..d5662ca8144f2dd37018f852bd8a29891dc4b52b 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs @@ -31,12 +31,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { #region Implementation of IVectoRunDataFactory - protected override IDeclarationDataAdapter Dao { get { - return _dao ?? (_dao = new DeclarationDataAdapterPrimaryBus()); - } } - - - + protected override IDeclarationDataAdapter Dao => _dao ?? (_dao = new DeclarationDataAdapterPrimaryBus()); #endregion diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs index 3d9af605ede37536944329dfdf5c8c4615b752b2..a1357c407b3d9057a726c33e817dd5683316bf97 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl protected DeclarationVTPModeVectoRunDataFactoryLorries(IVTPDeclarationJobInputData job, IVTPReport report) : base(job, report) { } - protected override IDeclarationDataAdapter Dao { get { return _dao ?? (_dao = new DeclarationDataAdapterHeavyLorry()); } } + protected override IDeclarationDataAdapter Dao => _dao ?? (_dao = new DeclarationDataAdapterHeavyLorry()); protected override void Initialize() { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs index c9d5e3b491785a9d1a0f1d63840510f77d370e0a..9a10e768bfe0a741da1b1d0f64122a31e8dbab73 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs @@ -93,18 +93,12 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries } - public override Watt ElectricPowerConsumer { - get { return AveragePowerDemandAtAlternatorFromElectrics; } - } + public override Watt ElectricPowerConsumer => AveragePowerDemandAtAlternatorFromElectrics; - public override Watt HVACElectricalPowerConsumer { - get { return ssmTool.ElectricalWAdjusted; } - } + public override Watt HVACElectricalPowerConsumer => ssmTool.ElectricalWAdjusted; - public override Watt ElectricPowerConsumerSum { - get { return ssmTool.ElectricalWAdjusted + AveragePowerDemandAtAlternatorFromElectrics; } - } + public override Watt ElectricPowerConsumerSum => ssmTool.ElectricalWAdjusted + AveragePowerDemandAtAlternatorFromElectrics; protected Watt AveragePowerDemandAtAlternatorFromElectrics { get { @@ -245,21 +239,12 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries public ISignals Signals { get; set; } - public virtual Watt ElectricPowerConsumer - { - get { return M2.AveragePowerDemandAtAlternatorFromElectrics; } - } + public virtual Watt ElectricPowerConsumer => M2.AveragePowerDemandAtAlternatorFromElectrics; - public virtual Watt HVACElectricalPowerConsumer - { - get { return M1.AveragePowerDemandAtAlternatorFromHVACElectrics; } - } + public virtual Watt HVACElectricalPowerConsumer => M1.AveragePowerDemandAtAlternatorFromHVACElectrics; - public virtual Watt ElectricPowerConsumerSum - { - get { return M1.AveragePowerDemandAtAlternatorFromHVACElectrics + M2.AveragePowerDemandAtAlternatorFromElectrics; } - } + public virtual Watt ElectricPowerConsumerSum => M1.AveragePowerDemandAtAlternatorFromHVACElectrics + M2.AveragePowerDemandAtAlternatorFromElectrics; public virtual Watt ElectricPowerDemandMech { @@ -288,10 +273,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries } } - public virtual NormLiter PSDemandConsumer - { - get { return M3.AverageAirConsumed * Signals.SimulationInterval; } - } + public virtual NormLiter PSDemandConsumer => M3.AverageAirConsumed * Signals.SimulationInterval; public virtual NormLiter PSAirGenerated { @@ -311,10 +293,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries } } - public virtual NormLiter PSAirGeneratedAlwaysOn - { - get { return M4.GetFlowRate() * Signals.SimulationInterval; } - } + public virtual NormLiter PSAirGeneratedAlwaysOn => M4.GetFlowRate() * Signals.SimulationInterval; public virtual Watt PSPowerDemandAirGenerated @@ -330,27 +309,15 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries } } - public virtual Watt PSPowerCompressorAlwaysOn - { - get { return M4.GetPowerCompressorOn(); } - } + public virtual Watt PSPowerCompressorAlwaysOn => M4.GetPowerCompressorOn(); - public virtual Watt PSPowerCompressorDragOnly - { - get { return M4.GetPowerCompressorOff(); } - } + public virtual Watt PSPowerCompressorDragOnly => M4.GetPowerCompressorOff(); - public virtual Watt HVACMechanicalPowerConsumer - { - get { return M1.AveragePowerDemandAtCrankFromHVACMechanicals; } - } + public virtual Watt HVACMechanicalPowerConsumer => M1.AveragePowerDemandAtCrankFromHVACMechanicals; + + public virtual Watt HVACMechanicalPowerGenerated => M1.AveragePowerDemandAtCrankFromHVACMechanicals; - public virtual Watt HVACMechanicalPowerGenerated - { - get { return M1.AveragePowerDemandAtCrankFromHVACMechanicals; } - } - //public string AuxiliaryName //{ // get { return "BusAuxiliaries"; } @@ -361,10 +328,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries // get { return "Version 2.0 DEV"; } //} - public virtual Watt AuxiliaryPowerAtCrankWatts - { - get { return M8.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries; } - } + public virtual Watt AuxiliaryPowerAtCrankWatts => M8.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries; public WattSecond BatteryEnergyDemand(Second dt, double essFactor) { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/AlternatorMap.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/AlternatorMap.cs index 9defeccb84dce87fb765d2f33d46782580ef54a1..f285fade20841a2f952db547d3a7f68918eeb467 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/AlternatorMap.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/AlternatorMap.cs @@ -233,12 +233,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric return GetValue(rpm, currentDemand); } - public IList<string> Technologies - { - get { - return new List<string>(); - } - } + public IList<string> Technologies => new List<string>(); // Public Events diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs index 37cae3b8b00fc5c25443b2c45d3959a55ef542cd..36edab2cc03c0fa010f0f981284a6c713c9ecad7 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs @@ -63,12 +63,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric return alternatorMapValues; } - public IList<string> Technologies - { - get { - return new List<string>(); - } - } + public IList<string> Technologies => new List<string>(); protected void Initialise(IList<ICombinedAlternatorMapRow> map) { @@ -201,10 +196,10 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric { // Count Check. - if (this.Alternators.Count != other.Alternators.Count) + if (Alternators.Count != other.Alternators.Count) return false; - foreach (var alt in this.Alternators) { + foreach (var alt in Alternators) { // Can we find the same alternatorName in other if (other.Alternators.Count(f => f.AlternatorName == alt.AlternatorName) != 1) diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs index 1a1a2b6346030d2cd345f673a56b493d53ee9b83..8567bf8edfbe5e261a13eaf3f6b7d51a627cd061 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs @@ -28,12 +28,6 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric // Interface implementation - public IReadOnlyList<ElectricalConsumer> Items - { - get { - return _items; - } - } - + public IReadOnlyList<ElectricalConsumer> Items => _items; } } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs index f6b20452afaa04d573450dfc0ccebaf6816d0728..c1034927fac9a00ce2568b377c5c5f8bf5a4dea0 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs @@ -52,20 +52,11 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric } } - public Ampere AverageCurrentDemand - { - get { return AverageCurrentDemandInclBaseLoad(false, false); } - } + public Ampere AverageCurrentDemand => AverageCurrentDemandInclBaseLoad(false, false); - public Ampere AverageCurrentDemandEngineOffStandstill - { - get { return AverageCurrentDemandInclBaseLoad(true, true); } - } + public Ampere AverageCurrentDemandEngineOffStandstill => AverageCurrentDemandInclBaseLoad(true, true); - public Ampere AverageCurrentDemandEngineOffDriving - { - get { return AverageCurrentDemandInclBaseLoad(true, false); } - } + public Ampere AverageCurrentDemandEngineOffDriving => AverageCurrentDemandInclBaseLoad(true, false); public Ampere AverageCurrentDemandWithoutBaseLoad(bool engineOff, bool vehicleStopped) { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs index a654e35008113682db0b76700c78d24ced414209..3fd966a4b5fa94c6331957df5f746b0782b09b74 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs @@ -56,10 +56,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric #region Implementation of IM0_NonSmart_AlternatorsSetEfficiency - public Ampere GetHVACElectricalCurrentDemand - { - get { return _ElectricalPowerW / _powernetVoltage; } - } + public Ampere GetHVACElectricalCurrentDemand => _ElectricalPowerW / _powernetVoltage; public double AlternatorsEfficiency { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs index 7c04b90df818ba7b4e5540b875a43be6e05c31b5..720df336851ed424b41caac818f5533e8d97c916 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs @@ -79,30 +79,15 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric } } - public double AlternatorsEfficiencyIdleResultCard - { - get { return _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartIdleCurrent); } - } + public double AlternatorsEfficiencyIdleResultCard => _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartIdleCurrent); - public Ampere SmartTractionCurrent - { - get { return _resultCardTraction.GetSmartCurrentResult(HvacPlusNonBaseCurrents()); } - } + public Ampere SmartTractionCurrent => _resultCardTraction.GetSmartCurrentResult(HvacPlusNonBaseCurrents()); - public double AlternatorsEfficiencyTractionOnResultCard - { - get { return _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartTractionCurrent); } - } + public double AlternatorsEfficiencyTractionOnResultCard => _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartTractionCurrent); - public Ampere SmartOverrunCurrent - { - get { return _resultCardOverrun.GetSmartCurrentResult(HvacPlusNonBaseCurrents()); } - } + public Ampere SmartOverrunCurrent => _resultCardOverrun.GetSmartCurrentResult(HvacPlusNonBaseCurrents()); - public double AlternatorsEfficiencyOverrunResultCard - { - get { return _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartOverrunCurrent); } - } + public double AlternatorsEfficiencyOverrunResultCard => _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartOverrunCurrent); #endregion } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs index 53c73c8b2255a34a27f8dee2b88b8e8833495f78..e4f4a86ca18f73413652de7ab8667b8dfa2c6af2 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs @@ -27,7 +27,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric return 10.SI<Ampere>(); } - public Dictionary<Ampere, Ampere> Entries { get { return new Dictionary<Ampere, Ampere>();} } + public Dictionary<Ampere, Ampere> Entries => new Dictionary<Ampere, Ampere>(); #endregion } @@ -51,10 +51,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric // Public class outputs - public IReadOnlyList<SmartResult> Results - { - get { return _results; } - } + public IReadOnlyList<SmartResult> Results => _results; public Ampere GetSmartCurrentResult(Ampere Amps) { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleAlternator.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleAlternator.cs index 8ef09f4b2c30c3398fa426d75cb4cef3a2fd7a86..02052660cf0f23d3f08fc30bb0f70448009c575d 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleAlternator.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleAlternator.cs @@ -24,7 +24,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric return _efficiency; } - public string Source { get { return null; } } + public string Source => null; #endregion } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs index 5ea0ed14fd494c1e4135b4272c4472875b4e0c00..6fff2a8be4a8dcf535cdb86ffb59d39ff3118cea 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs @@ -15,14 +15,9 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric #region Implementation of ISimpleBatteryInfo - public double SOC - { - get { return 0; } - } - public WattSecond Capacity - { - get { return 0.SI<WattSecond>(); } - } + public double SOC => 0; + + public WattSecond Capacity => 0.SI<WattSecond>(); #endregion @@ -80,10 +75,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric public double SOC { get; internal set; } public WattSecond Capacity { get; } - public WattSecond ConsumedEnergy - { - get { return CurrentState.ConsumedEnergy; } - } + public WattSecond ConsumedEnergy => CurrentState.ConsumedEnergy; public void ConsumeEnergy(WattSecond energy, bool dryRun) { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs index 967308d31eec200f50f888b085c98a8ebf74dda2..ff8b4e1932de2533e866a4b1304ba773a06c6a73 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs @@ -31,7 +31,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC } if (compressorGearEfficiency <= 0 || compressorGearEfficiency > 1) { - throw new ArgumentException(String.Format("Compressor Gear efficiency must be between {0} and {1}", 0, 1)); + throw new ArgumentException("Compressor Gear efficiency must be between 0 and 1"); } //'Assign @@ -48,20 +48,11 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC #region Implementation of IM1_AverageHVACLoadDemand - public Watt AveragePowerDemandAtCrankFromHVACMechanicals - { - get { return _MechanicalPower * (1 / _compressorGearEfficiency); } - } + public Watt AveragePowerDemandAtCrankFromHVACMechanicals => _MechanicalPower * (1 / _compressorGearEfficiency); - public Watt AveragePowerDemandAtAlternatorFromHVACElectrics - { - get { return _ElectricalPower; } - } + public Watt AveragePowerDemandAtAlternatorFromHVACElectrics => _ElectricalPower; - public Watt AveragePowerDemandAtCrankFromHVACElectrics - { - get { return _ElectricalPower * (1 / _m0.AlternatorsEfficiency / _alternatorGearEfficiency); } - } + public Watt AveragePowerDemandAtCrankFromHVACElectrics => _ElectricalPower * (1 / _m0.AlternatorsEfficiency / _alternatorGearEfficiency); //public KilogramPerSecond HVACFueling() //{ diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMInputs.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMInputs.cs index feaa56a3fa93bc58e850a756b2b042a03912592c..ec98baf60b02ed655c464107ab21ed53503d2c25 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMInputs.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMInputs.cs @@ -69,10 +69,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC public Kelvin CoolingBoundaryTemperature { get; set; } // C28 - ( oC ) - public Kelvin TemperatureCoolingTurnsOff - { - get { return 17.0.DegCelsiusToKelvin(); } - } + public Kelvin TemperatureCoolingTurnsOff => 17.0.DegCelsiusToKelvin(); // C29 - ( L/H ) --- !! 1/h public PerSecond VentilationRate { get; set; } @@ -93,16 +90,10 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC public double AuxHeaterEfficiency { get; set; } // C38 - ( KW/HKG ) - public JoulePerKilogramm GCVDieselOrHeatingOil - { - get { return HeatingFuel.LowerHeatingValueVecto; } - } + public JoulePerKilogramm GCVDieselOrHeatingOil => HeatingFuel.LowerHeatingValueVecto; // C42 - ( K ) - public Kelvin MaxTemperatureDeltaForLowFloorBusses - { - get { return Constants.BusAuxiliaries.SteadyStateModel.MaxTemperatureDeltaForLowFloorBusses; } - } + public Kelvin MaxTemperatureDeltaForLowFloorBusses => Constants.BusAuxiliaries.SteadyStateModel.MaxTemperatureDeltaForLowFloorBusses; // C43 - ( Fraction ) public double MaxPossibleBenefitFromTechnologyList { get; set; } @@ -113,10 +104,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC // ( EC_EnviromentalTemperature and EC_Solar) (Batch Mode) public IEnvironmentalConditionsMap EnvironmentalConditionsMap { get; set; } - public bool BatchMode - { - get { return EnvironmentalConditionsMap != null && EnvironmentalConditionsMap.GetEnvironmentalConditions().Any(); } - } + public bool BatchMode => EnvironmentalConditionsMap != null && EnvironmentalConditionsMap.GetEnvironmentalConditions().Any(); // C53 - "Continous/2-stage/3-stage/4-stage @@ -150,40 +138,22 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC #region Implementation of ISSMInputs [JsonIgnore] - public ISSMBusParameters BusParameters - { - get { return this; } - } + public ISSMBusParameters BusParameters => this; [JsonIgnore] - public ISSMBoundaryConditions BoundaryConditions - { - get { return this; } - } + public ISSMBoundaryConditions BoundaryConditions => this; [JsonIgnore] - public IEnvironmentalConditions EnvironmentalConditions - { - get { return this; } - } + public IEnvironmentalConditions EnvironmentalConditions => this; [JsonIgnore] - public IACSystem ACSystem - { - get { return this; } - } + public IACSystem ACSystem => this; [JsonIgnore] - public IVentilation Ventilation - { - get { return this; } - } + public IVentilation Ventilation => this; [JsonIgnore] - public IAuxHeater AuxHeater - { - get { return this; } - } + public IAuxHeater AuxHeater => this; public ISSMTechnologyBenefits Technologies { get; set; } public string HVACTechnology { get; set; } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs index 570820d80931a796f874f2e42ea8f59023f11d2e..0a4d11e144ed973c4d45ac1552a47f45d4411e25 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs @@ -27,14 +27,9 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC #region Implementation of ISSMPowerDemand - public Watt ElectricalWAdjusted - { - get { return _ssmInput.ElectricPower; } - } - public Watt MechanicalWBaseAdjusted - { - get { return _ssmInput.MechanicalPower; } - } + public Watt ElectricalWAdjusted => _ssmInput.ElectricPower; + + public Watt MechanicalWBaseAdjusted => _ssmInput.MechanicalPower; public Watt AverageAuxHeaterPower(Watt averageUseableEngineWasteHeat) { @@ -75,19 +70,9 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC private bool CompressorCapacityInsufficientWarned; // Base Values - public Watt ElectricalWBase - { - get { - return Calculate.ElectricalWBase; // .SI(Of Watt)() - } - } + public Watt ElectricalWBase => Calculate.ElectricalWBase; // .SI(Of Watt)() - public Watt MechanicalWBase - { - get { - return Calculate.MechanicalWBase; // .SI(Of Watt)() - } - } + public Watt MechanicalWBase => Calculate.MechanicalWBase; // .SI(Of Watt)() //public KilogramPerSecond FuelPerHBase //{ @@ -97,12 +82,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC //} // Adjusted Values - public Watt ElectricalWAdjusted - { - get { - return Calculate.ElectricalWAdjusted; // .SI(Of Watt)() - } - } + public Watt ElectricalWAdjusted => Calculate.ElectricalWAdjusted; // .SI(Of Watt)() public Watt MechanicalWBaseAdjusted { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs index fe3b4e47408344b61b48aa82b1e07dd0a9f9e7bf..6e82b1cb5866fd8e9b07884649fbed51affa2078 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs @@ -109,25 +109,13 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate += s12 * stepTimeInSeconds; } - public NormLiter LitresOfAirCompressorOnContinually - { - get { return _LitresOfAirCompressorOnContinuallyAggregate; } - } + public NormLiter LitresOfAirCompressorOnContinually => _LitresOfAirCompressorOnContinuallyAggregate; - public NormLiter LitresOfAirCompressorOnOnlyInOverrun - { - get { return _LitresOfAirCompressorOnOnlyInOverrunAggregate; } - } + public NormLiter LitresOfAirCompressorOnOnlyInOverrun => _LitresOfAirCompressorOnOnlyInOverrunAggregate; - public Kilogram TotalCycleFuelConsumptionCompressorOnContinuously - { - get { return _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate; } - } + public Kilogram TotalCycleFuelConsumptionCompressorOnContinuously => _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate; - public Kilogram TotalCycleFuelConsumptionCompressorOffContinuously - { - get { return _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate; } - } + public Kilogram TotalCycleFuelConsumptionCompressorOffContinuously => _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate; #endregion } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs index b5e5f782b8360b21387a91bdea8d18b866b79122..f94e9bfade44ede061b00d3e5c623f7e0bd27589 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs @@ -37,40 +37,19 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl #region Implementation of IM11 - public Joule SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly - { - get { return AG1; } - } + public Joule SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly => AG1; - public Joule SmartElectricalTotalCycleEletricalEnergyGenerated - { - get { return AG2; } - } + public Joule SmartElectricalTotalCycleEletricalEnergyGenerated => AG2; - public Joule TotalCycleElectricalDemand - { - get { return AG3; } - } + public Joule TotalCycleElectricalDemand => AG3; - public Kilogram TotalCycleFuelConsumptionSmartElectricalLoad - { - get { return AG4; } - } + public Kilogram TotalCycleFuelConsumptionSmartElectricalLoad => AG4; - public Kilogram TotalCycleFuelConsumptionZeroElectricalLoad - { - get { return AG5; } - } + public Kilogram TotalCycleFuelConsumptionZeroElectricalLoad => AG5; - public Joule StopStartSensitiveTotalCycleElectricalDemand - { - get { return AG6; } - } + public Joule StopStartSensitiveTotalCycleElectricalDemand => AG6; - public Kilogram TotalCycleFuelConsuptionAverageLoads - { - get { return AG7; } - } + public Kilogram TotalCycleFuelConsuptionAverageLoads => AG7; public void ClearAggregates() { diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs index 59d353a136d2a86ad991e29efa3e5a7b0d1c6c16..363a54f34b6bf7f73d0b08bafa05f13d843348f1 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs @@ -29,12 +29,12 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumati public double PulleyGearRatio { - get { return _pulleyGearRatio; } + get => _pulleyGearRatio; set { if (value < MinRatio || value > MaxRatio) { throw new ArgumentOutOfRangeException( "pulleyGearRatio", value, - string.Format("Invalid value, should be in the range {0} to {1}", MinRatio, MaxRatio)); + $"Invalid value, should be in the range {MinRatio} to {MaxRatio}"); } _pulleyGearRatio = value; @@ -43,12 +43,12 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumati public double PulleyGearEfficiency { - get { return _pulleyGearEfficiency; } + get => _pulleyGearEfficiency; set { if (value < MinEff || value > MaxEff) { throw new ArgumentOutOfRangeException( "pulleyGearEfficiency", value, - String.Format("Invalid value, should be in the range {0} to {1}", MinEff, MaxEff) + $"Invalid value, should be in the range {MinEff} to {MaxEff}" ); } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs index 529d1a23ae7b73faebeb2b798f1663a3def9d481..5fad6cf9d2015ff8720cc4c633e10317e4246d52 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs @@ -45,7 +45,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Util { // Extension Expected, but not match if (expectedExtension.Trim().Length > 0) { if (string.Compare(expectedExtension, detectedExtention, true) != 0) { - message = string.Format("The file extension type does not match the expected type of {0}", expectedExtension); + message = $"The file extension type does not match the expected type of {expectedExtension}"; return false; } } @@ -53,7 +53,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Util { // Extension Not Expected, but was supplied if (expectedExtension.Trim().Length > 0) { if (detectedExtention.Length == 0) { - message = string.Format("No Extension was supplied, but an extension of {0}, this is not required", detectedExtention); + message = $"No Extension was supplied, but an extension of {detectedExtention}, this is not required"; return false; } } @@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Util { // Illegal characters if (!fileNameLegal(fileNameOnlyWithExtension)) { - message = string.Format("The filenames have one or more illegal characters"); + message = "The filenames have one or more illegal characters"; return false; } diff --git a/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs b/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs index 06023c3d862d1258838c4917473fa7c7bd6fce92..9c9675d60b1d65d6307e275f1fb3efd95b45a7c0 100644 --- a/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs +++ b/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs @@ -72,25 +72,15 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl public IRESSResponse RESSResponse { get; set; } - public Watt MaxPowerDrive - { - get - { - return (RESSResponse != null && RESSResponse.MaxDischargePower != null ? RESSResponse.MaxDischargePower : 0.SI<Watt>()) - - (ChargingPower != null ? ChargingPower : 0.SI<Watt>()) + - (AuxPower != null ? AuxPower : 0.SI<Watt>()); - } - } + public Watt MaxPowerDrive => + (RESSResponse != null && RESSResponse.MaxDischargePower != null ? RESSResponse.MaxDischargePower : 0.SI<Watt>()) - + (ChargingPower != null ? ChargingPower : 0.SI<Watt>()) + + (AuxPower != null ? AuxPower : 0.SI<Watt>()); - public Watt MaxPowerDrag - { - get - { - return (RESSResponse != null && RESSResponse.MaxChargePower != null ? RESSResponse.MaxChargePower : 0.SI<Watt>()) - - (ChargingPower != null ? ChargingPower : 0.SI<Watt>()) + - (AuxPower != null ? AuxPower : 0.SI<Watt>()); - } - } + public Watt MaxPowerDrag => + (RESSResponse != null && RESSResponse.MaxChargePower != null ? RESSResponse.MaxChargePower : 0.SI<Watt>()) - + (ChargingPower != null ? ChargingPower : 0.SI<Watt>()) + + (AuxPower != null ? AuxPower : 0.SI<Watt>()); public Watt RESSPowerDemand { get; set; } @@ -99,8 +89,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl public override string ToString() { var t = GetType(); - return string.Format("{0}{{{1}}}", t.Name, - string.Join(", ", t.GetProperties().Select(p => string.Format("{0}: {1}", p.Name, p.GetValue(this))))); + return $"{t.Name}{{{string.Join(", ", t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}"))}}}"; } } diff --git a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs index 3f0d3bf899b3a5f97a4bb3c026f8aeb6d3a6a799..629cbeff730662d71ffd6d83286734172822603a 100644 --- a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs +++ b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs @@ -110,8 +110,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl public override string ToString() { var t = GetType(); - return string.Format("{0}{{{1}}}", t.Name, - string.Join(", ", t.GetProperties().Select(p => string.Format("{0}: {1}", p.Name, p.GetValue(this))))); + return $"{t.Name}{{{string.Join(", ", t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}"))}}}"; } } diff --git a/VectoCore/VectoCore/Models/Declaration/ADASCombination.cs b/VectoCore/VectoCore/Models/Declaration/ADASCombination.cs index a131c669d9c2c9ab89a4cd20157ade6c38e818a3..b7e3218a1402db40e46fdc50c5e3e8508b5b8c10 100644 --- a/VectoCore/VectoCore/Models/Declaration/ADASCombination.cs +++ b/VectoCore/VectoCore/Models/Declaration/ADASCombination.cs @@ -72,18 +72,9 @@ namespace TUGraz.VectoCore.Models.Declaration } } - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".ADAS.ADAS_Combinations.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".ADAS.ADAS_Combinations.csv"; - protected override string ErrorMessage - { - get { - return - "ADAS Combination Lookup Error: No entry found for engine stop/start: {0}, eco roll: {1}, PCC: {2}"; - } - } + protected override string ErrorMessage => "ADAS Combination Lookup Error: No entry found for engine stop/start: {0}, eco roll: {1}, PCC: {2}"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/AirDrag.cs b/VectoCore/VectoCore/Models/Declaration/AirDrag.cs index 2bd3b3788416daaafdbeb75b45d18993b8c351e3..e23a5349314fb64a2fb0e16e9ad9b35a1e44de75 100644 --- a/VectoCore/VectoCore/Models/Declaration/AirDrag.cs +++ b/VectoCore/VectoCore/Models/Declaration/AirDrag.cs @@ -39,15 +39,9 @@ namespace TUGraz.VectoCore.Models.Declaration { public sealed class AirDrag : LookupData<string, AirDrag.Entry> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VCDV.VCDV_parameters.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VCDV.VCDV_parameters.csv"; - protected override string ErrorMessage - { - get { return "AirDrag Lookup Error: no value found. Key: '{0}'"; } - } + protected override string ErrorMessage => "AirDrag Lookup Error: no value found. Key: '{0}'"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs index be9d3aed494da2286ae40719ff255b8e9b953a5a..4d9216c12fa3365fe27c4640996db65cb0b25541 100644 --- a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs +++ b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs @@ -60,8 +60,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static AuxiliaryType Parse(string s) { - AuxiliaryType aux; - return StrToAux.TryGetValue(s, out aux) ? aux : AuxiliaryType.Fan; + return StrToAux.TryGetValue(s, out var aux) ? aux : AuxiliaryType.Fan; } public static AuxiliaryType ParseKey(string s) diff --git a/VectoCore/VectoCore/Models/Declaration/Axle.cs b/VectoCore/VectoCore/Models/Declaration/Axle.cs index 88f73bee3071650f806f1b5f067fb9e8b7c3dcc6..e6c99bff9ae9c45c1e856efa9849345b508bdf11 100644 --- a/VectoCore/VectoCore/Models/Declaration/Axle.cs +++ b/VectoCore/VectoCore/Models/Declaration/Axle.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Models.Declaration try { DeclarationData.Wheels.Lookup(axle.WheelsDimension); } catch (Exception) { - return new ValidationResult(string.Format("Unknown Tyre dimenstion '{0}'", axle.WheelsDimension)); + return new ValidationResult($"Unknown Tyre dimenstion '{axle.WheelsDimension}'"); } return ValidationResult.Success; } diff --git a/VectoCore/VectoCore/Models/Declaration/BusAlternatorTechnologies.cs b/VectoCore/VectoCore/Models/Declaration/BusAlternatorTechnologies.cs index c0156498dcc9c8b3958e3348c582c02e143e0bbd..bc6ac0a9e2d1018e10fd005171243a4809f7a8dd 100644 --- a/VectoCore/VectoCore/Models/Declaration/BusAlternatorTechnologies.cs +++ b/VectoCore/VectoCore/Models/Declaration/BusAlternatorTechnologies.cs @@ -9,12 +9,10 @@ namespace TUGraz.VectoCore.Models.Declaration { { #region Overrides of LookupData - protected override string ResourceId { get { return DeclarationData.DeclarationDataResourcePrefix + ".Buses.AlternatorTechnologies.csv"; } } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".Buses.AlternatorTechnologies.csv"; + + protected override string ErrorMessage => "Bus-Alternator Technology Lookup Error: No value found for Technology. Key: '{0}'"; - protected override string ErrorMessage - { - get { return "Bus-Alternator Technology Lookup Error: No value found for Technology. Key: '{0}'"; } - } protected override void ParseData(DataTable table) { Data = table.Rows.Cast<DataRow>() diff --git a/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs b/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs index 3587c6bd982a6fd4e785865c1e9e05b8662d681b..bbd03585ca561155665a11754a8a22b321294f5a 100644 --- a/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs +++ b/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs @@ -20,18 +20,12 @@ namespace TUGraz.VectoCore.Models.Declaration #region Overrides of LookupData - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + COMPLETED_BUS_SEGMENTS_CSV; } - } - - protected override string ErrorMessage - { - get { return "ERROR: Could not find the declaration segment for vehicle. numberOfAxles: {0}, vehicleCode: {1}, registrationClass: {2}, " + - "passengersLowerDeck: {3}, bodyHeight: {4} , lowEntry: {5}"; - } - } - + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + COMPLETED_BUS_SEGMENTS_CSV; + + protected override string ErrorMessage => + "ERROR: Could not find the declaration segment for vehicle. numberOfAxles: {0}, vehicleCode: {1}, registrationClass: {2}, " + + "passengersLowerDeck: {3}, bodyHeight: {4} , lowEntry: {5}"; + protected override void ParseData(DataTable table) { _segmentTable = table.Copy(); diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 90d40f9efa8974be81e787f15c4b4503b92eeb2d..e8287a62cd6faa9417d403e2e07b79934affe74d 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -183,7 +183,7 @@ namespace TUGraz.VectoCore.Models.Declaration case "Large Supply 2-stage": resource = "DEFAULT_3-Cylinder_2-Stage_598ccm.acmp"; break; - default: throw new ArgumentException(string.Format("unkown compressor size {0}", compressorSize), compressorSize); + default: throw new ArgumentException($"unkown compressor size {compressorSize}", compressorSize); } var dragCurveFactorClutch = 1.0; @@ -197,49 +197,30 @@ namespace TUGraz.VectoCore.Models.Declaration } return CompressorMapReader.ReadStream( - RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VAUXBus." + resource), dragCurveFactorClutch, $"{compressorSize} - {clutchType}"); + RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".VAUXBus." + resource), dragCurveFactorClutch, $"{compressorSize} - {clutchType}"); } public static BusAlternatorTechnologies AlternatorTechnologies = new BusAlternatorTechnologies(); private static HVACCoolingPower hvacMaxCoolingPower; - public static List<SSMTechnology> SSMTechnologyList - { - get { - return ssmTechnologies ?? (ssmTechnologies = SSMTechnologiesReader.ReadFromStream( - RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.SSMTechList.csv"))); - } - } + public static List<SSMTechnology> SSMTechnologyList => + ssmTechnologies ?? (ssmTechnologies = SSMTechnologiesReader.ReadFromStream( + RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.SSMTechList.csv"))); - public static IEnvironmentalConditionsMap DefaultEnvironmentalConditions - { - get { - return envMap ?? (envMap = EnvironmentalContidionsMapReader.ReadStream( - RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.DefaultClimatic.aenv"))); - } - } + public static IEnvironmentalConditionsMap DefaultEnvironmentalConditions => + envMap ?? (envMap = EnvironmentalContidionsMapReader.ReadStream( + RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.DefaultClimatic.aenv"))); - public static ElectricalConsumerList DefaultElectricConsumerList - { - get { - return elUserConfig ?? (elUserConfig = ElectricConsumerReader.ReadStream( - RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.ElectricConsumers.csv"))); - } - } + public static ElectricalConsumerList DefaultElectricConsumerList => + elUserConfig ?? (elUserConfig = ElectricConsumerReader.ReadStream( + RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.ElectricConsumers.csv"))); - public static IActuationsMap ActuationsMap - { - get { - return actuationsMap ?? (actuationsMap = ActuationsMapReader.ReadStream( - RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.DefaultActuationsMap.apac"))); - } - } + public static IActuationsMap ActuationsMap => + actuationsMap ?? (actuationsMap = ActuationsMapReader.ReadStream( + RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.DefaultActuationsMap.apac"))); - public static HVACCoolingPower HVACMaxCoolingPower - { - get { return hvacMaxCoolingPower ?? (hvacMaxCoolingPower = new HVACCoolingPower()); } - } + public static HVACCoolingPower HVACMaxCoolingPower => hvacMaxCoolingPower ?? (hvacMaxCoolingPower = new HVACCoolingPower()); public static PerSecond VentilationRate(BusHVACSystemConfiguration? hvacSystemConfig, bool heating) { diff --git a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs index 5eae698c46488875eab76230ced2149e811cf8df..d1604744e93bad3474f6d833c55581dee7a33dec 100644 --- a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs @@ -42,15 +42,9 @@ namespace TUGraz.VectoCore.Models.Declaration { private readonly Alternator _alternator = new Alternator(); - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.ES-Tech.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.ES-Tech.csv"; - protected override string ErrorMessage - { - get { return "Auxiliary Lookup Error: No value found for Electric System. Mission: '{0}', Technology: '{1}'"; } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for Electric System. Mission: '{0}', Technology: '{1}'"; protected override void ParseData(DataTable table) { @@ -76,15 +70,9 @@ namespace TUGraz.VectoCore.Models.Declaration internal sealed class Alternator : LookupData<MissionType, string, double> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.ALT-Tech.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.ALT-Tech.csv"; - protected override string ErrorMessage - { - get { return "Auxiliary Lookup Error: No value found for Alternator. Mission: '{0}', Technology: '{1}'"; } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for Alternator. Mission: '{0}', Technology: '{1}'"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/Fan.cs b/VectoCore/VectoCore/Models/Declaration/Fan.cs index 95fe70f25df75342b289a63a8bf425b2ee625bef..ac7dabac8ed32f5f74a677d8dc094188de180f93 100644 --- a/VectoCore/VectoCore/Models/Declaration/Fan.cs +++ b/VectoCore/VectoCore/Models/Declaration/Fan.cs @@ -95,12 +95,9 @@ namespace TUGraz.VectoCore.Models.Declaration { //private readonly List<string> FullyElectricFanTechnologies = new List<string>(); - protected override string ErrorMessage - { - get { return "Auxiliary Lookup Error: No value found for Fan. Mission: '{0}', Technology: '{1}'"; } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for Fan. Mission: '{0}', Technology: '{1}'"; - protected override void ParseData(DataTable table) + protected override void ParseData(DataTable table) { foreach (DataRow row in table.Rows) { @@ -146,17 +143,11 @@ namespace TUGraz.VectoCore.Models.Declaration public sealed class FanMediumLorries : AbstractFan { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.Fan-Tech-Medium.csv"; } - } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.Fan-Tech-Medium.csv"; + } public sealed class FanHeavyLorries : AbstractFan { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.Fan-Tech.csv"; } - } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.Fan-Tech.csv"; + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/FuelData.cs b/VectoCore/VectoCore/Models/Declaration/FuelData.cs index 7aa63279ae83229c86ccdafb4eb024dc4082cb9a..6f4b775a3599cee96f715334fba4f4e70f13515d 100644 --- a/VectoCore/VectoCore/Models/Declaration/FuelData.cs +++ b/VectoCore/VectoCore/Models/Declaration/FuelData.cs @@ -54,15 +54,9 @@ namespace TUGraz.VectoCore.Models.Declaration private FuelData() { } - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".FuelTypes.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".FuelTypes.csv"; - protected override string ErrorMessage - { - get { return "FuelType {0} {1} not found!"; } - } + protected override string ErrorMessage => "FuelType {0} {1} not found!"; public Entry Lookup(FuelType fuelType, TankSystem? tankSystem = null) { @@ -81,10 +75,7 @@ namespace TUGraz.VectoCore.Models.Declaration return entries.First(); } - public static Entry Diesel - { - get { return Instance().Lookup(FuelType.DieselCI, null); } - } + public static Entry Diesel => Instance().Lookup(FuelType.DieselCI); protected override void ParseData(DataTable table) { @@ -119,7 +110,7 @@ namespace TUGraz.VectoCore.Models.Declaration return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) + if (obj.GetType() != GetType()) return false; return Equals((Entry)obj); @@ -166,10 +157,7 @@ namespace TUGraz.VectoCore.Models.Declaration public JoulePerKilogramm LowerHeatingValueVectoEngine { get; } - public double HeatingValueCorrection - { - get { return LowerHeatingValueVectoEngine / LowerHeatingValueVecto; } - } + public double HeatingValueCorrection => LowerHeatingValueVectoEngine / LowerHeatingValueVecto; public string GetLabel() { diff --git a/VectoCore/VectoCore/Models/Declaration/HVAC.cs b/VectoCore/VectoCore/Models/Declaration/HVAC.cs index c4e05fe303ab4d577906a0919108182dd70dbe32..7c20b0e87d62a0995968c694ef9879209cc8ad33 100644 --- a/VectoCore/VectoCore/Models/Declaration/HVAC.cs +++ b/VectoCore/VectoCore/Models/Declaration/HVAC.cs @@ -44,17 +44,9 @@ namespace TUGraz.VectoCore.Models.Declaration { private List<string> Technologies; - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.HVAC-Table.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.HVAC-Table.csv"; - protected override string ErrorMessage - { - get { - return "Auxiliary Lookup Error: No value found for HVAC. Mission: '{0}', Technology: '{1}' , HDVClass: '{2}'"; - } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for HVAC. Mission: '{0}', Technology: '{1}' , HDVClass: '{2}'"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/HVACCoolingPower.cs b/VectoCore/VectoCore/Models/Declaration/HVACCoolingPower.cs index f320d5cf9bac426ec7f04e2474baea3370293ffa..5be5e155552bf6e2064fb8500a6d4d8b9977edb5 100644 --- a/VectoCore/VectoCore/Models/Declaration/HVACCoolingPower.cs +++ b/VectoCore/VectoCore/Models/Declaration/HVACCoolingPower.cs @@ -33,7 +33,8 @@ namespace TUGraz.VectoCore.Models.Declaration { #region Overrides of LookupData protected override string ResourceId { get; } - protected override string ErrorMessage { get { return "No entry found for configuration {0}, mission {1}"; } } + protected override string ErrorMessage => "No entry found for configuration {0}, mission {1}"; + protected override void ParseData(DataTable table) { var missionTypes = Enum.GetValues(typeof(MissionType)).Cast<MissionType>().Where( diff --git a/VectoCore/VectoCore/Models/Declaration/LACDecisionFactor.cs b/VectoCore/VectoCore/Models/Declaration/LACDecisionFactor.cs index 3b8c92d1cd7a0562e93960cf73e1a589785aeb33..c9e6ba094862062f634e7806a9af167f9425b48e 100644 --- a/VectoCore/VectoCore/Models/Declaration/LACDecisionFactor.cs +++ b/VectoCore/VectoCore/Models/Declaration/LACDecisionFactor.cs @@ -71,15 +71,9 @@ namespace TUGraz.VectoCore.Models.Declaration public sealed class LACDecisionFactorVdrop : LookupData<MeterPerSecond, double> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".LAC-DF-Vdrop.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".LAC-DF-Vdrop.csv"; - protected override string ErrorMessage - { - get { throw new System.NotImplementedException(); } - } + protected override string ErrorMessage => throw new System.NotImplementedException(); public LACDecisionFactorVdrop() {} @@ -125,15 +119,9 @@ namespace TUGraz.VectoCore.Models.Declaration public sealed class LACDecisionFactorVTarget : LookupData<MeterPerSecond, double> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".LAC-DF-Vtarget.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".LAC-DF-Vtarget.csv"; - protected override string ErrorMessage - { - get { throw new System.NotImplementedException(); } - } + protected override string ErrorMessage => throw new System.NotImplementedException(); public LACDecisionFactorVTarget() {} diff --git a/VectoCore/VectoCore/Models/Declaration/LookupData.cs b/VectoCore/VectoCore/Models/Declaration/LookupData.cs index 413ab9f9a26e871f668999277d2b51df4496eaad..03f7315e3d2d4c9c70632820f228c1a5e039c35b 100644 --- a/VectoCore/VectoCore/Models/Declaration/LookupData.cs +++ b/VectoCore/VectoCore/Models/Declaration/LookupData.cs @@ -88,7 +88,7 @@ namespace TUGraz.VectoCore.Models.Declaration { protected Dictionary<TKey, TValue> Data = new Dictionary<TKey, TValue>(); - protected override string ErrorMessage { get { return "key {0} not found in lookup data"; } } + protected override string ErrorMessage => "key {0} not found in lookup data"; public virtual TValue Lookup(TKey key) { @@ -99,10 +99,7 @@ namespace TUGraz.VectoCore.Models.Declaration } } - public Dictionary<TKey, TValue> Entries - { - get { return Data; } - } + public Dictionary<TKey, TValue> Entries => Data; } public abstract class LookupData<TKey1, TKey2, TValue> : LookupData where TValue : struct diff --git a/VectoCore/VectoCore/Models/Declaration/PT1.cs b/VectoCore/VectoCore/Models/Declaration/PT1.cs index 9d063d929893f6993676318ace58931b29e8a11a..427e8decf1f6974b2070e0ef303330b4fe24a24b 100644 --- a/VectoCore/VectoCore/Models/Declaration/PT1.cs +++ b/VectoCore/VectoCore/Models/Declaration/PT1.cs @@ -41,15 +41,9 @@ namespace TUGraz.VectoCore.Models.Declaration { public sealed class PT1 : LookupData<PerSecond, PT1.PT1Result> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".PT1.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".PT1.csv"; - protected override string ErrorMessage - { - get { throw new InvalidOperationException("ErrorMessage not applicable."); } - } + protected override string ErrorMessage => throw new InvalidOperationException("ErrorMessage not applicable."); private List<KeyValuePair<PerSecond, Second>> _entries; diff --git a/VectoCore/VectoCore/Models/Declaration/PTOTransmission.cs b/VectoCore/VectoCore/Models/Declaration/PTOTransmission.cs index c8336db0fcf6040275761378db44bb003d4ea5a1..61cb57c6f31781722ee7c76aded1bbd144676cc4 100644 --- a/VectoCore/VectoCore/Models/Declaration/PTOTransmission.cs +++ b/VectoCore/VectoCore/Models/Declaration/PTOTransmission.cs @@ -40,15 +40,9 @@ namespace TUGraz.VectoCore.Models.Declaration { public const string NoPTO = "None"; - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.PTO-tech.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.PTO-tech.csv"; - protected override string ErrorMessage - { - get { return "PTO Transmission Lookup Error: No value found for PTO Transmission. Technology: '{0}'"; } - } + protected override string ErrorMessage => "PTO Transmission Lookup Error: No value found for PTO Transmission. Technology: '{0}'"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/Payloads.cs b/VectoCore/VectoCore/Models/Declaration/Payloads.cs index 5c8ee7fa3bbb7e144de95be0a1f358435d2abc5c..63b3080770069a6ac6530b90dcbc166ea049ea6d 100644 --- a/VectoCore/VectoCore/Models/Declaration/Payloads.cs +++ b/VectoCore/VectoCore/Models/Declaration/Payloads.cs @@ -39,15 +39,9 @@ namespace TUGraz.VectoCore.Models.Declaration { public sealed class Payloads : LookupData<Kilogram, Payloads.PayloadEntry> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".Payloads.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".Payloads.csv"; - protected override string ErrorMessage - { - get { throw new InvalidOperationException("ErrorMessage not applicable."); } - } + protected override string ErrorMessage => throw new InvalidOperationException("ErrorMessage not applicable."); public Kilogram Lookup10Percent(Kilogram grossVehicleWeight) { diff --git a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs index 4c137a52711bfbc0ad2520dc868fe3488cf6ef85..5222c8b0370903e4d4fa70feacdc4955840cc236 100644 --- a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs @@ -40,15 +40,9 @@ namespace TUGraz.VectoCore.Models.Declaration { public sealed class PneumaticSystem : LookupData<MissionType, string, AuxDemandEntry>, IDeclarationAuxiliaryTable { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.PS-Table.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.PS-Table.csv"; - protected override string ErrorMessage - { - get { return "Auxiliary Lookup Error: No value found for Pneumatic System. Mission: '{0}', Technology: '{1}'"; } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for Pneumatic System. Mission: '{0}', Technology: '{1}'"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/PrimaryBusSegments.cs b/VectoCore/VectoCore/Models/Declaration/PrimaryBusSegments.cs index a69f6935f75e86423de9d1ad844bcf80213f8f37..80ad3251a312d913ed0d925c36c89e31ef0bb08f 100644 --- a/VectoCore/VectoCore/Models/Declaration/PrimaryBusSegments.cs +++ b/VectoCore/VectoCore/Models/Declaration/PrimaryBusSegments.cs @@ -17,18 +17,9 @@ namespace TUGraz.VectoCore.Models.Declaration #region Overrides of LookupData - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".PrimaryBusSegmentationTable.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".PrimaryBusSegmentationTable.csv"; - protected override string ErrorMessage - { - get { - return - "ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}"; - } - } + protected override string ErrorMessage => "ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/StandardBodies.cs b/VectoCore/VectoCore/Models/Declaration/StandardBodies.cs index 4d81f98301400cff85f6da49876f45b3c5b1aaa0..8287ef494740ccce3055b066026fd0d6eebade10 100644 --- a/VectoCore/VectoCore/Models/Declaration/StandardBodies.cs +++ b/VectoCore/VectoCore/Models/Declaration/StandardBodies.cs @@ -46,10 +46,7 @@ namespace TUGraz.VectoCore.Models.Declaration public readonly List<Wheels.Entry> Wheels; public readonly CubicMeter CargoVolume; - public Kilogram MaxPayLoad - { - get { return GrossVehicleWeight - CurbWeight; } - } + public Kilogram MaxPayLoad => GrossVehicleWeight - CurbWeight; public StandardBody(string name, Kilogram curbWeight, Kilogram grossVehicleWeight, SquareMeter[] deltaCrossWindArea, Wheels.Entry? wheels, int axleCount, CubicMeter volume) : @@ -92,15 +89,9 @@ namespace TUGraz.VectoCore.Models.Declaration public static readonly StandardBody Empty = new StandardBody("", 0.SI<Kilogram>(), 0.SI<Kilogram>(), new[] { 0.SI<SquareMeter>(), 0.SI<SquareMeter>() }, null, 0, 0.SI<CubicMeter>()); - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".Body_Trailers_Weights.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".Body_Trailers_Weights.csv"; - protected override string ErrorMessage - { - get { return "StandardWeigths Lookup Error: No value found for ID '{0}'"; } - } + protected override string ErrorMessage => "StandardWeigths Lookup Error: No value found for ID '{0}'"; public override StandardBody Lookup(string id) { diff --git a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs index 194c81e2f4e82effa9323e0d6b056f1b69895085..2f24beb5edc17da0f76794209a894e00b48843ff 100644 --- a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs +++ b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs @@ -73,15 +73,9 @@ namespace TUGraz.VectoCore.Models.Declaration private sealed class SteeringPumpBaseLine : LookupData<MissionType, VehicleClass, SteeringPumpValues<Watt>> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.SP-Table.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.SP-Table.csv"; - protected override string ErrorMessage - { - get { return "Auxiliary Lookup Error: No value found for Steering Pump. Mission: '{0}', HDVClass: '{1}'"; } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for Steering Pump. Mission: '{0}', HDVClass: '{1}'"; protected override void ParseData(DataTable table) { @@ -102,15 +96,9 @@ namespace TUGraz.VectoCore.Models.Declaration private sealed class SteeringPumpTechnologies : LookupData<string, SteeringPumpValues<double>> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.SP-Tech.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.SP-Tech.csv"; - protected override string ErrorMessage - { - get { return "Auxiliary Lookup Error: No value found for SteeringPump Technology. Key: '{0}'"; } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for SteeringPump Technology. Key: '{0}'"; protected override void ParseData(DataTable table) { @@ -149,15 +137,9 @@ namespace TUGraz.VectoCore.Models.Declaration private sealed class SteeringPumpAxles : LookupData<MissionType, int, SteeringPumpValues<double>> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUX.SP-Axles.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUX.SP-Axles.csv"; - protected override string ErrorMessage - { - get { return "Auxiliary Lookup Error: No value found for SteeringPump Axle. Mission: '{0}', Axle Count: '{1}'"; } - } + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for SteeringPump Axle. Mission: '{0}', Axle Count: '{1}'"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/SteeringPumpBus.cs b/VectoCore/VectoCore/Models/Declaration/SteeringPumpBus.cs index 3da8514f463b0d72f7aa1078a615baa8582ed602..de3f5a88c4b6750ed4f1d45476759a47a5c4b612 100644 --- a/VectoCore/VectoCore/Models/Declaration/SteeringPumpBus.cs +++ b/VectoCore/VectoCore/Models/Declaration/SteeringPumpBus.cs @@ -59,8 +59,9 @@ namespace TUGraz.VectoCore.Models.Declaration { { #region Overrides of LookupData - protected override string ResourceId { get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUXBus.SP-Axles_Bus.csv"; } } - protected override string ErrorMessage { get { return "Auxiliary Lookup Error: No value found for Steering Pump. Mission: '{0}', HDVClass: '{1}'"; } } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUXBus.SP-Axles_Bus.csv"; + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for Steering Pump. Mission: '{0}', HDVClass: '{1}'"; + protected override void ParseData(DataTable table) { foreach (DataRow row in table.Rows) { @@ -83,13 +84,14 @@ namespace TUGraz.VectoCore.Models.Declaration { { #region Overrides of LookupData - protected override string ResourceId { get { return DeclarationData.DeclarationDataResourcePrefix + ".VAUXBus.SP-Factors_Bus.csv"; } } - protected override string ErrorMessage { get { return "Auxiliary Lookup Error: No value found for Steering Pump. Mission: '{0}', HDVClass: '{1}'"; } } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".VAUXBus.SP-Factors_Bus.csv"; + protected override string ErrorMessage => "Auxiliary Lookup Error: No value found for Steering Pump. Mission: '{0}', HDVClass: '{1}'"; + protected override void ParseData(DataTable table) { var missionTypes = Enum.GetValues(typeof(MissionType)).Cast<MissionType>().Where( m => ((m.IsDeclarationMission() && m != MissionType.ExemptedMission) || m == MissionType.VerificationTest) && - table.Columns.Contains("tubing-" + m.ToString())).ToList(); + table.Columns.Contains("tubing-" + m)).ToList(); foreach (DataRow row in table.Rows) { var axleNumber = row.Field<string>("technology"); diff --git a/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs b/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs index 814f8784b6fdd4ffa9e6b9fae78cad45739fe403..623c4f7af9fc084b08b45aa13613753bbbfb8f02 100644 --- a/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs +++ b/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs @@ -45,18 +45,9 @@ namespace TUGraz.VectoCore.Models.Declaration { private DataTable _segmentTable; - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".SegmentTable.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".SegmentTable.csv"; - protected override string ErrorMessage - { - get { - return - "ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}"; - } - } + protected override string ErrorMessage => "ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}"; protected override void ParseData(DataTable table) { @@ -203,10 +194,9 @@ namespace TUGraz.VectoCore.Models.Declaration var payloads = row.Field<string>(missionType.ToString()); - Kilogram refLoad, lowLoad; var weight = grossVehicleWeight; GetLoadings( - out lowLoad, out refLoad, payloads, (p, l) => GetLoading(p, weight, vehicleWeight, trailers, l), maxLoad); + out var lowLoad, out var refLoad, payloads, (p, l) => GetLoading(p, weight, vehicleWeight, trailers, l), maxLoad); var mission = new Mission { MissionType = missionType, diff --git a/VectoCore/VectoCore/Models/Declaration/TyreClass.cs b/VectoCore/VectoCore/Models/Declaration/TyreClass.cs index bad4a7e0c706c414cafcd1927885feeefc5b81f2..b1c4855b2ca2e6123205ac152b6ff90138ee1d75 100644 --- a/VectoCore/VectoCore/Models/Declaration/TyreClass.cs +++ b/VectoCore/VectoCore/Models/Declaration/TyreClass.cs @@ -50,8 +50,9 @@ namespace TUGraz.VectoCore.Models.Declaration #region Overrides of LookupData - protected override string ResourceId { get { return DeclarationData.DeclarationDataResourcePrefix + ".TyreLabeling.csv"; } } - protected override string ErrorMessage { get { return "No Tyre class found for RRC {0}"; } } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".TyreLabeling.csv"; + protected override string ErrorMessage => "No Tyre class found for RRC {0}"; + protected override void ParseData(DataTable table) { foreach (DataRow row in table.Rows) { diff --git a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs index ca33052e8b5320c3eb9880fe753bc97c752b3cd4..2123c256e8d19fbd1c3f05e0eeab53d7f6b1f9ed 100644 --- a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs +++ b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs @@ -50,15 +50,9 @@ namespace TUGraz.VectoCore.Models.Declaration private sealed class WHTCCorrectionData : LookupData<MissionType, Entry> { - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".WHTC-Weighting-Factors.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".WHTC-Weighting-Factors.csv"; - protected override string ErrorMessage - { - get { return "WHTC Correction Lookup Error: no value found. Mission: '{0}'"; } - } + protected override string ErrorMessage => "WHTC Correction Lookup Error: no value found. Mission: '{0}'"; protected override void ParseData(DataTable table) { diff --git a/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs b/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs index 6a8dd8e35430b9b5fca9e4b151e585cb42d156f8..b8e0c101204b52b1f2c075a8eeb40e3004e3ffc2 100644 --- a/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs +++ b/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs @@ -55,8 +55,9 @@ namespace TUGraz.VectoCore.Models.Declaration #region Overrides of LookupData - protected override string ResourceId { get { return DeclarationData.DeclarationDataResourcePrefix + ".CO2Standards.MissionProfileWeights.csv"; } } - protected override string ErrorMessage { get { return "No Weighting Factors found for Weighting Group {0}"; } } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".CO2Standards.MissionProfileWeights.csv"; + protected override string ErrorMessage => "No Weighting Factors found for Weighting Group {0}"; + protected override void ParseData(DataTable table) { var loadingTypes = new[] { LoadingType.LowLoading, LoadingType.ReferenceLoad }; diff --git a/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs b/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs index 65bf744edb766b3eb00535204bff23fb2dcf2024..1487733f93c171f9abe974b32cdfb180cc42b564 100644 --- a/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs +++ b/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs @@ -84,10 +84,10 @@ namespace TUGraz.VectoCore.Models.Declaration #region Overrides of LookupData - protected override string ResourceId { get { return DeclarationData.DeclarationDataResourcePrefix + ".CO2Standards.WeightingGroups.csv"; } } - protected override string ErrorMessage { get { - return "WeightingGroup Lookup Error: no entry found for group {0}, sleeper cab: {1}, engine rated power {2}"; - } } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".CO2Standards.WeightingGroups.csv"; + + protected override string ErrorMessage => "WeightingGroup Lookup Error: no entry found for group {0}, sleeper cab: {1}, engine rated power {2}"; + protected override void ParseData(DataTable table) { foreach (DataRow row in table.Rows) { diff --git a/VectoCore/VectoCore/Models/Declaration/Wheels.cs b/VectoCore/VectoCore/Models/Declaration/Wheels.cs index afa97f2805903da2b7ea76ee32ae29e3a3325b85..3ae7aae077a3cbfd1f4ad09011115ab71908d724 100644 --- a/VectoCore/VectoCore/Models/Declaration/Wheels.cs +++ b/VectoCore/VectoCore/Models/Declaration/Wheels.cs @@ -42,15 +42,9 @@ namespace TUGraz.VectoCore.Models.Declaration private string[] _dimensions; public TyreClass TyreClass = new TyreClass(); - protected override string ResourceId - { - get { return DeclarationData.DeclarationDataResourcePrefix + ".Wheels.csv"; } - } + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".Wheels.csv"; - protected override string ErrorMessage - { - get { return "Wheels Lookup Error: No value found for Wheels. Key: '{0}'"; } - } + protected override string ErrorMessage => "Wheels Lookup Error: No value found for Wheels. Key: '{0}'"; public override Entry Lookup(string key) { @@ -76,10 +70,7 @@ namespace TUGraz.VectoCore.Models.Declaration public Meter WheelsDiameter; public double CircumferenceFactor; - public Meter DynamicTyreRadius - { - get { return WheelsDiameter * CircumferenceFactor / (2 * Math.PI); } - } + public Meter DynamicTyreRadius => WheelsDiameter * CircumferenceFactor / (2 * Math.PI); } public string[] GetWheelsDimensions() diff --git a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs index dd376e59ebb0bb46dd356783c42b0d79e5063b81..f8356328e0ba18d8bfceb155b7750c0f5db54ed8 100644 --- a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs +++ b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs @@ -32,10 +32,7 @@ namespace TUGraz.VectoCore.Models.Declaration private static GenericBusEngineData _instance; - public static GenericBusEngineData Instance - { - get { return _instance ?? (_instance = new GenericBusEngineData()); } - } + public static GenericBusEngineData Instance => _instance ?? (_instance = new GenericBusEngineData()); #endregion @@ -153,7 +150,6 @@ namespace TUGraz.VectoCore.Models.Declaration denormalizedData.Rows.Add(newRow2); } - ; var fcMap = FuelConsumptionMapReader.Create(denormalizedData.AsEnumerable().OrderBy(r => r.Field<string>(FuelConsumptionMapReader.Fields.EngineSpeed).ToDouble()) .ThenBy(r => r.Field<string>(FuelConsumptionMapReader.Fields.Torque).ToDouble()).CopyToDataTable()); var engineCF = GetEngineCorrectionFactors(fuels); diff --git a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs index 67b3aaaf5c4dff81638043a4449c823e18ec7180..d45db546d7b6619722f90d57b80ce48ee66ca4df 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs @@ -134,12 +134,14 @@ namespace TUGraz.VectoCore.Models.Simulation.Data public SuperCapData SuperCapData { get; internal set; } - public SimulationType SimulationType { get; set; } + public SimulationType SimulationType { get; internal set; } - public VTPData VTPData { get; set; } + public VTPData VTPData { get; internal set; } - public ShiftStrategyParameters GearshiftParameters { get; set; } - public bool Exempted { get; set; } + public ShiftStrategyParameters GearshiftParameters { get; internal set; } + public bool Exempted { get; internal set; } + + public bool MultistageRun { get; internal set; } public IDrivingCycleData PTOCycleWhileDrive { get; internal set; } @@ -246,7 +248,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data var angledriveRatio = hasAngleDrive && angledriveData.Type == AngledriveType.SeparateAngledrive ? angledriveData.Angledrive.Ratio : 1.0; - var axlegearRatio = axleGearData != null ? axleGearData.AxleGear.Ratio : 1.0; + var axlegearRatio = axleGearData?.AxleGear.Ratio ?? 1.0; var dynamicTyreRadius = runData.VehicleData != null ? runData.VehicleData.DynamicTyreRadius : 0.0.SI<Meter>(); var vehicleMaxSpeed = runData.EngineData.FullLoadCurves[0].N95hSpeed / @@ -257,8 +259,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Data if (gearboxData.Gears.Count + 1 != engineData.FullLoadCurves.Count) { return new ValidationResult( - string.Format("number of full-load curves in engine does not match gear count. engine fld: {0}, gears: {1}", - engineData.FullLoadCurves.Count, gearboxData.Gears.Count)); + $"number of full-load curves in engine does not match gear count. " + + $"engine fld: {engineData.FullLoadCurves.Count}, gears: {gearboxData.Gears.Count}"); } foreach (var gear in gearboxData.Gears) { @@ -299,9 +301,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Data var tqLoss = gear.Value.LossMap.GetTorqueLoss(engineSpeed / gear.Value.Ratio, inTorque * gear.Value.Ratio); if (tqLoss.Extrapolated) { - return new ValidationResult( - string.Format("Interpolation of Gear-{0}-LossMap failed with torque={1} and angularSpeed={2}", gear.Key, - inTorque, engineSpeed.ConvertToRoundsPerMinute())); + return new ValidationResult($"Interpolation of Gear-{gear.Key}-LossMap failed " + + $"with torque={inTorque} " + + $"and angularSpeed={engineSpeed.ConvertToRoundsPerMinute()}"); } var angledriveTorque = (inTorque - tqLoss.Value) / gear.Value.Ratio; @@ -313,10 +315,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Data engineSpeed / gear.Value.Ratio / angledriveRatio, angledriveTorque * angledriveRatio); if (anglTqLoss.Extrapolated) { - return new ValidationResult( - string.Format( - "Interpolation of Angledrive-LossMap failed with torque={0} and angularSpeed={1}", - angledriveTorque, (engineSpeed / gear.Value.Ratio).ConvertToRoundsPerMinute())); + return new ValidationResult("Interpolation of Angledrive-LossMap failed " + + $"with torque={angledriveTorque} " + + $"and angularSpeed={(engineSpeed / gear.Value.Ratio).ConvertToRoundsPerMinute()}"); } } @@ -325,11 +326,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Data var axlTqLoss = axleGearData.AxleGear.LossMap.GetTorqueLoss(axleAngularVelocity, axlegearTorque * axleGearData.AxleGear.Ratio); if (axlTqLoss.Extrapolated) { - return - new ValidationResult( - string.Format( - "Interpolation of AxleGear-LossMap failed with torque={0} and angularSpeed={1} (gear={2}, velocity={3})", - axlegearTorque, axleAngularVelocity.ConvertToRoundsPerMinute(), gear.Key, velocity)); + return new ValidationResult("Interpolation of AxleGear-LossMap failed " + + $"with torque={axlegearTorque} " + + $"and angularSpeed={axleAngularVelocity.ConvertToRoundsPerMinute()} " + + $"(gear={gear.Key}, velocity={velocity})"); } } return null; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs index 17b9bfb1a31c0dfe7589a9b22254e3622fae3a0c..d1b158c5c72de5acf6818c82f64a924f66ca1549 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs @@ -61,24 +61,27 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl Container.Brakes.BrakePower = 0.SI<Watt>(); response = CyclePort.Request(AbsTime, ds); - response.Switch(). - Case<ResponseSuccess>(r => { dt = r.SimulationInterval; }). - Case<ResponseDrivingCycleDistanceExceeded>(r => { + switch (response) { + case ResponseSuccess r: + dt = r.SimulationInterval; + break; + case ResponseDrivingCycleDistanceExceeded r: if (r.MaxDistance.IsSmallerOrEqual(0)) { throw new VectoSimulationException("DistanceExceeded, MaxDistance is invalid: {0}", r.MaxDistance); } ds = r.MaxDistance; - }). - Case<ResponseCycleFinished>(r => { + break; + case ResponseCycleFinished _: FinishedWithoutErrors = true; Log.Info("========= Driving Cycle Finished"); - }). - Case<ResponseBatteryEmpty>( - r => { - FinishedWithoutErrors = true; - Log.Info("========= REESS empty"); - }). - Default(r => { throw new VectoException("DistanceRun got an unexpected response: {0}", r); }); + break; + case ResponseBatteryEmpty _: + FinishedWithoutErrors = true; + Log.Info("========= REESS empty"); + break; + default: + throw new VectoException("DistanceRun got an unexpected response: {0}", response); + } if (loopCount++ > Constants.SimulationSettings.MaximumIterationCountForSimulationStep) { throw new VectoSimulationException("Maximum iteration count for a single simulation interval reached! Aborting!"); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/ExemptedRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/ExemptedRun.cs index 7aeca33d1d57e26819b49dc3e7422bd6a4b679de..611fcfedbeaec3b22e34c04b1bd94010d53aaede 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/ExemptedRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/ExemptedRun.cs @@ -47,11 +47,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { #region Overrides of VectoRun - public override double Progress { get { return 1; } } + public override double Progress => 1; - public override string CycleName { get { return "ExemptedVehicle"; } } + public override string CycleName => "ExemptedVehicle"; - public override string RunSuffix { get { return ""; } } + public override string RunSuffix => ""; protected override IResponse DoSimulationStep() { @@ -63,6 +63,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { private void CheckValidInput() { + if (Container.RunData.MultistageRun) { + return; + } var vehicleData = Container.RunData.VehicleData; if (vehicleData.ZeroEmissionVehicle && vehicleData.DualFuelVehicle) { throw new VectoException("Invalid input: ZE-HDV and DualFuelVehicle are mutually exclusive!"); diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs index 2c1894114e9a739641733690f5d3292bf8bd6dda..a8987e044a6f97b692107508bf89d244eb55ed99 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs @@ -166,9 +166,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public int CurrentIdx { get; private set; } - public int Count { get { return Segments.Count; } } + public int Count => Segments.Count; - public PCCSegment Current { get { return Segments.Any() ? Segments[CurrentIdx] : null; } } + public PCCSegment Current => Segments.Any() ? Segments[CurrentIdx] : null; public List<PCCSegment> Segments { get; } } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 1aa637a434e9d524a385cb6853b595ab1946ad39..2d345091b64cb893ea30f4dbcd2fd1cf2435d73b 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -1011,7 +1011,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl //return new ATShiftStrategy(runData, container); default: throw new ArgumentOutOfRangeException("GearboxType", - string.Format("Unknown Gearbox Type {0}", runData.GearboxData.Type.ToString())); + $"Unknown Gearbox Type {runData.GearboxData.Type.ToString()}"); } } @@ -1020,8 +1020,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl x.Item2.Equals(shiftStrategy, StringComparison.InvariantCultureIgnoreCase)); if (selected == null) { throw new ArgumentOutOfRangeException("ShiftStrategy", - string.Format("Unknown Shiftstrategy {0} for Gearbox Type {1}", shiftStrategy, - runData.GearboxData.Type.ToString())); + $"Unknown Shiftstrategy {shiftStrategy} for Gearbox Type {runData.GearboxData.Type.ToString()}"); } runData.ShiftStrategy = selected.Item3; @@ -1087,20 +1086,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region Implementation of IDriverInfo - public DrivingBehavior DriverBehavior - { - get { return DrivingBehavior.Accelerating; } - } + public DrivingBehavior DriverBehavior => DrivingBehavior.Accelerating; - public DrivingAction DrivingAction - { - get { return DrivingAction.Accelerate; } - } + public DrivingAction DrivingAction => DrivingAction.Accelerate; - public MeterPerSquareSecond DriverAcceleration - { - get { return 0.SI<MeterPerSquareSecond>(); } - } + public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); #endregion } @@ -1128,75 +1118,39 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region Implementation of IGearboxInfo - public GearboxType GearboxType - { - get {return GearboxType.DrivingCycle; } - } + public GearboxType GearboxType => GearboxType.DrivingCycle; - public GearshiftPosition Gear - { - get { return new GearshiftPosition(0); } - } + public GearshiftPosition Gear => new GearshiftPosition(0); - public bool TCLocked - { - get { return true; } - } + public bool TCLocked => true; - public MeterPerSecond StartSpeed - { - get { throw new VectoException("No Gearbox available. StartSpeed unknown."); } - } + public MeterPerSecond StartSpeed => throw new VectoException("No Gearbox available. StartSpeed unknown."); - public MeterPerSquareSecond StartAcceleration - { - get { throw new VectoException("No Gearbox available. StartAcceleration unknown."); } - } + public MeterPerSquareSecond StartAcceleration => throw new VectoException("No Gearbox available. StartAcceleration unknown."); public Watt GearboxLoss() { throw new VectoException("No Gearbox available."); } - public Second LastShift - { - get { throw new VectoException("No Gearbox available."); } - } + public Second LastShift => throw new VectoException("No Gearbox available."); - public Second LastUpshift - { - get { throw new VectoException("No Gearbox available."); } - } + public Second LastUpshift => throw new VectoException("No Gearbox available."); - public Second LastDownshift - { - get { throw new VectoException("No Gearbox available."); } - } + public Second LastDownshift => throw new VectoException("No Gearbox available."); public GearData GetGearData(uint gear) { throw new VectoException("No Gearbox available."); } - public GearshiftPosition NextGear - { - get { throw new VectoException("No Gearbox available."); } - } + public GearshiftPosition NextGear => throw new VectoException("No Gearbox available."); - public Second TractionInterruption - { - get { throw new NotImplementedException(); } - } + public Second TractionInterruption => throw new NotImplementedException(); - public uint NumGears - { - get { throw new NotImplementedException(); } - } + public uint NumGears => throw new NotImplementedException(); - public bool DisengageGearbox - { - get { throw new VectoException("No Gearbox available."); } - } + public bool DisengageGearbox => throw new VectoException("No Gearbox available."); public bool GearEngaged(Second absTime) { @@ -1229,10 +1183,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region Implementation of IMileageCounter - public Meter Distance - { - get { return 0.SI<Meter>(); } - } + public Meter Distance => 0.SI<Meter>(); #endregion } @@ -1260,55 +1211,34 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region Implementation of IVehicleInfo - public MeterPerSecond VehicleSpeed - { - get { return 0.SI<MeterPerSecond>(); } - } + public MeterPerSecond VehicleSpeed => 0.SI<MeterPerSecond>(); - public bool VehicleStopped - { - get { throw new System.NotImplementedException(); } - } + public bool VehicleStopped => throw new NotImplementedException(); - public Kilogram VehicleMass - { - get { throw new System.NotImplementedException(); } - } + public Kilogram VehicleMass => throw new NotImplementedException(); - public Kilogram VehicleLoading - { - get { throw new System.NotImplementedException(); } - } + public Kilogram VehicleLoading => throw new NotImplementedException(); - public Kilogram TotalMass - { - get { throw new System.NotImplementedException(); } - } + public Kilogram TotalMass => throw new NotImplementedException(); - public CubicMeter CargoVolume - { - get { throw new System.NotImplementedException(); } - } + public CubicMeter CargoVolume => throw new NotImplementedException(); public Newton AirDragResistance(MeterPerSecond previousVelocity, MeterPerSecond nextVelocity) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public Newton RollingResistance(Radian gradient) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public Newton SlopeResistance(Radian gradient) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } - public MeterPerSecond MaxVehicleSpeed - { - get { throw new System.NotImplementedException(); } - } + public MeterPerSecond MaxVehicleSpeed => throw new NotImplementedException(); #endregion } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index bddcacb7b1bd208134967d46255bbed923fd45c0..afc3a8bdc44faeb5566c095bbd82836ff309733c 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -73,9 +73,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ModWriter = writer; Validate = validate; - int workerThreads; - int completionThreads; - ThreadPool.GetMinThreads(out workerThreads, out completionThreads); + ThreadPool.GetMinThreads(out var workerThreads, out var completionThreads); if (workerThreads < 12) { workerThreads = 12; } @@ -214,7 +212,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var current = i++; var d = data; data.JobRunId = current; - yield return data.Exempted ? GetExemptedRun(data) : GetNonExemptedRun(data, current, d, ref warning1Hz); + yield return data.Exempted || data.MultistageRun ? GetExemptedRun(data) : GetNonExemptedRun(data, current, d, ref warning1Hz); } } @@ -266,7 +264,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl if (Validate) { ValidateVectoRunData( - run, data.JobType, data.ElectricMachinesData.FirstOrDefault()?.Item1, data.GearboxData == null ? (GearboxType?)null : data.GearboxData.Type, + run, data.JobType, data.ElectricMachinesData.FirstOrDefault()?.Item1, data.GearboxData?.Type, data.Mission != null && data.Mission.MissionType.IsEMS()); } return run; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/TimeRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/TimeRun.cs index f5aa88bef0053f8c0aac802b3bfbea4540ec07a7..47f210f5946281859960e8c99cea999037bed04f 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/TimeRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/TimeRun.cs @@ -39,7 +39,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { public class TimeRun : VectoRun { - public TimeRun(IVehicleContainer container) : base(container) {} + public TimeRun(IVehicleContainer container) : base(container) { } protected override IResponse DoSimulationStep() { @@ -51,15 +51,20 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl do { response = CyclePort.Request(AbsTime, dt); debug.Add(response); - - response.Switch(). - Case<ResponseSuccess>(r => { dt = r.SimulationInterval; }). - Case<ResponseFailTimeInterval>(r => { dt = r.DeltaT; }). - Case<ResponseCycleFinished>(r => { + switch (response) { + case ResponseSuccess r: + dt = r.SimulationInterval; + break; + case ResponseFailTimeInterval r: + dt = r.DeltaT; + break; + case ResponseCycleFinished r: FinishedWithoutErrors = true; Log.Info("========= Driving Cycle Finished"); - }). - Default(r => { throw new VectoException("TimeRun got an unexpected response: {0}", r); }); + break; + default: + throw new VectoException("TimeRun got an unexpected response: {0}", response); + } if (loopCount++ > Constants.SimulationSettings.MaximumIterationCountForSimulationStep) { throw new VectoSimulationException("Maximum iteration count for a single simulation interval reached! Aborting!"); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs index b3b21458d2d3923b077c5c0b55d023cc46b4b419..fd1fb036b33b8f77d530c1a0b7d763d525879dcf 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs @@ -61,30 +61,15 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public int RunIdentifier { get; protected set; } - public virtual string RunName - { - get { return Container.RunData.JobName; } - } + public virtual string RunName => Container.RunData.JobName; - public virtual string CycleName - { - get { return Container.RunData.Cycle.Name; } - } + public virtual string CycleName => Container.RunData.Cycle.Name; - public virtual string RunSuffix - { - get { return Container.RunData.ModFileSuffix; } - } + public virtual string RunSuffix => Container.RunData.ModFileSuffix; - public int JobRunIdentifier - { - get { return Container.RunData.JobRunId; } - } + public int JobRunIdentifier => Container.RunData.JobRunId; - public virtual double Progress - { - get { return CyclePort.Progress * (PostProcessingDone ? 1.0 : 0.99) * (WritingResultsDone ? 1.0 : 0.99); } - } + public virtual double Progress => CyclePort.Progress * (PostProcessingDone ? 1.0 : 0.99) * (WritingResultsDone ? 1.0 : 0.99); protected VectoRun(IVehicleContainer container) { @@ -139,7 +124,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl Container.AbsTime = AbsTime; } } while (response is ResponseSuccess); - if (!GetContainer().RunData.Exempted) { + if (!(GetContainer().RunData.Exempted || GetContainer().RunData.MultistageRun)) { //foreach (var fuel in GetContainer().RunData.EngineData.Fuels) { // calculate vehicleline correction here in local thread context because writing sum-data and report afterwards is synchronized //var cf = GetContainer().ModalData.VehicleLineCorrectionFactor(fuel.FuelData); @@ -186,7 +171,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl throw ex; } - Container.RunStatus = Container.RunData.Exempted + Container.RunStatus = Container.RunData.Exempted || Container.RunData.MultistageRun ? Status.Success : CyclePort.Progress < 1 ? (response is ResponseBatteryEmpty ? Status.REESSEmpty : Status.Aborted) diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index bd914050011c15eb7f0527706d477cb7d3d7f238..71c8d5202e7e268754772f21515b0b10c85ce245 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -82,10 +82,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public IDCDCConverter DCDCConverter { get; private set; } - public virtual bool IsTestPowertrain - { - get { return false; } - } + public virtual bool IsTestPowertrain => false; internal ISimulationOutPort Cycle; @@ -98,7 +95,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl internal readonly Dictionary<PowertrainPosition, IElectricMotorInfo> ElectricMotors = new Dictionary<PowertrainPosition, IElectricMotorInfo>(); - + public VehicleContainer(ExecutionMode executionMode, IModalDataContainer modData = null, WriteSumData writeSumData = null) { @@ -109,10 +106,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region IVehicleContainer - public virtual IModalDataContainer ModalData - { - get { return ModData; } - } + public virtual IModalDataContainer ModalData => ModData; public virtual ISimulationOutPort GetCycleOutPort() { @@ -123,88 +117,75 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public virtual Second AbsTime { get; set; } public IElectricMotorInfo ElectricMotorInfo(PowertrainPosition pos) { - return ElectricMotors.ContainsKey(pos) ? ElectricMotors[pos] : null; + return ElectricMotors.ContainsKey(pos) ? ElectricMotors[pos] : null; } - public IPowertainInfo PowertrainInfo - { - get { return this; } - } + public IPowertainInfo PowertrainInfo => this; - public IHybridControllerInfo HybridControllerInfo - { - get { return HybridController; } - } + public IHybridControllerInfo HybridControllerInfo => HybridController; - public IHybridControllerCtl HybridControllerCtl - { - get { return HybridController; } - } + public IHybridControllerCtl HybridControllerCtl => HybridController; - public virtual void AddComponent(VectoSimulationComponent component) { var commitPriority = 0; - var ignoreComponent = false; - component.Switch() - .If<IEngineInfo>(c => { - EngineInfo = c; - commitPriority = 2; - HasCombustionEngine = true; - }) - .If<IEngineControl>(c => { EngineCtl = c; }) - .If<IDriverInfo>(c => DriverInfo = c) - .If<IGearboxInfo>(c => { - GearboxInfo = c; - commitPriority = 4; - HasGearbox = true; - }) - .If<IGearboxControl>(c => GearboxCtl = c) - .If<ITorqueConverterInfo>(c => TorqueConverterInfo = c) - .If<ITorqueConverterControl>(c => TorqueConverterCtl = c) - .If<IAxlegearInfo>(c => AxlegearInfo = c) - .If<IAngledriveInfo>(c => AngledriveInfo = c) - .If<IWheelsInfo>(c => WheelsInfo = c) - .If<IVehicleInfo>(c => { - VehicleInfo = c; - commitPriority = 5; - }) - .If<ISimulationOutPort>(c => Cycle = c) - .If<IMileageCounter>(c => MileageCounter = c) - .If<IBrakes>(c => Brakes = c) - .If<IClutchInfo>(c => ClutchInfo = c) - .If<IDrivingCycleInfo>(c => { - DrivingCycleInfo = c; - commitPriority = 6; - }) - .If<PTOCycleController>(c => { commitPriority = 99; }) - .If<VTPCycle>(_ => { commitPriority = 0; }) - .If<IElectricMotorInfo>(c => { - if (c.Position == PowertrainPosition.HybridPositionNotSet) { - ignoreComponent = true; - return; - } - if (ElectricMotors.ContainsKey(c.Position)) { - throw new VectoException("There is already an electric machine at position {0}", - c.Position); - } - - ElectricMotors[c.Position] = c; - HasElectricMotor = true; - }) - .If<IHybridController>(c => { HybridController = c; }) - .If<IRESSInfo>(c => BatteryInfo = c) - .If<BusAuxiliariesAdapter>(c => BusAux = c) - .If<IDCDCConverter>(c => DCDCConverter = c); - - - if (ignoreComponent) { - return; + + if (component is IEngineControl c1) { EngineCtl = c1; } + if (component is IDriverInfo c2) { DriverInfo = c2; } + if (component is IGearboxControl c3) { GearboxCtl = c3; } + if (component is ITorqueConverterInfo c4) { TorqueConverterInfo = c4; } + if (component is ITorqueConverterControl c5) { TorqueConverterCtl = c5; } + if (component is IAxlegearInfo c6) { AxlegearInfo = c6; } + if (component is IAngledriveInfo c7) { AngledriveInfo = c7; } + if (component is IWheelsInfo c8) { WheelsInfo = c8; } + if (component is ISimulationOutPort c9) { Cycle = c9; } + if (component is IMileageCounter c10) { MileageCounter = c10; } + if (component is IBrakes c11) { Brakes = c11; } + if (component is IClutchInfo c12) { ClutchInfo = c12; } + if (component is IHybridController c13) { HybridController = c13; } + if (component is IRESSInfo c14) { BatteryInfo = c14; } + if (component is BusAuxiliariesAdapter c15) { BusAux = c15; } + if (component is IDCDCConverter c16) { DCDCConverter = c16; } + + if (component is IEngineInfo c17){ + EngineInfo = c17; + commitPriority = 2; + HasCombustionEngine = true; } + if (component is IGearboxInfo c18) { + GearboxInfo = c18; + commitPriority = 4; + HasGearbox = true; + } + + if (component is IVehicleInfo c19) { + VehicleInfo = c19; + commitPriority = 5; + } + + if (component is IDrivingCycleInfo c20) { + DrivingCycleInfo = c20; + commitPriority = 6; + } + if (component is PTOCycleController c21) { commitPriority = 99; } + if (component is VTPCycle c22) { commitPriority = 0; } + if (component is IElectricMotorInfo c23) { + if (c23.Position == PowertrainPosition.HybridPositionNotSet) { + return; + } + if (ElectricMotors.ContainsKey(c23.Position)) { + throw new VectoException("There is already an electric machine at position {0}", c23.Position); + } + + ElectricMotors[c23.Position] = c23; + HasElectricMotor = true; + } + _components.Add(Tuple.Create(commitPriority, component)); + //todo mk20210617 use sorted list with inverse commitPriority (-commitPriority) _components = _components.OrderBy(x => x.Item1).Reverse().ToList(); } @@ -239,10 +220,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl DrivingCycleInfo?.FinishSimulation(); } - public virtual IEnumerable<ISimulationPreprocessor> GetPreprocessingRuns - { - get { return new ReadOnlyCollection<ISimulationPreprocessor>(Preprocessors); } - } + public virtual IEnumerable<ISimulationPreprocessor> GetPreprocessingRuns => new ReadOnlyCollection<ISimulationPreprocessor>(Preprocessors); public virtual void AddPreprocessor(ISimulationPreprocessor simulationPreprocessor) { @@ -265,21 +243,18 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public virtual bool HasElectricMotor { get; private set; } - public PowertrainPosition[] ElectricMotorPositions - { - get { return ElectricMotors.Keys.ToArray(); } - } + public PowertrainPosition[] ElectricMotorPositions => ElectricMotors.Keys.ToArray(); public virtual bool HasCombustionEngine { get; private set; } public virtual bool HasGearbox { get; private set; } - + public virtual VectoRunData RunData { get; set; } public virtual ExecutionMode ExecutionMode { get; } - + } public class ExemptedRunContainer : VehicleContainer @@ -300,29 +275,19 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region Overrides of VehicleContainer - public override IMileageCounter MileageCounter - { - get { return _mileageCounter; } - - } + public override IMileageCounter MileageCounter => _mileageCounter; #endregion #region Overrides of VehicleContainer - public override IVehicleInfo VehicleInfo - { - get { return _vehicleInfo; } - } + public override IVehicleInfo VehicleInfo => _vehicleInfo; #endregion #region Overrides of VehicleContainer - public override IGearboxInfo GearboxInfo - { - get { return _gearboxInfo; } - } + public override IGearboxInfo GearboxInfo => _gearboxInfo; #endregion } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs index 6d5983615d94447127e863e78c55d0406d234d34..0e63c8286c4c9761f33a4629698cc2180fe48e92 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs @@ -60,10 +60,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data DataBus = dataBus; } - public CrossWindCorrectionMode CorrectionMode - { - get { return CrossWindCorrectionMode.VAirBetaLookupTable; } - } + public CrossWindCorrectionMode CorrectionMode => CrossWindCorrectionMode.VAirBetaLookupTable; public Watt AverageAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2, KilogramPerCubicMeter airDensity) { @@ -98,8 +95,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (beta > AirDragEntries.Last().Beta) { throw new VectoSimulationException("Beta / CdxA Lookup table does not cover beta={0}", beta); } - int index; - AirDragEntries.GetSection(x => x.Beta < beta, out index); + + AirDragEntries.GetSection(x => x.Beta < beta, out var index); return index + 1; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index 9a1292cc2008c5331877b76455fb0ea32881c21e..ead6520b54df8872e43876e02c015cb8df5488f4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -114,7 +114,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } } if (result.Any()) { - return new ValidationResult(string.Format("Validation of Cycle {0} failed", cycleData.Name), result); + return new ValidationResult($"Validation of Cycle {cycleData.Name} failed", result); } return ValidationResult.Success; } @@ -170,10 +170,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// <summary> /// [%] Optional. /// </summary> - public Scalar RoadGradientPercent - { - get { return (Math.Tan(RoadGradient.Value()) * 100).SI<Scalar>(); } - } + public Scalar RoadGradientPercent => (Math.Tan(RoadGradient.Value()) * 100).SI<Scalar>(); public Dictionary<FuelType, KilogramPerSecond> VTPFuelconsumption; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs index 20add777492266ccb3a11d60deb7312e9f9e9204..92fb6d5839e5af7bd2f2a32d79eb892750ccfb5f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs @@ -55,9 +55,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor var response = LookupElectricPower(angularSpeed, torque, true); var delta = response.ElectricalPower - electricPower; torque = SearchAlgorithm.Search(torque, delta, torque * 0.1, - getYValue: result => ((EfficiencyMap.EfficiencyResult)result).ElectricalPower - electricPower, + getYValue: result => ((EfficiencyResult)result).ElectricalPower - electricPower, evaluateFunction: x => LookupElectricPower(angularSpeed, x, true), - criterion: result => (((EfficiencyMap.EfficiencyResult)result).ElectricalPower - electricPower).Value()); + criterion: result => (((EfficiencyResult)result).ElectricalPower - electricPower).Value()); return new EfficiencyResult { @@ -76,16 +76,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor } [JsonIgnore] - public IReadOnlyCollection<EfficiencyMap.Entry> Entries + public IReadOnlyCollection<Entry> Entries { get { var entries = _efficiencyMapMech2El.Entries; - var retVal = new EfficiencyMap.Entry[entries.Count]; + var retVal = new Entry[entries.Count]; var i = 0; foreach (var entry in entries) { - retVal[i++] = new EfficiencyMap.Entry(entry.Y.SI<PerSecond>(), entry.X.SI<NewtonMeter>(), entry.Z.SI<Watt>()); + retVal[i++] = new Entry(entry.Y.SI<PerSecond>(), entry.X.SI<NewtonMeter>(), entry.Z.SI<Watt>()); } return retVal; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs index eaf186a03d4aa27aa4abaf218542412717594fdd..c1752c795dbf43a8a7e24ec4da242c1e8e86356e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs @@ -106,19 +106,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine /// Get the rated speed from the given full-load curve (i.e. speed with max. power) /// </summary> [Required, SIRange(0, 5000 * Constants.RPMToRad)] - public PerSecond RatedSpeed - { - get { return _ratedSpeed ?? ComputeRatedSpeed().Item1; } - } + public PerSecond RatedSpeed => _ratedSpeed ?? ComputeRatedSpeed().Item1; /// <summary> /// Gets the maximum power. /// </summary> [Required, SIRange(0, 10000 * 5000 * Constants.RPMToRad)] - public Watt MaxPower - { - get { return _maxPower ?? ComputeRatedSpeed().Item2; } - } + public Watt MaxPower => _maxPower ?? ComputeRatedSpeed().Item2; public NewtonMeter MaxTorque { @@ -277,30 +271,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine } } - public PerSecond NTq99hSpeed - { - get { return _nTq99hSpeed ?? (_nTq99hSpeed = FindEnginSpeedForTorque(0.99 * MaxTorque).Last()); } - } + public PerSecond NTq99hSpeed => _nTq99hSpeed ?? (_nTq99hSpeed = FindEnginSpeedForTorque(0.99 * MaxTorque).Last()); - public PerSecond NTq99lSpeed - { - get { return _nTq99lSpeed ?? (_nTq99lSpeed = FindEnginSpeedForTorque(0.99 * MaxTorque).First()); } - } + public PerSecond NTq99lSpeed => _nTq99lSpeed ?? (_nTq99lSpeed = FindEnginSpeedForTorque(0.99 * MaxTorque).First()); - public PerSecond NP99hSpeed - { - get { return _nP99hSpeed ?? (_nP99hSpeed = ComputeNP99HSpeed()); } - } + public PerSecond NP99hSpeed => _nP99hSpeed ?? (_nP99hSpeed = ComputeNP99HSpeed()); - public PerSecond NTq98hSpeed - { - get { return _nTq98hSpeed ?? (_nTq98hSpeed = FindEnginSpeedForTorque(0.98 * MaxTorque).Last()); } - } + public PerSecond NTq98hSpeed => _nTq98hSpeed ?? (_nTq98hSpeed = FindEnginSpeedForTorque(0.98 * MaxTorque).Last()); - public PerSecond NP98hSpeed - { - get { return _nP98hSpeed ?? (_nP98hSpeed = ComputeNP98HSpeed()); } - } + public PerSecond NP98hSpeed => _nP98hSpeed ?? (_nP98hSpeed = ComputeNP98HSpeed()); private PerSecond ComputeNP99HSpeed() { @@ -322,10 +301,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine return retVal; } - public PerSecond LoSpeed - { - get { return _engineSpeedLo ?? (_engineSpeedLo = FindEngineSpeedForPower(0.55 * MaxPower).First()); } - } + public PerSecond LoSpeed => _engineSpeedLo ?? (_engineSpeedLo = FindEngineSpeedForPower(0.55 * MaxPower).First()); //public PerSecond HiSpeed //{ diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs index f238ae28186563e20a2712487202d39db72c851f..f932d239d8ba0a2bd1525fc6910c03677579f8f5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs @@ -15,10 +15,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData WHRMap = whrMap; } - public string Name - { - get { return WHRMap.Name; } - } + public string Name => WHRMap.Name; public class Entry { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs index bec2802d1899b068677136f1087e3b6e1cc44498..6a33c200e9c2269b49e1add81c0b855e39ba9ad2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs @@ -54,15 +54,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox TorqueConverterRatio = double.NaN; } - public bool HasTorqueConverter - { - get { return !double.IsNaN(TorqueConverterRatio) && TorqueConverterGearLossMap != null; } - } + public bool HasTorqueConverter => !double.IsNaN(TorqueConverterRatio) && TorqueConverterGearLossMap != null; - public bool HasLockedGear - { - get { return !double.IsNaN(Ratio) && LossMap != null; } - } + public bool HasLockedGear => !double.IsNaN(Ratio) && LossMap != null; [ValidateObject] public ShiftPolygon ShiftPolygon { get; internal set; } @@ -82,11 +76,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { var validationService = context.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; - var mode = validationService != null ? validationService.Mode : ExecutionMode.Declaration; + var mode = validationService?.Mode ?? ExecutionMode.Declaration; var gbxType = validationService != null ? validationService.GearboxType : GearboxType.MT; var emsMission = validationService != null && validationService.IsEMSCycle; - var jobType = validationService != null ? validationService.JobType : VectoSimulationJobType.ConventionalVehicle; - var emPos = validationService != null ? validationService.EMPowertrainPosition : (PowertrainPosition?)null; + var jobType = validationService?.JobType ?? VectoSimulationJobType.ConventionalVehicle; + var emPos = validationService?.EMPowertrainPosition; if (gearData.HasTorqueConverter) { if (gearData.TorqueConverterShiftPolygon == null) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs index ed7babace64f6dfab1b1c0bb582c45495592938e..20536240d6cb843012dc70f5fcd26052c524cc78 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs @@ -54,16 +54,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox } [JsonIgnore] - public ReadOnlyCollection<ShiftPolygonEntry> Upshift - { - get { return _upShiftPolygon.AsReadOnly(); } - } + public ReadOnlyCollection<ShiftPolygonEntry> Upshift => _upShiftPolygon.AsReadOnly(); [JsonIgnore] - public ReadOnlyCollection<ShiftPolygonEntry> Downshift - { - get { return _downShiftPolygon.AsReadOnly(); } - } + public ReadOnlyCollection<ShiftPolygonEntry> Downshift => _downShiftPolygon.AsReadOnly(); public string[] DownshiftSerialized { @@ -164,7 +158,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { var validationService = validationContext.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; - var gbxType = validationService != null ? validationService.GearboxType : null; + var gbxType = validationService?.GearboxType; if (gbxType == null || gbxType.Value.AutomaticTransmission()) { return ValidationResult.Success; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs index 87239edc6d15e1d23ef9e421c5fe7503c80f8ec1..de9e1b6fb3dcdb50ba3e6532964fa132e80dbae3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs @@ -136,10 +136,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox inAngularVelocity.AsRPM); } - public GearLossMapEntry this[int i] - { - get { return _entries[i]; } - } + public GearLossMapEntry this[int i] => _entries[i]; #if DEBUG public void DrawGraph() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs index e6b26aa3b4a57b78d9c1ec7d737680c81245632f..eb4c7d5c00c0c8d2280800b9a0a7356cdd9e31d2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs @@ -81,13 +81,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [JsonIgnore] - public GearList GearList - { - get - { - return _gearlist ?? (_gearlist = CreateGearList()); - } - } + public GearList GearList => _gearlist ?? (_gearlist = CreateGearList()); private GearList CreateGearList() { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/AverageAccelerationTorqueLookup.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/AverageAccelerationTorqueLookup.cs index 9f475b8c1a44eda7739294e05887a91e643fb8e7..7a62beffe7461fe2def052f2987504701fd3b103 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/AverageAccelerationTorqueLookup.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/AverageAccelerationTorqueLookup.cs @@ -10,9 +10,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public KeyValuePair<Tuple<PerSecond, NewtonMeter>, NewtonMeter>[] Data { - set { - SetData(value); - } + set => SetData(value); } #region Overrides of Interpolate2D<PerSecond,NewtonMeter,NewtonMeter,KeyValuePair<Tuple<PerSecond,NewtonMeter>,NewtonMeter>> diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs index 565fa8c12eb3bb2887dbc9c2f0aa7ffd84ac5b02..51d3fd037419492c81a9c000f79bfb7d7eed0e10 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var validationService = context.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; - return validationService == null ? ExecutionMode.Declaration : validationService.Mode; + return validationService?.Mode ?? ExecutionMode.Declaration; } protected static bool GetEmsMode(ValidationContext context) @@ -71,7 +71,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var validationService = context.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; - return validationService != null ? validationService.JobType : VectoSimulationJobType.ConventionalVehicle; + return validationService?.JobType ?? VectoSimulationJobType.ConventionalVehicle; } @@ -79,7 +79,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var validationService = context.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; - return validationService != null ? validationService.EMPowertrainPosition : (PowertrainPosition?)null; + return validationService?.EMPowertrainPosition; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index ba466b68f6de66b15a4d600d44225d81da4974e2..15969af8e60efee043a86847064d36973e718297 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -100,7 +100,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public List<Axle> AxleData { - get { return _axleData; } + get => _axleData; internal set { _axleData = value; _wheelsInertia = null; @@ -163,7 +163,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } return _wheelsInertia; } - internal set { _wheelsInertia = value; } + internal set => _wheelsInertia = value; } //[Required, SIRange(0, 1E12)] @@ -175,7 +175,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } return _totalRollResistanceCoefficient.GetValueOrDefault(); } - protected internal set { _totalRollResistanceCoefficient = value; } + protected internal set => _totalRollResistanceCoefficient = value; } public double RollResistanceCoefficientWithoutTrailer @@ -186,7 +186,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } return _rollResistanceCoefficientWithoutTrailer.GetValueOrDefault(); } - protected internal set { _rollResistanceCoefficientWithoutTrailer = value; } + protected internal set => _rollResistanceCoefficientWithoutTrailer = value; } public Kilogram TotalVehicleMass @@ -200,10 +200,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } } - public Kilogram TotalCurbMass - { - get { return (CurbMass ?? 0.SI<Kilogram>()) + (BodyAndTrailerMass ?? 0.SI<Kilogram>()); } - } + public Kilogram TotalCurbMass => (CurbMass ?? 0.SI<Kilogram>()) + (BodyAndTrailerMass ?? 0.SI<Kilogram>()); public Kilogram MinimumVehicleMass { @@ -215,10 +212,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } } - public Kilogram MaximumVehicleMass - { - get { return GrossVehicleMass; } - } + public Kilogram MaximumVehicleMass => GrossVehicleMass; public double AverageRollingResistanceTruck { @@ -228,7 +222,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } return _averageRollingResistanceTruck.GetValueOrDefault(); } - protected internal set { _averageRollingResistanceTruck = value; } + protected internal set => _averageRollingResistanceTruck = value; } public bool ZeroEmissionVehicle { get; internal set; } @@ -327,19 +321,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var weightShareSum = vehicleData.AxleData.Sum(axle => axle.AxleWeightShare); if (!weightShareSum.IsEqual(1.0, 1E-10)) { return new ValidationResult( - string.Format("Sum of axle weight share is not 1! sum: {0}, difference: {1}", - weightShareSum, 1 - weightShareSum)); + $"Sum of axle weight share is not 1! sum: {weightShareSum}, difference: {1 - weightShareSum}"); } for (var i = 0; i < vehicleData.AxleData.Count; i++) { if (vehicleData.AxleData[i].TyreTestLoad.IsSmallerOrEqual(0)) { - return new ValidationResult(string.Format("Tyre test load (FzISO) for axle {0} must be greater than 0.", i)); + return new ValidationResult($"Tyre test load (FzISO) for axle {i} must be greater than 0."); } } if (vehicleData.TotalRollResistanceCoefficient <= 0) { return - new ValidationResult(string.Format("Total rolling resistance must be greater than 0! {0}", - vehicleData.TotalRollResistanceCoefficient)); + new ValidationResult($"Total rolling resistance must be greater than 0! {vehicleData.TotalRollResistanceCoefficient}"); } // total gvw is limited by max gvw (40t) @@ -361,8 +353,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (vehicleData.TotalVehicleMass > gvwTotal) { return new ValidationResult( - string.Format("Total Vehicle mass is greater than GrossVehicleMass! Mass: {0}, GVM: {1}", - vehicleData.TotalVehicleMass, gvwTotal)); + $"Total Vehicle mass is greater than GrossVehicleMass! Mass: {vehicleData.TotalVehicleMass}, GVM: {gvwTotal}"); } var numDrivenAxles = vehicleData._axleData.Count(x => x.AxleType == AxleType.VehicleDriven); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs b/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs index feaeceaaddf82e653ba91952048fb9745d519111..3cecf2e8b025422c005393c32dd18d3861b6ee51 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs @@ -57,10 +57,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent return response; } - public Watt ElectricAuxPower { get { return PreviousState.AuxPower; } } - public Watt ChargePower { get { return PreviousState.ChargePower; } } - public Watt BatteryPower { get { return PreviousState.BatteryPower; } } - public Watt ConsumerPower { get { return PreviousState.ConsumerPower; } } + public Watt ElectricAuxPower => PreviousState.AuxPower; + public Watt ChargePower => PreviousState.ChargePower; + public Watt BatteryPower => PreviousState.BatteryPower; + public Watt ConsumerPower => PreviousState.ConsumerPower; protected override void DoWriteModalResults(Second absTime, Second dt, IModalDataContainer container) { @@ -107,15 +107,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent #region Implementation of IRESSInfo - public Volt InternalCellVoltage - { - get { return Battery.InternalVoltage; } - } + public Volt InternalCellVoltage => Battery.InternalVoltage; - public double StateOfCharge - { - get { return Battery.StateOfCharge; } - } + public double StateOfCharge => Battery.StateOfCharge; public Watt MaxChargePower(Second dt) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs index b286ae2e62d4b9bad47c868c3777cdb86019eb97..30196371482534a9749b32a668b8ed62b448f4ad 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs @@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return; } var transmissionRatio = runData.AxleGearData.AxleGear.Ratio * - (runData.AngledriveData == null ? 1.0 : runData.AngledriveData.Angledrive.Ratio) / + (runData.AngledriveData?.Angledrive.Ratio ?? 1.0) / runData.VehicleData.DynamicTyreRadius; var minEngineSpeed = (runData.EngineData.FullLoadCurves[0].RatedSpeed - runData.EngineData.IdleSpeed) * Constants.SimulationSettings.ClutchClosingSpeedNorm + runData.EngineData.IdleSpeed; @@ -93,10 +93,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DataBus.EngineInfo.EngineN95hSpeed)); } - public override GearshiftPosition NextGear - { - get { return _nextGear; } - } + public override GearshiftPosition NextGear => _nextGear; public override ShiftPolygon ComputeDeclarationShiftPolygon( GearboxType gearboxType, int i, EngineFullLoadCurve engineDataFullLoadCurve, IList<ITransmissionInputData> gearboxGears, @@ -106,7 +103,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl i, engineDataFullLoadCurve, gearboxGears, engineData, axlegearRatio, dynamicTyreRadius); } - public static string Name { get { return "AMT - Classic"; } } + public static string Name => "AMT - Classic"; public override GearshiftPosition Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs index 1b5f4270061e09eb95ca695caf9401a0e9b3d7ee..dc0a77b3e23a4b7bf0a1548166c9f94bda28a2dc 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs @@ -204,6 +204,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return minFcGear; } + //todo mk20210618 fcUpshiftPossible is always true! Maybe this statement can be simplified? return fcUpshiftPossible ? currentGear : base.CheckEarlyUpshift(absTime, dt, outTorque, outAngularVelocity, currentGear, response1); @@ -331,10 +332,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - public new static string Name - { - get { return "AMT - EffShift"; } - } + public new static string Name => "AMT - EffShift"; #region Overrides of AMTShiftStrategy diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs index b003e1917a6637dfa41572f8c28ad3ac4b506c71..59593d6bf4e052602745d3e60fd828ca677532cc 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs @@ -31,10 +31,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { return true; } - public Watt ClutchLosses - { - get { return 0.SI<Watt>(); } - } + public Watt ClutchLosses => 0.SI<Watt>(); #endregion } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index 674a8bcdeab3b4d6d27d9c2fa30c92c04cf48477..5009a8974ed59fdcbdcdb9202e5613ec4e97aa4c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -55,12 +55,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl internal WattSecond _powershiftLossEnergy; protected internal KilogramSquareMeter EngineInertia; - public bool TorqueConverterLocked { - get { return CurrentState.Gear.TorqueConverterLocked.Value; } - //set { CurrentState.TorqueConverterLocked = value; } - } + public bool TorqueConverterLocked => CurrentState.Gear.TorqueConverterLocked.Value; - public override bool TCLocked { get { return Gear.TorqueConverterLocked.Value; } } + //set { CurrentState.TorqueConverterLocked = value; } + public override bool TCLocked => Gear.TorqueConverterLocked.Value; public ATGearbox(IVehicleContainer container, IShiftStrategy strategy) : base(container) @@ -77,7 +75,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IIdleController IdleController { - get { return _idleController; } + get => _idleController; set { _idleController = value; @@ -85,18 +83,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public bool ShiftToLocked - { - get { - return PreviousState.Gear.Gear == Gear.Gear && !PreviousState.Gear.TorqueConverterLocked.Value && - Gear.TorqueConverterLocked.Value; - } - } + public bool ShiftToLocked => + PreviousState.Gear.Gear == Gear.Gear && !PreviousState.Gear.TorqueConverterLocked.Value && + Gear.TorqueConverterLocked.Value; public bool Disengaged { - get { return CurrentState.Disengaged; } - set { CurrentState.Disengaged = value; } + get => CurrentState.Disengaged; + set => CurrentState.Disengaged = value; } public override void Connect(ITnOutPort other) @@ -107,41 +101,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override Second LastUpshift { - get - { - return -double.MaxValue.SI<Second>(); - //throw new System.NotImplementedException(); - } - protected internal set { throw new System.NotImplementedException(); } + get => -double.MaxValue.SI<Second>(); + //throw new System.NotImplementedException(); + protected internal set => throw new System.NotImplementedException(); } public override Second LastDownshift { - get - { - return -double.MaxValue.SI<Second>(); - //throw new System.NotImplementedException(); - } - protected internal set { throw new System.NotImplementedException(); } + get => -double.MaxValue.SI<Second>(); + //throw new System.NotImplementedException(); + protected internal set => throw new System.NotImplementedException(); } - public override GearshiftPosition NextGear - { - get { return _strategy.NextGear; } - } + public override GearshiftPosition NextGear => _strategy.NextGear; #region Overrides of AbstractGearbox<ATGearboxState> public override GearshiftPosition Gear { - get { return _gear; } - protected internal set - { - _gear = value; - //if (PreviousState.Gear == value) { - // RequestAfterGearshift = false; - //} - } + get => _gear; + protected internal set => _gear = value; + //if (PreviousState.Gear == value) { + // RequestAfterGearshift = false; + //} } #endregion @@ -230,14 +212,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } response = TorqueConverter.Initialize(inTorque, inAngularVelocity); } - - response.Switch(). - Case<ResponseSuccess>(). // accept - Case<ResponseUnderload>(). // accept - Case<ResponseOverload>(). // accept - Default(r => { - throw new UnexpectedResponseException("AT-Gearbox.Initialize", r); - }); + + switch (response) { + case ResponseSuccess _: + case ResponseUnderload _: + case ResponseOverload _: + break; + default: + throw new UnexpectedResponseException("AT-Gearbox.Initialize", response); + } return new ResponseDryRun(this) { Engine = { @@ -434,7 +417,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (dryRun) { // if gearbox is disengaged the 0[W]-line is the limit for drag and full load. - var engResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), 0.RPMtoRad(), dryRun); + var engResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), 0.RPMtoRad(), true); return new ResponseDryRun(this, engResponse) { Gearbox = { PowerRequest = outTorque * avgAngularVelocity, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs index 3de1faed011b5d79a817fc85624920d6de08118e..59c9b16a6a1d98397424fe65f1cbfdc17f5f16fa 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs @@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override IGearbox Gearbox { - get { return _gearbox; } + get => _gearbox; set { _gearbox = value as ATGearbox; if (_gearbox == null) { @@ -65,10 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public override GearshiftPosition NextGear - { - get { return _nextGear.Gear; } - } + public override GearshiftPosition NextGear => _nextGear.Gear; public override ShiftPolygon ComputeDeclarationShiftPolygon( GearboxType gearboxType, int i, EngineFullLoadCurve engineDataFullLoadCurve, @@ -79,10 +76,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl engineDataFullLoadCurve, i == 0, i >= gearboxGears.Count - 1); } - public static string Name - { - get { return "AT - Classic"; } - } + public static string Name => "AT - Classic"; public ATShiftStrategy(IVehicleContainer dataBus) : base(dataBus) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs index 2b93654877837415599470b6c3f41c14a83fd591..09d73e115d4c8a2615a75960ce3567e8ba04ae99 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs @@ -35,10 +35,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private List<SchmittTrigger> LoadStageSteps = new List<SchmittTrigger>(); private ShiftLineSet UpshiftLineTCLocked = new ShiftLineSet(); - public new static string Name - { - get { return "AT - EffShift"; } - } + public new static string Name => "AT - EffShift"; public ATShiftStrategyOptimized(IVehicleContainer dataBus) : base(dataBus) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs index 7a6f069d53538f148502e0932ed1cf659954557f..e7b845bf7362c79d6caa4cef783f79cd4805e519 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs @@ -69,18 +69,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region IGearboxCockpit - public GearboxType GearboxType - { - get { return ModelData.Type; } - } + public GearboxType GearboxType => ModelData.Type; /// <summary> /// The current gear. /// </summary> public virtual GearshiftPosition Gear { - get { return _gear; } - protected internal set { _gear = value; } + get => _gear; + protected internal set => _gear = value; } public abstract bool TCLocked { get; } @@ -120,15 +117,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public abstract GearshiftPosition NextGear { get; } - public virtual Second TractionInterruption - { - get { return ModelData.TractionInterruption; } - } + public virtual Second TractionInterruption => ModelData.TractionInterruption; - public uint NumGears - { - get { return (uint)ModelData.Gears.Count; } - } + public uint NumGears => (uint)ModelData.Gears.Count; #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs index 325c1574158b2b562c94d72cbe019e2c3640ff59..4d50c43c3d4e53416effca7df1aca9b943370c5b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs @@ -60,9 +60,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.P_angle_in] = CurrentState.InTorque * avgAngularVelocity; } - public double Ratio - { - get { return ModelData.Ratio; } - } + public double Ratio => ModelData.Ratio; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AverageAccelerationTorquePreprocessor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AverageAccelerationTorquePreprocessor.cs index 92e3e9eb2a122672167f094e0d386877aa943f01..02c6c4e569ec165c08bf4f9208bc94ea04d93795 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AverageAccelerationTorquePreprocessor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AverageAccelerationTorquePreprocessor.cs @@ -44,7 +44,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { engineSpeed >= Data.EngineData.IdleSpeed; engineSpeed -= speedStepSize) { - sum += VectoMath.Min(torque, maxTorque[engineSpeed]); ; + sum += VectoMath.Min(torque, maxTorque[engineSpeed]); var tmp = engineSpeed.IsEqual(UpperLimit, speedStepSize / 2) ? 0.SI<NewtonMeter>() : sum * speedStepSize / (UpperLimit - engineSpeed); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs index 13d75f344d3e5ea3ca4d2254d46fddc2898cf4ae..7d84011aee946b43143c2309e93fcfdfa18be9e7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs @@ -76,17 +76,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return PreviousState.TorqueLossResult.Value * PreviousState.InAngularVelocity; } - public Tuple<PerSecond, NewtonMeter> CurrentAxleDemand - { - get { - return Tuple.Create( - (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0, CurrentState.InTorque); - } - } + public Tuple<PerSecond, NewtonMeter> CurrentAxleDemand => + Tuple.Create( + (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0, CurrentState.InTorque); - public double Ratio - { - get { return ModelData.Ratio; } - } + public double Ratio => ModelData.Ratio; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs index 98c95a97d4103d5d78fc822c78735e623c5faf9d..89effcf3c48116088aabb54eba241bc335e05328 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs @@ -23,10 +23,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } #region Implementation of IBatteryProvider - public IElectricEnergyStoragePort MainBatteryPort - { - get { return this; } - } + public IElectricEnergyStoragePort MainBatteryPort => this; #endregion @@ -169,23 +166,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IRESSInfo - public Volt InternalVoltage - { - get { return ModelData.SOCMap.Lookup(PreviousState.StateOfCharge); } - } + public Volt InternalVoltage => ModelData.SOCMap.Lookup(PreviousState.StateOfCharge); - public double StateOfCharge - { - get { return PreviousState.StateOfCharge; } - } + public double StateOfCharge => PreviousState.StateOfCharge; - public WattSecond StoredEnergy - { - get { - return PreviousState.StateOfCharge * ModelData.Capacity * ModelData.SOCMap.Lookup(PreviousState.StateOfCharge); - } - } + public WattSecond StoredEnergy => PreviousState.StateOfCharge * ModelData.Capacity * ModelData.SOCMap.Lookup(PreviousState.StateOfCharge); public Watt MaxChargePower(Second dt) { @@ -207,14 +193,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return VectoMath.Max(maxDischargePower, maxPower); } - public double MinSoC - { - get { return ModelData.MinSOC; } - } - public double MaxSoC - { - get { return ModelData.MaxSOC; } - } + public double MinSoC => ModelData.MinSOC; + + public double MaxSoC => ModelData.MaxSOC; //public Ampere MaxCurrent //{ diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index 434b08694afa8e62d98c71484098e04582096468..ed2d5bed7e495e86f31333f383fe463701fcb58f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -402,12 +402,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of ISimpleBatteryInfo - public double SOC { - get { return busAuxAdapter.ElectricStorage.SOC; } - } - public WattSecond Capacity { - get { return busAuxAdapter.ElectricStorage.Capacity; } - } + public double SOC => busAuxAdapter.ElectricStorage.SOC; + + public WattSecond Capacity => busAuxAdapter.ElectricStorage.Capacity; #endregion } @@ -424,9 +421,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of ISimpleBatteryInfo - public double SOC { - get { return ElectricStorage.SOC.IsEqual(1, 1e-2) ? 1 : 0.5; } - } + public double SOC => ElectricStorage.SOC.IsEqual(1, 1e-2) ? 1 : 0.5; public WattSecond Capacity { get; } #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index 37dc467c7c72a0dc6ba7cd939376ceff0a4b1074..6a36d53657cd2bc0336f8964867202e4be7d85a8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -43,7 +43,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class + public class Clutch : StatefulProviderComponent<Clutch.ClutchState, ITnOutPort, ITnInPort, ITnOutPort>, IClutch, ITnOutPort, ITnInPort { @@ -54,9 +54,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IIdleController IdleController { - get { return _idleController; } - set - { + get => _idleController; + set { _idleController = value; _idleController.RequestPort = NextComponent; } @@ -105,7 +104,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { firstInitialize = false; if ((!DataBus.ClutchInfo.ClutchClosed(absTime) || !DataBus.GearboxInfo.GearEngaged(absTime)) && !dryRun) { - return HandleClutchOpen(absTime, dt, outTorque, outAngularVelocity, dryRun); + return HandleClutchOpen(absTime, dt, outTorque, outAngularVelocity, false); } if (IdleController != null) { @@ -114,7 +113,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("from Wheels: torque: {0}, angularVelocity: {1}, power {2}", outTorque, outAngularVelocity, Formulas.TorqueToPower(outTorque, outAngularVelocity)); - + return HandleClutchClosed(absTime, dt, outTorque, outAngularVelocity, dryRun); } @@ -122,11 +121,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl bool dryRun) { var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; - if (dryRun) - { + if (dryRun) { var delta = outTorque * avgOutAngularVelocity; - return new ResponseDryRun(this) - { + return new ResponseDryRun(this) { Gearbox = { PowerRequest = delta }, DeltaDragLoad = delta, DeltaFullLoad = delta, @@ -137,52 +134,47 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl OutputSpeed = outAngularVelocity } }; - } - if ((outTorque * avgOutAngularVelocity).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) - { - return new ResponseOverload(this) - { - Delta = outTorque * avgOutAngularVelocity, - Clutch = { + } else { + + if ((outTorque * avgOutAngularVelocity).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { + return new ResponseOverload(this) { + Delta = outTorque * avgOutAngularVelocity, + Clutch = { PowerRequest = outTorque * avgOutAngularVelocity, OutputSpeed = outAngularVelocity } - }; - } + }; + } - if ((outTorque * avgOutAngularVelocity).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) - { - return new ResponseUnderload(this) - { - Delta = outTorque * avgOutAngularVelocity, - Clutch = { + if ((outTorque * avgOutAngularVelocity).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { + return new ResponseUnderload(this) { + Delta = outTorque * avgOutAngularVelocity, + Clutch = { PowerRequest = outTorque * avgOutAngularVelocity, OutputSpeed = outAngularVelocity } - }; + }; + } + + Log.Debug("Invoking IdleController..."); + var retVal = IdleController.Request(absTime, dt, outTorque, null, false); + retVal.Clutch.PowerRequest = 0.SI<Watt>(); + retVal.Clutch.OutputSpeed = outAngularVelocity; + CurrentState.SetState(0.SI<NewtonMeter>(), retVal.Engine.EngineSpeed, outTorque, outAngularVelocity); + CurrentState.ClutchLoss = 0.SI<Watt>(); + return retVal; } - - Log.Debug("Invoking IdleController..."); - var retval = IdleController.Request(absTime, dt, outTorque, null, dryRun); - retval.Clutch.PowerRequest = 0.SI<Watt>(); - retval.Clutch.OutputSpeed = outAngularVelocity; - CurrentState.SetState(0.SI<NewtonMeter>(), retval.Engine.EngineSpeed, outTorque, outAngularVelocity); - CurrentState.ClutchLoss = 0.SI<Watt>(); - return retval; } - protected virtual IResponse HandleClutchClosed(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) + protected virtual IResponse HandleClutchClosed(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) { - NewtonMeter torqueIn; - PerSecond angularVelocityIn; - var startClutch = DataBus.VehicleInfo.VehicleStopped || !PreviousState.ClutchLoss.IsEqual(0, 1e-3) || (outAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineSpeed, 1e-3) && !DataBus.EngineInfo.EngineOn); // || (PreviousState.ClutchLoss.IsEqual(0) && outAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineIdleSpeed)); var slippingClutchWhenDriving = (DataBus.GearboxInfo.Gear.Gear <= 2 && DataBus.DriverInfo.DriverBehavior != DrivingBehavior.Braking); var slippingClutchDuringBraking = DataBus.GearboxInfo.Gear.Gear == 1 && DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking && outTorque > 0 && DataBus.Brakes.BrakePower.IsEqual(0); //var slippingClutchWhenDriving = (DataBus.Gear == 1 && outTorque > 0); AddClutchLoss(outTorque, outAngularVelocity, slippingClutchWhenDriving || slippingClutchDuringBraking || startClutch || outAngularVelocity.IsEqual(0), - out torqueIn, out angularVelocityIn); + out var torqueIn, out var angularVelocityIn); Log.Debug("to Engine: torque: {0}, angularVelocity: {1}, power {2}", torqueIn, angularVelocityIn, Formulas.TorqueToPower(torqueIn, angularVelocityIn)); @@ -244,10 +236,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return DataBus.GearboxInfo.GearEngaged(absTime); } - public Watt ClutchLosses - { - get { return PreviousState.ClutchLoss; } - } + public Watt ClutchLosses => PreviousState.ClutchLoss; public class ClutchState : SimpleComponentState { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index fd4d86c13873aa0c53d4b5a34c27da1005453bfe..dc84bcf0edc9be725085fd03ab72339e91b0d0b9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -86,20 +86,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region IEngineCockpit - public virtual bool EngineOn - { - get { return PreviousState.EngineOn; } - } + public virtual bool EngineOn => PreviousState.EngineOn; - public PerSecond EngineSpeed - { - get { return PreviousState.EngineSpeed; } - } + public PerSecond EngineSpeed => PreviousState.EngineSpeed; - public NewtonMeter EngineTorque - { - get { return PreviousState.EngineTorque; } - } + public NewtonMeter EngineTorque => PreviousState.EngineTorque; public Watt EngineStationaryFullPower(PerSecond angularSpeed) { @@ -125,31 +116,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl 0.SI<Second>(), dt, 0.SI<NewtonMeter>(), avgEngineSpeed, true) * avgEngineSpeed; } - public PerSecond EngineIdleSpeed - { - get { return ModelData.IdleSpeed; } - } + public PerSecond EngineIdleSpeed => ModelData.IdleSpeed; - public PerSecond EngineRatedSpeed - { - get { return ModelData.FullLoadCurves[0].RatedSpeed; } - } + public PerSecond EngineRatedSpeed => ModelData.FullLoadCurves[0].RatedSpeed; - public PerSecond EngineN95hSpeed - { - get { return ModelData.FullLoadCurves[0].N95hSpeed; } - } + public PerSecond EngineN95hSpeed => ModelData.FullLoadCurves[0].N95hSpeed; - public PerSecond EngineN80hSpeed + public PerSecond EngineN80hSpeed => ModelData.FullLoadCurves[0].N80hSpeed; - { - get { return ModelData.FullLoadCurves[0].N80hSpeed; } - } - - public IIdleController IdleController - { - get { return EngineIdleController ?? (EngineIdleController = new CombustionEngineIdleController(this, DataBus)); } - } + public IIdleController IdleController => EngineIdleController ?? (EngineIdleController = new CombustionEngineIdleController(this, DataBus)); protected CombustionEngineIdleController EngineIdleController { get; set; } @@ -701,7 +676,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new VectoException("Torque has to be 0 for idle requests! {0}", outTorque); } - return DoHandleRequest(absTime, dt, outTorque, outAngularVelocity); + return DoHandleRequest(absTime, dt, outTorque, null); } protected virtual IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { @@ -735,35 +710,37 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), nextAngularSpeed, false); - retVal.Switch(). - Case<ResponseSuccess>(). - Case<ResponseUnderload>(r => { + switch(retVal) { + case ResponseSuccess _: + break; + case ResponseUnderload r: var angularSpeed = SearchAlgorithm.Search(nextAngularSpeed, r.Delta, Constants.SimulationSettings.EngineIdlingSearchInterval, getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, evaluateFunction: n => RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), n, true), criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value()); - Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", absTime, dt, - 0.SI<NewtonMeter>(), angularSpeed); + Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", + absTime, dt, 0.SI<NewtonMeter>(), angularSpeed); if (angularSpeed < _engine.ModelData.IdleSpeed) { angularSpeed = _engine.ModelData.IdleSpeed; } retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), angularSpeed, false); - }). - Case<ResponseOverload>(r => { - var angularSpeed = SearchAlgorithm.Search(nextAngularSpeed, r.Delta, + break; + case ResponseOverload r: + var angularSpeed2 = SearchAlgorithm.Search(nextAngularSpeed, r.Delta, Constants.SimulationSettings.EngineIdlingSearchInterval, getYValue: result => ((ResponseDryRun)result).DeltaFullLoad, evaluateFunction: n => RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), n, true), criterion: result => ((ResponseDryRun)result).DeltaFullLoad.Value()); - Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", absTime, dt, - 0.SI<NewtonMeter>(), angularSpeed); - angularSpeed = angularSpeed.LimitTo(_engine.ModelData.IdleSpeed, engineMaxSpeed); - retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), angularSpeed, false); - }). - Default(r => { throw new UnexpectedResponseException("searching Idling point", r); }); - + Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", + absTime, dt, 0.SI<NewtonMeter>(), angularSpeed2); + angularSpeed2 = angularSpeed2.LimitTo(_engine.ModelData.IdleSpeed, engineMaxSpeed); + retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), angularSpeed2, false); + break; + default: + throw new UnexpectedResponseException("searching Idling point", retVal); + } return retVal; } @@ -802,20 +779,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl .LimitTo(_engine.ModelData.IdleSpeed, _engine.EngineRatedSpeed); retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), nextAngularSpeed, false); - retVal.Switch(). - Case<ResponseSuccess>(). - Case<ResponseUnderload>(r => { + switch (retVal) { + case ResponseSuccess _: + break; + case ResponseUnderload r: var angularSpeed = SearchAlgorithm.Search(nextAngularSpeed, r.Delta, Constants.SimulationSettings.EngineIdlingSearchInterval, getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, evaluateFunction: n => RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), n, true), criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value()); - Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", absTime, dt, - 0.SI<NewtonMeter>(), angularSpeed); + Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", + absTime, dt, 0.SI<NewtonMeter>(), angularSpeed); retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), angularSpeed, false); - }). - Default(r => { throw new UnexpectedResponseException("searching Idling point", r); }); - + break; + default: + throw new UnexpectedResponseException("searching Idling point", retVal); + } return retVal; } } @@ -836,7 +815,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public virtual bool CombustionEngineOn { - get { return true; } + get => true; set { } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index d804febb1f6786623d69ccab15638ab66220d415..a30715f3873a4573a9e9dd91b4d094dcfa0e5647 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -89,9 +89,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var dt = Constants.SimulationSettings.TargetTimeInterval; - var tcLocked = DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive != null - ? !DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive - : null; + var tcLocked = !DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive; Gear = new GearshiftPosition(GetGearFromCycle(), tcLocked); if (TorqueConverter != null && Gear.TorqueConverterLocked == null) { @@ -135,7 +133,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - public override bool TCLocked { get { return Gear.TorqueConverterLocked ?? false; } } + public override bool TCLocked => Gear.TorqueConverterLocked ?? false; /// <summary> /// Requests the Gearbox to deliver torque and angularVelocity @@ -206,9 +204,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { Disengaged = null; - var tcLocked = DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive != null - ? !DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive - : null; + var tcLocked = !DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive; Gear = new GearshiftPosition(GetGearFromCycle(), tcLocked); @@ -451,14 +447,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override Second LastUpshift { - get { throw new System.NotImplementedException(); } - protected internal set { throw new System.NotImplementedException(); } + get => throw new NotImplementedException(); + protected internal set => throw new NotImplementedException(); } public override Second LastDownshift { - get { throw new System.NotImplementedException(); } - protected internal set { throw new System.NotImplementedException(); } + get => throw new NotImplementedException(); + protected internal set => throw new NotImplementedException(); } public override GearshiftPosition NextGear @@ -532,8 +528,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override bool DisengageGearbox { - get { return false; } - set { throw new System.NotImplementedException(); } + get => false; + set => throw new NotImplementedException(); } public override void TriggerGearshift(Second absTime, Second dt) @@ -564,23 +560,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override GearshiftPosition InitGear(Second absTime, Second dt, NewtonMeter torque, PerSecond outAngularVelocity) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public override GearshiftPosition Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } - public override GearshiftPosition NextGear - { - get { throw new System.NotImplementedException(); } - } + public override GearshiftPosition NextGear => throw new NotImplementedException(); public override ShiftPolygon ComputeDeclarationShiftPolygon( GearboxType gearboxType, int i, EngineFullLoadCurve engineDataFullLoadCurve, IList<ITransmissionInputData> gearboxGears, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 3d9f71a01e5c9bfc037fc6d6dc1805fc933b9c8c..147ff66a56527180a26dd15521e313a311bc9436 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Windows.Forms.DataVisualization.Charting; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; @@ -102,7 +103,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ATEcoRollReleaseLockupClutch = data?.GearboxData?.ATEcoRollReleaseLockupClutch ?? false; EcoRollState = new EcoRoll() { - State = Impl.EcoRollStates.EcoRollOff, + State = EcoRollStates.EcoRollOff, Gear = new GearshiftPosition(0), StateChangeTstmp = -double.MaxValue.SI<Second>(), PreviousBrakePower = 0.SI<Watt>(), @@ -204,13 +205,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //if (ADAS.EcoRoll != EcoRollType.None) { // todo MQ: keep something like this to prevent driver to turn on engine in every timestep (in combination with hybrids leads to errors!) - if (EcoRollState.State != EcoRollStates.EcoRollOn && PCCState != PCCStates.UseCase1 && - PCCState != PCCStates.UseCase2) { - EngineOffTimestamp = null; - if (Driver.DataBus.PowertrainInfo.HasCombustionEngine && !Driver.DataBus.PowertrainInfo.HasElectricMotor) { - Driver.DataBus.EngineCtl.CombustionEngineOn = true; - } + if (EcoRollState.State != EcoRollStates.EcoRollOn && PCCState != PCCStates.UseCase1 && + PCCState != PCCStates.UseCase2) { + EngineOffTimestamp = null; + if (Driver.DataBus.PowertrainInfo.HasCombustionEngine && !Driver.DataBus.PowertrainInfo.HasElectricMotor) { + Driver.DataBus.EngineCtl.CombustionEngineOn = true; } + } //} if (CurrentDrivingMode == DrivingMode.DrivingModeBrake) { @@ -224,7 +225,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DrivingModes[CurrentDrivingMode].ResetMode(); Log.Debug("Switching to DrivingMode DRIVE"); } - + } if (CurrentDrivingMode == DrivingMode.DrivingModeDrive) { @@ -250,8 +251,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl .IsSmaller( Constants.SimulationSettings.LowerBoundTimeInterval / 2) && (Driver.DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || !Driver.DataBus.ClutchInfo.ClutchClosed(absTime)); if (brakingIntervalShort && remainingDistance.IsEqual(ds)) { - return new ResponseDrivingCycleDistanceExceeded(this) - { + return new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = ds / 2 }; } @@ -594,7 +594,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { return (targetSpeed + GetOverspeed()).LimitTo( 0.KMPHtoMeterPerSecond(), VehicleCategory.IsBus() ? Constants.BusParameters.MaxBusSpeed : 500.KMPHtoMeterPerSecond()); - + } protected internal MeterPerSecond GetOverspeed() @@ -777,20 +777,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public DefaultDriverStrategy DriverStrategy { get; set; } - protected IDriverActions Driver - { - get { return _driver ?? (_driver = DriverStrategy.Driver); } - } + protected IDriverActions Driver => _driver ?? (_driver = DriverStrategy.Driver); - protected DriverData DriverData - { - get { return _driverData ?? (_driverData = Driver.DriverData); } - } + protected DriverData DriverData => _driverData ?? (_driverData = Driver.DriverData); - protected IDataBus DataBus - { - get { return _dataBus ?? (_dataBus = Driver.DataBus); } - } + protected IDataBus DataBus => _dataBus ?? (_dataBus = Driver.DataBus); public IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient) { @@ -813,8 +804,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - Meter newds; - response = CheckRequestDoesNotExceedNextAction(absTime, ds, targetVelocity, gradient, response, out newds); + response = CheckRequestDoesNotExceedNextAction(absTime, ds, targetVelocity, gradient, response, out var newds); if (ds.IsEqual(newds, 1e-3.SI<Meter>())) { return response; @@ -871,12 +861,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed)) { velocity = DriverStrategy.ApplyOverspeed(velocity); } - - if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || (DataBus.ClutchInfo.ClutchClosed(absTime) && DataBus.GearboxInfo.GearEngaged(absTime) )) { - if (DataBus.DrivingCycleInfo.CycleData.LeftSample.PTOActive == PTOActivity.PTOActivityRoadSweeping && targetVelocity < DriverStrategy.PTODriveMinSpeed) { - velocity = DriverStrategy.PTODriveMinSpeed; - targetVelocity = velocity; - } + + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || (DataBus.ClutchInfo.ClutchClosed(absTime) && DataBus.GearboxInfo.GearEngaged(absTime))) { + if (DataBus.DrivingCycleInfo.CycleData.LeftSample.PTOActive == PTOActivity.PTOActivityRoadSweeping && targetVelocity < DriverStrategy.PTODriveMinSpeed) { + velocity = DriverStrategy.PTODriveMinSpeed; + targetVelocity = velocity; + } for (var i = 0; i < 3; i++) { var retVal = HandleRequestEngaged( @@ -920,20 +910,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var response = Driver.DrivingActionRoll(absTime, ds, velocity, gradient); debug.Add(new { action = "ClutchOpen -> Roll", response }); - response.Switch().Case<ResponseUnderload>( - r => { - if (DataBus.ClutchInfo.ClutchClosed(absTime)) { - response = HandleRequestEngaged(absTime, ds, velocity, gradient, false, velocity, debug); - } else { - response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, r); - debug.Add(new { action = "Roll:Underload -> Brake", response }); - } - }) - .Case<ResponseSpeedLimitExceeded>( - () => { - response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); - debug.Add(new { action = "Roll:SpeedLimitExceeded -> Brake", response }); - }); + switch (response) { + case ResponseUnderload _ when DataBus.ClutchInfo.ClutchClosed(absTime): + response = HandleRequestEngaged(absTime, ds, velocity, gradient, false, velocity, debug); + break; + case ResponseUnderload _ when !DataBus.ClutchInfo.ClutchClosed(absTime): + response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, response); + debug.Add(new { action = "Roll:Underload -> Brake", response }); + break; + case ResponseSpeedLimitExceeded _: + response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); + debug.Add(new { action = "Roll:SpeedLimitExceeded -> Brake", response }); + break; + } return response; } @@ -946,32 +935,33 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocityWithOverspeed, debug); var second = first; - first.Switch() - .Case<ResponseUnderload>( - r => { - if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.ClutchInfo.ClutchClosed(absTime)) { - second = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); - } - if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0) && DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed)) { - second = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "first:(Underload & Overspeed)-> Coast", second }); - second = HandleCoastAfterUnderloadWithOverspeed(absTime, ds, gradient, velocityWithOverspeed, debug, second); - } else { - second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient, - overrideAction: DataBus.GearboxInfo.GearboxType.AutomaticTransmission() - ? DrivingAction.Accelerate - : (DrivingAction?)null); - debug.Add(new { action = "first:(Underload & !Overspeed) -> Brake", second }); - } - }) - .Case<ResponseEngineSpeedTooHigh>( - r => { second = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient, r); }) - .Case<ResponseSpeedLimitExceeded>( - r => { - second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "SpeedLimitExceeded -> Brake", second }); - }); - ; + switch (first) { + case ResponseUnderload _: + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.ClutchInfo.ClutchClosed(absTime)) { + //TODO mk20210616 the assignment to second is always overriden. Delete the assignment, or maybe even delete the whole line? + //TODO mk20210616 the whole statement could be de-nested to switch-pattern matching (with "where") if this first "if" would not be here. + second = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); + } + + if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0) && DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed)) { + second = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); + debug.Add(new { action = "first:(Underload & Overspeed)-> Coast", second }); + second = HandleCoastAfterUnderloadWithOverspeed(absTime, ds, gradient, velocityWithOverspeed, debug, second); + } else { + second = DataBus.GearboxInfo.GearboxType.AutomaticTransmission() + ? Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient, overrideAction: DrivingAction.Accelerate) + : Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); + debug.Add(new { action = "first:(Underload & !Overspeed) -> Brake", second }); + } + break; + case ResponseEngineSpeedTooHigh _: + second = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient, first); + break; + case ResponseSpeedLimitExceeded _: + second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); + debug.Add(new { action = "SpeedLimitExceeded -> Brake", second }); + break; + } if (second == null) { return null; @@ -979,27 +969,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var third = second; - second.Switch().Case<ResponseGearShift>( - r => { + switch (second) { + case ResponseGearShift _: third = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); debug.Add(new { action = "second: GearShift -> Roll", third }); - third.Switch().Case<ResponseUnderload>( - () => { + switch (third) { + case ResponseUnderload _: // overload may happen if driver limits acceleration when rolling downhill third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); debug.Add(new { action = "third:Underload -> Brake", third }); - }).Case<ResponseSpeedLimitExceeded>( - () => { + break; + case ResponseSpeedLimitExceeded _: third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); debug.Add(new { action = "third:SpeedLimitExceeded -> Brake", third }); - }); - }).Case<ResponseOverload>( - r => { - if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0)) { - third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "second:Overload -> Coast", third }); + break; } - }); + break; + case ResponseOverload _ when DataBus.VehicleInfo.VehicleSpeed.IsGreater(0): + third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); + debug.Add(new { action = "second:Overload -> Coast", third }); + break; + } return third; } @@ -1038,7 +1028,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse first; if (DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed) && - DataBus.VehicleInfo.VehicleSpeed.IsEqual(targetVelocity)) { + DataBus.VehicleInfo.VehicleSpeed.IsGreaterOrEqual(targetVelocity)) { first = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); debug.Add(new { action = "Coast", first }); if (first is ResponseSuccess && first.Driver.Acceleration < 0) { @@ -1229,126 +1219,114 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - response.Switch().Case<ResponseOverload>( - r => { - Log.Info( - "Brake -> Got OverloadResponse during brake action - desired deceleration could not be reached! response: {0}", - r); + switch (response) { + case ResponseOverload r: + Log.Info("Brake -> Got OverloadResponse during brake action - desired deceleration could not be reached! response: {0}", r); if (!DataBus.ClutchInfo.ClutchClosed(absTime)) { Log.Info("Brake -> Overload -> Clutch is open - Trying roll action"); response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); - response.Switch().Case<ResponseSpeedLimitExceeded>( - () => { response = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient); } - ); + if (response is ResponseSpeedLimitExceeded) + response = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient); } else { Log.Info("Brake -> Overload -> Clutch is closed - Trying brake action again"); DataBus.Brakes.BrakePower = 0.SI<Watt>(); DataBus.HybridControllerCtl?.RepeatDrivingAction(absTime); - response = Driver.DrivingActionBrake( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, - targetDistance: targetDistance); - response.Switch().Case<ResponseOverload>( - r1 => { - Log.Info("Brake -> Overload -> 2nd Brake -> Overload -> Trying accelerate action"); - var gear = DataBus.GearboxInfo.Gear; - if (DataBus.GearboxInfo.GearEngaged(absTime)) { - response = Driver.DrivingActionAccelerate( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); - } else { - response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); - } - - response.Switch().Case<ResponseGearShift>( - rs => { - Log.Info( - "Brake -> Overload -> 2nd Brake -> Accelerate -> Got GearShift response, performing roll action"); - response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); - }) - .Case<ResponseUnderload>( - rs => { - if (gear != DataBus.GearboxInfo.Gear) { - // AT Gearbox switched gears, shift losses are no longer applied, try once more... - response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); - } - }); - }); + response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, + gradient, targetDistance: targetDistance); + if (response is ResponseOverload) { + Log.Info("Brake -> Overload -> 2nd Brake -> Overload -> Trying accelerate action"); + var gear = DataBus.GearboxInfo.Gear; + response = DataBus.GearboxInfo.GearEngaged(absTime) + ? Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient) + : Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); + + switch (response) { + case ResponseGearShift _: + Log.Info("Brake -> Overload -> 2nd Brake -> Accelerate -> Got GearShift response, performing roll action"); + response = Driver.DrivingActionRoll(absTime, ds, + DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + break; + case ResponseUnderload _: + if (gear.Gear != DataBus.GearboxInfo.Gear.Gear) { + // AT Gearbox switched gears, shift losses are no longer applied, try once more... + response = Driver.DrivingActionAccelerate(absTime, ds, + DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + } + break; + } + } } - }).Case<ResponseGearShift>( - r => { + break; + case ResponseGearShift _: Log.Info("Brake -> Got GearShift response, performing roll action + brakes"); //response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); DataBus.Brakes.BrakePower = 0.SI<Watt>(); - response = Driver.DrivingActionBrake( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, + response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); - response.Switch().Case<ResponseOverload>( - () => { - Log.Info("Brake -> Geearshift -> Overload -> trying roll action (no gear engaged)"); - response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); - }); - }); + if (response is ResponseOverload) { + Log.Info("Brake -> Gearshift -> Overload -> trying roll action (no gear engaged)"); + response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + } + break; + } return response; } - private IResponse DoCoast( - Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, - Meter currentDistance) + private IResponse DoCoast(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, Meter currentDistance) { IResponse response; Driver.DriverBehavior = DrivingBehavior.Coasting; response = DataBus.ClutchInfo.ClutchClosed(absTime) ? Driver.DrivingActionCoast(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleInfo.VehicleSpeed), gradient) : Driver.DrivingActionRoll(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleInfo.VehicleSpeed), gradient); - response.Switch().Case<ResponseUnderload>( - r => { + switch (response) { + case ResponseUnderload r: // coast would decelerate more than driver's max deceleration => issue brakes to decelerate with driver's max deceleration - response = Driver.DrivingActionBrake( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, - gradient, r); - if ((DriverStrategy.BrakeTrigger.BrakingStartDistance - currentDistance).IsSmallerOrEqual( - Constants.SimulationSettings.DriverActionDistanceTolerance)) { + response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, r); + if ((DriverStrategy.BrakeTrigger.BrakingStartDistance - currentDistance).IsSmallerOrEqual(Constants.SimulationSettings.DriverActionDistanceTolerance)) { Phase = BrakingPhase.Brake; } - }).Case<ResponseOverload>( - r => { + break; + case ResponseOverload _: // limiting deceleration while coast may result in an overload => issue brakes to decelerate with driver's max deceleration response = DataBus.ClutchInfo.ClutchClosed(absTime) ? Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient) : Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); - //Phase = BrakingPhase.Brake; - }).Case<ResponseDrivingCycleDistanceExceeded>( - r => { + break; + case ResponseDrivingCycleDistanceExceeded r: if (!ds.IsEqual(r.MaxDistance)) { // distance has been reduced due to vehicle stop in coast/roll action => use brake action to get exactly to the stop-distance // TODO what if no gear is enaged (and we need driveline power to get to the stop-distance? response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } - }).Case<ResponseEngineSpeedTooHigh>( - r => { response = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient, r); }); + break; + case ResponseEngineSpeedTooHigh r: + response = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient, r); + break; + } + if (response == null) { - return response; + return null; } // handle the SpeedLimitExceeded Response and Gearshift Response separately in case it occurs in one of the requests in the second try for (var i = 0; i < 3 && (response is ResponseGearShift || response is ResponseSpeedLimitExceeded); i++) { - response.Switch() - .Case<ResponseGearShift>( - r => { response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); }) - .Case<ResponseSpeedLimitExceeded>( - () => { - response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleInfo.VehicleSpeed, - gradient); - if (response is ResponseOverload && !DataBus.ClutchInfo.ClutchClosed(absTime)) { - response = Driver.DrivingActionRoll(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); - } - if (response is ResponseGearShift) { - response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, - gradient); - } - }); + switch (response) { + case ResponseGearShift _: + response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); + break; + case ResponseSpeedLimitExceeded _: + response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); + if (response is ResponseOverload && !DataBus.ClutchInfo.ClutchClosed(absTime)) { + response = Driver.DrivingActionRoll(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); + } + if (response is ResponseGearShift) { + response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); + } + break; + } } return response; @@ -1397,51 +1375,46 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //var i = 0; //do { - response.Switch().Case<ResponseGearShift>( - () => { + switch (response) { + case ResponseGearShift _: response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); - response.Switch().Case<ResponseUnderload>( - r => { + switch (response) { + case ResponseUnderload r: // under-load may happen if driver limits acceleration when rolling downhill - response = Driver.DrivingActionBrake( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, - gradient, r); - }).Case<ResponseSpeedLimitExceeded>( - () => { - response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleInfo.VehicleSpeed, - gradient); - }); - }).Case<ResponseSpeedLimitExceeded>( - () => { - response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleInfo.VehicleSpeed, - gradient); - }).Case<ResponseUnderload>( - r => { + response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, r); + break; + case ResponseSpeedLimitExceeded _: + response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); + break; + } + break; + case ResponseSpeedLimitExceeded _: + response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); + break; + case ResponseUnderload r: //response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, // gradient, r); - response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleInfo.VehicleSpeed + r.Driver.Acceleration * r.SimulationInterval, + response = Driver.DrivingActionBrake(absTime, ds, + DataBus.VehicleInfo.VehicleSpeed + r.Driver.Acceleration * r.SimulationInterval, gradient, DataBus.HybridControllerInfo == null ? r : null); if (response != null) { - response.Switch().Case<ResponseGearShift>( - () => { + switch (response) { + case ResponseGearShift _: DataBus.Brakes.BrakePower = 0.SI<Watt>(); - response = Driver.DrivingActionBrake( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, + response = Driver.DrivingActionBrake(absTime, ds, + DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, DataBus.HybridControllerInfo == null ? r : null); if (response is ResponseOverload) { response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } - }).Case<ResponseOverload>( - () => { + break; + case ResponseOverload _: DataBus.Brakes.BrakePower = 0.SI<Watt>(); if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.ClutchInfo.ClutchClosed(absTime)) { if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0)) { - response = Driver.DrivingActionAccelerate( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + response = Driver.DrivingActionAccelerate(absTime, ds, + DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } else { if (RetryDistanceExceeded) { response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); @@ -1453,9 +1426,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } else { response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } - }); + break; + } } - }); + break; + } //} while (!(response is ResponseSuccess) && i++ < 3); return response; @@ -1528,20 +1503,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public MeterPerSecond NextTargetSpeed; public Meter TriggerDistance; - public Meter ActionDistance - { - get { - return VectoMath.Min( - CoastingStartDistance ?? double.MaxValue.SI<Meter>(), - BrakingStartDistance ?? double.MaxValue.SI<Meter>()); - } - } + public Meter ActionDistance => VectoMath.Min( + CoastingStartDistance ?? double.MaxValue.SI<Meter>(), + BrakingStartDistance ?? double.MaxValue.SI<Meter>()); - public Meter SelectActionDistance(Meter minDistance) - { - return - new[] { BrakingStartDistance, CoastingStartDistance }.OrderBy(x => x.Value()).First(x => x >= minDistance); - } + public Meter SelectActionDistance(Meter minDistance) => + new[] { BrakingStartDistance, CoastingStartDistance }.OrderBy(x => x.Value()).First(x => x >= minDistance); public Meter CoastingStartDistance { get; set; } @@ -1556,9 +1523,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override string ToString() { - return string.Format( - "action: {0} @ {1} / {2}. trigger: {3} targetSpeed: {4}", Action, CoastingStartDistance, - BrakingStartDistance, TriggerDistance, NextTargetSpeed); + return $"action: {Action} @ {CoastingStartDistance} / {BrakingStartDistance}. trigger: {TriggerDistance} targetSpeed: {NextTargetSpeed}"; } } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index f939777d2f6a43bde3398def11fbeec6671588d4..e257278d34a104ab4b1aa3a30d8146259ef5cbe1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -65,15 +65,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private MeterPerSquareSecond StartAcceleration; private MeterPerSecond StartSpeed; - private DrivingCycleData.DrivingCycleEntry Left - { - get { return CycleIntervalIterator.LeftSample; } - } + private DrivingCycleData.DrivingCycleEntry Left => CycleIntervalIterator.LeftSample; - private DrivingCycleData.DrivingCycleEntry Right - { - get { return CycleIntervalIterator.RightSample; } - } + private DrivingCycleData.DrivingCycleEntry Right => CycleIntervalIterator.RightSample; public DistanceBasedDrivingCycle(IVehicleContainer container, IDrivingCycleData cycle) : base(container) { @@ -317,12 +311,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.Gradient = ComputeGradient(ds); var retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); - retVal.Switch() - .Case<ResponseFailTimeInterval>( - r => { - retVal = NextComponent.Request(absTime, r.DeltaT, 0.SI<MeterPerSecond>(), CurrentState.Gradient); - retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); - }); + if (retVal is ResponseFailTimeInterval r) { + // TODO mk20160616 the first assignment to retVal is overwritten. Remove assignment? + retVal = NextComponent.Request(absTime, r.DeltaT, 0.SI<MeterPerSecond>(), CurrentState.Gradient); + retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); + } CurrentState.AbsTime = absTime; if (retVal is ResponseSuccess) { CurrentState.Distance = PreviousState.Distance + retVal.SimulationDistance; @@ -428,20 +421,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <summary> /// Progress of the distance in the driving cycle. /// </summary> - public double Progress - { - get { - return Data.Entries.Count > 0 - ? (CurrentState.Distance.Value() - Data.Entries.First().Distance.Value()) / - (Data.Entries.Last().Distance.Value() - Data.Entries.First().Distance.Value()) - : 0; - } - } + public double Progress => + Data.Entries.Count > 0 + ? (CurrentState.Distance.Value() - Data.Entries.First().Distance.Value()) / + (Data.Entries.Last().Distance.Value() - Data.Entries.First().Distance.Value()) + : 0; - public Second StopTime - { - get { return CycleIntervalIterator.LeftSample.StoppingTime; } - } + public Second StopTime => CycleIntervalIterator.LeftSample.StoppingTime; public Meter CycleStartDistance { get; internal set; } @@ -492,17 +478,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Data.Finish(); } - public CycleData CycleData - { - get { - return new CycleData { - AbsTime = CurrentState.AbsTime, - AbsDistance = CurrentState.Distance, - LeftSample = Left, - RightSample = CycleIntervalIterator.RightSample - }; - } - } + public CycleData CycleData => + new CycleData { + AbsTime = CurrentState.AbsTime, + AbsDistance = CurrentState.Distance, + LeftSample = Left, + RightSample = CycleIntervalIterator.RightSample + }; public bool PTOActive { get; private set; } @@ -550,16 +532,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - public Meter Altitude - { - get { return PreviousState.Altitude; } - } + public Meter Altitude => PreviousState.Altitude; - public Radian RoadGradient { get { return CurrentState.Gradient; } } - public MeterPerSecond TargetSpeed - { - get { return CurrentState.VehicleTargetSpeed; } - } + public Radian RoadGradient => CurrentState.Gradient; + + public MeterPerSecond TargetSpeed => CurrentState.VehicleTargetSpeed; public sealed class DrivingCycleState diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 8019d41f1c004b628ed60cc8e01fbd3106bf1a83..02b8894c21f032a0b06176cf7413def1a8df516d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -30,6 +30,7 @@ */ using System; +using System.Windows.Forms.DataVisualization.Charting; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -130,10 +131,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - public new IDataBus DataBus - { - get { return base.DataBus; } - } + public new IDataBus DataBus => base.DataBus; /// <summary> /// see documentation of IDriverActions @@ -144,9 +142,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <param name="gradient"></param> /// <param name="previousResponse"></param> /// <returns></returns> + /// <returns></returns> public IResponse DrivingActionAccelerate(Second absTime, Meter ds, MeterPerSecond targetVelocity, - Radian gradient, - IResponse previousResponse = null) + Radian gradient, IResponse previousResponse = null) { DrivingAction = DrivingAction.Accelerate; IterationStatistics.Increment(this, "Accelerate"); @@ -155,34 +153,33 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse retVal = null; DriverAcceleration = operatingPoint.Acceleration; - var response = previousResponse ?? - NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, - gradient, false); + var response = previousResponse ?? NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, false); response.Driver.Acceleration = operatingPoint.Acceleration; - response.Switch(). - Case<ResponseSuccess>(r => { + switch (response) { + case ResponseSuccess r: retVal = r; // => return - }). - Case<ResponseOverload>(). // do nothing, searchOperatingPoint is called later on - Case<ResponseEngineSpeedTooHigh>(). // do nothing, searchOperatingPoint is called later on - Case<ResponseUnderload>(r => { + break; + case ResponseOverload _: + break; // do nothing, searchOperatingPoint is called later on + case ResponseEngineSpeedTooHigh _: + break; // do nothing, searchOperatingPoint is called later on + case ResponseUnderload r: // Delta is negative we are already below the Drag-load curve. activate brakes retVal = r; // => return, strategy should brake - }). - Case<ResponseFailTimeInterval>(r => { + break; + case ResponseFailTimeInterval r: // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT }; - }). - Case<ResponseGearShift>(r => { + break; + case ResponseGearShift r: retVal = r; - }). - Default(r => { - throw new UnexpectedResponseException("DrivingAction Accelerate.", r); - }); - + break; + default: + throw new UnexpectedResponseException("DrivingAction Accelerate.", response); + } if (retVal == null) { // unhandled response (overload, delta > 0) - we need to search for a valid operating point.. @@ -197,11 +194,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } if (nextOperatingPoint == null && absTime > 0 && DataBus.VehicleInfo.VehicleStopped) { - Log.Info( - "No operating point found! Vehicle stopped! trying HALT action"); + Log.Info("No operating point found! Vehicle stopped! trying HALT action"); DataBus.Brakes.BrakePower = 1.SI<Watt>(); retVal = DrivingActionHalt(absTime, operatingPoint.SimulationInterval, 0.SI<MeterPerSecond>(), gradient); - + retVal.SimulationDistance = 0.SI<Meter>(); retVal.Driver.Acceleration = 0.SI<MeterPerSquareSecond>(); retVal.SimulationInterval = operatingPoint.SimulationInterval; @@ -211,7 +207,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl SimulationInterval = operatingPoint.SimulationInterval }; return retVal; - } + } var limitedOperatingPoint = nextOperatingPoint; if (!(retVal is ResponseEngineSpeedTooHigh || DataBus.ClutchInfo.ClutchClosed(absTime))) { @@ -230,10 +226,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (retVal != null) { retVal.Driver.Acceleration = limitedOperatingPoint.Acceleration; } - retVal.Switch(). - Case<ResponseUnderload>(() => operatingPoint = limitedOperatingPoint) - . // acceleration is limited by driver model, operating point moves below drag curve - Case<ResponseOverload>(() => { + + switch (retVal) { + case ResponseUnderload _: + operatingPoint = limitedOperatingPoint; + break; // acceleration is limited by driver model, operating point moves below drag curve + case ResponseOverload _: // deceleration is limited by driver model, operating point moves above full load (e.g., steep uphill) // the vehicle/driver can't achieve an acceleration higher than deceleration curve, try again with higher deceleration if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { @@ -247,13 +245,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DriverAcceleration = nextOperatingPoint.Acceleration; retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, nextOperatingPoint.Acceleration, gradient, false); - retVal.Switch().Case<ResponseFailTimeInterval>( - rt => { - // occurs only with AT gearboxes - extend time interval after gearshift! - retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT - }; - }); + if (retVal is ResponseFailTimeInterval rt) + // occurs only with AT gearboxes - extend time interval after gearshift! + retVal = new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT }; } else { if (absTime > 0 && DataBus.VehicleInfo.VehicleStopped) { Log.Info( @@ -265,76 +259,74 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //retVal.Acceleration = 0.SI<MeterPerSquareSecond>(); } else { if (response is ResponseEngineSpeedTooHigh) { - Log.Info( - "Operating point with limited acceleration due to high engine speed resulted in an overload, searching again..."); - nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, - retVal); + Log.Info("Operating point with limited acceleration due to high engine speed resulted in an overload, searching again..."); + nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, retVal); DriverAcceleration = nextOperatingPoint.Acceleration; retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, nextOperatingPoint.Acceleration, gradient, false); } else { - Log.Info( - "Operating point with limited acceleration resulted in an overload! trying again with original acceleration {0}", + Log.Info("Operating point with limited acceleration resulted in an overload! trying again with original acceleration {0}", nextOperatingPoint.Acceleration); DriverAcceleration = nextOperatingPoint.Acceleration; retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, - nextOperatingPoint.Acceleration, - gradient, false); + nextOperatingPoint.Acceleration, gradient, false); } } } retVal.Driver.Acceleration = operatingPoint.Acceleration; - retVal.Switch(). - Case<ResponseDrivingCycleDistanceExceeded>(). - Case<ResponseSuccess>(() => operatingPoint = nextOperatingPoint). - Case<ResponseGearShift>(() => operatingPoint = nextOperatingPoint). - Case<ResponseOverload>( - r => { - nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, - r); - DriverAcceleration = nextOperatingPoint.Acceleration; - retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, - nextOperatingPoint.Acceleration, gradient, false); - retVal.Switch().Case<ResponseFailTimeInterval>( - rt => { - // occurs only with AT gearboxes - extend time interval after gearshift! - retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT - }; - }); - }). - Case<ResponseFailTimeInterval>(r => { + switch (retVal) { + case ResponseDrivingCycleDistanceExceeded _: break; + case ResponseSuccess _: + operatingPoint = nextOperatingPoint; + break; + case ResponseGearShift _: + operatingPoint = nextOperatingPoint; + break; + case ResponseOverload r: + nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, r); + DriverAcceleration = nextOperatingPoint.Acceleration; + retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, + nextOperatingPoint.Acceleration, gradient, false); + if (retVal is ResponseFailTimeInterval rt) // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT + MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT }; - }). - Default( - r => { - throw new UnexpectedResponseException("DrivingAction Accelerate after Overload", r); - }); - }). - Case<ResponseGearShift>(() => operatingPoint = limitedOperatingPoint). - Case<ResponseFailTimeInterval>(r => { + break; + case ResponseFailTimeInterval r: + // occurs only with AT gearboxes - extend time interval after gearshift! + retVal = new ResponseDrivingCycleDistanceExceeded(this) { + MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT + }; + break; + default: + throw new UnexpectedResponseException("DrivingAction Accelerate after Overload", retVal); + } + + break; + case ResponseGearShift _: + operatingPoint = limitedOperatingPoint; + break; + case ResponseFailTimeInterval r: // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT }; - }). - Case<ResponseSuccess>(() => operatingPoint = limitedOperatingPoint). - Case<ResponseBatteryEmpty>(() => { }). - Case<ResponseEngineSpeedTooHigh>(r => { - nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, - r); - retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, - nextOperatingPoint.Acceleration, gradient, false); - }). - Default( - r => { - throw new UnexpectedResponseException( - "DrivingAction Accelerate after SearchOperatingPoint.", r); - }); + break; + case ResponseSuccess _: + operatingPoint = limitedOperatingPoint; + break; + case ResponseBatteryEmpty _: + break; + case ResponseEngineSpeedTooHigh r: + nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, r); + retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, nextOperatingPoint.Acceleration, gradient, false); + break; + default: + throw new UnexpectedResponseException("DrivingAction Accelerate after SearchOperatingPoint.", retVal); + } } + CurrentState.Acceleration = operatingPoint.Acceleration; CurrentState.dt = operatingPoint.SimulationInterval; CurrentState.Response = retVal; @@ -389,12 +381,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("DrivingAction Roll"); var retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, true); - retVal.Switch(). - Case<ResponseGearShift>( - () => { - throw new UnexpectedResponseException("DrivingAction Roll: Gearshift during Roll action.", - retVal); - }); + if (retVal is ResponseGearShift) + throw new UnexpectedResponseException("DrivingAction Roll: Gearshift during Roll action.", retVal); return retVal; } @@ -502,23 +490,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl response.Driver.Acceleration = limitedOperatingPoint.Acceleration; response.Driver.OperatingPoint = limitedOperatingPoint; - response.Switch(). - Case<ResponseSuccess>(). - Case<ResponseUnderload>(). // driver limits acceleration, operating point may be below engine's - //drag load resp. below 0 - Case<ResponseOverload>(). // driver limits acceleration, operating point may be above 0 (GBX), use brakes - Case<ResponseEngineSpeedTooHigh>(). // reduce acceleration/vehicle speed - Case<ResponseGearShift>(). - Case<ResponseFailTimeInterval>(r => { + switch (response) { + case ResponseSuccess _: + break; + case ResponseUnderload _: + break; // driver limits acceleration, operating point may be below engine's drag load resp. below 0 + case ResponseOverload _: + break; // driver limits acceleration, operating point may be above 0 (GBX), use brakes + case ResponseEngineSpeedTooHigh _: + break; // reduce acceleration/vehicle speed + case ResponseGearShift _: + break; + case ResponseFailTimeInterval r: response = new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT }; - }). - Default( - () => { - throw new UnexpectedResponseException( - "CoastOrRoll Action: unhandled response from powertrain.", response); - }); + break; + default: + throw new UnexpectedResponseException("CoastOrRoll Action: unhandled response from powertrain.", response); + } CurrentState.Response = response; CurrentState.Acceleration = response.Driver.Acceleration; @@ -534,7 +524,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (tc == null) { throw new VectoException("NO TorqueConverter Available!"); } - + if (dryRunResp == null) { throw new VectoException("dry-run response expected!"); } @@ -546,7 +536,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // out-torque at the torque converter var engineSpeed = DataBus.EngineInfo.EngineIdleSpeed * 1.01; var tcOp = EstimateTCOpPoint(operatingPoint, dryRunResp, engineSpeed, tcInfo); - + if (tcOp.Item1.Item2.IsBetween(tcOp.Item2, tcOp.Item3)) { if (!dryRunResp.TorqueConverter.TorqueConverterOperatingPoint.OutTorque.IsEqual(tcOp.Item1.Item1.OutTorque)) { tc.SetOperatingPoint = tcOp.Item1.Item1; @@ -595,7 +585,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }); } catch (Exception e) { Log.Error(e, "Failed to find engine speed for valid torque converter operating point! absTime: {0}", absTime); - + // if no engine speed can be found that results in an operating point on the TC curve, set the TC in-torque to the maximum // available from the engine. reverse-calc TC-in-torque from average engine torque var tcInPwrPrev = (DataBus.EngineInfo.EngineSpeed + tcOp.Item1.Item1.InAngularVelocity) * tcOp.Item1.Item2 - @@ -682,17 +672,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var deltaSpeed = VectoMath.Min(0.RPMtoRad(), tqOp.Item1.InAngularVelocity - DataBus.EngineInfo.EngineIdleSpeed) + VectoMath.Max(0.RPMtoRad(), tqOp.Item1.InAngularVelocity - DataBus.EngineInfo.EngineRatedSpeed); - var tqDiff = 0.SI<NewtonMeter>(); + var tqDiff = 0.SI<NewtonMeter>(); if (tqOp.Item2.IsSmaller(dragTorque)) { tqDiff = tqOp.Item2 - dragTorque; - + } if (tqOp.Item2.IsGreater(maxTorque)) { - tqDiff = tqOp.Item2 - maxTorque; + tqDiff = tqOp.Item2 - maxTorque; } return ((tqDiff.Value() * tqDiff.Value()) + (deltaSpeed.Value() * deltaSpeed.Value())).SI<NewtonMeter>(); - + } public IResponse DrivingActionBrake(Second absTime, Meter ds, MeterPerSecond nextTargetSpeed, Radian gradient, IResponse previousResponse = null, Meter targetDistance = null, DrivingAction? overrideAction = null) @@ -720,24 +710,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl gradient, false); var point = operatingPoint; - response.Switch(). - Case<ResponseSuccess>(r => retVal = r). - Case<ResponseOverload>(r => retVal = r) - . // i.e., driving uphill, clutch open, deceleration higher than desired deceleration - Case<ResponseUnderload>(). // will be handled in SearchBrakingPower - Case<ResponseEngineSpeedTooHigh>(r => { + switch (response) { + case ResponseSuccess r: + retVal = r; + break; + case ResponseOverload r: + retVal = r; + break; // i.e., driving uphill, clutch open, deceleration higher than desired deceleration + case ResponseUnderload _: + break; // will be handled in SearchBrakingPower + case ResponseEngineSpeedTooHigh r: Log.Debug("Engine speeed was too high, search for appropriate acceleration first."); - operatingPoint = SearchOperatingPoint(absTime, ds, gradient, point.Acceleration, - response); - }). // will be handled in SearchBrakingPower - Case<ResponseGearShift>(). // will be handled in SearchBrakingPower - Case<ResponseFailTimeInterval>(r => + operatingPoint = SearchOperatingPoint(absTime, ds, gradient, point.Acceleration, response); + break; // will be handled in SearchBrakingPower + case ResponseGearShift _: + break; // will be handled in SearchBrakingPower + case ResponseFailTimeInterval r: retVal = new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = DataBus.VehicleInfo.VehicleSpeed * r.DeltaT + point.Acceleration / 2 * r.DeltaT * r.DeltaT - }). - Default(r => { - throw new UnexpectedResponseException("DrivingAction Brake: first request.", r); - }); + }; + break; + default: + throw new UnexpectedResponseException("DrivingAction Brake: first request.", response); + } if (retVal != null) { CurrentState.Acceleration = operatingPoint.Acceleration; @@ -789,7 +784,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl gradient, false); var gearChanged = !(DataBus.GearboxInfo.Gear == gear && DataBus.GearboxInfo.TCLocked == tcLocked); if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) { - Log.Debug("Gear changed after a valid operating point was found - braking is no longer applicable due to overload"); + Log.Debug("Gear changed after a valid operating point was found - braking is no longer applicable due to overload"); return null; } @@ -811,15 +806,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl gradient, false); } - retVal.Switch(). - Case<ResponseSuccess>(). - Case<ResponseGearShift>(). - Case<ResponseFailTimeInterval>(r => + switch (retVal) { + case ResponseSuccess _: break; + case ResponseGearShift _: break; + case ResponseFailTimeInterval r: retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = - DataBus.VehicleInfo.VehicleSpeed * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT - }). - Case<ResponseUnderload>(r => { + MaxDistance = DataBus.VehicleInfo.VehicleSpeed * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT + }; + break; + case ResponseUnderload r: if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { operatingPoint = SearchBrakingPower(absTime, operatingPoint.SimulationDistance, gradient, operatingPoint.Acceleration, response); @@ -827,21 +822,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, false); } - }). - Case<ResponseOverload>(r => { + break; + case ResponseOverload r: if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { // overload may happen because of gearshift between search and actual request, search again var i = 5; while (i-- > 0 && !(retVal is ResponseSuccess)) { DataBus.Brakes.BrakePower = 0.SI<Watt>(); - + retVal = NextComponent.Request( absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, false); if (retVal is ResponseSuccess) { break; } - + operatingPoint = SearchBrakingPower(absTime, operatingPoint.SimulationDistance, gradient, operatingPoint.Acceleration, retVal); DriverAcceleration = operatingPoint.Acceleration; @@ -857,13 +852,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new UnexpectedResponseException( "DrivingAction Brake: request failed after braking power was found.", r); } - }). - Default( - r => { - throw new UnexpectedResponseException( - "DrivingAction Brake: request failed after braking power was found.", r); - }); - + + break; + default: + throw new UnexpectedResponseException("DrivingAction Brake: request failed after braking power was found.", retVal); + } + CurrentState.Acceleration = operatingPoint.Acceleration; CurrentState.dt = operatingPoint.SimulationInterval; CurrentState.Response = retVal; @@ -1006,29 +1000,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var operatingPoint = new OperatingPoint { SimulationDistance = ds, Acceleration = acceleration }; operatingPoint = ComputeTimeInterval(operatingPoint.Acceleration, ds); Watt deltaPower = null; - initialResponse.Switch(). - Case<ResponseGearShift>(r => { + switch (initialResponse) { + case ResponseGearShift r: IterationStatistics.Increment(this, "SearchBrakingPower"); DriverAcceleration = operatingPoint.Acceleration; var nextResp = NextComponent.Request(absTime, operatingPoint.SimulationInterval, - operatingPoint.Acceleration, - gradient, true); + operatingPoint.Acceleration, gradient, true); deltaPower = nextResp.Gearbox.PowerRequest; - }). - Case<ResponseEngineSpeedTooHigh>(r => { + break; + case ResponseEngineSpeedTooHigh r: IterationStatistics.Increment(this, "SearchBrakingPower"); DriverAcceleration = operatingPoint.Acceleration; - var nextResp = NextComponent.Request(absTime, operatingPoint.SimulationInterval, - operatingPoint.Acceleration, - gradient, true); - deltaPower = nextResp.Gearbox.PowerRequest; - }). - Case<ResponseUnderload>(r => - deltaPower = DataBus.ClutchInfo.ClutchClosed(absTime) && DataBus.GearboxInfo.GearEngaged(absTime) ? r.Delta : r.Gearbox.PowerRequest). - Default( - r => { - throw new UnexpectedResponseException("cannot use response for searching braking power!", r); - }); + var nextResp1 = NextComponent.Request(absTime, operatingPoint.SimulationInterval, + operatingPoint.Acceleration, gradient, true); + deltaPower = nextResp1.Gearbox.PowerRequest; + break; + case ResponseUnderload r: + deltaPower = DataBus.ClutchInfo.ClutchClosed(absTime) && DataBus.GearboxInfo.GearEngaged(absTime) ? r.Delta : r.Gearbox.PowerRequest; + break; + default: + throw new UnexpectedResponseException("cannot use response for searching braking power!", initialResponse); + } try { DataBus.Brakes.BrakePower = SearchAlgorithm.Search(DataBus.Brakes.BrakePower, deltaPower, @@ -1125,7 +1117,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var response = NextComponent.Request(absTime, retVal.SimulationInterval, acc, gradient, true); response.Driver.OperatingPoint = retVal; return response; - + }, criterion: response => { var r = (ResponseDryRun)response; @@ -1166,7 +1158,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // calculate new time interval only when vehiclespeed and acceleration are != 0 // else: use same timeinterval as before. var vehicleDrivesAndAccelerates = - !(acc.IsEqual(0) && DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)); + !(acc.IsEqual(0) && DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)); if (vehicleDrivesAndAccelerates) { var tmp = ComputeTimeInterval(acc, ds); if (tmp.SimulationInterval.IsEqual(0.SI<Second>(), 1e-9.SI<Second>())) { @@ -1232,23 +1224,34 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { Watt origDelta = null; if (actionRoll) { - initialResponse.Switch(). - Case<ResponseDryRun>(r => origDelta = r.Gearbox.PowerRequest). - Case<ResponseOverload>(r => origDelta = r.Delta). - Case<ResponseFailTimeInterval>(r => origDelta = r.Gearbox.PowerRequest). - Default(r => { - throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", r); - }); + switch (initialResponse) { + case ResponseDryRun r: + origDelta = r.Gearbox.PowerRequest; + break; + case ResponseOverload r: + origDelta = r.Delta; + break; + case ResponseFailTimeInterval r: + origDelta = r.Gearbox.PowerRequest; + break; + default: + throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", initialResponse); + } } else { - initialResponse.Switch(). - Case<ResponseOverload>(r => origDelta = r.Delta). - Case<ResponseEngineSpeedTooHigh>(r => { + switch (initialResponse) { + case ResponseOverload r: + origDelta = r.Delta; + break; + case ResponseEngineSpeedTooHigh r: + // search operating point in drive action after overload origDelta = r.DeltaEngineSpeed * 1.SI<NewtonMeter>(); - }). // search operating point in drive action after overload - Case<ResponseDryRun>(r => origDelta = coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad). - Default(r => { - throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", r); - }); + break; + case ResponseDryRun r: + origDelta = coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad; + break; + default: + throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", initialResponse); + } } return origDelta; } @@ -1353,11 +1356,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DriverAcceleration = 0.SI<MeterPerSquareSecond>(); var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient, false); - retVal.Switch(). - Case<ResponseGearShift>(r => { - DriverAcceleration = 0.SI<MeterPerSquareSecond>(); - retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient, false); - }); + if (retVal is ResponseGearShift) { + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); + retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient, false); + } CurrentState.dt = dt; CurrentState.Acceleration = 0.SI<MeterPerSquareSecond>(); return retVal; @@ -1371,7 +1373,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DriverStrategy.WriteModalResults(container); } - + protected override void DoCommitSimulationStep(Second time, Second simulationInterval) { if (CurrentState.Response != null && !(CurrentState.Response is ResponseSuccess)) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs index d2e736240db05d192a4fca0572e7eb23e5ca334c..d218b7ee5b386882a561aa1d4f14750868d3e8a2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs @@ -62,27 +62,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - public DrivingCycleData.DrivingCycleEntry Current - { - get { return LeftSample; } - } + public DrivingCycleData.DrivingCycleEntry Current => LeftSample; - public DrivingCycleData.DrivingCycleEntry LeftSample - { - get { return _data.Entries[_currentCycleIndex]; } - } + public DrivingCycleData.DrivingCycleEntry LeftSample => _data.Entries[_currentCycleIndex]; - public DrivingCycleData.DrivingCycleEntry RightSample - { - get { return _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; } - } + public DrivingCycleData.DrivingCycleEntry RightSample => _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; public bool LastEntry { get; private set; } - object System.Collections.IEnumerator.Current - { - get { return LeftSample; } - } + object System.Collections.IEnumerator.Current => LeftSample; public bool MoveNext() { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs index 43be274584ec503a1abf0301d62fae288bc76ac6..32b108d69df67cce0396ff904cdd21bc1771f0fb 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs @@ -26,75 +26,39 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IGearboxInfo - public GearboxType GearboxType - { - get { return GearboxType.AMT; } - } + public GearboxType GearboxType => GearboxType.AMT; - public GearshiftPosition Gear - { - get { return new GearshiftPosition(1); } - } + public GearshiftPosition Gear => new GearshiftPosition(1); - public bool TCLocked - { - get { return true; } - } + public bool TCLocked => true; - public MeterPerSecond StartSpeed - { - get { return DeclarationData.GearboxTCU.StartSpeed; } - } + public MeterPerSecond StartSpeed => DeclarationData.GearboxTCU.StartSpeed; - public MeterPerSquareSecond StartAcceleration - { - get { return DeclarationData.GearboxTCU.StartAcceleration; } - } + public MeterPerSquareSecond StartAcceleration => DeclarationData.GearboxTCU.StartAcceleration; public Watt GearboxLoss() { return 0.SI<Watt>(); } - public Second LastShift - { - get { return -double.MaxValue.SI<Second>(); } - } + public Second LastShift => -double.MaxValue.SI<Second>(); - public Second LastUpshift - { - get { return -double.MaxValue.SI<Second>(); } - } + public Second LastUpshift => -double.MaxValue.SI<Second>(); - public Second LastDownshift - { - get { return -double.MaxValue.SI<Second>(); } - } + public Second LastDownshift => -double.MaxValue.SI<Second>(); public GearData GetGearData(uint gear) { throw new NotImplementedException(); } - public GearshiftPosition NextGear - { - get { throw new NotImplementedException(); } - } + public GearshiftPosition NextGear => throw new NotImplementedException(); - public Second TractionInterruption - { - get { return 0.SI<Second>(); } - } + public Second TractionInterruption => 0.SI<Second>(); - public uint NumGears - { - get { return 1; } - } + public uint NumGears => 1; - public bool DisengageGearbox - { - get { return false; } - } + public bool DisengageGearbox => false; public bool GearEngaged(Second absTime) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index 7e9ff4a809457b960f5e04c9838f0543a2c4457f..b54e9f0bf737852758b537345b93e78f8c3b9b0f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -526,10 +526,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl - public PerSecond ElectricMotorSpeed - { - get { return PreviousState.EMSpeed; } - } + public PerSecond ElectricMotorSpeed => PreviousState.EMSpeed; public void Connect(IElectricSystem powersupply) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs index 8d9ce00efea22a7055d7439f4f821ed5ce72c342..3ee8595ee4a39aa6be51b0ec7eea3576fe5c90e4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs @@ -30,10 +30,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public GearRatingCase RatingCase { get; } public PerSecond MaxEngineSpeed { get; } - public double NumericValue - { - get { return ((int)RatingCase - 1) * CaseSeparationInterval + Rating.LimitTo(0, CaseSeparationInterval-1); } - } + public double NumericValue => ((int)RatingCase - 1) * CaseSeparationInterval + Rating.LimitTo(0, CaseSeparationInterval-1); public static bool operator <(GearRating first, GearRating second) { @@ -47,7 +44,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public override string ToString() { - return string.Format("{0} / {1} ({2})", RatingCase, Rating, NumericValue); + return $"{RatingCase} / {Rating} ({NumericValue})"; } public int CompareTo(object obj) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 40cebdc69f4b43bc41bbdddf71f2eda4f7aa9066..e1eb6819e60845f0de82ec733c37d2e80fda6fb9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -71,10 +71,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override Second LastDownshift { get; protected internal set; } - public override GearshiftPosition NextGear - { - get { return _strategy?.NextGear ?? _nextGear; } - } + public override GearshiftPosition NextGear => _strategy?.NextGear ?? _nextGear; public override bool GearEngaged(Second absTime) { @@ -135,10 +132,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - public override bool TCLocked - { - get { return true; } - } + public override bool TCLocked => true; protected internal virtual ResponseDryRun Initialize(Second absTime, GearshiftPosition gear, NewtonMeter outTorque, PerSecond outAngularVelocity) { @@ -159,9 +153,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl inTorque += inertiaPowerLoss / inAngularVelocity; } - var response = - NextComponent.Request(absTime, Constants.SimulationSettings.TargetTimeInterval, inTorque, - inAngularVelocity, true); //NextComponent.Initialize(inTorque, inAngularVelocity); + var response = NextComponent.Request(absTime, Constants.SimulationSettings.TargetTimeInterval, + inTorque, inAngularVelocity, true); + //NextComponent.Initialize(inTorque, inAngularVelocity); //response.Switch(). // Case<ResponseSuccess>(). // Case<ResponseOverload>(). @@ -204,8 +198,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </list> /// </returns> public override IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, - PerSecond outAngularVelocity, - bool dryRun = false) + PerSecond outAngularVelocity, bool dryRun = false) { IterationStatistics.Increment(this, "Requests"); @@ -230,7 +223,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl postponeEngage = true; } else { ReEngageGear(absTime, dt, outTorque, outAngularVelocity); - reEngaging = true; + reEngaging = true; Log.Debug("Gearbox engaged gear {0}", Gear); } } @@ -278,9 +271,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl (DataBus.DrivingCycleInfo.RoadGradient.IsSmaller(0) || (ICEAvailable && inAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineIdleSpeed))) && (DataBus.Brakes.BrakePower.IsGreater(0) || inTorque.IsSmaller(0)); - var vehiclespeedBelowThreshold = + var vehicleSpeedBelowThreshold = DataBus.VehicleInfo.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ClutchDisengageWhenHaltingSpeed); - if (halted || (driverDeceleratingNegTorque && vehiclespeedBelowThreshold)) { + if (halted || (driverDeceleratingNegTorque && vehicleSpeedBelowThreshold)) { EngageTime = VectoMath.Max(EngageTime, absTime + dt); _strategy?.Disengage(absTime, dt, outTorque, outAngularVelocity); //if (_strategy != null && DataBus.HybridControllerInfo != null && @@ -315,19 +308,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </list> /// </returns> private IResponse RequestGearDisengaged(Second absTime, Second dt, NewtonMeter outTorque, - PerSecond outAngularVelocity, NewtonMeter inTorque, - bool dryRun) + PerSecond outAngularVelocity, NewtonMeter inTorque, bool dryRun) { Disengaged = true; Log.Debug("Current Gear: Neutral"); - var avgAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; - var gear = NextGear; - - var inAngularVelocity = outAngularVelocity * ModelData.Gears[gear.Gear].Ratio; - var avgInAngularVelocity = (PreviousState.InAngularVelocity + inAngularVelocity) / 2.0; if (dryRun) { @@ -351,8 +338,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var shiftTimeExceeded = absTime.IsSmaller(EngageTime) && - EngageTime.IsSmaller(absTime + dt, - Constants.SimulationSettings.LowerBoundTimeInterval); + EngageTime.IsSmaller(absTime + dt, Constants.SimulationSettings.LowerBoundTimeInterval); // allow 5% tolerance of shift time if (shiftTimeExceeded && EngageTime - absTime > Constants.SimulationSettings.LowerBoundTimeInterval / 2) { return new ResponseFailTimeInterval(this) { @@ -378,12 +364,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl inTorque = 0.SI<NewtonMeter>(); } - if (!dryRun) { - CurrentState.SetState(inTorque, inAngularVelocity, outTorque, - outAngularVelocity); - CurrentState.Gear = gear; - CurrentState.TransmissionTorqueLoss = inTorque * ModelData.Gears[gear.Gear].Ratio - outTorque; - } + CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); + CurrentState.Gear = gear; + CurrentState.TransmissionTorqueLoss = inTorque * ModelData.Gears[gear.Gear].Ratio - outTorque; var response = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, false); @@ -417,7 +400,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var inAngularVelocity = outAngularVelocity * ModelData.Gears[Gear.Gear].Ratio; - if (dryRun) { + if (dryRun) { var dryRunResponse = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, true); dryRunResponse.Gearbox.PowerRequest = outTorque * (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; @@ -427,69 +410,69 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl dryRunResponse.Gearbox.OutputTorque = outTorque; dryRunResponse.Gearbox.OutputSpeed = outAngularVelocity; return dryRunResponse; - } - - var response = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, false); - response.Gearbox.InputSpeed = inAngularVelocity; - response.Gearbox.InputTorque = inTorque; - response.Gearbox.OutputTorque = outTorque; - response.Gearbox.OutputSpeed = outAngularVelocity; - - var shiftAllowed = !inAngularVelocity.IsEqual(0) && !DataBus.VehicleInfo.VehicleSpeed.IsEqual(0); - - if (response is ResponseSuccess && shiftAllowed) { - var shiftRequired = _strategy?.ShiftRequired(absTime, dt, outTorque, outAngularVelocity, inTorque, - response.Engine.EngineSpeed, Gear, EngageTime, response) ?? false; - - if (shiftRequired) { - if (_overrideDisengage != null) { - EngageTime = absTime; - return RequestGearEngaged(absTime, dt, outTorque, outAngularVelocity, inTorque, - inTorqueLossResult, inertiaTorqueLossOut, dryRun); - } - - EngageTime = absTime + ModelData.TractionInterruption; - - Log.Debug( - "Gearbox is shifting. absTime: {0}, dt: {1}, interuptionTime: {2}, out: ({3}, {4}), in: ({5}, {6})", - absTime, - dt, EngageTime, outTorque, outAngularVelocity, inTorque, inAngularVelocity); - - Disengaged = true; - _strategy.Disengage(absTime, dt, outTorque, outAngularVelocity); - Log.Info("Gearbox disengaged"); - - return new ResponseGearShift(this, response) { - SimulationInterval = ModelData.TractionInterruption, - Gearbox = { + } else { + var response = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, false); + response.Gearbox.InputSpeed = inAngularVelocity; + response.Gearbox.InputTorque = inTorque; + response.Gearbox.OutputTorque = outTorque; + response.Gearbox.OutputSpeed = outAngularVelocity; + + var shiftAllowed = !inAngularVelocity.IsEqual(0) && !DataBus.VehicleInfo.VehicleSpeed.IsEqual(0); + + if (response is ResponseSuccess && shiftAllowed) { + var shiftRequired = _strategy?.ShiftRequired(absTime, dt, outTorque, outAngularVelocity, inTorque, + response.Engine.EngineSpeed, Gear, EngageTime, response) ?? false; + + if (shiftRequired) { + if (_overrideDisengage != null) { + EngageTime = absTime; + return RequestGearEngaged(absTime, dt, outTorque, outAngularVelocity, inTorque, + inTorqueLossResult, inertiaTorqueLossOut, false); + } + + EngageTime = absTime + ModelData.TractionInterruption; + + Log.Debug( + "Gearbox is shifting. absTime: {0}, dt: {1}, interuptionTime: {2}, out: ({3}, {4}), in: ({5}, {6})", + absTime, + dt, EngageTime, outTorque, outAngularVelocity, inTorque, inAngularVelocity); + + Disengaged = true; + _strategy.Disengage(absTime, dt, outTorque, outAngularVelocity); + Log.Info("Gearbox disengaged"); + + return new ResponseGearShift(this, response) { + SimulationInterval = ModelData.TractionInterruption, + Gearbox = { PowerRequest = outTorque * (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0, Gear = Gear }, - - }; + + }; + } } - } - // this code has to be _after_ the check for a potential gear-shift! - // (the above block issues dry-run requests and thus may update the CurrentState!) - // begin critical section - CurrentState.TransmissionTorqueLoss = inTorque * ModelData.Gears[Gear.Gear].Ratio - outTorque; - // MQ 19.2.2016: check! inertia is related to output side, torque loss accounts to input side - CurrentState.InertiaTorqueLossOut = inertiaTorqueLossOut; + // this code has to be _after_ the check for a potential gear-shift! + // (the above block issues dry-run requests and thus may update the CurrentState!) + // begin critical section + CurrentState.TransmissionTorqueLoss = inTorque * ModelData.Gears[Gear.Gear].Ratio - outTorque; + // MQ 19.2.2016: check! inertia is related to output side, torque loss accounts to input side + CurrentState.InertiaTorqueLossOut = inertiaTorqueLossOut; - CurrentState.TorqueLossResult = inTorqueLossResult; - CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); - CurrentState.Gear = Gear; - // end critical section + CurrentState.TorqueLossResult = inTorqueLossResult; + CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); + CurrentState.Gear = Gear; + // end critical section - response.Gearbox.PowerRequest = - outTorque * (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; - response.Gearbox.Gear = Gear; + response.Gearbox.PowerRequest = + outTorque * (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; + response.Gearbox.Gear = Gear; - return response; + return response; + } } private void ReEngageGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) @@ -575,17 +558,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool SwitchToNeutral { - set - { - _overrideDisengage = value ? DataBus.AbsTime : null; - //Disengaged = value; - } + set => _overrideDisengage = value ? DataBus.AbsTime : null; + //Disengaged = value; } - public override Second LastShift - { - get { return EngageTime; } - } + public override Second LastShift => EngageTime; } public class PEVGearbox : Gearbox @@ -614,7 +591,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var response = NextComponent.Request(absTime, Constants.SimulationSettings.TargetTimeInterval, inTorque, inAngularVelocity, true); //NextComponent.Initialize(inTorque, inAngularVelocity); - + var fullLoad = -DataBus.ElectricMotorInfo(PowertrainPosition.BatteryElectricE2).MaxPowerDrive(inAngularVelocity); Gear = oldGear; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs index 9f8032b500481797faf7b4820ad89af38d811b2c..a814528687f14ff125d67aec928d2cb3c3d9c98b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs @@ -49,10 +49,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ElectricSystem = es; } - public IHybridControlStrategy Strategy - { - get { return _hybridStrategy; } - } + public IHybridControlStrategy Strategy => _hybridStrategy; public IElectricSystem ElectricSystem { get; } @@ -86,45 +83,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //} } - SimpleComponentState IHybridController.PreviousState - { - get { return PreviousState; } - } + SimpleComponentState IHybridController.PreviousState => PreviousState; public virtual IElectricMotorControl ElectricMotorControl(PowertrainPosition pos) { return _electricMotorCtl[pos]; } - public virtual IShiftStrategy ShiftStrategy - { - get { return _shiftStrategy; } - } + public virtual IShiftStrategy ShiftStrategy => _shiftStrategy; public GearshiftPosition SelectedGear { get; protected set; } - public bool GearboxEngaged - { - get { return CurrentStrategySettings.GearboxEngaged; } - } + public bool GearboxEngaged => CurrentStrategySettings.GearboxEngaged; public PerSecond ElectricMotorSpeed(PowertrainPosition pos) { return CurrentStrategySettings.MechanicalAssistPower[pos].Item1; } - public Second SimulationInterval - { - get - { - return CurrentStrategySettings.SimulationInterval; - } - } + public Second SimulationInterval => CurrentStrategySettings.SimulationInterval; - public PerSecond ICESpeed - { - get { return CurrentStrategySettings.EvaluatedSolution.Response?.Engine.EngineSpeed; } - } + public PerSecond ICESpeed => CurrentStrategySettings.EvaluatedSolution.Response?.Engine.EngineSpeed; public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, @@ -198,8 +177,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Strategy.AllowEmergencyShift = true; retryCount++; retry = true; - Strategy.OperatingpointChangedDuringRequest(absTime, dt, outTorque, outAngularVelocity, dryRun, - retVal); + Strategy.OperatingpointChangedDuringRequest(absTime, dt, outTorque, outAngularVelocity, false, retVal); continue; } @@ -207,8 +185,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retryCount++; retry = true; Strategy.AllowEmergencyShift = true; - Strategy.OperatingpointChangedDuringRequest(absTime, dt, outTorque, outAngularVelocity, dryRun, - retVal); + Strategy.OperatingpointChangedDuringRequest(absTime, dt, outTorque, outAngularVelocity, false, retVal); continue; } @@ -274,15 +251,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //return CurrentState.StrategyResponse.MechanicalAssistPower[pos]; } - public GearshiftPosition NextGear - { - get { return CurrentState.StrategyResponse.NextGear; } - } + public GearshiftPosition NextGear => CurrentState.StrategyResponse.NextGear; - public bool ShiftRequired - { - get { return CurrentState.StrategyResponse.ShiftRequired; } - } + public bool ShiftRequired => CurrentState.StrategyResponse.ShiftRequired; public IHybridControlledGearbox Gearbox { protected get; set; } public ICombustionEngine Engine { protected get; set; } @@ -531,7 +502,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override IGearbox Gearbox { - get { return _gearbox; } + get => _gearbox; set { var myGearbox = value as Gearbox; @@ -544,10 +515,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public override GearshiftPosition NextGear - { - get { return _nextGear; } - } + public override GearshiftPosition NextGear => _nextGear; public void SetNextGear(GearshiftPosition nextGear) { @@ -567,7 +535,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override IGearbox Gearbox { - get { return _gearbox; } + get => _gearbox; set { var myGearbox = value as ATGearbox; @@ -628,7 +596,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { - throw new System.NotImplementedException("AT Shift Strategy does not support disengaging."); + throw new NotImplementedException("AT Shift Strategy does not support disengaging."); } protected override bool SpeedTooLowForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs index 646d0201a33a05e7aa3f941883e5d0e0cf6849ee..f5c45832c342e67ce2ac4dee01658e19d4c0d060 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { - throw new InvalidOperationException(string.Format("{0} cannot initialize.", GetType().FullName)); + throw new InvalidOperationException($"{GetType().FullName} cannot initialize."); } public ITnOutPort RequestPort diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs index c595f12c726e926e0f294687691fcbe588d7a963..deb1e9e501dc01f49fca3b719b2a722e986611b8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs @@ -43,6 +43,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl SkipGears = true; } - public new static string Name { get { return "MT Shift Strategy"; } } + public new static string Name => "MT Shift Strategy"; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index b2c924b55a59308c3599a05814f6f2d1588e324d..6b62c5d065916c9508fc668b2f1a8138aca964c8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -140,7 +140,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // reduce the current simulation interval to extend the remaining interval return new ResponseFailTimeInterval(this) { AbsTime = absTime, - DeltaT = (CycleIterator.RightSample.Time - absTime)/2 + DeltaT = (CycleIterator.RightSample.Time - absTime) / 2 }; } } @@ -176,33 +176,36 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl do { response = NextComponent.Request(absTime, dt, acceleration, gradient, false); debug.Add(response); - response.Switch() - .Case<ResponseGearShift>(() => response = NextComponent.Request(absTime, dt, acceleration, gradient, false)) - .Case<ResponseUnderload>(r => { + + switch (response) { + case ResponseGearShift _: + response = NextComponent.Request(absTime, dt, acceleration, gradient, false); + break; + case ResponseUnderload r: response = HandleUnderload(absTime, dt, r, gradient, ref acceleration); - }) - .Case<ResponseOverload>(r => { + break; + case ResponseOverload r: response = HandleOverload(absTime, dt, r, gradient, ref acceleration); - }) - .Case<ResponseEngineSpeedTooHigh>(r => { + break; + case ResponseEngineSpeedTooHigh r: acceleration = SearchAlgorithm.Search(acceleration, r.DeltaEngineSpeed, Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating, getYValue: result => ((ResponseDryRun)result).DeltaEngineSpeed, + // ReSharper disable once AccessToModifiedClosure evaluateFunction: x => NextComponent.Request(absTime, dt, x, gradient, true), - criterion: - y => ((ResponseDryRun)y).DeltaEngineSpeed.Value()); - Log.Info( - "Found operating point for driver acceleration. absTime: {0}, dt: {1}, acceleration: {2}, gradient: {3}", + criterion: y => ((ResponseDryRun)y).DeltaEngineSpeed.Value()); + Log.Info("Found operating point for driver acceleration. absTime: {0}, dt: {1}, acceleration: {2}, gradient: {3}", absTime, dt, acceleration, gradient); - }) - .Case<ResponseFailTimeInterval>(r => { + break; + case ResponseFailTimeInterval r: dt = r.DeltaT; - }) - .Case<ResponseSuccess>() - .Default( - r => { - throw new UnexpectedResponseException("MeasuredSpeedDrivingCycle received an unexpected response.", r); - }); + break; + case ResponseSuccess _: + break; + default: + throw new UnexpectedResponseException("MeasuredSpeedDrivingCycle received an unexpected response.", response); + } + } while (!(response is ResponseSuccess || response is ResponseFailTimeInterval) && (++responseCount < 10)); AbsTime = absTime + dt; @@ -261,7 +264,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private IResponse HandleOverload(Second absTime, Second dt, ResponseOverload r, Radian gradient, ref MeterPerSquareSecond acceleration) { - IResponse response; if (DataBus.ClutchInfo.ClutchClosed(absTime)) { acceleration = SearchAlgorithm.Search(acceleration, r.Delta, Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating, @@ -301,7 +303,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl criterion: y => ((ResponseDryRun)y).DeltaFullLoad.Value()); } } - response = NextComponent.Request(absTime, dt, acceleration, gradient, false); + var response = NextComponent.Request(absTime, dt, acceleration, gradient, false); return response; } @@ -323,28 +325,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl AdvanceState(); } - public double Progress - { - get { return AbsTime == null ? 0 : AbsTime.Value() / Data.Entries.Last().Time.Value(); } - } + public double Progress => AbsTime == null ? 0 : AbsTime.Value() / Data.Entries.Last().Time.Value(); - public CycleData CycleData - { - get - { - return new CycleData { - AbsTime = CycleIterator.LeftSample.Time, - AbsDistance = null, - LeftSample = CycleIterator.LeftSample, - RightSample = CycleIterator.RightSample, - }; - } - } + public CycleData CycleData => + new CycleData { + AbsTime = CycleIterator.LeftSample.Time, + AbsDistance = null, + LeftSample = CycleIterator.LeftSample, + RightSample = CycleIterator.RightSample, + }; - public bool PTOActive - { - get { return false; } - } + public bool PTOActive => false; public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance) { @@ -352,25 +343,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //throw new System.NotImplementedException(); } - public Meter Altitude - { - get { return CycleIterator.LeftSample.Altitude; } - } + public Meter Altitude => CycleIterator.LeftSample.Altitude; - public Radian RoadGradient { get { return CycleIterator.LeftSample.RoadGradient; } } - public MeterPerSecond TargetSpeed - { - get { return CycleIterator.LeftSample.VehicleTargetSpeed; } - } - public Second StopTime - { - get { return CycleIterator.LeftSample.StoppingTime; } - } + public Radian RoadGradient => CycleIterator.LeftSample.RoadGradient; - public Meter CycleStartDistance - { - get { return 0.SI<Meter>(); } - } + public MeterPerSecond TargetSpeed => CycleIterator.LeftSample.VehicleTargetSpeed; + + public Second StopTime => CycleIterator.LeftSample.StoppingTime; + + public Meter CycleStartDistance => 0.SI<Meter>(); public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) { @@ -389,25 +370,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - public SpeedChangeEntry LastTargetspeedChange { get { return null; } } + public SpeedChangeEntry LastTargetspeedChange => null; - public void FinishSimulation() - { - Data.Finish(); - } + public void FinishSimulation() => Data.Finish(); public DrivingBehavior DriverBehavior { get; internal set; } - public DrivingAction DrivingAction - { - get { return DrivingAction.Accelerate; } - } + public DrivingAction DrivingAction => DrivingAction.Accelerate; public MeterPerSquareSecond DriverAcceleration { get; protected set; } - public Meter Distance - { - get { return CurrentState.Distance; } - } + public Meter Distance => CurrentState.Distance; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVAMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVAMTShiftStrategy.cs index 4360fca3bd65040cab9671a635d5dd21d2145446..a5f0127cdbaf26a95d97b4b57eaf6e3b83241ab1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVAMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVAMTShiftStrategy.cs @@ -44,9 +44,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool SkipGears { get; } - public static string Name { - get { return "AMT - EffShift (BEV)"; } - } + public static string Name => "AMT - EffShift (BEV)"; public PEVAMTShiftStrategy(IVehicleContainer dataBus) @@ -70,7 +68,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl SkipGears = true; TransmissionRatio = runData.AxleGearData.AxleGear.Ratio * - (runData.AngledriveData == null ? 1.0 : runData.AngledriveData.Angledrive.Ratio) / + (runData.AngledriveData?.Angledrive.Ratio ?? 1.0) / runData.VehicleData.DynamicTyreRadius; //var minEngineSpeed = (runData.EngineData.FullLoadCurves[0].RatedSpeed - runData.EngineData.IdleSpeed) * // Constants.SimulationSettings.ClutchClosingSpeedNorm + runData.EngineData.IdleSpeed; @@ -641,7 +639,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { } public IGearbox Gearbox { - get { return _gearbox; } + get => _gearbox; set { var myGearbox = value as Gearbox; if (myGearbox == null) { @@ -651,9 +649,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public GearshiftPosition NextGear { - get { return _nextGear; } - } + public GearshiftPosition NextGear => _nextGear; public bool CheckGearshiftRequired { get; protected set; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs index 24cb6dc355707ec475b3fce02d6784c3c0850f8b..db93702f781420f96552fb94158b5e06558f5d56 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs @@ -47,7 +47,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public ITnOutPort RequestPort { - set { NextComponent = value; } + set => NextComponent = value; } public readonly Second Duration; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs index 4f4aa1082190a89a9e8a27b118b63cb8579017c2..36c6974618180d9a0a1994fb6cd4c935b6be9005 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs @@ -116,30 +116,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <summary> /// True if the angularVelocity at the wheels is 0. /// </summary> - public virtual bool VehicleStopped - { - get { return CycleIterator.LeftSample.WheelAngularVelocity.IsEqual(0); } - } + public virtual bool VehicleStopped => CycleIterator.LeftSample.WheelAngularVelocity.IsEqual(0); - public Kilogram VehicleMass - { - get { return RunData.VehicleData.TotalCurbMass; } - } + public Kilogram VehicleMass => RunData.VehicleData.TotalCurbMass; - public Kilogram VehicleLoading - { - get { return RunData.VehicleData.Loading; } - } + public Kilogram VehicleLoading => RunData.VehicleData.Loading; - public Kilogram TotalMass - { - get { return RunData.VehicleData.TotalVehicleMass; } - } + public Kilogram TotalMass => RunData.VehicleData.TotalVehicleMass; - public CubicMeter CargoVolume - { - get { return RunData.VehicleData.CargoVolume; } - } + public CubicMeter CargoVolume => RunData.VehicleData.CargoVolume; public Newton AirDragResistance(MeterPerSecond previousVelocity, MeterPerSecond nextVelocity) { @@ -156,25 +141,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new System.NotImplementedException(); } - public MeterPerSecond MaxVehicleSpeed { get { return null; } } + public MeterPerSecond MaxVehicleSpeed => null; /// <summary> /// Always Driving. /// </summary> - public DrivingBehavior DriverBehavior - { - get { return DrivingBehavior.Driving; } - } + public DrivingBehavior DriverBehavior => DrivingBehavior.Driving; - public DrivingAction DrivingAction - { - get { return DrivingAction.Accelerate; } - } + public DrivingAction DrivingAction => DrivingAction.Accelerate; - public MeterPerSquareSecond DriverAcceleration - { - get { return 0.SI<MeterPerSquareSecond>(); } - } + public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); #endregion } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 4841b37ea40749e5a87d7579526c3b021c912466..1c8ee412bba22725e1a01068789efb6c0db3d9c3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -118,10 +118,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.InAngularVelocity = angularVelocity; CurrentState.InTorque = CycleIterator.LeftSample.Torque; debug.Add(response); - response.Switch() - .Case<ResponseGearShift>( - () => response = NextComponent.Request(absTime, dt, CurrentState.InTorque, angularVelocity, false)) - .Case<ResponseUnderload>(r => { + switch (response) { + case ResponseGearShift _: + response = NextComponent.Request(absTime, dt, CurrentState.InTorque, angularVelocity, false); + break; + case ResponseUnderload r: var torqueInterval = -r.Delta / (angularVelocity.IsEqual(0) ? 10.RPMtoRad() : angularVelocity); var torque = SearchAlgorithm.Search(CycleIterator.LeftSample.Torque, r.Delta, torqueInterval, getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, @@ -129,31 +130,31 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl criterion: y => ((ResponseDryRun)y).DeltaDragLoad.Value()); response = NextComponent.Request(absTime, dt, torque, angularVelocity, false); CurrentState.InTorque = torque; - }) - .Case<ResponseOverload>(r => { - var torque = SearchAlgorithm.Search(CycleIterator.LeftSample.Torque, r.Delta, - 50.SI<NewtonMeter>(), + break; + case ResponseOverload r: + var torque2 = SearchAlgorithm.Search(CycleIterator.LeftSample.Torque, r.Delta, 50.SI<NewtonMeter>(), getYValue: result => ((ResponseDryRun)result).DeltaFullLoad, evaluateFunction: t => NextComponent.Request(absTime, dt, t, angularVelocity, true), criterion: y => ((ResponseDryRun)y).DeltaFullLoad.Value()); - response = NextComponent.Request(absTime, dt, torque, angularVelocity, false); + response = NextComponent.Request(absTime, dt, torque2, angularVelocity, false); CurrentState.InAngularVelocity = angularVelocity; - CurrentState.InTorque = torque; - }) - .Case<ResponseEngineSpeedTooHigh>(r => { + CurrentState.InTorque = torque2; + break; + case ResponseEngineSpeedTooHigh r: angularVelocity = SearchAlgorithm.Search(angularVelocity, r.DeltaEngineSpeed, 1.RPMtoRad(), getYValue: result => ((ResponseDryRun)result).DeltaEngineSpeed, evaluateFunction: x => NextComponent.Request(absTime, dt, CurrentState.InTorque, x, true), criterion: y => ((ResponseDryRun)y).DeltaEngineSpeed.Value()); - }) - .Case<ResponseFailTimeInterval>(r => { dt = r.DeltaT; }) - .Case<ResponseSuccess>(() => { }) - .Default( - r => { - throw new UnexpectedResponseException( - "PowertrainDrivingCycle received an unexpected response.", r); - }); + break; + case ResponseFailTimeInterval r: + dt = r.DeltaT; + break; + case ResponseSuccess _: + break; + default: + throw new UnexpectedResponseException("PowertrainDrivingCycle received an unexpected response.", response); + } } while (!(response is ResponseSuccess || response is ResponseFailTimeInterval) && (++responseCount < 10)); AbsTime = absTime + dt; @@ -162,17 +163,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - public double Progress - { - get { return Math.Max(0, AbsTime.Value() / Data.Entries.Last().Time.Value()); } - } + public double Progress => Math.Max(0, AbsTime.Value() / Data.Entries.Last().Time.Value()); #endregion #region VectoSimulationComponent - protected override void DoWriteModalResults(Second time, Second simulationInterval, - IModalDataContainer container) { } + protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) + { } protected override void DoCommitSimulationStep(Second time, Second simulationInterval) { @@ -182,60 +180,34 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #endregion - public CycleData CycleData - { - get - { - return new CycleData { - AbsTime = CycleIterator.LeftSample.Time, - AbsDistance = null, - LeftSample = CycleIterator.LeftSample, - RightSample = CycleIterator.RightSample, - }; - } - } + public CycleData CycleData => + new CycleData { + AbsTime = CycleIterator.LeftSample.Time, + AbsDistance = null, + LeftSample = CycleIterator.LeftSample, + RightSample = CycleIterator.RightSample, + }; - public bool PTOActive - { - get { return true; } - } + public bool PTOActive => true; public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance) { - return new DrivingCycleData.DrivingCycleEntry() { + return new DrivingCycleData.DrivingCycleEntry { Altitude = 0.SI<Meter>() }; } - public Meter Altitude - { - get { return 0.SI<Meter>(); } - } + public Meter Altitude => 0.SI<Meter>(); - public Radian RoadGradient - { - get { return 0.SI<Radian>(); } - } + public Radian RoadGradient => 0.SI<Radian>(); - public MeterPerSecond TargetSpeed - { - get { throw new NotImplementedException("Targetspeed in Powertrain not available?"); } - } + public MeterPerSecond TargetSpeed => throw new NotImplementedException("Targetspeed in Powertrain not available?"); - public Second StopTime - { - get { return CycleIterator.LeftSample.StoppingTime; } - } + public Second StopTime => CycleIterator.LeftSample.StoppingTime; - public Meter CycleStartDistance - { - get { return 0.SI<Meter>(); } - } + public Meter CycleStartDistance => 0.SI<Meter>(); - public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) - { - throw new NotImplementedException(); - } + public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) => throw new NotImplementedException(); public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time) { @@ -249,14 +221,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - public SpeedChangeEntry LastTargetspeedChange - { - get { return null; } - } + public SpeedChangeEntry LastTargetspeedChange => null; - public void FinishSimulation() - { - Data.Finish(); - } + public void FinishSimulation() => Data.Finish(); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index 1970981e5ef32bef3ab0a974fe4ea3c1ed849060..e7cb660c2c3d5c48c3fba2ecb7fe4986761df1d6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override IGearbox Gearbox { - get { return _gearbox; } + get => _gearbox; set { var myGearbox = value as Gearbox; if (myGearbox == null) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs index 2390dbb7ea7fad7a2b891df063e69b857685f0e8..204cf6ef07b007514c35b8e7d41a294ee835319d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs @@ -24,7 +24,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public SimpleHybridController(VehicleContainer container, ElectricSystem es, SwitchableClutch clutch) : base(container) { - this.ElectricSystem = es; + ElectricSystem = es; //this.clutch = clutch; } @@ -62,15 +62,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { #region Implementation of IHybridController - public IShiftStrategy ShiftStrategy - { - get { return null; } - } + public IShiftStrategy ShiftStrategy => null; - public SimpleComponentState PreviousState - { - get { throw new System.NotImplementedException(); } - } + public SimpleComponentState PreviousState => throw new NotImplementedException(); public IElectricMotorControl ElectricMotorControl(PowertrainPosition pos) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs index ca523806819f30ff811089970def1f36f500c9dd..8f0f795da17247d4991a05906b6c8a7c4089889b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs @@ -13,46 +13,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { RunData = runData; } - public IDriverDemandOutPort VehiclePort - { - get { return (VehicleInfo as Vehicle)?.OutPort(); } - } + public IDriverDemandOutPort VehiclePort => (VehicleInfo as Vehicle)?.OutPort(); - public ITnOutPort GearboxOutPort - { - get { return (GearboxInfo as IGearbox)?.OutPort(); } - } + public ITnOutPort GearboxOutPort => (GearboxInfo as IGearbox)?.OutPort(); - public IGearbox GearboxCtlTest - { - get { return GearboxInfo as IGearbox; } - } + public IGearbox GearboxCtlTest => GearboxInfo as IGearbox; - public override Second AbsTime { get { return 0.SI<Second>(); } } + public override Second AbsTime => 0.SI<Second>(); - public override IDriverInfo DriverInfo { get { return base.DriverInfo ?? this; } } + public override IDriverInfo DriverInfo => base.DriverInfo ?? this; - public override bool IsTestPowertrain - { - get { return true; } - } + public override bool IsTestPowertrain => true; #region Implementation of IDriverInfo - public DrivingBehavior DriverBehavior - { - get { return DrivingBehavior.Driving; } - } + public DrivingBehavior DriverBehavior => DrivingBehavior.Driving; - public DrivingAction DrivingAction - { - get { return DrivingAction.Accelerate; } - } + public DrivingAction DrivingAction => DrivingAction.Accelerate; - public MeterPerSquareSecond DriverAcceleration - { - get { return 0.SI<MeterPerSquareSecond>(); } - } + public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); #endregion } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs index 45e6fd86a036b4840970c0687642a2a9ced969fd..662712a887f29562e50f6022bfa51100ae871a5a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs @@ -9,7 +9,8 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { +namespace TUGraz.VectoCore.Models.SimulationComponent.Impl +{ public class StopStartCombustionEngine : CombustionEngine { protected double EngineStopStartUtilityFactor; @@ -91,8 +92,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { CurrentState.dt = dt; //if (!dryRun) { - //EngineAux.TorqueDemand(absTime, dt, 0.SI<NewtonMeter>(), 0.SI<NewtonMeter>(), ModelData.IdleSpeed); - //CurrentState.AuxPowerEngineOff = EngineAux.PowerDemandEngineOff(absTime, dt); + //EngineAux.TorqueDemand(absTime, dt, 0.SI<NewtonMeter>(), 0.SI<NewtonMeter>(), ModelData.IdleSpeed); + //CurrentState.AuxPowerEngineOff = EngineAux.PowerDemandEngineOff(absTime, dt); //} else { if (dryRun) { return new ResponseDryRun(this) { @@ -114,7 +115,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { }; } - EngineAux?.TorqueDemand(absTime, dt, outTorque, outAngularVelocity, dryRun); + EngineAux?.TorqueDemand(absTime, dt, outTorque, outAngularVelocity); return new ResponseSuccess(this) { Engine = { TorqueOutDemand = outTorque, @@ -153,7 +154,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { (EngineStartEnergy + (engineRampUpEnergy + engineDragEnergy) * EngineStopStartUtilityFactor) / CurrentState.dt; } else { - container[ModalResultField.P_ice_start] = 0.SI<Watt>(); + container[ModalResultField.P_ice_start] = 0.SI<Watt>(); } container[ModalResultField.P_aux_ESS_mech_ice_off] = 0.SI<Watt>(); @@ -183,11 +184,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { container[ModalResultField.T_ice_drag] = 0.SI<NewtonMeter>(); container[ModalResultField.ICEOn] = CurrentState.EngineOn; - + var auxDemandPwrICEOn = EngineAux.PowerDemandESSEngineOn(time, simulationInterval, ModelData.IdleSpeed); var auxDemandPwrICEOff = EngineAux.PowerDemandESSEngineOff(time, simulationInterval); var auxDemandTq = auxDemandPwrICEOn / ModelData.IdleSpeed; - + container[ModalResultField.P_aux_ESS_mech_ice_off] = (auxDemandPwrICEOff ?? 0.SI<Watt>()); container[ModalResultField.P_aux_ESS_mech_ice_on] = (auxDemandPwrICEOn ?? 0.SI<Watt>()); @@ -206,7 +207,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { //fcAAUX = advancedAux.AAuxFuelConsumption; } - + var result = fuel.ConsumptionMap.GetFuelConsumption(auxDemandTq, ModelData.IdleSpeed); var fcESS = result.Value * (1 - EngineStopStartUtilityFactor) * fuel.FuelData.HeatingValueCorrection * WHTCCorrectionFactor(fuel.FuelData); @@ -242,8 +243,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { { public SimplePowerrtrainCombustionEngine( IVehicleContainer container, CombustionEngineData modelData, bool pt1Disabled = false) : base( - container, modelData, pt1Disabled) { } + container, modelData, pt1Disabled) + { } - public EngineState EnginePreviousState { get { return PreviousState; } } + public EngineState EnginePreviousState => PreviousState; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs index 57e408318d4a1b6b9b9a7345a07f5d31336c0f2e..f786f997b509c0a119549b553f7d252c6c777ef4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs @@ -22,25 +22,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ModelData = modelData; } - public IElectricEnergyStoragePort MainBatteryPort - { - get { return this; } - } - public Volt InternalVoltage - { - get { return PreviousState.Charge / ModelData.Capacity; } - } + public IElectricEnergyStoragePort MainBatteryPort => this; - public double StateOfCharge - { - get { return PreviousState.Charge / (ModelData.Capacity * ModelData.MaxVoltage); } - } + public Volt InternalVoltage => PreviousState.Charge / ModelData.Capacity; - public WattSecond StoredEnergy - { + public double StateOfCharge => PreviousState.Charge / (ModelData.Capacity * ModelData.MaxVoltage); + + public WattSecond StoredEnergy => // E = 1/2 C * U^2 = 1/2 Q^2/C - get { return PreviousState.Charge * InternalVoltage / 2.0; } - } + PreviousState.Charge * InternalVoltage / 2.0; public Watt MaxChargePower(Second dt) { @@ -63,14 +53,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return VectoMath.Max(maxDischargePower, maxPower); } - public double MinSoC - { - get { return ModelData.MinVoltage / ModelData.MaxVoltage; } - } - public double MaxSoC - { - get { return 1; } - } + public double MinSoC => ModelData.MinVoltage / ModelData.MaxVoltage; + + public double MaxSoC => 1; public void Initialize(double initialSoC) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs index 22d178872f56dffeb2e4da6b62207543b457cbcf..ea80b530199618eb4e0869185675b425646780d8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs @@ -174,7 +174,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return; } var transmissionRatio = RunData.AxleGearData.AxleGear.Ratio * - (RunData.AngledriveData == null ? 1.0 : RunData.AngledriveData.Angledrive.Ratio) / + (RunData.AngledriveData?.Angledrive.Ratio ?? 1.0) / RunData.VehicleData.DynamicTyreRadius; var cardanStartSpeed = (RunData.GearshiftParameters.StartSpeed * transmissionRatio).Cast<PerSecond>(); var minEngineSpeed = (RunData.EngineData.FullLoadCurves[0].RatedSpeed - RunData.EngineData.IdleSpeed) * @@ -315,14 +315,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return DoHandleRequest(absTime, dt, CycleIterator.LeftSample.WheelAngularVelocity); } - public override bool VehicleStopped - { - get - { - return CycleIterator.Previous().LeftSample.VehicleTargetSpeed - .IsEqual(0.KMPHtoMeterPerSecond(), 0.3.KMPHtoMeterPerSecond()); - } - } + public override bool VehicleStopped => + CycleIterator.Previous().LeftSample.VehicleTargetSpeed + .IsEqual(0.KMPHtoMeterPerSecond(), 0.3.KMPHtoMeterPerSecond()); protected override void DoCommitSimulationStep(Second time, Second simulationInterval) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index 6b21ee7b7553413764741235027b7abcbd55ef9a..1d94509c1fe9b6a5f361782cca641afacd26156d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -244,40 +244,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return AirdragData.CrossWindCorrectionCurve.AverageAirDragPowerLoss(v1, v2, ModelData.AirDensity); } - public Meter Distance - { - get { return PreviousState.Distance; } - } + public Meter Distance => PreviousState.Distance; - public MeterPerSecond VehicleSpeed - { - get { return PreviousState.Velocity; } - } + public MeterPerSecond VehicleSpeed => PreviousState.Velocity; - public bool VehicleStopped - { - get { return PreviousState.Velocity.IsEqual(0.SI<MeterPerSecond>(), 0.01.SI<MeterPerSecond>()); } - } + public bool VehicleStopped => PreviousState.Velocity.IsEqual(0.SI<MeterPerSecond>(), 0.01.SI<MeterPerSecond>()); - public Kilogram VehicleMass - { - get { return ModelData.TotalCurbMass; } - } + public Kilogram VehicleMass => ModelData.TotalCurbMass; - public Kilogram VehicleLoading - { - get { return ModelData.Loading; } - } + public Kilogram VehicleLoading => ModelData.Loading; - public Kilogram TotalMass - { - get { return ModelData.TotalVehicleMass; } - } + public Kilogram TotalMass => ModelData.TotalVehicleMass; - public CubicMeter CargoVolume - { - get { return ModelData.CargoVolume; } - } + public CubicMeter CargoVolume => ModelData.CargoVolume; public class VehicleState { @@ -291,15 +270,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public MeterPerSecond Velocity = 0.SI<MeterPerSecond>(); public MeterPerSquareSecond Acceleration = 0.SI<MeterPerSquareSecond>(); - public override string ToString() - { - return - string.Format( - "v: {0} a: {1}, dt: {2}, driver_acc: {3}, roll_res: {4}, slope_res: {5}, air_drag: {6}, traction force: {7}", - Velocity, Acceleration, SimulationInterval, DriverAcceleration, RollingResistance, SlopeResistance, - AirDragResistance, - VehicleTractionForce); - } + public override string ToString() => + $"v: {Velocity} " + + $"a: {Acceleration}, " + + $"dt: {SimulationInterval}, " + + $"driver_acc: {DriverAcceleration}, " + + $"roll_res: {RollingResistance}, " + + $"slope_res: {SlopeResistance}, " + + $"air_drag: {AirDragResistance}, " + + $"traction force: {VehicleTractionForce}"; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs index 56ff12176d4561f0facfaee38baf4a3d26b186e6..cc71009281485d1c85e5196ddd3a5f923d2d72e5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs @@ -127,7 +127,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var angledriveRatio = hasAngleDrive && angledriveData.Type == AngledriveType.SeparateAngledrive ? angledriveData.Angledrive.Ratio : 1.0; - var axlegearRatio = axleGearData != null ? axleGearData.AxleGear.Ratio : 1.0; + var axlegearRatio = axleGearData?.AxleGear.Ratio ?? 1.0; var dynamicTyreRadius = runData.VehicleData != null ? runData.VehicleData.DynamicTyreRadius : 0.0.SI<Meter>(); var vehicleMaxSpeed = GetMaxMotorspeed(runData) / diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs index 9e9b33c285ea43ae32ed9a46b72b4107d2bcfd48..6afaf44cc2d0eb9b8d351fdc9c4eeb73e37b070c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs @@ -93,10 +93,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.P_wheel_inertia] = CurrentState.InertiaTorqueLoss * avgAngularSpeed; } - public Kilogram ReducedMassWheels - { - get { return (_totalWheelsInertia / DynamicTyreRadius / DynamicTyreRadius).Cast<Kilogram>(); } - } + public Kilogram ReducedMassWheels => (_totalWheelsInertia / DynamicTyreRadius / DynamicTyreRadius).Cast<Kilogram>(); public Meter DynamicTyreRadius { get; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs index c5b025e2d16fa32c9beceba242ec5df3f7cd339f..a7f2c150aa4480e3d801ea23c206b9df0f631afc 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs @@ -571,13 +571,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies public virtual IHybridController Controller { protected get; set; } - public PerSecond MinICESpeed - { - get - { - return ModelData.EngineData.IdleSpeed; - } - } + public PerSecond MinICESpeed => ModelData.EngineData.IdleSpeed; public bool AllowEmergencyShift { protected get; set; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs index e4fa2ff709d8b8d2ad2414414e427d65ad341ada..1d1126314a53aee8b65f1a756a0b50b55c8bd8b3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs @@ -114,45 +114,24 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies { #region Implementation of IDrivingCycleInfo - public CycleData CycleData - { - get { return realContainer.DrivingCycleInfo.CycleData; } - } + public CycleData CycleData => realContainer.DrivingCycleInfo.CycleData; - public bool PTOActive - { - get { return realContainer.DrivingCycleInfo.PTOActive; } - } + public bool PTOActive => realContainer.DrivingCycleInfo.PTOActive; public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance) { return realContainer.DrivingCycleInfo.CycleLookAhead(distance); } - public Meter Altitude - { - get { return realContainer.DrivingCycleInfo.Altitude; } - } + public Meter Altitude => realContainer.DrivingCycleInfo.Altitude; - public Radian RoadGradient - { - get { return realContainer.DrivingCycleInfo.RoadGradient; } - } + public Radian RoadGradient => realContainer.DrivingCycleInfo.RoadGradient; - public MeterPerSecond TargetSpeed - { - get { return realContainer.DrivingCycleInfo.TargetSpeed; } - } + public MeterPerSecond TargetSpeed => realContainer.DrivingCycleInfo.TargetSpeed; - public Second StopTime - { - get { return realContainer.DrivingCycleInfo.StopTime; } - } + public Second StopTime => realContainer.DrivingCycleInfo.StopTime; - public Meter CycleStartDistance - { - get { return realContainer?.DrivingCycleInfo?.CycleStartDistance ?? 0.SI<Meter>(); } - } + public Meter CycleStartDistance => realContainer?.DrivingCycleInfo?.CycleStartDistance ?? 0.SI<Meter>(); public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) { @@ -164,10 +143,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies { return realContainer.DrivingCycleInfo.LookAhead(time); } - public SpeedChangeEntry LastTargetspeedChange - { - get { return realContainer.DrivingCycleInfo.LastTargetspeedChange; } - } + public SpeedChangeEntry LastTargetspeedChange => realContainer.DrivingCycleInfo.LastTargetspeedChange; public void FinishSimulation() { @@ -201,20 +177,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies { #region Implementation of IDriverInfo - public DrivingBehavior DriverBehavior - { - get { return realContainer?.DriverInfo?.DriverBehavior ?? DrivingBehavior.Accelerating; } - } + public DrivingBehavior DriverBehavior => realContainer?.DriverInfo?.DriverBehavior ?? DrivingBehavior.Accelerating; - public DrivingAction DrivingAction - { - get { return realContainer?.DriverInfo?.DrivingAction ?? DrivingAction.Accelerate; } - } + public DrivingAction DrivingAction => realContainer?.DriverInfo?.DrivingAction ?? DrivingAction.Accelerate; - public MeterPerSquareSecond DriverAcceleration - { - get { return realContainer?.DriverInfo.DriverAcceleration; } - } + public MeterPerSquareSecond DriverAcceleration => realContainer?.DriverInfo.DriverAcceleration; #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs index 8ae93ba2f338d2a2db10b5ffd5ad95ee9fa4a65d..c8ccebbc00944357222cf2cc9e46db3de100bdce 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs @@ -81,7 +81,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent if (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted && !ClutchOpen) { //return HandleClutchClosed(absTime, dt, outTorque, outAngularVelocity, dryRun); - return base.HandleClutchOpen(absTime, dt, outTorque, outAngularVelocity, dryRun); + return HandleClutchOpen(absTime, dt, outTorque, outAngularVelocity, dryRun); } return base.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); diff --git a/VectoCore/VectoCore/OutputData/FileIO/FileOutputVIFWriter.cs b/VectoCore/VectoCore/OutputData/FileIO/FileOutputVIFWriter.cs index bf397d5ef0299c4595347ebb76ea533c9f8065e5..c42e6bb4b9b9ea2f1f6d91c5e857ae9b06afff92 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/FileOutputVIFWriter.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/FileOutputVIFWriter.cs @@ -14,11 +14,8 @@ namespace TUGraz.VectoCore.OutputData.FileIO private string _jobFile; private readonly int _numberOfManufacturingStages; - public string XMLMultistageReportFileName - { - get { return Path.ChangeExtension(_jobFile, $"{REPORT_ENDING_PREFIX}{_numberOfManufacturingStages + 2}.xml"); } - } - + public string XMLMultistageReportFileName => Path.ChangeExtension(_jobFile, $"{REPORT_ENDING_PREFIX}{_numberOfManufacturingStages + 2}.xml"); + public FileOutputVIFWriter(string jobFile, int numberOfManufacturingStages) : base(jobFile) { _jobFile = jobFile; diff --git a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs index cf36a8dd30ddda62e1a4721f7e504c15806a14d6..3c91014942a2f181346bf3c05c1e0e7d03e91fa6 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs @@ -45,46 +45,22 @@ namespace TUGraz.VectoCore.OutputData.FileIO { private readonly string _jobFile; - public string BasePath - { - get { return Path.GetDirectoryName(_jobFile); } - } + public string BasePath => Path.GetDirectoryName(_jobFile); - public string PDFReportName - { - get { return Path.ChangeExtension(_jobFile, Constants.FileExtensions.PDFReport); } - } + public string PDFReportName => Path.ChangeExtension(_jobFile, Constants.FileExtensions.PDFReport); - public string XMLFullReportName - { - get { return Path.ChangeExtension(_jobFile, "RSLT_MANUFACTURER.xml"); } - } + public string XMLFullReportName => Path.ChangeExtension(_jobFile, "RSLT_MANUFACTURER.xml"); - public string XMLCustomerReportName - { - get { return Path.ChangeExtension(_jobFile, "RSLT_CUSTOMER.xml"); } - } + public string XMLCustomerReportName => Path.ChangeExtension(_jobFile, "RSLT_CUSTOMER.xml"); - public string XMLPrimaryVehicleReportName - { - get { return Path.ChangeExtension(_jobFile, "RSLT_VIF.xml"); } - } + public string XMLPrimaryVehicleReportName => Path.ChangeExtension(_jobFile, "RSLT_VIF.xml"); - public string XMLMonitoringReportName - { - get { return Path.ChangeExtension(_jobFile, "RSLT_MONITORING.xml"); } - } + public string XMLMonitoringReportName => Path.ChangeExtension(_jobFile, "RSLT_MONITORING.xml"); - public string XMLVTPReportName - { - get { return Path.ChangeExtension(_jobFile, "VTP_Report.xml"); } - } + public string XMLVTPReportName => Path.ChangeExtension(_jobFile, "VTP_Report.xml"); + + public string SumFileName => Path.ChangeExtension(_jobFile, Constants.FileExtensions.SumFile); - public string SumFileName - { - get { return Path.ChangeExtension(_jobFile, Constants.FileExtensions.SumFile); } - } - /// <summary> /// /// </summary> @@ -103,9 +79,9 @@ namespace TUGraz.VectoCore.OutputData.FileIO { string modFileName; if (!string.IsNullOrWhiteSpace(cycleName) || !string.IsNullOrWhiteSpace(runSuffix)) { - modFileName = string.Format("{0}_{1}{2}{3}", runName, cycleName, runSuffix, Constants.FileExtensions.ModDataFile); + modFileName = $"{runName}_{cycleName}{runSuffix}{Constants.FileExtensions.ModDataFile}"; } else { - modFileName = string.Format("{0}{1}", runName, Constants.FileExtensions.ModDataFile); + modFileName = $"{runName}{Constants.FileExtensions.ModDataFile}"; } return Path.Combine(BasePath, string.Concat(modFileName.Split(Path.GetInvalidFileNameChars()))); diff --git a/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs b/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs index fd1d5a08bd278b12296223ce53f33c3851c04dc1..f44fe10656b85e6dc6608830b178c688d16d479f 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs @@ -390,7 +390,7 @@ public class JSONFileWriter : IOutputFileWriter { "EcoRoll", vehicle.ADAS.EcoRoll.ToString() }, { "PredictiveCruiseControl", vehicle.ADAS.PredictiveCruiseControl.ToString() }, { "ATEcoRollReleaseLockupClutch", - vehicle.ADAS.ATEcoRollReleaseLockupClutch.HasValue ? vehicle.ADAS.ATEcoRollReleaseLockupClutch.Value : false + vehicle.ADAS.ATEcoRollReleaseLockupClutch ?? false } }; if (airdrag.AirDragArea != null) @@ -654,7 +654,7 @@ public class JSONFileWriter : IOutputFileWriter foreach (var auxEntry in aux.Auxiliaries) { var auxOut = new Dictionary<string, object>(); - var engineeringAuxEntry = auxEntry as IAuxiliaryDeclarationInputData; + var engineeringAuxEntry = auxEntry; if (!job.SavedInDeclarationMode) { auxOut.Add("Type", auxEntry.Type.Name()); auxOut.Add("Technology", new string[] { }); diff --git a/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs b/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs index ad577d95d4c8710d36e4c889b7888c5fee6a9e80..350351d18ff29766c20dfab2494ac22c33d41dbc 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs @@ -69,12 +69,11 @@ namespace TUGraz.VectoCore.OutputData.FileIO sb.AppendLine("engine torque [Nm],downshift rpm [1/min],upshift rpm [1/min]"); foreach (var line in lines.Values) { if (line.DownShift == null) - sb.AppendLine(string.Format("{0},,{1:0.0000}", line.Torque.ToOutputFormat(), line.UpShift.AsRPM)); + sb.AppendLine($"{line.Torque.ToOutputFormat()},,{line.UpShift.AsRPM:0.0000}"); else if (line.UpShift == null) - sb.AppendLine(string.Format("{0},{1:0.0000},", line.Torque.ToOutputFormat(), line.DownShift.AsRPM)); + sb.AppendLine($"{line.Torque.ToOutputFormat()},{line.DownShift.AsRPM:0.0000},"); else - sb.AppendLine(string.Format("{0},{1:0.0000},{2:0.0000}", line.Torque.ToOutputFormat(), line.DownShift.AsRPM, - line.UpShift.AsRPM)); + sb.AppendLine($"{line.Torque.ToOutputFormat()},{line.DownShift.AsRPM:0.0000},{line.UpShift.AsRPM:0.0000}"); } File.WriteAllText(fileName, sb.ToString()); diff --git a/VectoCore/VectoCore/OutputData/ModFilter/ActualModalDataFilter.cs b/VectoCore/VectoCore/OutputData/ModFilter/ActualModalDataFilter.cs index d86cd295bb3c13743e46e849749fda0ecb0f9c7c..a693de730522ca168dac9029d603f49034c6a905 100644 --- a/VectoCore/VectoCore/OutputData/ModFilter/ActualModalDataFilter.cs +++ b/VectoCore/VectoCore/OutputData/ModFilter/ActualModalDataFilter.cs @@ -164,9 +164,6 @@ namespace TUGraz.VectoCore.OutputData.ModFilter } } - public string ID - { - get { return "sim"; } - } + public string ID => "sim"; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/ModFilter/ModalData1HzFilter.cs b/VectoCore/VectoCore/OutputData/ModFilter/ModalData1HzFilter.cs index 7575b637e20910f624a490ceb6b18effa2f92f9e..b1c71cfb34302a32c16e0f299fe64fd409d19599 100644 --- a/VectoCore/VectoCore/OutputData/ModFilter/ModalData1HzFilter.cs +++ b/VectoCore/VectoCore/OutputData/ModFilter/ModalData1HzFilter.cs @@ -184,14 +184,12 @@ namespace TUGraz.VectoCore.OutputData.ModFilter private static IEnumerable<object> MultiplyRow(IEnumerable<object> row, SI dt) { return row.Select(val => { - if (val is SI) { - val = (SI)val * dt.Value(); - } else { - val.Switch() - .Case<int>(i => val = i * dt.Value()) - .Case<double>(d => val = d * dt.Value()) - .Case<float>(f => val = f * dt.Value()) - .Case<uint>(ui => val = ui * dt.Value()); + switch (val) { + case SI si: val = si * dt.Value(); break; + case int i: val = i * dt.Value(); break; + case double d: val = d * dt.Value(); break; + case float f: val = f * dt.Value(); break; + case uint ui: val = ui * dt.Value(); break; } return val; }); @@ -214,19 +212,17 @@ namespace TUGraz.VectoCore.OutputData.ModFilter val = (SI)val + (SI)addVal; } } else { - val.Switch() - .Case<int>(i => val = i + (int)addVal) - .Case<double>(d => val = d + (double)addVal) - .Case<float>(f => val = f + (float)addVal) - .Case<uint>(ui => val = ui + (uint)addVal); + switch (val) { + case int x: val = x + (int)addVal; break; + case double x: val = x + (double)addVal; break; + case float x: val = x + (float)addVal; break; + case uint x: val = x + (uint)addVal; break; + } } return val; }).ToArray(); } - public string ID - { - get { return "1Hz"; } - } + public string ID => "1Hz"; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index a7b1b69a44191e7e3ecf5db37915e3cbaf2199fd..43c458c508f3f0fb7d0178d0d65bdf2b125997d8 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -144,7 +144,7 @@ namespace TUGraz.VectoCore.OutputData var col = new DataColumn( fuels.Count == 1 && !multipleEngineModes ? fcCol.GetName() - : string.Format("{0}_{1}", fcCol.GetName(), entry.FuelType.GetLabel()), typeof(SI)) { + : $"{fcCol.GetName()}_{entry.FuelType.GetLabel()}", typeof(SI)) { Caption = string.Format(fcCol.GetCaption(), fuels.Count == 1 && !multipleEngineModes ? "" : "_" + entry.FuelType.GetLabel()) }; @@ -162,59 +162,36 @@ namespace TUGraz.VectoCore.OutputData } - public int JobRunId - { - get { return _runData.JobRunId; } - } - public string RunName - { - get { return _runData.JobName; } - } - public string CycleName - { - get { return _runData.Cycle?.Name ?? ""; } - } - public string RunSuffix - { - get { return _runData.ModFileSuffix; } - } + public int JobRunId => _runData.JobRunId; + + public string RunName => _runData.JobName; + + public string CycleName => _runData.Cycle?.Name ?? ""; + + public string RunSuffix => _runData.ModFileSuffix; public bool WriteModalResults { get; set; } public VectoRun.Status RunStatus { get; protected set; } - public string Error - { - get { return SimException == null ? null : SimException.Message; } - } + public string Error => SimException?.Message; - public string StackTrace - { - get - { - return SimException == null - ? null - : (SimException.StackTrace ?? (SimException.InnerException != null ? SimException.InnerException.StackTrace : null)); - } - } - + public string StackTrace => + SimException == null + ? null + : (SimException.StackTrace ?? SimException.InnerException?.StackTrace); - public void Reset() + + public void Reset() { Data.Rows.Clear(); CurrentRow = Data.NewRow(); ClearAggregateResults(); } - public Second Duration - { - get { return _duration ?? (_duration = CalcDuration()); } - } + public Second Duration => _duration ?? (_duration = CalcDuration()); - public Meter Distance - { - get { return _distance ?? (_distance = CalcDistance()); } - } + public Meter Distance => _distance ?? (_distance = CalcDistance()); public Func<Second, Joule, Joule> AuxHeaterDemandCalc { get; set; } @@ -224,7 +201,6 @@ namespace TUGraz.VectoCore.OutputData return _engLine[fuel.FuelType]; } - double k, d, r; VectoMath.LeastSquaresFitting( GetValues( x => x.Field<bool>(ModalResultField.ICEOn.GetName()) @@ -232,7 +208,7 @@ namespace TUGraz.VectoCore.OutputData x.Field<SI>(ModalResultField.P_ice_fcmap.GetName()).Value(), x.Field<SI>(GetColumnName(fuel, ModalResultField.FCFinal)).Value()) : null).Where(x => x != null && x.Y > 0), - out k, out d, out r); + out var k, out var d, out var r); if (double.IsInfinity(k) || double.IsNaN(k)) { LogManager.GetLogger(typeof(ModalDataContainer).FullName).Warn("could not calculate engine correction line - k: {0}", k); k = 0; @@ -249,7 +225,6 @@ namespace TUGraz.VectoCore.OutputData } if (Data.AsEnumerable().Any(r => r.Field<SI>(ModalResultField.P_wheel_in.GetName()) != null)) { - double k, d, r; VectoMath.LeastSquaresFitting( GetValues( row => row.Field<bool>(ModalResultField.ICEOn.GetName()) @@ -257,7 +232,7 @@ namespace TUGraz.VectoCore.OutputData row.Field<SI>(ModalResultField.P_wheel_in.GetName()).Value(), row.Field<SI>(GetColumnName(fuel, ModalResultField.FCFinal)).Value()) : null) - .Where(x => x != null && x.X > 0 && x.Y > 0), out k, out d, out r); + .Where(x => x != null && x.X > 0 && x.Y > 0), out var k, out var d, out var r); if (double.IsInfinity(k) || double.IsNaN(k)) { LogManager.GetLogger(typeof(ModalDataContainer).FullName).Warn("could not calculate vehicle correction line - k: {0}", k); k = 0; @@ -269,10 +244,7 @@ namespace TUGraz.VectoCore.OutputData return null; } - public bool HasCombustionEngine - { - get { return _runData.JobType != VectoSimulationJobType.BatteryElectricVehicle; } - } + public bool HasCombustionEngine => _runData.JobType != VectoSimulationJobType.BatteryElectricVehicle; public WattSecond TotalElectricMotorWorkDrive(PowertrainPosition emPos) { @@ -310,7 +282,7 @@ namespace TUGraz.VectoCore.OutputData if (!_eEmRecuperate.ContainsKey(emPos)) { _eEmRecuperate[emPos] = TimeIntegral<WattSecond>( - string.Format(ModalResultField.P_EM_mech_.GetCaption(), emPos.GetName()), x => x > 0); ; + string.Format(ModalResultField.P_EM_mech_.GetCaption(), emPos.GetName()), x => x > 0); } return _eEmRecuperate[emPos]; @@ -325,7 +297,6 @@ namespace TUGraz.VectoCore.OutputData if (!_eEmRecuperateMot.ContainsKey(emPos)) { _eEmRecuperateMot[emPos] = TimeIntegral<WattSecond>( string.Format(ModalResultField.P_EM_electricMotor_em_mech_.GetCaption(), emPos.GetName()), x => x > 0); - ; } return _eEmRecuperateMot[emPos]; @@ -510,10 +481,7 @@ namespace TUGraz.VectoCore.OutputData return TimeIntegral<WattSecond>(ModalResultField.P_reess_loss); } - public ICorrectedModalData CorrectedModalData - { - get { return _correctedModalData ?? (_correctedModalData = PostProcessingCorrection.ApplyCorrection(this, _runData)); } - } + public ICorrectedModalData CorrectedModalData => _correctedModalData ?? (_correctedModalData = PostProcessingCorrection.ApplyCorrection(this, _runData)); public void CalculateAggregateValues() @@ -578,10 +546,7 @@ namespace TUGraz.VectoCore.OutputData } } - public bool HasTorqueConverter - { - get { return _runData.GearboxData?.TorqueConverterData != null; } - } + public bool HasTorqueConverter => _runData.GearboxData?.TorqueConverterData != null; public void CommitSimulationStep() { @@ -626,10 +591,7 @@ namespace TUGraz.VectoCore.OutputData return max == null || min == null ? null : max - min; } - public IList<IFuelProperties> FuelData - { - get { return FuelColumns.Keys.ToList(); } - } + public IList<IFuelProperties> FuelData => FuelColumns.Keys.ToList(); public void Finish(VectoRun.Status runStatus, Exception exception = null) { @@ -853,7 +815,6 @@ namespace TUGraz.VectoCore.OutputData } var retVal = result.SI<T>(); - ; if (filter == null) { _timeIntegrals[field] = retVal; } @@ -867,8 +828,8 @@ namespace TUGraz.VectoCore.OutputData public object this[ModalResultField key] { - get { return CurrentRow[key.GetName()]; } - set { CurrentRow[key.GetName()] = value; } + get => CurrentRow[key.GetName()]; + set => CurrentRow[key.GetName()] = value; } public string GetColumnName(IFuelProperties fuelData, ModalResultField mrf) @@ -904,14 +865,14 @@ namespace TUGraz.VectoCore.OutputData public object this[ModalResultField key, PowertrainPosition pos] { - get { return CurrentRow[string.Format(key.GetCaption(), pos.GetName())]; } - set { CurrentRow[string.Format(key.GetCaption(), pos.GetName())] = value; } + get => CurrentRow[string.Format(key.GetCaption(), pos.GetName())]; + set => CurrentRow[string.Format(key.GetCaption(), pos.GetName())] = value; } public object this[string auxId] { - get { return CurrentRow[Auxiliaries[auxId]]; } - set { CurrentRow[Auxiliaries[auxId]] = value; } + get => CurrentRow[Auxiliaries[auxId]]; + set => CurrentRow[Auxiliaries[auxId]] = value; } [MethodImpl(MethodImplOptions.Synchronized)] diff --git a/VectoCore/VectoCore/OutputData/ModalDataPostprocessingCorrection.cs b/VectoCore/VectoCore/OutputData/ModalDataPostprocessingCorrection.cs index 4c3689044b42ea54e9ddcc1ce79e9ee9e41e33ed..cc2188ed1d2563ecee06d06a91fc23f72a654228 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataPostprocessingCorrection.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataPostprocessingCorrection.cs @@ -172,16 +172,10 @@ namespace TUGraz.VectoCore.OutputData public WattSecond WorkWHREl { get; set; } public WattSecond WorkWHRElMech { get; set; } public WattSecond WorkWHRMech { get; set; } - public WattSecond WorkWHR - { - get { return WorkWHRElMech + WorkWHRMech; } - } + public WattSecond WorkWHR => WorkWHRElMech + WorkWHRMech; public WattSecond WorkBusAuxPSCorr { get; set; } public WattSecond WorkBusAuxESMech { get; set; } - public WattSecond WorkBusAuxCorr - { - get { return WorkBusAuxPSCorr + WorkBusAuxESMech; } - } + public WattSecond WorkBusAuxCorr => WorkBusAuxPSCorr + WorkBusAuxESMech; public Joule AuxHeaterDemand { get; set; } public KilogramPerMeter KilogramCO2PerMeter { get; set; } @@ -215,18 +209,13 @@ namespace TUGraz.VectoCore.OutputData public Second ICEOffTimeStandstill { get; set; } public WattSecond EnergyAuxICEOffStandstill { get; set; } public WattSecond EnergyAuxICEOnStandstill { get; set; } - public Watt AvgAuxPowerICEOnStandstill { - get { return ICEOffTimeStandstill.IsEqual(0) ? 0.SI<Watt>() : EnergyAuxICEOnStandstill / ICEOffTimeStandstill; } - } + public Watt AvgAuxPowerICEOnStandstill => ICEOffTimeStandstill.IsEqual(0) ? 0.SI<Watt>() : EnergyAuxICEOnStandstill / ICEOffTimeStandstill; public Second ICEOffTimeDriving { get; set; } public WattSecond EnergyAuxICEOffDriving { get; set; } public WattSecond EnergyPowerICEOnDriving { get; set; } - public Watt AvgAuxPowerICEOnDriving - { - get { return ICEOffTimeDriving.IsEqual(0) ? 0.SI<Watt>() : EnergyPowerICEOnDriving / ICEOffTimeDriving; } - } + public Watt AvgAuxPowerICEOnDriving => ICEOffTimeDriving.IsEqual(0) ? 0.SI<Watt>() : EnergyPowerICEOnDriving / ICEOffTimeDriving; public WattSecond EnergyDCDCMissing { get; set; } @@ -272,42 +261,30 @@ namespace TUGraz.VectoCore.OutputData public KilogramPerWattSecond EngineLineCorrectionFactor { get; set; } public KilogramPerWattSecond VehicleLine { get; set; } - public KilogramPerSecond FC_ESS_CORR_H { get { return Duration != null ? (FcEssCorr / Duration) : null; } } - public KilogramPerSecond FC_BusAux_PS_CORR_H { get { return Duration != null ? (FcBusAuxPsCorr / Duration) : null; } } - public KilogramPerSecond FC_BusAux_ES_CORR_H { get { return Duration != null ? (FcBusAuxEsCorr / Duration) : null; } } - public KilogramPerSecond FC_WHR_CORR_H { get { return Duration != null ? (FcWHRCorr / Duration) : null; } } - public KilogramPerSecond FC_AUXHTR_H { get { return Duration != null ? (FcAuxHtr / Duration) : null; } } - public KilogramPerSecond FC_AUXHTR_H_CORR { get { return Duration != null ? (FcAuxHtrCorr / Duration) : null; } } - public KilogramPerSecond FC_FINAL_H { get { return Duration != null ? FcFinal / Duration : null; } } - - public KilogramPerMeter FC_ESS_CORR_KM { get { return Distance != null ? (FcEssCorr / Distance) : null; } } - public KilogramPerMeter FC_WHR_CORR_KM { get { return Distance != null ? (FcWHRCorr / Distance) : null; } } - public KilogramPerMeter FC_BusAux_PS_CORR_KM { get { return Distance != null ? (FcBusAuxPsCorr / Distance) : null; } } - public KilogramPerMeter FC_BusAux_ES_CORR_KM { get { return Distance != null ? (FcBusAuxEsCorr / Distance) : null; } } - public KilogramPerMeter FC_AUXHTR_KM { get { return Distance != null ? (FcAuxHtr / Distance) : null; } } - public KilogramPerMeter FC_AUXHTR_KM_CORR { get { return Distance != null ? (FcAuxHtrCorr / Distance) : null; } } - public KilogramPerMeter FC_FINAL_KM { get { return Distance != null ? FcFinal / Distance : null; } } - - public VolumePerMeter FuelVolumePerMeter - { - get - { - return Fuel.FuelDensity != null && Distance != null - ? (FcFinal / Distance / Fuel.FuelDensity).Cast<VolumePerMeter>() - : null; - } - } - - public Kilogram TotalFuelConsumptionCorrected - { - get { return FcFinal; } - } - - public Joule EnergyDemand - { - get { return FcFinal * Fuel.LowerHeatingValueVecto; } - } - + public KilogramPerSecond FC_ESS_CORR_H => Duration != null ? (FcEssCorr / Duration) : null; + public KilogramPerSecond FC_BusAux_PS_CORR_H => Duration != null ? (FcBusAuxPsCorr / Duration) : null; + public KilogramPerSecond FC_BusAux_ES_CORR_H => Duration != null ? (FcBusAuxEsCorr / Duration) : null; + public KilogramPerSecond FC_WHR_CORR_H => Duration != null ? (FcWHRCorr / Duration) : null; + public KilogramPerSecond FC_AUXHTR_H => Duration != null ? (FcAuxHtr / Duration) : null; + public KilogramPerSecond FC_AUXHTR_H_CORR => Duration != null ? (FcAuxHtrCorr / Duration) : null; + public KilogramPerSecond FC_FINAL_H => Duration != null ? FcFinal / Duration : null; + + public KilogramPerMeter FC_ESS_CORR_KM => Distance != null ? (FcEssCorr / Distance) : null; + public KilogramPerMeter FC_WHR_CORR_KM => Distance != null ? (FcWHRCorr / Distance) : null; + public KilogramPerMeter FC_BusAux_PS_CORR_KM => Distance != null ? (FcBusAuxPsCorr / Distance) : null; + public KilogramPerMeter FC_BusAux_ES_CORR_KM => Distance != null ? (FcBusAuxEsCorr / Distance) : null; + public KilogramPerMeter FC_AUXHTR_KM => Distance != null ? (FcAuxHtr / Distance) : null; + public KilogramPerMeter FC_AUXHTR_KM_CORR => Distance != null ? (FcAuxHtrCorr / Distance) : null; + public KilogramPerMeter FC_FINAL_KM => Distance != null ? FcFinal / Distance : null; + + public VolumePerMeter FuelVolumePerMeter => + Fuel.FuelDensity != null && Distance != null + ? (FcFinal / Distance / Fuel.FuelDensity).Cast<VolumePerMeter>() + : null; + + public Kilogram TotalFuelConsumptionCorrected => FcFinal; + + public Joule EnergyDemand => FcFinal * Fuel.LowerHeatingValueVecto; #endregion } diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs index 8f96e87f1b2c4c3d381baa7491721cd3277376b2..47015a0310780ee39655a21a286272944fc4f97a 100644 --- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs @@ -286,7 +286,7 @@ namespace TUGraz.VectoCore.OutputData var row = GetResultRow(modData, runData); row[Fields.SORT] = jobNr * 1000 + runNr; - row[Fields.JOB] = string.Format("{0}-{1}", jobNr, runNr); //ReplaceNotAllowedCharacters(current); + row[Fields.JOB] = $"{jobNr}-{runNr}"; //ReplaceNotAllowedCharacters(current); row[Fields.INPUTFILE] = ReplaceNotAllowedCharacters(runData.JobName); row[Fields.CYCLE] = ReplaceNotAllowedCharacters(runData.Cycle.Name + Constants.FileExtensions.CycleFile); @@ -922,9 +922,9 @@ namespace TUGraz.VectoCore.OutputData ? "" : data.CertificationNumber; } else { - row[Fields.ANGLEDRIVE_MANUFACTURER] = Constants.NOT_AVailABLE; - row[Fields.ANGLEDRIVE_MODEL] = Constants.NOT_AVailABLE; - row[Fields.ANGLEDRIVE_RATIO] = Constants.NOT_AVailABLE; + row[Fields.ANGLEDRIVE_MANUFACTURER] = Constants.NOT_AVAILABLE; + row[Fields.ANGLEDRIVE_MODEL] = Constants.NOT_AVAILABLE; + row[Fields.ANGLEDRIVE_RATIO] = Constants.NOT_AVAILABLE; row[Fields.ANGLEDRIVE_CERTIFICATION_METHOD] = ""; row[Fields.ANGLEDRIVE_CERTIFICATION_NUMBER] = ""; } @@ -941,8 +941,8 @@ namespace TUGraz.VectoCore.OutputData ? "" : data.CertificationNumber; } else { - row[Fields.RETARDER_MANUFACTURER] = Constants.NOT_AVailABLE; - row[Fields.RETARDER_MODEL] = Constants.NOT_AVailABLE; + row[Fields.RETARDER_MANUFACTURER] = Constants.NOT_AVAILABLE; + row[Fields.RETARDER_MODEL] = Constants.NOT_AVAILABLE; row[Fields.RETARDER_CERTIFICATION_METHOD] = ""; row[Fields.RETARDER_CERTIFICATION_NUMBER] = ""; } @@ -983,8 +983,8 @@ namespace TUGraz.VectoCore.OutputData row[Fields.GEAR_RATIO_LAST_GEAR] = data.Gears.Count > 0 ? (ConvertedSI)data.Gears.Last().Value.Ratio.SI<Scalar>() : (ConvertedSI)0.SI<Scalar>(); - row[Fields.TORQUECONVERTER_MANUFACTURER] = Constants.NOT_AVailABLE; - row[Fields.TORQUECONVERTER_MODEL] = Constants.NOT_AVailABLE; + row[Fields.TORQUECONVERTER_MANUFACTURER] = Constants.NOT_AVAILABLE; + row[Fields.TORQUECONVERTER_MODEL] = Constants.NOT_AVAILABLE; row[Fields.TORQUE_CONVERTER_CERTIFICATION_METHOD] = ""; row[Fields.TORQUE_CONVERTER_CERTIFICATION_NUMBER] = ""; } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs index 5cb19313b4e8233fd8f9d162bf6bf4aa8e9c5b36..fe28253da5cb0804ecdf0e6e294f4e4247a3cad1 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs @@ -273,7 +273,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation new XAttribute(XNamespace.Xmlns + "tns", rootNS), new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}DEV/VectoOutputCustomer.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{rootNS} {AbstractXMLWriter.SchemaLocationBaseUrl}DEV/VectoOutputCustomer.xsd"), new XElement(rootNS + XMLNames.Report_DataWrap, new XAttribute(xsi + "type", "VectoOutputDataType"), vehicle, diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs index 03cdba3f6baeb0a63481d218965ae4e1c6ab8a63..d89169d70ebc1b3f259e565a2d302b42d82f45bb 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs @@ -23,7 +23,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleRecordFile { get; set; } - public IVehicleDeclarationInputData PrimaryVehicle { get { return PrimaryVehicleRecordFile.Vehicle; } } + public IVehicleDeclarationInputData PrimaryVehicle => PrimaryVehicleRecordFile.Vehicle; public override void Initialize(VectoRunData modelData, List<List<FuelData.Entry>> fuelModes) { @@ -101,7 +101,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation content = new object[] { new XElement( tns + XMLNames.Report_Results_Error, - string.Format("Simulation not finished! Status: {0} / {1}", genericResult.Status, specificResult.Status)), + $"Simulation not finished! Status: {genericResult.Status} / {specificResult.Status}"), new XElement(tns + XMLNames.Report_Results_ErrorDetails, ""), }; // should not happen! } @@ -284,7 +284,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation new XAttribute(XNamespace.Xmlns + "tns", rootNS), new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}DEV/VectoOutputCustomer.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{rootNS} {AbstractXMLWriter.SchemaLocationBaseUrl}DEV/VectoOutputCustomer.xsd"), new XElement(rootNS + XMLNames.Report_DataWrap, new XAttribute(xsi + "type", "VectoOutputDataType"), vehicle, diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/AbstractXMLManufacturerReport.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/AbstractXMLManufacturerReport.cs index 7663933f52c73121d047fffb3717456d59108425..4d5f123ef363ab9f8c7ee63f73d7619f18f4b060 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/AbstractXMLManufacturerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/AbstractXMLManufacturerReport.cs @@ -68,7 +68,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport new XAttribute(XNamespace.Xmlns + "mrf", mrf), new XAttribute( xsi + "schemaLocation", - string.Format("{0} {1}/DEV/VectoOutputManufacturer.xsd", mrf, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{mrf} {AbstractXMLWriter.SchemaLocationBaseUrl}/DEV/VectoOutputManufacturer.xsd"), new XElement( mrf + XMLNames.Report_DataWrap, new XAttribute(xsi + "type", "tns:VectoOutputDataType"), @@ -119,7 +119,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport GetSimulationParameters(resultEntry), new XElement( tns + XMLNames.Report_Results_Error, - string.Format("Simulation not finished! Status: {0}", resultEntry.Status)), + $"Simulation not finished! Status: {resultEntry.Status}"), new XElement(tns + XMLNames.Report_Results_ErrorDetails, ""), }; // should not happen! break; @@ -252,7 +252,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport return new XElement( tns + XMLNames.Vehicle_ADAS, new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", adasPrefix, type)), + new XAttribute(xsi + "type", $"{adasPrefix}:{type}"), XElement.Parse(adasData.InputData.XMLSource.OuterXml).Elements() ); } @@ -266,7 +266,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport return new XElement( tns + XMLNames.Vehicle_ADAS, new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", adasPrefix, type)), + new XAttribute(xsi + "type", $"{adasPrefix}:{type}"), new XElement(ns + XMLNames.Vehicle_ADAS_EngineStopStart, adasData.EngineStopStart), new XElement(ns + XMLNames.Vehicle_ADAS_EcoRollWithoutEngineStop, adasData.EcoRoll.WithoutEngineStop()), new XElement(ns + XMLNames.Vehicle_ADAS_EcoRollWithEngineStopStart, adasData.EcoRoll.WithEngineStop()), diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs index c78dfaa57078d78ddcb10be116c26b265d85b492..e40e0042823c8750da10fb293d9b1e391ca8d070 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs @@ -20,9 +20,8 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleRecordFile { get; set; } - public IVehicleDeclarationInputData PrimaryVehicle { get { return PrimaryVehicleRecordFile.Vehicle; } } + public IVehicleDeclarationInputData PrimaryVehicle => PrimaryVehicleRecordFile.Vehicle; - #region Overrides of AbstractXMLManufacturerReport @@ -99,7 +98,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport content = new object[] { new XElement( tns + XMLNames.Report_Results_Error, - string.Format("Simulation not finished! Status: {0} / {1}", genericResult.Status, specificResult.Status)), + $"Simulation not finished! Status: {genericResult.Status} / {specificResult.Status}"), new XElement(tns + XMLNames.Report_Results_ErrorDetails, ""), }; // should not happen! } @@ -388,7 +387,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport return new XElement( tns + XMLNames.Component_Auxiliaries, new XAttribute(XNamespace.Xmlns + auxPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", auxPrefix, busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name)), + new XAttribute(xsi + "type", $"{auxPrefix}:{busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(busAuxXML.InnerXml).Elements() ); } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportPrimaryBus.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportPrimaryBus.cs index 3b8604cb9a67c21b1ab5831b6223a1ba366b55e0..d3011bc2e24c6ec332db6655ccb50769df229bce 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportPrimaryBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportPrimaryBus.cs @@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.OutputData.XML { return new XElement( tns + XMLNames.Component_Auxiliaries, new XAttribute(XNamespace.Xmlns + auxPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", auxPrefix, busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name)), + new XAttribute(xsi + "type", $"{auxPrefix}:{busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(busAuxXML.InnerXml).Elements() ); } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportTruck.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportTruck.cs index e65b7972036240c0cb70f326d8f2520c4e9ac991..610ba2f20e1d985d1f16c423f2c1b00f45bbc226 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportTruck.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportTruck.cs @@ -129,7 +129,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport private string GetTagName(AuxiliaryType auxId) { - return auxId.ToString() + "Technology"; + return auxId + "Technology"; } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VTPReport/XMLVTPReport.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VTPReport/XMLVTPReport.cs index c22ac6e1e0ba1ee2ed04b49be6548181ab8fac6c..e7b4282468cb9892f184adebf57285fb88071dbf 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VTPReport/XMLVTPReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VTPReport/XMLVTPReport.cs @@ -293,7 +293,7 @@ namespace TUGraz.VectoCore.OutputData.XML tns + "CO2", new XElement( tns + "Mission", - string.Format("{0}, {1}", selectedMission.ToXMLFormat(), selectedLoading.ToString()) + $"{selectedMission.ToXMLFormat()}, {selectedLoading.ToString()}" ), new XElement( tns + "Declared", new XAttribute(XMLNames.Report_Results_Unit_Attr, key), @@ -328,7 +328,7 @@ namespace TUGraz.VectoCore.OutputData.XML //new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute( xsi + "schemaLocation", - string.Format("{0} {1}VTPReport.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{rootNS} {AbstractXMLWriter.SchemaLocationBaseUrl}VTPReport.xsd"), new XElement( rootNS + "Data", new XAttribute(xsi + "type", "VTPReportDataType"), @@ -442,7 +442,7 @@ namespace TUGraz.VectoCore.OutputData.XML bool status; var componentName = count == 1 ? VectoComponentsExtensionMethods.XMLElementName(component) - : string.Format("{0} ({1})", VectoComponentsExtensionMethods.XMLElementName(component), i + 1); + : $"{VectoComponentsExtensionMethods.XMLElementName(component)} ({i + 1})"; XElement retVal; try { var recomputed = InputDataHash.ComputeHash(component, i); @@ -700,7 +700,7 @@ namespace TUGraz.VectoCore.OutputData.XML private string GetTagName(AuxiliaryType auxId) { - return auxId.ToString() + "Technology"; + return auxId + "Technology"; } private object[] GetCommonDescription(CombustionEngineData data) diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/XMLPrimaryBusVehicleReport.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/XMLPrimaryBusVehicleReport.cs index 378038f5ebc7d5cf1206ebcfe94cf4e55527b007..c1ef7d963b6f655d2ad4d1d793569a754ec48fcd 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/XMLPrimaryBusVehicleReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/XMLPrimaryBusVehicleReport.cs @@ -162,7 +162,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), new XAttribute( xsi + "type", - string.Format("{0}:{1}", adasPrefix, adasData.InputData.XMLSource.SchemaInfo.SchemaType.QualifiedName.Name)), + $"{adasPrefix}:{adasData.InputData.XMLSource.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(adasData.InputData.XMLSource.OuterXml).Elements() ); } @@ -181,7 +181,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF tns + XMLNames.Vehicle_TorqueLimits, new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), new XAttribute( - xsi + "type", string.Format("{0}:{1}", adasPrefix, tcLimits.SchemaInfo.SchemaType.QualifiedName.Name)), + xsi + "type", $"{adasPrefix}:{tcLimits.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(tcLimits.OuterXml).Elements() ); } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs index 2bfc8b02888a584adcd3d963ba7604cf47fc703e..a352fea41f1a211e1873e03516e48d96777e24f9 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs @@ -112,8 +112,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Factory var bindings = Kernel.GetBindings(writerType).ToArray(); if (bindings.Any()) { var mostRecent = bindings.MaxBy(b => { - double retVal; - var success = double.TryParse(b.Metadata.Name, NumberStyles.Float, CultureInfo.InvariantCulture, out retVal); + var success = double.TryParse(b.Metadata.Name, NumberStyles.Float, CultureInfo.InvariantCulture, out var retVal); return success ? retVal : -1; }).Metadata.Name; return GetEngineeringWriter(inputDataType, mostRecent, writerType, xmlEngineeringWriter); diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs index d6b1ec151d21f23e34a7bcdbb0e2d5f6d670be65..0edfa0a73b0bbabf8b4fd39718531bd29b0fd22a 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs @@ -165,7 +165,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer { var xsns = Writer.RegisterNamespace(XMLDefinitions.XML_SCHEMA_NAMESPACE); return new XAttribute( - xsns + "type", string.Format("{0}:{1}", Writer.GetNSPrefix(ComponentDataNamespace.NamespaceName), XMLDataType)); + xsns + "type", $"{Writer.GetNSPrefix(ComponentDataNamespace.NamespaceName)}:{XMLDataType}"); } public virtual object[] WriteXML(IAdvancedDriverAssistantSystemsEngineering inputData) diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLAccelerationDataWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLAccelerationDataWriter.cs index 31028be6babea6abc41a2868af7bc93714154352..e4e6959c70fd7116d1053d499e7c67d3f93b0b6e 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLAccelerationDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLAccelerationDataWriter.cs @@ -50,10 +50,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer.DriverData #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringLookaheadDataWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringLookaheadDataWriter.cs index 22718baea32212f249aeea3d0085992ff424ff37..0e3e2a58c5f10740cd965fffc77481210494ab1b 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringLookaheadDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringLookaheadDataWriter.cs @@ -95,10 +95,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer.DriverData } - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringOverspeedDataWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringOverspeedDataWriter.cs index 0456fd7b20fb972fce0d2ab20bd96319e7f463ae..c4f8c6680aec44252a0f2c3e2f616ebdaf27cd89 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringOverspeedDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLEngineeringOverspeedDataWriter.cs @@ -72,10 +72,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer.DriverData #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLShiftParmeterDataWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLShiftParmeterDataWriter.cs index c30a3a96e1865d03af3f661a4e3590f26d405cfd..73c8ecd429d076a55d48f800aa7b425082729d5f 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLShiftParmeterDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/DriverData/XMLShiftParmeterDataWriter.cs @@ -46,10 +46,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer.DriverData #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringADASWriterV10.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringADASWriterV10.cs index 736dc6835e053488edac89779c3af7cc5006a00a..c6a554a44822e3477112a4edc249052ee11f369a 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringADASWriterV10.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringADASWriterV10.cs @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer { public override object[] WriteXML(IAdvancedDriverAssistantSystemsEngineering inputData) { - var adas = inputData as IAdvancedDriverAssistantSystemsEngineering; + var adas = inputData; if (adas == null) { return null; } @@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer { #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace { get { return Writer.RegisterNamespace(NAMESPACE_URI); } } + public override XNamespace ComponentDataNamespace => Writer.RegisterNamespace(NAMESPACE_URI); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs index 20271e5f5199ad9adc900e6d0fd94d8ef00105e0..3857558bdac267daa3b7652a9d3930c7e943e04a 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs @@ -51,10 +51,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion @@ -63,7 +60,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer protected override object[] DoWriteXML(IAirdragEngineeringInputData data) { var tns = ComponentDataNamespace; - var id = string.Format("Airdrag-{0}", data.Model); + var id = $"Airdrag-{data.Model}"; return new object[] { new XAttribute(XMLNames.Component_ID_Attr, id), GetXMLTypeAttribute(), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs index 633441cb834cd700b2492531efedacc95690d373..f620cb4df36e6e907195a238f87ccc370ab2771f 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs @@ -51,10 +51,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion @@ -63,7 +60,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer protected override object[] DoWriteXML(IAngledriveInputData data) { var tns = ComponentDataNamespace; - var typeId = string.Format("ANGLDRV-{0:0.000}", data.Ratio); + var typeId = $"ANGLDRV-{data.Ratio:0.000}"; return new object[] { GetXMLTypeAttribute(), new XAttribute(XMLNames.Component_ID_Attr, typeId), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliariesWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliariesWriter.cs index 3f90887cf5035f22b1388aa6de994aefbaeb22ce..459abf52236d76cd081875440337c37c182db417 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliariesWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliariesWriter.cs @@ -43,10 +43,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer { #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliaryWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliaryWriter.cs index c3079bfb51b7a8246445a2e0e66e5fa042a8314c..d34ea8cc5bb276f4e311c3a0fe84318f0433b634 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliaryWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAuxiliaryWriter.cs @@ -43,10 +43,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer { #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxleWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxleWriter.cs index ed4773fba25709dea1ed976175cc4a3f1f668c76..b107c34f56c22e2ac34c4f82ac27b26aa5f499b2 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxleWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxleWriter.cs @@ -54,10 +54,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #region Overrides of AbstractXMLWriter @@ -107,10 +104,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer { public new const string NAMESPACE_URI = XMLDefinitions.ENGINEERING_DEFINITONS_NAMESPACE_V10_TEST; - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); public override object[] WriteXML(IAxleEngineeringInputData axle, int idx, Meter dynamicTyreRadius) { diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs index 854972858453f0591d045f8ec1f2ca71ad38aa36..9f702fd8c556fda0498c8c97224c6f3906d395cc 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs @@ -51,10 +51,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion @@ -63,7 +60,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer protected override object[] DoWriteXML(IAxleGearInputData data) { var tns = ComponentDataNamespace; - var typeId = string.Format("AXLGEAR-{0:0.000}", data.Ratio); + var typeId = $"AXLGEAR-{data.Ratio:0.000}"; return new object[] { GetXMLTypeAttribute(), new XAttribute(XMLNames.Component_ID_Attr, typeId), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlesWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlesWriter.cs index 584723774ba32aaabdca347a09d3b391ebdab9bc..2343549cb82e8d1ef8449145d727023a60ab7968 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlesWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlesWriter.cs @@ -84,10 +84,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #endregion - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringComponentsWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringComponentsWriter.cs index ad83f82f4e95e56cb41f260e3635ac98c2b0df83..6d8a5e395945691d55fab4afd180f63808f3f1e3 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringComponentsWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringComponentsWriter.cs @@ -143,10 +143,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringDriverDataWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringDriverDataWriter.cs index cdb41a3f59e3e9f25c0cb3bad8a8475ffc253ec2..7068d5276970f0099fc66e5bc08b805bd1a324f7 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringDriverDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringDriverDataWriter.cs @@ -88,10 +88,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs index 030415319b6036e2c9b81ef513d985a0eeacac03..f1dfa6e7bb660b3c1b65362cf9c130124233fbda 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer } var filename = Path.Combine( - Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters(string.Format("ENG_{0}.vfld", data.Model))); + Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters($"ENG_{data.Model}.vfld")); return ExtCSVResource(data.EngineModes.First().FullLoadCurve, filename); } @@ -89,16 +89,13 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer } var filename = Path.Combine( - Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters(string.Format("ENG_{0}.vmap", data.Model))); + Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters($"ENG_{data.Model}.vmap")); return ExtCSVResource(data.EngineModes.First().Fuels.First().FuelConsumptionMap, filename); } #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentNamespace ?? (_componentNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentNamespace ?? (_componentNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } @@ -126,9 +123,6 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer }; } - public override XNamespace ComponentDataNamespace - { - get { return _componentNamespace ?? (_componentNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentNamespace ?? (_componentNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearDataWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearDataWriter.cs index 517c4cc82f00f332111aa1c650970f9d50f06eaa..186fe95ae1b23915dbf5dcc8922e6b6f518e8c82 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearDataWriter.cs @@ -49,10 +49,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs index 1a3d1f815953401729b9c3d681411103113558c4..c18c1cf15f778a25597a6c96f94378c9c02145f0 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer return new object[] { GetXMLTypeAttribute(), - new XAttribute(XMLNames.Component_ID_Attr, string.Format("GBX-{0}", data.Model)), + new XAttribute(XMLNames.Component_ID_Attr, $"GBX-{data.Model}"), GetDefaultComponentElements(data), new XElement(tns + XMLNames.Gearbox_TransmissionType, data.Type.ToXMLFormat()), @@ -83,10 +83,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentNamespace ?? (_componentNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentNamespace ?? (_componentNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringJobWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringJobWriter.cs index a3e54bdef7477b707f01d4548f7d217399fb8a36..f7e9b0d2c980ae78745a95a35b0bf2ef5951fa8c 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringJobWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringJobWriter.cs @@ -149,10 +149,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs index 31b2a6324c69b619373e239eebdb48abbc3aec9e..0193ad06a5058d3a2da3a874702b3511c0304684 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs @@ -49,10 +49,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion @@ -73,7 +70,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer data.LossMap, Path.Combine( Writer.Configuration.BasePath, - Writer.RemoveInvalidFileCharacters(string.Format("RET_{0}.vrlm", data.Model))))) + Writer.RemoveInvalidFileCharacters($"RET_{data.Model}.vrlm")))) }; return retarder; } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs index 9be6472c3998ac74cc7fcfe219a013b0f434f031..471d6934a6f7b883964b201cc5a9cd743fe0ca49 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs @@ -53,10 +53,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion @@ -67,7 +64,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer var tns = ComponentDataNamespace; return new object[] { GetXMLTypeAttribute(), - new XAttribute(XMLNames.Component_ID_Attr, string.Format("TC-{0}", data.Model)), + new XAttribute(XMLNames.Component_ID_Attr, $"TC-{data.Model}"), GetDefaultComponentElements(data), new XElement(tns + XMLNames.TorqueConverter_ReferenceRPM, data.ReferenceRPM.AsRPM.ToXMLFormat()), new XElement( diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTyreWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTyreWriter.cs index b4341b8c4fb3fe51d24a5548fded17658ea70069..73e5602fb4790b6217c4d086fffc5c617e4bf954 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTyreWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTyreWriter.cs @@ -49,10 +49,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringVehicleDataWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringVehicleDataWriter.cs index a25091712c7d25ac904b798a4749838720ce9e33..3541e0bc24e1310452d0b402bc69b24ffe46ef96 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringVehicleDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringVehicleDataWriter.cs @@ -56,10 +56,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer #region Overrides of AbstractXMLWriter - public override XNamespace ComponentDataNamespace - { - get { return _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); } - } + public override XNamespace ComponentDataNamespace => _componentDataNamespace ?? (_componentDataNamespace = Writer.RegisterNamespace(NAMESPACE_URI)); #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs index 035b6af287c6e4ef17da2c821dd40047d7fccef6..2b64351e407fc565ac06a73d990135fb5cf01e59 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering new XElement( v10Inp + XMLNames.VectoComponentEngineering, new XAttribute( - xsns + "type", string.Format("{0}:VectoComponentEngineeringType", GetNSPrefix(v10Def.NamespaceName))), + xsns + "type", $"{GetNSPrefix(v10Def.NamespaceName)}:VectoComponentEngineeringType"), GetNamespaceAttributes(), GetSchemaLocations(), new XElement( @@ -190,17 +190,14 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering public string GetComponentFilename(IComponentInputData component) { - string formatString = null; - component.Switch() - .Case<IEngineEngineeringInputData>(c => formatString = "ENG_{0}.xml"); - - return RemoveInvalidFileCharacters(string.Format(formatString ?? "{0}", component.Model)); + var formatString = component is IEngineEngineeringInputData ? "ENG_{0}.xml" : "{0}"; + return RemoveInvalidFileCharacters(string.Format(formatString, component.Model)); } public string RemoveInvalidFileCharacters(string filename) { - string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); - Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); + var regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); + var r = new Regex($"[{Regex.Escape(regexSearch)}]"); return r.Replace(filename, ""); } } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs index 5cc169a643ce6acb7c6808e221e0d0a942e76e74..46bec9b30a77f889c26d81e3bee348be4405cd4f 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs @@ -183,20 +183,11 @@ namespace TUGraz.VectoCore.OutputData.XML - public virtual XDocument FullReport - { - get { return ManufacturerRpt.Report; } - } + public virtual XDocument FullReport => ManufacturerRpt.Report; - public virtual XDocument CustomerReport - { - get { return CustomerRpt.Report; } - } + public virtual XDocument CustomerReport => CustomerRpt.Report; - public virtual XDocument PrimaryVehicleReport - { - get { return null; } - } + public virtual XDocument PrimaryVehicleReport => null; protected override void DoStoreResult(ResultEntry entry, VectoRunData runData, IModalDataContainer modData) @@ -264,38 +255,34 @@ namespace TUGraz.VectoCore.OutputData.XML CustomerRpt = new XMLCustomerReport(); } - private static IDictionary<Tuple<MissionType, LoadingType>, double> ZeroWeighting - { - get { - return new ReadOnlyDictionary<Tuple<MissionType, LoadingType>, double>( - new Dictionary<Tuple<MissionType, LoadingType>, double>() { - { Tuple.Create(MissionType.LongHaul, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.LongHaul, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.RegionalDelivery, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.RegionalDelivery, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.UrbanDelivery, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.UrbanDelivery, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.LongHaulEMS, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.LongHaulEMS, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.MunicipalUtility, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.MunicipalUtility, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.Construction, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.Construction, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.HeavyUrban, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.HeavyUrban, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.Urban, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.Urban, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.Suburban, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.Suburban, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.Interurban, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.Interurban, LoadingType.ReferenceLoad), 0 }, - { Tuple.Create(MissionType.Coach, LoadingType.LowLoading), 0 }, - { Tuple.Create(MissionType.Coach, LoadingType.ReferenceLoad), 0 }, - }); - } - } + private static IDictionary<Tuple<MissionType, LoadingType>, double> ZeroWeighting => + new ReadOnlyDictionary<Tuple<MissionType, LoadingType>, double>( + new Dictionary<Tuple<MissionType, LoadingType>, double>() { + { Tuple.Create(MissionType.LongHaul, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.LongHaul, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.RegionalDelivery, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.RegionalDelivery, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.UrbanDelivery, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.UrbanDelivery, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.LongHaulEMS, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.LongHaulEMS, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.MunicipalUtility, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.MunicipalUtility, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.Construction, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.Construction, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.HeavyUrban, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.HeavyUrban, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.Urban, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.Urban, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.Suburban, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.Suburban, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.Interurban, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.Interurban, LoadingType.ReferenceLoad), 0 }, + { Tuple.Create(MissionType.Coach, LoadingType.LowLoading), 0 }, + { Tuple.Create(MissionType.Coach, LoadingType.ReferenceLoad), 0 }, + }); public static IEnumerable<XElement> GetResults(ResultEntry result, XNamespace tns, bool fullOutput) diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs index 6770518897d72a75a81aa545df7a07cadadf6b6c..18d8a1e85ecdd895948090b3846024ae1743645a 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs @@ -48,39 +48,34 @@ namespace TUGraz.VectoCore.OutputData.XML { } #endregion - private static IDictionary<Tuple<MissionType, LoadingType>, double> EqualWeighting - { - get - { - return new ReadOnlyDictionary<Tuple<MissionType, LoadingType>, double>( - new Dictionary<Tuple<MissionType, LoadingType>, double>() { - { Tuple.Create(MissionType.LongHaul, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.LongHaul, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.RegionalDelivery, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.RegionalDelivery, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.UrbanDelivery, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.UrbanDelivery, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.LongHaulEMS, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.LongHaulEMS, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.MunicipalUtility, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.MunicipalUtility, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.Construction, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.Construction, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.HeavyUrban, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.HeavyUrban, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.Urban, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.Urban, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.Suburban, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.Suburban, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.Interurban, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.Interurban, LoadingType.ReferenceLoad), 1 }, - { Tuple.Create(MissionType.Coach, LoadingType.LowLoading), 1 }, - { Tuple.Create(MissionType.Coach, LoadingType.ReferenceLoad), 1 }, - }); - } - } + private static IDictionary<Tuple<MissionType, LoadingType>, double> EqualWeighting => + new ReadOnlyDictionary<Tuple<MissionType, LoadingType>, double>( + new Dictionary<Tuple<MissionType, LoadingType>, double>() { + { Tuple.Create(MissionType.LongHaul, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.LongHaul, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.RegionalDelivery, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.RegionalDelivery, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.UrbanDelivery, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.UrbanDelivery, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.LongHaulEMS, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.LongHaulEMS, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.RegionalDeliveryEMS, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.MunicipalUtility, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.MunicipalUtility, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.Construction, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.Construction, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.HeavyUrban, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.HeavyUrban, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.Urban, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.Urban, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.Suburban, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.Suburban, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.Interurban, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.Interurban, LoadingType.ReferenceLoad), 1 }, + { Tuple.Create(MissionType.Coach, LoadingType.LowLoading), 1 }, + { Tuple.Create(MissionType.Coach, LoadingType.ReferenceLoad), 1 }, + }); protected internal override void DoWriteReport() { diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportMultistageBusVehicle.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportMultistageBusVehicle.cs index c7ae96cc8f86c22ce86b343019ebc3f44bd5d2be..c2ba05703732a8c25a4d0f5e6a8123828388ab17 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportMultistageBusVehicle.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportMultistageBusVehicle.cs @@ -36,11 +36,11 @@ namespace TUGraz.VectoCore.OutputData.XML Writer.WriteReport(ReportType.DeclarationReportMultistageVehicleXML, _multistageBusReport.Report); } - protected override void DoStoreResult(XMLDeclarationReport.ResultEntry entry, VectoRunData runData, IModalDataContainer modData) + protected override void DoStoreResult(ResultEntry entry, VectoRunData runData, IModalDataContainer modData) { throw new NotSupportedException(); } - protected override void WriteResult(XMLDeclarationReport.ResultEntry result) + protected override void WriteResult(ResultEntry result) { throw new NotSupportedException(); } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportPrimaryVehicle.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportPrimaryVehicle.cs index 276ef4230de386f53001e20d07498e2b1712604a..36bdb48f59d0c32501569a67a651132268576c30 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportPrimaryVehicle.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportPrimaryVehicle.cs @@ -17,17 +17,11 @@ namespace TUGraz.VectoCore.OutputData.XML { { } - public override XDocument CustomerReport - { - get { return null; } - } + public override XDocument CustomerReport => null; + + public override XDocument PrimaryVehicleReport => PrimaryReport?.Report; - public override XDocument PrimaryVehicleReport - { - get { return PrimaryReport?.Report; } - } - #region Overrides of XMLDeclarationReport protected override void InstantiateReports(VectoRunData modelData) diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs index 61f482c9d31cc96e2a2feb0aec955eb7039a4b72..2534c73a24fdbd79d71af22d2b0c236507ced5a1 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs @@ -75,7 +75,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute("xmlns", tns), new XAttribute(XNamespace.Xmlns + "tns", rootNamespace), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}VectoInput.xsd", rootNamespace, SchemaLocationBaseUrl)), + $"{rootNamespace} {SchemaLocationBaseUrl}VectoInput.xsd"), CreateDeclarationJob(data)) ); return job; @@ -102,7 +102,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute("xmlns", tns), new XAttribute(XNamespace.Xmlns + "tns", componentNamespace), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}VectoComponent.xsd", componentNamespace, SchemaLocationBaseUrl)), + $"{componentNamespace} {SchemaLocationBaseUrl}VectoComponent.xsd"), content) ); return component; @@ -128,7 +128,7 @@ namespace TUGraz.VectoCore.OutputData.XML return new XElement(tns + XMLNames.Component_Vehicle, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(vehicle.CertificationNumber, vehicle.Model, Constants.NOT_AVailABLE), + GetDefaultComponentElements(vehicle.CertificationNumber, vehicle.Model, Constants.NOT_AVAILABLE), new XElement(tns + XMLNames.Vehicle_LegislativeClass, "N3"), new XElement(tns + XMLNames.Vehicle_VehicleCategory, vehicle.VehicleCategory.ToXMLFormat()), new XElement(tns + XMLNames.Vehicle_AxleConfiguration, vehicle.AxleConfiguration.GetName()), @@ -171,13 +171,13 @@ namespace TUGraz.VectoCore.OutputData.XML protected XElement CreateEngine(IEngineDeclarationInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("ENG-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"ENG-{data.Model.RemoveWhitespace()}"); var fld = FullLoadCurveReader.Create(data.EngineModes.First().FullLoadCurve, true); return new XElement((ns ?? tns) + XMLNames.Component_Engine, new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(string.Format("ENG-{0}", data.Model), data.Model), + GetDefaultComponentElements($"ENG-{data.Model}", data.Model), new XElement(tns + XMLNames.Engine_Displacement, (data.Displacement.Value() * 1000 * 1000).ToXMLFormat(0)), new XElement(tns + XMLNames.Engine_IdlingSpeed, data.EngineModes.First().IdleSpeed.AsRPM.ToXMLFormat(0)), new XElement(tns + XMLNames.Engine_RatedSpeed, fld.RatedSpeed.AsRPM.ToXMLFormat(0)), @@ -220,13 +220,13 @@ namespace TUGraz.VectoCore.OutputData.XML ); gears.Add(gear); } - var id = CreateIdString(string.Format("GBX-{0}", gbxData.Model.RemoveWhitespace())); + var id = CreateIdString($"GBX-{gbxData.Model.RemoveWhitespace()}"); return new XElement((ns ?? tns) + XMLNames.Component_Gearbox, new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(string.Format("GBX-{0}", gbxData.Model), gbxData.Model), + GetDefaultComponentElements($"GBX-{gbxData.Model}", gbxData.Model), new XElement(tns + XMLNames.Gearbox_TransmissionType, gbxData.Type.ToXMLFormat()), new XElement(tns + XMLNames.Component_Gearbox_CertificationMethod, "Standard values"), gears @@ -242,7 +242,7 @@ namespace TUGraz.VectoCore.OutputData.XML throw new Exception("Torque Converter is required!"); } - var id = CreateIdString(string.Format("TC-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"TC-{data.Model.RemoveWhitespace()}"); return new XElement(tns + XMLNames.Component_TorqueConverter, @@ -262,7 +262,7 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement CreateAngleDrive(IAngledriveInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("ANGL-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"ANGL-{data.Model.RemoveWhitespace()}"); return new XElement((ns ?? tns) + XMLNames.Component_Angledrive, new XElement(tns + XMLNames.ComponentDataWrapper, @@ -277,7 +277,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XElement CreateRetarder(IRetarderInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("RET-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"RET-{data.Model.RemoveWhitespace()}"); return new XElement((ns ?? tns) + XMLNames.Component_Retarder, new XElement(tns + XMLNames.ComponentDataWrapper, @@ -294,12 +294,12 @@ namespace TUGraz.VectoCore.OutputData.XML public XElement CreateAxlegear(IAxleGearInputData data, XNamespace ns = null) { - var typeId = CreateIdString(string.Format("AXLGEAR-{0}", data.Ratio.ToString("F3", CultureInfo.InvariantCulture))); + var typeId = CreateIdString($"AXLGEAR-{data.Ratio.ToString("F3", CultureInfo.InvariantCulture)}"); return new XElement((ns ?? tns) + XMLNames.Component_Axlegear, new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, typeId), - GetDefaultComponentElements(typeId, Constants.NOT_AVailABLE), + GetDefaultComponentElements(typeId, Constants.NOT_AVAILABLE), new XElement(tns + "LineType", "Single portal axle"), new XElement(tns + XMLNames.Axlegear_Ratio, data.Ratio.ToXMLFormat(3)), new XElement(tns + XMLNames.Component_CertificationMethod, "Standard values"), @@ -334,12 +334,12 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement CreateTyre(ITyreDeclarationInputData tyre) { - var id = CreateIdString(string.Format("TYRE-{0}", tyre.Dimension).Replace("/", "_")); + var id = CreateIdString($"TYRE-{tyre.Dimension}".Replace("/", "_")); return new XElement(tns + "Tyre", new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(string.Format("TYRE-{0}", tyre.Dimension), tyre.Dimension), + GetDefaultComponentElements($"TYRE-{tyre.Dimension}", tyre.Dimension), new XElement(tns + XMLNames.AxleWheels_Axles_Axle_Dimension, tyre.Dimension), new XElement(tns + XMLNames.AxleWheels_Axles_Axle_RRCDeclared, tyre.RollResistanceCoefficient.ToXMLFormat(4)), new XElement(tns + XMLNames.AxleWheels_Axles_Axle_FzISO, tyre.TyreTestLoad.Value().ToXMLFormat(0)) @@ -369,12 +369,12 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement CreateAirdrag(IAirdragDeclarationInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("Airdrag-{0}", data.Model)); + var id = CreateIdString($"Airdrag-{data.Model}"); return new XElement((ns ?? tns) + XMLNames.Component_AirDrag, new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(data.Model, Constants.NOT_AVailABLE), + GetDefaultComponentElements(data.Model, Constants.NOT_AVAILABLE), new XElement(tns + "CdxA_0", data.AirDragArea.Value().ToXMLFormat(2)), new XElement(tns + "TransferredCdxA", data.AirDragArea.Value().ToXMLFormat(2)), new XElement(tns + XMLNames.AirDrag_DeclaredCdxA, data.AirDragArea.Value().ToXMLFormat(2))), diff --git a/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs b/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs index 93c1d55765927630424907ca0f9f2ffb91557260..edc9e98a1ea4aa3be9d37ae88e47430358216b33 100644 --- a/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs +++ b/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs @@ -40,7 +40,7 @@ namespace TUGraz.VectoCore.Utils { var hash = System.Convert.ToBase64String(GetHash(string.Join("\n", lines))); - return string.Format("SHA256: {0}", hash); + return $"SHA256: {hash}"; } public static byte[] GetHash(string inputString) diff --git a/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs b/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs index 3df85156f273bd618f0c2965206db6d3e05cbafd..3f99fb03af72be15ae21dc9110b373f2778a5015 100644 --- a/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs +++ b/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs @@ -44,8 +44,7 @@ namespace TUGraz.VectoCore.Utils double defaultValue = default(double)) { if (row.Table.Columns.Contains(columnName)) { - double result; - if (double.TryParse(row.Field<string>(columnName), NumberStyles.Any, CultureInfo.InvariantCulture, out result)) { + if (double.TryParse(row.Field<string>(columnName), NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } } @@ -70,7 +69,7 @@ namespace TUGraz.VectoCore.Utils public static double ParseDouble(this DataRow row, string columnName) { if (!row.Table.Columns.Contains(columnName)) { - throw new KeyNotFoundException(string.Format("Column {0} was not found in DataRow.", columnName)); + throw new KeyNotFoundException($"Column {columnName} was not found in DataRow."); } return row.ParseDouble(row.Table.Columns[columnName]); } @@ -80,27 +79,25 @@ namespace TUGraz.VectoCore.Utils try { return row.Field<string>(column).ToDouble(); } catch (IndexOutOfRangeException e) { - throw new VectoException(string.Format("Field {0} was not found in DataRow.", column), e); + throw new VectoException($"Field {column} was not found in DataRow.", e); } catch (NullReferenceException e) { - throw new VectoException(string.Format("Field {0} must not be null.", column), e); + throw new VectoException($"Field {column} must not be null.", e); } catch (FormatException e) { - throw new VectoException(string.Format("Field {0} is not in a valid number format: {1}", column, - row.Field<string>(column)), e); + throw new VectoException($"Field {column} is not in a valid number format: {row.Field<string>(column)}", e); } catch (OverflowException e) { - throw new VectoException(string.Format("Field {0} has a value too high or too low: {1}", column, - row.Field<string>(column)), e); + throw new VectoException($"Field {column} has a value too high or too low: {row.Field<string>(column)}", e); } catch (ArgumentNullException e) { - throw new VectoException(string.Format("Field {0} contains null which cannot be converted to a number.", column), + throw new VectoException($"Field {column} contains null which cannot be converted to a number.", e); } catch (Exception e) { - throw new VectoException(string.Format("Field {0}: {1}", column, e.Message), e); + throw new VectoException($"Field {column}: {e.Message}", e); } } public static bool ParseBoolean(this DataRow row, string columnName) { if (!row.Table.Columns.Contains(columnName)) { - throw new KeyNotFoundException(string.Format("Column {0} was not found in DataRow.", columnName)); + throw new KeyNotFoundException($"Column {columnName} was not found in DataRow."); } return row.Field<string>(row.Table.Columns[columnName]).ToBoolean(); } diff --git a/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs b/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs index ee28f9a92573b151b337bd5384062f2016830d13..0a88875261952993ec0782caae7f2cfa4d073f07 100644 --- a/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs +++ b/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs @@ -48,12 +48,11 @@ namespace TUGraz.VectoCore.Utils { public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - DateTime dateTime; if (reader.TokenType == JsonToken.Date) { return reader.Value; } if (DateTime.TryParseExact((string)reader.Value, new[] { "d.M.yyyy HH:mm:ss", "M/d/yyyy HH:mm:ss tt" }, - CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) { + CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime)) { return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); } diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index 91eb81f5e0247a4fc471f7d52ecdd1a88dea291c..c9e483cd3203f182657487dcd11f57b667618fb8 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Utils _mapName = name; } - public string Name { get { return _mapName; } } + public string Name => _mapName; public void AddPoint(double x, double y, double z) { @@ -92,8 +92,7 @@ namespace TUGraz.VectoCore.Utils public void Triangulate() { if (_points.Count < 3) { - throw new ArgumentException(string.Format("{0}: Triangulation needs at least 3 Points. Got {1} Points.", _mapName, - _points.Count)); + throw new ArgumentException($"{_mapName}: Triangulation needs at least 3 Points. Got {_points.Count} Points."); } SanitycheckInputPoints(); @@ -165,7 +164,7 @@ namespace TUGraz.VectoCore.Utils } if (duplicates.Any()) { throw new VectoException("{0}: Input Data for Delaunay map contains duplicates! \n{1}", _mapName, - string.Join("\n", duplicates.Select(pt => string.Format("{0} / {1}", pt.Key.X, pt.Key.Y)))); + string.Join("\n", duplicates.Select(pt => $"{pt.Key.X} / {pt.Key.Y}"))); } } @@ -181,10 +180,10 @@ namespace TUGraz.VectoCore.Utils private static void DrawGraph(int i, IEnumerable<Triangle> triangles, Triangle superTriangle, Point[] points, Point lastPoint = null) { - var xmin = Math.Min(points.Min(p => p.X), lastPoint != null ? lastPoint.X : double.NaN); - var xmax = Math.Max(points.Max(p => p.X), lastPoint != null ? lastPoint.X : double.NaN); - var ymin = Math.Min(points.Min(p => p.Y), lastPoint != null ? lastPoint.Y : double.NaN); - var ymax = Math.Max(points.Max(p => p.Y), lastPoint != null ? lastPoint.Y : double.NaN); + var xmin = Math.Min(points.Min(p => p.X), lastPoint?.X ?? double.NaN); + var xmax = Math.Max(points.Max(p => p.X), lastPoint?.X ?? double.NaN); + var ymin = Math.Min(points.Min(p => p.Y), lastPoint?.Y ?? double.NaN); + var ymax = Math.Max(points.Max(p => p.Y), lastPoint?.Y ?? double.NaN); using (var chart = new Chart { Width = 1000, Height = 1000 }) { chart.ChartAreas.Add(new ChartArea("main") { @@ -225,7 +224,7 @@ namespace TUGraz.VectoCore.Utils var type = string.Join("", method.DeclaringType.Name.Split(Path.GetInvalidFileNameChars())); var methodName = string.Join("", method.Name.Split(Path.GetInvalidFileNameChars())); Directory.CreateDirectory("delaunay"); - chart.SaveImage(string.Format("delaunay\\{0}_{1}_{2}_{3}.png", type, methodName, superTriangle.GetHashCode(), i), + chart.SaveImage($"delaunay\\{type}_{methodName}_{superTriangle.GetHashCode()}_{i}.png", ChartImageFormat.Png); } } diff --git a/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs b/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs index 1261eff951874662e935c8987dfbda3a63c7dc2a..c4949b7be81fa89e4b28578590344a9cc5f9063c 100644 --- a/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs +++ b/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs @@ -39,15 +39,13 @@ namespace TUGraz.VectoCore.Utils { public static object GetValueOrNull<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) { - TValue value; - return dictionary.TryGetValue(key, out value) ? (object)value : DBNull.Value; + return dictionary.TryGetValue(key, out var value) ? (object)value : DBNull.Value; } public static TValue GetValueOrZero<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) where TValue : SIBase<TValue> { - TValue value; - return dictionary.TryGetValue(key, out value) ? value : 0.SI<TValue>(); + return dictionary.TryGetValue(key, out var value) ? value : 0.SI<TValue>(); } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Utils/IterationStatistics.cs b/VectoCore/VectoCore/Utils/IterationStatistics.cs index 5a4da47f967ed4b643a80e83bad6ef7d03e89b47..d8c0fa7797797b3be0477de137b6158e2e0bf9b3 100644 --- a/VectoCore/VectoCore/Utils/IterationStatistics.cs +++ b/VectoCore/VectoCore/Utils/IterationStatistics.cs @@ -45,17 +45,11 @@ namespace TUGraz.VectoCore.Utils private static readonly ThreadLocal<List<DataEntry>> DataLocal = new ThreadLocal<List<DataEntry>>(() => new List<DataEntry>()); - public static List<DataEntry> Data - { - get { return DataLocal.Value; } - } + public static List<DataEntry> Data => DataLocal.Value; private static readonly ThreadLocal<Stopwatch> TimerLocal = new ThreadLocal<Stopwatch>(Stopwatch.StartNew); - private static Stopwatch Timer - { - get { return TimerLocal.Value; } - } + private static Stopwatch Timer => TimerLocal.Value; private static readonly ThreadLocal<Dictionary<string, Dictionary<string, double>>> CurrentLocal = new ThreadLocal<Dictionary<string, Dictionary<string, double>>>( @@ -63,8 +57,8 @@ namespace TUGraz.VectoCore.Utils private static Dictionary<string, Dictionary<string, double>> Current { - get { return CurrentLocal.Value; } - set { CurrentLocal.Value = value; } + get => CurrentLocal.Value; + set => CurrentLocal.Value = value; } [Conditional("TRACE")] diff --git a/VectoCore/VectoCore/Utils/MeanShiftClustering.cs b/VectoCore/VectoCore/Utils/MeanShiftClustering.cs index 104b91efa013aa894c1d2f5ef63dc9db825601d7..be40ef7e018584fa829c0fcd4dbbd060aa21ec6d 100644 --- a/VectoCore/VectoCore/Utils/MeanShiftClustering.cs +++ b/VectoCore/VectoCore/Utils/MeanShiftClustering.cs @@ -116,17 +116,15 @@ namespace TUGraz.VectoCore.Utils _count++; } - public double? Mean { get { return _count > 0 ? _sum / _count : (double?)null; } } + public double? Mean => _count > 0 ? _sum / _count : (double?)null; - public override string ToString() - { - return string.Format("[{0},{2}]", Center, Mean); - } + public override string ToString() => $"[{Center},{Mean}]"; public bool Update(double tolerance) { if (Mean == null) return false; + var retVal = Math.Abs(Center - Mean.Value) > tolerance; Center = Mean.Value; _count = 0; diff --git a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs index 3400b3250e52af961a520fed880d43b00e6f9de2..5cd1169ac65f2414bc421a57599f570f8f00f759 100644 --- a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs +++ b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs @@ -185,17 +185,16 @@ namespace TUGraz.VectoCore.Utils var rand = new Random().Next(); using ( - var f = - new StreamWriter(File.Open("LineSearch-" + Thread.CurrentThread.ManagedThreadId + "-statistics.csv", + var f = new StreamWriter(File.Open("LineSearch-" + Thread.CurrentThread.ManagedThreadId + "-statistics.csv", FileMode.Append))) { foreach (var d in debug.Data) { - f.WriteLine(string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}", - rand, - (d.x - xmin) / (xmax - xmin), - (d.y - ymin) / (ymax - ymin), - d.x / Math.Max(Math.Abs(xmax), Math.Abs(xmin)), - d.y / Math.Max(Math.Abs(ymax), Math.Abs(ymin)), - d.x, d.y)); + f.WriteLine($"{rand}, " + + $"{(d.x - xmin) / (xmax - xmin)}, " + + $"{(d.y - ymin) / (ymax - ymin)}, " + + $"{d.x / Math.Max(Math.Abs(xmax), Math.Abs(xmin))}, " + + $"{d.y / Math.Max(Math.Abs(ymax), Math.Abs(ymin))}, " + + $"{d.x}, " + + $"{d.y}"); } } } diff --git a/VectoCore/VectoCore/Utils/SwitchExtension.cs b/VectoCore/VectoCore/Utils/SwitchExtension.cs deleted file mode 100644 index abd6fd389734241b6ff3c8b51ea89f2f68a1b377..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/Utils/SwitchExtension.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System; -using System.Diagnostics; - -namespace TUGraz.VectoCore.Utils -{ - /// <summary> - /// Extension Methods for Creating a Switch-Case Construct on Types. - /// </summary> - /// <remarks> - /// Adapted for VECTO. Created by Virtlink. Original source code on GitHub: <see href="https://gist.github.com/Virtlink/8722649"/>. - /// </remarks> - public static class SwitchExtension - { - /// <summary> - /// Switches on the type. - /// With ".Case" you can define single alternatives (only the first suitable case will be executed). - /// With ".If" you can define multiple type-conditionals (every suitable if will be executed) - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="self">The self.</param> - /// <returns></returns> - [DebuggerHidden] - public static Switch<T> Switch<T>(this T self) - { - return new Switch<T>(self); - } - } - - public class Switch<T> - { - private readonly T _value; - private bool _handled; - - [DebuggerHidden] - internal Switch(T value) - { - _value = value; - _handled = false; - } - - [DebuggerHidden] - public Switch<T> Case<TFilter>(Action action) where TFilter : T - { - return Case<TFilter>(_ => action()); - } - - [DebuggerHidden] - public Switch<T> Case<TFilter>() where TFilter : T - { - return Case<TFilter>(() => { }); - } - - - [DebuggerHidden] - public Switch<T> Case<TFilter>(Action<TFilter> action) where TFilter : T - { - if (!_handled && _value.GetType() == typeof(TFilter)) { - action((TFilter)_value); - _handled = true; - } - return this; - } - - /// <summary> - /// Does the action if the type is fullfilled and continues the evaluation. - /// </summary> - /// <typeparam name="TFilter">The type of the filter.</typeparam> - /// <param name="action">The action.</param> - /// <returns></returns> - [DebuggerHidden] - public Switch<T> If<TFilter>(Action<TFilter> action) where TFilter : class - { - if (_value is TFilter) { - action(_value as TFilter); - } - return this; - } - - [DebuggerHidden] - public void Default(Action action) - { - Default(_ => action()); - } - - [DebuggerHidden] - public void Default(Action<T> action) - { - if (!_handled) { - action(_value); - } - } - } -} \ No newline at end of file diff --git a/VectoCore/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/VectoCore/Utils/VectoCSVFile.cs index f4ccae73c0676f9b1ce8c2884a8d0b9fd462cf10..455717e11189c524ee34735dab0f0cffc37c2815 100644 --- a/VectoCore/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/VectoCore/Utils/VectoCSVFile.cs @@ -155,8 +155,8 @@ namespace TUGraz.VectoCore.Utils firstLineIsData = false; if (table.Columns.Count != cells.Length && !ignoreEmptyColumns) { throw new CSVReadException( - string.Format("Line {0}: The number of values is not correct. Expected {1} Columns, Got {2} Columns", - lineNumber, table.Columns.Count, cells.Length)); + $"Line {lineNumber}: The number of values is not correct. " + + $"Expected {table.Columns.Count} Columns, Got {cells.Length} Columns"); } try { @@ -164,7 +164,7 @@ namespace TUGraz.VectoCore.Utils table.Rows.Add(cells); } catch (InvalidCastException e) { throw new CSVReadException( - string.Format("Line {0}: The data format of a value is not correct. {1}", lineNumber, e.Message), e); + $"Line {lineNumber}: The data format of a value is not correct. {e.Message}", e); } lineNumber++; } @@ -203,10 +203,9 @@ namespace TUGraz.VectoCore.Utils var entries = new List<string>(); if (addVersionHeader) { try { - entries.Add(string.Format("# VECTO{0} {1} - {2}", VectoSimulationCore.BranchSuffix, VectoSimulationCore.VersionNumber, - DateTime.Now.ToString("dd.MM.yyyy HH:mm"))); + entries.Add($"# VECTO{VectoSimulationCore.BranchSuffix} {VectoSimulationCore.VersionNumber} - {DateTime.Now:dd.MM.yyyy HH:mm}"); } catch (Exception) { - entries.Add(string.Format("# VECTO {0} - {1}", "Unknown", DateTime.Now.ToString("dd.MM.yyyy HH:mm"))); + entries.Add($"# VECTO Unknown - {DateTime.Now:dd.MM.yyyy HH:mm}"); } } var header = table.Columns.Cast<DataColumn>().Select(col => col.Caption ?? col.ColumnName); @@ -240,7 +239,7 @@ namespace TUGraz.VectoCore.Utils // if a string contains a "," then it has to be contained in quotes in order to be correctly recognized in a CSV file. if (formattedList[i].Contains(Delimiter)) { - formattedList[i] = string.Format("\"{0}\"", formattedList[i]); + formattedList[i] = $"\"{formattedList[i]}\""; } } entries.Add(string.Join(Delimiter, formattedList)); @@ -248,7 +247,7 @@ namespace TUGraz.VectoCore.Utils if (addDigest) { var digest = DataIntegrityHelper.ComputeDigestValue(entries.Where(x => !x.StartsWith(DigestValuePrefix)).ToArray()); - entries.Add(string.Format("{0} {1}", DigestValuePrefix, digest)); + entries.Add($"{DigestValuePrefix} {digest}"); } foreach (var entry in entries) { diff --git a/VectoCore/VectoCore/Utils/VectoVersionCore.cs b/VectoCore/VectoCore/Utils/VectoVersionCore.cs index c001707fe9fecfcd12713d61e326ef850576a856..bba38738193877e65f3670651632df55a4604a0d 100644 --- a/VectoCore/VectoCore/Utils/VectoVersionCore.cs +++ b/VectoCore/VectoCore/Utils/VectoVersionCore.cs @@ -44,25 +44,10 @@ namespace TUGraz.VectoCore.Utils #endif #endif - public static string VersionNumber - { - get { - return "0.7.3.2247" + SUFFIX; - } - } + public static string VersionNumber => "0.7.3.2247" + SUFFIX; - public static string BranchSuffix - { - get { - return "-DEV"; - } - } + public static string BranchSuffix => "-DEV"; - public static string FullVersion - { - get { - return string.Format("VectoCore{1} {0}", VersionNumber, BranchSuffix); - } - } + public static string FullVersion => string.Format("VectoCore{1} {0}", VersionNumber, BranchSuffix); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Utils/XMLDefinitions.cs b/VectoCore/VectoCore/Utils/XMLDefinitions.cs index 65099861ac3093164a3c3b35dd9b2b17e84315d3..11957a048ac63fe8431f49af2336935d160b0638 100644 --- a/VectoCore/VectoCore/Utils/XMLDefinitions.cs +++ b/VectoCore/VectoCore/Utils/XMLDefinitions.cs @@ -141,7 +141,7 @@ namespace TUGraz.VectoCore.Utils public static string GetSchemaFilename(XmlDocumentType type) { if (!schemaFilenames.ContainsKey(type)) { - throw new Exception(string.Format("Invalid argument '{0}' - only use single flags", type)); + throw new Exception($"Invalid argument '{type}' - only use single flags"); } var entry = schemaFilenames[type]; diff --git a/VectoCore/VectoCore/Utils/XMLHelper.cs b/VectoCore/VectoCore/Utils/XMLHelper.cs index 1e44881524766d936f31e5910ae2f30efd500723..49d6fff697cf95f5e99990f585ccfb94b57c375f 100644 --- a/VectoCore/VectoCore/Utils/XMLHelper.cs +++ b/VectoCore/VectoCore/Utils/XMLHelper.cs @@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.Utils case "kg": return GetValueAsUnit(mass.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(Watt power, string unit, uint? decimals = 0) @@ -93,7 +93,7 @@ namespace TUGraz.VectoCore.Utils case "W": return GetValueAsUnit(power?.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(CubicMeter volume, string unit, uint? decimals = 0) @@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Utils case "m3": return GetValueAsUnit(volume.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(PerSecond angSpeed, string unit, uint? decimals = 0) @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.Utils case "rpm": return GetValueAsUnit(angSpeed.ConvertToRoundsPerMinute(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } @@ -123,7 +123,7 @@ namespace TUGraz.VectoCore.Utils case "km/h": return GetValueAsUnit(speed.ConvertToKiloMeterPerHour(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(MeterPerSquareSecond acc, string unit, uint? decimals) @@ -132,7 +132,7 @@ namespace TUGraz.VectoCore.Utils case "m/s²": return GetValueAsUnit(acc.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(Meter m, string unit, uint? decimals) @@ -142,7 +142,7 @@ namespace TUGraz.VectoCore.Utils case "km": return GetValueAsUnit(m.ConvertToKiloMeter(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(double value, string unit, uint? decimals) @@ -182,7 +182,7 @@ namespace TUGraz.VectoCore.Utils public static string QueryLocalName(string nodeName) { - return string.Format(".//*[local-name()='{0}']", nodeName); + return $".//*[local-name()='{nodeName}']"; } public static string QueryLocalName(params string[] nodePath) @@ -228,7 +228,7 @@ namespace TUGraz.VectoCore.Utils public static TableData ReadCSVResource(XmlNode baseNode, string xmlElement, string basePath) { var resourceNode = baseNode.SelectSingleNode( - XMLHelper.QueryLocalName(xmlElement) + ExtCSVResourceQuery); + QueryLocalName(xmlElement) + ExtCSVResourceQuery); var filename = string.Empty; if (resourceNode != null) { filename = resourceNode.Attributes?.GetNamedItem(XMLNames.ExtResource_File_Attr).InnerText; @@ -251,14 +251,8 @@ namespace TUGraz.VectoCore.Utils return null;// new TableData(Path.Combine(basePath ?? "", filename), DataSourceType.Missing); } - private static string ExtCSVResourceQuery - { - get { - return string.Format( - "/*[local-name()='{0}' and @{1}='{2}']", XMLNames.ExternalResource, XMLNames.ExtResource_Type_Attr, - XMLNames.ExtResource_Type_Value_CSV); - } - } + private static string ExtCSVResourceQuery => + $"/*[local-name()='{XMLNames.ExternalResource}' and @{XMLNames.ExtResource_Type_Attr}='{XMLNames.ExtResource_Type_Value_CSV}']"; private static IEnumerable<T> Shim<T>(XmlNodeList nodes) { diff --git a/VectoCore/VectoCore/Utils/XMLValidator.cs b/VectoCore/VectoCore/Utils/XMLValidator.cs index b7fa13ed4ea1c2734174056deae5059cf148ee01..302f6860d6df7bf4006af225c50608adc126c7e1 100644 --- a/VectoCore/VectoCore/Utils/XMLValidator.cs +++ b/VectoCore/VectoCore/Utils/XMLValidator.cs @@ -128,7 +128,7 @@ namespace TUGraz.VectoCore.Utils resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schemaFile); } catch (Exception e) { throw new Exception( - string.Format("Missing resource {0} for XML document type: {1} ({2})", schemaFile, entry, docType.ToString()), e); + $"Missing resource {schemaFile} for XML document type: {entry} ({docType.ToString()})", e); } var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); diff --git a/VectoCore/VectoCore/Utils/XPathHelper.cs b/VectoCore/VectoCore/Utils/XPathHelper.cs index 85fbfe15b6485700b1f73ae5e682bd20e9b7e1bb..3f18f3a79d84279eaad183e20bb2807d41a899b2 100644 --- a/VectoCore/VectoCore/Utils/XPathHelper.cs +++ b/VectoCore/VectoCore/Utils/XPathHelper.cs @@ -67,7 +67,7 @@ namespace TUGraz.VectoCore.Utils public string QueryAbs(params string[] xPathSections) { - return string.Format("/{0}", Query(xPathSections)); + return $"/{Query(xPathSections)}"; } public string NSPrefix(string element, string prefix = null) diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 341ec40b46ec8606187829a9e58b73b1246cd525..c18091b869825ad1e5e2ab11e293bca48d5dff7a 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -727,7 +727,6 @@ <Compile Include="Models\Simulation\IVehicleContainer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="OutputData\FileIO\ShiftPolygonExport.cs" /> - <Compile Include="Utils\SwitchExtension.cs" /> <Compile Include="Utils\VectoCSVFile.cs" /> <Compile Include="Utils\DelaunayMap.cs" /> <Compile Include="Utils\VectoVersionCore.cs"> diff --git a/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs b/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs index 97bf4aa707007a0c739b7407469e29d9da5b53d4..e9e38942fe7cb721ed8b76f7815cf5333668b559 100644 --- a/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs +++ b/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs @@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Tests.Algorithms var digest = DataIntegrityHelper.ComputeDigestValue(otherLines); - Assert.AreEqual(string.Format("#@ {0}", digest), last); + Assert.AreEqual($"#@ {digest}", last); } private static DataTable CreateDataTable(string[] cols, int numRows) diff --git a/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs b/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs index bdefb58d3776418d6e417da3f258a0c9f6d6e380..e6017218e5fa8c835f64c2b1fed8c83ee0bacf1b 100644 --- a/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs +++ b/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs @@ -215,7 +215,7 @@ namespace TUGraz.VectoCore.Tests.Algorithms // test one arbitrary point in the middle AssertHelper.AreRelativeEqual(37681, map.Interpolate(1500 * xfactor, 1300 * yfactor), - string.Format("{0}, {1}", xfactor, yfactor)); + $"{xfactor}, {yfactor}"); } } } diff --git a/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs b/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs index 65ce70d494ecece738bdb9e2dc739fae153e40fa..491b793f18dc085d52c41d078260429eb7b5d70c 100644 --- a/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs @@ -538,10 +538,7 @@ namespace TUGraz.VectoCore.Tests.FileIO public VectoSimulationJobType JobType { get; set; } public IEngineEngineeringInputData EngineOnly { get; set; } - IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle - { - get { return Vehicle; } - } + IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle => Vehicle; public string JobName { get; set; } public string ShiftStrategy { get; set; } diff --git a/VectoCore/VectoCoreTest/Integration/ADAS/ADASTests.cs b/VectoCore/VectoCoreTest/Integration/ADAS/ADASTests.cs index c462bf45956102e805acdf29104d5e19d3034c3b..9a5981be2d8504706b782ed7dd9e59b086e28d64 100644 --- a/VectoCore/VectoCoreTest/Integration/ADAS/ADASTests.cs +++ b/VectoCore/VectoCoreTest/Integration/ADAS/ADASTests.cs @@ -111,7 +111,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ADAS jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); var modFilename = writer.GetModDataFileName(run.RunName, run.CycleName, run.RunSuffix); GetGraphWriter().Write(modFilename); } @@ -152,7 +152,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ADAS jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); var modFilename = writer.GetModDataFileName(run.RunName, run.CycleName, run.RunSuffix); GetGraphWriter().Write(modFilename); } @@ -193,7 +193,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ADAS jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); var modFilename = writer.GetModDataFileName(run.RunName, run.CycleName, run.RunSuffix); GetGraphWriter().Write(modFilename); } @@ -287,7 +287,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ADAS jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); var modFilename = writer.GetModDataFileName(run.RunName, run.CycleName, run.RunSuffix); GetGraphWriter().Write(modFilename); } @@ -315,7 +315,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ADAS jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); return jobContainer; } @@ -346,7 +346,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ADAS jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); //var run = jobContainer.Runs[runIdx].Run; //run.Run(); diff --git a/VectoCore/VectoCoreTest/Integration/AMTShiftStrategyTests.cs b/VectoCore/VectoCoreTest/Integration/AMTShiftStrategyTests.cs index f0ff60e0e64bbea753132bc3c85f03b9898e6d47..73d27a4a754efa732b8ab124d30c565bb522631a 100644 --- a/VectoCore/VectoCoreTest/Integration/AMTShiftStrategyTests.cs +++ b/VectoCore/VectoCoreTest/Integration/AMTShiftStrategyTests.cs @@ -78,8 +78,8 @@ namespace TUGraz.VectoCore.Tests.Integration jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), String.Concat<Exception>(jobContainer.Runs.Select(r => r.ExecException))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), String.Concat(jobContainer.Runs.Select(r => r.ExecException))); } } diff --git a/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs index b09819ddd799604af482b2480749f1637b73f6bd..233f680a270f56edd738389a6561a52a0db004c3 100644 --- a/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs @@ -151,14 +151,14 @@ namespace TUGraz.VectoCore.Tests.Integration new GearData { //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) - ? TransmissionLossMapReader.Create(0.96, ratio, string.Format("Gear {0}", i)) - : TransmissionLossMapReader.Create(0.98, ratio, string.Format("Gear {0}", i)), + ? TransmissionLossMapReader.Create(0.96, ratio, $"Gear {i}") + : TransmissionLossMapReader.Create(0.98, ratio, $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile), TorqueConverterRatio = i == 0 ? (gbxType == GearboxType.ATPowerSplit ? 1.0 : ratio) : double.NaN, TorqueConverterGearLossMap = i == 0 ? TransmissionLossMapReader.Create(gbxType == GearboxType.ATPowerSplit ? 1.0 : 0.98, ratio, - string.Format("Gear {0}", i)) + $"Gear {i}") : null, TorqueConverterShiftPolygon = i == 0 ? ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) : null })) diff --git a/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs b/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs index 73ad66f37453b576db259c6a3cb51bd9c8de64f0..9ae61f5b293ab54767a8b3c250aeba21cbdf5c08 100644 --- a/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B4_constant_{0}-{1}_{2}_{3}", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B4_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true, pAuxEl: pAuxEl); @@ -149,7 +149,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B4_acc_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B4_acc_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -185,7 +185,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-B4_cycle_{0}-{1}_{2}_{3}", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-B4_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -270,7 +270,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B3_constant_{0}-{1}_{2}_{3}", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B3_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true, pAuxEl: pAuxEl); @@ -306,7 +306,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B3_acc_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B3_acc_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -342,7 +342,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-B3_cycle_{0}-{1}_{2}_{3}", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-B3_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -427,7 +427,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_constant_{0}-{1}_{2}_{3}", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B2_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true, pAuxEl: pAuxEl); @@ -465,7 +465,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_stop_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B2_stop_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true); @@ -495,7 +495,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_acc_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B2_acc_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true); @@ -531,7 +531,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_cycle_{0}-{1}_{2}_{3}", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B2_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true); @@ -781,7 +781,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = shiftStrategy.ComputeDeclarationShiftPolygon(GearboxType.AMT, i, null, ) })).ToDictionary(k => k.Item1 + 1, v => v.Item2), @@ -939,10 +939,8 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric get; set; } - public NewtonMeter EngineTorque - { - get { return null; } - } + public NewtonMeter EngineTorque => null; + public Watt EngineStationaryFullPower(PerSecond angularSpeed) { throw new NotImplementedException(); @@ -967,10 +965,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric public PerSecond EngineRatedSpeed { get; } public PerSecond EngineN95hSpeed { get; } public PerSecond EngineN80hSpeed { get; } - public bool EngineOn - { - get { return true; } - } + public bool EngineOn => true; } diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs index 980c220ad349893a633582bf10387e7de70e2e03..3d12cc847962767a2d3940fc54865b367b7149d2 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs @@ -67,8 +67,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries public void AuxDemandtest(double vehicleWeight, double engineSpeedRpm, double driveLinePower, double internalPower, double expectedPowerDemand) { - MockDriver driver; - var busAux = CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); var engineDrivelinePower = (driveLinePower * 1000).SI<Watt>(); var engineSpeed = engineSpeedRpm.RPMtoRad(); @@ -86,8 +85,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var engineSpeedRpm = 1256; var internalPower = 148; - MockDriver driver; - var busAux = CreateBusAuxAdapterForTesting(12000, out driver); + var busAux = CreateBusAuxAdapterForTesting(12000, out var driver); var engineDrivelinePower = (driveLinePower * 1000).SI<Watt>(); var engineSpeed = engineSpeedRpm.RPMtoRad(); diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs index 235238dfcb6bd86686ba4b2b189f282ae23bf9a3..97edc78a5877fe3468dbe3a5ff2028f9f82dcb36 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs @@ -61,8 +61,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries public void TestNoSmartAuxDuringDrive(double vehicleWeight, double engineSpeedRpm, double driveLinePower, double internalPower, double expectedPowerDemand) { - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Driving; driver.DrivingAction = DrivingAction.Accelerate; @@ -93,8 +92,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries // this test is to make sure that the aux power-demand does not jump between average and smart power demand // when searching for the operating point for coasting (i.e. power demand (internal Power) is close to the motoring curve, // intependent of power demand of power train) - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Coasting; driver.DrivingAction = DrivingAction.Coast; @@ -116,8 +114,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries public void TestSmartAuxDuringBrake(double vehicleWeight, double engineSpeedRpm, double driveLinePower, double internalPower, double expectedPowerDemand) { - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Braking; driver.DrivingAction = DrivingAction.Brake; @@ -135,8 +132,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries TestCase(19000)] public void AuxDemandContinuityTest(double vehicleWeight) { - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Driving; diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index 0f66184be9b5ab7ea40becad5855ab5efbd307fd..258ae5281d6c84cdab3c2e73a143f7bd807d4010 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -142,8 +142,8 @@ namespace TUGraz.VectoCore.Tests.Integration new GearData { //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) - ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, string.Format("Gear {0}", i)) - : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), + ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, $"Gear {i}") + : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) diff --git a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs index 22601613c7dfc85ba1319b623cac46da94f86cc5..aca96a92aba63b6567a3273957b420b6b8f5e1c1 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs @@ -140,8 +140,8 @@ namespace TUGraz.VectoCore.Tests.Integration new GearData { //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) - ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, string.Format("Gear {0}", i)) - : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), + ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, $"Gear {i}") + : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) diff --git a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs index 7c1c4d19dd210c8bd2bf18d22c8b92af4b38ed9a..52884da0ee1b4a13163a621dff94d11a1cb5e533 100644 --- a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs +++ b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs @@ -512,8 +512,8 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus private void AssertAuxiliaryData(RelatedRun relatedRun) { - var genericAuxiliaryData = relatedRun.VectoRunDataGenericBody.Aux; - var specificAuxiliaryData = relatedRun.VectoRunDataSpezificBody.Aux; + var genericAuxiliaryData = relatedRun.VectoRunDataGenericBody.Aux.ToList(); + var specificAuxiliaryData = relatedRun.VectoRunDataSpezificBody.Aux.ToList(); Assert.AreEqual(2, genericAuxiliaryData.Count()); Assert.AreEqual("Hydraulic driven - Constant displacement pump", genericAuxiliaryData.First().Technology.First()); @@ -1085,8 +1085,8 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), String.Concat<Exception>(jobContainer.Runs.Select(r => r.ExecException))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), String.Concat(jobContainer.Runs.Select(r => r.ExecException))); } [TestCase(@"TestData\Integration\Buses\FactorMethod\vecto_vehicle-primary_heavyBus_ESS_electricFanSTP.xml", 13, TestName = "RunBusSimulation electric STP/Fan ESS IU/RL"), diff --git a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusSanityCheckTests.cs b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusSanityCheckTests.cs index b17f338240e5d60bbd4607cd2d5386111e3bf7fd..991a0731a24c60d11b48e945a7fdb55b2ca0353c 100644 --- a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusSanityCheckTests.cs +++ b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusSanityCheckTests.cs @@ -178,42 +178,23 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus //JobName = Vehicle.VIN; } - public IDeclarationMultistageJobInputData JobInputData - { - get { return input.JobInputData; } - } + public IDeclarationMultistageJobInputData JobInputData => input.JobInputData; IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData => null; - public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData - { - get { return input.PrimaryVehicleData; } - } - public XElement XMLHash { get; } + public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleData => input.PrimaryVehicleData; + public XElement XMLHash { get; } - public bool SavedInDeclarationMode - { - get { return true; } - } + public bool SavedInDeclarationMode => true; - public IPrimaryVehicleInformationInputDataProvider PrimaryVehicle - { - get { return PrimaryVehicleData; } - } - public IList<IManufacturingStageInputData> ManufacturingStages - { - get { return input.JobInputData.ManufacturingStages; } - } - public IManufacturingStageInputData ConsolidateManufacturingStage - { - get { return input.JobInputData.ConsolidateManufacturingStage; } - } + public IPrimaryVehicleInformationInputDataProvider PrimaryVehicle => PrimaryVehicleData; - public VectoSimulationJobType JobType - { - get { return VectoSimulationJobType.ConventionalVehicle; } - } + public IList<IManufacturingStageInputData> ManufacturingStages => input.JobInputData.ManufacturingStages; + + public IManufacturingStageInputData ConsolidateManufacturingStage => input.JobInputData.ConsolidateManufacturingStage; + + public VectoSimulationJobType JobType => VectoSimulationJobType.ConventionalVehicle; public bool InputComplete { get; } diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs b/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs index 62a0412fc13bcfe52a349c88f59c3797b3ca5c45..eb012863b0f5d54765940435471c0296c7b2eff2 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs @@ -108,7 +108,7 @@ namespace TUGraz.VectoCore.Tests.Integration jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); Assert.IsTrue(File.Exists(manufactuerFile)); Assert.IsTrue(File.Exists(customerFile)); diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs b/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs index e6141c21ab3f9f47a74b059ec309888981fc6e06..83f6dc0b74b0c029d96daadd99b499c06260b1d7 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs @@ -118,9 +118,9 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration } var fcNode = manufacturerReport.XPathSelectElement( - string.Format("//*[local-name()='Results']/*[local-name()='Result'][{0}]//*[local-name()='FuelConsumption' and @unit='g/km']", runIdx)); + $"//*[local-name()='Results']/*[local-name()='Result'][{runIdx}]//*[local-name()='FuelConsumption' and @unit='g/km']"); var co2Node = manufacturerReport.XPathSelectElement( - string.Format("//*[local-name()='Results']/*[local-name()='Result'][{0}]//*[local-name()='CO2' and @unit='g/km']", runIdx)); + $"//*[local-name()='Results']/*[local-name()='Result'][{runIdx}]//*[local-name()='CO2' and @unit='g/km']"); Console.WriteLine("fc: {0} co2: {1}", fcNode.Value, co2Node.Value); diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs b/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs index 8705ce467f1be8ab8195dec9d32c72883d73aa51..05b72fc4ec65f1f4d9761d58ebedf402ee8fef5f 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs @@ -85,7 +85,7 @@ namespace TUGraz.VectoCore.Tests.Integration jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); } } } diff --git a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs index 09f1dcd09f0cc1f781c9a7a033f8304eec0122af..ef936822099a928ec60d41e926040a6d9295ba9e 100644 --- a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs +++ b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs @@ -231,14 +231,14 @@ namespace TUGraz.VectoCore.Tests.Integration var i = 5; jobContainer.Runs[i].Run.Run(); Assert.IsTrue(jobContainer.Runs[i].Run.FinishedWithoutErrors, - string.Format("{0}", jobContainer.Runs[i].ExecException)); + $"{jobContainer.Runs[i].ExecException}"); jobContainer = new JobContainer(sumData); jobContainer.AddRuns(factory1Hz); jobContainer.Runs[i].Run.Run(); Assert.IsTrue(jobContainer.Runs[i].Run.FinishedWithoutErrors, - string.Format("{0}", jobContainer.Runs[i].ExecException)); + $"{jobContainer.Runs[i].ExecException}"); var modFile = VectoCSVFile.Read(modFileName); var modFile1Hz = VectoCSVFile.Read(modFileName1Hz); @@ -248,8 +248,7 @@ namespace TUGraz.VectoCore.Tests.Integration var lineCount1Hz = modFile1Hz.Rows.Count; AssertHelper.AreRelativeEqual(lineCount1Hz, maxSeconds, - string.Format("LineCount must equal max seconds. Lines={0}, MaxSeconds={1}", lineCount1Hz, - maxSeconds), 1); + $"LineCount must equal max seconds. Lines={lineCount1Hz}, MaxSeconds={maxSeconds}", 1); // test max distance var maxDistance = modFile.Rows.Cast<DataRow>().Last().ParseDouble(ModalResultField.dist.GetShortCaption()); @@ -323,9 +322,8 @@ namespace TUGraz.VectoCore.Tests.Integration jobContainer.Execute(); jobContainer.WaitFinished(); Assert.IsTrue(jobContainer.Runs.All(r => r.Success), - string.Format("folowing runs failed: {0}\n{1}", - string.Concat(jobContainer.Runs.Where(r => !r.Success).Select(r => r.Run.RunName + " - " + r.Run.CycleName)), - string.Concat(jobContainer.Runs.Select(r => r.ExecException)))); + $"folowing runs failed: {string.Concat(jobContainer.Runs.Where(r => !r.Success).Select(r => r.Run.RunName + " - " + r.Run.CycleName))}\n" + + $"{string.Concat(jobContainer.Runs.Select(r => r.ExecException))}"); } [TestCase, Category("LongRunning")] diff --git a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs index 735123cefe2081309072b6effb2022ca9f725365..ccfa911ea3b7f0aa2df0af12c2451ce987210228 100644 --- a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs @@ -132,7 +132,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P1_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, gbxType.ToXMLFormat()); + var modFilename = $"SimpleParallelHybrid-P1_constant_{vmax}-{initialSoC}_{slope}_{gbxType.ToXMLFormat()}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP1; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: false, gearboxType: gbxType); @@ -178,7 +178,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P1_acc_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, gbxType.ToXMLFormat()); + var modFilename = $"SimpleParallelHybrid-P1_acc_{vmax}-{initialSoC}_{slope}_{gbxType.ToXMLFormat()}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP1; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: false, gearboxType: gbxType); @@ -216,7 +216,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P1_stop_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, gbxType.ToXMLFormat()); + var modFilename = $"SimpleParallelHybrid-P1_stop_{vmax}-{initialSoC}_{slope}_{gbxType.ToXMLFormat()}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP1; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: false, gearboxType: gbxType); @@ -336,7 +336,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_acc_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P2_acc_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -371,7 +371,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_acc_{0}-{1}_{2}_maxPwr-{3}.vmod", vmax, initialSoC, slope, maxPwrkW); + var modFilename = $"SimpleParallelHybrid-P2_acc_{vmax}-{initialSoC}_{slope}_maxPwr-{maxPwrkW}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, maxDriveTrainPower: (maxPwrkW * 1000).SI<Watt>()); @@ -420,7 +420,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P2_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl); @@ -519,7 +519,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_cycle_{0}-{1}_{2}_{3}.vmod", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P2_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl, payload: payload.SI<Kilogram>()); @@ -864,7 +864,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid //const PowertrainPosition pos = PowertrainPosition.HybridP2; var run = CreateConventionalEngineeringRun( - cycle, string.Format("ConventionalVehicle_acc_{0}_{1}.vmod", vmax, slope)); + cycle, $"ConventionalVehicle_acc_{vmax}_{slope}.vmod"); //var hybridController = (HybridController)((VehicleContainer)run.GetContainer()).HybridController; //Assert.NotNull(hybridController); @@ -893,7 +893,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_stop_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P2_stop_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -946,7 +946,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P3_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl); @@ -984,7 +984,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_acc_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P3_acc_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1018,7 +1018,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_stop_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P3_stop_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1061,7 +1061,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_cycle_{0}-{1}_{2}_{3}.vmod", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P3_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl, payload: payload.SI<Kilogram>()); @@ -1193,7 +1193,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P4_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl); @@ -1232,7 +1232,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_acc_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P4_acc_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1265,7 +1265,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_stop_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P4_stop_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1307,7 +1307,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_cycle_{0}-{1}_{2}_{3}.vmod", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P4_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl, payload: payload.SI<Kilogram>()); @@ -1717,7 +1717,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = DeclarationData.Gearbox.ComputeEfficiencyShiftPolygon(i,) })).ToDictionary(k => k.Item1 + 1, v => v.Item2), @@ -1743,12 +1743,12 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile), TorqueConverterRatio = i == 0 ? ratio : double.NaN, TorqueConverterGearLossMap = i == 0 - ? TransmissionLossMapReader.Create( 0.98, ratio, string.Format("Gear {0}", i)) + ? TransmissionLossMapReader.Create( 0.98, ratio, $"Gear {i}") : null, //TorqueConverterShiftPolygon = i == 0 ? ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) : null })).ToDictionary(k => k.Item1 + 1, v => v.Item2), @@ -1773,12 +1773,12 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile), TorqueConverterRatio = i == 0 ? 1.0 : double.NaN, TorqueConverterGearLossMap = i == 0 - ? TransmissionLossMapReader.Create(1.0, ratio, string.Format("Gear {0}", i)) + ? TransmissionLossMapReader.Create(1.0, ratio, $"Gear {i}") : null, //TorqueConverterShiftPolygon = i == 0 ? ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) : null })).ToDictionary(k => k.Item1 + 1, v => v.Item2), diff --git a/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs b/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs index 1750f7709bfed9ffe59505b1614c10224c0da19d..def6f4ae4fde19eebd27f0fde3ad405f4462e699 100644 --- a/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs @@ -102,7 +102,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Multistage jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); using (var xmlReader = XmlReader.Create(writer.XMLMultistageReportFileName)) { var validator = new XMLValidator(xmlReader); @@ -140,7 +140,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Multistage jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); using (var xmlReader = XmlReader.Create(writer.XMLMultistageReportFileName)) { @@ -348,8 +348,8 @@ namespace TUGraz.VectoCore.Tests.Integration.Multistage jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat<Exception>(jobContainer.Runs.Select(r => r.ExecException))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException))); } [TestCase()] @@ -425,8 +425,8 @@ namespace TUGraz.VectoCore.Tests.Integration.Multistage jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat<Exception>(jobContainer.Runs.Select(r => r.ExecException))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException))); } diff --git a/VectoCore/VectoCoreTest/Integration/RoadSweepers/RoadSweeperTests.cs b/VectoCore/VectoCoreTest/Integration/RoadSweepers/RoadSweeperTests.cs index 47e8f8d7a33b641535fd9ff7c68e9e4126f8bdc4..309efab926658ed494f85bc8e0a80a90bb5f0743 100644 --- a/VectoCore/VectoCoreTest/Integration/RoadSweepers/RoadSweeperTests.cs +++ b/VectoCore/VectoCoreTest/Integration/RoadSweepers/RoadSweeperTests.cs @@ -214,7 +214,7 @@ namespace TUGraz.VectoCore.Tests.Integration.RoadSweepers jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); } @@ -253,7 +253,7 @@ namespace TUGraz.VectoCore.Tests.Integration.RoadSweepers jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); } public class EngineeringJobInputData : IEngineeringInputDataProvider, IEngineeringJobInputData @@ -262,13 +262,13 @@ namespace TUGraz.VectoCore.Tests.Integration.RoadSweepers #region Implementation of IInputDataProvider - public DataSource DataSource { get { return new DataSource(); } } + public DataSource DataSource => new DataSource(); #endregion #region Implementation of IEngineeringInputDataProvider - public IEngineeringJobInputData JobInputData { get { return this; } } + public IEngineeringJobInputData JobInputData => this; public IDriverEngineeringInputData DriverInputData { get; set; } #endregion @@ -281,14 +281,11 @@ namespace TUGraz.VectoCore.Tests.Integration.RoadSweepers public IHybridStrategyParameters HybridStrategyParameters { get; } public IList<ICycleData> Cycles { get; set; } public VectoSimulationJobType JobType { get; } - public bool EngineOnlyMode { get { return false; } } - public IEngineEngineeringInputData EngineOnly { get { return null; } } + public bool EngineOnlyMode => false; + public IEngineEngineeringInputData EngineOnly => null; public TableData PTOCycleWhileDrive { get; set; } - IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle - { - get { return Vehicle; } - } + IVehicleDeclarationInputData IDeclarationJobInputData.Vehicle => Vehicle; public string JobName { get; set; } public string ShiftStrategy { get; } @@ -297,10 +294,7 @@ namespace TUGraz.VectoCore.Tests.Integration.RoadSweepers #region Implementation of IDeclarationJobInputData - bool IDeclarationJobInputData.SavedInDeclarationMode - { - get { return _savedInDeclarationMode; } - } + bool IDeclarationJobInputData.SavedInDeclarationMode => _savedInDeclarationMode; #endregion } diff --git a/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs b/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs index e3a50bb7821ca2255d3fdb5c3000155c7e226121..3d024f5dd3c4fb2e898a85c09c28e73ea450400b 100644 --- a/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs +++ b/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs @@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ShiftStrategy string.Format(CultureInfo.InvariantCulture, "1000, {1}, {2}, 0", v1, v2, slope), string.Format(CultureInfo.InvariantCulture, "1100, {1}, 0, 0", v1, v2, slope) }; - System.IO.Directory.CreateDirectory(string.Format(@"Shiftt_{0}_{1}", v1, v2, slope)); + Directory.CreateDirectory(string.Format(@"Shiftt_{0}_{1}", v1, v2, slope)); var slopePrefix = ""; if (!slope.IsEqual(0)) { slopePrefix = slope > 0 ? "uh_" : "dh_"; diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index a4e46f489499a0966fe906469d1b5214188ea992..4dfc179aca1dd162c11ba9f7b725c2080e16fd6e 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -106,7 +106,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var cycle = new DistanceBasedDrivingCycle(container, cycleData); var cyclePort = cycle.OutPort(); - cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy(container))) + cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy(container))) .AddComponent(new Vehicle(container, vehicleData, airDragData)) .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) .AddComponent(new Brakes(container)) @@ -125,22 +125,26 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var cnt = 0; do { response = cyclePort.Request(absTime, ds); - response.Switch(). - Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseCycleFinished>(r => { }). - Case<ResponseSuccess>(r => { + switch (response) { + case ResponseCycleFinished _: + break; + case ResponseDrivingCycleDistanceExceeded r: + ds = r.MaxDistance; + break; + case ResponseSuccess r: container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance : Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed; - if (cnt++ % 100 == 0) { modData.Finish(VectoRun.Status.Success); } - }). - Default(r => Assert.Fail("Unexpected Response: {0}", r)); + break; + default: + Assert.Fail("Unexpected Response: {0}", response); + break; + } } while (!(response is ResponseCycleFinished)); modData.Finish(VectoRun.Status.Success); Assert.IsInstanceOf<ResponseCycleFinished>(response); @@ -157,7 +161,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var vehicleData = CreateVehicleData(3300.SI<Kilogram>()); var driverData = CreateDriverData(AccelerationFile); var airDragData = CreateAirdragData(); - + var runData = new VectoRunData() { JobName = "Coach_FullPowertrain", EngineData = engineData, @@ -176,7 +180,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var cycle = new DistanceBasedDrivingCycle(container, cycleData); - var cyclePort = cycle.OutPort(); + var cyclePort = cycle.OutPort(); cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy(container))) .AddComponent(new Vehicle(container, vehicleData, airDragData)) .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) @@ -210,23 +214,29 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns } Log.Info("Test Got Response: {0},", response); - response.Switch(). - Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseCycleFinished>(r => { }). - Case<ResponseGearShift>(r => { Log.Debug("Gearshift"); }). - Case<ResponseSuccess>(r => { + switch (response) { + case ResponseCycleFinished _: + break; + case ResponseDrivingCycleDistanceExceeded r: + ds = r.MaxDistance; + break; + case ResponseGearShift _: + Log.Debug("Gearshift"); + break; + case ResponseSuccess r: container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance : Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed; - if (cnt++ % 100 == 0) { modData.Finish(VectoRun.Status.Success); } - }). - Default(r => Assert.Fail("Unexpected Response: {0}", r)); + break; + default: + Assert.Fail("Unexpected Response: {0}", response); + break; + } } modData.Finish(VectoRun.Status.Success); Assert.IsInstanceOf<ResponseSuccess>(response); @@ -292,26 +302,30 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns } Log.Info("Test Got Response: {0},", response); - response.Switch(). - Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseCycleFinished>(r => { }). - Case<ResponseGearShift>(r => { Log.Debug("Gearshift"); }). - Case<ResponseSuccess>(r => { + switch (response) { + case ResponseCycleFinished _: + break; + case ResponseDrivingCycleDistanceExceeded r: + ds = r.MaxDistance; + break; + case ResponseGearShift _: + Log.Debug("Gearshift"); + break; + case ResponseSuccess r: container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance : Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed; - if (cnt++ % 100 == 0) { modData.Finish(VectoRun.Status.Success); } - }). - Default(r => { + break; + default: modData.Finish(VectoRun.Status.Success); - Assert.Fail("Unexpected Response: {0}", r); - }); + Assert.Fail("Unexpected Response: {0}", response); + break; + } } modData.Finish(VectoRun.Status.Success); Assert.IsInstanceOf<ResponseCycleFinished>(response); @@ -347,8 +361,8 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { -// MaxTorque = ratio > 5 ? 2300.SI<NewtonMeter>() : null, - LossMap = TransmissionLossMapReader.ReadFromFile(GearboxLossMap, ratio, string.Format("Gear {0}", i)), + // MaxTorque = ratio > 5 ? 2300.SI<NewtonMeter>() : null, + LossMap = TransmissionLossMapReader.ReadFromFile(GearboxLossMap, ratio, $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) @@ -441,7 +455,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns private static AirdragData CreateAirdragData() { - return new AirdragData() { + return new AirdragData { CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(3.2634.SI<SquareMeter>(), CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), @@ -458,9 +472,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns //Deceleration = -0.5.SI<MeterPerSquareSecond>() LookAheadDecisionFactor = new LACDecisionFactor() }, - OverSpeed = new DriverData.OverSpeedData { - Enabled = false - }, + OverSpeed = new DriverData.OverSpeedData { Enabled = false } }; } } diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs index 106437d8e235251e0edd8c8ad536ba36c9c60fa0..cba3cbc4320426276fec74b6c97d6995d31d9fc1 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs @@ -91,7 +91,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns }; var modData = new ModalDataContainer(runData, fileWriter, null); var container = new VehicleContainer(ExecutionMode.Engineering, modData) { - RunData = new VectoRunData() { + RunData = new VectoRunData() { VehicleData = vehicleData, DriverData = driverData } @@ -106,6 +106,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns .AddComponent(engine); var gbx = new MockGearbox(container); + // ReSharper disable once ObjectCreationAsStatement new DummyCycle(container); var driverPort = driver.OutPort(); @@ -140,8 +141,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var driverData = CreateDriverData(AccelerationFile); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrain"); - var runData = new VectoRunData() - { + var runData = new VectoRunData() { JobName = "Coach_MinimalPowertrain", VehicleData = vehicleData, EngineData = engineData, @@ -170,13 +170,10 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns .AddComponent(new CombustionEngine(container, engineData)); //engine.IdleController.RequestPort = clutch.IdleControlPort; - var gbx = new MockGearbox(container); - gbx.Gear = new GearshiftPosition(0); + var gbx = new MockGearbox(container) { Gear = new GearshiftPosition(0) }; var cyclePort = cycle.OutPort(); - cyclePort.Initialize(); - gbx.Gear = new GearshiftPosition(0); var absTime = 0.SI<Second>(); @@ -190,29 +187,30 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var cnt = 0; while (!(response is ResponseCycleFinished) && container.MileageCounter.Distance < 17000) { response = cyclePort.Request(absTime, ds); - response.Switch(). - Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseCycleFinished>(r => { }). - Case<ResponseSuccess>(r => { + switch (response) { + case ResponseCycleFinished _: + break; + case ResponseDrivingCycleDistanceExceeded r: + ds = r.MaxDistance; + break; + case ResponseSuccess r: container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed) - .Cast<Meter>(); - + : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed).Cast<Meter>(); if (cnt++ % 100 == 0) { modData.Finish(VectoRun.Status.Success); } - }). - Default(r => Assert.Fail("Unexpected Response: {0}", r)); + break; + default: + Assert.Fail("Unexpected Response: {0}", response); + break; + } } Assert.IsInstanceOf<ResponseCycleFinished>(response); - modData.Finish(VectoRun.Status.Success); - NLog.LogManager.EnableLogging(); } @@ -229,8 +227,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var driverData = CreateDriverData(AccelerationFile2); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrainOverload"); - var runData = new VectoRunData() - { + var runData = new VectoRunData() { JobName = "Coach_MinimalPowertrain", SimulationType = SimulationType.DistanceCycle, VehicleData = vehicleData, @@ -269,19 +266,19 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var ds = Constants.SimulationSettings.DriveOffDistance; while (container.MileageCounter.Distance < 100) { var response = cyclePort.Request(absTime, ds); - response.Switch(). - Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseSuccess>(r => { + switch (response) { + case ResponseDrivingCycleDistanceExceeded r: + ds = r.MaxDistance; + break; + case ResponseSuccess r: container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed) - .Cast<Meter>(); - + : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed).Cast<Meter>(); modData.Finish(VectoRun.Status.Success); - }); + break; + } } modData.Finish(VectoRun.Status.Success); diff --git a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs index 4920c206a530c4dc0e411e133160a4ffff87531d..1a36bd0abcafd967fd32d1547fea96b7e2e42781 100644 --- a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs @@ -157,7 +157,7 @@ namespace TUGraz.VectoCore.Tests.Integration //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(ShiftPolygonFile) })).ToDictionary(k => k.Item1 + 1, v => v.Item2), diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index 8d59e5783ee18052d1ff3eda53673c442cfdca72..255c280cec46a2ce71ce3acdbeb32a865f1be010 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -629,7 +629,10 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration weight.SI<Kilogram>(), 0.SI<Kilogram>(), false), - string.Format("ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}", VehicleCategory.RigidTruck, AxleConfiguration.AxleConfig_4x2.GetName(), weight.SI<Kilogram>())); + $"ERROR: Could not find the declaration segment for vehicle. " + + $"Category: {VehicleCategory.RigidTruck}, " + + $"AxleConfiguration: {AxleConfiguration.AxleConfig_4x2.GetName()}, " + + $"GrossVehicleWeight: {weight.SI<Kilogram>()}"); } [ @@ -647,7 +650,10 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration weight.SI<Kilogram>(), 0.SI<Kilogram>(), false), - string.Format("ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}", VehicleCategory.RigidTruck, AxleConfiguration.AxleConfig_4x4.GetName(), weight.SI<Kilogram>())); + $"ERROR: Could not find the declaration segment for vehicle. " + + $"Category: {VehicleCategory.RigidTruck}, " + + $"AxleConfiguration: {AxleConfiguration.AxleConfig_4x4.GetName()}, " + + $"GrossVehicleWeight: {weight.SI<Kilogram>()}"); } [Test, diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs index 81e89dd9e6b59b8acac29486b94c084e2bb6c45e..2251a040c9008f47f6c4d7f87710b93b79e3d4d2 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs @@ -717,7 +717,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration } if (kitchenStandard.HasValue) { retVal["Kitchen Standard"] = kitchenStandard.Value; - }; + } + return retVal; } diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index 9da5f36fb6d7333ea7538b64775604be6302f518..45bad7552f1271ba7fbf06ad9db49781b3b0e331 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -576,10 +576,9 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftPolygons.Add(DeclarationData.Gearbox.ComputeShiftPolygon(GearboxType.AMT, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn, null)); - List<Point> tmp1, tmp2, tmp3; ShiftPolygonComparison.ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn, out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); downshiftOrig.Add(tmp3); @@ -596,11 +595,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftLines += "Gear " + gear + "\n"; shiftLines += "Upshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Upshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } shiftLines += "Downshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Downshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } } } @@ -636,10 +635,9 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftPolygons.Add(DeclarationData.Gearbox.ComputeShiftPolygon(GearboxType.AMT, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn, null)); - List<Point> tmp1, tmp2, tmp3; ShiftPolygonComparison.ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn, out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); downshiftOrig.Add(tmp3); @@ -656,11 +654,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftLines += "Gear " + gear + "\n"; shiftLines += "Upshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Upshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } shiftLines += "Downshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Downshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } } } @@ -739,9 +737,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration DeclarationData.Gearbox.ComputeShiftPolygon(gearboxData.Type, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn.SI<Meter>(), null) ); - List<Point> tmp1, tmp2, tmp3; ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn.SI<Meter>(), out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn.SI<Meter>(), out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); } @@ -759,11 +756,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration str += "Gear " + g + "\n"; str += "downshift\n"; foreach (var entry in shiftPolygon.Downshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } str += "upshift\n"; foreach (var entry in shiftPolygon.Upshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } g++; } @@ -897,9 +894,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration DeclarationData.Gearbox.ComputeShiftPolygon(gearboxData.Type, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn, null) ); - List<Point> tmp1, tmp2, tmp3; ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn, out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); } @@ -915,11 +911,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration str += "Gear " + g + "\n"; str += "downshift\n"; foreach (var entry in shiftPolygon.Downshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } str += "upshift\n"; foreach (var entry in shiftPolygon.Upshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } g++; } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs index 3b7b8bce436008f7224e824ef29eccd9ad9c78bd..949e4396bd99d65745f235ec0e3bd69ae55b8b6e 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs @@ -138,9 +138,11 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation for (var i = 0; i < 100; i++) { response = cycle.OutPort().Request(absTime, dt); - response.Switch() - .Case<ResponseFailTimeInterval>(r => dt = r.DeltaT) - .Case<ResponseSuccess>(r => { + switch (response) { + case ResponseFailTimeInterval r: + dt = r.DeltaT; + break; + case ResponseSuccess _: container.CommitSimulationStep(absTime, dt); Assert.AreEqual(absTime, outPort.AbsTime); Assert.AreEqual(dt, outPort.Dt); @@ -158,8 +160,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation absTime += dt; dt = 1.SI<Second>(); - }) - .Default(r => { throw new UnexpectedResponseException("Got an unexpected response", r); }); + break; + default: + throw new UnexpectedResponseException("Got an unexpected response", response); + } } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs index 2b0f28f3e37522ebccae43a4cb6724255251ed5a..e7fdd14ffb450f66950c05f118c7a3e9e13e2683 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs @@ -49,15 +49,15 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation for (var vTarget = vVehicle; vTarget > 0; vTarget -= 1.KMPHtoMeterPerSecond()) { var df_coast = new LACDecisionFactor().Lookup(vTarget, vVehicle - vTarget); if (vTarget < 48.KMPHtoMeterPerSecond()) { - AssertHelper.AreRelativeEqual(df_coast, 2.5, string.Format("vVehicle: {0}, vTarget: {1}", vVehicle, vTarget)); + AssertHelper.AreRelativeEqual(df_coast, 2.5, $"vVehicle: {vVehicle}, vTarget: {vTarget}"); } if (vVehicle - vTarget > 11) { - AssertHelper.AreRelativeEqual(df_coast, 2.5, string.Format("vVehicle: {0}, vTarget: {1}", vVehicle, vTarget)); + AssertHelper.AreRelativeEqual(df_coast, 2.5, $"vVehicle: {vVehicle}, vTarget: {vTarget}"); } if (vTarget > 52.KMPHtoMeterPerSecond() && vVehicle - vTarget < 9.KMPHtoMeterPerSecond()) { - AssertHelper.AreRelativeEqual(df_coast, 1.0, string.Format("vVehicle: {0}, vTarget: {1}", vVehicle, vTarget)); + AssertHelper.AreRelativeEqual(df_coast, 1.0, $"vVehicle: {vVehicle}, vTarget: {vTarget}"); } } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs index 54c2a9ee725e251b89941ba056795151d55f7f1b..fd782aaed4c0e9a95d953ad23803bd23b8e7caeb 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs @@ -203,7 +203,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation new GearData { // MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(!ratio.IsEqual(1.0) ? directlossMap : indirectLossMap, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(ShiftPolygonFile) })) @@ -284,7 +284,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); foreach (var r in jobContainer.Runs) { - Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException)); + Assert.IsTrue(r.Run.FinishedWithoutErrors, $"{r.ExecException}"); } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/ShiftStrategyV2Test.cs b/VectoCore/VectoCoreTest/Models/Simulation/ShiftStrategyV2Test.cs index 80cf1d33da17ad8a791309a910b32d2d0c77ff36..6cce70c95eff8275ab29dffea6752f7866d6989a 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/ShiftStrategyV2Test.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/ShiftStrategyV2Test.cs @@ -325,8 +325,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat<Exception>(jobContainer.Runs.Select(r => r.ExecException))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException))); } @@ -366,8 +366,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.Execute(); jobContainer.WaitFinished(); var progress = jobContainer.GetProgress(); - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), String.Concat<Exception>(jobContainer.Runs.Select(r => r.ExecException))); + Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat(progress.Select(r => r.Value.Error))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), String.Concat(jobContainer.Runs.Select(r => r.ExecException))); } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/SimulationPreprocessingTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/SimulationPreprocessingTest.cs index 62433b2106f5eccff6aee0dfe8ce6e5820b31a20..f154d32a4a84e693d3e4313fcc84e6886e0fc211 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/SimulationPreprocessingTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/SimulationPreprocessingTest.cs @@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var lookup = SimulationRunPreprocessingEcoRoll(jobContainer.Runs[i].Run); - Console.WriteLine(string.Format("run: {0}{1} vehicle mass: {2}", jobContainer.Runs[i].Run.RunName, jobContainer.Runs[i].Run.RunSuffix, jobContainer.Runs[i].Run.GetContainer().RunData.VehicleData.TotalVehicleMass)); + Console.WriteLine("run: {0}{1} vehicle mass: {2}", jobContainer.Runs[i].Run.RunName, jobContainer.Runs[i].Run.RunSuffix, jobContainer.Runs[i].Run.GetContainer().RunData.VehicleData.TotalVehicleMass); foreach (var tuple in lookup) { Console.WriteLine("velocity: {0}, slope: {1},", tuple.Key, tuple.Value); } @@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var lookup = SimulationRunPreprocessingEcoRoll(jobContainer.Runs[i].Run); - Console.WriteLine(string.Format("run: {0}{1} vehicle mass: {2}", jobContainer.Runs[i].Run.RunName, jobContainer.Runs[i].Run.RunSuffix, jobContainer.Runs[i].Run.GetContainer().RunData.VehicleData.TotalVehicleMass)); + Console.WriteLine("run: {0}{1} vehicle mass: {2}", jobContainer.Runs[i].Run.RunName, jobContainer.Runs[i].Run.RunSuffix, jobContainer.Runs[i].Run.GetContainer().RunData.VehicleData.TotalVehicleMass); foreach (var tuple in lookup) { Console.WriteLine("velocity: {0}, slope: {1},", tuple.Key, tuple.Value); } @@ -136,7 +136,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var segments = SimulationRunPreprocessingPCCSegments(jobContainer.Runs[i].Run); - Console.WriteLine(string.Format("run: {0}{1} vehicle mass: {2}", jobContainer.Runs[i].Run.RunName, jobContainer.Runs[i].Run.RunSuffix, jobContainer.Runs[i].Run.GetContainer().RunData.VehicleData.TotalVehicleMass)); + Console.WriteLine("run: {0}{1} vehicle mass: {2}", jobContainer.Runs[i].Run.RunName, jobContainer.Runs[i].Run.RunSuffix, jobContainer.Runs[i].Run.GetContainer().RunData.VehicleData.TotalVehicleMass); foreach (var entry in segments.Segments) { Console.WriteLine("x_start: {0}, x_vLow: {1}, x_end: {2}", entry.StartDistance, entry.DistanceMinSpeed, entry.EndDistance); } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs index 260e0744e603c91a55fd1abbb8747f565399e1d7..32122b7005c4b72c6b040a2bb985a22b5c2b7a9e 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs @@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); foreach (var r in jobContainer.Runs) { - Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException)); + Assert.IsTrue(r.Run.FinishedWithoutErrors, $"{r.ExecException}"); } ResultFileHelper.TestModFile(expected, actual); @@ -132,7 +132,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); foreach (var run in jobContainer.Runs) { - Assert.IsTrue(run.Run.FinishedWithoutErrors, string.Format("{0}", run.ExecException)); + Assert.IsTrue(run.Run.FinishedWithoutErrors, $"{run.ExecException}"); } ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\24t Coach EngineOnly.vsum", diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs index 0cee2a4fc8e67c0c439964b4992b710df0cd856b..27530fdf0d401cfd5a73408619598a39329168f0 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs @@ -125,7 +125,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC-{0}.vmod", gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); @@ -141,7 +141,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC_shiftup-{0}.vmod", gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC_shiftup-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); @@ -157,7 +157,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC_shiftdown-{0}.vmod", gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC_shiftdown-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); @@ -181,14 +181,12 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.ReadDeclarationCycle(cycleName); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC_{0}-{1}.vmod", cycleName, gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC_{cycleName}-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); var sumWriter = new SummaryDataContainer( new FileOutputWriter( - string.Format( - "AT_Vehicle_Drive-TC_{0}-{1}", cycleName, - gbxType == GearboxType.ATSerial ? "ser" : "ps"))); + $"AT_Vehicle_Drive-TC_{cycleName}-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}")); ((VehicleContainer)run.GetContainer()).WriteSumData = (modData) => sumWriter.Write(run.GetContainer().ModalData, 0, 0, run.GetContainer().RunData); run.Run(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs index d1689caf54db7d7f4eb34481798a2a80cc2c6d75..6a17fa00a854d0a252716708657d231dbfca1607 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs @@ -196,10 +196,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public PerSecond EngineN95hSpeed { get; set; } public PerSecond EngineN80hSpeed { get; set; } - public bool EngineOn - { - get { throw new System.NotImplementedException(); } - } + public bool EngineOn => throw new System.NotImplementedException(); protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) { diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs index b0c6c9d4d8351cac25c758e6cd95a77372a91016..936f118c7886ce0de584304e000cd64f18af3a21 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs @@ -213,7 +213,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent engine.CommitSimulationStep(t, dt, modalData); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(0), t.Value(), 0.001, "Time"); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(1), ((SI)modalData[ModalResultField.P_ice_full]).Value(), 0.1, - string.Format("Load in timestep {0}", t)); + $"Load in timestep {t}"); modalData.CommitSimulationStep(); } modalData.Finish(VectoRun.Status.Success); @@ -270,7 +270,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent engine.CommitSimulationStep(t, dt, modalData); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(0), t.Value(), 0.001, "Time"); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(1), ((SI)modalData[ModalResultField.P_ice_full]).Value(), 0.1, - string.Format("Load in timestep {0}", t)); + $"Load in timestep {t}"); modalData.CommitSimulationStep(); } modalData.Finish(VectoRun.Status.Success); @@ -349,11 +349,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent [TestCase] public void EngineIdleControllerTestCoach() { - VehicleContainer container; - CombustionEngine engine; - ITnOutPort requestPort; - MockGearbox gearbox; - VehicleContainer(CoachEngine, out container, out engine, out requestPort, out gearbox); + VehicleContainer(CoachEngine, out var container, out var engine, out var requestPort, out var gearbox); var absTime = 0.SI<Second>(); var dt = Constants.SimulationSettings.TargetTimeInterval; @@ -404,11 +400,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent [TestCase] public void EngineIdleControllerTestTruck() { - VehicleContainer container; - CombustionEngine engine; - ITnOutPort requestPort; - MockGearbox gearbox; - VehicleContainer(TruckEngine, out container, out engine, out requestPort, out gearbox); + VehicleContainer(TruckEngine, out var container, out var engine, out var requestPort, out var gearbox); //var dataWriter = new ModalDataWriter("EngineIdle.vmod"); //container.DataWriter = dataWriter; @@ -448,8 +440,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent container.CommitSimulationStep(absTime, dt); engSpeedResults.Add(new { absTime, engine.PreviousState.EngineSpeed, engine.PreviousState.EnginePower }); - Assert.AreEqual(engineSpeed[i], engine.PreviousState.EngineSpeed.AsRPM, Tolerance, string.Format("entry {0}", i)); - Assert.AreEqual(enginePower[i], engine.PreviousState.EnginePower.Value(), Tolerance, string.Format("entry {0}", i)); + Assert.AreEqual(engineSpeed[i], engine.PreviousState.EngineSpeed.AsRPM, Tolerance, $"entry {i}"); + Assert.AreEqual(enginePower[i], engine.PreviousState.EnginePower.Value(), Tolerance, $"entry {i}"); absTime += dt; } //dataWriter.Finish(); @@ -458,11 +450,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent [TestCase] public void EngineIdleControllerTest2Truck() { - VehicleContainer container; - CombustionEngine engine; - ITnOutPort requestPort; - MockGearbox gearbox; - VehicleContainer(TruckEngine, out container, out engine, out requestPort, out gearbox); + VehicleContainer(TruckEngine, out var container, out var engine, out var requestPort, out var gearbox); //var dataWriter = new ModalDataWriter("EngienIdle.vmod"); //container.DataWriter = dataWriter; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs index 7bf16a1b137bb126a817deda375dddbf9ff70f2d..f51d0443de5e366a56a4d82829090a901a8252fe 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs @@ -313,35 +313,17 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent #region Implementation of IVehicleInfo - public MeterPerSecond VehicleSpeed - { - get { return 0.SI<MeterPerSecond>(); } - } + public MeterPerSecond VehicleSpeed => 0.SI<MeterPerSecond>(); - public bool VehicleStopped - { - get { throw new System.NotImplementedException(); } - } + public bool VehicleStopped => throw new System.NotImplementedException(); - public Kilogram VehicleMass - { - get { throw new System.NotImplementedException(); } - } + public Kilogram VehicleMass => throw new System.NotImplementedException(); - public Kilogram VehicleLoading - { - get { throw new System.NotImplementedException(); } - } + public Kilogram VehicleLoading => throw new System.NotImplementedException(); - public Kilogram TotalMass - { - get { throw new System.NotImplementedException(); } - } + public Kilogram TotalMass => throw new System.NotImplementedException(); - public CubicMeter CargoVolume - { - get { throw new System.NotImplementedException(); } - } + public CubicMeter CargoVolume => throw new System.NotImplementedException(); public Newton AirDragResistance(MeterPerSecond previousVelocity, MeterPerSecond nextVelocity) { @@ -358,10 +340,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent throw new System.NotImplementedException(); } - public MeterPerSecond MaxVehicleSpeed - { - get { throw new System.NotImplementedException(); } - } + public MeterPerSecond MaxVehicleSpeed => throw new System.NotImplementedException(); #endregion } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs index cf51cae361edd0889b207b6963835d6813f780f4..08dbcfdcd569eed5cea2c2cec7c32baf7502cdf1 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs @@ -86,11 +86,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public void TestShiftLossComputation(double torqueDemand, uint gear, double preShiftRpm, double postShiftRpm, double expectedShiftLoss, double expectedShiftLossEnergy) { - AxleGear axleGear; - ATGearbox gbx; - CombustionEngine engine; var cycleDataStr = "0, 0, 0, 2\n100, 20, 0, 0\n1000, 50, 0, 0"; - var container = CreateVehicle(cycleDataStr, preShiftRpm, out axleGear, out gbx, out engine); + var container = CreateVehicle(cycleDataStr, preShiftRpm, out var axleGear, out var gbx, out var engine); new ATClutchInfo(container); gbx.Gear = new GearshiftPosition(gear, true); @@ -138,11 +135,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public void TestSplittingShiftLossesTwoIntervals(double torqueDemand, uint gear, double preShiftRpm, double postShiftRpm, double expectedShiftLoss, double expectedShiftLossEnergy) { - AxleGear axleGear; - ATGearbox gbx; - CombustionEngine engine; var cycleDataStr = "0, 0, 0, 2\n100, 20, 0, 0\n1000, 50, 0, 0"; - var container = CreateVehicle(cycleDataStr, preShiftRpm, out axleGear, out gbx, out engine); + var container = CreateVehicle(cycleDataStr, preShiftRpm, out var axleGear, out var gbx, out var engine); var modData = new MockModalDataContainer(); gbx.Gear = new GearshiftPosition(gear, true); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index df4c5cff9fe53af99fd093a2b712e6aa8a715fc7..78f092674ae9e186a6a90721d1a479bc17915054 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent new GearData { // MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(i != 6 ? IndirectLossMap : DirectLossMap, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs index 2a7587283954233c0242795bb726b1da1cf50483..4ad8f1fdc2f39e5154c3dacc61572e17db47376f 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs @@ -324,7 +324,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", (i / 2.0).ToString(CultureInfo.InvariantCulture), ((fcLimit * 1.01 * (1 - i/100000.0)).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)); + cycleEntries += $" {(i / 2.0).ToString(CultureInfo.InvariantCulture)} , 0, 600, 400, 500 , 500 , 100 , 100 , {((fcLimit * 1.01 * (1 - i / 100000.0)).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)}, 3 \n"; var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { @@ -354,7 +354,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", (i / 2.0).ToString(CultureInfo.InvariantCulture), ((fcLimit * 1.0001).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)); + cycleEntries += $" {(i / 2.0).ToString(CultureInfo.InvariantCulture)} , 0, 600, 400, 500 , 500 , 100 , 100 , {((fcLimit * 1.0001).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)}, 3 \n"; var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { @@ -383,7 +383,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", (i / 2.0).ToString(CultureInfo.InvariantCulture), ((fcLimit * 0.99 * (1 + i / 100000.0)).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)); + cycleEntries += $" {(i / 2.0).ToString(CultureInfo.InvariantCulture)} , 0, 600, 400, 500 , 500 , 100 , 100 , {((fcLimit * 0.99 * (1 + i / 100000.0)).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)}, 3 \n"; var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { @@ -412,7 +412,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", (i / 2.0).ToString(CultureInfo.InvariantCulture), ((fcLimit * 0.9999).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)); + cycleEntries += $" {(i / 2.0).ToString(CultureInfo.InvariantCulture)} , 0, 600, 400, 500 , 500 , 100 , 100 , {((fcLimit * 0.9999).ConvertToGrammPerHour().Value).ToString(CultureInfo.InvariantCulture)}, 3 \n"; var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs index 891f0cd4d310aadc4519d3afef7395e7f653ec8d..f2a5b141995b56d23b7ba8b76353e267d834cc37 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs @@ -256,45 +256,24 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent #region Implementation of IDrivingCycleInfo - public CycleData CycleData - { - get { throw new NotImplementedException(); } - } + public CycleData CycleData => throw new NotImplementedException(); - public bool PTOActive - { - get { throw new NotImplementedException(); } - } + public bool PTOActive => throw new NotImplementedException(); public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance) { throw new NotImplementedException(); } - public Meter Altitude - { - get { throw new NotImplementedException(); } - } + public Meter Altitude => throw new NotImplementedException(); - public Radian RoadGradient - { - get { throw new NotImplementedException(); } - } + public Radian RoadGradient => throw new NotImplementedException(); - public MeterPerSecond TargetSpeed - { - get { throw new NotImplementedException(); } - } + public MeterPerSecond TargetSpeed => throw new NotImplementedException(); - public Second StopTime - { - get { throw new NotImplementedException(); } - } + public Second StopTime => throw new NotImplementedException(); - public Meter CycleStartDistance - { - get { return 0.SI<Meter>(); } - } + public Meter CycleStartDistance => 0.SI<Meter>(); public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) { @@ -306,10 +285,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent throw new NotImplementedException(); } - public SpeedChangeEntry LastTargetspeedChange - { - get { throw new NotImplementedException(); } - } + public SpeedChangeEntry LastTargetspeedChange => throw new NotImplementedException(); public void FinishSimulation() { diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs index 1e26aac4e0013a0d166f1c462cfeb46d2b671ed4..a1151ca3fa99b642a6ee5f0a593dfc0a4076fbb2 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs @@ -471,56 +471,32 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData #region 4 parent instance properties [Required, System.ComponentModel.DataAnnotations.Range(11, 12)] - private int private_parent_property - { - get { return 7; } - } + private int private_parent_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(13, 14)] - protected int protected_parent_property - { - get { return 7; } - } + protected int protected_parent_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(15, 16)] - internal int internal_parent_property - { - get { return 7; } - } + internal int internal_parent_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(17, 18)] - public int public_parent_property - { - get { return 7; } - } + public int public_parent_property => 7; #endregion #region 4 parent static properties [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - private static int private_static_parent_property - { - get { return 7; } - } + private static int private_static_parent_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - protected static int protected_static_parent_property - { - get { return 7; } - } + protected static int protected_static_parent_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - internal static int internal_static_parent_property - { - get { return 7; } - } + internal static int internal_static_parent_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - public static int public_static_parent_property - { - get { return 7; } - } + public static int public_static_parent_property => 7; #endregion @@ -560,56 +536,32 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData #region 4 instance properties [Required, System.ComponentModel.DataAnnotations.Range(11, 12)] - private int private_property - { - get { return 7; } - } + private int private_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(13, 14)] - protected int protected_property - { - get { return 7; } - } + protected int protected_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(15, 16)] - internal int internal_property - { - get { return 7; } - } + internal int internal_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(17, 18)] - public int public_property - { - get { return 7; } - } + public int public_property => 7; #endregion #region 4 static properties [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - private static int private_static_property - { - get { return 7; } - } + private static int private_static_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - protected static int protected_static_property - { - get { return 7; } - } + protected static int protected_static_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - internal static int internal_static_property - { - get { return 7; } - } + internal static int internal_static_property => 7; [Required, System.ComponentModel.DataAnnotations.Range(19, 20)] - public static int public_static_property - { - get { return 7; } - } + public static int public_static_property => 7; #endregion @@ -638,10 +590,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData public string AppVersion { get; set; } public string TechnicalReportId { get; set; } - public CertificationMethod CertificationMethod - { - get { return CertificationMethod.NotCertified; } - } + public CertificationMethod CertificationMethod => CertificationMethod.NotCertified; public string CertificationNumber { get; set; } public DigestData DigestValue { get; set; } diff --git a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs index d981033fc4ca1a7de4b41430a244ba7bbeec52b0..c6680bc1cba6c5891213cbc1686de7832105357d 100644 --- a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs @@ -267,7 +267,7 @@ namespace TUGraz.VectoCore.Tests.Reports continue; } var numParts = parts[i].Split('.'); - Assert.AreEqual(2, numParts.Length, string.Format("Line {0}: column {1}: value {2}", lineCnt, i, parts[i])); + Assert.AreEqual(2, numParts.Length, $"Line {lineCnt}: column {i}: value {parts[i]}"); Assert.IsTrue(numParts[0].Length > 0); Assert.AreEqual(4, numParts[1].Length); } diff --git a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs index f07d2933f2250c215071ba03dbd3e91804245554..0d5ffdf3bf5974dbaabfca9de3962795c6dcdcdd 100644 --- a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs +++ b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Tests.Utils double toleranceFactor = DoubleExtensionMethods.ToleranceFactor, string message = null) { Assert.IsTrue(actual.HasEqualUnit(expected), - string.Format("Wrong SI Units: expected: {0}, actual: {1}", expected.ToBasicUnits(), actual.ToBasicUnits())); + $"Wrong SI Units: expected: {expected.ToBasicUnits()}, actual: {actual.ToBasicUnits()}"); AreRelativeEqual(expected.Value(), actual.Value(), toleranceFactor: toleranceFactor, message: message); } @@ -105,7 +105,7 @@ namespace TUGraz.VectoCore.Tests.Utils if (double.IsNaN(expected.Value)) { Assert.IsTrue(double.IsNaN(actual.Value), - string.Format("Actual value is not NaN. Expected: {0}, Actual: {1}{2}", expected, actual, message)); + $"Actual value is not NaN. Expected: {expected}, Actual: {actual}{message}"); return; } diff --git a/VectoCore/VectoCoreTest/Utils/GraphWriter.cs b/VectoCore/VectoCoreTest/Utils/GraphWriter.cs index 2df475d9d13d9e1b84fa59fcb1a5578362f96f29..3951ad1661c967b405c7d2f924862a781d2b920d 100644 --- a/VectoCore/VectoCoreTest/Utils/GraphWriter.cs +++ b/VectoCore/VectoCoreTest/Utils/GraphWriter.cs @@ -96,8 +96,7 @@ namespace TUGraz.VectoCore.Tests.Utils var titleHeight = (50 * 100.0f) / (_diagramSize.Height * Yfields.Length); foreach (var xfield in Xfields) { - var fileName = string.Format("{0}_{1}.png", Path.GetFileNameWithoutExtension(fileNameV3), - xfield.GetName()); + var fileName = $"{Path.GetFileNameWithoutExtension(fileNameV3)}_{xfield.GetName()}.png"; var x = LoadData(modDataV3, xfield.GetName()); var x2 = new[] { double.NegativeInfinity }; @@ -282,8 +281,7 @@ namespace TUGraz.VectoCore.Tests.Utils var titleHeight = (50 * 100.0f) / (_diagramSize.Height * yfields.Length); //foreach (var xfield in xfields) { - var fileName = string.Format("{0}_{1}-{2:D3}_{3:D3}.png", Path.GetFileNameWithoutExtension(fileNameV3), - xfield.GetName(), (int)(start / 1000), (int)(end / 1000)); + var fileName = $"{Path.GetFileNameWithoutExtension(fileNameV3)}_{xfield.GetName()}-{(int)(start / 1000):D3}_{(int)(end / 1000):D3}.png"; var x = LoadData(modDataV3, xfield.GetName()); var x2 = new[] { double.NegativeInfinity }; @@ -327,12 +325,12 @@ namespace TUGraz.VectoCore.Tests.Utils seriesGrad.YAxisType = AxisType.Secondary; } - var series1 = CreateSeries(string.Format("Vecto 3 - {0}", yfield), legend, chartArea, chart, + var series1 = CreateSeries($"Vecto 3 - {yfield}", legend, chartArea, chart, Color.Blue, x, y); if (fileNameV22 != null) { var y2 = LoadData(modDataV22, yfield.GetName()); - var series2 = CreateSeries(string.Format("Vecto 2.2 - {0}", yfield), legend, chartArea, chart, + var series2 = CreateSeries($"Vecto 2.2 - {yfield}", legend, chartArea, chart, Color.Red, x2, y2); } diff --git a/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs b/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs index 9512ad39fc2e65dc30f3e5b416f1c655ad04f6b7..6ba0f3433b0ce5589fcde090ebec169ef3368fe5 100644 --- a/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs +++ b/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs @@ -60,17 +60,13 @@ namespace TUGraz.VectoCore.Tests.Utils } - public CycleData CycleData - { - get { - return new CycleData { - AbsTime = 0.SI<Second>(), - AbsDistance = 0.SI<Meter>(), - LeftSample = _left.Current, - RightSample = _right.Current - }; - } - } + public CycleData CycleData => + new CycleData { + AbsTime = 0.SI<Second>(), + AbsDistance = 0.SI<Meter>(), + LeftSample = _left.Current, + RightSample = _right.Current + }; public bool PTOActive { get; set; } @@ -82,12 +78,9 @@ namespace TUGraz.VectoCore.Tests.Utils }; } - public Meter Altitude - { - get { return 0.SI<Meter>(); } - } + public Meter Altitude => 0.SI<Meter>(); - public Radian RoadGradient { get { return 0.SI<Radian>(); } } + public Radian RoadGradient => 0.SI<Radian>(); public MeterPerSecond TargetSpeed { get; set; } public Second StopTime { get; set; } @@ -105,10 +98,7 @@ namespace TUGraz.VectoCore.Tests.Utils _right.MoveNext(); } - public Meter CycleStartDistance - { - get { return 0.SI<Meter>(); } - } + public Meter CycleStartDistance => 0.SI<Meter>(); public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) { diff --git a/VectoCore/VectoCoreTest/Utils/MockBattery.cs b/VectoCore/VectoCoreTest/Utils/MockBattery.cs index da546f91f30fad4aa94874f0507d17df44a2959b..03343905049a3d04963e294f2cefc340a7178e37 100644 --- a/VectoCore/VectoCoreTest/Utils/MockBattery.cs +++ b/VectoCore/VectoCoreTest/Utils/MockBattery.cs @@ -6,10 +6,7 @@ using TUGraz.VectoCore.Models.SimulationComponent; namespace TUGraz.VectoCore.Tests.Utils { public class MockBattery : IElectricEnergyStorage, IElectricEnergyStoragePort, IElectricAuxConnecor { - public Volt InternalVoltage - { - get { return 640.SI<Volt>(); } - } + public Volt InternalVoltage => 640.SI<Volt>(); public IRESSResponse Request(Second absTime, Second dt, Watt powerdemand, bool dryRun = false) { @@ -26,15 +23,9 @@ namespace TUGraz.VectoCore.Tests.Utils { public double StateOfCharge { get; set; } - public WattSecond StoredEnergy - { - get { throw new System.NotImplementedException(); } - } + public WattSecond StoredEnergy => throw new System.NotImplementedException(); - public Ampere MaxCurrent - { - get { return 375.SI<Ampere>(); } - } + public Ampere MaxCurrent => 375.SI<Ampere>(); public Watt MaxChargePower(Second dt) { @@ -46,19 +37,11 @@ namespace TUGraz.VectoCore.Tests.Utils { throw new System.NotImplementedException(); } - public double MinSoC - { - get { return 0; } - } - public double MaxSoC - { - get { return 1; } - } + public double MinSoC => 0; - public IElectricEnergyStoragePort MainBatteryPort - { - get { return this; } - } + public double MaxSoC => 1; + + public IElectricEnergyStoragePort MainBatteryPort => this; public IElectricAuxConnecor AuxBatteryPort() { diff --git a/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs b/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs index aa2acbcdee3d47cc2740d73e1ab42fc81e783f40..1ac3faaf4bfd2fd3d9d2c641dcf896c5e9063d5a 100644 --- a/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs +++ b/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs @@ -17,7 +17,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public string Manufacturer { get; } public string Model { get; } public DateTime Date { get; } - public string AppVersion { get { return "Mock-Class"; } } + public string AppVersion => "Mock-Class"; public CertificationMethod CertificationMethod { get; } public string CertificationNumber { get; } public DigestData DigestValue { get; } @@ -34,7 +34,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public AxleConfiguration AxleConfiguration { get; } public Kilogram CurbMassChassis { get; } public Kilogram GrossVehicleMassRating { get; } - public IList<ITorqueLimitInputData> TorqueLimits { get { return new List<ITorqueLimitInputData>(); } } + public IList<ITorqueLimitInputData> TorqueLimits => new List<ITorqueLimitInputData>(); public string ManufacturerAddress { get; } public PerSecond EngineIdleSpeed { get; } public bool VocationalVehicle { get; } @@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public Meter EntranceHeight { get; } public ConsumerTechnology? DoorDriveTechnology { get; } public VehicleDeclarationType VehicleDeclarationType { get; } - public IVehicleComponentsDeclaration Components { get { return this; } } + public IVehicleComponentsDeclaration Components => this; public XmlNode XMLSource { get; } #endregion @@ -99,7 +99,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public string Manufacturer { get; } public string Model { get; } public DateTime Date { get; } - public string AppVersion { get { return "Mock-Class"; } } + public string AppVersion => "Mock-Class"; public CertificationMethod CertificationMethod { get; } public string CertificationNumber { get; } public DigestData DigestValue { get; } @@ -131,14 +131,11 @@ namespace TUGraz.VectoCore.Tests.Utils { public VehicleCode? VehicleCode { get; set; } public bool? LowEntry { get; } - IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components - { - get { return _components; } - } + IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components => _components; public XmlNode XMLSource { get; } - public IVehicleComponentsEngineering Components { get { return this; } } + public IVehicleComponentsEngineering Components => this; public string Identifier { get; } public bool ExemptedVehicle { get; } public string VIN { get; } @@ -147,7 +144,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public AxleConfiguration AxleConfiguration { get; } public Kilogram CurbMassChassis { get; } public Kilogram GrossVehicleMassRating { get; } - public IList<ITorqueLimitInputData> TorqueLimits { get { return new List<ITorqueLimitInputData>(); } } + public IList<ITorqueLimitInputData> TorqueLimits => new List<ITorqueLimitInputData>(); public string ManufacturerAddress { get; } public PerSecond EngineIdleSpeed { get; } public bool VocationalVehicle { get; } @@ -155,10 +152,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public bool? AirdragModifiedMultistage { get; } public TankSystem? TankSystem { get; } - IAdvancedDriverAssistantSystemDeclarationInputData IVehicleDeclarationInputData.ADAS - { - get { return _adas; } - } + IAdvancedDriverAssistantSystemDeclarationInputData IVehicleDeclarationInputData.ADAS => _adas; public double InitialSOC { get; } public VectoSimulationJobType VehicleType { get; } diff --git a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs index a336da2924c0acc0c3c4d7fecef544d8362436f2..61bec7f47eb0e046e51c7cf6415b15e16619720f 100644 --- a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs +++ b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs @@ -50,9 +50,9 @@ namespace TUGraz.VectoCore.Tests.Utils public string Model { get; set; } public string Creator { get; set; } public DateTime Date { get; set; } - public string AppVersion { get { return "Mock-Class"; } } + public string AppVersion => "Mock-Class"; public string TechnicalReportId { get; set; } - public CertificationMethod CertificationMethod { get{return CertificationMethod.NotCertified;} } + public CertificationMethod CertificationMethod => CertificationMethod.NotCertified; public string CertificationNumber { get; set; } public DigestData DigestValue { get; set; } public CubicMeter Displacement { get; set; } @@ -95,9 +95,6 @@ namespace TUGraz.VectoCore.Tests.Utils public KilogramSquareMeter Inertia { get; set; } public double WHTCEngineering { get; set; } - public Second EngineStartTime - { - get { return DeclarationData.Engine.DefaultEngineStartTime; } - } + public Second EngineStartTime => DeclarationData.Engine.DefaultEngineStartTime; } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockGearbox.cs b/VectoCore/VectoCoreTest/Utils/MockGearbox.cs index eedfc96df31bd72c6168c381c1c2d998ab63aa64..8f656aa0f2f11b41ab940f0c0c43e3ea5b921a6d 100644 --- a/VectoCore/VectoCoreTest/Utils/MockGearbox.cs +++ b/VectoCore/VectoCoreTest/Utils/MockGearbox.cs @@ -68,27 +68,15 @@ namespace TUGraz.VectoCore.Tests.Utils public bool TCLocked { get; set; } public GearshiftPosition NextGear { get; private set; } - public Second TractionInterruption - { - get { return 1.SI<Second>(); } - } + public Second TractionInterruption => 1.SI<Second>(); public uint NumGears { get; set; } - public MeterPerSecond StartSpeed - { - get { return 2.SI<MeterPerSecond>(); } - } + public MeterPerSecond StartSpeed => 2.SI<MeterPerSecond>(); - public MeterPerSquareSecond StartAcceleration - { - get { return 0.6.SI<MeterPerSquareSecond>(); } - } + public MeterPerSquareSecond StartAcceleration => 0.6.SI<MeterPerSquareSecond>(); - public NewtonMeter GearMaxTorque - { - get { return null; } - } + public NewtonMeter GearMaxTorque => null; public Watt GearboxLoss() { @@ -97,15 +85,9 @@ namespace TUGraz.VectoCore.Tests.Utils public Second LastShift { get; private set; } - public Second LastUpshift - { - get { throw new NotImplementedException(); } - } + public Second LastUpshift => throw new NotImplementedException(); - public Second LastDownshift - { - get { throw new NotImplementedException(); } - } + public Second LastDownshift => throw new NotImplementedException(); public GearData GetGearData(uint gear) { @@ -154,10 +136,7 @@ namespace TUGraz.VectoCore.Tests.Utils return _clutchClosed; } - public Watt ClutchLosses - { - get { throw new NotImplementedException(); } - } + public Watt ClutchLosses => throw new NotImplementedException(); public void SetClutch(bool closed) { @@ -200,10 +179,7 @@ namespace TUGraz.VectoCore.Tests.Utils } public Tuple<PerSecond, NewtonMeter> CurrentAxleDemand { get; } - public double Ratio - { - get { return 1; } - } + public double Ratio => 1; protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) { diff --git a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs index 2b6c8f979119c6687a0cb1d961df683138b885b9..3caea6a689b1eceddcde9ead2c5f40093e4a1591 100644 --- a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Tests.Utils FuelColumns[entry] = new Dictionary<ModalResultField, DataColumn>(); foreach (var fcCol in ModalDataContainer.FuelConsumptionSignals) { var col = Data.Columns.Add( - fuels.Count == 1 ? fcCol.GetName() : string.Format("{0}_{1}", fcCol.GetName(), entry.FuelType.GetLabel()), + fuels.Count == 1 ? fcCol.GetName() : $"{fcCol.GetName()}_{entry.FuelType.GetLabel()}", typeof(SI)); col.ExtendedProperties[ModalResults.ExtendedPropertyNames.Decimals] = fcCol.GetAttribute().Decimals; @@ -105,10 +105,7 @@ namespace TUGraz.VectoCore.Tests.Utils public ModalResults Data { get; set; } public DataRow CurrentRow { get; set; } - public string ModFileName - { - get { return ""; } - } + public string ModFileName => ""; public object this[ModalResultField key, IFuelProperties fuel] { @@ -130,14 +127,14 @@ namespace TUGraz.VectoCore.Tests.Utils public object this[ModalResultField key, PowertrainPosition pos] { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } + get => throw new NotImplementedException(); + set => throw new NotImplementedException(); } public object this[string auxId] { - get { return CurrentRow[Auxiliaries[auxId]]; } - set { CurrentRow[Auxiliaries[auxId]] = value; } + get => CurrentRow[Auxiliaries[auxId]]; + set => CurrentRow[Auxiliaries[auxId]] = value; } public bool HasTorqueConverter { get; set; } @@ -148,27 +145,15 @@ namespace TUGraz.VectoCore.Tests.Utils CurrentRow = Data.NewRow(); } - IList<IFuelProperties> IModalDataContainer.FuelData { get { return FuelColumns.Keys.ToList(); } } + IList<IFuelProperties> IModalDataContainer.FuelData => FuelColumns.Keys.ToList(); - public FuelData.Entry FuelData - { - get { return VectoCore.Models.Declaration.FuelData.Diesel; } - } + public FuelData.Entry FuelData => VectoCore.Models.Declaration.FuelData.Diesel; - public VectoRun.Status RunStatus - { - get { return VectoRun.Status.Success; } - } + public VectoRun.Status RunStatus => VectoRun.Status.Success; - public string Error - { - get { return null; } - } + public string Error => null; - public string StackTrace - { - get { return null; } - } + public string StackTrace => null; public void Finish(VectoRun.Status runStatus, Exception exception = null) {} @@ -203,7 +188,7 @@ namespace TUGraz.VectoCore.Tests.Utils public void SetDataValue(string fieldName, object value) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void AddAuxiliary(string id, string columnName = null) @@ -239,15 +224,9 @@ namespace TUGraz.VectoCore.Tests.Utils } - public Second Duration - { - get { return _duration; } - } + public Second Duration => _duration; - public Meter Distance - { - get { return _distance; } - } + public Meter Distance => _distance; public Func<Second, Joule, Joule> AuxHeaterDemandCalc { get; set; } @@ -365,8 +344,8 @@ namespace TUGraz.VectoCore.Tests.Utils public object this[ModalResultField key] { - get { return CurrentRow[key.GetName()]; } - set { CurrentRow[key.GetName()] = value; } + get => CurrentRow[key.GetName()]; + set => CurrentRow[key.GetName()] = value; } public void CommitSimulationStep(Second absTime, Second simulationInterval) diff --git a/VectoCore/VectoCoreTest/Utils/MockPorts.cs b/VectoCore/VectoCoreTest/Utils/MockPorts.cs index 65df8f6a22d61ed3bedf114c7b2001827792dfee..336f703fd6a558a0d9b2619d9829bdfbc6cb1ffc 100644 --- a/VectoCore/VectoCoreTest/Utils/MockPorts.cs +++ b/VectoCore/VectoCoreTest/Utils/MockPorts.cs @@ -110,15 +110,9 @@ namespace TUGraz.VectoCore.Tests.Utils AngularVelocity = null; } - public PerSecond EngineSpeed - { - get { return AngularVelocity; } - } + public PerSecond EngineSpeed => AngularVelocity; - public NewtonMeter EngineTorque - { - get { return Torque; } - } + public NewtonMeter EngineTorque => Torque; public Watt EngineStationaryFullPower(PerSecond angularSpeed) { @@ -140,24 +134,16 @@ namespace TUGraz.VectoCore.Tests.Utils throw new NotImplementedException(); } - public PerSecond EngineIdleSpeed - { - get { return 560.RPMtoRad(); } - } + public PerSecond EngineIdleSpeed => 560.RPMtoRad(); - public PerSecond EngineRatedSpeed - { + public PerSecond EngineRatedSpeed => // just a test value. not real. - get { return 1600.SI<PerSecond>(); } - } + 1600.SI<PerSecond>(); public PerSecond EngineN95hSpeed { get; set; } public PerSecond EngineN80hSpeed { get; set; } - public bool EngineOn - { - get { throw new NotImplementedException(); } - } + public bool EngineOn => throw new NotImplementedException(); } public class MockDrivingCycleOutPort : LoggingObject, IDrivingCycleOutPort diff --git a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs index 469de95a0bdfb9729f7608328c34c0bc3157e252..a5e43b2bb0f580ecc5335965e8d65a91d097a0fb 100644 --- a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs +++ b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs @@ -163,7 +163,7 @@ namespace TUGraz.VectoCore.Tests.Utils { var dao = new EngineeringDataAdapter(); var vehicleInput = JSONInputDataFactory.ReadJsonVehicle(vehicleDataFile, null); - var airdragData = vehicleInput.Components.AirdragInputData as IAirdragEngineeringInputData; + var airdragData = vehicleInput.Components.AirdragInputData; return dao.CreateAirdragData(airdragData, vehicleInput); } diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicle.cs b/VectoCore/VectoCoreTest/Utils/MockVehicle.cs index bf9741d401c0fc8c2b7162c20bd0f51d4064b66e..3e83a0ec1916b4a205acea74bdb5c28e889bfe8e 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicle.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicle.cs @@ -66,30 +66,15 @@ namespace TUGraz.VectoCore.Tests.Utils return this; } - public MeterPerSecond VehicleSpeed - { - get { return MyVehicleSpeed; } - } + public MeterPerSecond VehicleSpeed => MyVehicleSpeed; - public bool VehicleStopped - { - get { return MyVehicleSpeed.IsEqual(0.SI<MeterPerSecond>(), 0.01.SI<MeterPerSecond>()); } - } + public bool VehicleStopped => MyVehicleSpeed.IsEqual(0.SI<MeterPerSecond>(), 0.01.SI<MeterPerSecond>()); - public Kilogram VehicleMass - { - get { return 7500.SI<Kilogram>(); } - } + public Kilogram VehicleMass => 7500.SI<Kilogram>(); - public Kilogram VehicleLoading - { - get { return 0.SI<Kilogram>(); } - } + public Kilogram VehicleLoading => 0.SI<Kilogram>(); - public Kilogram TotalMass - { - get { return VehicleMass; } - } + public Kilogram TotalMass => VehicleMass; public CubicMeter CargoVolume { get; set; } @@ -108,7 +93,7 @@ namespace TUGraz.VectoCore.Tests.Utils return 0.SI<Newton>(); } - public MeterPerSecond MaxVehicleSpeed { get { return null; } } + public MeterPerSecond MaxVehicleSpeed => null; public void Connect(IFvOutPort other) { @@ -144,9 +129,6 @@ namespace TUGraz.VectoCore.Tests.Utils public Radian gradient; } - public Meter Distance - { - get { return 0.SI<Meter>(); } - } + public Meter Distance => 0.SI<Meter>(); } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index c4a7bca1e3c615bfeda8a5a3ad477609c77eb611..1669dfc081a6cd0254da78ec3540d5ae88d62f70 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -58,47 +58,23 @@ namespace TUGraz.VectoCore.Tests.Utils private ITorqueConverter _torqueConverter; private IGearboxInfo _gearboxInfoImplementation; - public IAxlegearInfo AxlegearInfo - { - get { return this; } - } + public IAxlegearInfo AxlegearInfo => this; public IEngineInfo EngineInfo { get; set; } - public IEngineControl EngineCtl - { - get { return this; } - } + public IEngineControl EngineCtl => this; - public IVehicleInfo VehicleInfo - { - get { return this; } - } + public IVehicleInfo VehicleInfo => this; - public IClutchInfo ClutchInfo - { - get { return this; } - } + public IClutchInfo ClutchInfo => this; - public IBrakes Brakes - { - get { return this; } - } + public IBrakes Brakes => this; - public IWheelsInfo WheelsInfo - { - get { return this; } - } + public IWheelsInfo WheelsInfo => this; - public IDriverInfo DriverInfo - { - get { return this; } - } + public IDriverInfo DriverInfo => this; - public IDrivingCycleInfo DrivingCycleInfo - { - get { return this; } - } + public IDrivingCycleInfo DrivingCycleInfo => this; public GearboxType GearboxType { get; set; } @@ -106,10 +82,7 @@ namespace TUGraz.VectoCore.Tests.Utils public bool TCLocked { get; set; } public GearshiftPosition NextGear { get; private set; } - public Second TractionInterruption - { - get { return 1.SI<Second>(); } - } + public Second TractionInterruption => 1.SI<Second>(); public uint NumGears { get; set; } @@ -117,27 +90,15 @@ namespace TUGraz.VectoCore.Tests.Utils public MeterPerSquareSecond StartAcceleration { get; set; } public NewtonMeter GearMaxTorque { get; set; } - public FuelType FuelType - { - get { return FuelType.DieselCI; } - } + public FuelType FuelType => FuelType.DieselCI; public Second AbsTime { get; set; } - public IMileageCounter MileageCounter - { - get { return this; } - } + public IMileageCounter MileageCounter => this; - public IGearboxInfo GearboxInfo - { - get { return this; } - } + public IGearboxInfo GearboxInfo => this; - public IGearboxControl GearboxCtl - { - get { return this; } - } + public IGearboxControl GearboxCtl => this; public IElectricMotorInfo ElectricMotorInfo(PowertrainPosition pos) { @@ -150,50 +111,32 @@ namespace TUGraz.VectoCore.Tests.Utils set; } - public ITorqueConverterInfo TorqueConverterInfo - { - get { return _torqueConverter; } - } + public ITorqueConverterInfo TorqueConverterInfo => _torqueConverter; - public ITorqueConverterControl TorqueConverterCtl - { - get { return _torqueConverter; } - } + public ITorqueConverterControl TorqueConverterCtl => _torqueConverter; - public IPowertainInfo PowertrainInfo - { - get { return this; } - } + public IPowertainInfo PowertrainInfo => this; public IHybridControllerInfo HybridControllerInfo { get; } public IHybridControllerCtl HybridControllerCtl { get; } public IAngledriveInfo AngledriveInfo { get; } public IDCDCConverter DCDCConverter { get; } - public bool IsTestPowertrain - { - get { return false; } - } + public bool IsTestPowertrain => false; public Watt GearboxLoss() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public Second LastShift { get; set; } - public Second LastUpshift - { - get { return _gearboxInfoImplementation.LastUpshift; } - } + public Second LastUpshift => _gearboxInfoImplementation.LastUpshift; - public Second LastDownshift - { - get { return _gearboxInfoImplementation.LastDownshift; } - } + public Second LastDownshift => _gearboxInfoImplementation.LastDownshift; public GearData GetGearData(uint gear) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public PerSecond EngineSpeed { get; set; } @@ -219,30 +162,15 @@ namespace TUGraz.VectoCore.Tests.Utils throw new NotImplementedException(); } - public PerSecond EngineIdleSpeed - { - get { return EngineInfo.EngineIdleSpeed; } - } + public PerSecond EngineIdleSpeed => EngineInfo.EngineIdleSpeed; - public PerSecond EngineRatedSpeed - { - get { return EngineInfo.EngineRatedSpeed; } - } + public PerSecond EngineRatedSpeed => EngineInfo.EngineRatedSpeed; - public PerSecond EngineN95hSpeed - { - get { return EngineInfo.EngineN95hSpeed; } - } + public PerSecond EngineN95hSpeed => EngineInfo.EngineN95hSpeed; - public PerSecond EngineN80hSpeed - { - get { return EngineInfo.EngineN80hSpeed; } - } + public PerSecond EngineN80hSpeed => EngineInfo.EngineN80hSpeed; - public bool EngineOn - { - get { return EngineInfo.EngineOn; } - } + public bool EngineOn => EngineInfo.EngineOn; public MeterPerSecond VehicleSpeed { get; set; } public Kilogram VehicleMass { get; set; } @@ -265,13 +193,13 @@ namespace TUGraz.VectoCore.Tests.Utils return 0.SI<Newton>(); } - public MeterPerSecond MaxVehicleSpeed { get { return null; } } + public MeterPerSecond MaxVehicleSpeed => null; public Meter Distance { get; set; } public bool SetClutchClosed { - set { _clutchClosed = value; } + set => _clutchClosed = value; } public bool ClutchClosed(Second absTime) @@ -279,10 +207,7 @@ namespace TUGraz.VectoCore.Tests.Utils return _clutchClosed; } - public Watt ClutchLosses - { - get { throw new NotImplementedException(); } - } + public Watt ClutchLosses => throw new NotImplementedException(); public Watt BrakePower { get; set; } public Radian RoadGradient { get; set; } @@ -292,12 +217,12 @@ namespace TUGraz.VectoCore.Tests.Utils public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public SpeedChangeEntry LastTargetspeedChange { get; set; } @@ -327,7 +252,7 @@ namespace TUGraz.VectoCore.Tests.Utils public ISimulationOutPort GetCycleOutPort() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public VectoRun.Status RunStatus { get; set; } @@ -354,7 +279,7 @@ namespace TUGraz.VectoCore.Tests.Utils public Watt SetAxlegearLoss { - set { _axlegearLoss = value; } + set => _axlegearLoss = value; } public Watt AxlegearLoss() diff --git a/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs b/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs index 35e50b24b2b151b13db4a53c16a6805093c3452c..0f36502f3b8efbee0ad36d1a5def5c7588bf7733 100644 --- a/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs +++ b/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs @@ -86,8 +86,9 @@ namespace TUGraz.VectoCore.Tests.Utils if (testRowcount) { Assert.AreEqual(expected.Rows.Count, actual.Rows.Count, - string.Format("Moddata: Row count differs.\nExpected {0} Rows in {1}\nGot {2} Rows in {3}", expected.Rows.Count, - result.expectedFile, actual.Rows.Count, result.actualFile)); + $"Moddata: Row count differs.\n" + + $"Expected {expected.Rows.Count} Rows in {result.expectedFile}\n" + + $"Got {actual.Rows.Count} Rows in {result.actualFile}"); } var actualCols = actual.Columns.Cast<DataColumn>().Select(x => x.ColumnName).OrderBy(x => x).ToList(); @@ -117,7 +118,7 @@ namespace TUGraz.VectoCore.Tests.Utils foreach (var field in testColumns ?? new string[0]) { Assert.AreEqual(expectedRow.ParseDoubleOrGetDefault(field), actualRow.ParseDoubleOrGetDefault(field), 1e-4, - string.Format("t: {0} field: {1}", i, field)); + $"t: {i} field: {field}"); } } } @@ -131,8 +132,7 @@ namespace TUGraz.VectoCore.Tests.Utils var actual = VectoCSVFile.Read(actualFile, fullHeader: true); Assert.AreEqual(expected.Rows.Count, actual.Rows.Count, - string.Format("SUM File row count differs.\nExpected {0} Rows in {1}\nGot {2} Rows in {3}", expected.Rows.Count, - expectedFile, actual.Rows.Count, actualFile)); + $"SUM File row count differs.\nExpected {expected.Rows.Count} Rows in {expectedFile}\nGot {actual.Rows.Count} Rows in {actualFile}"); var actualCols = actual.Columns.Cast<DataColumn>().Select(x => x.ColumnName).OrderBy(x => x).ToList(); var expectedCols = expected.Columns.Cast<DataColumn>().Select(x => x.ColumnName).OrderBy(x => x).ToList(); @@ -150,7 +150,7 @@ namespace TUGraz.VectoCore.Tests.Utils foreach (var field in testColumns ?? new string[0]) { AssertHelper.AreRelativeEqual(expectedRow.ParseDoubleOrGetDefault(field), actualRow.ParseDoubleOrGetDefault(field), - string.Format("t: {0} field: {1}", i, field)); + $"t: {i} field: {field}"); } } } diff --git a/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs b/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs index 4b9113905dc41ad27a7b3ab3925f840f7d94253b..57988c3f48e35eded9d4456ae6c766f5ea49b714 100644 --- a/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs +++ b/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs @@ -140,8 +140,7 @@ namespace TUGraz.VectoCore.Tests.Utils new { X = 20, Y = 12 } }; - double k, d, r; - VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out k, out d, out r); + VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out var k, out var d, out var r); Assert.AreEqual(4, d, 1e-6); Assert.AreEqual(0.4, k, 1e-6); @@ -164,8 +163,7 @@ namespace TUGraz.VectoCore.Tests.Utils new { X = 11, Y = 30.55 }, }; - double k, d, r; - VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out k, out d, out r); + VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out var k, out var d, out var r); Assert.AreEqual(27.003529, d, 1e-6); Assert.AreEqual(0.431535, k, 1e-6); diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs index 3f59c372a9924c463624ea800e56a260a0e17ed6..f333143bc0587336835d882229873095f6e40667 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs @@ -762,7 +762,7 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual(ptoGearWheel, inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData.PTOTransmissionType); } else { - Assert.AreEqual(string.Format("{0} - {1}", ptoGearWheel, ptoOther), + Assert.AreEqual($"{ptoGearWheel} - {ptoOther}", inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData.PTOTransmissionType); } Assert.NotNull(DeclarationData.PTOTransmission.Lookup(inputDataProvider.JobInputData.Vehicle.Components @@ -1041,16 +1041,16 @@ namespace TUGraz.VectoCore.Tests.XML public static string[] GetEnumOptions(string xmlType, string schemaVersion) { Stream resource; - var schemaFile = string.Format("VectoDeclarationDefinitions{0}.xsd", "." + schemaVersion); + var schemaFile = $"VectoDeclarationDefinitions{"." + schemaVersion}.xsd"; try { resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schemaFile); } catch (Exception e) { - throw new Exception(string.Format("Unknown XML schema! version: {0}, xsd: {1}", schemaVersion, schemaFile), e); + throw new Exception($"Unknown XML schema! version: {schemaVersion}, xsd: {schemaFile}", e); } var reader = new XPathDocument(resource); var nav = reader.CreateNavigator(); var nodes = nav.Select( - string.Format("//*[local-name()='simpleType' and @name='{0}']//*[local-name()='enumeration']/@value", xmlType)); + $"//*[local-name()='simpleType' and @name='{xmlType}']//*[local-name()='enumeration']/@value"); var retVal = new List<string>(); foreach (var node in nodes) { retVal.Add(node.ToString()); diff --git a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs index 0aa4f25fc2a95fc69c4ad1b1ffeff809990074b4..08500daf4005c7b8bfcebb7f0118aac566121a1e 100644 --- a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs @@ -104,8 +104,8 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual("560.00", fcMapTable.Rows[0][0]); var fcMap = FuelConsumptionMapReader.Create(fcMapTable); - Assert.AreEqual(1256.SI(Unit.SI.Gramm.Per.Hour).Value(), - fcMap.GetFuelConsumption(0.SI<NewtonMeter>(), 560.RPMtoRad(), false).Value.Value()); + Assert.AreEqual(1256.SI(Unit.SI.Gramm.Per.Hour).Value(), + fcMap.GetFuelConsumption(0.SI<NewtonMeter>(), 560.RPMtoRad()).Value.Value()); var fldTable = engineDataProvider.EngineModes.First().FullLoadCurve; Assert.AreEqual(10, fldTable.Rows.Count); @@ -171,7 +171,6 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - var axleglosses = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, @@ -226,8 +225,8 @@ namespace TUGraz.VectoCore.Tests.XML var tyre = axles[0].Tyre; Assert.AreEqual("315/70 R22.5", tyre.Dimension); - Assert.AreEqual(0.0055,tyre.RollResistanceCoefficient); - Assert.AreEqual(31300,tyre.TyreTestLoad.Value()); + Assert.AreEqual(0.0055, tyre.RollResistanceCoefficient); + Assert.AreEqual(31300, tyre.TyreTestLoad.Value()); tyre = axles[1].Tyre; Assert.AreEqual("315/70 R22.5", tyre.Dimension); @@ -246,16 +245,15 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var firstAxle = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_AxleWheels, XMLNames.ComponentDataWrapper, - XMLNames.AxleWheels_Axles) + - string.Format("/*[@{0}={1}]", XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, "1") - ); + XMLNames.AxleWheels_Axles) + $"/*[@{XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr}=1]" + ); firstAxle.MoveToAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, string.Empty); firstAxle.SetTypedValue(2); @@ -281,7 +279,6 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - var firstAxle = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, @@ -289,9 +286,8 @@ namespace TUGraz.VectoCore.Tests.XML XMLNames.Vehicle_Components, XMLNames.Component_AxleWheels, XMLNames.ComponentDataWrapper, - XMLNames.AxleWheels_Axles) + - string.Format("/*[@{0}={1}]", XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, "1") - ); + XMLNames.AxleWheels_Axles) + $"/*[@{XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr}=1]" + ); firstAxle.MoveToAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, string.Empty); firstAxle.SetTypedValue(0); @@ -316,16 +312,15 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var firstAxle = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_AxleWheels, XMLNames.ComponentDataWrapper, - XMLNames.AxleWheels_Axles) + - string.Format("/*[@{0}={1}]", XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, "1") - ); + XMLNames.AxleWheels_Axles) + $"/*[@{XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr}=1]" + ); firstAxle.MoveToAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, string.Empty); firstAxle.SetTypedValue(3); @@ -443,7 +438,7 @@ namespace TUGraz.VectoCore.Tests.XML AssertHelper.AreRelativeEqual(Constants.DefaultPowerShiftTime, gearboxData.PowershiftShiftTime); var tcShiftStrategy = inputDataProvider.DriverInputData.GearshiftInputData; - + AssertHelper.AreRelativeEqual(DeclarationData.TorqueConverter.CCUpshiftMinAcceleration, tcShiftStrategy.CCUpshiftMinAcceleration); AssertHelper.AreRelativeEqual(DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, @@ -458,7 +453,7 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var accData = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, XMLNames.Component_DriverModel, @@ -584,7 +579,7 @@ namespace TUGraz.VectoCore.Tests.XML //Assert.AreEqual(0.811, gearboxData.PowershiftShiftTime.Value(), 1e-6); // only available for AT gearboxes var tcShiftStrategy = inputDataProvider.DriverInputData.GearshiftInputData; - + Assert.AreEqual(0.134, tcShiftStrategy.CCUpshiftMinAcceleration.Value(), 1e-6); Assert.AreEqual(0.133, tcShiftStrategy.CLUpshiftMinAcceleration.Value(), 1e-6); } @@ -651,7 +646,7 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var angledrivelosses = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, @@ -682,9 +677,9 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var aux = nav.SelectSingleNode(XMLHelper.QueryLocalName( - XMLNames.VectoInputEngineering, + XMLNames.VectoInputEngineering, XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_Auxiliaries, XMLNames.ComponentDataWrapper)); //accData.DeleteSelf(); @@ -718,7 +713,7 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var retarderType = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, @@ -727,7 +722,7 @@ namespace TUGraz.VectoCore.Tests.XML retarderType.SetValue("None"); var retarder = nav.SelectSingleNode(XMLHelper.QueryLocalName( - XMLNames.VectoInputEngineering, + XMLNames.VectoInputEngineering, XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_Retarder)); @@ -742,7 +737,7 @@ namespace TUGraz.VectoCore.Tests.XML new XAttribute(XMLNames.ExtResource_Type_Attr, XMLNames.ExtResource_Type_Value_CSV), new XAttribute(XMLNames.ExtResource_File_Attr, "LongHaul")).ToString(); var aux = nav.SelectSingleNode(XMLHelper.QueryLocalName( - XMLNames.VectoInputEngineering, + XMLNames.VectoInputEngineering, XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_Auxiliaries, XMLNames.ComponentDataWrapper)); aux.InnerXml = ""; @@ -770,7 +765,7 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var engine = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_Engine)); @@ -795,7 +790,7 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var cycles = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, XMLNames.VectoJob_MissionCycles)); @@ -827,9 +822,9 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var driverAcceleration = nav.SelectSingleNode(XMLHelper.QueryLocalName( - XMLNames.VectoInputEngineering, + XMLNames.VectoInputEngineering, XMLNames.Component_DriverModel, XMLNames.DriverModel_DriverAccelerationCurve)); //accData.DeleteSelf(); driverAcceleration.InnerXml = @@ -858,7 +853,7 @@ namespace TUGraz.VectoCore.Tests.XML var doc = new XmlDocument(); doc.Load(reader); var nav = doc.CreateNavigator(); - + var axlegearLossMap = nav.SelectSingleNode(XMLHelper.QueryLocalName( XMLNames.VectoInputEngineering, XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_Axlegear,