Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 35167c10 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

minor cleanups

parent f731117c
Branches
Tags
No related merge requests found
Showing
with 73 additions and 98 deletions
......@@ -23,8 +23,10 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AMT/@EntryIndexedValue">AMT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AT/@EntryIndexedValue">AT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CSV/@EntryIndexedValue">CSV</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HVAC/@EntryIndexedValue">HVAC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MT/@EntryIndexedValue">MT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PT/@EntryIndexedValue">PT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PTO/@EntryIndexedValue">PTO</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RP/@EntryIndexedValue">RP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SI/@EntryIndexedValue">SI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WHTC/@EntryIndexedValue">WHTC</s:String>
......
......@@ -186,7 +186,8 @@ Public Class FileBrowserDialog
End Sub
'Browse - Custom Dialog
Public Function Browse(path As String, fileMustExist As Boolean, overwriteCheck As Boolean, extMode As FileBrowserFileExtensionMode,
Public Function Browse(path As String, fileMustExist As Boolean, overwriteCheck As Boolean,
extMode As FileBrowserFileExtensionMode,
multiFile As Boolean, ext As String, caption As String) As Boolean
If Not _initialized Then Init()
......@@ -494,7 +495,7 @@ Public Class FileBrowserDialog
TextBoxPath.Text = ""
Else
If ListViewFiles.SelectedItems.Count > 1 Then
TextBoxPath.Text = "<" & ListViewFiles.SelectedItems.Count & " Files selected>"
TextBoxPath.Text = String.Format("<{0} Files selected>", ListViewFiles.SelectedItems.Count)
Else
TextBoxPath.Text = ListViewFiles.SelectedItems.Item(0).Text
TextBoxPath.SelectionStart = TextBoxPath.Text.Length
......
......@@ -269,6 +269,7 @@ Public Class MainForm
DeclOnOff()
End Sub
' ReSharper disable once UnusedMember.Global -- used via Logging Framework!
Public Shared Sub LogMethod(level As String, message As String)
Try
If level = "Warn" Then
......@@ -641,16 +642,15 @@ lbFound:
'Update job files counter in tab titel
Private Sub UpdateJobTabText()
Dim c As Integer
c = LvGEN.Items.Count
Dim count As Integer = LvGEN.Items.Count
TabPageGEN.Text = "Job Files ( " & _genChecked & " / " & c & " )"
TabPageGEN.Text = String.Format("Job Files ( {0} / {1} )", _genChecked, count)
_genCheckAllLock = True
If _genChecked = 0 Then
ChBoxAllGEN.CheckState = CheckState.Unchecked
ElseIf _genChecked = c Then
ElseIf _genChecked = count Then
ChBoxAllGEN.CheckState = CheckState.Checked
Else
ChBoxAllGEN.CheckState = CheckState.Indeterminate
......@@ -1547,8 +1547,8 @@ lbFound:
Private _mouseDownOnListView As Boolean
Private Class GUItest
Private ReadOnly RowLim As Integer = 9
Private ReadOnly ColLim As Integer = 45
Private Const RowLim As Integer = 9
Private Const ColLim As Integer = 45
Public TestActive As Boolean = False
Private _testAborted As Boolean
Private _xCtrl As Integer
......
......@@ -108,17 +108,17 @@ Public Class VectoJobForm
If Not RdEcoRoll.Checked Then RdOverspeed.Checked = True
CbLookAhead.Checked = True
TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph().ToGUIFormat() 'cDeclaration.SSspeed
TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat() 'cDeclaration.SSspeed
TbSStime.Text = DeclarationData.Driver.StartStop.MinTime.ToGUIFormat() 'cDeclaration.SStime
TbSSdelay.Text = DeclarationData.Driver.StartStop.Delay.ToGUIFormat() ' cDeclaration.SSdelay
tbLacPreviewFactor.Text = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor.ToGUIFormat()
tbLacDfTargetSpeedFile.Text = ""
tbLacDfVelocityDropFile.Text = ""
TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph().ToGUIFormat() 'cDeclaration.Overspeed
TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph().ToGUIFormat() _
TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat() 'cDeclaration.Overspeed
TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat() _
' cDeclaration.Underspeed
TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph().ToGUIFormat() 'cDeclaration.ECvmin
TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat() 'cDeclaration.ECvmin
If _
LvAux.Items.Count <> 5 OrElse
......@@ -396,7 +396,7 @@ Public Class VectoJobForm
'Start/Stop
Dim driver As IDriverEngineeringInputData = inputData.DriverInputData
ChBStartStop.Checked = driver.StartStop.Enabled
TbSSspeed.Text = driver.StartStop.MaxSpeed.AsKmph().ToGUIFormat()
TbSSspeed.Text = driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat()
TbSStime.Text = driver.StartStop.MinTime.ToGUIFormat()
TbSSdelay.Text = driver.StartStop.Delay.ToGUIFormat()
......@@ -464,12 +464,12 @@ Public Class VectoJobForm
Else
RdOff.Checked = True
End If
TbOverspeed.Text = driver.OverSpeedEcoRoll.OverSpeed.AsKmph().ToGUIFormat()
TbUnderSpeed.Text = driver.OverSpeedEcoRoll.UnderSpeed.AsKmph().ToGUIFormat()
TbVmin.Text = driver.OverSpeedEcoRoll.MinSpeed.AsKmph().ToGUIFormat()
TbOverspeed.Text = driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat()
TbUnderSpeed.Text = driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat()
TbVmin.Text = driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat()
CbLookAhead.Checked = driver.Lookahead.Enabled
'TbAlookahead.Text = CStr(VEC0.ALookahead)
tbLacMinSpeed.Text = driver.Lookahead.MinSpeed.AsKmph().ToGUIFormat()
tbLacMinSpeed.Text = driver.Lookahead.MinSpeed.AsKmph.ToGUIFormat()
'TbVminLA.Text = CStr(VEC0.VMinLa)
tbLacPreviewFactor.Text = driver.Lookahead.LookaheadDistanceFactor.ToGUIFormat()
tbDfCoastingOffset.Text = driver.Lookahead.CoastingDecisionFactorOffset.ToGUIFormat()
......@@ -625,7 +625,7 @@ Public Class VectoJobForm
TbDesMaxFile.Text = ""
'Start/Stop
TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph().ToGUIFormat()
TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat()
TbSStime.Text = DeclarationData.Driver.StartStop.MinTime.ToGUIFormat()
TbSSdelay.Text = DeclarationData.Driver.StartStop.Delay.ToGUIFormat()
ChBStartStop.Checked = False
......@@ -637,12 +637,12 @@ Public Class VectoJobForm
RdOff.Checked = True
CbLookAhead.Checked = True
'TbAlookahead.Text = "-0.5"
TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph().ToGUIFormat()
TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph().ToGUIFormat()
TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph().ToGUIFormat()
TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat()
TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat()
TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat()
'TbVminLA.Text = "50"
tbLacMinSpeed.Text = DeclarationData.Driver.LookAhead.MinimumSpeed.AsKmph().ToGUIFormat()
tbLacMinSpeed.Text = DeclarationData.Driver.LookAhead.MinimumSpeed.AsKmph.ToGUIFormat()
tbLacPreviewFactor.Text = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor.ToGUIFormat()
tbDfCoastingOffset.Text = DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset.ToGUIFormat()
tbDfCoastingScale.Text = DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling.ToGUIFormat()
......@@ -1005,14 +1005,7 @@ lbDlog:
Public Sub UpdatePic()
Dim i As Integer
Dim pmax As Double
Dim s As Series
Dim a As ChartArea = New ChartArea()
Dim img As Bitmap
Dim engOk As Boolean = False
TbHVCclass.Text = ""
TbVehCat.Text = ""
......@@ -1033,30 +1026,31 @@ lbDlog:
If chart Is Nothing Then Return
a.Name = "main"
Dim chartArea As ChartArea = New ChartArea()
chartArea.Name = "main"
a.AxisX.Title = "engine speed [1/min]"
a.AxisX.TitleFont = New Font("Helvetica", 10)
a.AxisX.LabelStyle.Font = New Font("Helvetica", 8)
a.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None
a.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot
chartArea.AxisX.Title = "engine speed [1/min]"
chartArea.AxisX.TitleFont = New Font("Helvetica", 10)
chartArea.AxisX.LabelStyle.Font = New Font("Helvetica", 8)
chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None
chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot
a.AxisY.Title = "engine torque [Nm]"
a.AxisY.TitleFont = New Font("Helvetica", 10)
a.AxisY.LabelStyle.Font = New Font("Helvetica", 8)
a.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None
a.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot
chartArea.AxisY.Title = "engine torque [Nm]"
chartArea.AxisY.TitleFont = New Font("Helvetica", 10)
chartArea.AxisY.LabelStyle.Font = New Font("Helvetica", 8)
chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None
chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot
a.AxisX.Minimum = 300
a.BorderDashStyle = ChartDashStyle.Solid
a.BorderWidth = 1
chartArea.AxisX.Minimum = 300
chartArea.BorderDashStyle = ChartDashStyle.Solid
chartArea.BorderWidth = 1
a.BackColor = Color.GhostWhite
chartArea.BackColor = Color.GhostWhite
chart.ChartAreas.Add(a)
chart.ChartAreas.Add(chartArea)
chart.Update()
img = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb)
Dim img As Bitmap = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb)
chart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height))
PicBox.Image = img
......@@ -1080,7 +1074,7 @@ lbDlog:
If gearbox Is Nothing Then Return
TbGbxTxt.Text = gearbox.Gears.Count & "-Speed " & gearbox.Type.ShortName() & " " & gearbox.ModelName
TbGbxTxt.Text = String.Format("{0}-Speed {1} {2}", gearbox.Gears.Count, gearbox.Type.ShortName(), gearbox.ModelName)
If Cfg.DeclMode Then
For i = 1 To gearbox.Gears.Count
......@@ -1200,8 +1194,7 @@ lbDlog:
pmax = fullLoadCurve.MaxPower.Value() / 1000 'FLD0.Pfull(FLD0.EngineRatedSpeed)
TbEngTxt.Text = (engine.Displacement.Value() * 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " &
engine.ModelName
TbEngTxt.Text = String.Format("{0} l {1} kw {2}", (engine.Displacement.Value() * 1000).ToString("0.0"), pmax.ToString("#"), engine.ModelName)
Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.FuelConsumptionMap)
......@@ -1259,7 +1252,7 @@ lbDlog:
PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, HDVclass.ToInt()), False) _
'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False))
TbHVCclass.Text = "HDV Class " & HDVclass
TbHVCclass.Text = String.Format("HDV Class {0}", 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)
......
......@@ -129,7 +129,7 @@ Public Class VehicleAuxiliariesDialog
If Trim(TbID.Text) = "" Or Cfg.DeclMode Then
LbIDhelp.Text = ""
Else
LbIDhelp.Text = "Header in Driving cycle: <AUX_" & Trim(TbID.Text) & ">"
LbIDhelp.Text = String.Format("Header in Driving cycle: <AUX_{1}>", Trim(TbID.Text))
End If
End Sub
End Class
......@@ -75,7 +75,7 @@ namespace TUGraz.VectoCommon.Exceptions
Response = (IResponse)info.GetValue("Response", typeof(IResponse));
}
public IResponse Response;
public readonly IResponse Response;
public UnexpectedResponseException(string message, IResponse resp)
: base(message + Environment.NewLine + "{0}", resp)
......
......@@ -30,7 +30,6 @@
*/
using System.Collections.Generic;
using System.Data;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......
......@@ -31,7 +31,6 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......
......@@ -37,7 +37,7 @@ namespace TUGraz.VectoCommon.Models
Advanced
}
public class AuxiliaryModelHelper
public static class AuxiliaryModelHelper
{
public static AuxiliaryModel Parse(string auxAssemblyStr)
{
......
......@@ -29,7 +29,6 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Diagnostics.CodeAnalysis;
using TUGraz.VectoCommon.Utils;
......
......@@ -29,7 +29,6 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCommon.Models
......
......@@ -29,8 +29,6 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
namespace TUGraz.VectoCommon.Models
{
public enum VehicleCategory
......
......@@ -55,6 +55,7 @@ namespace TUGraz.VectoCommon.Utils
return false;
}
// ReSharper disable once LoopCanBeConvertedToQuery
for (var i = 0; i < self.Length; i++) {
if (self[i].CompareTo(other[i]) != 0) {
return self.OrderBy(x => x).SequenceEqual(other.OrderBy(x => x));
......
......@@ -611,7 +611,7 @@ namespace TUGraz.VectoCommon.Utils
/// <summary>
/// SI Class for one per second [1/s].
/// </summary>
[DebuggerDisplay("rad/s: {this} | rpm: {ConvertTo().Rounds.Per.Minute}")]
[DebuggerDisplay("rad/s: {Val} | rpm: {AsRPM}")]
public class PerSecond : SIBase<PerSecond>
{
private static readonly Unit[] DenominatorDefault = { Unit.s };
......@@ -628,7 +628,7 @@ namespace TUGraz.VectoCommon.Utils
/// <summary>
/// SI Class for Meter per second [m/s].
/// </summary>
[DebuggerDisplay("{this} | {ConvertTo().Kilo.Meter.Per.Hour}")]
[DebuggerDisplay("{Val} | {AsKmph}")]
public class MeterPerSecond : SIBase<MeterPerSecond>
{
private static readonly Unit[] NumeratorDefault = { Unit.m };
......@@ -637,9 +637,9 @@ namespace TUGraz.VectoCommon.Utils
[DebuggerHidden]
private MeterPerSecond(double val) : base(val, NumeratorDefault, DenominatorDefault) {}
public double AsKmph()
public double AsKmph
{
return Val * 3.6;
get { return Val * 3.6; }
}
/// <summary>
......@@ -2194,7 +2194,7 @@ namespace TUGraz.VectoCommon.Utils
/// </returns>
public int CompareTo(object obj)
{
var si = (obj as SI);
var si = obj as SI;
if (si == null) {
return 1;
}
......
......@@ -254,7 +254,6 @@ namespace TUGraz.VectoCommon.Utils
/// </summary>
/// <param name="minimum">The minimum.</param>
/// <param name="maximum">The maximum.</param>
/// <param name="mode">if specified the validation is only performed in the corresponding mode</param>
public SIRangeAttribute(double minimum, double maximum) : base(minimum, maximum) {}
/// <summary>
......@@ -273,7 +272,6 @@ namespace TUGraz.VectoCommon.Utils
/// </summary>
/// <param name="minimum">The minimum.</param>
/// <param name="maximum">The maximum.</param>
/// <param name="mode">if specified the validation is only performed in the corresponding mode</param>
public SIRangeAttribute(SI minimum, SI maximum) : base(minimum.Value(), maximum.Value()) {}
/// <summary>
......
......@@ -154,7 +154,7 @@ namespace TUGraz.VectoCommon.Utils
retVal.Add((-b - Math.Sqrt(d)) / (2 * a));
} else {
// only one solution possible
retVal.Add((-b / (2 * a)));
retVal.Add(-b / (2 * a));
}
return retVal;
}
......@@ -186,7 +186,7 @@ namespace TUGraz.VectoCommon.Utils
}
var t = tNumer / denom;
return new Point(line1.P1.X + (t * s10X), line1.P1.Y + t * s10Y);
return new Point(line1.P1.X + t * s10X, line1.P1.Y + t * s10Y);
}
/// <summary>
......@@ -261,31 +261,17 @@ namespace TUGraz.VectoCommon.Utils
return Math.Ceiling(si.Value()).SI<T>();
}
public static List<double> CubicEquationSolver(double A, double B, double C, double D)
public static List<double> CubicEquationSolver(double a, double b, double c, double d)
{
//var a = B / A;
//var b = C / A;
//var d = D / A;
//var p = b / a - a * a / 3;
//var q = 2 * a * a / 27 - a * b / 3 + C;
//var R = q * q / 4 + p * p * p / 27;
//if (R > 0) {
// // one real and two complex solutions - we are only interested on the real solution
//} else {
// // three real solutions (two may coincide)
//}
var solutions = new List<double>();
if (A.IsEqual(0, 1e-12)) {
return QuadraticEquationSolver(B, C, D);
}
var w = B / (3 * A);
var p = Math.Pow(C / (3 * A) - w * w, 3);
var q = -0.5 * (2 * (w * w * w) - (C * w - D) / A);
var d = q * q + p; // discriminant
if (d < 0.0) {
if (a.IsEqual(0, 1e-12)) {
return QuadraticEquationSolver(b, c, d);
}
var w = b / (3 * a);
var p = Math.Pow(c / (3 * a) - w * w, 3);
var q = -0.5 * (2 * (w * w * w) - (c * w - d) / a);
var discriminant = q * q + p;
if (discriminant < 0.0) {
// 3 real solutions
var h = q / Math.Sqrt(-p);
var phi = Math.Acos(Math.Max(-1.0, Math.Min(1.0, h)));
......@@ -295,15 +281,15 @@ namespace TUGraz.VectoCommon.Utils
}
} else {
// only one real solution
d = Math.Sqrt(d);
solutions.Add(Cbrt(q + d) + Cbrt(q - d) - w);
discriminant = Math.Sqrt(discriminant);
solutions.Add(Cbrt(q + discriminant) + Cbrt(q - discriminant) - w);
}
// 1 Newton iteration step in order to minimize round-off errors
for (var i = 0; i < solutions.Count; i++) {
var h = C + solutions[i] * (2 * B + 3 * solutions[i] * A);
var h = c + solutions[i] * (2 * b + 3 * solutions[i] * a);
if (!h.IsEqual(0, 1e-12)) {
solutions[i] -= (D + solutions[i] * (C + solutions[i] * (B + solutions[i] * A))) / h;
solutions[i] -= (d + solutions[i] * (c + solutions[i] * (b + solutions[i] * a))) / h;
}
}
solutions.Sort();
......@@ -431,10 +417,10 @@ namespace TUGraz.VectoCommon.Utils
[DebuggerDisplay("Plane({X}, {Y}, {Z}, {W})")]
public class Plane
{
public double X;
public double Y;
public double Z;
public double W;
public readonly double X;
public readonly double Y;
public readonly double Z;
public readonly double W;
public Plane(double x, double y, double z, double w)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment