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
Select Git revision
  • 94f6851aade2d51ab9622539849d79aaaefa4de0
  • stable default
  • amdm3/develop
  • fix-h2-ice-bus
  • feat-fchv-bus
  • powertrains-multiple-axles
  • issue-1039
  • amdm3/main
  • test/nuget_publish
  • IEPC-experiments
  • amdm2/main
  • amdm2/develop
  • aptngearbox-not-auto
  • playground
  • official/main
  • official/develop
  • issue-templates
  • pdf-reports
  • HEV-timeruns-dev
  • timerun-empower-hybrids
  • timerun-pwheel-hybrids
  • Release/v5.0.3
  • Release/v5.0.1
  • Release/5.0.0-RC
  • Nuget/v0.11.4-DEV
  • Release/v0.11.4-DEV
  • Release/4.3.4-DEV
  • Release/4.3.3
  • Release/4.3.2-RC
  • Release/v4.3.0-DEV
  • Release/4.2.7
  • XMLConverterTool/4.2.6.0
  • Release/4.2.6-RC
  • Release/v4.2.5
  • Release/v4.2.3
  • Release/v4.2.2.3539-RC
  • Release/v4.2.1.3469
  • Release/v0.11.2.3456-DEV
  • Release/v4.2.0.3448-RC
  • Release/v4.1.3.3415
  • Release/v4.1.1.3413
41 results

VehicleAxleDialog.vb

Blame
  • Forked from VECTO / VECTO Sim
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    VehicleAxleDialog.vb 3.39 KiB
    ' Copyright 2017 European Union.
    ' Licensed under the EUPL (the 'Licence');
    '
    ' * You may not use this work except in compliance with the Licence.
    ' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
    ' * Unless required by applicable law or agreed to in writing,
    '   software distributed under the Licence is distributed on an "AS IS" basis,
    '   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    '
    ' See the LICENSE.txt for the specific language governing permissions and limitations.
    Option Infer On
    Option Strict On
    Option Explicit On
    
    Imports System.Collections.Generic
    Imports System.ComponentModel.DataAnnotations
    Imports System.Linq
    Imports TUGraz.VectoCommon.Models
    Imports TUGraz.VectoCommon.Utils
    Imports TUGraz.VectoCore.InputData.Impl
    Imports TUGraz.VectoCore.Models.Declaration
    
    
    ''' <summary>
    ''' Axle Config Editor (Vehicle Editor sub-dialog)
    ''' </summary>
    Public Class VehicleAxleDialog
    	Public Sub New()
    		InitializeComponent()
    
    		CbWheels.Items.Add("-")
    		CbWheels.Items.AddRange(DeclarationData.Wheels.GetWheelsDimensions().OrderBy(function(s) s).ToArray())
    
    		cbAxleType.Items.Clear()
    		cbAxleType.ValueMember = "Value"
    		cbAxleType.DisplayMember = "Label"
    
    		cbAxleType.DataSource = [Enum].GetValues(GetType(AxleType)) _
    			.Cast(Of AxleType)() _
    			.Where(Function(type) Not Cfg.DeclMode OrElse type <> AxleType.Trailer) _
    			.Select(Function(type) New With {Key .Value = type, .Label = type.GetLabel()}).ToList()
    
    	End Sub
    
    	Public Sub Clear()
    		CbTwinT.Checked = False
    		TbAxleShare.Text = ""
    		TbI_wheels.Text = ""
    		TbRRC.Text = ""
    		TbFzISO.Text = ""
    		CbWheels.SelectedIndex = 0
    	End Sub
    
    	'Initialise
    	Private Sub F_VEH_Axle_Load(sender As Object, e As EventArgs) Handles Me.Load
    		PnAxle.Enabled = Not Cfg.DeclMode
    	End Sub
    
    	'Save and close
    	Private Sub OK_Button_Click(sender As Object, e As EventArgs) Handles OK_Button.Click
    
    		Dim axleData As Axle = New Axle With {
    				.AxleWeightShare = TbAxleShare.Text.ToDouble(0),
    				.RollResistanceCoefficient = TbRRC.Text.ToDouble(0),
    				.TyreTestLoad = TbFzISO.Text.ToDouble(0).SI(Of Newton)(),
    				.TwinTyres = CbTwinT.Checked,
    				.WheelsDimension = If(IsNothing(CbWheels.SelectedItem), "", CbWheels.SelectedItem.ToString()),
    				.Inertia = TbI_wheels.Text.ToDouble(0).SI(Of KilogramSquareMeter)()
    				}
    
    		Dim results As IList(Of ValidationResult) =
    				axleData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering), Nothing, False)
    
    		If results.Any() Then
    			Dim messages As IEnumerable(Of String) =
    					results.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct()))
    			MsgBox("Invalid input:" + Environment.NewLine + String.Join(Environment.NewLine, messages), MsgBoxStyle.OkOnly,
    					"Failed to save axle gear")
    			Exit Sub
    		End If
    
    		DialogResult = DialogResult.OK
    		Close()
    	End Sub
    
    	Private Sub CbWheels_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CbWheels.SelectedIndexChanged
    		'Dim inertia As Double
    		If Cfg.DeclMode Then
    			'inertia = DeclarationData.Wheels.Lookup(CbWheels.Text).Inertia.Value()
    			If CbWheels.Text = "-" Then
    				TbI_wheels.Text = "-"
    			Else
    				TbI_wheels.Text = DeclarationData.Wheels.Lookup(CbWheels.Text).Inertia.Value().ToString()
    			End If
    		End If
    	End Sub
    
    	'Cancel
    	Private Sub Cancel_Button_Click(sender As Object, e As EventArgs) Handles Cancel_Button.Click
    		DialogResult = DialogResult.Cancel
    		Close()
    	End Sub
    End Class