diff --git a/HashingCmd/Program.cs b/HashingCmd/Program.cs index e88664d9d276b938cf40d9fbf3200522709679b3..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); } } diff --git a/HashingTool/ViewModel/HashComponentDataViewModel.cs b/HashingTool/ViewModel/HashComponentDataViewModel.cs index 250f91d82a9cb68128329f5c3ae9f2e6f925ab99..01641b30662e1801e6db9c0a5dfff0118ba66763 100644 --- a/HashingTool/ViewModel/HashComponentDataViewModel.cs +++ b/HashingTool/ViewModel/HashComponentDataViewModel.cs @@ -156,12 +156,12 @@ 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(XmlDocumentType.DeclarationComponentData); } diff --git a/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb b/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb index 0e491c3b08681bf403aeaa422778c9b7520b249c..d615f5d200746f792df9d1bb115a98fde1ef04f6 100644 --- a/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb +++ b/VECTO/BusAuxiliaries/UI/frmAuxiliaryConfig.vb @@ -800,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 00718473b621244ea0d3ea4d0ebf160ed2325603..fd6426e8fc4f8ae2976d45299cca27f25efadd07 100644 --- a/VECTO/BusAuxiliaries/UI/frmHVACTool.vb +++ b/VECTO/BusAuxiliaries/UI/frmHVACTool.vb @@ -1062,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 97f21f95097912b52436b2b84b8ccdc13510ca0c..8cc48694109058979b1d1ec28f06a1aabc21b073 100644 --- a/VECTO/File Browser/FileBrowserDialog.vb +++ b/VECTO/File Browser/FileBrowserDialog.vb @@ -498,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/BatteryForm.vb b/VECTO/GUI/BatteryForm.vb index 8928c68597d3d6625dc0b22c38e29fc7759cb71d..a09bde5f59111a5162cb83fb323881e61a4b619d 100644 --- a/VECTO/GUI/BatteryForm.vb +++ b/VECTO/GUI/BatteryForm.vb @@ -125,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 ce98a38f7bfcd30b6df772402c6112f6b824e2e8..3691148f067ac00255794cf2b8bfdca258d3cb50 100644 --- a/VECTO/GUI/BusAuxiliariesEngParametersForm.vb +++ b/VECTO/GUI/BusAuxiliariesEngParametersForm.vb @@ -120,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.vb b/VECTO/GUI/ElectricMotorForm.vb index fec9d7b4cacb6b3adafaee916f17aa334a9ec45a..ece27531a97576ee310df851e03b536817367ece 100644 --- a/VECTO/GUI/ElectricMotorForm.vb +++ b/VECTO/GUI/ElectricMotorForm.vb @@ -118,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 diff --git a/VECTO/GUI/EngineForm.vb b/VECTO/GUI/EngineForm.vb index 0c911de2b4b178b541735e693cc974dfbf17e014..14015e8fd336a5702d2e48933f9f883d619f764b 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 @@ -594,9 +594,8 @@ Public Class EngineForm 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) + $"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/GraphForm.vb b/VECTO/GUI/GraphForm.vb index 96ef7a84286863ed8bf982b7096dfcd0c8c625ff..5bb42a55d7f5903cba439f0b20878269f54f3e8d 100644 --- a/VECTO/GUI/GraphForm.vb +++ b/VECTO/GUI/GraphForm.vb @@ -547,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 334ad55ca97d10bc33f34202a5b61be6e8eff1f5..c672b3b46e3226aff88d99c30150afc67b6f5762 100644 --- a/VECTO/GUI/HybridStrategyParamsForm.vb +++ b/VECTO/GUI/HybridStrategyParamsForm.vb @@ -112,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 f3510344a86ddfb24fc02e61406907c22b5ba532..e0cb637613f5595afe7f62dadad1f3d6a84670a1 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -687,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 @@ -773,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 @@ -1050,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 @@ -1061,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) @@ -1086,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)). @@ -1116,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"))}) @@ -1138,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 @@ -1148,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 @@ -1196,27 +1185,21 @@ 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)}) + 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.vb b/VECTO/GUI/Settings.vb index 88bcbdbc274687bc1e7ee00ef1180e1adf6233a2..e371c1239469f3e03f7abcc48755732b235130fc 100644 --- a/VECTO/GUI/Settings.vb +++ b/VECTO/GUI/Settings.vb @@ -74,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/VehicleForm.vb b/VECTO/GUI/VehicleForm.vb index f4e3382273b08e0cdfc61b8e26f8db4231914027..800a4f30475892f273c28ae7ba8b0b10ba5f20af 100644 --- a/VECTO/GUI/VehicleForm.vb +++ b/VECTO/GUI/VehicleForm.vb @@ -300,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 21758d9cdefbde81b9581023b1d2575bcde4062a..916fb0b2ce060041e58549d12cebf397cb969c86 100644 --- a/VECTO/GUI/WelcomeDialog.vb +++ b/VECTO/GUI/WelcomeDialog.vb @@ -40,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/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index e8a0b34f8e8d7b4a263057488dcb84ae950025d3..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 { @@ -55,8 +55,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IIdleController IdleController { get => _idleController; - set - { + 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,41 +134,39 @@ 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) { 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);