Newer
Older
Dim s As Series
Dim a As ChartArea
Dim img As Bitmap
Dim EngOK = False
TbHVCclass.Text = ""
TbVehCat.Text = ""
TbMass.Text = ""
TbAxleConf.Text = ""
TbEngTxt.Text = ""
TbGbxTxt.Text = ""
PicVehicle.Image = Nothing
PicBox.Image = Nothing

Markus QUARITSCH
committed
VEH0.FilePath = fFileRepl(TbVEH.Text, GetPath(VECTOfile))
If VEH0.ReadFile(False) Then
Dim maxMass = (VEH0.MassMax * 1000).SI(Of Kilogram)() 'CSng(fTextboxToNumString(TbMassMass.Text))
Dim s0 As Segment = Nothing
Try
s0 = DeclarationData.Segments.Lookup(VEH0.VehicleCategory, VEH0.AxleConfiguration, maxMass, 0.SI(Of Kilogram), True)
Catch
End Try
If Not s0 Is Nothing Then
HDVclass = s0.VehicleClass.GetClassNumber()
If Cfg.DeclMode Then
LvCycles.Items.Clear()
For Each m0 In s0.Missions
LvCycles.Items.Add(m0.MissionType.ToString())
Next
End If
Else
HDVclass = "-"
End If
PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, HDVclass.ToInt()), False) _
'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False))
TbHVCclass.Text = "HDV Class " & HDVclass
TbVehCat.Text = VEH0.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True)
TbMass.Text = VEH0.MassMax & " t"
TbAxleConf.Text = VEH0.AxleConfiguration.GetName() 'ConvAxleConf(VEH0.AxleConf)
End If
Dim OkCount = 0
Dim ENG0 = New Engine

Markus QUARITSCH
committed
ENG0.FilePath = fFileRepl(TbENG.Text, GetPath(VECTOfile))
'Create plot
Dim MyChart = New Chart
MyChart.Width = PicBox.Width
MyChart.Height = PicBox.Height
a = New ChartArea
Dim FLD0 = New EngineFullLoadCurve
If ENG0.ReadFile(False) Then
EngineIdleSpeed = ENG0.IdleSpeed
EngineFullLoadFile = ENG0.PathFLD
EngOK = True
FLD0.FilePath = ENG0.PathFLD
If FLD0.ReadFile(False, False) Then
s = New Series
s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.MaxTorqueList)
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.DarkBlue
s.Name = "Full load"
MyChart.Series.Add(s)
s = New Series
s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.DragTorqueList)
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.Blue
s.Name = "Motoring"
MyChart.Series.Add(s)
OkCount += 1
pmax = FLD0.Pfull(FLD0.EngineRatedSpeed)
End If

Markus QUARITSCH
committed
TbEngTxt.Text = (ENG0.Displacement / 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " & ENG0.ModelName
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
Dim MAP0 = New FuelconsumptionMap
MAP0.FilePath = ENG0.PathMAP
If MAP0.ReadFile(False) Then
s = New Series
s.Points.DataBindXY(MAP0.nU, MAP0.Tq)
s.ChartType = SeriesChartType.Point
s.MarkerSize = 3
s.Color = Color.Red
s.Name = "Map"
MyChart.Series.Add(s)
OkCount += 1
End If
End If
Dim GBX0 = New Gearbox

Markus QUARITSCH
committed
GBX0.FilePath = fFileRepl(TbGBX.Text, GetPath(VECTOfile))
If GBX0.ReadFile(False) Then
TbGbxTxt.Text = GBX0.GearCount & "-Speed " & GBX0.Type.ShortName() & " " & GBX0.ModelName
If Cfg.DeclMode Then
If EngOK Then
For i = 1 To GBX0.GearCount
FLD0.FilePath = ENG0.PathFLD
If FLD0.ReadFile(True, False) Then
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
'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
End If
Else
f = New CsvFile
For i = 1 To GBX0.GearCount
lM = New List(Of Single)
lup = New List(Of Single)
ldown = New List(Of Single)
If f.OpenRead(GBX0.ShiftPolygonFile(i)) Then
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
f.ReadLine()
Try
Do While Not f.EndOfFile
line = f.ReadLine
lM.Add(CSng(line(0)))
lup.Add(CSng(line(1)))
ldown.Add(CSng(line(2)))
Loop
s = New Series
s.Points.DataBindXY(lup, lM)
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(ldown, lM)
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
OkCount += 1
f.Close()
Catch ex As Exception
f.Close()
End Try
End If
Next
End If
End If
If OkCount > 0 Then
a.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
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
a.AxisX.Minimum = 300
a.BorderDashStyle = ChartDashStyle.Solid
a.BorderWidth = 1
a.BackColor = Color.GhostWhite
MyChart.ChartAreas.Add(a)
MyChart.Update()
img = New Bitmap(MyChart.Width, MyChart.Height, PixelFormat.Format32bppArgb)
MyChart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height))
PicBox.Image = img
End If
End Sub
#Region "Open File Context Menu"
Private CmFiles As String()
Private Sub OpenFiles(ParamArray files() As String)
If files.Length = 0 Then Exit Sub
CmFiles = files
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(CmFiles(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(CmFiles(0)) Then
Try
Process.Start("explorer", "/select,""" & CmFiles(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)
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
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
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,
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))
assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary)

Markus QUARITSCH
committed
File.Exists(ResolveAAUXFilePath(GetPath(VECTOfile), txtAdvancedAuxiliaryFile.Text)) OrElse
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
1409
1410
1411
1412
MsgBox("Do you want to create a new .AAUX file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
needToFindOrCreateFile = False
ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion,
txtAdvancedAuxiliaryFile.Text, VECTOfile)
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(fFileRepl(txtAdvancedAuxiliaryFile.Text, GetPath(VECTOfile)))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnDfTargetSpeed.Click

Markus QUARITSCH
committed
If DriverDecisionFactorTargetSpeedFileBrowser.OpenDialog(fFileRepl(tbLacDfTargetSpeedFile.Text, GetPath(VECTOfile))) _
Then _
tbLacDfTargetSpeedFile.Text = GetFilenameWithoutDirectory(DriverDecisionFactorTargetSpeedFileBrowser.Files(0),
GetPath(VECTOfile))
End Sub
End Class