Newer
Older
Label21.Enabled = overspeed Or ecoRoll
End Sub
#End Region
Public Sub UpdatePic()
TbHVCclass.Text = ""
TbVehCat.Text = ""
TbMass.Text = ""
TbAxleConf.Text = ""
TbEngTxt.Text = ""
TbGbxTxt.Text = ""
PicVehicle.Image = Nothing
PicBox.Image = Nothing

Markus QUARITSCH
committed
UpdateVehiclePic()

Markus QUARITSCH
committed
Dim chart As Chart = Nothing
UpdateEnginePic(chart)

Markus QUARITSCH
committed
UpdateGearboxPic(chart)

Markus QUARITSCH
committed
If chart Is Nothing Then Return
Dim chartArea As ChartArea = New ChartArea()
chartArea.Name = "main"
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
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
chartArea.AxisX.Minimum = 300
chartArea.BorderDashStyle = ChartDashStyle.Solid
chartArea.BorderWidth = 1

Markus QUARITSCH
committed
chart.Update()
Dim img As Bitmap = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb)

Markus QUARITSCH
committed
chart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height))

Markus QUARITSCH
committed
PicBox.Image = img
End Sub

Markus QUARITSCH
committed
Private Sub UpdateGearboxPic(ByRef chartArea As Chart)
Dim s As Series
Dim i As Integer

Markus QUARITSCH
committed
Dim gearbox As IGearboxEngineeringInputData = Nothing
Dim gearboxFile As String =
If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbGBX.Text), TbGBX.Text)
If File.Exists(gearboxFile) Then
Try
Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(gearboxFile),
IEngineeringInputDataProvider)
gearbox = inputData.GearboxInputData
Catch
End Try
End If

Markus QUARITSCH
committed
If gearbox Is Nothing Then Return
TbGbxTxt.Text = String.Format("{0}-Speed {1} {2}", gearbox.Gears.Count, gearbox.Type.ShortName(), gearbox.ModelName)

Markus QUARITSCH
committed
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
If Cfg.DeclMode Then
For i = 1 To gearbox.Gears.Count
'If FLD0.Init(ENG0.Nidle) Then '' use engine from below...
'Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle)
'Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1,
' engine.FullLoadCurve, gears,
' engine,
' Double.Parse(LvGears.Items(0).SubItems(F_GBX.GearboxTbl.Ratio).Text,
' CultureInfo.InvariantCulture),
' (.rdyn / 1000.0).SI(Of Meter))
's = New Series
's.Points.DataBindXY(shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(),
' shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList())
's.ChartType = SeriesChartType.FastLine
's.BorderWidth = 2
's.Color = Color.DarkRed
's.Name = "Upshift curve (" & i & ")"
'MyChart.Series.Add(s)
's = New Series
's.Points.DataBindXY(
' shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(),
' shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList())
's.ChartType = SeriesChartType.FastLine
's.BorderWidth = 2
's.Color = Color.DarkRed
's.Name = "Downshift curve (" & i & ")"
'MyChart.Series.Add(s)
'End If
' OkCount += 1
' pmax = FLD0.Pfull(FLD0.EngineRatedSpeed)
'End If
Next
Else
For Each gear As ITransmissionInputData In gearbox.Gears
If gear.ShiftPolygon Is Nothing OrElse gear.ShiftPolygon.Rows.Count = 0 Then Continue For
Dim shiftPolygon As ShiftPolygon = ShiftPolygonReader.Create(gear.ShiftPolygon)
s = New Series
s.Points.DataBindXY(shiftPolygon.Upshift.Select(Function(x) x.AngularSpeed),
shiftPolygon.Upshift.Select(Function(x) x.Torque))
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.DarkRed
s.Name = "Upshift curve"
' MyChart.Series.Add(s) 'MQ 2016-06-20: do not plot shift lines in engine dialog
s = New Series
s.Points.DataBindXY(shiftPolygon.Downshift.Select(Function(x) x.AngularSpeed),
shiftPolygon.Downshift.Select(Function(x) x.Torque))
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.DarkRed
s.Name = "Downshift curve"
'MyChart.Series.Add(s) 'MQ 2016-06-20:do not plot shift lines in engine dialog
Next
End If
End Sub

Markus QUARITSCH
committed
Private Sub UpdateEnginePic(ByRef chart As Chart)
Dim s As Series
Dim pmax As Double

Markus QUARITSCH
committed
Dim engine As IEngineEngineeringInputData = Nothing
Dim engineFile As String =
If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbENG.Text), TbENG.Text)
If File.Exists(engineFile) Then
Try
Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(engineFile),
IEngineeringInputDataProvider)
engine = inputData.EngineInputData
Catch
Return
End Try
End If

Markus QUARITSCH
committed
'engine.FilePath = fFileRepl(TbENG.Text, GetPath(VECTOfile))

Markus QUARITSCH
committed
'Create plot
chart = New Chart
chart.Width = PicBox.Width
chart.Height = PicBox.Height

Markus QUARITSCH
committed
'Dim FLD0 As EngineFullLoadCurve = New EngineFullLoadCurve

Markus QUARITSCH
committed
If engine Is Nothing Then Return

Markus QUARITSCH
committed
engine.IdleSpeed.Value()

Markus QUARITSCH
committed
Dim fullLoadCurve As FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve)

Markus QUARITSCH
committed
s = New Series
s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(),
fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray())
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.DarkBlue
s.Name = "Full load"
chart.Series.Add(s)

Markus QUARITSCH
committed
s = New Series
s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(),
fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value()).ToArray())
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.Blue
s.Name = "Motoring"
chart.Series.Add(s)

Markus QUARITSCH
committed
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.ModelName)

Markus QUARITSCH
committed
Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.FuelConsumptionMap)

Markus QUARITSCH
committed
s = New Series
s.Points.DataBindXY(fuelConsumptionMap.Entries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(),
fuelConsumptionMap.Entries.Select(Function(x) x.Torque.Value()).ToArray())
s.ChartType = SeriesChartType.Point
s.MarkerSize = 3
s.Color = Color.Red
s.Name = "Map"
chart.Series.Add(s)
End Sub

Markus QUARITSCH
committed
Private Sub UpdateVehiclePic()
Dim HDVclass As String

Markus QUARITSCH
committed
Dim vehicle As IVehicleEngineeringInputData = Nothing

Markus QUARITSCH
committed
Dim vehicleFile As String =
If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbVEH.Text), TbVEH.Text)
If File.Exists(vehicleFile) Then
Try
Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(vehicleFile),
IEngineeringInputDataProvider)
vehicle = inputData.VehicleInputData
Catch
End Try
End If

Markus QUARITSCH
committed
If vehicle Is Nothing Then Return

Markus QUARITSCH
committed
Dim maxMass As Kilogram = vehicle.GrossVehicleMassRating 'CSng(fTextboxToNumString(TbMassMass.Text))

Markus QUARITSCH
committed
Dim s0 As Segment = Nothing
Try
s0 = DeclarationData.Segments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, maxMass, 0.SI(Of Kilogram),
True)
Catch
End Try
If s0 Is Nothing Then
HDVclass = "-"
Else
HDVclass = s0.VehicleClass.GetClassNumber()

Markus QUARITSCH
committed
If Cfg.DeclMode Then
LvCycles.Items.Clear()
Dim m0 As Mission
For Each m0 In s0.Missions
LvCycles.Items.Add(m0.MissionType.ToString())
Next
End If
End If

Markus QUARITSCH
committed
PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, HDVclass.ToInt()), False) _
'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False))
TbHVCclass.Text = String.Format("HDV Class {0}", HDVclass)

Markus QUARITSCH
committed
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
#Region "Open File Context Menu"

Markus QUARITSCH
committed
Private _basePath As String = ""
Private Sub OpenFiles(ParamArray files() As String)
If files.Length = 0 Then Exit Sub
OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName
CmOpenFile.Show(Windows.Forms.Cursor.Position)
End Sub
Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles OpenWithToolStripMenuItem.Click
If Not FileOpenAlt(_contextMenuFiles(0)) Then MsgBox("Failed to open file!")
End Sub
Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles ShowInFolderToolStripMenuItem.Click
If File.Exists(_contextMenuFiles(0)) Then
Process.Start("explorer", "/select,""" & _contextMenuFiles(0) & "")
Catch ex As Exception
MsgBox("Failed to open file!")
End Try
Else
MsgBox("File not found!")
End If
End Sub
#End Region
'AA-TB
Private Sub picAuxInfo_MouseEnter(sender As Object, e As EventArgs) Handles picAuxInfo.MouseEnter
If cboAdvancedAuxiliaries.SelectedIndex = -1 Then Exit Sub
'Get tooltip

Markus QUARITSCH
committed
Dim item As AdvancedAuxiliary

Markus QUARITSCH
committed
item = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary)
If item.AuxiliaryVersion = "CLASSIC" Then
ToolTip1.ToolTipTitle = "Classic Vecto Auxiliaries"
ToolTip1.SetToolTip(picAuxInfo, "Uses original basic auxiliaries calculation")
Else
ToolTip1.ToolTipTitle = "Advanced Auxiliary Information"
ToolTip1.SetToolTip(picAuxInfo, item.AuxiliaryName & " : Version=" & item.AuxiliaryVersion)
End If
End Sub
'AA-TB
Private Sub btnBrowseAAUXFile_Click(sender As Object, e As EventArgs) Handles btnBrowseAAUXFile.Click

Markus QUARITSCH
committed
If String.IsNullOrEmpty(VectoFile) Then
MessageBox.Show(
"Please complete and save a valid new .vecto file before adding/configuring advanced bus auxiliaries.")
Return
End If
Dim aauxFileValidated As Boolean = False
Dim fbAux As New FileBrowser("aaux", True, False)
Dim message As String = String.Empty
Dim absoluteAuxPath As String

Markus QUARITSCH
committed
Dim assembly As AdvancedAuxiliary
'If Classic is selected, then bail
If cboAdvancedAuxiliaries.SelectedIndex = 0 Then Return
'Get Absolute Path for AAUX FILE.

Markus QUARITSCH
committed
absoluteAuxPath = ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text)
'Set Extensions
fbAux.Extensions = New String() {"AAUX"}
Try

Markus QUARITSCH
committed
assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary)
Dim validAAUXFile As Boolean = ValidateAAUXFile(absoluteAuxPath, assembly.AssemblyName,
assembly.AuxiliaryVersion, message)
Dim fileExists As Boolean = File.Exists(absoluteAuxPath)
If fileExists AndAlso validAAUXFile Then
ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion,

Markus QUARITSCH
committed
txtAdvancedAuxiliaryFile.Text, VectoFile)
Else
Dim needToFindOrCreateFile As Boolean = True
While needToFindOrCreateFile
'Find / Create file and configure.
If fbAux.CustomDialog(absoluteAuxPath, False, False, FileBrowserFileExtensionMode.ForceExt, False, String.Empty) _
Then

Markus QUARITSCH
committed
txtAdvancedAuxiliaryFile.Text = GetFilenameWithoutDirectory(fbAux.Files(0), GetPath(VectoFile))

Markus QUARITSCH
committed
assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary)

Markus QUARITSCH
committed
File.Exists(ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text)) OrElse
MsgBox("Do you want to create a new .AAUX file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
needToFindOrCreateFile = False
ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion,

Markus QUARITSCH
committed
txtAdvancedAuxiliaryFile.Text, VectoFile)
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
End If
Else
needToFindOrCreateFile = False
End If
End While
End If
Catch ex As Exception
MessageBox.Show("There was an error configuring your Advanced Auxiliary File")
End Try
End Sub
'AA-TB
Private Sub cboAdvancedAuxiliaries_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles cboAdvancedAuxiliaries.SelectedIndexChanged
'Enable or otherwise the text box and browser button associated with Advanced Axuiliaries
If cboAdvancedAuxiliaries.SelectedIndex = 0 Then
btnBrowseAAUXFile.Enabled = False
txtAdvancedAuxiliaryFile.Enabled = False
Else
btnBrowseAAUXFile.Enabled = True
txtAdvancedAuxiliaryFile.Enabled = True
End If
End Sub
'AA-TB
Private Sub btnAAUXOpen_Click(sender As Object, e As EventArgs) Handles btnAAUXOpen.Click

Markus QUARITSCH
committed
OpenFiles(FileRepl(txtAdvancedAuxiliaryFile.Text, GetPath(VectoFile)))
End Sub

Markus QUARITSCH
committed
Private Sub btnDfTargetSpeed_Click(sender As Object, e As EventArgs) Handles btnDfTargetSpeed.Click
If DriverDecisionFactorTargetSpeedFileBrowser.OpenDialog(FileRepl(tbLacDfTargetSpeedFile.Text, GetPath(VectoFile))) _

Markus QUARITSCH
committed
Then _
tbLacDfTargetSpeedFile.Text = GetFilenameWithoutDirectory(DriverDecisionFactorTargetSpeedFileBrowser.Files(0),

Markus QUARITSCH
committed
GetPath(VectoFile))
End Sub

Markus QUARITSCH
committed
Private Sub btnDfVelocityDrop_Click_1(sender As Object, e As EventArgs) Handles btnDfVelocityDrop.Click
If DriverDecisionFactorVelocityDropFileBrowser.OpenDialog(FileRepl(tbLacDfVelocityDropFile.Text, GetPath(VectoFile))) _
Then _
tbLacDfVelocityDropFile.Text = GetFilenameWithoutDirectory(DriverDecisionFactorVelocityDropFileBrowser.Files(0),
GetPath(VectoFile))
End Sub

Markus QUARITSCH
committed
Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
End Sub
End Class