Newer
Older
TbEngTxt.Text = ""
TbGbxTxt.Text = ""
PicVehicle.Image = Nothing
PicBox.Image = Nothing
VEH0.FilePath = fFileRepl(TbVEH.Text, fPATH(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(HDVclass, 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)
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
End If
Dim OkCount = 0
Dim ENG0 = New Engine
ENG0.FilePath = fFileRepl(TbENG.Text, fPATH(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
n_idle = ENG0.Nidle
FLDfile = 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)
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
End If
TbEngTxt.Text = (ENG0.Displ / 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " & ENG0.ModelName
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
GBX0.FilePath = fFileRepl(TbGBX.Text, fPATH(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
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
'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
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
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
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
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
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
Dim item As cAdvancedAuxiliary
item = DirectCast(cboAdvancedAuxiliaries.SelectedItem, cAdvancedAuxiliary)
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(True, False)
Dim message As String = String.Empty
Dim absoluteAuxPath As String
Dim assembly As cAdvancedAuxiliary
'If Classic is selected, then bail
If cboAdvancedAuxiliaries.SelectedIndex = 0 Then Return
'Get Absolute Path for AAUX FILE.
absoluteAuxPath = ResolveAAUXFilePath(fPATH(VECTOfile), txtAdvancedAuxiliaryFile.Text)
'Set Extensions
fbAux.Extensions = New String() {"AAUX"}
Try
assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, cAdvancedAuxiliary)
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, tFbExtMode.ForceExt, False, String.Empty) Then
txtAdvancedAuxiliaryFile.Text = fFileWoDir(fbAux.Files(0), fPATH(VECTOfile))
assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, cAdvancedAuxiliary)
If _
File.Exists(ResolveAAUXFilePath(fPATH(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,
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
OpenFiles(fFileRepl(txtAdvancedAuxiliaryFile.Text, fPATH(VECTOfile)))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnDfTargetSpeed.Click
If DriverDecisionFactorTargetSpeedFileBrowser.OpenDialog(fFileRepl(tbLacDfTargetSpeedFile.Text, fPATH(VECTOfile))) Then _
tbLacDfTargetSpeedFile.Text = fFileWoDir(DriverDecisionFactorTargetSpeedFileBrowser.Files(0), fPATH(VECTOfile))
End Sub
End Class