diff --git a/Declaration/Reports/rep3C.pdf b/Declaration/Reports/rep3C.pdf index 52eb20016fad493740e8937fe76130e83c446254..219dc6b64c0ea9b6470b688c28f6ecd645a40cec 100644 Binary files a/Declaration/Reports/rep3C.pdf and b/Declaration/Reports/rep3C.pdf differ diff --git a/Declaration/SegmentTable.csv b/Declaration/SegmentTable.csv index b7cdfef9777066c13528aeec4b0ea51147716a1a..f28c6c9e63762b3dc0f72031f8ca707c68645b8a 100644 --- a/Declaration/SegmentTable.csv +++ b/Declaration/SegmentTable.csv @@ -1,7 +1,7 @@ Valid,Vehicle Category ,Axle Conf.,GVW_Min,GVW_Max,HDV class,.vacc file ,Cross Wind Correction - Long haul,Cross Wind Correction - Other,Truck Axles - Long haul,Truck Axles - Other,Trailer Axles - Long haul,Trailer Axles - Other,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach,Mass Extra - Long haul,Mass Extra - Regional delivery,Mass Extra - Urban delivery,Mass Extra - Municipal utility,Mass Extra - Construction,Mass Extra - Heavy Urban,Mass Extra - Urban,Mass Extra - Suburban,Mass Extra - Interurban,Mass Extra - Coach,Payload - Long haul,Payload - Regional delivery,Payload - Urban delivery,Payload - Municipal utility,Payload - Construction,Payload - Heavy Urban,Payload - Urban,Payload - Suburban,Payload - Interurban,Payload - Coach 0,RigidTruck,4x2,0,7.5,0,Truck.vacc,-,RigidSolo,-,-,-,-,0,1,1,0,0,0,0,0,0,0,-,???,???,-,-,-,-,-,-,-,-,???,???,-,-,-,-,-,-,- 1,RigidTruck,4x2,7.5,10,1,Truck.vacc,-,RigidSolo,-,45/55,-,-,0,1,1,0,0,0,0,0,0,0,-,1600,1600,-,-,-,-,-,-,-,-,f,f,-,-,-,-,-,-,- -1,RigidTruck,4x2,10,12,2,Truck.vacc,RigidSolo,RigidSolo,40/60,45/55,-,-,1,1,1,0,0,0,0,0,0,0,1900,1900,1900,-,-,-,-,-,-,-,f,f,f,-,-,-,-,-,-,- +1,RigidTruck,4x2,10,12,2,Truck.vacc,RigidSolo,RigidSolo,22.5/32.5,45/55,45/1,-,1,1,1,0,0,0,0,0,0,0,1900,1900,1900,-,-,-,-,-,-,-,f,f,f,-,-,-,-,-,-,- 1,RigidTruck,4x2,12,16,3,Truck.vacc,-,RigidSolo,-,40/60,-,-,0,1,1,0,0,0,0,0,0,0,-,2000,2000,-,-,-,-,-,-,-,-,f,f,-,-,-,-,-,-,- 1,RigidTruck,4x2,16,99,4,Truck.vacc,RigidTrailer,RigidSolo,20/30,45/55,50/2,-,1,1,0,1,0,0,0,0,0,0,7500,2100,-,2100,-,-,-,-,-,-,14000,4400,-,4400,-,-,-,-,-,- 1,Tractor,4x2,16,99,5,Truck.vacc,TractorSemitrailer,TractorSemitrailer,20/25,25/25,55/3,50/3,1,1,0,0,0,0,0,0,0,0,7500,7500,-,-,-,-,-,-,-,-,19300,12900,-,-,-,-,-,-,-,- diff --git a/VECTO/File Browser/FB_Dialog.vb b/VECTO/File Browser/FB_Dialog.vb index 39f14aa8012679cb18e851dd0af309d22b22c160..271a1c22785455aa714c1d0695bd57d731383f7a 100644 --- a/VECTO/File Browser/FB_Dialog.vb +++ b/VECTO/File Browser/FB_Dialog.vb @@ -8,1001 +8,912 @@ ' 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 + +Imports System.IO +Imports System.Text +Imports Microsoft.VisualBasic.FileIO ''' <summary> ''' File Browser dialog. Entirely controlled by cFilebrowser class. ''' </summary> -''' <remarks></remarks> Public Class FB_Dialog - - Private MyFolder As String - Private MyFiles() As String - Private MyDrive As String - Private UpdateLock As Boolean - Private Initialized As Boolean - Private MyID As String - Private MyExt() As String - Private LastFile As String - Private bFileMustExist As Boolean - Private bOverwriteCheck As Boolean - Private bMultiFiles As Boolean - Private NoExt As Boolean - Private bBrowseFolder As Boolean - Private bForceExt As Boolean - Private ExtListSingle As ArrayList - Private ExtListMulti As ArrayList - Private LastExt As String - Private bLightMode As Boolean - - Private Const FavText As String = "Edit Favorites..." - Private Const EmptyText As String = " " - Private Const NoFavString As String = "<undefined>" - - 'New - Public Sub New(ByVal LightMode As Boolean) - ' This call is required by the Windows Form Designer. - InitializeComponent() - ' Append any initialization after the InitializeComponent() call. - MyID = "Default" - UpdateLock = False - Initialized = False - MyFolder = "" - MyDrive = "" - LastFile = "" - bOverwriteCheck = False - bFileMustExist = False - bMultiFiles = False - NoExt = True - bBrowseFolder = False - bLightMode = LightMode - Me.ButtonHisFile.Enabled = Not bLightMode - End Sub - - 'Resize - Private Sub FB_Dialog_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize - Resized() - End Sub - - 'Shown - Private Sub FileBrowser_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown - Resized() - Me.TextBoxPath.Focus() - Me.TextBoxPath.SelectAll() - End Sub - - 'Resized ListView Format - Private Sub Resized() - Me.ListViewFolder.Columns(0).Width = -2 - Me.ListViewFiles.Columns(0).Width = -2 - End Sub - - 'SplitterMoved - Private Sub SplitContainer1_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved - If Initialized Then Resized() - End Sub - - 'Closing (Overwrite-Check etc) - Private Sub FileBrowser_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing - Dim x As Int32 - Dim path As String - Dim Ext As String - Dim HasExt As Boolean - HasExt = False - If Me.DialogResult = Windows.Forms.DialogResult.OK Then - If bBrowseFolder Then - path = Trim(Me.TextBoxPath.Text) - 'If empty path: use the Current-folder(MyFolder) - If path = "" Then - path = MyFolder - Else - If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path - End If - If Not IO.Directory.Exists(path) Then - MsgBox("Directory " & path & " does not exist!", MsgBoxStyle.Critical) - e.Cancel = True - Exit Sub - End If - If Microsoft.VisualBasic.Right(path, 1) <> "\" Then path &= "\" - ReDim MyFiles(0) - MyFiles(0) = path - Else - 'Stop if empty path - If Trim(Me.TextBoxPath.Text) = "" Then - e.Cancel = True - Exit Sub - End If - LastExt = Trim(Me.ComboBoxExt.Text) - 'Assume Files in array - If Microsoft.VisualBasic.Left(Me.TextBoxPath.Text, 1) = "<" And Me.ListViewFiles.SelectedItems.Count > 0 Then - 'Multiple files selected - ReDim MyFiles(Me.ListViewFiles.SelectedItems.Count - 1) - x = -1 - For Each lv0 As ListViewItem In Me.ListViewFiles.Items - If lv0.Selected Then - x += 1 - MyFiles(x) = MyFolder & lv0.SubItems(0).Text - End If - Next - bMultiFiles = True - Else - 'Single File - path = Trim(Me.TextBoxPath.Text) - 'Primary extension (eg for bForceExt) - Ext = Trim(Me.ComboBoxExt.Text.Split(",")(0)) - 'If file without path then append path - If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path - 'If instead of File a Folder is entered: Switch to Folder and Abort - If IO.Directory.Exists(path) Then - SetFolder(path) - e.Cancel = True - Exit Sub - End If - 'Force Extension - If bForceExt Then - If UCase(IO.Path.GetExtension(path)) <> "." & UCase(Ext) Then path &= "." & Ext - HasExt = True - Else - 'Check whether specified a File with Ext - HasExt = (Microsoft.VisualBasic.Len(IO.Path.GetExtension(path)) > 1) - End If - 'If File without Extension (after bForceExt question) and it does not exist, then add primary Extension - If Not HasExt Then - If Ext <> "*" And Ext <> "" Then - If Not IO.File.Exists(path) Then path &= "." & Ext - End If - End If - 'Check that File exists - If IO.File.Exists(path) Then - 'Yes: when bOverwriteCheck, check for Overwrite - If bOverwriteCheck Then - If MsgBox("Overwrite " & path & " ?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then - e.Cancel = True - Exit Sub - End If - End If - Else - 'No: abort if bFileMustExist - If bFileMustExist Then - MsgBox("The file " & path & " does not exist!", MsgBoxStyle.Critical) - e.Cancel = True - Exit Sub - End If - End If - 'Define MyFiles - ReDim MyFiles(0) - MyFiles(0) = path - bMultiFiles = False - End If - End If - End If - End Sub - - 'Browse - Custom Dialog - Public Function Browse(ByVal path As String, ByVal FileMustExist As Boolean, ByVal OverwriteCheck As Boolean, ByVal ExtMode As tFbExtMode, ByVal MultiFile As Boolean, ByVal Ext As String, ByVal Title As String) As Boolean - Dim x As Int16 - - If Not Initialized Then Init() - - 'Load Folder History ContextMenu - For x = 0 To 9 - Me.ContextMenuHisFolder.Items(x).Text = FB_FolderHistory(x) - Next - For x = 10 To 19 - Me.ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) - Next - - 'Options - bOverwriteCheck = OverwriteCheck - bFileMustExist = FileMustExist - bForceExt = (ExtMode = tFbExtMode.ForceExt) - - 'Form Config - Me.ListViewFiles.MultiSelect = MultiFile - Me.ButtonAll.Visible = MultiFile - Me.Text = Title - - 'Ext-Combobox - Me.ComboBoxExt.Items.Clear() - If NoExt Then - Me.ComboBoxExt.Items.Add("*") - Me.ComboBoxExt.SelectedIndex = 0 - Else - Select Case ExtMode - Case tFbExtMode.ForceExt - If Ext = "" Then Ext = ExtListSingle(0).ToString - Me.ComboBoxExt.Items.AddRange(ExtListSingle.ToArray) - Me.ComboBoxExt.Text = Ext - Me.ComboBoxExt.Enabled = False - Case tFbExtMode.MultiExt, tFbExtMode.SingleExt - If ExtMode = tFbExtMode.MultiExt Then - Me.ComboBoxExt.Items.AddRange(ExtListMulti.ToArray) - Else - Me.ComboBoxExt.Items.AddRange(ExtListSingle.ToArray) - End If - If Ext <> "" Then - Me.ComboBoxExt.Text = Ext - Else - Me.ComboBoxExt.Text = LastExt - End If - Me.ComboBoxExt.Enabled = True - End Select - End If - - - 'Define Path - ' If no path is specified: Last folder, no file name - If path = "" Then path = FB_FolderHistory(0) - - ' If path-length too small (Path is invalid): Last File - If path.Length < 2 Then path = LastFile - - 'Open Folder - If no folder in the path: Last folder - If fPATH(path) = "" Then - 'If given a file without path - If Trim(FB_FolderHistory(0)) = "" Then - SetFolder("C:\") - Else - SetFolder(FB_FolderHistory(0)) - End If - Else - '...Otherwise: - SetFolder(fPATH(path)) - End If - If bBrowseFolder Then - FolderUp() - Me.TextBoxPath.Text = path - Else - Me.TextBoxPath.Text = IO.Path.GetFileName(path) - End If - - 'Show form ------------------------------------------------ ---- - Me.ShowDialog() - If Me.DialogResult = Windows.Forms.DialogResult.OK Then - 'File / Folder History - If bMultiFiles Then - LastFile = MyFolder - UpdateHisFolder(MyFolder) - Else - LastFile = MyFiles(0) - UpdateHisFolder(fPATH(LastFile)) - If Not bBrowseFolder Then UpdateHisFile(LastFile) - End If - 'Update Global History Folder - For x = 0 To 9 - FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x).Text - Next - For x = 10 To 19 - FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x + 1).Text - Next - Return True - Else - Return False - End If - End Function - - 'Close and save File / Folder History - Public Sub SaveAndClose() - Dim f As System.IO.StreamWriter - Dim x As Int16 - 'Folder History - If FB_Init Then - Try - f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & "Directories.txt", False, System.Text.Encoding.UTF8) - For x = 0 To 19 - f.WriteLine(FB_FolderHistory(x)) - Next - f.Close() - f.Dispose() - Catch ex As Exception - End Try - FB_Init = False - End If - 'File History - If Initialized And Not bLightMode Then - If Not bBrowseFolder Then - Try - f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & MyID & ".txt", False, System.Text.Encoding.UTF8) - For x = 0 To 9 - f.WriteLine(Me.ContextMenuHisFile.Items(x).Text) - Next - f.Close() - f.Dispose() - Catch ex As Exception - End Try - End If - Initialized = False - End If - f = Nothing - 'Close - Me.Close() - End Sub - - 'Switching to FolderBrowser - Public Sub SetFolderBrowser() - If Initialized Then Exit Sub - bBrowseFolder = True - Me.Width = 500 - Me.ListViewFiles.Enabled = False - Me.ButtonHisFile.Enabled = False - Me.TextBoxSearchFile.Enabled = False - Me.SplitContainer1.Panel2Collapsed = True - Me.Text = "Directory Browser" - End Sub - - 'Initialize - Private Sub Init() - Dim x As Int16 - Dim line As String - Dim f As System.IO.StreamReader - - UpdateLock = True - - 'Initialization for Global File Browser - If Not FB_Init Then GlobalInit() - - 'Load Drive ComboBox - For x = 0 To UBound(FB_Drives) - Me.ComboBoxDrive.Items.Add(FB_Drives(x)) - Next - - 'FolderHistory ContextMenu - Me.ContextMenuHisFolder.Items.Clear() - For x = 0 To 9 - Me.ContextMenuHisFolder.Items.Add("") - Next - Me.ContextMenuHisFolder.Items.Add("-") - For x = 10 To 19 - Me.ContextMenuHisFolder.Items.Add("") - Next - Me.ContextMenuHisFolder.Items.Add("-") - Me.ContextMenuHisFolder.Items.Add(FavText) - - 'FileHistory ContextMenu - If bBrowseFolder Then - LastFile = FB_FolderHistory(0) - ElseIf Not bLightMode Then - For x = 0 To 9 - Me.ContextMenuHisFile.Items.Add("") - Next - If IO.File.Exists(FB_FilHisDir & MyID & ".txt") Then - f = New System.IO.StreamReader(FB_FilHisDir & MyID & ".txt") - x = -1 - Do While Not f.EndOfStream And x < 9 - x += 1 - line = f.ReadLine - Me.ContextMenuHisFile.Items(x).Text = line - If x = 0 Then LastFile = line - Loop - f.Close() - f.Dispose() - End If - End If - - 'Extension-ComboBox - If Not NoExt Then - ExtListSingle = New ArrayList - ExtListMulti = New ArrayList - For x = 0 To UBound(MyExt) - ExtListMulti.Add(MyExt(x)) - For Each line In MyExt(x).Split(",") - ExtListSingle.Add(Trim(line)) - Next - Next - ExtListMulti.Add("*") - ExtListSingle.Add("*") - End If - - Initialized = True - f = Nothing - UpdateLock = False - End Sub - - Private Sub GlobalInit() - Dim drive As String - Dim x As Int16 - - Dim f As System.IO.StreamReader - - 'Create Drive List - ReDim FB_Drives(UBound(IO.Directory.GetLogicalDrives())) - x = -1 - For Each drive In IO.Directory.GetLogicalDrives() - x += 1 - FB_Drives(x) = Microsoft.VisualBasic.Left(drive, 2) - Next - - 'Read Folder History - For x = 0 To 19 - FB_FolderHistory(x) = EmptyText - Next - If IO.File.Exists(FB_FilHisDir & "Directories.txt") Then - f = New System.IO.StreamReader(FB_FilHisDir & "Directories.txt") - x = -1 - Do While Not f.EndOfStream And x < 19 - x += 1 - FB_FolderHistory(x) = f.ReadLine() - Loop - f.Dispose() - f.Close() - End If - - FB_Init = True - - f = Nothing - End Sub - - 'ComboBoxDrive_SelectedIndexChanged - Private Sub ComboBoxDrive_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxDrive.SelectedIndexChanged - If Not UpdateLock Then SetFolder(Me.ComboBoxDrive.SelectedItem.ToString) - End Sub - - - 'ButtonFolderBack_Click - Private Sub ButtonFolderBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonFolderBack.Click - FolderUp() - End Sub - - 'TextBoxPath_KeyDown (ENTER) - Private Sub TextBoxPath_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxPath.KeyDown - Dim path As String - If e.KeyCode = Keys.Enter Then - path = Me.TextBoxPath.Text - If IO.Directory.Exists(path) Then - If bBrowseFolder Then - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - Else - SetFolder(path) - End If - Else - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - End If - End If - End Sub - - 'ListViewFolder_SelectedIndexChanged - Private Sub ListViewFolder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListViewFolder.SelectedIndexChanged - If bBrowseFolder Then - UpdateLock = True - If Me.ListViewFolder.SelectedItems.Count > 0 Then - Me.TextBoxPath.Text = Me.ListViewFolder.SelectedItems.Item(0).Text & "\" - End If - UpdateLock = False - End If - End Sub - - 'ListViewFolder_MouseDoubleClick - Private Sub ListViewFolder_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListViewFolder.MouseDoubleClick - If Me.ListViewFolder.SelectedItems.Count = 0 Then Exit Sub - SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) - End Sub - - 'ListViewFolder_KeyDown - Private Sub ListViewFolder_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListViewFolder.KeyDown - If e.KeyCode = Keys.Enter Then - If Me.ListViewFolder.SelectedItems.Count = 0 Then Exit Sub - SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) - End If - End Sub - - ''<SORTER> - ''Private Sub ListViewFiles_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListViewFiles.ColumnClick - '' ' Determine if the clicked column is already the column that is - '' ' being sorted. - '' If (e.Column = lvwColumnSorter.SortColumn) Then - '' ' Reverse the current sort direction for this column. - '' If (lvwColumnSorter.Order = SortOrder.Ascending) Then - '' lvwColumnSorter.Order = SortOrder.Descending - '' Else - '' lvwColumnSorter.Order = SortOrder.Ascending - '' End If - '' Else - '' ' Set the column number that is to be sorted; default to ascending. - '' lvwColumnSorter.SortColumn = e.Column - '' lvwColumnSorter.Order = SortOrder.Ascending - '' End If - - '' ' Perform the sort with these new sort options. - '' Me.ListViewFiles.Sort() - - ''End Sub - - 'ListViewFiles_SelectedIndexChanged - Private Sub ListViewFiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListViewFiles.SelectedIndexChanged - UpdateLock = True - If Me.ListViewFiles.SelectedItems.Count = 0 Then - Me.TextBoxPath.Text = "" - Else - If Me.ListViewFiles.SelectedItems.Count > 1 Then - Me.TextBoxPath.Text = "<" & Me.ListViewFiles.SelectedItems.Count & " Files selected>" - Else - Me.TextBoxPath.Text = Me.ListViewFiles.SelectedItems.Item(0).Text - Me.TextBoxPath.SelectionStart = Me.TextBoxPath.Text.Length - End If - End If - UpdateLock = False - End Sub - - 'ListViewFiles_MouseDoubleClick - Private Sub ListViewFiles_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListViewFiles.MouseDoubleClick - If Me.ListViewFiles.SelectedItems.Count = 0 Then Exit Sub - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - End Sub - - 'ListViewFiles_KeyDown - Private Sub ListViewFiles_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListViewFiles.KeyDown - If e.KeyCode = Keys.Enter Then - If Me.ListViewFiles.SelectedItems.Count = 0 Then Exit Sub - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - End If - End Sub - - 'TextBoxSearchFolder_KeyDown - Private Sub TextBoxSearchFolder_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxSearchFolder.KeyDown - Dim ItemCount As Int32 - Dim SelIndex As Int32 - Dim NoItem As Boolean - ItemCount = Me.ListViewFolder.Items.Count - NoItem = (ItemCount = 0) - If Not NoItem Then - If Me.ListViewFolder.SelectedItems.Count = 0 Then - SelIndex = -1 - Else - SelIndex = Me.ListViewFolder.SelectedIndices(0) - End If - End If - Select Case e.KeyCode - Case Keys.Enter - If NoItem Then Exit Sub - If Me.ListViewFolder.SelectedItems.Count = 0 Then Me.ListViewFolder.SelectedIndices.Add(0) - SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) - Case Keys.Up - If Not NoItem Then - If SelIndex < 1 Then - SelIndex = 1 - Else - Me.ListViewFolder.Items(SelIndex).Selected = False - End If - Me.ListViewFolder.Items(SelIndex - 1).Selected = True - Me.ListViewFolder.Items(SelIndex - 1).EnsureVisible() - End If - Case Keys.Down - If Not NoItem And SelIndex < ItemCount - 1 Then - If Not SelIndex = -1 Then Me.ListViewFolder.Items(SelIndex).Selected = False - Me.ListViewFolder.Items(SelIndex + 1).Selected = True - Me.ListViewFolder.Items(SelIndex + 1).EnsureVisible() - End If - Case Keys.Back - If Me.TextBoxSearchFolder.Text = "" Then FolderUp() - End Select - End Sub - - 'TextBoxSearchFolder_TextChanged - Private Sub TextBoxSearchFolder_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxSearchFolder.TextChanged - If Not UpdateLock Then LoadListFolder() - End Sub - - 'TextBoxSearchFile_KeyDown - Private Sub TextBoxSearchFile_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxSearchFile.KeyDown - Dim ItemCount As Int32 - Dim SelIndex As Int32 - Dim NoItem As Boolean - ItemCount = Me.ListViewFiles.Items.Count - NoItem = (ItemCount = 0) - If Not NoItem Then - If Me.ListViewFiles.SelectedItems.Count = 0 Then - SelIndex = -1 - Else - SelIndex = Me.ListViewFiles.SelectedIndices(0) - End If - End If - Select Case e.KeyCode - Case Keys.Enter - If NoItem Then Exit Sub - If Me.ListViewFiles.SelectedItems.Count = 0 Then Me.ListViewFiles.SelectedIndices.Add(0) - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - Case Keys.Up - If Not NoItem Then - If SelIndex < 1 Then - SelIndex = 1 - Else - Me.ListViewFiles.Items(SelIndex).Selected = False - End If - Me.ListViewFiles.Items(SelIndex - 1).Selected = True - Me.ListViewFiles.Items(SelIndex - 1).EnsureVisible() - End If - Case Keys.Down - If Not NoItem And SelIndex < ItemCount - 1 Then - If Not SelIndex = -1 Then Me.ListViewFiles.Items(SelIndex).Selected = False - Me.ListViewFiles.Items(SelIndex + 1).Selected = True - Me.ListViewFiles.Items(SelIndex + 1).EnsureVisible() - End If - End Select - End Sub - - 'TextBoxSearchFile_TextChanged - Private Sub TextBoxSearchFile_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxSearchFile.TextChanged - If Not UpdateLock Then LoadListFiles() - End Sub - - 'ComboBoxExt_TextChanged - Private Sub ComboBoxExt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBoxExt.TextChanged - If Not UpdateLock Then LoadListFiles() - End Sub - - 'ButtonHisFolder_Click - Private Sub ButtonHisFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHisFolder.Click - Me.ContextMenuHisFolder.Show(Control.MousePosition) - End Sub - - 'ButtonHisFile_Click - Private Sub ButtonHisFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHisFile.Click - Me.ContextMenuHisFile.Show(Control.MousePosition) - End Sub - - 'Select All - Click - Private Sub ButtonAll_Click(sender As System.Object, e As System.EventArgs) Handles ButtonAll.Click - Dim i As Integer - Me.ListViewFiles.BeginUpdate() - For i = 0 To Me.ListViewFiles.Items.Count - 1 - Me.ListViewFiles.Items(i).Selected = True - Next - Me.ListViewFiles.EndUpdate() - End Sub - - 'ContextMenuHisFile_ItemClicked - Private Sub ContextMenuHisFile_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuHisFile.ItemClicked - Dim path As String - - path = e.ClickedItem.Text.ToString - - If path = EmptyText Then Exit Sub - - SetFolder(fPATH(path)) - - Me.TextBoxPath.Text = IO.Path.GetFileName(path) - - End Sub - - 'ContextMenuHisFolder_ItemClicked - Private Sub ContextMenuHisFolder_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuHisFolder.ItemClicked - Dim path As String - Dim favdlog As FB_FavDlog - Dim x As Integer - - path = e.ClickedItem.Text.ToString - - If path = EmptyText Then Exit Sub - - If path = FavText Then - favdlog = New FB_FavDlog - If favdlog.ShowDialog = Windows.Forms.DialogResult.OK Then - For x = 10 To 19 - path = favdlog.ListBox1.Items(x - 10) - If path = NoFavString Then - FB_FolderHistory(x) = EmptyText - Else - FB_FolderHistory(x) = path - End If - Me.ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) - Next - End If - Else - SetFolder(path) - End If - - End Sub - - 'TextBoxCurrent_MouseClick - Private Sub TextBoxCurrent_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBoxCurrent.MouseClick - Dim x As Int32 - Dim x1 As Int32 - Dim path As String - Dim newpath As String - newpath = "" - x = Me.TextBoxCurrent.SelectionStart - path = Me.TextBoxCurrent.Text - x1 = path.Length - If x = x1 Then Exit Sub - If x < 4 Then - SetFolder(Microsoft.VisualBasic.Left(path, 2)) - Exit Sub - End If - Do While x1 > x - newpath = path - 'path = Microsoft.VisualBasic.Left(path, x1 - 1) - path = Microsoft.VisualBasic.Left(path, path.LastIndexOf("\")) - x1 = path.Length - Loop - SetFolder(newpath) - End Sub - - 'ButtonDesktop_Click - Private Sub ButtonDesktop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDesktop.Click - SetFolder(FileIO.SpecialDirectories.Desktop.ToString) - End Sub - - 'Context Menu Update - Private Sub UpdateHisFile(ByVal path As String) - Dim x As Int16 - Dim y As Int16 - If bLightMode Then Exit Sub - 'Sort Context Menu - For x = 0 To 8 - If UCase(Me.ContextMenuHisFile.Items(x).Text.ToString) = UCase(path) Then Exit For - Next - For y = x To 1 Step -1 - Me.ContextMenuHisFile.Items(y).Text = Me.ContextMenuHisFile.Items(y - 1).Text - Next - Me.ContextMenuHisFile.Items(0).Text = path - End Sub - Private Sub UpdateHisFolder(ByVal path As String) - Dim x As Int16 - Dim y As Int16 - - 'Sort Context Menu - For x = 0 To 8 - If UCase(Me.ContextMenuHisFolder.Items(x).Text.ToString) = UCase(path) Then Exit For - Next - - For y = x To 1 Step -1 - Me.ContextMenuHisFolder.Items(y).Text = Me.ContextMenuHisFolder.Items(y - 1).Text - Next - - Me.ContextMenuHisFolder.Items(0).Text = path - - End Sub - - 'Manuelles History-Update - Public Sub UpdateHistory(ByVal path As String) - Dim x As Int16 - Dim y As Int16 - 'Init - If Not Initialized Then Init() - 'Files - UpdateHisFile(path) - 'Folder - path = fPATH(path) - For x = 0 To 8 - If UCase(FB_FolderHistory(x)) = UCase(path) Then Exit For - Next - For y = x To 1 Step -1 - FB_FolderHistory(y) = FB_FolderHistory(y - 1) - Next - FB_FolderHistory(0) = path - End Sub - - 'Change folder - Private Sub SetFolder(ByVal Path As String) - - 'Abort if no drive specified - If Microsoft.VisualBasic.Mid(Path, 2, 1) <> ":" Then Exit Sub - - UpdateLock = True - - 'Delete Search-fields - Me.TextBoxSearchFile.Text = "" - Me.TextBoxSearchFolder.Text = "" - - 'Set Drive - If MyDrive <> Microsoft.VisualBasic.Left(Path, 2) Then - MyDrive = UCase(Microsoft.VisualBasic.Left(Path, 2)) - Me.ComboBoxDrive.SelectedItem = MyDrive - End If - - 'Set Folder - MyFolder = Path - If Microsoft.VisualBasic.Right(MyFolder, 1) <> "\" Then MyFolder &= "\" - LoadListFolder() - LoadListFiles() - - If bBrowseFolder Then Me.TextBoxPath.Text = "" - - Me.TextBoxCurrent.Text = MyFolder - - 'Me.TextBoxPath.SelectionStart = Me.TextBoxPath.Text.Length - UpdateLock = False - - End Sub - - 'Folder one level up - Private Sub FolderUp() - Dim path As String - Dim x As Int32 - If MyFolder <> "" Then - path = Microsoft.VisualBasic.Left(MyFolder, MyFolder.Length - 1) - x = path.LastIndexOf("\") - If x > 0 Then SetFolder(Microsoft.VisualBasic.Left(path, x)) - End If - End Sub - - 'Load Folder-List - Private Sub LoadListFolder() - Dim SearchPat As String - 'Delete Folder-List - Me.ListViewFolder.Items.Clear() - SearchPat = "*" & Me.TextBoxSearchFolder.Text & "*" - Try - 'Add Folder - Dim di As New IO.DirectoryInfo(MyFolder) - Dim aryFi As IO.DirectoryInfo() - Dim fi As IO.DirectoryInfo - aryFi = di.GetDirectories(SearchPat) - For Each fi In aryFi - Me.ListViewFolder.Items.Add(fi.ToString) - Next - Catch ex As Exception - Me.ListViewFolder.Items.Add("<ERROR: " & ex.Message.ToString & ">") - End Try - End Sub - - 'Load File-list - Private Sub LoadListFiles() - Dim x As Int32 - Dim SearchPat As String - Dim SearchFile As String - Dim SearchExt As String - Dim ExtStr As String() - - 'Abort if bBrowseFolder - If bBrowseFolder Then Exit Sub - - Me.LabelFileAnz.Text = "0 Files" - 'Define Extension-filter - If Trim(Me.ComboBoxExt.Text.ToString) = "" Then - ExtStr = New String() {"*"} - Else - ExtStr = Me.ComboBoxExt.Text.ToString.Split(",") - End If - - 'Delete File-List - Me.ListViewFiles.Items.Clear() - - SearchFile = Me.TextBoxSearchFile.Text - - Me.ListViewFiles.BeginUpdate() - Try - 'Add Folder - Dim di As New IO.DirectoryInfo(MyFolder) - Dim aryFi As IO.FileInfo() - Dim fi As IO.FileInfo - x = -1 - For Each SearchExt In ExtStr - SearchPat = "*" & Trim(SearchFile) & "*." & Trim(SearchExt) - aryFi = di.GetFiles(SearchPat) - For Each fi In aryFi - x += 1 - Me.ListViewFiles.Items.Add(fi.ToString) - Next - Next - If x = 0 Then - Me.LabelFileAnz.Text = "1 File" - Else - Me.LabelFileAnz.Text = x + 1 & " Files" - End If - Catch ex As Exception - Me.ListViewFiles.Items.Add("<ERROR: " & ex.Message.ToString & ">") - End Try - - Me.ListViewFiles.EndUpdate() - - End Sub - - 'Rename File - Private Sub RenameFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RenameFileToolStripMenuItem.Click - Dim file0 As String - Dim file As String - If Me.ListViewFiles.SelectedItems.Count = 1 Then - file0 = Me.ListViewFiles.SelectedItems(0).Text - file = file0 + Private _myFolder As String + Private _myFiles() As String + Private _myDrive As String + Private _updateLock As Boolean + Private _initialized As Boolean + Private _myId As String + Private _myExt() As String + Private _lastFile As String + Private _bFileMustExist As Boolean + Private _bOverwriteCheck As Boolean + Private _bMultiFiles As Boolean + Private _noExt As Boolean + Private _bBrowseFolder As Boolean + Private _bForceExt As Boolean + Private _extListSingle As ArrayList + Private _extListMulti As ArrayList + Private _lastExt As String + Private ReadOnly _bLightMode As Boolean + + Private Const FavText As String = "Edit Favorites..." + Private Const EmptyText As String = " " + Private Const NoFavString As String = "<undefined>" + + 'New + Public Sub New(lightMode As Boolean) + ' This call is required by the Windows Form Designer. + InitializeComponent() + ' Append any initialization after the InitializeComponent() call. + _myId = "Default" + _updateLock = False + _initialized = False + _myFolder = "" + _myDrive = "" + _lastFile = "" + _bOverwriteCheck = False + _bFileMustExist = False + _bMultiFiles = False + _noExt = True + _bBrowseFolder = False + _bLightMode = LightMode + ButtonHisFile.Enabled = Not _bLightMode + End Sub + + 'Resize + Private Sub FB_Dialog_Resize(sender As Object, e As EventArgs) Handles Me.Resize + Resized() + End Sub + + 'Shown + Private Sub FileBrowser_Shown(sender As Object, e As EventArgs) Handles Me.Shown + Resized() + TextBoxPath.Focus() + TextBoxPath.SelectAll() + End Sub + + 'Resized ListView Format + Private Sub Resized() + ListViewFolder.Columns(0).Width = -2 + ListViewFiles.Columns(0).Width = -2 + End Sub + + 'SplitterMoved + Private Sub SplitContainer1_SplitterMoved(sender As Object, e As SplitterEventArgs) _ + Handles SplitContainer1.SplitterMoved + If _initialized Then Resized() + End Sub + + 'Closing (Overwrite-Check etc) + Private Sub FileBrowser_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing + Dim x As Int32 + Dim path As String + Dim ext As String + Dim hasExt As Boolean + If DialogResult = DialogResult.OK Then + If _bBrowseFolder Then + path = Trim(TextBoxPath.Text) + 'If empty path: use the Current-folder(MyFolder) + If path = "" Then + path = _myFolder + Else + If Mid(path, 2, 1) <> ":" Then path = _myFolder & path + End If + If Not Directory.Exists(path) Then + MsgBox("Directory " & path & " does not exist!", MsgBoxStyle.Critical) + e.Cancel = True + Exit Sub + End If + If Microsoft.VisualBasic.Right(path, 1) <> "\" Then path &= "\" + ReDim _myFiles(0) + _myFiles(0) = path + Else + 'Stop if empty path + If Trim(TextBoxPath.Text) = "" Then + e.Cancel = True + Exit Sub + End If + _lastExt = Trim(ComboBoxExt.Text) + 'Assume Files in array + If Microsoft.VisualBasic.Left(TextBoxPath.Text, 1) = "<" And ListViewFiles.SelectedItems.Count > 0 Then + 'Multiple files selected + ReDim _myFiles(ListViewFiles.SelectedItems.Count - 1) + x = -1 + For Each lv0 As ListViewItem In ListViewFiles.Items + If lv0.Selected Then + x += 1 + _myFiles(x) = _myFolder & lv0.SubItems(0).Text + End If + Next + _bMultiFiles = True + Else + 'Single File + path = Trim(TextBoxPath.Text) + 'Primary extension (eg for bForceExt) + ext = Trim(ComboBoxExt.Text.Split(",")(0)) + 'If file without path then append path + If Mid(path, 2, 1) <> ":" Then path = _myFolder & path + 'If instead of File a Folder is entered: Switch to Folder and Abort + If Directory.Exists(path) Then + SetFolder(path) + e.Cancel = True + Exit Sub + End If + 'Force Extension + If _bForceExt Then + If UCase(IO.Path.GetExtension(path)) <> "." & UCase(ext) Then path &= "." & ext + hasExt = True + Else + 'Check whether specified a File with Ext + hasExt = (Microsoft.VisualBasic.Len(IO.Path.GetExtension(path)) > 1) + End If + 'If File without Extension (after bForceExt question) and it does not exist, then add primary Extension + If Not hasExt Then + If ext <> "*" And ext <> "" Then + If Not File.Exists(path) Then path &= "." & ext + End If + End If + 'Check that File exists + If File.Exists(path) Then + 'Yes: when bOverwriteCheck, check for Overwrite + If _bOverwriteCheck Then + If MsgBox("Overwrite " & path & " ?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then + e.Cancel = True + Exit Sub + End If + End If + Else + 'No: abort if bFileMustExist + If _bFileMustExist Then + MsgBox("The file " & path & " does not exist!", MsgBoxStyle.Critical) + e.Cancel = True + Exit Sub + End If + End If + 'Define MyFiles + ReDim _myFiles(0) + _myFiles(0) = path + _bMultiFiles = False + End If + End If + End If + End Sub + + 'Browse - Custom Dialog + Public Function Browse(path As String, fileMustExist As Boolean, overwriteCheck As Boolean, extMode As tFbExtMode, + multiFile As Boolean, ext As String, title As String) As Boolean + If Not _initialized Then Init() + + 'Load Folder History ContextMenu + For x = 0 To 9 + ContextMenuHisFolder.Items(x).Text = FB_FolderHistory(x) + Next + For x = 10 To 19 + ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) + Next + + 'Options + _bOverwriteCheck = overwriteCheck + _bFileMustExist = fileMustExist + _bForceExt = (extMode = tFbExtMode.ForceExt) + + 'Form Config + ListViewFiles.MultiSelect = multiFile + ButtonAll.Visible = multiFile + Text = title + + 'Ext-Combobox + ComboBoxExt.Items.Clear() + If _noExt Then + ComboBoxExt.Items.Add("*") + ComboBoxExt.SelectedIndex = 0 + Else + Select Case extMode + Case tFbExtMode.ForceExt + If ext = "" Then ext = _extListSingle(0).ToString + ComboBoxExt.Items.AddRange(_extListSingle.ToArray) + ComboBoxExt.Text = ext + ComboBoxExt.Enabled = False + Case tFbExtMode.MultiExt, tFbExtMode.SingleExt + If extMode = tFbExtMode.MultiExt Then + ComboBoxExt.Items.AddRange(_extListMulti.ToArray) + Else + ComboBoxExt.Items.AddRange(_extListSingle.ToArray) + End If + If ext <> "" Then + ComboBoxExt.Text = ext + Else + ComboBoxExt.Text = _lastExt + End If + ComboBoxExt.Enabled = True + End Select + End If + + + 'Define Path + ' If no path is specified: Last folder, no file name + If path = "" Then path = FB_FolderHistory(0) + + ' If path-length too small (Path is invalid): Last File + If path.Length < 2 Then path = _lastFile + + 'Open Folder - If no folder in the path: Last folder + If fPATH(path) = "" Then + 'If given a file without path + If Trim(FB_FolderHistory(0)) = "" Then + SetFolder("C:\") + Else + SetFolder(FB_FolderHistory(0)) + End If + Else + '...Otherwise: + SetFolder(fPATH(path)) + End If + If _bBrowseFolder Then + FolderUp() + TextBoxPath.Text = path + Else + TextBoxPath.Text = IO.Path.GetFileName(path) + End If + + 'Show form ------------------------------------------------ ---- + ShowDialog() + If DialogResult = DialogResult.OK Then + 'File / Folder History + If _bMultiFiles Then + _lastFile = _myFolder + UpdateHisFolder(_myFolder) + Else + _lastFile = _myFiles(0) + UpdateHisFolder(fPATH(_lastFile)) + If Not _bBrowseFolder Then UpdateHisFile(_lastFile) + End If + 'Update Global History Folder + For x = 0 To 9 + FB_FolderHistory(x) = ContextMenuHisFolder.Items(x).Text + Next + For x = 10 To 19 + FB_FolderHistory(x) = ContextMenuHisFolder.Items(x + 1).Text + Next + Return True + Else + Return False + End If + End Function + + 'Close and save File / Folder History + Public Sub SaveAndClose() + 'Folder History + If FB_Init Then + Try + Dim f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & "Directories.txt", False, Encoding.UTF8) + For x = 0 To 19 + f.WriteLine(FB_FolderHistory(x)) + Next + f.Close() + f.Dispose() + Catch ex As Exception + End Try + FB_Init = False + End If + 'File History + If _initialized And Not _bLightMode Then + If Not _bBrowseFolder Then + Try + Dim f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & _myId & ".txt", False, Encoding.UTF8) + For x = 0 To 9 + f.WriteLine(ContextMenuHisFile.Items(x).Text) + Next + f.Close() + f.Dispose() + Catch ex As Exception + End Try + End If + _initialized = False + End If + + 'Close + Close() + End Sub + + 'Switching to FolderBrowser + Public Sub SetFolderBrowser() + If _initialized Then Exit Sub + + _bBrowseFolder = True + Width = 500 + ListViewFiles.Enabled = False + ButtonHisFile.Enabled = False + TextBoxSearchFile.Enabled = False + SplitContainer1.Panel2Collapsed = True + Text = "Directory Browser" + End Sub + + 'Initialize + Private Sub Init() + _updateLock = True + + 'Initialization for Global File Browser + If Not FB_Init Then GlobalInit() + + 'Load Drive ComboBox + For x = 0 To UBound(FB_Drives) + ComboBoxDrive.Items.Add(FB_Drives(x)) + Next + + 'FolderHistory ContextMenu + ContextMenuHisFolder.Items.Clear() + For x = 0 To 9 + ContextMenuHisFolder.Items.Add("") + Next + ContextMenuHisFolder.Items.Add("-") + For x = 10 To 19 + ContextMenuHisFolder.Items.Add("") + Next + ContextMenuHisFolder.Items.Add("-") + ContextMenuHisFolder.Items.Add(FavText) + + 'FileHistory ContextMenu + If _bBrowseFolder Then + _lastFile = FB_FolderHistory(0) + ElseIf Not _bLightMode Then + For x = 0 To 9 + ContextMenuHisFile.Items.Add("") + Next + If File.Exists(FB_FilHisDir & _myId & ".txt") Then + Dim f = New StreamReader(FB_FilHisDir & _myId & ".txt") + Dim x = -1 + Do While Not f.EndOfStream And x < 9 + x += 1 + Dim line = f.ReadLine + ContextMenuHisFile.Items(x).Text = line + If x = 0 Then _lastFile = line + Loop + f.Close() + f.Dispose() + End If + End If + + 'Extension-ComboBox + If Not _noExt Then + _extListSingle = New ArrayList + _extListMulti = New ArrayList + For x = 0 To UBound(_myExt) + _extListMulti.Add(_myExt(x)) + For Each line In _myExt(x).Split(",") + _extListSingle.Add(Trim(line)) + Next + Next + _extListMulti.Add("*") + _extListSingle.Add("*") + End If + + _initialized = True + _updateLock = False + End Sub + + Private Sub GlobalInit() + + 'Create Drive List + ReDim FB_Drives(UBound(Directory.GetLogicalDrives())) + Dim x = -1 + For Each drive In Directory.GetLogicalDrives() + x += 1 + FB_Drives(x) = Microsoft.VisualBasic.Left(drive, 2) + Next + + 'Read Folder History + For x = 0 To 19 + FB_FolderHistory(x) = EmptyText + Next + If File.Exists(FB_FilHisDir & "Directories.txt") Then + Dim f = New StreamReader(FB_FilHisDir & "Directories.txt") + x = -1 + Do While Not f.EndOfStream And x < 19 + x += 1 + FB_FolderHistory(x) = f.ReadLine() + Loop + f.Dispose() + f.Close() + End If + + FB_Init = True + End Sub + + 'ComboBoxDrive_SelectedIndexChanged + Private Sub ComboBoxDrive_SelectedIndexChanged(sender As Object, e As EventArgs) _ + Handles ComboBoxDrive.SelectedIndexChanged + If Not _updateLock Then SetFolder(ComboBoxDrive.SelectedItem.ToString) + End Sub + + + 'ButtonFolderBack_Click + Private Sub ButtonFolderBack_Click(sender As Object, e As EventArgs) Handles ButtonFolderBack.Click + FolderUp() + End Sub + + 'TextBoxPath_KeyDown (ENTER) + Private Sub TextBoxPath_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBoxPath.KeyDown + If e.KeyCode = Keys.Enter Then + Dim path = TextBoxPath.Text + If Directory.Exists(path) Then + If _bBrowseFolder Then + DialogResult = DialogResult.OK + Close() + Else + SetFolder(path) + End If + Else + DialogResult = DialogResult.OK + Close() + End If + End If + End Sub + + 'ListViewFolder_SelectedIndexChanged + Private Sub ListViewFolder_SelectedIndexChanged(sender As Object, e As EventArgs) _ + Handles ListViewFolder.SelectedIndexChanged + If _bBrowseFolder Then + _updateLock = True + If ListViewFolder.SelectedItems.Count > 0 Then + TextBoxPath.Text = ListViewFolder.SelectedItems.Item(0).Text & "\" + End If + _updateLock = False + End If + End Sub + + 'ListViewFolder_MouseDoubleClick + Private Sub ListViewFolder_MouseDoubleClick(sender As Object, e As MouseEventArgs) _ + Handles ListViewFolder.MouseDoubleClick + If ListViewFolder.SelectedItems.Count = 0 Then Exit Sub + SetFolder(_myFolder & ListViewFolder.SelectedItems.Item(0).Text) + End Sub + + 'ListViewFolder_KeyDown + Private Sub ListViewFolder_KeyDown(sender As Object, e As KeyEventArgs) Handles ListViewFolder.KeyDown + If e.KeyCode = Keys.Enter Then + If ListViewFolder.SelectedItems.Count = 0 Then Exit Sub + SetFolder(_myFolder & ListViewFolder.SelectedItems.Item(0).Text) + End If + End Sub + + 'ListViewFiles_SelectedIndexChanged + Private Sub ListViewFiles_SelectedIndexChanged(sender As Object, e As EventArgs) _ + Handles ListViewFiles.SelectedIndexChanged + _updateLock = True + If ListViewFiles.SelectedItems.Count = 0 Then + TextBoxPath.Text = "" + Else + If ListViewFiles.SelectedItems.Count > 1 Then + TextBoxPath.Text = "<" & ListViewFiles.SelectedItems.Count & " Files selected>" + Else + TextBoxPath.Text = ListViewFiles.SelectedItems.Item(0).Text + TextBoxPath.SelectionStart = TextBoxPath.Text.Length + End If + End If + _updateLock = False + End Sub + + 'ListViewFiles_MouseDoubleClick + Private Sub ListViewFiles_MouseDoubleClick(sender As Object, e As MouseEventArgs) _ + Handles ListViewFiles.MouseDoubleClick + If ListViewFiles.SelectedItems.Count = 0 Then Exit Sub + + DialogResult = DialogResult.OK + Close() + End Sub + + 'ListViewFiles_KeyDown + Private Sub ListViewFiles_KeyDown(sender As Object, e As KeyEventArgs) Handles ListViewFiles.KeyDown + If e.KeyCode = Keys.Enter Then + If ListViewFiles.SelectedItems.Count = 0 Then Exit Sub + DialogResult = DialogResult.OK + Close() + End If + End Sub + + 'TextBoxSearchFolder_KeyDown + Private Sub TextBoxSearchFolder_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBoxSearchFolder.KeyDown + Dim itemCount = ListViewFolder.Items.Count + Dim noItem = (itemCount = 0) + + Dim selIndex As Integer + If Not noItem Then + If ListViewFolder.SelectedItems.Count = 0 Then + selIndex = -1 + Else + selIndex = ListViewFolder.SelectedIndices(0) + End If + End If + Select Case e.KeyCode + Case Keys.Enter + If noItem Then Exit Sub + If ListViewFolder.SelectedItems.Count = 0 Then ListViewFolder.SelectedIndices.Add(0) + SetFolder(_myFolder & ListViewFolder.SelectedItems.Item(0).Text) + Case Keys.Up + If Not noItem Then + If selIndex < 1 Then + selIndex = 1 + Else + ListViewFolder.Items(selIndex).Selected = False + End If + ListViewFolder.Items(selIndex - 1).Selected = True + ListViewFolder.Items(selIndex - 1).EnsureVisible() + End If + Case Keys.Down + If Not noItem And selIndex < itemCount - 1 Then + If Not selIndex = -1 Then ListViewFolder.Items(selIndex).Selected = False + ListViewFolder.Items(selIndex + 1).Selected = True + ListViewFolder.Items(selIndex + 1).EnsureVisible() + End If + Case Keys.Back + If TextBoxSearchFolder.Text = "" Then FolderUp() + End Select + End Sub + + 'TextBoxSearchFolder_TextChanged + Private Sub TextBoxSearchFolder_TextChanged(sender As Object, e As EventArgs) Handles TextBoxSearchFolder.TextChanged + If Not _updateLock Then LoadListFolder() + End Sub + + 'TextBoxSearchFile_KeyDown + Private Sub TextBoxSearchFile_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBoxSearchFile.KeyDown + Dim selIndex As Integer + + Dim itemCount = ListViewFiles.Items.Count + Dim noItem = (itemCount = 0) + If Not noItem Then + If ListViewFiles.SelectedItems.Count = 0 Then + selIndex = -1 + Else + selIndex = ListViewFiles.SelectedIndices(0) + End If + End If + Select Case e.KeyCode + Case Keys.Enter + If noItem Then Exit Sub + If ListViewFiles.SelectedItems.Count = 0 Then ListViewFiles.SelectedIndices.Add(0) + DialogResult = DialogResult.OK + Close() + Case Keys.Up + If Not noItem Then + If selIndex < 1 Then + selIndex = 1 + Else + ListViewFiles.Items(selIndex).Selected = False + End If + ListViewFiles.Items(selIndex - 1).Selected = True + ListViewFiles.Items(selIndex - 1).EnsureVisible() + End If + Case Keys.Down + If Not noItem And selIndex < itemCount - 1 Then + If Not selIndex = -1 Then ListViewFiles.Items(selIndex).Selected = False + ListViewFiles.Items(selIndex + 1).Selected = True + ListViewFiles.Items(selIndex + 1).EnsureVisible() + End If + End Select + End Sub + + Private Sub TextBoxSearchFile_TextChanged(sender As Object, e As EventArgs) _ + Handles TextBoxSearchFile.TextChanged, ComboBoxExt.TextChanged + If Not _updateLock Then LoadListFiles() + End Sub + + Private Sub ButtonHisFolder_Click(sender As Object, e As EventArgs) Handles ButtonHisFolder.Click, ButtonHisFile.Click + ContextMenuHisFolder.Show(MousePosition) + End Sub + + Private Sub ButtonAll_Click(sender As Object, e As EventArgs) Handles ButtonAll.Click + ListViewFiles.BeginUpdate() + For i = 0 To ListViewFiles.Items.Count - 1 + ListViewFiles.Items(i).Selected = True + Next + ListViewFiles.EndUpdate() + End Sub + + Private Sub ContextMenuHisFile_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) _ + Handles ContextMenuHisFile.ItemClicked + Dim path = e.ClickedItem.Text.ToString + If path = EmptyText Then Exit Sub + SetFolder(fPATH(path)) + TextBoxPath.Text = IO.Path.GetFileName(path) + End Sub + + Private Sub ContextMenuHisFolder_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) _ + Handles ContextMenuHisFolder.ItemClicked + + Dim path = e.ClickedItem.Text.ToString + + If path = EmptyText Then Exit Sub + + If path = FavText Then + Dim favdlog = New FB_FavDlog + If favdlog.ShowDialog = DialogResult.OK Then + For x = 10 To 19 + path = favdlog.ListBox1.Items(x - 10) + If path = NoFavString Then + FB_FolderHistory(x) = EmptyText + Else + FB_FolderHistory(x) = path + End If + ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) + Next + End If + Else + SetFolder(path) + End If + End Sub + + Private Sub TextBoxCurrent_MouseClick(sender As Object, e As MouseEventArgs) Handles TextBoxCurrent.MouseClick + Dim newpath = "" + Dim x = TextBoxCurrent.SelectionStart + Dim path = TextBoxCurrent.Text + Dim x1 = path.Length + If x = x1 Then Exit Sub + If x < 4 Then + SetFolder(Microsoft.VisualBasic.Left(path, 2)) + Exit Sub + End If + Do While x1 > x + newpath = path + 'path = Microsoft.VisualBasic.Left(path, x1 - 1) + path = Microsoft.VisualBasic.Left(path, path.LastIndexOf("\")) + x1 = path.Length + Loop + SetFolder(newpath) + End Sub + + Private Sub ButtonDesktop_Click(sender As Object, e As EventArgs) Handles ButtonDesktop.Click + SetFolder(SpecialDirectories.Desktop.ToString) + End Sub + + Private Sub UpdateHisFile(path As String) + If _bLightMode Then Exit Sub + + Dim x As Integer + For x = 0 To 8 + If UCase(ContextMenuHisFile.Items(x).Text.ToString) = UCase(path) Then Exit For + Next + For y = x To 1 Step -1 + ContextMenuHisFile.Items(y).Text = ContextMenuHisFile.Items(y - 1).Text + Next + ContextMenuHisFile.Items(0).Text = path + End Sub + + Private Sub UpdateHisFolder(path As String) + Dim x As Integer + For x = 0 To 8 + If UCase(ContextMenuHisFolder.Items(x).Text.ToString) = UCase(path) Then Exit For + Next + For y = x To 1 Step -1 + ContextMenuHisFolder.Items(y).Text = ContextMenuHisFolder.Items(y - 1).Text + Next + ContextMenuHisFolder.Items(0).Text = path + End Sub + + Public Sub UpdateHistory(path As String) + If Not _initialized Then Init() + UpdateHisFile(path) + path = fPATH(path) + Dim x As Integer + For x = 0 To 8 + If UCase(FB_FolderHistory(x)) = UCase(path) Then Exit For + Next + For y = x To 1 Step -1 + FB_FolderHistory(y) = FB_FolderHistory(y - 1) + Next + FB_FolderHistory(0) = path + End Sub + + 'Change folder + Private Sub SetFolder(path As String) + + 'Abort if no drive specified + If Mid(path, 2, 1) <> ":" Then Exit Sub + + _updateLock = True + + 'Delete Search-fields + TextBoxSearchFile.Text = "" + TextBoxSearchFolder.Text = "" + + 'Set Drive + If _myDrive <> Microsoft.VisualBasic.Left(path, 2) Then + _myDrive = UCase(Microsoft.VisualBasic.Left(path, 2)) + ComboBoxDrive.SelectedItem = _myDrive + End If + + 'Set Folder + _myFolder = path + If Microsoft.VisualBasic.Right(_myFolder, 1) <> "\" Then _myFolder &= "\" + LoadListFolder() + LoadListFiles() + + If _bBrowseFolder Then TextBoxPath.Text = "" + + TextBoxCurrent.Text = _myFolder + + 'TextBoxPath.SelectionStart = TextBoxPath.Text.Length + _updateLock = False + End Sub + + 'Folder one level up + Private Sub FolderUp() + If _myFolder <> "" Then + Dim path = Microsoft.VisualBasic.Left(_myFolder, _myFolder.Length - 1) + Dim x = path.LastIndexOf("\") + If x > 0 Then SetFolder(Microsoft.VisualBasic.Left(path, x)) + End If + End Sub + + 'Load Folder-List + Private Sub LoadListFolder() + 'Delete Folder-List + ListViewFolder.Items.Clear() + Dim searchPat = "*" & TextBoxSearchFolder.Text & "*" + Try + 'Add Folder + Dim di As New DirectoryInfo(_myFolder) + Dim aryFi = di.GetDirectories(searchPat) + For Each fi In aryFi + ListViewFolder.Items.Add(fi.ToString) + Next + Catch ex As Exception + ListViewFolder.Items.Add("<ERROR: " & ex.Message.ToString & ">") + End Try + End Sub + + 'Load File-list + Private Sub LoadListFiles() + 'Abort if bBrowseFolder + If _bBrowseFolder Then Exit Sub + + LabelFileAnz.Text = "0 Files" + 'Define Extension-filter + Dim extStr As String() + If Trim(ComboBoxExt.Text.ToString) = "" Then + extStr = New String() {"*"} + Else + extStr = ComboBoxExt.Text.ToString.Split(",") + End If + + 'Delete File-List + ListViewFiles.Items.Clear() + + Dim searchFile = TextBoxSearchFile.Text + + ListViewFiles.BeginUpdate() + Try + 'Add Folder + Dim di As New DirectoryInfo(_myFolder) + Dim aryFi As FileInfo() + Dim fi As FileInfo + Dim x = -1 + For Each SearchExt In extStr + Dim searchPat = "*" & Trim(searchFile) & "*." & Trim(SearchExt) + aryFi = di.GetFiles(searchPat) + For Each fi In aryFi + x += 1 + ListViewFiles.Items.Add(fi.ToString) + Next + Next + If x = 0 Then + LabelFileAnz.Text = "1 File" + Else + LabelFileAnz.Text = x + 1 & " Files" + End If + Catch ex As Exception + ListViewFiles.Items.Add("<ERROR: " & ex.Message.ToString & ">") + End Try + + ListViewFiles.EndUpdate() + End Sub + + 'Rename File + Private Sub RenameFileToolStripMenuItem_Click(sender As Object, e As EventArgs) _ + Handles RenameFileToolStripMenuItem.Click + + If ListViewFiles.SelectedItems.Count = 1 Then + Dim file0 = ListViewFiles.SelectedItems(0).Text + Dim file = file0 lb1: - file = InputBox("New Filename", "Rename " & file0, file) - If file <> "" Then - If IO.File.Exists(MyFolder & file) Then - MsgBox("File " & file & " already exists!") - GoTo lb1 - End If - Try - My.Computer.FileSystem.RenameFile(MyFolder & file0, file) - LoadListFiles() - Catch ex As Exception - MsgBox("Cannot rename " & file0 & "!") - End Try - End If - End If - End Sub - - 'Delete File - Private Sub DeleteFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteFileToolStripMenuItem.Click - Dim x As Int32 - Dim c As Int32 - c = Me.ListViewFiles.SelectedItems.Count - If c > 0 Then - If c = 1 Then - If MsgBox("Delete " & MyFolder & Me.ListViewFiles.SelectedItems(0).Text & "?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub - Else - If MsgBox("Delete " & c & " files?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub - End If - For x = 0 To c - 1 - Try - IO.File.Delete(MyFolder & Me.ListViewFiles.SelectedItems(x).Text) - Catch ex As Exception - End Try - Next - LoadListFiles() - End If - End Sub - - 'Neuer Ordner - Private Sub ButtonNewDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonNewDir.Click - Dim f As String - f = "New Folder" + file = InputBox("New Filename", "Rename " & file0, file) + If file <> "" Then + If IO.File.Exists(_myFolder & file) Then + MsgBox("File " & file & " already exists!") + GoTo lb1 + End If + Try + My.Computer.FileSystem.RenameFile(_myFolder & file0, file) + LoadListFiles() + Catch ex As Exception + MsgBox("Cannot rename " & file0 & "!") + End Try + End If + End If + End Sub + + 'Delete File + Private Sub DeleteFileToolStripMenuItem_Click(sender As Object, e As EventArgs) _ + Handles DeleteFileToolStripMenuItem.Click + Dim c = ListViewFiles.SelectedItems.Count + If c > 0 Then + If c = 1 Then + If MsgBox("Delete " & _myFolder & ListViewFiles.SelectedItems(0).Text & "?", MsgBoxStyle.YesNo) = MsgBoxResult.No _ + Then Exit Sub + Else + If MsgBox("Delete " & c & " files?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub + End If + For x = 0 To c - 1 + Try + File.Delete(_myFolder & ListViewFiles.SelectedItems(x).Text) + Catch ex As Exception + End Try + Next + LoadListFiles() + End If + End Sub + + 'Neuer Ordner + Private Sub ButtonNewDir_Click(sender As Object, e As EventArgs) Handles ButtonNewDir.Click + Dim f = "New Folder" lb10: - f = InputBox("Create New Folder", "New Folder", f) - If f <> "" Then - If IO.Directory.Exists(MyFolder & f) Then - MsgBox("Folder " & MyFolder & f & " already exists!") - GoTo lb10 - End If - Try - IO.Directory.CreateDirectory(MyFolder & f) - SetFolder(MyFolder & f) - Catch ex As Exception - MsgBox("Cannot create " & f & "!") - End Try - End If - End Sub - - ''Private Function fTimeString(ByVal T As Date) As String - '' Return T.Year & "-" & T.Month.ToString("00") & "-" & T.Day.ToString("00") & " " & T.Hour.ToString("00") & ":" & T.Minute.ToString("00") & ":" & T.Second.ToString("00") - ''End Function - - - Private Function fPATH(ByVal Pfad As String) As String - Dim x As Int16 - x = Pfad.LastIndexOf("\") - If x = -1 Then - Return Microsoft.VisualBasic.Left(Pfad, 0) - Else - Return Microsoft.VisualBasic.Left(Pfad, x + 1) - End If - End Function - - Public ReadOnly Property Folder() As String - Get - Return MyFolder - End Get - End Property - - Public ReadOnly Property Files() As String() - Get - Return MyFiles - End Get - End Property - - Public Property ID() As String - Get - Return MyID - End Get - Set(ByVal value As String) - MyID = value - End Set - End Property - - Public Property Extensions() As String() - Get - Return MyExt - End Get - Set(ByVal value As String()) - MyExt = value - LastExt = MyExt(0) - NoExt = False - End Set - End Property + f = InputBox("Create New Folder", "New Folder", f) + If f <> "" Then + If Directory.Exists(_myFolder & f) Then + MsgBox("Folder " & _myFolder & f & " already exists!") + GoTo lb10 + End If + Try + Directory.CreateDirectory(_myFolder & f) + SetFolder(_myFolder & f) + Catch ex As Exception + MsgBox("Cannot create " & f & "!") + End Try + End If + End Sub + + Private Shared Function fPATH(Pfad As String) As String + Dim x = Pfad.LastIndexOf("\") + If x = -1 Then + Return Microsoft.VisualBasic.Left(Pfad, 0) + Else + Return Microsoft.VisualBasic.Left(Pfad, x + 1) + End If + End Function + + Public ReadOnly Property Folder As String + Get + Return _myFolder + End Get + End Property + + Public ReadOnly Property Files As String() + Get + Return _myFiles + End Get + End Property + + Public Property ID As String + Get + Return _myId + End Get + Set(value As String) + _myId = value + End Set + End Property + + Public Property Extensions As String() + Get + Return _myExt + End Get + Set(value As String()) + _myExt = value + _lastExt = _myExt(0) + _noExt = False + End Set + End Property +End Class -End Class diff --git a/VECTO/GUI/F_MAINForm.vb b/VECTO/GUI/F_MAINForm.vb index b31e67b7c98e5f5aefd2e4409a0f7abb1e0cbc8b..2b9b370babfda0cdd6e80da84c33bc398ee90709 100644 --- a/VECTO/GUI/F_MAINForm.vb +++ b/VECTO/GUI/F_MAINForm.vb @@ -1650,6 +1650,7 @@ lbFound: Catch ex As Exception MsgBox(String.Format("ERROR running job {0}: {1}", jobFile, ex.Message), MsgBoxStyle.Critical) sender.ReportProgress(0, New With {.Target = "ListBoxError", .Message = ex.Message}) + Return End Try Next @@ -1720,8 +1721,7 @@ lbFound: sender.ReportProgress(100, New _ With {.Target = "ListBox", - .Message = String.Format("PDF-Report for '{0}' written to {1}", Path.GetFileName(job), report), .Link = report - }) + .Message = String.Format("PDF-Report for '{0}' written to {1}", Path.GetFileName(job), report), .Link = "<RUN>" + report}) End If Next diff --git a/VECTO/GUI/F_VECTO.vb b/VECTO/GUI/F_VECTO.vb index f0878655aebcbb2e355633838d0a37fc69647b8e..90eba9275e25cc27753b910fbbb551d3feb89e70 100644 --- a/VECTO/GUI/F_VECTO.vb +++ b/VECTO/GUI/F_VECTO.vb @@ -10,8 +10,10 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.Drawing.Imaging Imports System.IO -Imports VectoAuxiliaries +Imports System.Text.RegularExpressions +Imports System.Windows.Forms.DataVisualization.Charting ''' <summary> ''' Job Editor. Create/Edit VECTO job files (.vecto) @@ -38,7 +40,7 @@ Public Class F_VECTO 'Scan the program directory for DLL's which are AdvancedAuxiliaries and display - Dim AList As List(Of cAdvancedAuxiliary) = mAAUX_Global.DiscoverAdvancedAuxiliaries() + Dim AList As List(Of cAdvancedAuxiliary) = DiscoverAdvancedAuxiliaries() cboAdvancedAuxiliaries.DataSource = AList cboAdvancedAuxiliaries.DisplayMember = "AuxiliaryName" @@ -46,7 +48,7 @@ Public Class F_VECTO 'Initialise form - Private Sub F02_GEN_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + Private Sub F02_GEN_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim x As Int16 n_idle = -1 @@ -87,7 +89,7 @@ Public Class F_VECTO End Sub 'Close - Check for unsaved changes - Private Sub F02_GEN_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) _ + Private Sub F02_GEN_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) _ Handles Me.FormClosing If e.CloseReason <> CloseReason.ApplicationExitCall And e.CloseReason <> CloseReason.WindowsShutDown Then e.Cancel = ChangeCheckCancel() @@ -193,27 +195,27 @@ Public Class F_VECTO #Region "Browse Buttons" - Private Sub ButtonVEH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonVEH.Click + Private Sub ButtonVEH_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonVEH.Click If fbVEH.OpenDialog(fFileRepl(Me.TbVEH.Text, fPATH(VECTOfile))) Then _ Me.TbVEH.Text = fFileWoDir(fbVEH.Files(0), fPATH(VECTOfile)) End Sub - Private Sub ButtonMAP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonMAP.Click + Private Sub ButtonMAP_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonMAP.Click If fbENG.OpenDialog(fFileRepl(Me.TbENG.Text, fPATH(VECTOfile))) Then _ Me.TbENG.Text = fFileWoDir(fbENG.Files(0), fPATH(VECTOfile)) End Sub - Private Sub ButtonGBX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGBX.Click + Private Sub ButtonGBX_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonGBX.Click If fbGBX.OpenDialog(fFileRepl(Me.TbGBX.Text, fPATH(VECTOfile))) Then _ Me.TbGBX.Text = fFileWoDir(fbGBX.Files(0), fPATH(VECTOfile)) End Sub - Private Sub BtDesMaxBr_Click_1(sender As System.Object, e As System.EventArgs) Handles BtDesMaxBr.Click + Private Sub BtDesMaxBr_Click_1(sender As Object, e As EventArgs) Handles BtDesMaxBr.Click If fbACC.OpenDialog(fFileRepl(Me.TbDesMaxFile.Text, fPATH(VECTOfile))) Then _ Me.TbDesMaxFile.Text = fFileWoDir(fbACC.Files(0), fPATH(VECTOfile)) End Sub - Private Sub BtAccOpen_Click(sender As System.Object, e As System.EventArgs) Handles BtAccOpen.Click + Private Sub BtAccOpen_Click(sender As Object, e As EventArgs) Handles BtAccOpen.Click OpenFiles(fFileRepl(Me.TbDesMaxFile.Text, fPATH(VECTOfile))) End Sub @@ -222,7 +224,7 @@ Public Class F_VECTO #Region "Open Buttons" 'Open Vehicle Editor - Private Sub ButOpenVEH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButOpenVEH.Click + Private Sub ButOpenVEH_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButOpenVEH.Click Dim f As String f = fFileRepl(TbVEH.Text, fPATH(VECTOfile)) @@ -231,7 +233,7 @@ Public Class F_VECTO F_VEH.AutoSendTo = True If Not Trim(f) = "" Then - If Not IO.File.Exists(f) Then + If Not File.Exists(f) Then MsgBox("File not found!") Exit Sub End If @@ -248,7 +250,7 @@ Public Class F_VECTO End Sub 'Open Engine Editor - Private Sub ButOpenENG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButOpenENG.Click + Private Sub ButOpenENG_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButOpenENG.Click Dim f As String f = fFileRepl(TbENG.Text, fPATH(VECTOfile)) @@ -257,7 +259,7 @@ Public Class F_VECTO F_ENG.AutoSendTo = True If Not Trim(f) = "" Then - If Not IO.File.Exists(f) Then + If Not File.Exists(f) Then MsgBox("File not found!") Exit Sub End If @@ -274,7 +276,7 @@ Public Class F_VECTO End Sub 'Open Gearbox Editor - Private Sub ButOpenGBX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButOpenGBX.Click + Private Sub ButOpenGBX_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButOpenGBX.Click Dim f As String f = fFileRepl(TbGBX.Text, fPATH(VECTOfile)) @@ -283,7 +285,7 @@ Public Class F_VECTO F_GBX.AutoSendTo = True If Not Trim(f) = "" Then - If Not IO.File.Exists(f) Then + If Not File.Exists(f) Then MsgBox("File not found!") Exit Sub End If @@ -304,27 +306,27 @@ Public Class F_VECTO #Region "Toolbar" 'New - Private Sub ToolStripBtNew_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtNew.Click + Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click VECTOnew() End Sub 'Open - Private Sub ToolStripBtOpen_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtOpen.Click + Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click If fbVECTO.OpenDialog(VECTOfile, False, "vecto") Then VECTOload2Form(fbVECTO.Files(0)) End Sub 'Save - Private Sub ToolStripBtSave_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtSave.Click + Private Sub ToolStripBtSave_Click(sender As Object, e As EventArgs) Handles ToolStripBtSave.Click Save() End Sub 'Save As - Private Sub ToolStripBtSaveAs_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtSaveAs.Click + Private Sub ToolStripBtSaveAs_Click(sender As Object, e As EventArgs) Handles ToolStripBtSaveAs.Click If fbVECTO.SaveDialog(VECTOfile) Then Call VECTOsave(fbVECTO.Files(0)) End Sub 'Send to Job file list in main form - Private Sub ToolStripBtSendTo_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtSendTo.Click + Private Sub ToolStripBtSendTo_Click(sender As Object, e As EventArgs) Handles ToolStripBtSendTo.Click If ChangeCheckCancel() Then Exit Sub If VECTOfile = "" Then MsgBox("File not found!" & ChrW(10) & ChrW(10) & "Save file and try again.") @@ -334,14 +336,14 @@ Public Class F_VECTO End Sub 'Help - Private Sub ToolStripButton1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton1.Click - If IO.File.Exists(MyAppPath & "User Manual\help.html") Then + Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click + If File.Exists(MyAppPath & "User Manual\help.html") Then Dim BrowserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString Dim DefaultBrowserPath As String = - System.Text.RegularExpressions.Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - System.Diagnostics.Process.Start(DefaultBrowserPath, - String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#job-editor")) + Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString + Process.Start(DefaultBrowserPath, + String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#job-editor")) Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -525,13 +527,13 @@ Public Class F_VECTO If cboAdvancedAuxiliaries.SelectedIndex > 0 Then 'resolve absolute path for auxiliary file. - absoluteAAUxFile = mAAUX_Global.ResolveAAUXFilePath(fPATH(VECTOfile), txtAdvancedAuxiliaryFile.Text) + absoluteAAUxFile = ResolveAAUXFilePath(fPATH(VECTOfile), txtAdvancedAuxiliaryFile.Text) aaAssemblyName = DirectCast(cboAdvancedAuxiliaries.SelectedItem, cAdvancedAuxiliary).AssemblyName aaAssemblyVersion = DirectCast(cboAdvancedAuxiliaries.SelectedItem, cAdvancedAuxiliary).AuxiliaryVersion - If Not mAAUX_Global.ValidateAAUXFile(absoluteAAUxFile, aaAssemblyName, aaAssemblyVersion, message) Then + If Not ValidateAAUXFile(absoluteAAUxFile, aaAssemblyName, aaAssemblyVersion, message) Then MessageBox.Show( String.Format("You have selected an advanced auxiliary *Auxiliary Type*, but the file specified is invalid :{0}", message)) @@ -683,56 +685,56 @@ Public Class F_VECTO #Region "'Change' Events" - Private Sub TextBoxVEH_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub TextBoxVEH_TextChanged(ByVal sender As Object, ByVal e As EventArgs) _ Handles TbVEH.TextChanged UpdatePic() Change() End Sub - Private Sub TextBoxMAP_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub TextBoxMAP_TextChanged(ByVal sender As Object, ByVal e As EventArgs) _ Handles TbENG.TextChanged UpdatePic() Change() End Sub - Private Sub TextBoxFLD_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub TextBoxFLD_TextChanged(ByVal sender As Object, ByVal e As EventArgs) _ Handles TbGBX.TextChanged UpdatePic() Change() End Sub - Private Sub TbDesMaxFile_TextChanged_1(sender As System.Object, e As System.EventArgs) Handles TbDesMaxFile.TextChanged + Private Sub TbDesMaxFile_TextChanged_1(sender As Object, e As EventArgs) Handles TbDesMaxFile.TextChanged Change() End Sub - Private Sub TBSSspeed_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbSSspeed.TextChanged + Private Sub TBSSspeed_TextChanged(sender As Object, e As EventArgs) Handles TbSSspeed.TextChanged Change() End Sub - Private Sub TBSStime_TextChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub TBSStime_TextChanged(sender As Object, e As EventArgs) _ Handles TbSStime.TextChanged, TbSSdelay.TextChanged Change() End Sub - Private Sub TbOverspeed_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbOverspeed.TextChanged + Private Sub TbOverspeed_TextChanged(sender As Object, e As EventArgs) Handles TbOverspeed.TextChanged Change() End Sub - Private Sub TbUnderSpeed_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbUnderSpeed.TextChanged + Private Sub TbUnderSpeed_TextChanged(sender As Object, e As EventArgs) Handles TbUnderSpeed.TextChanged Change() End Sub - Private Sub TbVmin_TextChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub TbVmin_TextChanged(sender As Object, e As EventArgs) _ Handles TbVmin.TextChanged Change() End Sub - Private Sub TbAlookahead_TextChanged(sender As System.Object, e As System.EventArgs) + Private Sub TbAlookahead_TextChanged(sender As Object, e As EventArgs) Change() End Sub - Private Sub LvCycles_AfterLabelEdit(sender As Object, e As System.Windows.Forms.LabelEditEventArgs) _ + Private Sub LvCycles_AfterLabelEdit(sender As Object, e As LabelEditEventArgs) _ Handles LvCycles.AfterLabelEdit Change() End Sub @@ -773,7 +775,7 @@ Public Class F_VECTO #Region "Aux Listview" - Private Sub ButAuxAdd_Click(sender As System.Object, e As System.EventArgs) Handles ButAuxAdd.Click + Private Sub ButAuxAdd_Click(sender As Object, e As EventArgs) Handles ButAuxAdd.Click Dim LV0 As ListViewItem Dim ID As String @@ -784,7 +786,7 @@ Public Class F_VECTO AuxDlog.TbID.Text = "" '!!! Vorher Type setzen weil ID beim ändern von Type überschrieben wird !!!" lbDlog: - If AuxDlog.ShowDialog = Windows.Forms.DialogResult.OK Then + If AuxDlog.ShowDialog = DialogResult.OK Then ID = UCase(Trim(AuxDlog.TbID.Text)) @@ -816,15 +818,15 @@ lbDlog: End If End Sub - Private Sub ButAuxRem_Click(sender As System.Object, e As System.EventArgs) Handles ButAuxRem.Click + Private Sub ButAuxRem_Click(sender As Object, e As EventArgs) Handles ButAuxRem.Click RemoveAuxItem() End Sub - Private Sub LvAux_DoubleClick(sender As Object, e As System.EventArgs) Handles LvAux.DoubleClick + Private Sub LvAux_DoubleClick(sender As Object, e As EventArgs) Handles LvAux.DoubleClick EditAuxItem() End Sub - Private Sub LvAux_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles LvAux.KeyDown + Private Sub LvAux_KeyDown(sender As Object, e As KeyEventArgs) Handles LvAux.KeyDown Select Case e.KeyCode Case Keys.Delete, Keys.Back If Not Cfg.DeclMode Then RemoveAuxItem() @@ -865,7 +867,7 @@ lbDlog: AuxDlog.TbPath.Text = SelItem.SubItems(2).Text End If - If AuxDlog.ShowDialog = Windows.Forms.DialogResult.OK Then + If AuxDlog.ShowDialog = DialogResult.OK Then SelItem.SubItems(0).Text = UCase(Trim(AuxDlog.TbID.Text)) SelItem.SubItems(1).Text = Trim(AuxDlog.CbType.Text) @@ -917,24 +919,24 @@ lbDlog: #End Region 'OK (Save & Close) - Private Sub ButSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButOK.Click + Private Sub ButSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButOK.Click If Not Save() Then Exit Sub Me.Close() End Sub 'Cancel - Private Sub ButCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCancel.Click + Private Sub ButCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButCancel.Click Me.Close() End Sub #Region "Cycle list" - Private Sub LvCycles_DoubleClick(sender As Object, e As System.EventArgs) Handles LvCycles.DoubleClick + Private Sub LvCycles_DoubleClick(sender As Object, e As EventArgs) Handles LvCycles.DoubleClick If Me.LvCycles.SelectedItems.Count > 0 Then _ OpenFiles(fFileRepl(Me.LvCycles.SelectedItems(0).SubItems(0).Text, fPATH(VECTOfile))) End Sub - Private Sub LvCycles_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles LvCycles.KeyDown + Private Sub LvCycles_KeyDown(sender As Object, e As KeyEventArgs) Handles LvCycles.KeyDown Select Case e.KeyCode Case Keys.Delete, Keys.Back RemoveCycle() @@ -944,7 +946,7 @@ lbDlog: End Sub - Private Sub BtDRIadd_Click(sender As System.Object, e As System.EventArgs) Handles BtDRIadd.Click + Private Sub BtDRIadd_Click(sender As Object, e As EventArgs) Handles BtDRIadd.Click Dim str As String Dim GenDir As String @@ -961,7 +963,7 @@ lbDlog: End If End Sub - Private Sub BtDRIrem_Click(sender As System.Object, e As System.EventArgs) Handles BtDRIrem.Click + Private Sub BtDRIrem_Click(sender As Object, e As EventArgs) Handles BtDRIrem.Click RemoveCycle() End Sub @@ -998,7 +1000,7 @@ lbDlog: #Region "Enable/Disable GUI controls" 'Engine only mode changed - Private Sub CbEngOnly_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CbEngOnly.CheckedChanged + Private Sub CbEngOnly_CheckedChanged(sender As Object, e As EventArgs) Handles CbEngOnly.CheckedChanged CheckEngOnly() Change() End Sub @@ -1020,21 +1022,21 @@ lbDlog: End Sub 'Start/Stop changed - Private Sub ChBStartStop_CheckedChanged_1(sender As System.Object, e As System.EventArgs) _ + Private Sub ChBStartStop_CheckedChanged_1(sender As Object, e As EventArgs) _ Handles ChBStartStop.CheckedChanged Change() If Not Cfg.DeclMode Then Me.PnStartStop.Enabled = Me.ChBStartStop.Checked End Sub 'LAC changed - Private Sub CbLookAhead_CheckedChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub CbLookAhead_CheckedChanged(sender As Object, e As EventArgs) _ Handles CbLookAhead.CheckedChanged Change() Me.PnLookAhead.Enabled = CbLookAhead.Checked End Sub 'EcoRoll / Overspeed changed - Private Sub RdOff_CheckedChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub RdOff_CheckedChanged(sender As Object, e As EventArgs) _ Handles RdOff.CheckedChanged, RdOverspeed.CheckedChanged, RdEcoRoll.CheckedChanged Dim EcoR As Boolean Dim Ovr As Boolean @@ -1080,9 +1082,9 @@ lbDlog: Dim HDVclass As String Dim m0 As tMission - Dim MyChart As System.Windows.Forms.DataVisualization.Charting.Chart - Dim s As System.Windows.Forms.DataVisualization.Charting.Series - Dim a As System.Windows.Forms.DataVisualization.Charting.ChartArea + Dim MyChart As Chart + Dim s As Series + Dim a As ChartArea Dim img As Image Dim EngOK As Boolean = False @@ -1099,8 +1101,8 @@ lbDlog: VEH0.FilePath = fFileRepl(Me.TbVEH.Text, fPATH(VECTOfile)) If VEH0.ReadFile(False) Then - - If Declaration.SegmentTable.SetRef(s0, VEH0.VehCat, VEH0.AxleConf, VEH0.MassMax) Then + s0 = Declaration.SegmentTable.SetRef(VEH0.VehCat, VEH0.AxleConf, VEH0.MassMax) + If Not s0 Is Nothing Then HDVclass = s0.HDVclass If Cfg.DeclMode Then @@ -1130,11 +1132,11 @@ lbDlog: ENG0.FilePath = fFileRepl(Me.TbENG.Text, fPATH(VECTOfile)) 'Create plot - MyChart = New System.Windows.Forms.DataVisualization.Charting.Chart + MyChart = New Chart MyChart.Width = Me.PicBox.Width MyChart.Height = Me.PicBox.Height - a = New System.Windows.Forms.DataVisualization.Charting.ChartArea + a = New ChartArea FLD0 = New cFLD @@ -1148,17 +1150,17 @@ lbDlog: If FLD0.ReadFile(False, False) Then - s = New System.Windows.Forms.DataVisualization.Charting.Series + s = New Series s.Points.DataBindXY(FLD0.LnU, FLD0.LTq) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkBlue s.Name = "Full load" MyChart.Series.Add(s) - s = New System.Windows.Forms.DataVisualization.Charting.Series + s = New Series s.Points.DataBindXY(FLD0.LnU, FLD0.LTqDrag) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.Blue s.Name = "Motoring" @@ -1178,9 +1180,9 @@ lbDlog: If MAP0.ReadFile(False) Then - s = New System.Windows.Forms.DataVisualization.Charting.Series + s = New Series s.Points.DataBindXY(MAP0.nU, MAP0.Tq) - s.ChartType = DataVisualization.Charting.SeriesChartType.Point + s.ChartType = SeriesChartType.Point s.MarkerSize = 3 s.Color = Color.Red s.Name = "Map" @@ -1214,17 +1216,17 @@ lbDlog: Shiftpoly = New cGBX.cShiftPolygon("", 0) Shiftpoly.SetGenericShiftPoly(FLD0, ENG0.Nidle) - s = New System.Windows.Forms.DataVisualization.Charting.Series + s = New Series s.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed s.Name = "Upshift curve (" & i & ")" MyChart.Series.Add(s) - s = New System.Windows.Forms.DataVisualization.Charting.Series + s = New Series s.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed s.Name = "Downshift curve (" & i & ")" @@ -1264,17 +1266,17 @@ lbDlog: ldown.Add(CSng(line(2))) Loop - s = New System.Windows.Forms.DataVisualization.Charting.Series + s = New Series s.Points.DataBindXY(lup, lM) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + 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 System.Windows.Forms.DataVisualization.Charting.Series + s = New Series s.Points.DataBindXY(ldown, lM) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed s.Name = "Downshift curve" @@ -1303,17 +1305,17 @@ lbDlog: 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 = DataVisualization.Charting.LabelAutoFitStyles.None - a.AxisX.MajorGrid.LineDashStyle = DataVisualization.Charting.ChartDashStyle.Dot + 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 = DataVisualization.Charting.LabelAutoFitStyles.None - a.AxisY.MajorGrid.LineDashStyle = DataVisualization.Charting.ChartDashStyle.Dot + a.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None + a.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot a.AxisX.Minimum = 300 - a.BorderDashStyle = DataVisualization.Charting.ChartDashStyle.Solid + a.BorderDashStyle = ChartDashStyle.Solid a.BorderWidth = 1 a.BackColor = Color.GhostWhite @@ -1322,7 +1324,7 @@ lbDlog: MyChart.Update() - img = New Bitmap(MyChart.Width, MyChart.Height, Imaging.PixelFormat.Format32bppArgb) + img = New Bitmap(MyChart.Width, MyChart.Height, PixelFormat.Format32bppArgb) MyChart.DrawToBitmap(img, New Rectangle(0, 0, Me.PicBox.Width, Me.PicBox.Height)) Me.PicBox.Image = img @@ -1344,19 +1346,19 @@ lbDlog: OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName - CmOpenFile.Show(Cursor.Position) + CmOpenFile.Show(System.Windows.Forms.Cursor.Position) End Sub - Private Sub OpenWithToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + 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 System.Object, e As System.EventArgs) _ + Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ShowInFolderToolStripMenuItem.Click - If IO.File.Exists(CmFiles(0)) Then + If File.Exists(CmFiles(0)) Then Try - System.Diagnostics.Process.Start("explorer", "/select,""" & CmFiles(0) & "") + Process.Start("explorer", "/select,""" & CmFiles(0) & "") Catch ex As Exception MsgBox("Failed to open file!") End Try @@ -1411,7 +1413,7 @@ lbDlog: If cboAdvancedAuxiliaries.SelectedIndex = 0 Then Return 'Get Absolute Path for AAUX FILE. - absoluteAuxPath = mAAUX_Global.ResolveAAUXFilePath(fPATH(VECTOfile), txtAdvancedAuxiliaryFile.Text) + absoluteAuxPath = ResolveAAUXFilePath(fPATH(VECTOfile), txtAdvancedAuxiliaryFile.Text) 'Set Extensions fbAux.Extensions = New String() {"AAUX"} @@ -1420,13 +1422,13 @@ lbDlog: assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, cAdvancedAuxiliary) - Dim validAAUXFile As Boolean = mAAUX_Global.ValidateAAUXFile(absoluteAuxPath, assembly.AssemblyName, - assembly.AuxiliaryVersion, message) - Dim fileExists As Boolean = IO.File.Exists(absoluteAuxPath) + Dim validAAUXFile As Boolean = ValidateAAUXFile(absoluteAuxPath, assembly.AssemblyName, + assembly.AuxiliaryVersion, message) + Dim fileExists As Boolean = File.Exists(absoluteAuxPath) If fileExists AndAlso validAAUXFile Then - mAAUX_Global.ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion, - txtAdvancedAuxiliaryFile.Text, VECTOfile) + ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion, + txtAdvancedAuxiliaryFile.Text, VECTOfile) Else Dim needToFindOrCreateFile As Boolean = True @@ -1439,11 +1441,11 @@ lbDlog: assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, cAdvancedAuxiliary) If _ - IO.File.Exists(mAAUX_Global.ResolveAAUXFilePath(fPATH(VECTOfile), txtAdvancedAuxiliaryFile.Text)) OrElse + 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 - mAAUX_Global.ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion, - txtAdvancedAuxiliaryFile.Text, VECTOfile) + ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion, + txtAdvancedAuxiliaryFile.Text, VECTOfile) End If Else needToFindOrCreateFile = False diff --git a/VECTO/GUI/F_VEH.Designer.vb b/VECTO/GUI/F_VEH.Designer.vb index 8ea7b75c4ec3fbae682fac4614b642973bc05e43..714812e65d6d55f682be377ef4fca402b83847e6 100644 --- a/VECTO/GUI/F_VEH.Designer.vb +++ b/VECTO/GUI/F_VEH.Designer.vb @@ -103,10 +103,6 @@ Partial Class F_VEH Me.PnLoad = New System.Windows.Forms.Panel() Me.GrAirRes = New System.Windows.Forms.GroupBox() Me.PnCdATrTr = New System.Windows.Forms.Panel() - Me.LbCdATr = New System.Windows.Forms.Label() - Me.PnCdARig = New System.Windows.Forms.Panel() - Me.LbCdARig = New System.Windows.Forms.Label() - Me.TBcdA2 = New System.Windows.Forms.TextBox() Me.Label38 = New System.Windows.Forms.Label() Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.CmOpenFile = New System.Windows.Forms.ContextMenuStrip(Me.components) @@ -126,7 +122,6 @@ Partial Class F_VEH Me.PnLoad.SuspendLayout() Me.GrAirRes.SuspendLayout() Me.PnCdATrTr.SuspendLayout() - Me.PnCdARig.SuspendLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.CmOpenFile.SuspendLayout() Me.PnAll.SuspendLayout() @@ -168,7 +163,7 @@ Partial Class F_VEH 'Label3 ' Me.Label3.AutoSize = True - Me.Label3.Location = New System.Drawing.Point(36, 52) + Me.Label3.Location = New System.Drawing.Point(3, 6) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(37, 13) Me.Label3.TabIndex = 8 @@ -176,9 +171,7 @@ Partial Class F_VEH ' 'TBcdA ' - Me.TBcdA.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ - Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.TBcdA.Location = New System.Drawing.Point(2, 24) + Me.TBcdA.Location = New System.Drawing.Point(46, 3) Me.TBcdA.Name = "TBcdA" Me.TBcdA.Size = New System.Drawing.Size(57, 20) Me.TBcdA.TabIndex = 0 @@ -743,9 +736,6 @@ Partial Class F_VEH 'GrAirRes ' Me.GrAirRes.Controls.Add(Me.PnCdATrTr) - Me.GrAirRes.Controls.Add(Me.PnCdARig) - Me.GrAirRes.Controls.Add(Me.Label3) - Me.GrAirRes.Controls.Add(Me.Label38) Me.GrAirRes.Location = New System.Drawing.Point(278, 3) Me.GrAirRes.Name = "GrAirRes" Me.GrAirRes.Size = New System.Drawing.Size(266, 124) @@ -755,51 +745,19 @@ Partial Class F_VEH ' 'PnCdATrTr ' - Me.PnCdATrTr.Controls.Add(Me.LbCdATr) Me.PnCdATrTr.Controls.Add(Me.TBcdA) - Me.PnCdATrTr.Location = New System.Drawing.Point(79, 25) + Me.PnCdATrTr.Controls.Add(Me.Label38) + Me.PnCdATrTr.Controls.Add(Me.Label3) + Me.PnCdATrTr.Dock = System.Windows.Forms.DockStyle.Fill + Me.PnCdATrTr.Location = New System.Drawing.Point(3, 16) Me.PnCdATrTr.Name = "PnCdATrTr" - Me.PnCdATrTr.Size = New System.Drawing.Size(64, 78) + Me.PnCdATrTr.Size = New System.Drawing.Size(260, 105) Me.PnCdATrTr.TabIndex = 0 ' - 'LbCdATr - ' - Me.LbCdATr.AutoSize = True - Me.LbCdATr.Location = New System.Drawing.Point(3, 3) - Me.LbCdATr.Name = "LbCdATr" - Me.LbCdATr.Size = New System.Drawing.Size(58, 13) - Me.LbCdATr.TabIndex = 25 - Me.LbCdATr.Text = "Tr && Trailer" - ' - 'PnCdARig - ' - Me.PnCdARig.Controls.Add(Me.LbCdARig) - Me.PnCdARig.Controls.Add(Me.TBcdA2) - Me.PnCdARig.Location = New System.Drawing.Point(146, 25) - Me.PnCdARig.Name = "PnCdARig" - Me.PnCdARig.Size = New System.Drawing.Size(64, 78) - Me.PnCdARig.TabIndex = 1 - ' - 'LbCdARig - ' - Me.LbCdARig.AutoSize = True - Me.LbCdARig.Location = New System.Drawing.Point(10, 3) - Me.LbCdARig.Name = "LbCdARig" - Me.LbCdARig.Size = New System.Drawing.Size(31, 13) - Me.LbCdARig.TabIndex = 25 - Me.LbCdARig.Text = "Rigid" - ' - 'TBcdA2 - ' - Me.TBcdA2.Location = New System.Drawing.Point(3, 24) - Me.TBcdA2.Name = "TBcdA2" - Me.TBcdA2.Size = New System.Drawing.Size(57, 20) - Me.TBcdA2.TabIndex = 0 - ' 'Label38 ' Me.Label38.AutoSize = True - Me.Label38.Location = New System.Drawing.Point(212, 52) + Me.Label38.Location = New System.Drawing.Point(109, 6) Me.Label38.Name = "Label38" Me.Label38.Size = New System.Drawing.Size(24, 13) Me.Label38.TabIndex = 24 @@ -910,11 +868,8 @@ Partial Class F_VEH Me.PnLoad.ResumeLayout(False) Me.PnLoad.PerformLayout() Me.GrAirRes.ResumeLayout(False) - Me.GrAirRes.PerformLayout() Me.PnCdATrTr.ResumeLayout(False) Me.PnCdATrTr.PerformLayout() - Me.PnCdARig.ResumeLayout(False) - Me.PnCdARig.PerformLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.CmOpenFile.ResumeLayout(False) Me.PnAll.ResumeLayout(False) @@ -989,19 +944,15 @@ Partial Class F_VEH Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader Friend WithEvents PnLoad As System.Windows.Forms.Panel - Friend WithEvents LbCdARig As System.Windows.Forms.Label - Friend WithEvents LbCdATr As System.Windows.Forms.Label - Friend WithEvents TBcdA2 As System.Windows.Forms.TextBox - Friend WithEvents PnCdARig As System.Windows.Forms.Panel - Friend WithEvents PnAll As System.Windows.Forms.Panel - Friend WithEvents Label6 As System.Windows.Forms.Label - Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader - Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader - Friend WithEvents Label7 As System.Windows.Forms.Label - Friend WithEvents CbRim As System.Windows.Forms.ComboBox - Friend WithEvents PnWheelDiam As System.Windows.Forms.Panel - Friend WithEvents PicVehicle As System.Windows.Forms.PictureBox - Friend WithEvents Label8 As System.Windows.Forms.Label + Friend WithEvents PnAll As System.Windows.Forms.Panel + Friend WithEvents Label6 As System.Windows.Forms.Label + Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader + Friend WithEvents Label7 As System.Windows.Forms.Label + Friend WithEvents CbRim As System.Windows.Forms.ComboBox + Friend WithEvents PnWheelDiam As System.Windows.Forms.Panel + Friend WithEvents PicVehicle As System.Windows.Forms.PictureBox + Friend WithEvents Label8 As System.Windows.Forms.Label Friend WithEvents PnCdATrTr As System.Windows.Forms.Panel Friend WithEvents Label38 As System.Windows.Forms.Label End Class diff --git a/VECTO/GUI/F_VEH.vb b/VECTO/GUI/F_VEH.vb index 6c609ce4344e2e6964c856fd6bbddf0e38a5b1db..d14a30b06b7e60db168f389e0b67de0963fab355 100644 --- a/VECTO/GUI/F_VEH.vb +++ b/VECTO/GUI/F_VEH.vb @@ -8,7 +8,11 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports System.Collections.Generic +Option Infer On + + +Imports System.IO +Imports System.Text.RegularExpressions ''' <summary> ''' Vehicle Editor. @@ -16,45 +20,36 @@ Imports System.Collections.Generic ''' <remarks></remarks> Public Class F_VEH Dim AxlDlog As F_VEH_Axle + Private HDVclass As String Dim VehFile As String Public AutoSendTo As Boolean = False Public JobDir As String = "" Private Changed As Boolean = False - 'Close - Check for unsaved changes - Private Sub F_VEH_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) _ - Handles Me.FormClosing + Private Sub F_VEH_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing If e.CloseReason <> CloseReason.ApplicationExitCall And e.CloseReason <> CloseReason.WindowsShutDown Then e.Cancel = ChangeCheckCancel() End If End Sub 'Initialise form - Private Sub F05_VEH_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + Private Sub F05_VEH_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim txt As String - Me.TbLoadingMax.Text = "-" - Me.PnLoad.Enabled = Not Cfg.DeclMode - Me.ButAxlAdd.Enabled = Not Cfg.DeclMode - Me.ButAxlRem.Enabled = Not Cfg.DeclMode - Me.CbCdMode.Enabled = Not Cfg.DeclMode - Me.PnCdARig.Visible = Cfg.DeclMode - Me.LbCdATr.Visible = Cfg.DeclMode - Me.PnWheelDiam.Enabled = Not Cfg.DeclMode - - If Cfg.DeclMode Then - Me.PnCdATrTr.Width = 64 - Else - Me.PnCdATrTr.Width = 132 - End If + TbLoadingMax.Text = "-" + PnLoad.Enabled = Not Cfg.DeclMode + ButAxlAdd.Enabled = Not Cfg.DeclMode + ButAxlRem.Enabled = Not Cfg.DeclMode + CbCdMode.Enabled = Not Cfg.DeclMode + PnWheelDiam.Enabled = Not Cfg.DeclMode AxlDlog = New F_VEH_Axle - Me.CbRim.Items.Add("-") + CbRim.Items.Add("-") For Each txt In Declaration.RimsList - Me.CbRim.Items.Add(txt) + CbRim.Items.Add(txt) Next Changed = False @@ -64,60 +59,38 @@ Public Class F_VEH 'Set HDVclasss Private Sub SetHDVclass() - Dim s0 As cSegmentTableEntry = Nothing - Dim VehC As tVehCat - Dim AxlC As tAxleConf - Dim MaxMass As Single - Dim HDVclass As String + Dim VehC = CType(CbCat.SelectedIndex, tVehCat) + Dim AxlC = CType(CbAxleConfig.SelectedIndex, tAxleConf) + Dim MaxMass = CSng(fTextboxToNumString(TbMassMass.Text)) - VehC = CType(Me.CbCat.SelectedIndex, tVehCat) - - AxlC = CType(Me.CbAxleConfig.SelectedIndex, tAxleConf) - - MaxMass = CSng(fTextboxToNumString(Me.TbMassMass.Text)) - - If Declaration.SegmentTable.SetRef(s0, VehC, AxlC, MaxMass) Then + Dim s0 As cSegmentTableEntry = Declaration.SegmentTable.SetRef(VehC, AxlC, MaxMass) + HDVclass = "-" + If Not s0 Is Nothing Then HDVclass = s0.HDVclass - Else - HDVclass = "-" End If - Me.TbHDVclass.Text = HDVclass - - Me.PicVehicle.Image = Image.FromFile(Declaration.ConvPicPath(HDVclass, False)) + TbHDVclass.Text = HDVclass + PicVehicle.Image = Image.FromFile(Declaration.ConvPicPath(HDVclass, False)) End Sub 'Set generic values for Declaration mode Private Sub DeclInit() - Dim VehC As tVehCat - Dim AxlC As tAxleConf - Dim MaxMass As Single - Dim HDVclass As String - Dim s0 As cSegmentTableEntry = Nothing - Dim i As Int16 - Dim i0 As Int16 - Dim AxleCount As Int16 - Dim lvi As ListViewItem - Dim rdyn As Single - If Not Cfg.DeclMode Then Exit Sub - VehC = CType(Me.CbCat.SelectedIndex, tVehCat) - - AxlC = CType(Me.CbAxleConfig.SelectedIndex, tAxleConf) - - MaxMass = CSng(fTextboxToNumString(Me.TbMassMass.Text)) + Dim vehC = CType(CbCat.SelectedIndex, tVehCat) + Dim axlC = CType(CbAxleConfig.SelectedIndex, tAxleConf) + Dim maxMass = CSng(fTextboxToNumString(TbMassMass.Text)) + Dim s0 = Declaration.SegmentTable.SetRef(vehC, axlC, maxMass) - If Declaration.SegmentTable.SetRef(s0, VehC, AxlC, MaxMass) Then + If Not s0 Is Nothing Then HDVclass = s0.HDVclass + Dim axleCount As Short = s0.AxleShares(s0.Missions(0)).Count + Dim i0 = LvRRC.Items.Count - AxleCount = s0.AxleShares(s0.Missions(0)).Count - i0 = LvRRC.Items.Count - - If AxleCount > i0 Then - For i = 1 To AxleCount - LvRRC.Items.Count - lvi = New ListViewItem + If axleCount > i0 Then + For i = 1 To axleCount - LvRRC.Items.Count + Dim lvi = New ListViewItem lvi.SubItems(0).Text = (i + i0).ToString lvi.SubItems.Add("-") lvi.SubItems.Add("no") @@ -135,38 +108,29 @@ Public Class F_VEH Next End If - If s0.TrailerOnlyInLongHaul Then - Me.PnCdATrTr.Width = 64 - Me.PnCdARig.Visible = True - Me.LbCdATr.Visible = True - Else - Me.PnCdATrTr.Width = 132 - Me.PnCdARig.Visible = False - Me.LbCdATr.Visible = False - End If - - Me.PnAll.Enabled = True + PnAll.Enabled = True Else - Me.PnAll.Enabled = False + PnAll.Enabled = False HDVclass = "-" End If - Me.TbMassExtra.Text = "-" - Me.TbLoad.Text = "-" - Me.CbCdMode.SelectedIndex = CType(tCdMode.CdOfVdecl, Integer) - Me.TbCdFile.Text = "" + TbMassExtra.Text = "-" + TbLoad.Text = "-" + CbCdMode.SelectedIndex = CType(tCdMode.CdOfVdecl, Integer) + TbCdFile.Text = "" - If Me.LvRRC.Items.Count > 0 Then - rdyn = Declaration.rdyn(Me.LvRRC.Items(1).SubItems(5).Text, Me.CbRim.Text) + Dim rdyn As Single + If LvRRC.Items.Count > 0 Then + rdyn = Declaration.rdyn(LvRRC.Items(1).SubItems(5).Text, CbRim.Text) Else - rdyn = - 1 + rdyn = -1 End If If rdyn < 0 Then - Me.TBrdyn.Text = "-" + TBrdyn.Text = "-" Else - Me.TBrdyn.Text = rdyn + TBrdyn.Text = rdyn End If End Sub @@ -174,27 +138,27 @@ Public Class F_VEH #Region "Toolbar" 'New - Private Sub ToolStripBtNew_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtNew.Click + Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click newVEH() End Sub 'Open - Private Sub ToolStripBtOpen_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtOpen.Click + Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click If fbVEH.OpenDialog(VehFile) Then openVEH(fbVEH.Files(0)) End Sub 'Save - Private Sub ToolStripBtSave_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtSave.Click + Private Sub ToolStripBtSave_Click(sender As Object, e As EventArgs) Handles ToolStripBtSave.Click SaveOrSaveAs(False) End Sub 'Save As - Private Sub ToolStripBtSaveAs_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtSaveAs.Click + Private Sub ToolStripBtSaveAs_Click(sender As Object, e As EventArgs) Handles ToolStripBtSaveAs.Click SaveOrSaveAs(True) End Sub 'Send to VECTO Editor - Private Sub ToolStripBtSendTo_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtSendTo.Click + Private Sub ToolStripBtSendTo_Click(sender As Object, e As EventArgs) Handles ToolStripBtSendTo.Click If ChangeCheckCancel() Then Exit Sub @@ -219,14 +183,14 @@ Public Class F_VEH End Sub 'Help - Private Sub ToolStripButton1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton1.Click - If IO.File.Exists(MyAppPath & "User Manual\help.html") Then + Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click + If File.Exists(MyAppPath & "User Manual\help.html") Then Dim BrowserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString Dim DefaultBrowserPath As String = - System.Text.RegularExpressions.Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - System.Diagnostics.Process.Start(DefaultBrowserPath, - String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#vehicle-editor")) + Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString + Process.Start(DefaultBrowserPath, + String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#vehicle-editor")) Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -235,17 +199,17 @@ Public Class F_VEH #End Region 'Save and Close - Private Sub ButOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButOK.Click - If SaveOrSaveAs(False) Then Me.Close() + Private Sub ButOK_Click(sender As Object, e As EventArgs) Handles ButOK.Click + If SaveOrSaveAs(False) Then Close() End Sub 'Cancel - Private Sub ButCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCancel.Click - Me.Close() + Private Sub ButCancel_Click(sender As Object, e As EventArgs) Handles ButCancel.Click + Close() End Sub 'Save or Save As function = true if file is saved - Private Function SaveOrSaveAs(ByVal SaveAs As Boolean) As Boolean + Private Function SaveOrSaveAs(SaveAs As Boolean) As Boolean If VehFile = "" Or SaveAs Then If fbVEH.SaveDialog(VehFile) Then VehFile = fbVEH.Files(0) @@ -261,42 +225,41 @@ Public Class F_VEH If ChangeCheckCancel() Then Exit Sub - Me.TbMass.Text = "" - Me.TbLoad.Text = "" - Me.TBrdyn.Text = "" - Me.TBcdA.Text = "" - Me.TBcdA2.Text = "" + TbMass.Text = "" + TbLoad.Text = "" + TBrdyn.Text = "" + TBcdA.Text = "" - Me.CbCdMode.SelectedIndex = 0 - Me.TbCdFile.Text = "" + CbCdMode.SelectedIndex = 0 + TbCdFile.Text = "" - Me.CbRtType.SelectedIndex = 0 - Me.TbRtRatio.Text = "1" - Me.TbRtPath.Text = "" + CbRtType.SelectedIndex = 0 + TbRtRatio.Text = "1" + TbRtPath.Text = "" - Me.CbCat.SelectedIndex = 0 + CbCat.SelectedIndex = 0 - Me.LvRRC.Items.Clear() + LvRRC.Items.Clear() - Me.TbMassMass.Text = "" - Me.TbMassExtra.Text = "" - Me.CbAxleConfig.SelectedIndex = 0 + TbMassMass.Text = "" + TbMassExtra.Text = "" + CbAxleConfig.SelectedIndex = 0 - Me.CbRim.SelectedIndex = 0 + CbRim.SelectedIndex = 0 DeclInit() VehFile = "" - Me.Text = "VEH Editor" - Me.LbStatus.Text = "" + Text = "VEH Editor" + LbStatus.Text = "" Changed = False End Sub 'Open VEH - Sub openVEH(ByVal file As String) + Sub openVEH(file As String) Dim i As Int16 Dim VEH0 As cVEH Dim inertia As Single @@ -318,35 +281,35 @@ Public Class F_VEH If Cfg.DeclMode <> VEH0.SavedInDeclMode Then Select Case WrongMode() Case 1 - Me.Close() + Close() F_MAINForm.RbDecl.Checked = Not F_MAINForm.RbDecl.Checked F_MAINForm.OpenVectoFile(file) - Case - 1 + Case -1 Exit Sub Case Else '0 'Continue... End Select End If - Me.TbMass.Text = VEH0.Mass - Me.TbMassExtra.Text = VEH0.MassExtra - Me.TbLoad.Text = VEH0.Loading - Me.TBrdyn.Text = VEH0.rdyn - Me.CbRim.Text = VEH0.Rim + TbMass.Text = VEH0.Mass + TbMassExtra.Text = VEH0.MassExtra + TbLoad.Text = VEH0.Loading + TBrdyn.Text = VEH0.rdyn + CbRim.Text = VEH0.Rim - Me.CbCdMode.SelectedIndex = CType(VEH0.CdMode, Integer) - Me.TbCdFile.Text = VEH0.CdFile.OriginalPath + CbCdMode.SelectedIndex = CType(VEH0.CdMode, Integer) + TbCdFile.Text = VEH0.CdFile.OriginalPath - Me.CbRtType.SelectedIndex = CType(VEH0.RtType, Integer) - Me.TbRtRatio.Text = CStr(VEH0.RtRatio) - Me.TbRtPath.Text = CStr(VEH0.RtFile.OriginalPath) + CbRtType.SelectedIndex = CType(VEH0.RtType, Integer) + TbRtRatio.Text = CStr(VEH0.RtRatio) + TbRtPath.Text = CStr(VEH0.RtFile.OriginalPath) - Me.CbCat.SelectedIndex = CType(VEH0.VehCat, Integer) + CbCat.SelectedIndex = CType(VEH0.VehCat, Integer) - Me.LvRRC.Items.Clear() + LvRRC.Items.Clear() i = 0 For Each a0 In VEH0.Axles i += 1 @@ -382,63 +345,64 @@ Public Class F_VEH LvRRC.Items.Add(lvi) Next - Me.TbMassMass.Text = VEH0.MassMax - Me.TbMassExtra.Text = VEH0.MassExtra + TbMassMass.Text = VEH0.MassMax + TbMassExtra.Text = VEH0.MassExtra - Me.CbAxleConfig.SelectedIndex = CType(VEH0.AxleConf, Integer) + CbAxleConfig.SelectedIndex = CType(VEH0.AxleConf, Integer) - Me.TBcdA.Text = VEH0.CdA0 - Me.TBcdA2.Text = VEH0.CdA02 + TBcdA.Text = VEH0.CdA0 DeclInit() fbVEH.UpdateHistory(file) - Me.Text = fFILE(file, True) - Me.LbStatus.Text = "" + Text = fFILE(file, True) + LbStatus.Text = "" VehFile = file - Me.Activate() + Activate() Changed = False End Sub 'Save VEH - Private Function saveVEH(ByVal file As String) As Boolean - Dim a0 As cVEH.cAxle - Dim VEH0 As cVEH - Dim LV0 As ListViewItem - - VEH0 = New cVEH - VEH0.FilePath = file - - VEH0.Mass = CSng(fTextboxToNumString(Me.TbMass.Text)) - VEH0.MassExtra = CSng(fTextboxToNumString(Me.TbMassExtra.Text)) - VEH0.Loading = CSng(fTextboxToNumString(Me.TbLoad.Text)) - - VEH0.CdA0 = CSng(fTextboxToNumString(Me.TBcdA.Text)) - - If Me.PnCdARig.Visible Then - VEH0.CdA02 = CSng(fTextboxToNumString(Me.TBcdA2.Text)) + Private Function saveVEH(file As String) As Boolean + + Dim veh0 = New cVEH + veh0.FilePath = file + + veh0.Mass = CSng(fTextboxToNumString(TbMass.Text)) + veh0.MassExtra = CSng(fTextboxToNumString(TbMassExtra.Text)) + veh0.Loading = CSng(fTextboxToNumString(TbLoad.Text)) + + veh0.CdA0 = CSng(fTextboxToNumString(TBcdA.Text)) + veh0.CdA02 = veh0.CdA0 + + Dim vehC = CType(CbCat.SelectedIndex, tVehCat) + Dim axlC = CType(CbAxleConfig.SelectedIndex, tAxleConf) + Dim maxMass = CSng(fTextboxToNumString(TbMassMass.Text)) + Dim s0 As cSegmentTableEntry = Declaration.SegmentTable.SetRef(vehC, axlC, maxMass) + If Not s0 Is Nothing Then + If s0.HDVclass = "2" Then + ' CdA Addition for T1 Trailer + veh0.CdA02 += 1.1 + End If + If s0.HDVclass = "4" OrElse s0.HDVclass = "9" Then + ' CdA Addition for T2 Trailer + veh0.CdA02 += 0.6 + End If End If - VEH0.Rim = Me.CbRim.Text - - VEH0.rdyn = CSng(fTextboxToNumString(Me.TBrdyn.Text)) - - - VEH0.CdMode = CType(Me.CbCdMode.SelectedIndex, tCdMode) - VEH0.CdFile.Init(fPATH(file), Me.TbCdFile.Text) - - VEH0.RtType = CType(Me.CbRtType.SelectedIndex, tRtType) - VEH0.RtRatio = CSng(fTextboxToNumString(Me.TbRtRatio.Text)) - VEH0.RtFile.Init(fPATH(file), Me.TbRtPath.Text) - - VEH0.VehCat = CType(Me.CbCat.SelectedIndex, tVehCat) + veh0.Rim = CbRim.Text + veh0.rdyn = CSng(fTextboxToNumString(TBrdyn.Text)) + veh0.CdMode = CType(CbCdMode.SelectedIndex, tCdMode) + veh0.CdFile.Init(fPATH(file), TbCdFile.Text) + veh0.RtType = CType(CbRtType.SelectedIndex, tRtType) + veh0.RtRatio = CSng(fTextboxToNumString(TbRtRatio.Text)) + veh0.RtFile.Init(fPATH(file), TbRtPath.Text) + veh0.VehCat = CType(CbCat.SelectedIndex, tVehCat) Dim axleShareCheck As Double For Each LV0 In LvRRC.Items - - a0 = New cVEH.cAxle - + Dim a0 = New cVEH.cAxle a0.Share = fTextboxToNumString(LV0.SubItems(1).Text) axleShareCheck += a0.Share a0.TwinTire = (LV0.SubItems(2).Text = "yes") @@ -446,23 +410,20 @@ Public Class F_VEH a0.FzISO = fTextboxToNumString(LV0.SubItems(4).Text) a0.Wheels = LV0.SubItems(5).Text a0.Inertia = fTextboxToNumString(LV0.SubItems(6).Text) - - VEH0.Axles.Add(a0) - + veh0.Axles.Add(a0) Next - If Math.Abs(axleShareCheck - 1) > 0.000001 Then + If Not Cfg.DeclMode AndAlso Math.Abs(axleShareCheck - 1) > 0.000001 Then MsgBox("Relative axle loads must sum up to 1.0. Current value: " & axleShareCheck, MsgBoxStyle.Critical) Return False End If - VEH0.MassMax = CSng(fTextboxToNumString(Me.TbMassMass.Text)) - VEH0.MassExtra = CSng(fTextboxToNumString(Me.TbMassExtra.Text)) - VEH0.AxleConf = CType(Me.CbAxleConfig.SelectedIndex, tAxleConf) + veh0.MassMax = CSng(fTextboxToNumString(TbMassMass.Text)) + veh0.MassExtra = CSng(fTextboxToNumString(TbMassExtra.Text)) + veh0.AxleConf = CType(CbAxleConfig.SelectedIndex, tAxleConf) '--------------------------------------------------------------------------------- - - If Not VEH0.SaveFile Then + If Not veh0.SaveFile Then MsgBox("Cannot safe to " & file, MsgBoxStyle.Critical) Return False End If @@ -475,8 +436,8 @@ Public Class F_VEH End If fbVEH.UpdateHistory(file) - Me.Text = fFILE(file, True) - Me.LbStatus.Text = "" + Text = fFILE(file, True) + LbStatus.Text = "" Changed = False @@ -486,52 +447,52 @@ Public Class F_VEH #Region "Cd" 'Cd Mode Change - Private Sub CbCdMode_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub CbCdMode_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbCdMode.SelectedIndexChanged Dim bEnabled As Boolean - Select Case CType(Me.CbCdMode.SelectedIndex, tCdMode) + Select Case CType(CbCdMode.SelectedIndex, tCdMode) Case tCdMode.CdOfBeta bEnabled = True - Me.LbCdMode.Text = "Input file: Yaw Angle [°], Cd Scaling Factor [-]" + LbCdMode.Text = "Input file: Yaw Angle [°], Cd Scaling Factor [-]" Case tCdMode.CdOfVeng bEnabled = True - Me.LbCdMode.Text = "Input file: Vehicle Speed [km/h], Cd Scaling Factor [-]" + LbCdMode.Text = "Input file: Vehicle Speed [km/h], Cd Scaling Factor [-]" Case Else ' tCdMode.ConstCd0, tCdMode.CdOfVdecl bEnabled = False - Me.LbCdMode.Text = "" + LbCdMode.Text = "" End Select If Not Cfg.DeclMode Then - Me.TbCdFile.Enabled = bEnabled - Me.BtCdFileBrowse.Enabled = bEnabled - Me.BtCdFileOpen.Enabled = bEnabled + TbCdFile.Enabled = bEnabled + BtCdFileBrowse.Enabled = bEnabled + BtCdFileOpen.Enabled = bEnabled End If Change() End Sub 'Cd File Browse - Private Sub BtCdFileBrowse_Click(sender As System.Object, e As System.EventArgs) Handles BtCdFileBrowse.Click + Private Sub BtCdFileBrowse_Click(sender As Object, e As EventArgs) Handles BtCdFileBrowse.Click Dim ex As String - If Me.CbCdMode.SelectedIndex = 1 Then + If CbCdMode.SelectedIndex = 1 Then ex = "vcdv" Else ex = "vcdb" End If - If fbCDx.OpenDialog(fFileRepl(Me.TbCdFile.Text, fPATH(VehFile)), False, ex) Then _ + If fbCDx.OpenDialog(fFileRepl(TbCdFile.Text, fPATH(VehFile)), False, ex) Then _ TbCdFile.Text = fFileWoDir(fbCDx.Files(0), fPATH(VehFile)) End Sub 'Open Cd File - Private Sub BtCdFileOpen_Click(sender As System.Object, e As System.EventArgs) Handles BtCdFileOpen.Click - OpenFiles(fFileRepl(Me.TbCdFile.Text, fPATH(VehFile))) + Private Sub BtCdFileOpen_Click(sender As Object, e As EventArgs) Handles BtCdFileOpen.Click + OpenFiles(fFileRepl(TbCdFile.Text, fPATH(VehFile))) End Sub #End Region @@ -539,33 +500,33 @@ Public Class F_VEH #Region "Retarder" 'Rt Type Change - Private Sub CbRtType_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub CbRtType_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbRtType.SelectedIndexChanged - Select Case Me.CbRtType.SelectedIndex + Select Case CbRtType.SelectedIndex Case 1 'Primary - Me.LbRtRatio.Text = "Ratio to engine speed" - Me.TbRtPath.Enabled = True - Me.BtRtBrowse.Enabled = True - Me.PnRt.Enabled = True + LbRtRatio.Text = "Ratio to engine speed" + TbRtPath.Enabled = True + BtRtBrowse.Enabled = True + PnRt.Enabled = True Case 2 'Secondary - Me.LbRtRatio.Text = "Ratio to cardan shaft speed" - Me.TbRtPath.Enabled = True - Me.BtRtBrowse.Enabled = True - Me.PnRt.Enabled = True + LbRtRatio.Text = "Ratio to cardan shaft speed" + TbRtPath.Enabled = True + BtRtBrowse.Enabled = True + PnRt.Enabled = True Case Else '0 None - Me.LbRtRatio.Text = "Ratio" - Me.TbRtPath.Enabled = False - Me.BtRtBrowse.Enabled = False - Me.PnRt.Enabled = False + LbRtRatio.Text = "Ratio" + TbRtPath.Enabled = False + BtRtBrowse.Enabled = False + PnRt.Enabled = False End Select Change() End Sub 'Rt File Browse - Private Sub BtRtBrowse_Click(sender As System.Object, e As System.EventArgs) Handles BtRtBrowse.Click + Private Sub BtRtBrowse_Click(sender As Object, e As EventArgs) Handles BtRtBrowse.Click - If fbRLM.OpenDialog(fFileRepl(Me.TbRtPath.Text, fPATH(VehFile))) Then _ + If fbRLM.OpenDialog(fFileRepl(TbRtPath.Text, fPATH(VehFile))) Then _ TbRtPath.Text = fFileWoDir(fbRLM.Files(0), fPATH(VehFile)) End Sub @@ -575,7 +536,7 @@ Public Class F_VEH Private Sub Change() If Not Changed Then - Me.LbStatus.Text = "Unsaved changes in current file" + LbStatus.Text = "Unsaved changes in current file" Changed = True End If End Sub @@ -601,67 +562,43 @@ Public Class F_VEH End If End Function - Private Sub TBmass_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbMass.TextChanged + Private Sub TBmass_TextChanged(sender As Object, e As EventArgs) Handles TbMass.TextChanged SetMaxLoad() Change() End Sub - Private Sub TBston_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbLoad.TextChanged - Change() - End Sub - - Private Sub TBDreifen_TextChanged(sender As System.Object, e As System.EventArgs) Handles TBrdyn.TextChanged - Change() - End Sub - - Private Sub CbRim_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub CbRim_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbRim.SelectedIndexChanged Change() DeclInit() End Sub - Private Sub TBcw_TextChanged(sender As System.Object, e As System.EventArgs) _ - Handles TBcdA.TextChanged, TBcdA2.TextChanged - Change() - End Sub - - Private Sub TBAquers_TextChanged(sender As System.Object, e As System.EventArgs) - Change() - End Sub - - - Private Sub TbCdFile_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbCdFile.TextChanged + Private Sub TBcw_TextChanged(sender As Object, e As EventArgs) _ + Handles TbLoad.TextChanged, TBrdyn.TextChanged, TBcdA.TextChanged, TbCdFile.TextChanged, TbRtPath.TextChanged, + TbRtRatio.TextChanged Change() End Sub - Private Sub TbRtPath_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbRtPath.TextChanged - Change() - End Sub - - Private Sub TbRtRatio_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbRtRatio.TextChanged - Change() - End Sub - - Private Sub CbCat_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub CbCat_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbCat.SelectedIndexChanged Change() SetHDVclass() DeclInit() End Sub - Private Sub TbMassTrailer_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbMassExtra.TextChanged + Private Sub TbMassTrailer_TextChanged(sender As Object, e As EventArgs) Handles TbMassExtra.TextChanged SetMaxLoad() Change() End Sub - Private Sub TbMassMax_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbMassMass.TextChanged + Private Sub TbMassMax_TextChanged(sender As Object, e As EventArgs) Handles TbMassMass.TextChanged SetMaxLoad() Change() SetHDVclass() DeclInit() End Sub - Private Sub CbAxleConfig_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) _ + Private Sub CbAxleConfig_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbAxleConfig.SelectedIndexChanged Change() SetHDVclass() @@ -673,25 +610,25 @@ Public Class F_VEH 'Update maximum load when truck/trailer mass was changed Private Sub SetMaxLoad() If Not Cfg.DeclMode Then - If IsNumeric(Me.TbMass.Text) And IsNumeric(Me.TbMassExtra.Text) And IsNumeric(Me.TbMassMass.Text) Then - Me.TbLoadingMax.Text = CStr(CSng(Me.TbMassMass.Text)*1000 - CSng(Me.TbMass.Text) - CSng(Me.TbMassExtra.Text)) + If IsNumeric(TbMass.Text) And IsNumeric(TbMassExtra.Text) And IsNumeric(TbMassMass.Text) Then + TbLoadingMax.Text = CStr(CSng(TbMassMass.Text) * 1000 - CSng(TbMass.Text) - CSng(TbMassExtra.Text)) Else - Me.TbLoadingMax.Text = "" + TbLoadingMax.Text = "" End If End If End Sub #Region "Axle Configuration" - Private Sub ButAxlAdd_Click(sender As System.Object, e As System.EventArgs) Handles ButAxlAdd.Click + Private Sub ButAxlAdd_Click(sender As Object, e As EventArgs) Handles ButAxlAdd.Click Dim lv0 As ListViewItem AxlDlog.Clear() - If AxlDlog.ShowDialog = Windows.Forms.DialogResult.OK Then + If AxlDlog.ShowDialog = DialogResult.OK Then lv0 = New ListViewItem - lv0.SubItems(0).Text = Me.LvRRC.Items.Count + 1 + lv0.SubItems(0).Text = LvRRC.Items.Count + 1 lv0.SubItems.Add(Trim(AxlDlog.TbAxleShare.Text)) If AxlDlog.CbTwinT.Checked Then lv0.SubItems.Add("yes") @@ -703,7 +640,7 @@ Public Class F_VEH lv0.SubItems.Add(Trim(AxlDlog.CbWheels.Text)) lv0.SubItems.Add(Trim(AxlDlog.TbI_wheels.Text)) - Me.LvRRC.Items.Add(lv0) + LvRRC.Items.Add(lv0) Change() DeclInit() @@ -711,15 +648,15 @@ Public Class F_VEH End If End Sub - Private Sub ButAxlRem_Click(sender As System.Object, e As System.EventArgs) Handles ButAxlRem.Click + Private Sub ButAxlRem_Click(sender As Object, e As EventArgs) Handles ButAxlRem.Click RemoveAxleItem() End Sub - Private Sub LvAxle_DoubleClick(sender As Object, e As System.EventArgs) Handles LvRRC.DoubleClick + Private Sub LvAxle_DoubleClick(sender As Object, e As EventArgs) Handles LvRRC.DoubleClick EditAxleItem() End Sub - Private Sub LvAxle_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles LvRRC.KeyDown + Private Sub LvAxle_KeyDown(sender As Object, e As KeyEventArgs) Handles LvRRC.KeyDown Select Case e.KeyCode Case Keys.Delete, Keys.Back If Not Cfg.DeclMode Then RemoveAxleItem() @@ -758,34 +695,31 @@ Public Class F_VEH End Sub Private Sub EditAxleItem() - Dim LV0 As ListViewItem - If LvRRC.SelectedItems.Count = 0 Then Exit Sub - LV0 = LvRRC.SelectedItems(0) + Dim lv0 = LvRRC.SelectedItems(0) - AxlDlog.TbAxleShare.Text = LV0.SubItems(1).Text - AxlDlog.CbTwinT.Checked = (LV0.SubItems(2).Text = "yes") - AxlDlog.TbRRC.Text = LV0.SubItems(3).Text - AxlDlog.TbFzISO.Text = LV0.SubItems(4).Text - AxlDlog.TbI_wheels.Text = LV0.SubItems(6).Text - AxlDlog.CbWheels.Text = LV0.SubItems(5).Text + AxlDlog.TbAxleShare.Text = lv0.SubItems(1).Text + AxlDlog.CbTwinT.Checked = (lv0.SubItems(2).Text = "yes") + AxlDlog.TbRRC.Text = lv0.SubItems(3).Text + AxlDlog.TbFzISO.Text = lv0.SubItems(4).Text + AxlDlog.TbI_wheels.Text = lv0.SubItems(6).Text + AxlDlog.CbWheels.Text = lv0.SubItems(5).Text - If AxlDlog.ShowDialog = Windows.Forms.DialogResult.OK Then - LV0.SubItems(1).Text = AxlDlog.TbAxleShare.Text + If AxlDlog.ShowDialog = DialogResult.OK Then + lv0.SubItems(1).Text = AxlDlog.TbAxleShare.Text If AxlDlog.CbTwinT.Checked Then - LV0.SubItems(2).Text = "yes" + lv0.SubItems(2).Text = "yes" Else - LV0.SubItems(2).Text = "no" + lv0.SubItems(2).Text = "no" End If - LV0.SubItems(3).Text = AxlDlog.TbRRC.Text - LV0.SubItems(4).Text = AxlDlog.TbFzISO.Text - LV0.SubItems(5).Text = AxlDlog.CbWheels.Text - LV0.SubItems(6).Text = AxlDlog.TbI_wheels.Text + lv0.SubItems(3).Text = AxlDlog.TbRRC.Text + lv0.SubItems(4).Text = AxlDlog.TbFzISO.Text + lv0.SubItems(5).Text = AxlDlog.CbWheels.Text + lv0.SubItems(6).Text = AxlDlog.TbI_wheels.Text Change() DeclInit() - End If End Sub @@ -796,26 +730,23 @@ Public Class F_VEH 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(Cursor.Position) End Sub - Private Sub OpenWithToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + 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 System.Object, e As System.EventArgs) _ + Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ShowInFolderToolStripMenuItem.Click - If IO.File.Exists(CmFiles(0)) Then + If File.Exists(CmFiles(0)) Then Try - System.Diagnostics.Process.Start("explorer", "/select,""" & CmFiles(0) & "") + Process.Start("explorer", "/select,""" & CmFiles(0) & "") Catch ex As Exception MsgBox("Failed to open file!") End Try @@ -826,3 +757,4 @@ Public Class F_VEH #End Region End Class + diff --git a/VECTO/Input Files/cVEH.vb b/VECTO/Input Files/cVEH.vb index eee1b8beeaa945734c8d6c6a61e6e03b386f70ec..97f84ee26b0cc3fa28c2473d50cfb885ddc66acc 100644 --- a/VECTO/Input Files/cVEH.vb +++ b/VECTO/Input Files/cVEH.vb @@ -8,170 +8,168 @@ ' 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 + Imports System.Collections.Generic +Imports System.Linq -Public Class cVEH - 'V2 MassMax is now saved in [t] instead of [kg] +Public Class cVEH + 'V2 MassMax is now saved in [t] instead of [kg] Private Const FormatVersion As Short = 7 - Private FileVersion As Short + Private FileVersion As Short - Private sFilePath As String - Private MyPath As String + Private sFilePath As String + Private MyPath As String - Public Mass As Single - Public Loading As Single - Private siFr0 As Single + Public Mass As Single + Public Loading As Single + Private siFr0 As Single Public CdA0 As Single Public CdA02 As Single Private CdA0Act As Single - Public CdMode As tCdMode - Public CdFile As cSubPath - Private CdX As List(Of Single) - Private CdY As List(Of Single) - Private CdDim As Integer + Public CdMode As tCdMode + Public CdFile As cSubPath + Private CdX As List(Of Single) + Private CdY As List(Of Single) + Private CdDim As Integer - Public RtType As tRtType '0=None, 1=Primary, 2=Secondary - Public RtRatio As Single = 0 - Public RtFile As cSubPath - Private RtDim As Integer - Private RtnU As List(Of Single) - Private RtM As List(Of Single) + Public RtType As tRtType '0=None, 1=Primary, 2=Secondary + Public RtRatio As Single = 0 + Public RtFile As cSubPath + Private RtDim As Integer + Private RtnU As List(Of Single) + Private RtM As List(Of Single) - Public rdyn As Single - Public Axles As List(Of cAxle) - Public Rim As String - Private m_red0 As Single + Public rdyn As Single + Public Axles As List(Of cAxle) + Public Rim As String + Private m_red0 As Single - Public VehCat As tVehCat - Public MassExtra As Single - Public MassMax As Single - Public AxleConf As tAxleConf + Public VehCat As tVehCat + Public MassExtra As Single + Public MassMax As Single + Public AxleConf As tAxleConf - Private MyFileList As List(Of String) + Private MyFileList As List(Of String) - Public SavedInDeclMode As Boolean + Public SavedInDeclMode As Boolean - Public Class cAxle - Public RRC As Single - Public Share As Single - Public TwinTire As Boolean - Public FzISO As Single - Public Wheels As String - Public Inertia As Single - End Class + Public Class cAxle + Public RRC As Single + Public Share As Single + Public TwinTire As Boolean + Public FzISO As Single + Public Wheels As String + Public Inertia As Single + End Class + Public Function CreateFileList() As Boolean - Public Function CreateFileList() As Boolean + MyFileList = New List(Of String) - MyFileList = New List(Of String) - - '.vcdv / .vcdb + '.vcdv / .vcdb If Me.CdMode = tCdMode.CdOfVeng Or Me.CdMode = tCdMode.CdOfBeta Then MyFileList.Add(Me.CdFile.FullPath) - 'Retarder - If Me.RtType <> tRtType.None Then MyFileList.Add(Me.RtFile.FullPath) - - Return True - - End Function - + 'Retarder + If Me.RtType <> tRtType.None Then MyFileList.Add(Me.RtFile.FullPath) + Return True + End Function - Public Sub New() - MyPath = "" - sFilePath = "" - CdFile = New cSubPath - CdX = New List(Of Single) - CdY = New List(Of Single) - RtFile = New cSubPath - RtnU = New List(Of Single) - RtM = New List(Of Single) - Axles = New List(Of cAxle) - SetDefault() - End Sub - Private Sub SetDefault() - Mass = 0 - MassExtra = 0 - Loading = 0 + Public Sub New() + MyPath = "" + sFilePath = "" + CdFile = New cSubPath + CdX = New List(Of Single) + CdY = New List(Of Single) + RtFile = New cSubPath + RtnU = New List(Of Single) + RtM = New List(Of Single) + Axles = New List(Of cAxle) + SetDefault() + End Sub + + Private Sub SetDefault() + Mass = 0 + MassExtra = 0 + Loading = 0 CdA0 = 0 CdA0Act = CdA0 CdA02 = 0 - CdFile.Clear() - CdMode = tCdMode.ConstCd0 - CdX.Clear() - CdY.Clear() - CdDim = -1 - - siFr0 = 0 - rdyn = 0 - Rim = "" - - RtType = tRtType.None - RtRatio = 0 - RtnU.Clear() - RtM.Clear() - RtFile.Clear() - Axles.Clear() - VehCat = tVehCat.Undef - MassMax = 0 - AxleConf = tAxleConf.Undef + CdFile.Clear() + CdMode = tCdMode.ConstCd0 + CdX.Clear() + CdY.Clear() + CdDim = -1 - SavedInDeclMode = False + siFr0 = 0 + rdyn = 0 + Rim = "" - End Sub + RtType = tRtType.None + RtRatio = 0 + RtnU.Clear() + RtM.Clear() + RtFile.Clear() + Axles.Clear() + VehCat = tVehCat.Undef + MassMax = 0 + AxleConf = tAxleConf.Undef - Public Function Validate() As Boolean - Dim MsgSrc As String - Dim Check As Boolean = True + SavedInDeclMode = False + End Sub - MsgSrc = "VEH/Validate" + Public Function Validate() As Boolean + Dim MsgSrc As String + Dim Check As Boolean = True - If rdyn < 100 Then - WorkerMsg(tMsgID.Err, "Parameter 'Dynamic Tire Radius' is invalid (" & rdyn & "mm).", MsgSrc, sFilePath) - Check = False - End If + MsgSrc = "VEH/Validate" - Return Check + If rdyn < 100 Then + WorkerMsg(tMsgID.Err, "Parameter 'Dynamic Tire Radius' is invalid (" & rdyn & "mm).", MsgSrc, sFilePath) + Check = False + End If - End Function + Return Check + End Function - Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean - Dim Itemp As Single - Dim a0 As cAxle - Dim JSON As New JSON - Dim dic As Object + Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean + Dim Itemp As Single + Dim a0 As cAxle + Dim JSON As New JSON + Dim dic As Object - Dim MsgSrc As String + Dim MsgSrc As String - MsgSrc = "VEH/ReadFile" + MsgSrc = "VEH/ReadFile" - SetDefault() + SetDefault() - If Not JSON.ReadFile(sFilePath) Then Return False + If Not JSON.ReadFile(sFilePath) Then Return False - Try + Try - FileVersion = JSON.Content("Header")("FileVersion") + FileVersion = JSON.Content("Header")("FileVersion") - If FileVersion > 4 Then - SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If + If FileVersion > 4 Then + SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") + Else + SavedInDeclMode = Cfg.DeclMode + End If - Mass = JSON.Content("Body")("CurbWeight") - MassExtra = JSON.Content("Body")("CurbWeightExtra") - Loading = JSON.Content("Body")("Loading") - MassMax = JSON.Content("Body")("MassMax") - If FileVersion < 2 Then MassMax /= 1000 + Mass = JSON.Content("Body")("CurbWeight") + MassExtra = JSON.Content("Body")("CurbWeightExtra") + Loading = JSON.Content("Body")("Loading") + MassMax = JSON.Content("Body")("MassMax") + If FileVersion < 2 Then MassMax /= 1000 If FileVersion < 7 Then CdA0 = CSng(JSON.Content("Body")("Cd")) * CSng(JSON.Content("Body")("CrossSecArea")) @@ -182,7 +180,8 @@ Public Class cVEH CdA02 = CdA0 If FileVersion < 4 Then - If Not JSON.Content("Body")("CdRigid") Is Nothing AndAlso Not JSON.Content("Body")("CrossSecAreaRigid") Is Nothing Then + If Not JSON.Content("Body")("CdRigid") Is Nothing AndAlso Not JSON.Content("Body")("CrossSecAreaRigid") Is Nothing _ + Then CdA02 = CSng(JSON.Content("Body")("CdRigid")) * CSng(JSON.Content("Body")("CrossSecAreaRigid")) End If ElseIf FileVersion < 7 Then @@ -195,170 +194,127 @@ Public Class cVEH CdA0Act = CdA0 - If FileVersion < 3 Then - Itemp = JSON.Content("Body")("WheelsInertia") - rdyn = 1000 * JSON.Content("Body")("WheelsDiaEff") / 2 - Rim = "-" - Else - Rim = JSON.Content("Body")("Rim") - rdyn = JSON.Content("Body")("rdyn") - End If - - CdMode = CdModeConv(JSON.Content("Body")("CdCorrMode").ToString) - If Not JSON.Content("Body")("CdCorrFile") Is Nothing Then CdFile.Init(MyPath, JSON.Content("Body")("CdCorrFile")) - - If JSON.Content("Body")("Retarder") Is Nothing Then - RtType = tRtType.None - Else - RtType = RtTypeConv(JSON.Content("Body")("Retarder")("Type").ToString) - If Not JSON.Content("Body")("Retarder")("Ratio") Is Nothing Then RtRatio = JSON.Content("Body")("Retarder")("Ratio") - If Not JSON.Content("Body")("Retarder")("File") Is Nothing Then RtFile.Init(MyPath, JSON.Content("Body")("Retarder")("File")) - End If - - VehCat = ConvVehCat(JSON.Content("Body")("VehCat").ToString) - AxleConf = ConvAxleConf(JSON.Content("Body")("AxleConfig")("Type").ToString) - - For Each dic In JSON.Content("Body")("AxleConfig")("Axles") - - a0 = New cAxle - - If FileVersion < 3 Then - a0.Wheels = "-" - Else - a0.Inertia = CSng(dic("Inertia")) - a0.Wheels = CStr(dic("Wheels")) - If FileVersion < 6 Then a0.Wheels = a0.Wheels.Replace("R ", "R") - End If - - a0.Share = CSng(dic("AxleWeightShare")) - a0.TwinTire = CBool(dic("TwinTyres")) - a0.RRC = CSng(dic("RRCISO")) - a0.FzISO = CSng(dic("FzISO")) - - Axles.Add(a0) - - Next - - If FileVersion < 3 Then - For Each a0 In Axles - If a0.TwinTire Then - a0.Inertia = Itemp / (4 * Axles.Count) - Else - a0.Inertia = Itemp / (2 * Axles.Count) - End If - Next - End If - - - - Catch ex As Exception - If ShowMsg Then WorkerMsg(tMsgID.Err, "Failed to read Vehicle file! " & ex.Message, MsgSrc) - Return False - End Try - - Return True - - - - End Function - - Public Function SaveFile() As Boolean - Dim dic As Dictionary(Of String, Object) - Dim dic0 As Dictionary(Of String, Object) - Dim ls As List(Of Dictionary(Of String, Object)) - Dim a0 As cAxle - Dim JSON As New JSON - - - 'Header - dic = New Dictionary(Of String, Object) - dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") - dic.Add("Date", Now.ToString) - dic.Add("AppVersion", VECTOvers) - dic.Add("FileVersion", FormatVersion) - JSON.Content.Add("Header", dic) - - 'Body - dic = New Dictionary(Of String, Object) - - dic.Add("SavedInDeclMode", Cfg.DeclMode) - SavedInDeclMode = Cfg.DeclMode - - dic.Add("VehCat", ConvVehCat(VehCat, False)) + If FileVersion < 3 Then + Itemp = JSON.Content("Body")("WheelsInertia") + rdyn = 1000 * JSON.Content("Body")("WheelsDiaEff") / 2 + Rim = "-" + Else + Rim = JSON.Content("Body")("Rim") + rdyn = JSON.Content("Body")("rdyn") + End If - dic.Add("CurbWeight", Mass) - dic.Add("CurbWeightExtra", MassExtra) - dic.Add("Loading", Loading) - dic.Add("MassMax", MassMax) + CdMode = CdModeConv(JSON.Content("Body")("CdCorrMode").ToString) + If Not JSON.Content("Body")("CdCorrFile") Is Nothing Then CdFile.Init(MyPath, JSON.Content("Body")("CdCorrFile")) - dic.Add("CdA", CdA0) + If JSON.Content("Body")("Retarder") Is Nothing Then + RtType = tRtType.None + Else + RtType = RtTypeConv(JSON.Content("Body")("Retarder")("Type").ToString) + If Not JSON.Content("Body")("Retarder")("Ratio") Is Nothing Then RtRatio = JSON.Content("Body")("Retarder")("Ratio") + If Not JSON.Content("Body")("Retarder")("File") Is Nothing Then _ + RtFile.Init(MyPath, JSON.Content("Body")("Retarder")("File")) + End If - If CdA02 > 0 Then - dic.Add("CdA2", CdA02) - End If + VehCat = ConvVehCat(JSON.Content("Body")("VehCat").ToString) + AxleConf = ConvAxleConf(JSON.Content("Body")("AxleConfig")("Type").ToString) - dic.Add("rdyn", rdyn) - dic.Add("Rim", Rim) + For Each dic In JSON.Content("Body")("AxleConfig")("Axles") + a0 = New cAxle - dic.Add("CdCorrMode", CdModeConv(CdMode)) - dic.Add("CdCorrFile", CdFile.PathOrDummy) + If FileVersion < 3 Then + a0.Wheels = "-" + Else + a0.Inertia = CSng(dic("Inertia")) + a0.Wheels = CStr(dic("Wheels")) + If FileVersion < 6 Then a0.Wheels = a0.Wheels.Replace("R ", "R") + End If - dic0 = New Dictionary(Of String, Object) - dic0.Add("Type", RtTypeConv(RtType)) - dic0.Add("Ratio", RtRatio) - dic0.Add("File", RtFile.PathOrDummy) - dic.Add("Retarder", dic0) + a0.Share = CSng(dic("AxleWeightShare")) + a0.TwinTire = CBool(dic("TwinTyres")) + a0.RRC = CSng(dic("RRCISO")) + a0.FzISO = CSng(dic("FzISO")) - ls = New List(Of Dictionary(Of String, Object)) - For Each a0 In Axles - dic0 = New Dictionary(Of String, Object) + Axles.Add(a0) - dic0.Add("Inertia", a0.Inertia) - dic0.Add("Wheels", a0.Wheels) - dic0.Add("AxleWeightShare", a0.Share) - dic0.Add("TwinTyres", a0.TwinTire) - dic0.Add("RRCISO", a0.RRC) - dic0.Add("FzISO", a0.FzISO) - ls.Add(dic0) - Next + Next - dic0 = New Dictionary(Of String, Object) - dic0.Add("Type", ConvAxleConf(AxleConf)) - dic0.Add("Axles", ls) - dic.Add("AxleConfig", dic0) + If FileVersion < 3 Then + For Each a0 In Axles + If a0.TwinTire Then + a0.Inertia = Itemp / (4 * Axles.Count) + Else + a0.Inertia = Itemp / (2 * Axles.Count) + End If + Next + End If - JSON.Content.Add("Body", dic) - Return JSON.WriteFile(sFilePath) + Catch ex As Exception + If ShowMsg Then WorkerMsg(tMsgID.Err, "Failed to read Vehicle file! " & ex.Message, MsgSrc) + Return False + End Try + Return True + End Function - End Function + Public Function SaveFile() As Boolean + SavedInDeclMode = Cfg.DeclMode + + Dim json As New JSON + json.Content.Add("Header", New Dictionary(Of String, Object) From { + {"CreatedBy", Lic.LicString & " (" & Lic.GUID & ")"}, + {"Date", Now.ToString}, + {"AppVersion", VECTOvers}, + {"FileVersion", FormatVersion}}) + + 'Body + Dim dic As Dictionary(Of String, Object) + dic = New Dictionary(Of String, Object) From { + {"SavedInDeclMode", Cfg.DeclMode}, + {"VehCat", ConvVehCat(VehCat, False)}, + {"CurbWeight", Mass}, + {"CurbWeightExtra", MassExtra}, + {"Loading", Loading}, + {"MassMax", MassMax}, + {"CdA", CdA0}, + {"CdA2", CdA02}, + {"rdyn", rdyn}, + {"Rim", Rim}, + {"CdCorrMode", CdModeConv(CdMode)}, + {"CdCorrFile", CdFile.PathOrDummy}, + {"Retarder", New Dictionary(Of String, Object) From { + {"Type", RtTypeConv(RtType)}, + {"Ratio", RtRatio}, + {"File", RtFile.PathOrDummy}}}, + {"AxleConfig", New Dictionary(Of String, Object) From { + {"Type", ConvAxleConf(AxleConf)}, + {"Axles", (From axle In Axles Select New Dictionary(Of String, Object) From { + {"Inertia", axle.Inertia}, + {"Wheels", axle.Wheels}, + {"AxleWeightShare", axle.Share}, + {"TwinTyres", axle.TwinTire}, + {"RRCISO", axle.RRC}, + {"FzISO", axle.FzISO}})}}}} + + json.Content.Add("Body", dic) + Return json.WriteFile(sFilePath) + End Function Public Function DeclInitCycle() As Boolean - Dim al As List(Of Single) - Dim i As Integer - Dim a As Single - Dim a0 As cAxle - Dim MissionID As tMission - Dim MsgSrc As String - - MsgSrc = "VEH/DeclInit" - - MissionID = Declaration.CurrentMission.MissionID + Dim MsgSrc = "VEH/DeclInit" + Dim MissionID = Declaration.CurrentMission.MissionID MassExtra = Declaration.SegRef.GetBodyTrWeight(MissionID) - - al = Declaration.SegRef.AxleShares(MissionID) - + Dim al = Declaration.SegRef.AxleShares(MissionID) If al.Count > Axles.Count Then WorkerMsg(tMsgID.Err, "Invalid number of axles! Defined: " & Axles.Count & ", required: " & al.Count, MsgSrc) Return False End If - i = -1 + Dim i = -1 For Each a In al i += 1 Axles(i).Share = a / 100 @@ -369,36 +325,28 @@ Public Class cVEH Axles.RemoveAt(Axles.Count - 1) Loop - '(Semi-) Trailer If Not Declaration.SegRef.TrailerOnlyInLongHaul OrElse MissionID = tMission.LongHaul Then al = Declaration.SegRef.AxleSharesTr(MissionID) For Each a In al - - a0 = New cAxle - + Dim a0 = New cAxle a0.Inertia = 0 'Defined later a0.Wheels = cDeclaration.TyreTr - a0.Share = a / 100 a0.TwinTire = False a0.RRC = cDeclaration.RRCTr a0.FzISO = cDeclaration.FzISOTr - Axles.Add(a0) - Next End If 'Wheels Inertias For Each a0 In Axles a0.Inertia = Declaration.WheelsInertia(a0.Wheels) - If a0.Inertia < 0 Then WorkerMsg(tMsgID.Err, "Selected wheels (" & a0.Wheels & ") are not supported!", MsgSrc) Return False End If - Next CdMode = tCdMode.CdOfVdecl @@ -408,17 +356,13 @@ Public Class cVEH End If If Declaration.SegRef.TrailerOnlyInLongHaul Then - If MissionID = tMission.LongHaul Then CdA0Act = CdA0 Else CdA0Act = CdA02 End If - Else - CdA0Act = CdA0 - End If If Axles.Count < 2 Then @@ -433,154 +377,148 @@ Public Class cVEH End If Return True - End Function - Public Function DeclInitLoad(ByVal LoadingID As tLoading) As Boolean - Dim lmax As Single - Dim MissionID As tMission - Dim MsgSrc As String - - MsgSrc = "VEH/DeclInit" - - MissionID = Declaration.CurrentMission.MissionID - - - lmax = MassMax * 1000 - Mass - MassExtra - - Select Case LoadingID - Case tLoading.FullLoaded - Loading = lmax + Public Function DeclInitLoad(ByVal LoadingID As tLoading) As Boolean + Dim lmax As Single + Dim MissionID As tMission + Dim MsgSrc As String - Case tLoading.RefLoaded - Loading = Declaration.SegRef.GetLoading(MissionID, MassMax) - If Loading < 0 Then - WorkerMsg(tMsgID.Err, "Invalid loading in segement table!", MsgSrc) - Return False - End If + MsgSrc = "VEH/DeclInit" - If Loading > lmax Then - WorkerMsg(tMsgID.Warn, "Reference loading > Max. loading! Using max. loading.", MsgSrc) - Loading = lmax - End If + MissionID = Declaration.CurrentMission.MissionID - Case tLoading.EmptyLoaded - Loading = 0 - Case Else ' tLoading.EmptyLoaded - WorkerMsg(tMsgID.Err, "tLoading.UserDefLoaded not allowed!", MsgSrc) - Return False + lmax = MassMax * 1000 - Mass - MassExtra - End Select + Select Case LoadingID + Case tLoading.FullLoaded + Loading = lmax - Return True + Case tLoading.RefLoaded + Loading = Declaration.SegRef.GetLoading(MissionID, MassMax) + If Loading < 0 Then + WorkerMsg(tMsgID.Err, "Invalid loading in segement table!", MsgSrc) + Return False + End If - End Function + If Loading > lmax Then + WorkerMsg(tMsgID.Warn, "Reference loading > Max. loading! Using max. loading.", MsgSrc) + Loading = lmax + End If + Case tLoading.EmptyLoaded + Loading = 0 - Public Function VehmodeInit() As Boolean + Case Else ' tLoading.EmptyLoaded + WorkerMsg(tMsgID.Err, "tLoading.UserDefLoaded not allowed!", MsgSrc) + Return False - Dim MsgSrc As String - Dim a0 As cAxle - Dim ShareSum As Double - Dim RRC As Double - Dim nrwheels As Single + End Select - MsgSrc = "VEH/Init" + Return True + End Function - 'Cd-Init - If Not CdInit() Then Return False - 'Transmission Loss Maps - If Not GBX.TrLossMapInit Then - WorkerMsg(tMsgID.Err, "Failed to initialize Transmission Loss Maps!", MsgSrc) - Return False - End If + Public Function VehmodeInit() As Boolean - 'Retarder - If Not RtInit() Then Return False + Dim MsgSrc As String + Dim a0 As cAxle + Dim ShareSum As Double + Dim RRC As Double + Dim nrwheels As Single - 'Fr0 - If Axles.Count < 2 Then - WorkerMsg(tMsgID.Err, "At least 2 axle configurations are required!", MsgSrc, "<GUI>" & sFilePath) - Return False - End If + MsgSrc = "VEH/Init" - 'Check if sum=100% - ShareSum = 0 - For Each a0 In Axles - ShareSum += a0.Share - Next + 'Cd-Init + If Not CdInit() Then Return False - If Math.Abs(ShareSum - 1) > 0.0001 Then - WorkerMsg(tMsgID.Err, "Sum of relative axle shares is not 100%!", MsgSrc, "<GUI>" & sFilePath) - Return False - End If + 'Transmission Loss Maps + If Not GBX.TrLossMapInit Then + WorkerMsg(tMsgID.Err, "Failed to initialize Transmission Loss Maps!", MsgSrc) + Return False + End If - If rdyn <= 0 Then - WorkerMsg(tMsgID.Err, "rdyn is invalid!", MsgSrc, "<GUI>" & sFilePath) - Return False - End If + 'Retarder + If Not RtInit() Then Return False - RRC = 0 - m_red0 = 0 - For Each a0 In Axles + 'Fr0 + If Axles.Count < 2 Then + WorkerMsg(tMsgID.Err, "At least 2 axle configurations are required!", MsgSrc, "<GUI>" & sFilePath) + Return False + End If - If a0.RRC < -0.000001 Then - WorkerMsg(tMsgID.Err, "Invalid RRC value! (" & a0.RRC & ")", MsgSrc, "<GUI>" & sFilePath) - Return False - End If + 'Check if sum=100% + ShareSum = 0 + For Each a0 In Axles + ShareSum += a0.Share + Next - If a0.FzISO < 0.00001 Then - WorkerMsg(tMsgID.Err, "Invalid FzISO value! (" & a0.FzISO & ")", MsgSrc, "<GUI>" & sFilePath) - Return False - End If + If Math.Abs(ShareSum - 1) > 0.0001 Then + WorkerMsg(tMsgID.Err, "Sum of relative axle shares is not 100%!", MsgSrc, "<GUI>" & sFilePath) + Return False + End If - If a0.TwinTire Then - nrwheels = 4 - Else - nrwheels = 2 - End If + If rdyn <= 0 Then + WorkerMsg(tMsgID.Err, "rdyn is invalid!", MsgSrc, "<GUI>" & sFilePath) + Return False + End If - RRC += a0.Share * (a0.RRC * ((Loading + Mass + MassExtra) * a0.Share * 9.81 / (a0.FzISO * nrwheels)) ^ (0.9 - 1)) 'Beta=0.9 + RRC = 0 + m_red0 = 0 + For Each a0 In Axles - m_red0 += nrwheels * a0.Inertia / ((rdyn / 1000) ^ 2) + If a0.RRC < -0.000001 Then + WorkerMsg(tMsgID.Err, "Invalid RRC value! (" & a0.RRC & ")", MsgSrc, "<GUI>" & sFilePath) + Return False + End If - Next + If a0.FzISO < 0.00001 Then + WorkerMsg(tMsgID.Err, "Invalid FzISO value! (" & a0.FzISO & ")", MsgSrc, "<GUI>" & sFilePath) + Return False + End If - siFr0 = RRC + If a0.TwinTire Then + nrwheels = 4 + Else + nrwheels = 2 + End If - Return True + RRC += a0.Share * (a0.RRC * ((Loading + Mass + MassExtra) * a0.Share * 9.81 / (a0.FzISO * nrwheels)) ^ (0.9 - 1)) 'Beta=0.9 - End Function + m_red0 += nrwheels * a0.Inertia / ((rdyn / 1000) ^ 2) - + Next + siFr0 = RRC + Return True + End Function #Region "Cd Funktionen" - Private Function CdInit() As Boolean - Dim file As cFile_V3 - Dim MsgSrc As String - Dim line As String() + Private Function CdInit() As Boolean + Dim file As cFile_V3 + Dim MsgSrc As String + Dim line As String() - MsgSrc = "VEH/CdInit" + MsgSrc = "VEH/CdInit" - 'Warn If Vair specified in DRI but CdType != CdOfBeta - If DRI.VairVorg Xor CdMode = tCdMode.CdOfBeta Then + 'Warn If Vair specified in DRI but CdType != CdOfBeta + If DRI.VairVorg Xor CdMode = tCdMode.CdOfBeta Then - If DRI.VairVorg Then - WorkerMsg(tMsgID.Warn, "Vair input in driving cycle will be irgnored! (Side wind correction disabled in .veh file)", MsgSrc) - Else - WorkerMsg(tMsgID.Err, "No Vair input in driving cycle defined! Vres and Beta is required!", MsgSrc) - Return False - End If + If DRI.VairVorg Then + WorkerMsg(tMsgID.Warn, "Vair input in driving cycle will be irgnored! (Side wind correction disabled in .veh file)", + MsgSrc) + Else + WorkerMsg(tMsgID.Err, "No Vair input in driving cycle defined! Vres and Beta is required!", MsgSrc) + Return False + End If - End If + End If - 'If Cd-value is constant then do nothing + 'If Cd-value is constant then do nothing If CdMode = tCdMode.ConstCd0 Then Return True 'Declaration Mode @@ -610,7 +548,8 @@ Public Class cVEH CdX.Add(CSng(line(0))) CdY.Add(CSng(line(1))) Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & CdDim + 1 & " (" & CdFile.FullPath & ")", MsgSrc, CdFile.FullPath) + WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & CdDim + 1 & " (" & CdFile.FullPath & ")", MsgSrc, + CdFile.FullPath) file.Close() Return False End Try @@ -620,12 +559,12 @@ Public Class cVEH file.Close() If CdDim < 1 Then - WorkerMsg(tMsgID.Err, "Cd input file invalid! Two or more lines required! (" & CdFile.FullPath & ")", MsgSrc, CdFile.FullPath) + WorkerMsg(tMsgID.Err, "Cd input file invalid! Two or more lines required! (" & CdFile.FullPath & ")", MsgSrc, + CdFile.FullPath) Return False End If Return True - End Function Private Function CdofVdeclInit() As Boolean @@ -720,8 +659,6 @@ Public Class cVEH CdDim = CdX.Count - 1 Return True - - End Function Public Function CdA_Y(ByVal x As Single) As Single @@ -766,158 +703,145 @@ Public Class cVEH lbInt: 'Interpolation Return (x - CdX(i - 1)) * (CdY(i) - CdY(i - 1)) / (CdX(i) - CdX(i - 1)) + CdY(i - 1) - End Function #End Region #Region "Retarder" - Private Function RtInit() As Boolean - Dim file As cFile_V3 - Dim MsgSrc As String - Dim line As String() - - MsgSrc = "VEH/RtInit" - - If RtType = tRtType.None Then Return True + Private Function RtInit() As Boolean + Dim file As cFile_V3 + Dim MsgSrc As String + Dim line As String() - 'Read Inputfile - file = New cFile_V3 - If Not file.OpenRead(RtFile.FullPath) Then - WorkerMsg(tMsgID.Err, "Failed to read Retarder input file! (" & RtFile.FullPath & ")", MsgSrc) - Return False - End If + MsgSrc = "VEH/RtInit" - 'Skip Header - file.ReadLine() + If RtType = tRtType.None Then Return True - RtDim = -1 - Do While Not file.EndOfFile + 'Read Inputfile + file = New cFile_V3 + If Not file.OpenRead(RtFile.FullPath) Then + WorkerMsg(tMsgID.Err, "Failed to read Retarder input file! (" & RtFile.FullPath & ")", MsgSrc) + Return False + End If - RtDim += 1 - line = file.ReadLine + 'Skip Header + file.ReadLine() - Try - RtnU.Add(CSng(line(0))) - RtM.Add(CSng(line(1))) - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & RtDim + 1 & " (" & RtFile.FullPath & ")", MsgSrc, RtFile.FullPath) - file.Close() - Return False - End Try + RtDim = -1 + Do While Not file.EndOfFile - Loop + RtDim += 1 + line = file.ReadLine - file.Close() + Try + RtnU.Add(CSng(line(0))) + RtM.Add(CSng(line(1))) + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & RtDim + 1 & " (" & RtFile.FullPath & ")", MsgSrc, + RtFile.FullPath) + file.Close() + Return False + End Try - If RtDim < 1 Then - WorkerMsg(tMsgID.Err, "Retarder input file invalid! Two or more lines required! (" & RtFile.FullPath & ")", MsgSrc, RtFile.FullPath) - Return False - End If + Loop - Return True + file.Close() - End Function + If RtDim < 1 Then + WorkerMsg(tMsgID.Err, "Retarder input file invalid! Two or more lines required! (" & RtFile.FullPath & ")", MsgSrc, + RtFile.FullPath) + Return False + End If + Return True + End Function - Public Function RtPeLoss(ByVal v As Single, ByVal Gear As Integer) As Single - Dim M As Single - Dim nU As Single - Select Case RtType + Public Function RtPeLoss(ByVal v As Single, ByVal Gear As Integer) As Single + Dim M As Single + Dim nU As Single - Case tRtType.Primary - nU = (60 * v) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * GBX.Igetr(Gear) * RtRatio + Select Case RtType - Case tRtType.Secondary - nU = (60 * v) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * RtRatio + Case tRtType.Primary + nU = (60 * v) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * GBX.Igetr(Gear) * RtRatio - Case Else 'tRtType.None - Return 0 + Case tRtType.Secondary + nU = (60 * v) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * RtRatio - End Select + Case Else 'tRtType.None + Return 0 - M = RtIntpol(nU) + End Select - Return M * nU * 2 * Math.PI / 60 / 1000 + M = RtIntpol(nU) - End Function + Return M * nU * 2 * Math.PI / 60 / 1000 + End Function - Private Function RtIntpol(ByVal nU As Single) As Single - Dim i As Int32 + Private Function RtIntpol(ByVal nU As Single) As Single + Dim i As Int32 - 'Extrapolation for x < x(1) - If RtnU(0) >= nU Then - If RtnU(0) > nU Then MODdata.ModErrors.RtExtrapol = "n= " & nU & " [1/min]" - i = 1 - GoTo lbInt - End If + 'Extrapolation for x < x(1) + If RtnU(0) >= nU Then + If RtnU(0) > nU Then MODdata.ModErrors.RtExtrapol = "n= " & nU & " [1/min]" + i = 1 + GoTo lbInt + End If - i = 0 - Do While RtnU(i) < nU And i < RtDim - i += 1 - Loop + i = 0 + Do While RtnU(i) < nU And i < RtDim + i += 1 + Loop - 'Extrapolation for x> x(imax) - If RtnU(i) < nU Then MODdata.ModErrors.RtExtrapol = "n= " & nU & " [1/min]" + 'Extrapolation for x> x(imax) + If RtnU(i) < nU Then MODdata.ModErrors.RtExtrapol = "n= " & nU & " [1/min]" lbInt: - 'Interpolation - Return (nU - RtnU(i - 1)) * (RtM(i) - RtM(i - 1)) / (RtnU(i) - RtnU(i - 1)) + RtM(i - 1) - - End Function + 'Interpolation + Return (nU - RtnU(i - 1)) * (RtM(i) - RtM(i - 1)) / (RtnU(i) - RtnU(i - 1)) + RtM(i - 1) + End Function #End Region #Region "Properties" - Public ReadOnly Property FileList As List(Of String) - Get - Return MyFileList - End Get - End Property - - Public ReadOnly Property m_red As Single - Get - Return m_red0 - End Get - End Property - - Public Property Fr0 As Single - Get - Return siFr0 - End Get - Set(ByVal value As Single) - siFr0 = value - End Set - End Property - - Public Property FilePath() As String - Get - Return sFilePath - End Get - Set(ByVal value As String) - sFilePath = value - If sFilePath = "" Then - MyPath = "" - Else - MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" - End If - End Set - End Property - - - - - - - - + Public ReadOnly Property FileList As List(Of String) + Get + Return MyFileList + End Get + End Property + + Public ReadOnly Property m_red As Single + Get + Return m_red0 + End Get + End Property + + Public Property Fr0 As Single + Get + Return siFr0 + End Get + Set(value As Single) + siFr0 = value + End Set + End Property + + Public Property FilePath() As String + Get + Return sFilePath + End Get + Set(value As String) + sFilePath = value + If sFilePath = "" Then + MyPath = "" + Else + MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" + End If + End Set + End Property #End Region - - -End Class - +End Class \ No newline at end of file diff --git a/VECTO/cDeclaration.vb b/VECTO/cDeclaration.vb index d251182b3e3f6c10b3fc5411333b4eff3f10d8e7..046ef91cc8038ad218debe78f3ce64f80c47e935 100644 --- a/VECTO/cDeclaration.vb +++ b/VECTO/cDeclaration.vb @@ -82,7 +82,7 @@ Public Class cDeclaration Public Const UpshiftMinAcceleration As Single = 0.1 - Public Function VCDVparamPerCat(ByVal VehCat As tVehCat) As List(Of Single) + Public Function VCDVparamPerCat(VehCat As tVehCat) As List(Of Single) Select Case VehCat Case tVehCat.Citybus, tVehCat.Coach, tVehCat.InterurbanBus Return VCDVvehClassParam("CoachBus") @@ -676,11 +676,11 @@ Public Class cDeclaration Return True End Function - Public Function EngInertia(ByVal Displ As Single) As Single + Public Function EngInertia(Displ As Single) As Single Return 1.3 + 0.41 + 0.27 * (Displ / 1000) End Function - Public Function TracInt(ByVal Gearbox As tGearbox) As Single + Public Function TracInt(Gearbox As tGearbox) As Single Select Case Gearbox Case tGearbox.Manual Return 2 @@ -694,7 +694,7 @@ Public Class cDeclaration End Select End Function - Public Function SkipGears(ByVal Gearbox As tGearbox) As Boolean + Public Function SkipGears(Gearbox As tGearbox) As Boolean If Gearbox = tGearbox.Automatic Then Return False Else @@ -702,7 +702,7 @@ Public Class cDeclaration End If End Function - Public Function ShiftInside(ByVal Gearbox As tGearbox) As Boolean + Public Function ShiftInside(Gearbox As tGearbox) As Boolean If Gearbox = tGearbox.SemiAutomatic Then Return True Else @@ -710,7 +710,7 @@ Public Class cDeclaration End If End Function - Public Function ShiftTime(ByVal Gearbox As tGearbox) As Single + Public Function ShiftTime(Gearbox As tGearbox) As Single Select Case Gearbox Case tGearbox.Manual Return 3 @@ -724,7 +724,7 @@ Public Class cDeclaration End Select End Function - Public Function WheelsInertia(ByVal Wheel As String) As Single + Public Function WheelsInertia(Wheel As String) As Single If Wheels.ContainsKey(Wheel) Then Return Wheels(Wheel).Inertia @@ -733,7 +733,7 @@ Public Class cDeclaration End If End Function - Public Function rdyn(ByVal Wheel As String, ByVal Rim As String) As Single + Public Function rdyn(Wheel As String, Rim As String) As Single Dim F As Single Dim w As cWheel @@ -769,7 +769,7 @@ Public Class cDeclaration End Get End Property - Public Function ConvPicPath(ByVal HDVclass As String, ByVal LongHaul As Boolean) As String + Public Function ConvPicPath(HDVclass As String, LongHaul As Boolean) As String Select Case HDVclass @@ -804,7 +804,12 @@ Public Class cDeclaration Public Function SetRef() As Boolean - Return SegmentTable.SetRef(SegRef, VEH.VehCat, VEH.AxleConf, VEH.MassMax) + SegRef = SegmentTable.SetRef(VEH.VehCat, VEH.AxleConf, VEH.MassMax) + If SegRef Is Nothing Then + Return False + Else + Return True + End If End Function @@ -814,7 +819,7 @@ Public Class cDeclaration ''' <param name="CycleIndex"></param> ''' <returns></returns> ''' <remarks></remarks> - Public Function CalcInitCycle(ByVal CycleIndex As Integer) As Boolean + Public Function CalcInitCycle(CycleIndex As Integer) As Boolean CurrentMission = Missions(SegRef.Missions(CycleIndex)) @@ -834,7 +839,7 @@ Public Class cDeclaration ''' <param name="Loading"></param> ''' <returns></returns> ''' <remarks></remarks> - Public Function CalcInitLoad(ByVal Loading As tLoading) As Boolean + Public Function CalcInitLoad(Loading As tLoading) As Boolean Dim MsgSrc As String Dim U As Single Dim F As Single @@ -930,7 +935,7 @@ Public Class cDeclaration Return Result End Function - Public Function PT1(ByVal nU As Single) As Single + Public Function PT1(nU As Single) As Single Dim i As Int32 'Extrapolation for x < x(1) @@ -1054,17 +1059,14 @@ Public Class cSegmentTable Public SegTableEntries As New List(Of cSegmentTableEntry) Public MissionList As New List(Of tMission) - Public Function SetRef(ByRef SegTableEntryRef As cSegmentTableEntry, ByVal VehCat As tVehCat, - ByVal AxleConf As tAxleConf, ByVal MaxMass As Single) As Boolean + Public Function SetRef(vehCat As tVehCat, axleConf As tAxleConf, maxMass As Single) As cSegmentTableEntry For Each s0 As cSegmentTableEntry In SegTableEntries - If s0.VehCat = VehCat And s0.AxleConf = AxleConf And MaxMass >= s0.MinGVW And MaxMass <= s0.MaxGVW Then - SegTableEntryRef = s0 - Return True + If s0.VehCat = vehCat And s0.AxleConf = axleConf And MaxMass >= s0.MinGVW And MaxMass <= s0.MaxGVW Then + Return s0 End If Next - SegTableEntryRef = Nothing - Return False + Return Nothing End Function End Class @@ -1095,7 +1097,7 @@ Public Class cSegmentTableEntry Return l End Function - Public Function GetBodyTrWeight(ByVal Mission As tMission) As Single + Public Function GetBodyTrWeight(Mission As tMission) As Single 'Check if Config is valid If BodyTrWeight.ContainsKey(Mission) AndAlso IsNumeric(BodyTrWeight(Mission)) Then @@ -1105,7 +1107,7 @@ Public Class cSegmentTableEntry End If End Function - Public Function GetLoading(ByVal Mission As tMission, ByVal MassMax As Single) As Single + Public Function GetLoading(Mission As tMission, MassMax As Single) As Single 'Check if Config is valid If Loading.ContainsKey(Mission) Then diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index c88fec806e0f6dd944eb55058ce314fe73231672..3f101c0fa89ff5659b35cc36a98923b71f638400 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -91,16 +91,10 @@ namespace TUGraz.VectoCommon.InputData Kilogram GrossVehicleMassRating { get; } /// <summary> - /// P146 DragCoefficient * Cross Section Area - Truck & Trailer + /// P146, P147 DragCoefficient * Cross Section Area - Rigid /// cf. VECTO Input Parameters.xlsx /// </summary> - SquareMeter AirDragArea { get; } - - /// <summary> - /// P147 DragCoefficient * Cross Section Area - Rigid - /// cf. VECTO Input Parameters.xlsx - /// </summary> - SquareMeter AirDragAreaRigidTruck { get; } // without trailer + SquareMeter AirDragArea { get; } // without trailer /// <summary> /// P117 Powered axle tyres/rims diff --git a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs index d4bf8eb6fa037e8fd1bb1aeca819b6e874b570be..823986e91539a882b4d3ed297e0b8a71633ff8eb 100644 --- a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs +++ b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs @@ -30,6 +30,7 @@ */ using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Data; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -94,7 +95,6 @@ namespace TUGraz.VectoCommon.InputData DataTable CrosswindCorrectionMap { get; } } - public interface IAxleEngineeringInputData : IAxleDeclarationInputData { /// <summary> @@ -110,7 +110,6 @@ namespace TUGraz.VectoCommon.InputData KilogramSquareMeter Inertia { get; } } - public interface IGearboxEngineeringInputData : IGearboxDeclarationInputData { /// <summary> @@ -168,15 +167,19 @@ namespace TUGraz.VectoCommon.InputData /// </summary> bool SkipGears { get; } - /// <summary> /// P090, P091, P092, P127 /// cf. VECTO Input Parameters.xlsx /// </summary> ITorqueConverterInputData TorqueConverter { get; } + [Required, SIRange(0, double.MaxValue)] Second DownshiftAferUpshiftDelay { get; } + + [Required, SIRange(0, double.MaxValue)] Second UpshiftAfterDownshiftDelay { get; } + + [Required, SIRange(0, double.MaxValue)] MeterPerSquareSecond UpshiftMinAcceleration { get; } } @@ -189,7 +192,6 @@ namespace TUGraz.VectoCommon.InputData KilogramSquareMeter Inertia { get; } } - public interface IAuxiliariesEngineeringInputData : IAuxiliariesDeclarationInputData { new IList<IAuxiliaryEngineeringInputData> Auxiliaries { get; } @@ -202,7 +204,6 @@ namespace TUGraz.VectoCommon.InputData string AdvancedAuxiliaryFilePath { get; } } - public interface IDriverEngineeringInputData : IDriverDeclarationInputData { new IStartStopEngineeringInputData StartStop { get; } @@ -218,7 +219,6 @@ namespace TUGraz.VectoCommon.InputData ILookaheadCoastingInputData Lookahead { get; } } - public interface IOverSpeedEcoRollEngineeringInputData : IOverSpeedEcoRollDeclarationInputData { /// <summary> @@ -261,7 +261,6 @@ namespace TUGraz.VectoCommon.InputData Second Delay { get; } } - public interface ILookaheadCoastingInputData { /// <summary> diff --git a/VectoCommon/VectoCommon/Models/LoggingObject.cs b/VectoCommon/VectoCommon/Models/LoggingObject.cs index fe8dcae3267738e48899a8bc13ff233a483edd3c..389518e2ab5e7cff3ed52ac5bf212475749526cb 100644 --- a/VectoCommon/VectoCommon/Models/LoggingObject.cs +++ b/VectoCommon/VectoCommon/Models/LoggingObject.cs @@ -145,7 +145,7 @@ namespace TUGraz.VectoCommon.Models public void Error(Exception e, string message = null, params object[] args) { if (LogEnabled) { - _log.Error(e, message, args); + _log.Error(e.Message, message, args); } } diff --git a/VectoCommon/VectoCommon/Utils/EnumberableExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/EnumberableExtensionMethods.cs index d60a984f40dcdc6fea274194db97f5a3bb99a2df..a3b02515ce1b25262d0855043e6b2ac2cea87f49 100644 --- a/VectoCommon/VectoCommon/Utils/EnumberableExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/EnumberableExtensionMethods.cs @@ -40,7 +40,7 @@ namespace TUGraz.VectoCommon.Utils { public static IEnumerable<double> ToDouble(this IEnumerable<string> self) { - return self.Select(StringExtensionMethods.ToDouble); + return self.Select(s => s.ToDouble()); } public static bool SequenceEqualFast<T>(this IEnumerable<T> self, IEnumerable<T> other) where T : IComparable @@ -225,5 +225,10 @@ namespace TUGraz.VectoCommon.Utils } } } + + public static IEnumerable<T> Repeat<T>(this T element, int count) + { + return Enumerable.Repeat(element, count); + } } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs index 2c1b9fa15cdbad5e42de3d9f4b3e105cdfcc8bf6..5612a1d2d80a253629f15d3ecbb7d01ea2692255 100644 --- a/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -44,9 +45,15 @@ namespace TUGraz.VectoCommon.Utils return string.Join(s, values); } - public static double ToDouble(this string self) + public static double ToDouble(this string self, double? defaultValue = null) { - return double.Parse(self, CultureInfo.InvariantCulture); + try { + return double.Parse(self, CultureInfo.InvariantCulture); + } catch (FormatException) { + if (defaultValue.HasValue) + return defaultValue.Value; + throw; + } } public static double IndulgentParse(this string self) diff --git a/VectoCore/VectoCore/Utils/Validation.cs b/VectoCommon/VectoCommon/Utils/Validation.cs similarity index 99% rename from VectoCore/VectoCore/Utils/Validation.cs rename to VectoCommon/VectoCommon/Utils/Validation.cs index ade2ded943a22ef3d43c56bb16cfe11bab077c4e..e5c10dec5ac691420805f1e8eb3bb4071bc52281 100644 --- a/VectoCore/VectoCore/Utils/Validation.cs +++ b/VectoCommon/VectoCommon/Utils/Validation.cs @@ -36,9 +36,8 @@ using System.ComponentModel.DataAnnotations; using System.IO; using System.Linq; using System.Reflection; -using TUGraz.VectoCommon.Utils; -namespace TUGraz.VectoCore.Utils +namespace TUGraz.VectoCommon.Utils { /// <summary> /// Helper Class for doing the Validation diff --git a/VectoCommon/VectoCommon/VectoCommon.csproj b/VectoCommon/VectoCommon/VectoCommon.csproj index 9465f3d28f9f5906953c34438d9fb402cebf280e..f5af0adb6fb585a46a68a2b988b88da43e3c73e8 100644 --- a/VectoCommon/VectoCommon/VectoCommon.csproj +++ b/VectoCommon/VectoCommon/VectoCommon.csproj @@ -35,6 +35,7 @@ <HintPath>..\..\packages\NLog.4.2.3\lib\net45\NLog.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> @@ -67,6 +68,7 @@ <Compile Include="Utils\IntExtensionMethods.cs" /> <Compile Include="Utils\SI.cs" /> <Compile Include="Utils\StringExtensionMethods.cs" /> + <Compile Include="Utils\Validation.cs" /> <Compile Include="Utils\VectoMath.cs" /> </ItemGroup> <ItemGroup> diff --git a/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs b/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs index e3c8cc7e4b0df309ceed8d8a0c7e0174e2558542..052da517cdf08d63162b452bb8d6154eb38c4388 100644 --- a/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs +++ b/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs @@ -108,7 +108,7 @@ namespace TUGraz.VectoCore.ModelbasedTests.DriverStrategy ] public void Coach_AllSlopes(double v1, double v2) { - var slopes = new[] { 25, 20, 15, 12, 10, 7, 5, 3, 1, 0, -1, -3, -5, -7, -10, -12, -15, -20, -25 }; + var slopes = new[] { 15, 12, 10, 7, 5, 3, 1, 0, -1, -3, -5, -7, -10, -12, -15 }; foreach (var slope in slopes) { try { diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index 9f5ed156bc9efca212f6c14be6060e1428f96d28..51389efcaa97b612838947bd50f089c9d2375e3d 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -87,7 +87,6 @@ namespace TUGraz.VectoCore.Configuration /// </summary> public static readonly Second TargetTimeInterval = 0.5.SI<Second>(); - /// <summary> /// maximum time interval for the simulation in measured speed mode. /// </summary> @@ -151,6 +150,8 @@ namespace TUGraz.VectoCore.Configuration public static readonly MeterPerSecond VehicleStopClutchDisengageSpeed = 10.KMPHtoMeterPerSecond(); public static readonly Meter GearboxLookaheadForAccelerationEstimation = 100.SI<Meter>(); + + public static Kilogram MaximumGrossVehicleWeight = 40000.SI<Kilogram>(); } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index b9d0050d2aa729d6ed5a1a62b08d5e8671bb8746..375727b677541273cfd5e4a100a79d508de9b663 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper CurbWeight = data.CurbWeightChassis, //CurbWeigthExtra = data.CurbWeightExtra.SI<Kilogram>(), //Loading = data.Loading.SI<Kilogram>(), - GrossVehicleMassRating = data.GrossVehicleMassRating, + GrossVehicleWeight = data.GrossVehicleMassRating, //DragCoefficient = data.DragCoefficient, //CrossSectionArea = data.CrossSectionArea.SI<SquareMeter>(), //DragCoefficientRigidTruck = data.DragCoefficientRigidTruck, diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index 1f5714cbc1187ac283170dcb5e4b28da7dae1420..c5b20e4b95ba08eae68ebc1cb8b6e6ff3d35a52a 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -94,20 +94,16 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper } var retVal = SetCommonVehicleData(data); - - retVal.GrossVehicleMassRating = data.GrossVehicleMassRating; - - retVal.CurbWeigthExtra = mission.MassExtra; + retVal.TrailerGrossVehicleWeight = mission.TrailerGrossVehicleWeight; + retVal.CurbWeight += mission.BodyCurbWeight + mission.TrailerCurbWeight; retVal.Loading = loading; retVal.DynamicTyreRadius = DeclarationData.DynamicTyreRadius(data.Axles[DeclarationData.PoweredAxle()].Wheels, data.Rim); - var aerodynamicDragAera = mission.UseCdA2 - ? data.AirDragAreaRigidTruck - : data.AirDragArea; + var aerodynamicDragArea = data.AirDragArea + mission.DeltaCdA; retVal.CrossWindCorrectionCurve = - new CrosswindCorrectionCdxALookup(GetDeclarationAirResistanceCurve(retVal.VehicleCategory, aerodynamicDragAera), + new CrosswindCorrectionCdxALookup(GetDeclarationAirResistanceCurve(retVal.VehicleCategory, aerodynamicDragArea), CrossWindCorrectionMode.DeclarationModeCorrection); var axles = data.Axles; if (axles.Count < mission.AxleWeightDistribution.Length) { diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index fd38c2c1c3f6fc3b16a7e530bddd5f6687674688..8bd1a0e5d17f4e9cecca9afb8d11274ae0522dca 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -56,7 +56,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper var retVal = SetCommonVehicleData(data); - retVal.CurbWeigthExtra = data.CurbWeightExtra; + retVal.CurbWeight += data.CurbWeightExtra; + retVal.TrailerGrossVehicleWeight = 0.SI<Kilogram>(); retVal.Loading = data.Loading; retVal.DynamicTyreRadius = data.DynamicTyreRadius; retVal.CrossWindCorrectionMode = data.CrossWindCorrectionMode; diff --git a/VectoCore/VectoCore/Models/Declaration/Axle.cs b/VectoCore/VectoCore/Models/Declaration/Axle.cs index 4d4150279dc94c61b0c1e17bfc757881853504bb..9b686af4221da6689f18efee93764db531dcf653 100644 --- a/VectoCore/VectoCore/Models/Declaration/Axle.cs +++ b/VectoCore/VectoCore/Models/Declaration/Axle.cs @@ -33,7 +33,6 @@ using System.ComponentModel.DataAnnotations; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index cedc823acadeddbdfbc928de5ac2b6c2110b021d..3b72fa2aa8244fe4e3a833a6aa6e4ad094215be5 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -31,24 +31,19 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Net.NetworkInformation; -using iTextSharp.text.pdf; -using iTextSharp.text.pdf.interfaces; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class DeclarationData + internal class DeclarationData { private static DeclarationData _instance; private Segments _segments; @@ -63,6 +58,8 @@ namespace TUGraz.VectoCore.Models.Declaration private WHTCCorrection _whtcCorrection; private AirDrag _airDrag; private TorqueConverter _torqueConverter; + private StandardWeights _standardWeights; + private Payloads _payloads; public static Wheels Wheels { @@ -84,6 +81,11 @@ namespace TUGraz.VectoCore.Models.Declaration get { return Instance()._pt1 ?? (Instance()._pt1 = new PT1()); } } + public static Payloads Payloads + { + get { return Instance()._payloads ?? (Instance()._payloads = new Payloads()); } + } + public static ElectricSystem ElectricSystem { get { return Instance()._electricSystem ?? (Instance()._electricSystem = new ElectricSystem()); } @@ -104,6 +106,25 @@ namespace TUGraz.VectoCore.Models.Declaration } } + /// <summary> + /// Formula for calculating the payload for a given gross vehicle weight. + /// (so called "pc-formula", Whitebook Apr 2016, Part 1, p.187) + /// </summary> + public static Kilogram GetPayloadForGrossVehicleWeight(Kilogram grossVehicleWeight, MissionType missionType) + { + return missionType == MissionType.LongHaul + ? Payloads.Lookup75Percent(grossVehicleWeight) + : Payloads.Lookup50Percent(grossVehicleWeight); + } + + /// <summary> + /// Returns the payload for a trailer. This is 75% of (GVW-CurbWeight). + /// </summary> + public static Kilogram GetPayloadForTrailerWeight(Kilogram grossVehicleWeight, Kilogram curbWeight) + { + return Payloads.LookupTrailer(grossVehicleWeight, curbWeight); + } + public static Fan Fan { get { return Instance()._fan ?? (Instance()._fan = new Fan()); } @@ -118,6 +139,11 @@ namespace TUGraz.VectoCore.Models.Declaration } } + public static StandardWeights StandardWeights + { + get { return Instance()._standardWeights ?? (Instance()._standardWeights = new StandardWeights()); } + } + public static PneumaticSystem PneumaticSystem { get { return Instance()._pneumaticSystem ?? (Instance()._pneumaticSystem = new PneumaticSystem()); } @@ -293,7 +319,7 @@ namespace TUGraz.VectoCore.Models.Declaration } var gearRatio = gears[gear].Ratio / gears[gear + 1].Ratio; - var rpmMarginFactor = 1 + DeclarationData.Gearbox.ShiftPolygonRPMMargin / 100.0; + var rpmMarginFactor = 1 + ShiftPolygonRPMMargin / 100.0; var p2p = new Point(p2.X * gearRatio * rpmMarginFactor, p2.Y / gearRatio); var p3p = new Point(p3.X * gearRatio * rpmMarginFactor, p3.Y / gearRatio); @@ -345,7 +371,6 @@ namespace TUGraz.VectoCore.Models.Declaration .ToList(); } - internal static PerSecond ComputeEngineSpeed85kmh(ITransmissionInputData gear, double axleRatio, Meter dynamicTyreRadius, CombustionEngineData engine) { @@ -361,7 +386,6 @@ namespace TUGraz.VectoCore.Models.Declaration return engineSpeed; } - internal static List<Point> IntersectShiftPolygon(List<Point> orig, List<Point> transformedDownshift) { var intersections = new List<Point>(); diff --git a/VectoCore/VectoCore/Models/Declaration/Mission.cs b/VectoCore/VectoCore/Models/Declaration/Mission.cs index 5e0cd31d59eacdb8cf79c0e8c65f45d0b101a6a4..a11fccce4fbaecfac7f4a7790de744efc5a3c9ed 100644 --- a/VectoCore/VectoCore/Models/Declaration/Mission.cs +++ b/VectoCore/VectoCore/Models/Declaration/Mission.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.IO; using TUGraz.VectoCommon.Utils; @@ -46,23 +47,38 @@ namespace TUGraz.VectoCore.Models.Declaration { public static string GetShortName(this LoadingType loadingType) { - return loadingType.ToString().Substring(0, 1); + switch (loadingType) { + case LoadingType.FullLoading: + return "F"; + case LoadingType.ReferenceLoad: + return "R"; + case LoadingType.EmptyLoading: + return "E"; + default: + throw new ArgumentOutOfRangeException("loadingType", loadingType, null); + } } } - public class Mission { - public MissionType MissionType { get; set; } - public string CrossWindCorrection { get; set; } - public double[] AxleWeightDistribution { get; set; } - public double[] TrailerAxleWeightDistribution { get; set; } + public MissionType MissionType; + public string CrossWindCorrection; + public double[] AxleWeightDistribution; + public double[] TrailerAxleWeightDistribution; - public Kilogram MassExtra { get; set; } + public Kilogram CurbWeight; + public Kilogram BodyCurbWeight; + public Kilogram BodyGrossVehicleWeight; + public TrailerType TrailerType; + public Kilogram TrailerCurbWeight; + public Kilogram TrailerGrossVehicleWeight; + public Stream CycleFile; + public SquareMeter DeltaCdA; - public Kilogram MinLoad { get; set; } - public Kilogram RefLoad { get; set; } - public Kilogram MaxLoad { get; set; } + public Kilogram MinLoad; + public Kilogram RefLoad; + public Kilogram MaxLoad; public Dictionary<LoadingType, Kilogram> Loadings { @@ -75,15 +91,12 @@ namespace TUGraz.VectoCore.Models.Declaration }; } } + } - public Stream CycleFile { get; set; } - - public bool UseCdA2 { get; set; } - - public class LoadingEntry - { - public Kilogram LoadingWeight; - public string Name; - } + public enum TrailerType + { + None, + T1, + T2 } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/MissionType.cs b/VectoCore/VectoCore/Models/Declaration/MissionType.cs index b7e5a953c94208accc2cd0e078c6aa768b500ee5..8ccc72b7b96b46651a1bcafc2cd0b158713f896a 100644 --- a/VectoCore/VectoCore/Models/Declaration/MissionType.cs +++ b/VectoCore/VectoCore/Models/Declaration/MissionType.cs @@ -44,4 +44,12 @@ namespace TUGraz.VectoCore.Models.Declaration Interurban, Coach } + + public static class MissionTypeHelper + { + public static string GetName(this MissionType self) + { + return self.ToString().ToLowerInvariant(); + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/Payloads.cs b/VectoCore/VectoCore/Models/Declaration/Payloads.cs new file mode 100644 index 0000000000000000000000000000000000000000..e78819a7122496c9b0adee0db836583e285a8015 --- /dev/null +++ b/VectoCore/VectoCore/Models/Declaration/Payloads.cs @@ -0,0 +1,63 @@ +using System; +using System.Data; +using System.Linq; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Models.Declaration +{ + internal sealed class Payloads : LookupData<Kilogram, Payloads.PayloadEntry> + { + internal sealed class PayloadEntry + { + public Kilogram Payload50Percent; + public Kilogram Payload75Percent; + } + + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.Payloads.csv"; + + public Payloads() + { + ParseData(ReadCsvResource(ResourceId)); + } + + [Obsolete("Call Lookup50Percent, Lookup75Percent or LookupTrailer!", true)] + private new PayloadEntry Lookup(Kilogram grossVehicleWeight) + { + throw new NotImplementedException("Call Lookup50Percent, Lookup75Percent or LookupTrailer!"); + } + + public Kilogram Lookup50Percent(Kilogram grossVehicleWeight) + { + var section = Data.GetSection(d => d.Key > grossVehicleWeight); + return VectoMath.Interpolate(section.Item1.Key, section.Item2.Key, + section.Item1.Value.Payload50Percent, section.Item2.Value.Payload50Percent, + grossVehicleWeight); + } + + public Kilogram Lookup75Percent(Kilogram grossVehicleWeight) + { + var section = Data.GetSection(d => d.Key > grossVehicleWeight); + return VectoMath.Interpolate(section.Item1.Key, section.Item2.Key, + section.Item1.Value.Payload75Percent, section.Item2.Value.Payload75Percent, + grossVehicleWeight); + } + + public Kilogram LookupTrailer(Kilogram grossVehicleWeight, Kilogram curbWeight) + { + return 0.75 * (grossVehicleWeight - curbWeight); + } + + protected override void ParseData(DataTable table) + { + NormalizeTable(table); + Data = table.Rows.Cast<DataRow>() + .ToDictionary( + kv => kv.ParseDouble("grossvehicleweight").SI<Kilogram>(), + kv => new PayloadEntry { + Payload50Percent = kv.ParseDouble("payload50%").SI<Kilogram>(), + Payload75Percent = kv.ParseDouble("payload75%").SI<Kilogram>() + }); + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/Segments.cs b/VectoCore/VectoCore/Models/Declaration/Segments.cs index e97a807c64149797014e025684a3f0a68638973f..07294080960e31fc0d65108f6237a9669e25d60f 100644 --- a/VectoCore/VectoCore/Models/Declaration/Segments.cs +++ b/VectoCore/VectoCore/Models/Declaration/Segments.cs @@ -36,6 +36,7 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration @@ -83,7 +84,7 @@ namespace TUGraz.VectoCore.Models.Declaration }); } catch (InvalidOperationException e) { var errorMessage = string.Format( - "ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleMassRating: {2}", + "ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}", vehicleCategory, axleConfiguration.GetName(), grossVehicleMassRating); Log.Fatal(errorMessage); throw new VectoException(errorMessage, e); @@ -95,84 +96,103 @@ namespace TUGraz.VectoCore.Models.Declaration AxleConfiguration = axleConfiguration, VehicleClass = VehicleClassHelper.Parse(row.Field<string>("hdvclass")), AccelerationFile = RessourceHelper.ReadStream(RessourceHelper.Namespace + "VACC." + row.Field<string>(".vaccfile")), - Missions = CreateMissions(grossVehicleMassRating, curbWeight, row).ToArray(), + Missions = CreateMissions(ref grossVehicleMassRating, curbWeight, row), GrossVehicleMassRating = grossVehicleMassRating }; return segment; } - private static IEnumerable<Mission> CreateMissions(Kilogram grossVehicleMassRating, Kilogram curbWeight, DataRow row) + private static Mission[] CreateMissions(ref Kilogram grossVehicleWeight, Kilogram curbWeight, DataRow row) { - var trailerOnlyInLongHaul = row.Field<string>("vehiclecategory") == VehicleCategory.RigidTruck.ToString() && - row.Field<string>("traileraxles-longhaul") != "-" && - row.Field<string>("traileraxles-other") == "-"; - var missionTypes = Enum.GetValues(typeof(MissionType)).Cast<MissionType>(); - foreach (var missionType in missionTypes.Where(m => row.Field<string>(m.ToString()) == "1")) { - string vcdvField; - string axleField; - string trailerField; - - if (missionType == MissionType.LongHaul) { - vcdvField = "crosswindcorrection-longhaul"; - axleField = "truckaxles-longhaul"; - trailerField = "traileraxles-longhaul"; + var missions = new List<Mission>(); + foreach (var missionType in missionTypes.Where(m => row.Field<string>(m.ToString()) != "-")) { + var body = DeclarationData.StandardWeights.Lookup(row.Field<string>("body")); + + var trailerIsUsed = ShouldTrailerBeUsed(row, missionType); + var trailerField = row.Field<string>("trailer"); + var trailerType = trailerIsUsed && !string.IsNullOrWhiteSpace(trailerField) + ? trailerField.ParseEnum<TrailerType>() + : TrailerType.None; + var trailer = trailerIsUsed + ? DeclarationData.StandardWeights.Lookup(trailerField) + : DeclarationData.StandardWeights.Empty; + + var semiTrailerField = row.Field<string>("semitrailer"); + var semiTrailer = !string.IsNullOrWhiteSpace(semiTrailerField) + ? DeclarationData.StandardWeights.Lookup(semiTrailerField) + : DeclarationData.StandardWeights.Empty; + + trailer += semiTrailer; + + // limit gvw to MaxGVW (40t) + var gvw = VectoMath.Min(grossVehicleWeight + trailer.GrossVehicleWeight, + Constants.SimulationSettings.MaximumGrossVehicleWeight); + var maxLoad = gvw - curbWeight - body.CurbWeight - trailer.CurbWeight; + + var refLoadValue = row.Field<string>(missionType.ToString()).ToDouble(double.NaN); + Kilogram refLoad; + if (double.IsNaN(refLoadValue)) { + refLoad = DeclarationData.GetPayloadForGrossVehicleWeight(grossVehicleWeight, missionType) + + DeclarationData.GetPayloadForTrailerWeight(trailer.GrossVehicleWeight, trailer.CurbWeight); } else { - vcdvField = "crosswindcorrection-other"; - axleField = "truckaxles-other"; - trailerField = "traileraxles-other"; + refLoad = refLoadValue.SI<Kilogram>(); } + refLoad = VectoMath.Min(refLoad, maxLoad); + var mission = new Mission { MissionType = missionType, - CrossWindCorrection = row.Field<string>(vcdvField), - MassExtra = row.ParseDouble("massextra-" + missionType.ToString().ToLower()).SI<Kilogram>(), + CrossWindCorrection = row.Field<string>("crosswindcorrection" + GetMissionSuffix(missionType)), CycleFile = RessourceHelper.ReadStream(RessourceHelper.Namespace + "MissionCycles." + missionType + ".vdri"), - AxleWeightDistribution = row.Field<string>(axleField).Split('/').ToDouble().Select(x => x / 100.0).ToArray(), - UseCdA2 = trailerOnlyInLongHaul && missionType != MissionType.LongHaul, + AxleWeightDistribution = GetAxleWeightDistribution(row, missionType), + CurbWeight = curbWeight, + BodyCurbWeight = body.CurbWeight, + BodyGrossVehicleWeight = grossVehicleWeight, + TrailerType = trailerType, + TrailerCurbWeight = trailer.CurbWeight, + TrailerGrossVehicleWeight = trailer.GrossVehicleWeight, + DeltaCdA = trailer.DeltaCrossWindArea, + MinLoad = 0.SI<Kilogram>(), + MaxLoad = maxLoad, + RefLoad = refLoad, + TrailerAxleWeightDistribution = GetTrailerAxleWeightDistribution(row, missionType), }; + missions.Add(mission); + } + return missions.ToArray(); + } - var trailerAxles = row.Field<string>(trailerField).Split('/'); - var count = 0; - var weightPercent = 0.0; - - if (trailerAxles[0] != "-") { - count = int.Parse(trailerAxles[1]); - weightPercent = trailerAxles[0].ToDouble(); - } - mission.TrailerAxleWeightDistribution = Enumerable.Repeat(weightPercent / count / 100.0, count).ToArray(); - - mission.MinLoad = 0.SI<Kilogram>(); - mission.MaxLoad = grossVehicleMassRating - mission.MassExtra - curbWeight; - - var refLoadField = row.Field<string>("payload-" + missionType.ToString().ToLower()); - mission.RefLoad = CalculateRefLoad(grossVehicleMassRating, refLoadField, missionType, mission.MaxLoad); + /// <summary> + /// Checks if a trailer should be used for the current missionType. + /// </summary> + private static bool ShouldTrailerBeUsed(DataRow row, MissionType missionType) + { + return !string.IsNullOrWhiteSpace(row.Field<string>("traileraxles" + GetMissionSuffix(missionType))); + } - yield return mission; + private static double[] GetTrailerAxleWeightDistribution(DataRow row, MissionType missionType) + { + var trailerAxles = + row.Field<string>("traileraxles" + GetMissionSuffix(missionType)).Split('/'); + if (!string.IsNullOrWhiteSpace(trailerAxles[0])) { + var count = int.Parse(trailerAxles[1]); + return (trailerAxles[0].ToDouble() / 100.0 / count).Repeat(count).ToArray(); } + return new double[0]; } - private static Kilogram CalculateRefLoad(Kilogram grossVehicleMassRating, string refLoadField, MissionType missionType, - Kilogram maxLoad) + private static double[] GetAxleWeightDistribution(DataRow row, MissionType missionType) { - const double longHaulFactor = 0.5882; - const double otherFactor = 0.3941; - var longHaulWeightDeduction = 2511.8.SI<Kilogram>(); - var otherWeightDeduction = 1705.9.SI<Kilogram>(); - - Kilogram refLoad; - if (refLoadField == "f") { - if (missionType == MissionType.LongHaul) { - refLoad = longHaulFactor * grossVehicleMassRating - longHaulWeightDeduction; - } else { - refLoad = otherFactor * grossVehicleMassRating - otherWeightDeduction; - } - } else { - refLoad = refLoadField.ToDouble().SI<Kilogram>(); - } + return + row.Field<string>("truckaxles" + GetMissionSuffix(missionType)) + .Split('/').ToDouble().Select(x => x / 100.0).ToArray(); + } - return VectoMath.Min(refLoad, maxLoad); + private static string GetMissionSuffix(MissionType missionType) + { + return (missionType == MissionType.LongHaul ? "-longhaul" : "-other"); } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/StandardWeights.cs b/VectoCore/VectoCore/Models/Declaration/StandardWeights.cs new file mode 100644 index 0000000000000000000000000000000000000000..44e0c5212450efd4ff5edb18ea8753147f0c2330 --- /dev/null +++ b/VectoCore/VectoCore/Models/Declaration/StandardWeights.cs @@ -0,0 +1,113 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2016 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ + +using System.CodeDom; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Models.Declaration +{ + internal sealed class StandardWeight + { + public Kilogram CurbWeight; + public Kilogram GrossVehicleWeight; + + public Kilogram MaxPayLoad + { + get { return GrossVehicleWeight - CurbWeight; } + } + + public SquareMeter DeltaCrossWindArea; + + public static StandardWeight operator +(StandardWeight first, StandardWeight second) + { + return new StandardWeight { + CurbWeight = first.CurbWeight + second.CurbWeight, + DeltaCrossWindArea = first.DeltaCrossWindArea + second.DeltaCrossWindArea, + GrossVehicleWeight = first.GrossVehicleWeight + second.GrossVehicleWeight + }; + } + } + + /// <summary> + /// Lookup Class for Standard Weights of Bodies, Trailers and Semitrailers. + /// Standard Weights include + /// CurbWeight (=Empty Weight), + /// Gross Vehicle Weight (=Maximum Allowed Weight), and + /// MaxPayload. + /// </summary> + internal sealed class StandardWeights : LookupData<string, StandardWeight> + { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.Body_Trailers_Weights.csv"; + + public StandardWeights() + { + ParseData(ReadCsvResource(ResourceId)); + } + + public StandardWeight Empty = new StandardWeight { + CurbWeight = 0.SI<Kilogram>(), + GrossVehicleWeight = 0.SI<Kilogram>(), + DeltaCrossWindArea = 0.SI<SquareMeter>() + }; + + public override StandardWeight Lookup(string id) + { + if (string.IsNullOrWhiteSpace(id)) { + return Empty; + } + + try { + return Data[id]; + } catch (KeyNotFoundException) { + throw new VectoException("StandardWeigths Lookup Error: No value found for ID '{0}'", id); + } + } + + protected override void ParseData(DataTable table) + { + NormalizeTable(table); + + Data = table.Rows.Cast<DataRow>() + .ToDictionary( + kv => kv.Field<string>("name"), + kv => new StandardWeight { + CurbWeight = kv.ParseDoubleOrGetDefault("curbmass").SI<Kilogram>(), + GrossVehicleWeight = kv.ParseDoubleOrGetDefault("maxgrossmass").SI<Kilogram>(), + DeltaCrossWindArea = kv.ParseDoubleOrGetDefault("deltacdxafortraileroperationinlonghaul").SI<SquareMeter>() + }); + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/AxleGearData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/AxleGearData.cs index 72f567e92c13d1a66cf02e8911dc189b38f85f70..ed02ce1b91940ca4d559340826190ae593103868 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/AxleGearData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/AxleGearData.cs @@ -29,8 +29,8 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs index d17368efbdb73bc7259792e119cbc66b5d5c9189..24555fd7ce3d93c27331cd713cf82b66a5765bf7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs @@ -30,7 +30,7 @@ */ using System.ComponentModel.DataAnnotations; -using TUGraz.VectoCore.Utils; +using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs index 4436424adce2e6954fac7d29cc533672c4559934..0cdb43d5f7b51e629767e73ad555c6c8e1cd71f7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs @@ -35,7 +35,6 @@ using System.Runtime.Serialization; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { @@ -51,29 +50,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// </summary> [Required, ValidateObject] public Dictionary<uint, GearData> Gears = new Dictionary<uint, GearData>(); - /// <summary> - /// Gets the type. - /// </summary> - /// <value> - /// The type. - /// </value> public GearboxType Type { get; internal set; } - /// <summary> - /// Gets the inertia. - /// </summary> - /// <value> - /// The inertia. - /// </value> [Required, SIRange(0, 10)] public KilogramSquareMeter Inertia { get; internal set; } - /// <summary> - /// Gets the traction interruption. - /// </summary> - /// <value> - /// The traction interruption. - /// </value> [Required, SIRange(0, 5)] public Second TractionInterruption { get; internal set; } @@ -105,21 +86,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [Required, Range(0, 0.5)] public double StartTorqueReserve { get; internal set; } - /// <summary> - /// Gets the start speed. - /// </summary> - /// <value> - /// The start speed. - /// </value> [Required, SIRange(double.Epsilon, 5)] public MeterPerSecond StartSpeed { get; internal set; } - /// <summary> - /// Gets the start acceleration. - /// </summary> - /// <value> - /// The start acceleration. - /// </value> [Required, SIRange(double.Epsilon, 2)] public MeterPerSquareSecond StartAcceleration { get; internal set; } @@ -131,8 +100,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// </value> public bool HasTorqueConverter { get; internal set; } + [Required, SIRange(0, double.MaxValue)] public Second UpshiftAfterDownshiftDelay { get; internal set; } + + [Required, SIRange(0, double.MaxValue)] public Second DownshiftAfterUpshiftDelay { get; internal set; } + + [Required, SIRange(0, double.MaxValue)] public MeterPerSquareSecond UpshiftMinAcceleration { get; internal set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderData.cs index 2e4f227206ee4185f0f22eac4cae5c8ad6aa3d83..2e24e532c7e3b2b47b6801805b9261be9f9e2f27 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderData.cs @@ -30,7 +30,7 @@ */ using TUGraz.VectoCommon.Models; -using TUGraz.VectoCore.Utils; +using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index aca8f710a0dc809e2a24d384f1e202fb71a6721a..3f21d3baf2d6d7b1cc3eb45ecdbdd31d544886a7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -36,6 +36,7 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Utils; @@ -49,13 +50,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { public VehicleCategory VehicleCategory { get; internal set; } public VehicleClass VehicleClass { get; internal set; } + public AxleConfiguration AxleConfiguration { get; internal set; } [Required, ValidateObject] public ICrossWindCorrection CrossWindCorrectionCurve { get; internal set; } private List<Axle> _axleData; - [ValidateObject] + [Required, ValidateObject] public List<Axle> AxleData { get { return _axleData; } @@ -66,19 +68,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } } - public AxleConfiguration AxleConfiguration { get; internal set; } - + /// <summary> + /// The Curb Weight of the vehicle + /// (+ Curb Weight of Standard-Body if it has one) + /// (+ Curb Weight of Trailer if it has one) + /// </summary> [Required, SIRange(500, 40000)] public Kilogram CurbWeight { get; internal set; } - [Required, SIRange(0, 40000)] - public Kilogram CurbWeigthExtra { get; internal set; } - [Required, SIRange(0, 40000)] public Kilogram Loading { get; internal set; } + /// <summary> + /// The Gross Vehicle Weight of the Vehicle. + /// </summary> [Required, SIRange(3500, 40000)] - public Kilogram GrossVehicleMassRating { get; internal set; } + public Kilogram GrossVehicleWeight { get; internal set; } + + /// <summary> + /// The Gross Vehicle Weight of the Trailer (if the vehicle has one). + /// </summary> + [Required, SIRange(0, 40000)] + public Kilogram TrailerGrossVehicleWeight { get; internal set; } [Required, SIRange(0.1, 0.7)] public Meter DynamicTyreRadius { get; internal set; } @@ -96,7 +107,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var retVal = 0.SI<Kilogram>(); retVal += CurbWeight ?? 0.SI<Kilogram>(); - retVal += CurbWeigthExtra ?? 0.SI<Kilogram>(); retVal += Loading ?? 0.SI<Kilogram>(); return retVal; } @@ -105,7 +115,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var retVal = 0.SI<Kilogram>(); retVal += CurbWeight ?? 0.SI<Kilogram>(); - retVal += CurbWeigthExtra ?? 0.SI<Kilogram>(); return retVal; } @@ -147,10 +156,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data weightShareSum, 1 - weightShareSum)); } - if (vehicleData.TotalVehicleWeight() > vehicleData.GrossVehicleMassRating) { + // total gvw is limited by max gvw (40t) + var gvwTotal = VectoMath.Min(vehicleData.GrossVehicleWeight + vehicleData.TrailerGrossVehicleWeight, + Constants.SimulationSettings.MaximumGrossVehicleWeight); + + if (vehicleData.TotalVehicleWeight() > gvwTotal) { return new ValidationResult( - string.Format("Total Vehicle Weight is greater than GrossVehicleMassRating! sum: {0}, GVM: {1}", - vehicleData.TotalVehicleWeight(), vehicleData.GrossVehicleMassRating)); + string.Format("Total Vehicle Weight is greater than GrossVehicleWeight! Weight: {0}, GVW: {1}", + vehicleData.TotalVehicleWeight(), gvwTotal)); } return ValidationResult.Success; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs index dc7739b3f9a0d952ed71b77f9befe8cdbbb7ba9c..950d2c8f414317474f9f32968eebba533a137e45 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs @@ -81,7 +81,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl foreach (var kv in _powerDemands.Where(kv => !string.IsNullOrWhiteSpace(kv.Key))) { container[kv.Key] = kv.Value; } - if (container[ModalResultField.P_aux] == null) { + if (container[ModalResultField.P_aux] == null || container[ModalResultField.P_aux] == DBNull.Value) { // don't overwrite if someone else already wrote the total aux power container[ModalResultField.P_aux] = _powerDemands.Values.Sum(p => p); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 9f46216ef167ea2d65bb41b8b9be24f94c940f9b..2e2506572dcf708049c9e8328d4c308eba9404c8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.ComponentModel.DataAnnotations; using System.Diagnostics; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; @@ -57,7 +58,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <summary> /// The data and settings for the gearbox. /// </summary> - [ValidateObject] internal readonly GearboxData ModelData; + [Required, ValidateObject] internal readonly GearboxData ModelData; /// <summary> /// The shift strategy. diff --git a/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs b/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs index d2af4e8c633188130fffd972fe4f266f7f69b64c..1b00382da93f601a9abb974b4fa490f69099f626 100644 --- a/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs @@ -36,6 +36,7 @@ using System.Drawing.Imaging; using System.Globalization; using System.IO; using System.Linq; +using System.Threading.Tasks; using System.Windows.Forms.DataVisualization.Charting; using iTextSharp.text; using iTextSharp.text.pdf; @@ -51,8 +52,14 @@ using Rectangle = System.Drawing.Rectangle; namespace TUGraz.VectoCore.OutputData.PDF { + /// <summary> + /// Class for writing a PDF Declaration report. + /// </summary> public class PDFDeclarationReport : DeclarationReport { + /// <summary> + /// the writer which actually persists the stream (either to file or somewhere else). + /// </summary> private readonly IReportWriter _writer; /// <summary> @@ -91,12 +98,23 @@ namespace TUGraz.VectoCore.OutputData.PDF protected internal override void DoWriteReport() { ReportDate = DateTime.Now.ToString(CultureInfo.InvariantCulture); - var titlePage = CreateTitlePage(Missions); - var cyclePages = Missions.OrderBy(m => m.Key).Select((m, i) => CreateCyclePage(m.Value, i + 2, Missions.Count + 1)); - MergeDocuments(titlePage, cyclePages, _writer.WriteStream(ReportType.DeclarationReportPdf)); + var tasks = new List<Task<Stream>> { Task.Run(() => CreateTitlePage(Missions)) }; + tasks.AddRange(Missions + .OrderBy(m => m.Key) + .Select((m, i) => Task.Run(() => CreateCyclePage(m.Value, i + 2, Missions.Count + 1)))); + + Task.WaitAll(tasks.Cast<Task>().ToArray()); + var pages = tasks.Select(t => t.Result); + + MergeDocuments(pages, _writer.WriteStream(ReportType.DeclarationReportPdf)); } + /// <summary> + /// Initializes the report with the current date and some general data. + /// </summary> + /// <param name="modelData">the model data.</param> + /// <param name="segment">the current segment of the vehicle.</param> protected override void DoInitializeReport(VectoRunData modelData, Segment segment) { EngineModel = modelData.EngineData.ModelName; @@ -139,7 +157,10 @@ namespace TUGraz.VectoCore.OutputData.PDF var i = 1; foreach (var results in missions.Values.OrderBy(m => m.Mission.MissionType)) { - pdfFields.SetField("Mission" + i, results.Mission.MissionType.ToString()); + var trailerSuffix = results.Mission.TrailerType != TrailerType.None + ? string.Format(" with {0} Trailer", results.Mission.TrailerType) + : ""; + pdfFields.SetField("Mission" + i, results.Mission.MissionType + trailerSuffix); var data = results.ModData[LoadingType.ReferenceLoad]; @@ -173,7 +194,7 @@ namespace TUGraz.VectoCore.OutputData.PDF img.SetAbsolutePosition(360, 75); content.AddImage(img); - img = GetVehicleImage(Segment, MissionType.LongHaul); + img = GetVehicleImage(Segment, TrailerType.None); img.ScaleAbsolute(180, 50); img.SetAbsolutePosition(30, 475); content.AddImage(img); @@ -182,6 +203,7 @@ namespace TUGraz.VectoCore.OutputData.PDF stamper.Writer.CloseStream = false; stamper.Close(); + stream.Position = 0; return stream; } @@ -209,7 +231,11 @@ namespace TUGraz.VectoCore.OutputData.PDF Segment.AxleConfiguration.GetName(), Segment.VehicleCategory)); pdfFields.SetField("HDVclass", "HDV Class " + Segment.VehicleClass.GetClassNumber()); pdfFields.SetField("PageNr", string.Format("Page {0} of {1}", currentPageNr, pageCount)); - pdfFields.SetField("Mission", results.Mission.MissionType.ToString()); + + var trailerSuffix = results.Mission.TrailerType != TrailerType.None + ? string.Format(" with {0} Trailer", results.Mission.TrailerType) + : ""; + pdfFields.SetField("Mission", results.Mission.MissionType + trailerSuffix); foreach (var pair in results.ModData) { var loadingType = pair.Key; @@ -234,7 +260,7 @@ namespace TUGraz.VectoCore.OutputData.PDF var content = stamper.GetOverContent(1); - var img = GetVehicleImage(Segment, results.Mission.MissionType); + var img = GetVehicleImage(Segment, results.Mission.TrailerType); img.ScaleAbsolute(180, 50); img.SetAbsolutePosition(600, 475); content.AddImage(img); @@ -253,30 +279,27 @@ namespace TUGraz.VectoCore.OutputData.PDF stamper.Writer.CloseStream = false; stamper.Close(); + + stream.Position = 0; return stream; } /// <summary> /// Merges the given stream to one document and writes it to a file on disk. /// </summary> - /// <param name="titlePage"></param> /// <param name="pages">The pages.</param> /// <param name="reportWriter"></param> - private static void MergeDocuments(Stream titlePage, IEnumerable<Stream> pages, Stream reportWriter) + private static void MergeDocuments(IEnumerable<Stream> pages, Stream reportWriter) { - var document = new Document(PageSize.A4.Rotate(), 12, 12, 12, 12); - var writer = PdfWriter.GetInstance(document, reportWriter); - - document.Open(); - titlePage.Position = 0; - document.Add(Image.GetInstance(writer.GetImportedPage(new PdfReader(titlePage), 1))); - - foreach (var cyclePage in pages) { - cyclePage.Position = 0; - document.Add(Image.GetInstance(writer.GetImportedPage(new PdfReader(cyclePage), 1))); + using (var document = new Document(PageSize.A4.Rotate(), 12, 12, 12, 12)) + using (var writer = new PdfCopy(document, reportWriter)) { + document.Open(); + foreach (var page in pages) { + using (var reader = new PdfReader(page)) { + writer.AddDocument(reader); + } + } } - - document.Close(); } /// <summary> @@ -355,8 +378,9 @@ namespace TUGraz.VectoCore.OutputData.PDF TitleFont = new Font("Helvetica", 20), LabelStyle = { Font = new Font("Helvetica", 20) }, LabelAutoFitStyle = LabelAutoFitStyles.None, - Minimum = 0, - Maximum = 80 + Minimum = 20, + Maximum = 80, + Interval = 10, }, AxisY = { Title = "CO2 [g/km]", @@ -546,26 +570,24 @@ namespace TUGraz.VectoCore.OutputData.PDF /// <summary> /// Gets the appropriate vehicle image. /// </summary> - /// <param name="segment">The segment.</param> - /// <param name="missionType">Type of the mission.</param> - /// <returns></returns> - private static Image GetVehicleImage(Segment segment, MissionType missionType) + private static Image GetVehicleImage(Segment segment, TrailerType trailerType) { var name = "Undef.png"; + var withTrailer = trailerType != TrailerType.None; switch (segment.VehicleClass) { case VehicleClass.Class1: case VehicleClass.Class2: case VehicleClass.Class3: - name = "4x2r.png"; + name = withTrailer ? "4x2rt.png" : "4x2r.png"; break; case VehicleClass.Class4: - name = missionType == MissionType.LongHaul ? "4x2rt.png" : "4x2r.png"; + name = withTrailer ? "4x2rt.png" : "4x2r.png"; break; case VehicleClass.Class5: name = "4x2tt.png"; break; case VehicleClass.Class9: - name = missionType == MissionType.LongHaul ? "6x2rt.png" : "6x2r.png"; + name = withTrailer ? "6x2rt.png" : "6x2r.png"; break; case VehicleClass.Class10: name = "6x2tt.png"; diff --git a/VectoCore/VectoCore/Resources/Declaration/Body_Trailers_Weights.csv b/VectoCore/VectoCore/Resources/Declaration/Body_Trailers_Weights.csv new file mode 100644 index 0000000000000000000000000000000000000000..1fcd5eafa3359216dd9adfbdfce17d54b8c75fe7 --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/Body_Trailers_Weights.csv @@ -0,0 +1,12 @@ +name,curb mass,max gross mass,delta CdxA for trailer operation in long haul,remark +#,[kg],[kg],[m²], +B1,1600,-,-,--- +B2,1900,-,-,--- +B3,2000,-,-,--- +B4,2100,-,-,--- +B5,2200,-,-,"""B6"" changed to ""B5"" as ""old B5"" not applicable anymore" +T1,3400,10500,1.1, +T2,5400,18000,0.6, +ST1,7500,24000,-,relevant for fully loaded is GVM of tractor semitrailer combination = 40000kg +ST1-v2,7500,-,-, +Dolly,2500,-,-,only relevant for EMS diff --git a/VectoCore/VectoCore/Resources/Declaration/Payloads.csv b/VectoCore/VectoCore/Resources/Declaration/Payloads.csv new file mode 100644 index 0000000000000000000000000000000000000000..fe7c5c6c52d76a9c71b882fbf290f938faf66e61 --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/Payloads.csv @@ -0,0 +1,3 @@ +Gross Vehicle Weight,Payload 50%,Payload 75% +7500,1250,1900 +16000,4600,6900 diff --git a/VectoCore/VectoCore/Resources/Declaration/Report/title3CyclesTemplate.pdf b/VectoCore/VectoCore/Resources/Declaration/Report/title3CyclesTemplate.pdf index 52eb20016fad493740e8937fe76130e83c446254..8a269a8b61eae9bb59f13c45db5d09d50968a0db 100644 Binary files a/VectoCore/VectoCore/Resources/Declaration/Report/title3CyclesTemplate.pdf and b/VectoCore/VectoCore/Resources/Declaration/Report/title3CyclesTemplate.pdf differ diff --git a/VectoCore/VectoCore/Resources/Declaration/SegmentTable Description.md b/VectoCore/VectoCore/Resources/Declaration/SegmentTable Description.md new file mode 100644 index 0000000000000000000000000000000000000000..a4647dafcde02afd689c42e310a6a9b43ce160c6 --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/SegmentTable Description.md @@ -0,0 +1,57 @@ +# SegmentTable + +This document describes the structure of the file SegmentTable.csv. This +document resembles the Vehicle Classes table from the ACEA Whitebook and +defines standard vehicle classes, values and driving cycles. +(ACEA Whitebook April 2016, Part 1, Page 51). + +If a value is not defined there is a "-". + +| column | values | description | +|-----------------------------------|------------------------------------------------|----------------------------------------------------------------------------------------------------| +| Valid | 0,1 | 1 means the entry is enabled, 0 means the entry is disabled and will not be used in vecto. | +| Vehicle Category | RigidTruck,Tractor,CityBus,InterurbanBus,Coach | The basic vehicle category from whitebook. | +| Axle Conf. | 4x2,4x4,6x2,6x4,6x6,8x2,8x4,8x6,8x8 | | +| GVW_Min | | | +| GVW_Max | | | +| HDV class | | | +| Body | B1,B2,B3,B4,B5,B6 | Standard bodies (see standardbodies.csv) | +| Trailer | T1, T2 | Standard trailers (see standardbodies.csv) | +| Semitrailer | ST1, ST1-v2 | Standard semitrailer (see standardbodies.csv) | +| .vacc file | <filename>.vacc | | +| Cross Wind Correction - Long haul | RigidSolo, RigidTrailer, TractorSemitrailer | | +| Cross Wind Correction - Other | RigidSolo, TractorSemitrailer, CoachBus | | +| Truck Axles - Long haul | percent(/percent)\* (e.g. 40/60) | percent share for each axle on the truck. sum must be < 100. sum + trailer must be 100. | +| Truck Axles - Other | percent(/percent)\* | percent share for each axle on the truck. sum must be < 100. sum + trailer must be 100. | +| Trailer Axles - Long haul | percent/count | percent share divides amongst the axles of the trailer. e.g. for 3 axles: 60/3 (means 20%/20%/20%) | +| Trailer Axles - Other | percent/count | percent share divides amongst the axles of the trailer. e.g. for 3 axles: 60/3 (means 20%/20%/20%) | +| Long haul | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Regional delivery | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Urban delivery | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Municipal utility | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Construction | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Heavy Urban | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Urban | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Suburban | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Interurban | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Coach | 0,1 | if 1 then this driving cycle is enabled for declaration, 0 means it is disabled. | +| Mass Extra - Long haul | | | +| Mass Extra - Regional delivery | | | +| Mass Extra - Urban delivery | | | +| Mass Extra - Municipal utility | | | +| Mass Extra - Construction | | | +| Mass Extra - Heavy Urban | | | +| Mass Extra - Urban | | | +| Mass Extra - Suburban | | | +| Mass Extra - Interurban | | | +| Mass Extra - Coach | | | +| Payload - Long haul | | | +| Payload - Regional delivery | | | +| Payload - Urban delivery | | | +| Payload - Municipal utility | | | +| Payload - Construction | | | +| Payload - Heavy Urban | | | +| Payload - Urban | | | +| Payload - Suburban | | | +| Payload - Interurban | | | +| Payload - Coach | | | diff --git a/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv b/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv index f0ac67d600ea4e0cf9348459f85e53b38ed1a0b1..8f88bdc8d56bab902fb4ffdc10a7db21256fdfc8 100644 --- a/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv +++ b/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv @@ -1,29 +1,29 @@ -Valid,Vehicle Category ,Axle Conf.,GVW_Min,GVW_Max,HDV class,.vacc file ,Cross Wind Correction - Long haul,Cross Wind Correction - Other,Truck Axles - Long haul,Truck Axles - Other,Trailer Axles - Long haul,Trailer Axles - Other,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach,Mass Extra - Long haul,Mass Extra - Regional delivery,Mass Extra - Urban delivery,Mass Extra - Municipal utility,Mass Extra - Construction,Mass Extra - Heavy Urban,Mass Extra - Urban,Mass Extra - Suburban,Mass Extra - Interurban,Mass Extra - Coach,Payload - Long haul,Payload - Regional delivery,Payload - Urban delivery,Payload - Municipal utility,Payload - Construction,Payload - Heavy Urban,Payload - Urban,Payload - Suburban,Payload - Interurban,Payload - Coach -0 ,RigidTruck ,4x2 ,0 ,7.5 ,0 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,- ,??? ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,??? ,- ,- ,- ,- ,- ,- ,- -1 ,RigidTruck ,4x2 ,7.5 ,10 ,1 ,Truck.vacc ,- ,RigidSolo ,- ,45/55 ,- ,- ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,- ,1600 ,1600 ,- ,- ,- ,- ,- ,- ,- ,- ,f ,f ,- ,- ,- ,- ,- ,- ,- -1 ,Tractor ,4x2 ,7.5 ,10 ,1 ,Truck.vacc ,- ,RigidSolo ,- ,45/55 ,- ,- ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,- ,1600 ,1600 ,- ,- ,- ,- ,- ,- ,- ,- ,f ,f ,- ,- ,- ,- ,- ,- ,- -1 ,RigidTruck ,4x2 ,10 ,12 ,2 ,Truck.vacc ,RigidSolo ,RigidSolo ,40/60 ,45/55 ,- ,- ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1900 ,1900 ,1900 ,- ,- ,- ,- ,- ,- ,- ,f ,f ,f ,- ,- ,- ,- ,- ,- ,- -1 ,Tractor ,4x2 ,10 ,12 ,2 ,Truck.vacc ,RigidSolo ,RigidSolo ,40/60 ,45/55 ,- ,- ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1900 ,1900 ,1900 ,- ,- ,- ,- ,- ,- ,- ,f ,f ,f ,- ,- ,- ,- ,- ,- ,- -1 ,RigidTruck ,4x2 ,12 ,16 ,3 ,Truck.vacc ,- ,RigidSolo ,- ,40/60 ,- ,- ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,- ,2000 ,2000 ,- ,- ,- ,- ,- ,- ,- ,- ,f ,f ,- ,- ,- ,- ,- ,- ,- -1 ,Tractor ,4x2 ,12 ,16 ,3 ,Truck.vacc ,- ,RigidSolo ,- ,40/60 ,- ,- ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,- ,2000 ,2000 ,- ,- ,- ,- ,- ,- ,- ,- ,f ,f ,- ,- ,- ,- ,- ,- ,- -1 ,RigidTruck ,4x2 ,16 ,99 ,4 ,Truck.vacc ,RigidTrailer ,RigidSolo ,20/30 ,45/55 ,50/2 ,- ,1 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,7500 ,2100 ,- ,2100 ,- ,- ,- ,- ,- ,- ,14000 ,4400 ,- ,4400 ,- ,- ,- ,- ,- ,- -1 ,Tractor ,4x2 ,16 ,99 ,5 ,Truck.vacc ,TractorSemitrailer ,TractorSemitrailer ,20/25 ,25/25 ,55/3 ,50/3 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,7500 ,7500 ,- ,- ,- ,- ,- ,- ,- ,- ,19300 ,12900 ,- ,- ,- ,- ,- ,- ,- ,- -0 ,RigidTruck ,4x4 ,7.5 ,16 ,6 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,0 ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,??? ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,??? ,- ,- ,- ,- ,- -0 ,RigidTruck ,4x4 ,16 ,99 ,7 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- -0 ,Tractor ,4x4 ,16 ,99 ,8 ,Truck.vacc ,- ,TractorSemitrailer ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- -1 ,RigidTruck ,6x2 ,0 ,99 ,9 ,Truck.vacc ,RigidTrailer ,RigidSolo ,20/30/15 ,35/40/25 ,35/2 ,- ,1 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,7600 ,2200 ,- ,2200 ,- ,- ,- ,- ,- ,- ,19300 ,7100 ,- ,7100 ,- ,- ,- ,- ,- ,- -1 ,Tractor ,6x2 ,0 ,99 ,10 ,Truck.vacc ,TractorSemitrailer ,TractorSemitrailer ,15/10/20 ,20/10/20 ,55/2 ,50/2 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,7500 ,7500 ,- ,- ,- ,- ,- ,- ,- ,- ,19300 ,12900 ,- ,- ,- ,- ,- ,- ,- ,- -0 ,RigidTruck ,6x4 ,0 ,99 ,11 ,Truck.vacc ,- ,RigidSolo ,- ,35/35/30 ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,7100 ,- ,- ,- ,- ,- -0 ,Tractor ,6x4 ,0 ,99 ,12 ,Truck.vacc ,- ,TractorSemitrailer ,- ,20/15/15 ,- ,50/2 ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,12900 ,- ,- ,- ,- ,- -0 ,RigidTruck ,6x6 ,0 ,99 ,13 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- -0 ,Tractor ,6x6 ,0 ,99 ,14 ,Truck.vacc ,- ,TractorSemitrailer ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- -0 ,RigidTruck ,8x2 ,0 ,99 ,15 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- -0 ,RigidTruck ,8x4 ,0 ,99 ,16 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,12900 ,- ,- ,- ,- ,- -0 ,RigidTruck ,8x6 ,0 ,99 ,17 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- -0 ,RigidTruck ,8x8 ,0 ,99 ,17 ,Truck.vacc ,- ,RigidSolo ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- -0 ,CityBus ,4x2 ,0 ,18 ,B1 ,N/A ,- ,CoachBus ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,0 ,0 ,- ,- ,- ,- ,- ,??? ,??? ,??? ,- ,- ,- ,- ,- ,- ,- ,??? ,??? ,??? ,- ,- -0 ,InterurbanBus ,4x2 ,0 ,18 ,B2 ,N/A ,- ,CoachBus ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- -0 ,Coach ,4x2 ,0 ,18 ,B3 ,N/A ,- ,CoachBus ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? -0 ,CityBus ,6x2 ,18 ,99 ,B4 ,N/A ,- ,CoachBus ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,0 ,0 ,- ,- ,- ,- ,- ,??? ,??? ,??? ,- ,- ,- ,- ,- ,- ,- ,??? ,??? ,??? ,- ,- -0 ,InterurbanBus ,6x2 ,18 ,99 ,B5 ,N/A ,- ,CoachBus ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- -0 ,Coach ,6x2 ,18 ,99 ,B6 ,N/A ,- ,CoachBus ,- ,- ,- ,- ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? \ No newline at end of file +Valid,Vehicle Category,Axle Conf.,GVW_Min,GVW_Max,HDV class,Body,Trailer,Semitrailer,.vacc file,Cross Wind Correction - Long haul,Cross Wind Correction - Other,Truck Axles - Long haul,Truck Axles - Other,Trailer Axles - Long haul,Trailer Axles - Other,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach +0 ,RigidTruck ,4x2 ,0 ,7.5 ,0 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +1 ,RigidTruck ,4x2 ,7.5 ,10 ,1 ,B1 , , ,Truck.vacc, ,RigidSolo , ,45/55 , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +1 ,Tractor ,4x2 ,7.5 ,10 ,1 ,B1 , , ,Truck.vacc, ,RigidSolo , ,45/55 , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +1 ,RigidTruck ,4x2 ,10 ,12 ,2 ,B2 ,T1 , ,Truck.vacc,RigidTrailer ,RigidSolo ,22.5/32.5 ,45/55 ,45/1 , ,pc(R) ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +1 ,Tractor ,4x2 ,10 ,12 ,2 ,B2 ,T1 , ,Truck.vacc,RigidTrailer ,RigidSolo ,22.5/32.5 ,45/55 ,45/1 , ,pc(R) ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +1 ,RigidTruck ,4x2 ,12 ,16 ,3 ,B3 , , ,Truck.vacc, ,RigidSolo , ,40/60 , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +1 ,Tractor ,4x2 ,12 ,16 ,3 ,B3 , , ,Truck.vacc, ,RigidSolo , ,40/60 , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +1 ,RigidTruck ,4x2 ,16 ,99 ,4 ,B4 ,T2 , ,Truck.vacc,RigidTrailer ,RigidSolo ,20/30 ,45/55 ,50/2 , ,14000 ,4400 ,- ,4400 ,- ,- ,- ,- ,- ,- +1 ,Tractor ,4x2 ,16 ,99 ,5 , , ,ST1 ,Truck.vacc,TractorSemitrailer ,TractorSemitrailer ,20/25 ,25/25 ,55/3 ,50/3 ,19300 ,12900 ,- ,- ,- ,- ,- ,- ,- ,- +0 ,RigidTruck ,4x4 ,7.5 ,16 ,6 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,- ,- ,??? ,??? ,- ,- ,- ,- ,- +0 ,RigidTruck ,4x4 ,16 ,99 ,7 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- +0 ,Tractor ,4x4 ,16 ,99 ,8 , , , ,Truck.vacc, ,TractorSemitrailer , , , , ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- +1 ,RigidTruck ,6x2 ,0 ,99 ,9 ,B5 ,T2 , ,Truck.vacc,RigidTrailer ,RigidSolo ,20/30/15 ,35/40/25 ,35/2 , ,19300 ,7100 ,- ,7100 ,- ,- ,- ,- ,- ,- +1 ,Tractor ,6x2 ,0 ,99 ,10 , , ,ST1 ,Truck.vacc,TractorSemitrailer ,TractorSemitrailer ,15/10/20 ,20/10/20 ,55/2 ,50/2 ,19300 ,12900 ,- ,- ,- ,- ,- ,- ,- ,- +0 ,RigidTruck ,6x4 ,0 ,99 ,11 , , , ,Truck.vacc, ,RigidSolo , ,35/35/30 , , ,- ,- ,- ,- ,7100 ,- ,- ,- ,- ,- +0 ,Tractor ,6x4 ,0 ,99 ,12 , , , ,Truck.vacc, ,TractorSemitrailer , ,20/15/15 , ,50/2 ,- ,- ,- ,- ,12900 ,- ,- ,- ,- ,- +0 ,RigidTruck ,6x6 ,0 ,99 ,13 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- +0 ,Tractor ,6x6 ,0 ,99 ,14 , , , ,Truck.vacc, ,TractorSemitrailer , , , , ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- +0 ,RigidTruck ,8x2 ,0 ,99 ,15 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- +0 ,RigidTruck ,8x4 ,0 ,99 ,16 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,- ,- ,- ,12900 ,- ,- ,- ,- ,- +0 ,RigidTruck ,8x6 ,0 ,99 ,17 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- +0 ,RigidTruck ,8x8 ,0 ,99 ,17 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- +0 ,CityBus ,4x2 ,0 ,18 ,B1 , , , , , ,CoachBus , , , , ,- ,- ,- ,- ,- ,??? ,??? ,??? ,- ,- +0 ,InterurbanBus ,4x2 ,0 ,18 ,B2 , , , , , ,CoachBus , , , , ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- +0 ,Coach ,4x2 ,0 ,18 ,B3 , , , , , ,CoachBus , , , , ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? +0 ,CityBus ,6x2 ,18 ,99 ,B4 , , , , , ,CoachBus , , , , ,- ,- ,- ,- ,- ,??? ,??? ,??? ,- ,- +0 ,InterurbanBus ,6x2 ,18 ,99 ,B5 , , , , , ,CoachBus , , , , ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- +0 ,Coach ,6x2 ,18 ,99 ,B6 , , , , , ,CoachBus , , , , ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? \ No newline at end of file diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index f65cc32f28d419b886349b979663ecb44b08a48d..3de550b75edc48eb09dcb5b1e3027c889cfb9134 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -135,10 +135,12 @@ <Compile Include="Models\Declaration\Fan.cs" /> <Compile Include="Models\Declaration\HVAC.cs" /> <Compile Include="Models\Declaration\LACDecisionFactor.cs" /> + <Compile Include="Models\Declaration\Payloads.cs" /> <Compile Include="Models\Declaration\PneumaticSystem.cs" /> <Compile Include="Models\Declaration\PT1.cs" /> <Compile Include="Models\Declaration\Rims.cs" /> <Compile Include="Models\Declaration\Segments.cs" /> + <Compile Include="Models\Declaration\StandardWeights.cs" /> <Compile Include="Models\Declaration\SteeringPump.cs" /> <Compile Include="Models\Declaration\TorqueConverter.cs" /> <Compile Include="Models\Declaration\VehicleClass.cs" /> @@ -270,7 +272,6 @@ <Compile Include="Models\Simulation\IVehicleContainer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Utils\SwitchExtension.cs" /> - <Compile Include="Utils\Validation.cs" /> <Compile Include="Utils\VectoCSVFile.cs" /> <Compile Include="Utils\DelaunayMap.cs" /> </ItemGroup> @@ -316,6 +317,8 @@ </None> <EmbeddedResource Include="Resources\Declaration\LAC-DF-Vdrop.csv" /> <EmbeddedResource Include="Resources\Declaration\LAC-DF-Vtarget.csv" /> + <EmbeddedResource Include="Resources\Declaration\Body_Trailers_Weights.csv" /> + <EmbeddedResource Include="Resources\Declaration\Payloads.csv" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Resources\Declaration\Report\4x2r.png" /> diff --git a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs index 9375c4e2fd51db5785e8745b64cd3f506c597325..700b7477fe2d0ff8bcd91c14dae19861d15b79d5 100644 --- a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs @@ -64,14 +64,16 @@ namespace TUGraz.VectoCore.Tests.FileIO Assert.AreEqual(ExecutionMode.Declaration, runData.ExecutionMode); Assert.AreEqual(Path.GetFileNameWithoutExtension(DeclarationJob), runData.JobName); - Assert.AreEqual(5850, runData.VehicleData.CurbWeight.Value()); - Assert.AreEqual(1900, runData.VehicleData.CurbWeigthExtra.Value()); // taken from segmentation table - Assert.AreEqual(11900, runData.VehicleData.GrossVehicleMassRating.Value()); + + // curbweight + bodyCurbWeight + trailerCurbWeight (for Long Haul only) + Assert.AreEqual(5850 + 1900 + 3400, runData.VehicleData.CurbWeight.Value()); + + Assert.AreEqual(11900, runData.VehicleData.GrossVehicleWeight.Value()); Assert.AreEqual(AxleConfiguration.AxleConfig_4x2, runData.VehicleData.AxleConfiguration); Assert.AreEqual(0.4069297458, runData.VehicleData.DynamicTyreRadius.Value(), Tolerance); Assert.AreEqual(VehicleClass.Class2, runData.VehicleData.VehicleClass); - Assert.AreEqual(2, runData.VehicleData.AxleData.Count); + Assert.AreEqual(3, runData.VehicleData.AxleData.Count); Assert.AreEqual(6, runData.VehicleData.AxleData[0].Inertia.Value(), Tolerance); Assert.AreEqual(true, runData.DriverData.LookAheadCoasting.Enabled); @@ -116,9 +118,6 @@ namespace TUGraz.VectoCore.Tests.FileIO runData.GearboxData.Gears[1].ShiftPolygon.Upshift[i].AngularSpeed.Value(), Tolerance); Assert.AreEqual(upshiftTorque[i], runData.GearboxData.Gears[1].ShiftPolygon.Upshift[i].Torque.Value(), Tolerance); } - //Assert.AreEqual(); - - //Assert.AreEqual(, runData.DriverData.LookAheadCoasting.); } } diff --git a/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs b/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs index 8c63f9f9a13f3752d6921cdac56e562598665cf9..de6b768412dc33f7d00c80e6a30471301610c840 100644 --- a/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs @@ -33,7 +33,9 @@ using System.Data; using System.IO; using System.Linq; using NUnit.Framework; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.FileIO @@ -92,6 +94,23 @@ namespace TUGraz.VectoCore.Tests.FileIO Assert.IsTrue(new[] { "4", "5", "6" }.SequenceEqual(table.Rows[1].ItemArray)); } + [Test] + public void VectoCSVFile_ReadStream_No_Content() + { + var stream = "a,b,c".GetStream(); + var table = VectoCSVFile.ReadStream(stream); + + Assert.AreEqual(3, table.Columns.Count); + Assert.IsTrue(new[] { "a", "b", "c" }.SequenceEqual(table.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); + Assert.AreEqual(0, table.Rows.Count); + } + + [Test] + public void VectoCSVFile_ReadStream_Empty() + { + AssertHelper.Exception<VectoException>(() => VectoCSVFile.ReadStream("".GetStream())); + } + [Test] public void VectoCSVFile_ReadStream_Comments() { @@ -138,7 +157,7 @@ namespace TUGraz.VectoCore.Tests.FileIO table.Columns.Add("a"); table.Columns.Add("b"); var row = table.NewRow(); - row.ItemArray = new[] { "1", "2" }; + row.ItemArray = new object[] { "1", "2" }; table.Rows.Add(row); using (var stream = new MemoryStream()) { diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index 53461620830f48455b4a7003a8739d91f4f2d625..9bb267469f46dcd4217980d2537821ef55deea85 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -133,7 +133,10 @@ namespace TUGraz.VectoCore.Tests.Integration StartAcceleration = 0.6.SI<MeterPerSquareSecond>(), StartTorqueReserve = 0.2, SkipGears = true, - TorqueReserve = 0.2 + TorqueReserve = 0.2, + UpshiftAfterDownshiftDelay = 10.SI<Second>(), + DownshiftAfterUpshiftDelay = 10.SI<Second>(), + UpshiftMinAcceleration = 0.1.SI<MeterPerSquareSecond>() }; } @@ -181,7 +184,6 @@ namespace TUGraz.VectoCore.Tests.Integration new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), CrossWindCorrectionMode.NoCorrection), CurbWeight = 15700.SI<Kilogram>(), - CurbWeigthExtra = 0.SI<Kilogram>(), Loading = loading, DynamicTyreRadius = 0.52.SI<Meter>(), AxleData = axles, diff --git a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs index 760a8a04b0c0b570f4385cc7e14d719e68911f0e..a724ba594946cec8525a7f6e2c3193ff4f85836a 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs @@ -71,7 +71,7 @@ namespace TUGraz.VectoCore.Tests.Integration { var fileWriter = new FileOutputWriter(modFileName); var modData = new ModalDataContainer(modFileName, fileWriter, ExecutionMode.Engineering); - var container = new VehicleContainer(ExecutionMode.Engineering, modData, null) { + var container = new VehicleContainer(ExecutionMode.Engineering, modData) { RunData = new VectoRunData { JobName = modFileName, Cycle = cycleData } }; @@ -120,11 +120,9 @@ namespace TUGraz.VectoCore.Tests.Integration Tuple.Create((uint)i, new GearData { FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), - LossMap = (ratio != 1.0) - ? TransmissionLossMap.ReadFromFile(GearboxIndirectLoss, ratio, - string.Format("Gear {0}", i)) - : TransmissionLossMap.ReadFromFile(GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + LossMap = ratio.IsEqual(1) + ? TransmissionLossMap.ReadFromFile(GearboxIndirectLoss, ratio, string.Format("Gear {0}", i)) + : TransmissionLossMap.ReadFromFile(GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) @@ -136,7 +134,10 @@ namespace TUGraz.VectoCore.Tests.Integration StartAcceleration = 0.6.SI<MeterPerSquareSecond>(), StartTorqueReserve = 0.2, SkipGears = true, - TorqueReserve = 0.2 + TorqueReserve = 0.2, + UpshiftAfterDownshiftDelay = 10.SI<Second>(), + DownshiftAfterUpshiftDelay = 10.SI<Second>(), + UpshiftMinAcceleration = 0.1.SI<MeterPerSquareSecond>() }; } @@ -184,7 +185,6 @@ namespace TUGraz.VectoCore.Tests.Integration new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), CrossWindCorrectionMode.NoCorrection), CurbWeight = 15700.SI<Kilogram>(), - CurbWeigthExtra = 0.SI<Kilogram>(), Loading = loading, DynamicTyreRadius = 0.52.SI<Meter>(), AxleData = axles, diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index f3ced4885b94dabe13f729c83692f8c45356f349..38e3a83dff12504d009571aa89907ea4cfdbc8bf 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -317,7 +317,10 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns StartSpeed = 2.SI<MeterPerSecond>(), StartAcceleration = 0.6.SI<MeterPerSquareSecond>(), StartTorqueReserve = 0.2, - TorqueReserve = 0.2 + TorqueReserve = 0.2, + DownshiftAfterUpshiftDelay = 10.SI<Second>(), + UpshiftAfterDownshiftDelay = 10.SI<Second>(), + UpshiftMinAcceleration = 0.1.SI<MeterPerSquareSecond>() }; } @@ -352,7 +355,10 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns StartSpeed = 2.SI<MeterPerSecond>(), StartAcceleration = 0.6.SI<MeterPerSquareSecond>(), StartTorqueReserve = 0.2, - TorqueReserve = 0.2 + TorqueReserve = 0.2, + DownshiftAfterUpshiftDelay = 10.SI<Second>(), + UpshiftAfterDownshiftDelay = 10.SI<Second>(), + UpshiftMinAcceleration = 0.1.SI<MeterPerSquareSecond>() }; } @@ -387,7 +393,6 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), CrossWindCorrectionMode.NoCorrection), CurbWeight = 15700.SI<Kilogram>(), - CurbWeigthExtra = 0.SI<Kilogram>(), Loading = loading, DynamicTyreRadius = 0.52.SI<Meter>(), AxleData = axles, diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs index 1cbd26fbef50660e60cb50d77403655d5d909e75..715e9716c38b3a6b9b562eb2b1fd914129d972e1 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs @@ -99,8 +99,8 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns Assert.IsInstanceOfType(response, typeof(ResponseSuccess)); -// time [s] , dist [m] , v_act [km/h] , v_targ [km/h] , acc [m/s²] , grad [%] , n_eng_avg [1/min] , T_eng_fcmap [Nm] , Tq_clutch [Nm] , Tq_full [Nm] , Tq_drag [Nm] , P_eng_out [kW] , P_eng_full [kW] , P_eng_drag [kW] , P_clutch_out [kW] , Pa Eng [kW] , P_aux [kW] , Gear [-] , Ploss GB [kW] , Ploss Diff [kW] , Ploss Retarder [kW] , Pa GB [kW] , Pa Veh [kW] , P_roll [kW] , P_air [kW] , P_slope [kW] , P_wheel_in [kW] , P_brake_loss [kW] , FC-Map [g/h] , FC-AUXc [g/h] , FC-WHTCc [g/h] -// 1.5 , 5 , 18 , 18 , 0 , 2.842372 , 964.1117 , 323.7562 , 323.7562 , 2208.664 , -158.0261 , 32.68693 , 222.9902 , -15.95456 , 32.68693 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 5.965827 , 0.2423075 , 26.47879 , 32.68693 , 0 , 7574.113 , - , - + // time [s] , dist [m] , v_act [km/h] , v_targ [km/h] , acc [m/s²] , grad [%] , n_eng_avg [1/min] , T_eng_fcmap [Nm] , Tq_clutch [Nm] , Tq_full [Nm] , Tq_drag [Nm] , P_eng_out [kW] , P_eng_full [kW] , P_eng_drag [kW] , P_clutch_out [kW] , Pa Eng [kW] , P_aux [kW] , Gear [-] , Ploss GB [kW] , Ploss Diff [kW] , Ploss Retarder [kW] , Pa GB [kW] , Pa Veh [kW] , P_roll [kW] , P_air [kW] , P_slope [kW] , P_wheel_in [kW] , P_brake_loss [kW] , FC-Map [g/h] , FC-AUXc [g/h] , FC-WHTCc [g/h] + // 1.5 , 5 , 18 , 18 , 0 , 2.842372 , 964.1117 , 323.7562 , 323.7562 , 2208.664 , -158.0261 , 32.68693 , 222.9902 , -15.95456 , 32.68693 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 5.965827 , 0.2423075 , 26.47879 , 32.68693 , 0 , 7574.113 , - , - AssertHelper.AreRelativeEqual(964.1117.RPMtoRad().Value(), vehicleContainer.Engine.EngineSpeed.Value()); Assert.AreEqual(2208.664, engine.PreviousState.StationaryFullLoadTorque.Value(), Tolerance); @@ -286,7 +286,6 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), CrossWindCorrectionMode.NoCorrection), CurbWeight = 15700.SI<Kilogram>(), - CurbWeigthExtra = 0.SI<Kilogram>(), Loading = loading, DynamicTyreRadius = 0.52.SI<Meter>(), AxleData = axles, diff --git a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs index 560415d448c8ab632f7ad0376d1ac202a7d28654..f292ba05c5d993abc9dfb159d9406da9ee5d2b69 100644 --- a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs @@ -152,6 +152,9 @@ namespace TUGraz.VectoCore.Tests.Integration StartTorqueReserve = 0.2, SkipGears = true, EarlyShiftUp = true, + UpshiftAfterDownshiftDelay = 10.SI<Second>(), + DownshiftAfterUpshiftDelay = 10.SI<Second>(), + UpshiftMinAcceleration = 0.1.SI<MeterPerSquareSecond>() }; } @@ -214,8 +217,7 @@ namespace TUGraz.VectoCore.Tests.Integration CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(6.2985.SI<SquareMeter>()), CrossWindCorrectionMode.NoCorrection), - CurbWeight = 7100.SI<Kilogram>(), - CurbWeigthExtra = massExtra, + CurbWeight = 7100.SI<Kilogram>() + massExtra, Loading = loading, DynamicTyreRadius = 0.4882675.SI<Meter>(), AxleData = axles, diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index 5613ee510e1f3e8f5d610829815fb867771519bd..c2587bcfd1831426641662c6eeabd93826f1977b 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -42,6 +42,7 @@ using TUGraz.VectoCore.InputData.Reader.DataObjectAdaper; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; using CrossWindCorrectionMode = TUGraz.VectoCommon.Models.CrossWindCorrectionMode; @@ -51,7 +52,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public class DeclarationDataTest { public const double Tolerance = 0.0001; - public readonly MissionType[] Missions = Enum.GetValues(typeof(MissionType)).Cast<MissionType>().ToArray(); + public readonly MissionType[] Missions = EnumHelper.GetValues<MissionType>().ToArray(); [Test, TestCase("285/70 R19.5", 7.9, 0.8943, "b"), @@ -149,7 +150,6 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration Assert.AreEqual(expected, lookup, 1e-8); } - [TestMethod] public void WHTCLookupTestRegionalDelivery() { @@ -164,7 +164,6 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration Assert.AreEqual(expected, lookup, 1e-8); } - [Test] public void AirDragTest() { @@ -270,7 +269,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration TestCase(150, 0.5, 1.0, 0.0), TestCase(150, 12.0, 1.0, -18674.133), // = (12-4.4)*(-16540.98- -2462.17)/(11-4.4)+ -2462.17 ] - public void DefaultTCTest(double referenceRpm, double nu, double mu, double torque) + public void DefaultTcTest(double referenceRpm, double nu, double mu, double torque) { var referenceSpeed = referenceRpm.SI<PerSecond>(); @@ -334,6 +333,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration } [Test, + TestCase("", + new[] { 618, 671, 516, 566, 1037, 0, 0, 0, 0, 0 }), TestCase("Crankshaft mounted - Electronically controlled visco clutch (Default)", new[] { 618, 671, 516, 566, 1037, 0, 0, 0, 0, 0 }), TestCase("Crankshaft mounted - Bimetallic controlled visco clutch", new[] { 818, 871, 676, 766, 1277, 0, 0, 0, 0, 0 }), @@ -352,20 +353,9 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration ] public void AuxFanTechTest(string technology, int[] expected) { - var fan = DeclarationData.Fan; - - var defaultExpected = new[] { 618, 671, 516, 566, 1037, 0, 0, 0, 0, 0 }; - for (var i = 0; i < Missions.Length; i++) { - // default tech - var defaultValue = fan.Lookup(Missions[i], ""); - Assert.AreEqual(defaultExpected[i], defaultValue.Value(), Tolerance); - - // all fan techs - foreach (var expect in expected) { - var value = fan.Lookup(Missions[i], technology); - Assert.AreEqual(expected[i], value.Value(), Tolerance); - } + var value = DeclarationData.Fan.Lookup(Missions[i], technology); + Assert.AreEqual(expected[i], value.Value(), Tolerance); } } @@ -531,10 +521,12 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration Assert.AreEqual(expectedClass, segment.VehicleClass); } - [Test] - public void SegmentTest() + /// <summary> + /// trailer in longhaul, always pc formula + /// </summary> + [TestCase] + public void Segment2Test() { - //mock vehicleData var vehicleData = new { VehicleCategory = VehicleCategory.RigidTruck, AxleConfiguration = AxleConfiguration.AxleConfig_4x2, @@ -552,60 +544,164 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration Assert.AreEqual(3, segment.Missions.Length); - var longHaulMission = segment.Missions[0]; - Assert.AreEqual(MissionType.LongHaul, longHaulMission.MissionType); + AssertMission(segment.Missions[0], vehicleData: vehicleData, missionType: MissionType.LongHaul, + cosswindCorrection: "RigidTrailer", axleWeightDistribution: new[] { 0.225, 0.325 }, + trailerAxleWeightDistribution: new[] { 0.45 }, bodyCurbWeight: 1900, trailerCurbWeight: 3400, + trailerType: TrailerType.T1, minLoad: 0, refLoad: 9813.2353, trailerGrossVehicleWeight: 10500, deltaCdA: 1.1, + maxLoad: 11250); + + AssertMission(segment.Missions[1], vehicleData: vehicleData, missionType: MissionType.RegionalDelivery, + cosswindCorrection: "RigidSolo", axleWeightDistribution: new[] { 0.45, 0.55 }, + trailerAxleWeightDistribution: new double[] { }, bodyCurbWeight: 1900, trailerCurbWeight: 0, + trailerType: TrailerType.None, minLoad: 0, refLoad: 2984.1176, trailerGrossVehicleWeight: 0, deltaCdA: 0, + maxLoad: 4150); + + AssertMission(segment.Missions[2], vehicleData: vehicleData, missionType: MissionType.UrbanDelivery, + cosswindCorrection: "RigidSolo", axleWeightDistribution: new[] { 0.45, 0.55 }, + trailerAxleWeightDistribution: new double[] { }, bodyCurbWeight: 1900, trailerCurbWeight: 0, + trailerType: TrailerType.None, minLoad: 0, refLoad: 2984.1176, trailerGrossVehicleWeight: 0, deltaCdA: 0, + maxLoad: 4150); + } - Assert.AreEqual("RigidSolo", longHaulMission.CrossWindCorrection); + /// <summary> + /// normal pc formula, no trailer + /// </summary> + [TestCase] + public void Segment3Test() + { + var vehicleData = new { + VehicleCategory = VehicleCategory.RigidTruck, + AxleConfiguration = AxleConfiguration.AxleConfig_4x2, + GrossVehicleMassRating = 14000.SI<Kilogram>(), + CurbWeight = 5850.SI<Kilogram>() + }; - Assert.IsTrue(new[] { 0.4, 0.6 }.SequenceEqual(longHaulMission.AxleWeightDistribution)); - Assert.IsTrue(new double[] { }.SequenceEqual(longHaulMission.TrailerAxleWeightDistribution)); - Assert.AreEqual(1900.SI<Kilogram>(), longHaulMission.MassExtra); + var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight); - Assert.IsNotNull(longHaulMission.CycleFile); - Assert.IsTrue(!string.IsNullOrEmpty(new StreamReader(longHaulMission.CycleFile).ReadLine())); + Assert.AreEqual(VehicleClass.Class3, segment.VehicleClass); - Assert.AreEqual(0.SI<Kilogram>(), longHaulMission.MinLoad); - Assert.AreEqual(4150, longHaulMission.RefLoad.Value()); - Assert.AreEqual(vehicleData.GrossVehicleMassRating - longHaulMission.MassExtra - vehicleData.CurbWeight, - longHaulMission.MaxLoad); + Assert.AreEqual(2, segment.Missions.Length); - var regionalDeliveryMission = segment.Missions[1]; - Assert.AreEqual(MissionType.RegionalDelivery, regionalDeliveryMission.MissionType); + AssertMission(segment.Missions[0], vehicleData: vehicleData, missionType: MissionType.RegionalDelivery, + cosswindCorrection: "RigidSolo", axleWeightDistribution: new[] { 0.4, 0.6 }, + trailerAxleWeightDistribution: new double[] { }, bodyCurbWeight: 2000, trailerCurbWeight: 0, + trailerType: TrailerType.None, minLoad: 0, refLoad: 3811.7647, trailerGrossVehicleWeight: 0, deltaCdA: 0, + maxLoad: 6150); - Assert.AreEqual("RigidSolo", regionalDeliveryMission.CrossWindCorrection); + AssertMission(segment.Missions[1], vehicleData: vehicleData, missionType: MissionType.UrbanDelivery, + cosswindCorrection: "RigidSolo", axleWeightDistribution: new[] { 0.4, 0.6 }, + trailerAxleWeightDistribution: new double[] { }, bodyCurbWeight: 2000, trailerCurbWeight: 0, + trailerType: TrailerType.None, minLoad: 0, refLoad: 3811.7647, trailerGrossVehicleWeight: 0, deltaCdA: 0, + maxLoad: 6150); + } - Assert.IsTrue(new[] { 0.45, 0.55 }.SequenceEqual(regionalDeliveryMission.AxleWeightDistribution)); - Assert.IsTrue(new double[] { }.SequenceEqual(regionalDeliveryMission.TrailerAxleWeightDistribution)); - Assert.AreEqual(1900.SI<Kilogram>(), regionalDeliveryMission.MassExtra); + /// <summary> + /// fixed reference weight, trailer only in longhaul + /// </summary> + [TestCase] + public void Segment4Test() + { + var vehicleData = new { + VehicleCategory = VehicleCategory.RigidTruck, + AxleConfiguration = AxleConfiguration.AxleConfig_4x2, + GrossVehicleMassRating = 18000.SI<Kilogram>(), + CurbWeight = 7500.SI<Kilogram>() + }; - Assert.IsNotNull(regionalDeliveryMission.CycleFile); - Assert.IsTrue(!string.IsNullOrEmpty(new StreamReader(regionalDeliveryMission.CycleFile).ReadLine())); + var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight); + + Assert.AreEqual(VehicleClass.Class4, segment.VehicleClass); + + var data = AccelerationCurveData.ReadFromStream(segment.AccelerationFile); + TestAcceleration(data); + + Assert.AreEqual(3, segment.Missions.Length); + + AssertMission(segment.Missions[0], vehicleData: vehicleData, missionType: MissionType.LongHaul, + cosswindCorrection: "RigidTrailer", axleWeightDistribution: new[] { 0.2, 0.3 }, + trailerAxleWeightDistribution: new[] { 0.25, 0.25 }, bodyCurbWeight: 2100, trailerCurbWeight: 5400, + trailerType: TrailerType.T2, minLoad: 0, refLoad: 14000, trailerGrossVehicleWeight: 18000, deltaCdA: 0.6, + maxLoad: 21000); + + AssertMission(segment.Missions[1], vehicleData: vehicleData, missionType: MissionType.RegionalDelivery, + cosswindCorrection: "RigidSolo", axleWeightDistribution: new[] { 0.45, 0.55 }, + trailerAxleWeightDistribution: new double[] { }, bodyCurbWeight: 2100, trailerCurbWeight: 0, + trailerType: TrailerType.None, minLoad: 0, refLoad: 4400, trailerGrossVehicleWeight: 0, deltaCdA: 0, maxLoad: 8400); + + AssertMission(segment.Missions[2], vehicleData: vehicleData, missionType: MissionType.MunicipalUtility, + cosswindCorrection: "RigidSolo", axleWeightDistribution: new[] { 0.45, 0.55 }, + trailerAxleWeightDistribution: new double[] { }, bodyCurbWeight: 2100, trailerCurbWeight: 0, + trailerType: TrailerType.None, minLoad: 0, refLoad: 4400, trailerGrossVehicleWeight: 0, deltaCdA: 0, maxLoad: 8400); + } + + + /// <summary> + /// Segment 5: fixed reference weight, trailer always used + /// </summary> + [TestCase] + public void Segment5Test() + { + var vehicleData = new { + VehicleCategory = VehicleCategory.Tractor, + AxleConfiguration = AxleConfiguration.AxleConfig_4x2, + GrossVehicleMassRating = 18000.SI<Kilogram>(), + CurbWeight = 7500.SI<Kilogram>() + }; + + var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight); - Assert.AreEqual(0.SI<Kilogram>(), regionalDeliveryMission.MinLoad); - Assert.AreEqual(0.3941 * vehicleData.GrossVehicleMassRating - 1705.9.SI<Kilogram>(), - regionalDeliveryMission.RefLoad); - Assert.AreEqual( - vehicleData.GrossVehicleMassRating - regionalDeliveryMission.MassExtra - vehicleData.CurbWeight, - regionalDeliveryMission.MaxLoad); + Assert.AreEqual(VehicleClass.Class5, segment.VehicleClass); - var urbanDeliveryMission = segment.Missions[2]; - Assert.AreEqual(MissionType.UrbanDelivery, urbanDeliveryMission.MissionType); + var data = AccelerationCurveData.ReadFromStream(segment.AccelerationFile); + TestAcceleration(data); - Assert.AreEqual("RigidSolo", urbanDeliveryMission.CrossWindCorrection); + Assert.AreEqual(2, segment.Missions.Length); - Assert.IsTrue(new[] { 0.45, 0.55 }.SequenceEqual(urbanDeliveryMission.AxleWeightDistribution)); - Assert.IsTrue(new double[] { }.SequenceEqual(urbanDeliveryMission.TrailerAxleWeightDistribution)); - Assert.AreEqual(1900.SI<Kilogram>(), urbanDeliveryMission.MassExtra); + AssertMission(segment.Missions[0], vehicleData: vehicleData, missionType: MissionType.LongHaul, + cosswindCorrection: "TractorSemitrailer", axleWeightDistribution: new[] { 0.2, 0.25 }, + trailerAxleWeightDistribution: (0.55 / 3).Repeat(3).ToArray(), bodyCurbWeight: 0, trailerCurbWeight: 7500, + trailerType: TrailerType.None, minLoad: 0, refLoad: 19300, trailerGrossVehicleWeight: 24000, deltaCdA: 0, + maxLoad: 25000); - Assert.IsNotNull(urbanDeliveryMission.CycleFile); - Assert.IsTrue(!string.IsNullOrEmpty(new StreamReader(urbanDeliveryMission.CycleFile).ReadLine())); + AssertMission(segment.Missions[1], vehicleData: vehicleData, missionType: MissionType.RegionalDelivery, + cosswindCorrection: "TractorSemitrailer", axleWeightDistribution: new[] { 0.25, 0.25 }, + trailerAxleWeightDistribution: (0.5 / 3).Repeat(3).ToArray(), bodyCurbWeight: 0, trailerCurbWeight: 7500, + trailerType: TrailerType.None, minLoad: 0, refLoad: 12900, trailerGrossVehicleWeight: 24000, deltaCdA: 0, + maxLoad: 25000); + } - Assert.AreEqual(0.SI<Kilogram>(), urbanDeliveryMission.MinLoad); - Assert.AreEqual(0.3941 * vehicleData.GrossVehicleMassRating - 1705.9.SI<Kilogram>(), - urbanDeliveryMission.RefLoad); - Assert.AreEqual( - vehicleData.GrossVehicleMassRating - urbanDeliveryMission.MassExtra - vehicleData.CurbWeight, - urbanDeliveryMission.MaxLoad); + [Test] + public static void AssertMission(Mission m, dynamic vehicleData, MissionType missionType, string cosswindCorrection, + double[] axleWeightDistribution, double[] trailerAxleWeightDistribution, double bodyCurbWeight, + double trailerCurbWeight, TrailerType trailerType, double minLoad, double refLoad, double maxLoad, + double trailerGrossVehicleWeight, + double deltaCdA) + { + Assert.AreEqual(missionType, m.MissionType); + Assert.AreEqual(cosswindCorrection, m.CrossWindCorrection); + Assert.IsTrue(axleWeightDistribution.SequenceEqual(m.AxleWeightDistribution), + "Axle distribution not equal.\nexpected: {0}\nactual: {1}", string.Join(",", axleWeightDistribution), + string.Join(",", m.AxleWeightDistribution)); + Assert.IsTrue(trailerAxleWeightDistribution.SequenceEqual(m.TrailerAxleWeightDistribution), + "Trailer axle distribution not equal.\nexpected: {0}\nactual: {1}", string.Join(",", trailerAxleWeightDistribution), + string.Join(",", m.TrailerAxleWeightDistribution)); + Assert.AreEqual(bodyCurbWeight.SI<Kilogram>(), m.BodyCurbWeight); + Assert.AreEqual(trailerCurbWeight.SI<Kilogram>(), m.TrailerCurbWeight); + Assert.AreEqual(trailerType, m.TrailerType); + + Assert.IsNotNull(m.CycleFile); + Assert.IsTrue(!string.IsNullOrEmpty(new StreamReader(m.CycleFile).ReadLine())); + Assert.AreEqual(minLoad.SI<Kilogram>(), m.MinLoad); + AssertHelper.AreRelativeEqual(refLoad, m.RefLoad); + Assert.AreEqual(maxLoad.SI<Kilogram>(), m.MaxLoad); + Assert.AreEqual(trailerGrossVehicleWeight.SI<Kilogram>(), m.TrailerGrossVehicleWeight); + Assert.AreEqual(VectoMath.Min(vehicleData.GrossVehicleMassRating + m.TrailerGrossVehicleWeight, 40000.SI<Kilogram>()) + - m.BodyCurbWeight - m.TrailerCurbWeight - vehicleData.CurbWeight, + m.MaxLoad); + Assert.AreEqual(deltaCdA.SI<SquareMeter>(), m.DeltaCdA); } public void EqualAcceleration(AccelerationCurveData data, double velocity, double acceleration, diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs index 8864a78dbff2b80acb469769e483f89490b71dec..ef309e5375f01e4484a32886b0d506da0c13d5e4 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs @@ -246,7 +246,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var targetVelocity = 5.SI<MeterPerSecond>(); -// var response = driver.OutPort().Request(absTime, ds, targetVelocity, gradient); + // var response = driver.OutPort().Request(absTime, ds, targetVelocity, gradient); var accelerations = new[] { 1.01570922, 1.384540943, 1.364944972, 1.350793466, 1.331848649, 1.314995215, 1.2999934, @@ -314,7 +314,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var targetVelocity = 0.SI<MeterPerSecond>(); -// var response = driver.OutPort().Request(absTime, ds, targetVelocity, gradient); + // var response = driver.OutPort().Request(absTime, ds, targetVelocity, gradient); var accelerations = new[] { -0.68799597, -0.690581291, -0.693253225, -0.696020324, -0.698892653, -0.701882183, -0.695020765, @@ -392,7 +392,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), CrossWindCorrectionMode.NoCorrection), CurbWeight = 15700.SI<Kilogram>(), - CurbWeigthExtra = 0.SI<Kilogram>(), Loading = loading, DynamicTyreRadius = 0.52.SI<Meter>(), AxleData = axles, diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index 172df459cac38cf5b429548c38a0ed8165935db1..1d7d580504d074de9e712a3c7495cd4fa9c6073b 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -456,7 +456,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent DriverBehavior = DrivingBehavior.Driving, Altitude = 0.SI<Meter>(), VehicleMass = 10000.SI<Kilogram>(), - ReducedMassWheels = 100.SI<Kilogram>() + ReducedMassWheels = 100.SI<Kilogram>(), + TotalMass = 19000.SI<Kilogram>() }; var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile); var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); diff --git a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs index bd31845be091b7d631597f36d1d062dd918c45fa..0ff2688b69daab7cc9f30c5be5b0ae4ef523a841 100644 --- a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Data; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -110,7 +111,8 @@ namespace TUGraz.VectoCore.Tests.Reports var pRetIn = (Watt)row[(int)ModalResultField.P_retarder_in]; var pGbxInertia = (Watt)row[(int)ModalResultField.P_gbx_inertia]; var pEngInertia = (Watt)row[(int)ModalResultField.P_eng_inertia]; - var pAux = (Watt)row[(int)ModalResultField.P_aux]; + var pAux = + (Watt)(row[(int)ModalResultField.P_aux] != DBNull.Value ? row[(int)ModalResultField.P_aux] : 0.SI<Watt>()); var pBrakeLoss = (Watt)row[(int)ModalResultField.P_brake_loss]; var pBrakeIn = (Watt)row[(int)ModalResultField.P_brake_in]; var pClutchLoss = (Watt)row[(int)ModalResultField.P_clutch_loss]; @@ -130,7 +132,6 @@ namespace TUGraz.VectoCore.Tests.Reports Assert.AreEqual(pRetIn.Value(), (pAxleIn + pLossRet).Value(), 1E-3, "time: {0} distance: {1}", time, distance); - Assert.AreEqual(pGbxIn.Value(), pClutchOut.Value(), 1E-3, "time: {0} distance: {1}", time, distance); Assert.AreEqual(pEngOut.Value(), (pClutchOut + pClutchLoss).Value(), 1E-3, diff --git a/VectoCore/VectoCoreTest/TestData/Pwheel/axle_losses_r390_80_serie_1306.vtlm b/VectoCore/VectoCoreTest/TestData/Pwheel/axle_losses_r390_80_serie_1306.vtlm index 0155c2b128ee397da9f097e09636c901fde2766c..99f0f1801018172f13351e8e721ba9f9fd266eef 100644 --- a/VectoCore/VectoCoreTest/TestData/Pwheel/axle_losses_r390_80_serie_1306.vtlm +++ b/VectoCore/VectoCoreTest/TestData/Pwheel/axle_losses_r390_80_serie_1306.vtlm @@ -99,8 +99,8 @@ Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm],Eff [-] 4991.127273,0.000000,18.351630 4991.127273,5000.000000,77.878107 4991.127273,60000.000000,725.695092 -5253.818182,-60000.000000,726.310729 -5253.818182,-5000.000000,78.559121 -5253.818182,0.000000,18.959334 -5253.818182,5000.000000,78.559121 -5253.818182,60000.000000,726.310729 +5000,-60000.000000,726.310729 +5000,-5000.000000,78.559121 +5000,0.000000,18.959334 +5000,5000.000000,78.559121 +5000,60000.000000,726.310729