diff --git a/VECTO.sln.DotSettings b/VECTO.sln.DotSettings index 66ef45c5df209e9a60ecfc57c4ae31f93a21d13a..4f0f609125e85e8f93b0ca187d92c473514fb999 100644 --- a/VECTO.sln.DotSettings +++ b/VECTO.sln.DotSettings @@ -23,8 +23,10 @@ <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AMT/@EntryIndexedValue">AMT</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AT/@EntryIndexedValue">AT</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CSV/@EntryIndexedValue">CSV</s:String> + <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HVAC/@EntryIndexedValue">HVAC</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MT/@EntryIndexedValue">MT</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PT/@EntryIndexedValue">PT</s:String> + <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PTO/@EntryIndexedValue">PTO</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RP/@EntryIndexedValue">RP</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SI/@EntryIndexedValue">SI</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WHTC/@EntryIndexedValue">WHTC</s:String> @@ -58,6 +60,8 @@ <s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FFIELD/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String> <s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FMETHOD/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String> <s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FTYPE_005FPARAMETER/@EntryIndexedValue"><Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /></s:String> + <s:String x:Key="/Default/CodeStyle/Naming/VBNaming/Abbreviations/=JSON/@EntryIndexedValue">JSON</s:String> + <s:String x:Key="/Default/CodeStyle/Naming/VBNaming/Abbreviations/=WHTC/@EntryIndexedValue">WHTC</s:String> <s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FFIELD/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String> <s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FHTML_005FCONTROL/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String> <s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FTAG_005FNAME/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String> diff --git a/VECTO/AdvancedAuxiliariesModule.vb b/VECTO/AdvancedAuxiliariesModule.vb index 0d2bcfc212251226e1ce122c6571b3dfa4d1ef0c..c56ab64f152a8f25212f963f75a0bbb2aa35480a 100644 --- a/VECTO/AdvancedAuxiliariesModule.vb +++ b/VECTO/AdvancedAuxiliariesModule.vb @@ -11,7 +11,7 @@ Module AdvancedAuxiliariesModule ByVal messageType As AdvancedAuxiliaryMessageType) Handles advancedAuxModel.AuxiliaryEvent - WorkerMsg(messageType, message, "Advanced Auxiliaries") + WorkerMsg(CType(messageType, MessageType), message, "Advanced Auxiliaries") End Sub 'AA-TB diff --git a/VECTO/ApplicationEvents.vb b/VECTO/ApplicationEvents.vb index a701ab081213c977dee07d4b15c684dd33f4d978..fd08ae6d9faa17780a7c47fe5eaf0fee7b982f0f 100644 --- a/VECTO/ApplicationEvents.vb +++ b/VECTO/ApplicationEvents.vb @@ -9,6 +9,8 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.IO +Imports System.Text Namespace My ' The following events are available for MyApplication: @@ -18,14 +20,14 @@ Namespace My ' UnhandledException: Raised if the application encounters an unhandled exception. ' StartupNextInstance: Raised when launching a single-instance application, and one is already active. ' NetworkAvailabilityChanged: Occurs when connecting or disconnecting to the network. + ' ReSharper disable once ClassNeverInstantiated.Global Partial Friend Class MyApplication 'Initialization - Private Sub MyApplication_Startup(ByVal sender As Object, - ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup + Private Sub MyApplication_Startup(sender As Object, e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) _ + Handles Me.Startup Dim s As String - Dim i As Int16 - Dim file As CsvFile + Dim i As Integer 'Paths MyAppPath = Application.Info.DirectoryPath & "\" @@ -34,38 +36,38 @@ Namespace My FileHistoryPath = MyConfPath & "FileHistory\" 'Log - LogFile = New cLogFile + LogFile = New FileLogger If Not LogFile.StartLog() Then MsgBox("Error! Can't access log file. Application folder needs read/write permissions!") e.Cancel = True End If 'If folder does not exist: Create! - If Not IO.Directory.Exists(MyConfPath) Then + If Not Directory.Exists(MyConfPath) Then Try - IO.Directory.CreateDirectory(MyConfPath) + Directory.CreateDirectory(MyConfPath) Catch ex As Exception MsgBox("Failed to create directory '" & MyConfPath & "'!", MsgBoxStyle.Critical) LogFile.WriteToLog(MessageType.Err, "Failed to create directory '" & MyConfPath & "'!") e.Cancel = True End Try - IO.File.Create(MyConfPath & "joblist.txt") - IO.File.Create(MyConfPath & "cyclelist.txt") + File.Create(MyConfPath & "joblist.txt") + File.Create(MyConfPath & "cyclelist.txt") End If - If Not IO.Directory.Exists(FileHistoryPath) Then + If Not Directory.Exists(FileHistoryPath) Then Try - IO.Directory.CreateDirectory(FileHistoryPath) + Directory.CreateDirectory(FileHistoryPath) 'Preconfigure Directories.txt Try - s = IO.Directory.GetParent(Application.Info.DirectoryPath).ToString & "\" + s = Directory.GetParent(Application.Info.DirectoryPath).ToString & "\" Catch ex As Exception s = MyAppPath End Try Try - file = New CsvFile - file.OpenWrite(FileHistoryPath & "Directories.txt") + Dim file As StreamWriter = Computer.FileSystem.OpenTextFileWriter(FileHistoryPath & "Directories.txt", True, + Encoding.UTF8) file.WriteLine(s) For i = 2 To 20 file.WriteLine(" ") @@ -89,13 +91,12 @@ Namespace My Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US") 'MSGtoForm(8, "Set CurrentCulture to 'en-US'", True) Catch ex As Exception - GUImsg(MessageType.Err, + GUIMsg(MessageType.Err, "Failed to set Application Regional Settings to 'en-US'! Check system decimal- and group- separators!") End Try End If 'Initialise Classes - sKey = New csKey JobFileList = New List(Of String) 'DEV = New cDEV diff --git a/VECTO/Configuration.vb b/VECTO/Configuration.vb index 37a05ba47408625c94171e3ba0fab2408c595e27..867e09ff04b597a999d119b3926c76d3fb489210 100644 --- a/VECTO/Configuration.vb +++ b/VECTO/Configuration.vb @@ -10,19 +10,21 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic Imports System.IO +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq +Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.Models.Declaration Public Class Configuration Public FilePath As String - Public GnUfromCycle As Boolean Public ModOut As Boolean Public Mod1Hz As Boolean - Public LogSize As Single - Public AirDensity As Single + Public LogSize As Double + Public AirDensity As Double Public OpenCmd As String Public OpenCmdName As String - Public FuelDens As Single - Public CO2perFC As Single + Public FuelDens As Double + Public Co2PerFc As Double Public FirstRun As Boolean Public DeclMode As Boolean @@ -36,11 +38,9 @@ Public Class Configuration AirDensity = DeclarationData.Physics.AirDensity.Value() ' cDeclaration.AirDensity FuelDens = DeclarationData.Physics.FuelDensity.Value() ' cDeclaration.FuelDens CO2perFC = DeclarationData.Physics.CO2PerFuelWeight ' cDeclaration.CO2perFC - GnUfromCycle = False End Sub Public Sub SetDefault() - GnUfromCycle = True ModOut = True Mod1Hz = False LogSize = 2 @@ -60,57 +60,53 @@ Public Class Configuration Exit Sub End If - Dim json As New JSONParser - If Not json.ReadFile(FilePath) Then - GUImsg(MessageType.Err, "Failed to load settings! Using default settings.") - Exit Sub - End If - Try - Try - Mod1Hz = json.Content("Body")("Mod1Hz") - Catch - End Try + Using reader As TextReader = File.OpenText(FilePath) + Dim content As JToken = JToken.ReadFrom(New JsonTextReader(reader)) - ModOut = json.Content("Body")("ModOut") - GnUfromCycle = json.Content("Body")("UseGnUfromCycle") - LogSize = json.Content("Body")("LogSize") - AirDensity = json.Content("Body")("AirDensity") - FuelDens = json.Content("Body")("FuelDensity") - CO2perFC = json.Content("Body")("CO2perFC") - OpenCmd = json.Content("Body")("OpenCmd") - OpenCmdName = json.Content("Body")("OpenCmdName") - FirstRun = json.Content("Body")("FirstRun") - DeclMode = json.Content("Body")("DeclMode") + Dim body As JToken = content.GetEx("Body") + Try + Mod1Hz = body.GetEx(Of Boolean)("Mod1Hz") + Catch + End Try + ModOut = body.GetEx(Of Boolean)("ModOut") + LogSize = body.GetEx(Of Double)("LogSize") + AirDensity = body.GetEx(Of Double)("AirDensity") + FuelDens = body.GetEx(Of Double)("FuelDensity") + CO2perFC = body.GetEx(Of Double)("CO2perFC") + OpenCmd = body.GetEx(Of String)("OpenCmd") + OpenCmdName = body.GetEx(Of String)("OpenCmdName") + FirstRun = body.GetEx(Of Boolean)("FirstRun") + DeclMode = body.GetEx(Of Boolean)("DeclMode") + End Using Catch ex As Exception - GUImsg(MessageType.Err, "Error while loading settings!") + GUIMsg(MessageType.Err, "Error while loading settings!") End Try End Sub Public Sub Save() - Dim json As New JSONParser - Dim dic As Dictionary(Of String, Object) + Dim json As New JSONWriter + + Dim header As Dictionary(Of String, Object) = New Dictionary(Of String, Object) + header.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + header.Add("Date", Now.ToUniversalTime().ToString("o")) + header.Add("AppVersion", VECTOvers) + header.Add("FileVersion", FormatVersion) - dic = New Dictionary(Of String, Object) - dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") - dic.Add("Date", Now.ToUniversalTime().ToString("o")) - dic.Add("AppVersion", VECTOvers) - dic.Add("FileVersion", FormatVersion) - json.Content.Add("Header", dic) - dic = New Dictionary(Of String, Object) - dic.Add("ModOut", ModOut) - dic.Add("Mod1Hz", Mod1Hz) - dic.Add("LogSize", LogSize) - dic.Add("AirDensity", AirDensity) - dic.Add("FuelDensity", FuelDens) - dic.Add("CO2perFC", CO2perFC) - dic.Add("OpenCmd", OpenCmd) - dic.Add("OpenCmdName", OpenCmdName) - dic.Add("FirstRun", FirstRun) - dic.Add("DeclMode", DeclMode) - json.Content.Add("Body", dic) + Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) + body.Add("ModOut", ModOut) + body.Add("Mod1Hz", Mod1Hz) + body.Add("LogSize", LogSize) + body.Add("AirDensity", AirDensity) + body.Add("FuelDensity", FuelDens) + body.Add("CO2perFC", CO2perFC) + body.Add("OpenCmd", OpenCmd) + body.Add("OpenCmdName", OpenCmdName) + body.Add("FirstRun", FirstRun) + body.Add("DeclMode", DeclMode) + json.Content = JToken.FromObject(New Dictionary(Of String, Object) From {{"Header", header}, {"Body", body}}) json.WriteFile(FilePath) End Sub End Class diff --git a/VECTO/CsvFile.vb b/VECTO/CsvFile.vb deleted file mode 100644 index 9e36ce149188c9bb4f028945b960d8b3d54bf10c..0000000000000000000000000000000000000000 --- a/VECTO/CsvFile.vb +++ /dev/null @@ -1,144 +0,0 @@ -' Copyright 2014 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports System.IO -Imports System.Text -Imports Microsoft.VisualBasic.FileIO - -Public Class CsvFile - Private _parser As TextFieldParser - Private _writer As StreamWriter - Private _mode As FileMode - Private _path As String - Private _separator As String - Private _skipComments As Boolean - Private _fileOpen As Boolean - Private _preLine As String() - Private _endOfFile As Boolean - - Public Sub New() - Reset() - End Sub - - Private Sub Reset() - _fileOpen = False - _mode = FileMode.Undefined - _preLine = Nothing - _endOfFile = False - End Sub - - Public Function OpenRead(ByVal fileName As String, Optional ByVal separator As String = ",", - Optional ByVal skipComment As Boolean = True) As Boolean - Reset() - - _path = fileName - _separator = separator - _skipComments = skipComment - If Not (_mode = FileMode.Undefined) Then Return False - If Not File.Exists(_path) Then Return False - _mode = FileMode.Read - Try - _parser = New TextFieldParser(_path, Encoding.Default) - _fileOpen = True - Catch ex As Exception - Return False - End Try - _parser.TextFieldType = FieldType.Delimited - _parser.Delimiters = New String() {_separator} - - 'If TxtFldParser.EndOfData Then Return False - - ReadLine() - Return True - End Function - - Public Function ReadLine() As String() - Dim line As String() - Dim line0 As String - - line = _preLine - -lb10: - If _parser.EndOfData Then - _endOfFile = True - Else - _preLine = _parser.ReadFields - line0 = UCase(Trim(_preLine(0))) - - If _skipComments Then - If Left(line0, 1) = "#" Then GoTo lb10 - End If - - End If - - Return line - End Function - - Public Sub Close() - Select Case _mode - Case FileMode.Read - If _fileOpen Then _parser.Close() - _parser = Nothing - Case FileMode.Write - If _fileOpen Then _writer.Close() - _writer = Nothing - End Select - Reset() - End Sub - - Public ReadOnly Property EndOfFile() As Boolean - Get - Return _endOfFile - End Get - End Property - - Public Function OpenWrite(ByVal FileName As String, Optional ByVal Separator As String = ",", - Optional ByVal AutoFlush As Boolean = False, Optional ByVal Append As Boolean = False) As Boolean - Reset() - _path = FileName - _separator = Separator - If Not (_mode = FileMode.Undefined) Then Return False - _mode = FileMode.Write - Try - _writer = My.Computer.FileSystem.OpenTextFileWriter(_path, Append, FileFormat) - _fileOpen = True - Catch ex As Exception - Return False - End Try - _writer.AutoFlush = AutoFlush - Return True - End Function - - Public Sub WriteLine(ByVal ParamArray x() As Object) - Dim St As String - Dim StB As New StringBuilder - Dim Skip As Boolean - Skip = True - For Each St In x - If Skip Then - StB.Append(St) - Skip = False - Else - StB.Append(_separator & St) - End If - Next - _writer.WriteLine(StB.ToString) - End Sub - - Public Sub WriteLine(ByVal x As String) - _writer.WriteLine(x) - End Sub - - Private Enum FileMode - Undefined - Read - Write - End Enum -End Class diff --git a/VECTO/File Browser/FileBrowser.vb b/VECTO/File Browser/FileBrowser.vb index 6b7fbda4833bf583e2d26e8ac8092a9e0b7fede4..36c2693ecf50aa138c54c6cf0477c8bfd234add2 100644 --- a/VECTO/File Browser/FileBrowser.vb +++ b/VECTO/File Browser/FileBrowser.vb @@ -21,28 +21,28 @@ ''' File history is unique for each ID. Folder history is global. ''' </remarks> Public Class FileBrowser - Private Initialized As Boolean - Private ReadOnly MyID As String - Private MyExt As String() - Private Dlog As FileBrowserDialog - Private NoExt As Boolean - Private ReadOnly bFolderBrowser As Boolean - Private ReadOnly bLightMode As Boolean + Private _initialized As Boolean + Private ReadOnly _id As String + Private _extensionList As String() + Private _dialog As FileBrowserDialog + Private _noExtension As Boolean + Private ReadOnly _folderBrowser As Boolean + Private ReadOnly _lightMode As Boolean ''' <summary> ''' New cFileBrowser instance ''' </summary> - ''' <param name="ID">Needed to save the file history when not using LightMode.</param> - ''' <param name="FolderBrowser">Browse folders instead of files.</param> - ''' <param name="LightMode">If enabled file history is not saved.</param> + ''' <param name="id">Needed to save the file history when not using LightMode.</param> + ''' <param name="folderBrowser">Browse folders instead of files.</param> + ''' <param name="lightMode">If enabled file history is not saved.</param> ''' <remarks></remarks> - Public Sub New(ID As String, Optional ByVal FolderBrowser As Boolean = False, - Optional ByVal LightMode As Boolean = False) - Initialized = False - MyID = ID - NoExt = True - bFolderBrowser = FolderBrowser - bLightMode = LightMode + Public Sub New(id As String, Optional ByVal folderBrowser As Boolean = False, + Optional ByVal lightMode As Boolean = False) + _initialized = False + _id = ID + _noExtension = True + _folderBrowser = folderBrowser + _lightMode = lightMode End Sub ''' <summary> @@ -55,7 +55,7 @@ Public Class FileBrowser ''' <remarks></remarks> Public Function OpenDialog(path As String, Optional ByVal multiFile As Boolean = False, Optional ByVal ext As String = "") As Boolean - Return CustomDialog(path, True, False, tFbExtMode.MultiExt, multiFile, ext, "Open") + Return CustomDialog(path, True, False, FileBrowserFileExtensionMode.MultiExt, multiFile, ext, "Open") End Function ''' <summary> @@ -68,11 +68,11 @@ Public Class FileBrowser ''' <remarks></remarks> Public Function SaveDialog(path As String, Optional ByVal forceExt As Boolean = True, Optional ByVal ext As String = "") _ As Boolean - Dim x As tFbExtMode + Dim x As FileBrowserFileExtensionMode If forceExt Then - x = tFbExtMode.ForceExt + x = FileBrowserFileExtensionMode.ForceExt Else - x = tFbExtMode.SingleExt + x = FileBrowserFileExtensionMode.SingleExt End If Return CustomDialog(path, False, True, x, False, ext, "Save As") End Function @@ -89,10 +89,10 @@ Public Class FileBrowser ''' <param name="title">Dialog title.</param> ''' <returns></returns> ''' <remarks></remarks> - Public Function CustomDialog(path As String, fileMustExist As Boolean, overwriteCheck As Boolean, extMode As tFbExtMode, + Public Function CustomDialog(path As String, fileMustExist As Boolean, overwriteCheck As Boolean, extMode As FileBrowserFileExtensionMode, multiFile As Boolean, ext As String, Optional title As String = "File Browser") As Boolean - If Not Initialized Then Init() - Return Dlog.Browse(path, fileMustExist, overwriteCheck, extMode, multiFile, ext, title) + If Not _initialized Then Init() + Return _dialog.Browse(path, fileMustExist, overwriteCheck, extMode, multiFile, ext, title) End Function 'Manually update File History @@ -102,8 +102,8 @@ Public Class FileBrowser ''' <param name="path">File to be added to file history.</param> ''' <remarks></remarks> Public Sub UpdateHistory(path As String) - If Not Initialized Then Init() - Dlog.UpdateHistory(path) + If Not _initialized Then Init() + _dialog.UpdateHistory(path) End Sub ''' <summary> @@ -111,19 +111,19 @@ Public Class FileBrowser ''' </summary> ''' <remarks></remarks> Public Sub Close() - If Initialized Then - Dlog.SaveAndClose() - Initialized = False + If _initialized Then + _dialog.SaveAndClose() + _initialized = False End If - Dlog = Nothing + _dialog = Nothing End Sub Private Sub Init() - Dlog = New FileBrowserDialog(bLightMode) - Dlog.ID = MyID - If Not NoExt Then Dlog.Extensions = MyExt - If bFolderBrowser Then Dlog.SetFolderBrowser() - Initialized = True + _dialog = New FileBrowserDialog(_lightMode) + _dialog.ID = _id + If Not _noExtension Then _dialog.Extensions = _extensionList + If _folderBrowser Then _dialog.SetFolderBrowser() + _initialized = True End Sub ''' <summary> @@ -134,11 +134,11 @@ Public Class FileBrowser ''' <remarks></remarks> Public Property Extensions As String() Get - Return MyExt + Return _extensionList End Get Set(value As String()) - MyExt = value - NoExt = False + _extensionList = value + _noExtension = False End Set End Property @@ -150,8 +150,8 @@ Public Class FileBrowser ''' <remarks></remarks> Public ReadOnly Property Files As String() Get - If Initialized Then - Return Dlog.Files + If _initialized Then + Return _dialog.Files Else Return New String() {""} End If diff --git a/VECTO/File Browser/FileBrowserDialog.vb b/VECTO/File Browser/FileBrowserDialog.vb index b1498f0eeae38bf33f3d76bdfbd540a73ac24fd2..d5a31cbd3a6840c5b7c1a122381daa5d564faf07 100644 --- a/VECTO/File Browser/FileBrowserDialog.vb +++ b/VECTO/File Browser/FileBrowserDialog.vb @@ -136,7 +136,7 @@ Public Class FileBrowserDialog 'Single File path = Trim(TextBoxPath.Text) 'Primary extension (eg for bForceExt) - ext = Trim(ComboBoxExt.Text.Split(",")(0)) + ext = Trim(ComboBoxExt.Text.Split(","c)(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 @@ -186,7 +186,8 @@ Public Class FileBrowserDialog End Sub 'Browse - Custom Dialog - Public Function Browse(path As String, fileMustExist As Boolean, overwriteCheck As Boolean, extMode As tFbExtMode, + Public Function Browse(path As String, fileMustExist As Boolean, overwriteCheck As Boolean, + extMode As FileBrowserFileExtensionMode, multiFile As Boolean, ext As String, caption As String) As Boolean If Not _initialized Then Init() @@ -201,12 +202,12 @@ Public Class FileBrowserDialog 'Options _bOverwriteCheck = overwriteCheck _bFileMustExist = fileMustExist - _bForceExt = (extMode = tFbExtMode.ForceExt) + _bForceExt = (extMode = FileBrowserFileExtensionMode.ForceExt) 'Form Config ListViewFiles.MultiSelect = multiFile ButtonAll.Visible = multiFile - Title = caption + _title = caption Text = caption 'Ext-Combobox @@ -216,13 +217,13 @@ Public Class FileBrowserDialog ComboBoxExt.SelectedIndex = 0 Else Select Case extMode - Case tFbExtMode.ForceExt + Case FileBrowserFileExtensionMode.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 + Case FileBrowserFileExtensionMode.MultiExt, FileBrowserFileExtensionMode.SingleExt + If extMode = FileBrowserFileExtensionMode.MultiExt Then ComboBoxExt.Items.AddRange(_extListMulti.ToArray) Else ComboBoxExt.Items.AddRange(_extListSingle.ToArray) @@ -288,7 +289,7 @@ Public Class FileBrowserDialog End If End Function - Public Title As String + Private _title As String 'Close and save File / Folder History Public Sub SaveAndClose() @@ -389,7 +390,7 @@ Public Class FileBrowserDialog _extListMulti = New ArrayList For x = 0 To UBound(_myExt) _extListMulti.Add(_myExt(x)) - For Each line In _myExt(x).Split(",") + For Each line In _myExt(x).Split(","c) _extListSingle.Add(Trim(line)) Next Next @@ -494,7 +495,7 @@ Public Class FileBrowserDialog TextBoxPath.Text = "" Else If ListViewFiles.SelectedItems.Count > 1 Then - TextBoxPath.Text = "<" & ListViewFiles.SelectedItems.Count & " Files selected>" + TextBoxPath.Text = String.Format("<{0} Files selected>", ListViewFiles.SelectedItems.Count) Else TextBoxPath.Text = ListViewFiles.SelectedItems.Item(0).Text TextBoxPath.SelectionStart = TextBoxPath.Text.Length @@ -643,8 +644,8 @@ Public Class FileBrowserDialog If path = FavText Then Dim favdlog = New FileBrowserFavoritesDialog If favdlog.ShowDialog(Me) = DialogResult.OK Then - For x = 10 To 19 - path = favdlog.ListBox1.Items(x - 10) + For x As Integer = 10 To 19 + path = favdlog.ListBox1.Items(x - 10).ToString() If path = NoFavString Then FileBrowserFolderHistory(x) = EmptyText Else @@ -671,7 +672,7 @@ Public Class FileBrowserDialog Do While x1 > x newpath = path 'path = Microsoft.VisualBasic.Left(path, x1 - 1) - path = Microsoft.VisualBasic.Left(path, path.LastIndexOf("\")) + path = Microsoft.VisualBasic.Left(path, path.LastIndexOf("\", StringComparison.Ordinal)) x1 = path.Length Loop SetFolder(newpath) @@ -741,7 +742,7 @@ Public Class FileBrowserDialog _myFolder = path If Microsoft.VisualBasic.Right(_myFolder, 1) <> "\" Then _myFolder &= "\" - Text = Title & " " & _myFolder + Text = _title & " " & _myFolder LoadListFolder() LoadListFiles() @@ -758,7 +759,7 @@ Public Class FileBrowserDialog Private Sub FolderUp() If _myFolder <> "" Then Dim path = Microsoft.VisualBasic.Left(_myFolder, _myFolder.Length - 1) - Dim x = path.LastIndexOf("\") + Dim x = path.LastIndexOf("\", StringComparison.Ordinal) If x > 0 Then SetFolder(Microsoft.VisualBasic.Left(path, x)) End If End Sub @@ -811,7 +812,7 @@ Public Class FileBrowserDialog If Trim(ComboBoxExt.Text.ToString) = "" Then extStr = New String() {"*"} Else - extStr = ComboBoxExt.Text.ToString.Split(",") + extStr = ComboBoxExt.Text.ToString.Split(","c) End If 'Delete File-List @@ -913,7 +914,7 @@ lb10: End Sub Private Shared Function fPATH(path As String) As String - Dim x = path.LastIndexOf("\") + Dim x = path.LastIndexOf("\", StringComparison.Ordinal) If x = -1 Then Return Microsoft.VisualBasic.Left(path, 0) Else diff --git a/VECTO/File Browser/FileBrowserModule.vb b/VECTO/File Browser/FileBrowserModule.vb index 996df743ce804371966cd9890bcbd4dbb9402696..b6c77240153ac9454896fa68f652598b1bfe5332 100644 --- a/VECTO/File Browser/FileBrowserModule.vb +++ b/VECTO/File Browser/FileBrowserModule.vb @@ -36,11 +36,11 @@ Public Module FileBrowserModule Public GearboxShiftPolygonFileBrowser As FileBrowser Public TransmissionLossMapFileBrowser As FileBrowser - Public fbPTOLM As FileBrowser + Public PtoLossMapFileBrowser As FileBrowser Public RetarderLossMapFileBrowser As FileBrowser Public TorqueConverterFileBrowser As FileBrowser - Public fbTCCShift As FileBrowser - Public fbCDx As FileBrowser + Public TorqueConverterShiftPolygonFileBrowser As FileBrowser + Public CrossWindCorrectionFileBrowser As FileBrowser Public ModalResultsFileBrowser As FileBrowser End Module diff --git a/VECTO/GUI/EngineForm.Designer.vb b/VECTO/GUI/EngineForm.Designer.vb index c8374d87abd9a2c81e01fab37c19bafbb5a46aef..91a0a19ca83081a4248af307a160fe050e797830 100644 --- a/VECTO/GUI/EngineForm.Designer.vb +++ b/VECTO/GUI/EngineForm.Designer.vb @@ -35,220 +35,228 @@ Partial Class EngineForm 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. <DebuggerStepThrough()> _ Private Sub InitializeComponent() - Me.components = New Container() - Dim resources As ComponentResourceManager = New ComponentResourceManager(GetType(EngineForm)) - Me.TbNleerl = New TextBox() - Me.Label11 = New Label() - Me.TbInertia = New TextBox() - Me.Label41 = New Label() - Me.Label40 = New Label() - Me.Label5 = New Label() - Me.ButCancel = New Button() - Me.ButOK = New Button() - Me.ToolStrip1 = New ToolStrip() - Me.ToolStripBtNew = New ToolStripButton() - Me.ToolStripBtOpen = New ToolStripButton() - Me.ToolStripBtSave = New ToolStripButton() - Me.ToolStripBtSaveAs = New ToolStripButton() - Me.ToolStripSeparator3 = New ToolStripSeparator() - Me.ToolStripBtSendTo = New ToolStripButton() - Me.ToolStripSeparator1 = New ToolStripSeparator() - Me.ToolStripButton1 = New ToolStripButton() - Me.StatusStrip1 = New StatusStrip() - Me.LbStatus = New ToolStripStatusLabel() - Me.Label1 = New Label() - Me.Label2 = New Label() - Me.TbDispl = New TextBox() - Me.TbName = New TextBox() - Me.Label3 = New Label() - Me.TbMAP = New TextBox() - Me.Label6 = New Label() - Me.BtMAP = New Button() - Me.PictureBox1 = New PictureBox() - Me.CmOpenFile = New ContextMenuStrip(Me.components) - Me.OpenWithToolStripMenuItem = New ToolStripMenuItem() - Me.ShowInFolderToolStripMenuItem = New ToolStripMenuItem() - Me.BtMAPopen = New Button() - Me.PnInertia = New Panel() - Me.GrWHTC = New GroupBox() - Me.BtWHTCimport = New Button() - Me.Label13 = New Label() - Me.TbWHTCmw = New TextBox() - Me.TbWHTCrural = New TextBox() - Me.TbWHTCurban = New TextBox() - Me.Label8 = New Label() - Me.Label7 = New Label() - Me.Label4 = New Label() - Me.PicBox = New PictureBox() - Me.TbFLD = New TextBox() - Me.Label14 = New Label() - Me.BtFLD = New Button() - Me.BtFLDopen = New Button() + Me.components = New System.ComponentModel.Container() + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(EngineForm)) + Me.TbNleerl = New System.Windows.Forms.TextBox() + Me.Label11 = New System.Windows.Forms.Label() + Me.TbInertia = New System.Windows.Forms.TextBox() + Me.Label41 = New System.Windows.Forms.Label() + Me.Label40 = New System.Windows.Forms.Label() + Me.Label5 = New System.Windows.Forms.Label() + Me.ButCancel = New System.Windows.Forms.Button() + Me.ButOK = New System.Windows.Forms.Button() + Me.ToolStrip1 = New System.Windows.Forms.ToolStrip() + Me.ToolStripBtNew = New System.Windows.Forms.ToolStripButton() + Me.ToolStripBtOpen = New System.Windows.Forms.ToolStripButton() + Me.ToolStripBtSave = New System.Windows.Forms.ToolStripButton() + Me.ToolStripBtSaveAs = New System.Windows.Forms.ToolStripButton() + Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator() + Me.ToolStripBtSendTo = New System.Windows.Forms.ToolStripButton() + Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator() + Me.ToolStripButton1 = New System.Windows.Forms.ToolStripButton() + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() + Me.LbStatus = New System.Windows.Forms.ToolStripStatusLabel() + Me.Label1 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.TbDispl = New System.Windows.Forms.TextBox() + Me.TbName = New System.Windows.Forms.TextBox() + Me.Label3 = New System.Windows.Forms.Label() + Me.TbMAP = New System.Windows.Forms.TextBox() + Me.Label6 = New System.Windows.Forms.Label() + Me.BtMAP = New System.Windows.Forms.Button() + Me.PictureBox1 = New System.Windows.Forms.PictureBox() + Me.CmOpenFile = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.OpenWithToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.ShowInFolderToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.BtMAPopen = New System.Windows.Forms.Button() + Me.PnInertia = New System.Windows.Forms.Panel() + Me.GrWHTC = New System.Windows.Forms.GroupBox() + Me.PnWhtcDeclaration = New System.Windows.Forms.Panel() + Me.BtWHTCimport = New System.Windows.Forms.Button() + Me.Label4 = New System.Windows.Forms.Label() + Me.Label7 = New System.Windows.Forms.Label() + Me.Label13 = New System.Windows.Forms.Label() + Me.Label8 = New System.Windows.Forms.Label() + Me.TbWHTCmw = New System.Windows.Forms.TextBox() + Me.TbWHTCurban = New System.Windows.Forms.TextBox() + Me.TbWHTCrural = New System.Windows.Forms.TextBox() + Me.PnWhtcEngineering = New System.Windows.Forms.Panel() + Me.TbWHTCEngineering = New System.Windows.Forms.TextBox() + Me.lblWhtcEngineering = New System.Windows.Forms.Label() + Me.PicBox = New System.Windows.Forms.PictureBox() + Me.TbFLD = New System.Windows.Forms.TextBox() + Me.Label14 = New System.Windows.Forms.Label() + Me.BtFLD = New System.Windows.Forms.Button() + Me.BtFLDopen = New System.Windows.Forms.Button() + Me.lblColdHotFactor = New System.Windows.Forms.Label() + Me.TbColdHotFactor = New System.Windows.Forms.TextBox() Me.ToolStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() - CType(Me.PictureBox1, ISupportInitialize).BeginInit() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.CmOpenFile.SuspendLayout() Me.PnInertia.SuspendLayout() Me.GrWHTC.SuspendLayout() - CType(Me.PicBox, ISupportInitialize).BeginInit() + Me.PnWhtcDeclaration.SuspendLayout() + Me.PnWhtcEngineering.SuspendLayout() + CType(Me.PicBox, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'TbNleerl ' - Me.TbNleerl.Location = New Point(123, 108) + Me.TbNleerl.Location = New System.Drawing.Point(123, 108) Me.TbNleerl.Name = "TbNleerl" - Me.TbNleerl.Size = New Size(57, 20) + Me.TbNleerl.Size = New System.Drawing.Size(57, 20) Me.TbNleerl.TabIndex = 1 ' 'Label11 ' Me.Label11.AutoSize = True - Me.Label11.Location = New Point(15, 111) + Me.Label11.Location = New System.Drawing.Point(15, 111) Me.Label11.Name = "Label11" - Me.Label11.Size = New Size(102, 13) + Me.Label11.Size = New System.Drawing.Size(102, 13) Me.Label11.TabIndex = 15 Me.Label11.Text = "Idling Engine Speed" ' 'TbInertia ' - Me.TbInertia.Location = New Point(120, 2) + Me.TbInertia.Location = New System.Drawing.Point(120, 2) Me.TbInertia.Name = "TbInertia" - Me.TbInertia.Size = New Size(57, 20) + Me.TbInertia.Size = New System.Drawing.Size(57, 20) Me.TbInertia.TabIndex = 3 ' 'Label41 ' Me.Label41.AutoSize = True - Me.Label41.Location = New Point(183, 5) + Me.Label41.Location = New System.Drawing.Point(183, 5) Me.Label41.Name = "Label41" - Me.Label41.Size = New Size(36, 13) + Me.Label41.Size = New System.Drawing.Size(36, 13) Me.Label41.TabIndex = 24 Me.Label41.Text = "[kgm²]" ' 'Label40 ' Me.Label40.AutoSize = True - Me.Label40.Location = New Point(186, 111) + Me.Label40.Location = New System.Drawing.Point(186, 111) Me.Label40.Name = "Label40" - Me.Label40.Size = New Size(30, 13) + Me.Label40.Size = New System.Drawing.Size(30, 13) Me.Label40.TabIndex = 24 Me.Label40.Text = "[rpm]" ' 'Label5 ' Me.Label5.AutoSize = True - Me.Label5.Location = New Point(12, 5) + Me.Label5.Location = New System.Drawing.Point(12, 5) Me.Label5.Name = "Label5" - Me.Label5.Size = New Size(102, 13) + Me.Label5.Size = New System.Drawing.Size(102, 13) Me.Label5.TabIndex = 0 Me.Label5.Text = "Inertia incl. Flywheel" ' 'ButCancel ' - Me.ButCancel.Anchor = CType((AnchorStyles.Bottom Or AnchorStyles.Right), AnchorStyles) - Me.ButCancel.DialogResult = DialogResult.Cancel - Me.ButCancel.Location = New Point(898, 469) + Me.ButCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.ButCancel.Location = New System.Drawing.Point(898, 469) Me.ButCancel.Name = "ButCancel" - Me.ButCancel.Size = New Size(75, 23) + Me.ButCancel.Size = New System.Drawing.Size(75, 23) Me.ButCancel.TabIndex = 13 Me.ButCancel.Text = "Cancel" Me.ButCancel.UseVisualStyleBackColor = True ' 'ButOK ' - Me.ButOK.Anchor = CType((AnchorStyles.Bottom Or AnchorStyles.Right), AnchorStyles) - Me.ButOK.Location = New Point(817, 469) + Me.ButOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButOK.Location = New System.Drawing.Point(817, 469) Me.ButOK.Name = "ButOK" - Me.ButOK.Size = New Size(75, 23) + Me.ButOK.Size = New System.Drawing.Size(75, 23) Me.ButOK.TabIndex = 12 Me.ButOK.Text = "Save" Me.ButOK.UseVisualStyleBackColor = True ' 'ToolStrip1 ' - Me.ToolStrip1.GripStyle = ToolStripGripStyle.Hidden - Me.ToolStrip1.Items.AddRange(New ToolStripItem() {Me.ToolStripBtNew, Me.ToolStripBtOpen, Me.ToolStripBtSave, Me.ToolStripBtSaveAs, Me.ToolStripSeparator3, Me.ToolStripBtSendTo, Me.ToolStripSeparator1, Me.ToolStripButton1}) - Me.ToolStrip1.Location = New Point(0, 0) + Me.ToolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden + Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripBtNew, Me.ToolStripBtOpen, Me.ToolStripBtSave, Me.ToolStripBtSaveAs, Me.ToolStripSeparator3, Me.ToolStripBtSendTo, Me.ToolStripSeparator1, Me.ToolStripButton1}) + Me.ToolStrip1.Location = New System.Drawing.Point(0, 0) Me.ToolStrip1.Name = "ToolStrip1" - Me.ToolStrip1.Size = New Size(985, 25) + Me.ToolStrip1.Size = New System.Drawing.Size(985, 25) Me.ToolStrip1.TabIndex = 30 Me.ToolStrip1.Text = "ToolStrip1" ' 'ToolStripBtNew ' - Me.ToolStripBtNew.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtNew.Image = My.Resources.Resources.blue_document_icon - Me.ToolStripBtNew.ImageTransparentColor = Color.Magenta + Me.ToolStripBtNew.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtNew.Image = Global.TUGraz.VECTO.My.Resources.Resources.blue_document_icon + Me.ToolStripBtNew.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtNew.Name = "ToolStripBtNew" - Me.ToolStripBtNew.Size = New Size(23, 22) + Me.ToolStripBtNew.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtNew.Text = "ToolStripButton1" Me.ToolStripBtNew.ToolTipText = "New" ' 'ToolStripBtOpen ' - Me.ToolStripBtOpen.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtOpen.Image = My.Resources.Resources.Open_icon - Me.ToolStripBtOpen.ImageTransparentColor = Color.Magenta + Me.ToolStripBtOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtOpen.Image = Global.TUGraz.VECTO.My.Resources.Resources.Open_icon + Me.ToolStripBtOpen.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtOpen.Name = "ToolStripBtOpen" - Me.ToolStripBtOpen.Size = New Size(23, 22) + Me.ToolStripBtOpen.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtOpen.Text = "ToolStripButton1" Me.ToolStripBtOpen.ToolTipText = "Open..." ' 'ToolStripBtSave ' - Me.ToolStripBtSave.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtSave.Image = My.Resources.Resources.Actions_document_save_icon - Me.ToolStripBtSave.ImageTransparentColor = Color.Magenta + Me.ToolStripBtSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtSave.Image = Global.TUGraz.VECTO.My.Resources.Resources.Actions_document_save_icon + Me.ToolStripBtSave.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtSave.Name = "ToolStripBtSave" - Me.ToolStripBtSave.Size = New Size(23, 22) + Me.ToolStripBtSave.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtSave.Text = "ToolStripButton1" Me.ToolStripBtSave.ToolTipText = "Save" ' 'ToolStripBtSaveAs ' - Me.ToolStripBtSaveAs.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtSaveAs.Image = My.Resources.Resources.Actions_document_save_as_icon - Me.ToolStripBtSaveAs.ImageTransparentColor = Color.Magenta + Me.ToolStripBtSaveAs.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtSaveAs.Image = Global.TUGraz.VECTO.My.Resources.Resources.Actions_document_save_as_icon + Me.ToolStripBtSaveAs.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtSaveAs.Name = "ToolStripBtSaveAs" - Me.ToolStripBtSaveAs.Size = New Size(23, 22) + Me.ToolStripBtSaveAs.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtSaveAs.Text = "ToolStripButton1" Me.ToolStripBtSaveAs.ToolTipText = "Save As..." ' 'ToolStripSeparator3 ' Me.ToolStripSeparator3.Name = "ToolStripSeparator3" - Me.ToolStripSeparator3.Size = New Size(6, 25) + Me.ToolStripSeparator3.Size = New System.Drawing.Size(6, 25) ' 'ToolStripBtSendTo ' - Me.ToolStripBtSendTo.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtSendTo.Image = My.Resources.Resources.export_icon - Me.ToolStripBtSendTo.ImageTransparentColor = Color.Magenta + Me.ToolStripBtSendTo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtSendTo.Image = Global.TUGraz.VECTO.My.Resources.Resources.export_icon + Me.ToolStripBtSendTo.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtSendTo.Name = "ToolStripBtSendTo" - Me.ToolStripBtSendTo.Size = New Size(23, 22) + Me.ToolStripBtSendTo.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtSendTo.Text = "Send to Job Editor" Me.ToolStripBtSendTo.ToolTipText = "Send to Job Editor" ' 'ToolStripSeparator1 ' Me.ToolStripSeparator1.Name = "ToolStripSeparator1" - Me.ToolStripSeparator1.Size = New Size(6, 25) + Me.ToolStripSeparator1.Size = New System.Drawing.Size(6, 25) ' 'ToolStripButton1 ' - Me.ToolStripButton1.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripButton1.Image = My.Resources.Resources.Help_icon - Me.ToolStripButton1.ImageTransparentColor = Color.Magenta + Me.ToolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripButton1.Image = Global.TUGraz.VECTO.My.Resources.Resources.Help_icon + Me.ToolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripButton1.Name = "ToolStripButton1" - Me.ToolStripButton1.Size = New Size(23, 22) + Me.ToolStripButton1.Size = New System.Drawing.Size(23, 22) Me.ToolStripButton1.Text = "Help" ' 'StatusStrip1 ' - Me.StatusStrip1.Items.AddRange(New ToolStripItem() {Me.LbStatus}) - Me.StatusStrip1.Location = New Point(0, 495) + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.LbStatus}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 495) Me.StatusStrip1.Name = "StatusStrip1" - Me.StatusStrip1.Size = New Size(985, 22) + Me.StatusStrip1.Size = New System.Drawing.Size(985, 22) Me.StatusStrip1.SizingGrip = False Me.StatusStrip1.TabIndex = 37 Me.StatusStrip1.Text = "StatusStrip1" @@ -256,110 +264,110 @@ Partial Class EngineForm 'LbStatus ' Me.LbStatus.Name = "LbStatus" - Me.LbStatus.Size = New Size(39, 17) + Me.LbStatus.Size = New System.Drawing.Size(39, 17) Me.LbStatus.Text = "Status" ' 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New Point(186, 137) + Me.Label1.Location = New System.Drawing.Point(186, 137) Me.Label1.Name = "Label1" - Me.Label1.Size = New Size(33, 13) + Me.Label1.Size = New System.Drawing.Size(33, 13) Me.Label1.TabIndex = 24 Me.Label1.Text = "[ccm]" ' 'Label2 ' Me.Label2.AutoSize = True - Me.Label2.Location = New Point(46, 137) + Me.Label2.Location = New System.Drawing.Point(46, 137) Me.Label2.Name = "Label2" - Me.Label2.Size = New Size(71, 13) + Me.Label2.Size = New System.Drawing.Size(71, 13) Me.Label2.TabIndex = 13 Me.Label2.Text = "Displacement" ' 'TbDispl ' - Me.TbDispl.Location = New Point(123, 134) + Me.TbDispl.Location = New System.Drawing.Point(123, 134) Me.TbDispl.Name = "TbDispl" - Me.TbDispl.Size = New Size(57, 20) + Me.TbDispl.Size = New System.Drawing.Size(57, 20) Me.TbDispl.TabIndex = 2 ' 'TbName ' - Me.TbName.Location = New Point(123, 82) + Me.TbName.Location = New System.Drawing.Point(123, 82) Me.TbName.Name = "TbName" - Me.TbName.Size = New Size(370, 20) + Me.TbName.Size = New System.Drawing.Size(370, 20) Me.TbName.TabIndex = 0 ' 'Label3 ' Me.Label3.AutoSize = True - Me.Label3.Location = New Point(30, 85) + Me.Label3.Location = New System.Drawing.Point(30, 85) Me.Label3.Name = "Label3" - Me.Label3.Size = New Size(87, 13) + Me.Label3.Size = New System.Drawing.Size(87, 13) Me.Label3.TabIndex = 11 Me.Label3.Text = "Make and Model" ' 'TbMAP ' - Me.TbMAP.Location = New Point(12, 259) + Me.TbMAP.Location = New System.Drawing.Point(12, 259) Me.TbMAP.Name = "TbMAP" - Me.TbMAP.Size = New Size(434, 20) + Me.TbMAP.Size = New System.Drawing.Size(434, 20) Me.TbMAP.TabIndex = 5 ' 'Label6 ' Me.Label6.AutoSize = True - Me.Label6.Location = New Point(12, 243) + Me.Label6.Location = New System.Drawing.Point(12, 243) Me.Label6.Name = "Label6" - Me.Label6.Size = New Size(115, 13) + Me.Label6.Size = New System.Drawing.Size(115, 13) Me.Label6.TabIndex = 38 Me.Label6.Text = "Fuel Consumption Map" ' 'BtMAP ' - Me.BtMAP.Image = My.Resources.Resources.Open_icon - Me.BtMAP.Location = New Point(446, 257) + Me.BtMAP.Image = Global.TUGraz.VECTO.My.Resources.Resources.Open_icon + Me.BtMAP.Location = New System.Drawing.Point(446, 257) Me.BtMAP.Name = "BtMAP" - Me.BtMAP.Size = New Size(24, 24) + Me.BtMAP.Size = New System.Drawing.Size(24, 24) Me.BtMAP.TabIndex = 6 Me.BtMAP.TabStop = False Me.BtMAP.UseVisualStyleBackColor = True ' 'PictureBox1 ' - Me.PictureBox1.BackColor = Color.White - Me.PictureBox1.Image = My.Resources.Resources.VECTO_ENG - Me.PictureBox1.Location = New Point(12, 28) + Me.PictureBox1.BackColor = System.Drawing.Color.White + Me.PictureBox1.Image = Global.TUGraz.VECTO.My.Resources.Resources.VECTO_ENG + Me.PictureBox1.Location = New System.Drawing.Point(12, 28) Me.PictureBox1.Name = "PictureBox1" - Me.PictureBox1.Size = New Size(481, 40) + Me.PictureBox1.Size = New System.Drawing.Size(481, 40) Me.PictureBox1.TabIndex = 39 Me.PictureBox1.TabStop = False ' 'CmOpenFile ' - Me.CmOpenFile.Items.AddRange(New ToolStripItem() {Me.OpenWithToolStripMenuItem, Me.ShowInFolderToolStripMenuItem}) + Me.CmOpenFile.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OpenWithToolStripMenuItem, Me.ShowInFolderToolStripMenuItem}) Me.CmOpenFile.Name = "CmOpenFile" - Me.CmOpenFile.Size = New Size(153, 48) + Me.CmOpenFile.Size = New System.Drawing.Size(153, 48) ' 'OpenWithToolStripMenuItem ' Me.OpenWithToolStripMenuItem.Name = "OpenWithToolStripMenuItem" - Me.OpenWithToolStripMenuItem.Size = New Size(152, 22) + Me.OpenWithToolStripMenuItem.Size = New System.Drawing.Size(152, 22) Me.OpenWithToolStripMenuItem.Text = "Open with ..." ' 'ShowInFolderToolStripMenuItem ' Me.ShowInFolderToolStripMenuItem.Name = "ShowInFolderToolStripMenuItem" - Me.ShowInFolderToolStripMenuItem.Size = New Size(152, 22) + Me.ShowInFolderToolStripMenuItem.Size = New System.Drawing.Size(152, 22) Me.ShowInFolderToolStripMenuItem.Text = "Show in Folder" ' 'BtMAPopen ' - Me.BtMAPopen.Image = My.Resources.Resources.application_export_icon_small - Me.BtMAPopen.Location = New Point(469, 257) + Me.BtMAPopen.Image = Global.TUGraz.VECTO.My.Resources.Resources.application_export_icon_small + Me.BtMAPopen.Location = New System.Drawing.Point(469, 257) Me.BtMAPopen.Name = "BtMAPopen" - Me.BtMAPopen.Size = New Size(24, 24) + Me.BtMAPopen.Size = New System.Drawing.Size(24, 24) Me.BtMAPopen.TabIndex = 7 Me.BtMAPopen.TabStop = False Me.BtMAPopen.UseVisualStyleBackColor = True @@ -369,147 +377,196 @@ Partial Class EngineForm Me.PnInertia.Controls.Add(Me.Label5) Me.PnInertia.Controls.Add(Me.Label41) Me.PnInertia.Controls.Add(Me.TbInertia) - Me.PnInertia.Location = New Point(264, 106) + Me.PnInertia.Location = New System.Drawing.Point(264, 106) Me.PnInertia.Name = "PnInertia" - Me.PnInertia.Size = New Size(229, 32) + Me.PnInertia.Size = New System.Drawing.Size(229, 32) Me.PnInertia.TabIndex = 3 ' 'GrWHTC ' - Me.GrWHTC.Controls.Add(Me.BtWHTCimport) - Me.GrWHTC.Controls.Add(Me.Label13) - Me.GrWHTC.Controls.Add(Me.TbWHTCmw) - Me.GrWHTC.Controls.Add(Me.TbWHTCrural) - Me.GrWHTC.Controls.Add(Me.TbWHTCurban) - Me.GrWHTC.Controls.Add(Me.Label8) - Me.GrWHTC.Controls.Add(Me.Label7) - Me.GrWHTC.Controls.Add(Me.Label4) - Me.GrWHTC.Enabled = False - Me.GrWHTC.Location = New Point(12, 300) + Me.GrWHTC.Controls.Add(Me.PnWhtcDeclaration) + Me.GrWHTC.Controls.Add(Me.PnWhtcEngineering) + Me.GrWHTC.Location = New System.Drawing.Point(12, 300) Me.GrWHTC.Name = "GrWHTC" - Me.GrWHTC.Size = New Size(481, 91) + Me.GrWHTC.Size = New System.Drawing.Size(481, 153) Me.GrWHTC.TabIndex = 9 Me.GrWHTC.TabStop = False Me.GrWHTC.Text = "WHTC Correction" ' + 'PnWhtcDeclaration + ' + Me.PnWhtcDeclaration.Controls.Add(Me.lblColdHotFactor) + Me.PnWhtcDeclaration.Controls.Add(Me.TbColdHotFactor) + Me.PnWhtcDeclaration.Controls.Add(Me.BtWHTCimport) + Me.PnWhtcDeclaration.Controls.Add(Me.Label4) + Me.PnWhtcDeclaration.Controls.Add(Me.Label7) + Me.PnWhtcDeclaration.Controls.Add(Me.Label13) + Me.PnWhtcDeclaration.Controls.Add(Me.Label8) + Me.PnWhtcDeclaration.Controls.Add(Me.TbWHTCmw) + Me.PnWhtcDeclaration.Controls.Add(Me.TbWHTCurban) + Me.PnWhtcDeclaration.Controls.Add(Me.TbWHTCrural) + Me.PnWhtcDeclaration.Location = New System.Drawing.Point(3, 19) + Me.PnWhtcDeclaration.Name = "PnWhtcDeclaration" + Me.PnWhtcDeclaration.Size = New System.Drawing.Size(472, 87) + Me.PnWhtcDeclaration.TabIndex = 8 + ' 'BtWHTCimport ' - Me.BtWHTCimport.Location = New Point(305, 19) + Me.BtWHTCimport.Location = New System.Drawing.Point(299, 3) Me.BtWHTCimport.Name = "BtWHTCimport" - Me.BtWHTCimport.Size = New Size(170, 28) + Me.BtWHTCimport.Size = New System.Drawing.Size(170, 28) Me.BtWHTCimport.TabIndex = 4 Me.BtWHTCimport.Text = "Import from VECTO-Engine" Me.BtWHTCimport.UseVisualStyleBackColor = True ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(1, 37) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(36, 13) + Me.Label4.TabIndex = 0 + Me.Label4.Text = "Urban" + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(156, 37) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(32, 13) + Me.Label7.TabIndex = 0 + Me.Label7.Text = "Rural" + ' 'Label13 ' Me.Label13.AutoSize = True - Me.Label13.Location = New Point(6, 27) + Me.Label13.Location = New System.Drawing.Point(1, 5) Me.Label13.Name = "Label13" - Me.Label13.Size = New Size(242, 13) + Me.Label13.Size = New System.Drawing.Size(242, 13) Me.Label13.TabIndex = 3 Me.Label13.Text = "Correction Factors calculated with VECTO-Engine" ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Location = New System.Drawing.Point(284, 37) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(53, 13) + Me.Label8.TabIndex = 0 + Me.Label8.Text = "Motorway" + ' 'TbWHTCmw ' - Me.TbWHTCmw.Location = New Point(348, 56) + Me.TbWHTCmw.Location = New System.Drawing.Point(343, 34) Me.TbWHTCmw.Name = "TbWHTCmw" - Me.TbWHTCmw.Size = New Size(57, 20) + Me.TbWHTCmw.Size = New System.Drawing.Size(57, 20) Me.TbWHTCmw.TabIndex = 2 ' - 'TbWHTCrural - ' - Me.TbWHTCrural.Location = New Point(192, 56) - Me.TbWHTCrural.Name = "TbWHTCrural" - Me.TbWHTCrural.Size = New Size(57, 20) - Me.TbWHTCrural.TabIndex = 1 - ' 'TbWHTCurban ' - Me.TbWHTCurban.Location = New Point(48, 56) + Me.TbWHTCurban.Location = New System.Drawing.Point(43, 34) Me.TbWHTCurban.Name = "TbWHTCurban" - Me.TbWHTCurban.Size = New Size(57, 20) + Me.TbWHTCurban.Size = New System.Drawing.Size(57, 20) Me.TbWHTCurban.TabIndex = 0 ' - 'Label8 + 'TbWHTCrural ' - Me.Label8.AutoSize = True - Me.Label8.Location = New Point(289, 59) - Me.Label8.Name = "Label8" - Me.Label8.Size = New Size(53, 13) - Me.Label8.TabIndex = 0 - Me.Label8.Text = "Motorway" + Me.TbWHTCrural.Location = New System.Drawing.Point(194, 34) + Me.TbWHTCrural.Name = "TbWHTCrural" + Me.TbWHTCrural.Size = New System.Drawing.Size(57, 20) + Me.TbWHTCrural.TabIndex = 1 ' - 'Label7 + 'PnWhtcEngineering ' - Me.Label7.AutoSize = True - Me.Label7.Location = New Point(154, 59) - Me.Label7.Name = "Label7" - Me.Label7.Size = New Size(32, 13) - Me.Label7.TabIndex = 0 - Me.Label7.Text = "Rural" + Me.PnWhtcEngineering.Controls.Add(Me.TbWHTCEngineering) + Me.PnWhtcEngineering.Controls.Add(Me.lblWhtcEngineering) + Me.PnWhtcEngineering.Location = New System.Drawing.Point(3, 112) + Me.PnWhtcEngineering.Name = "PnWhtcEngineering" + Me.PnWhtcEngineering.Size = New System.Drawing.Size(472, 30) + Me.PnWhtcEngineering.TabIndex = 7 ' - 'Label4 + 'TbWHTCEngineering ' - Me.Label4.AutoSize = True - Me.Label4.Location = New Point(6, 59) - Me.Label4.Name = "Label4" - Me.Label4.Size = New Size(36, 13) - Me.Label4.TabIndex = 0 - Me.Label4.Text = "Urban" + Me.TbWHTCEngineering.Location = New System.Drawing.Point(194, 3) + Me.TbWHTCEngineering.Name = "TbWHTCEngineering" + Me.TbWHTCEngineering.Size = New System.Drawing.Size(57, 20) + Me.TbWHTCEngineering.TabIndex = 5 + ' + 'lblWhtcEngineering + ' + Me.lblWhtcEngineering.AutoSize = True + Me.lblWhtcEngineering.Location = New System.Drawing.Point(125, 6) + Me.lblWhtcEngineering.Name = "lblWhtcEngineering" + Me.lblWhtcEngineering.Size = New System.Drawing.Size(63, 13) + Me.lblWhtcEngineering.TabIndex = 6 + Me.lblWhtcEngineering.Text = "Engineering" ' 'PicBox ' - Me.PicBox.BackColor = Color.LightGray - Me.PicBox.Location = New Point(499, 28) + Me.PicBox.BackColor = System.Drawing.Color.LightGray + Me.PicBox.Location = New System.Drawing.Point(499, 28) Me.PicBox.Name = "PicBox" - Me.PicBox.Size = New Size(474, 425) + Me.PicBox.Size = New System.Drawing.Size(474, 425) Me.PicBox.TabIndex = 40 Me.PicBox.TabStop = False ' 'TbFLD ' - Me.TbFLD.Location = New Point(12, 202) + Me.TbFLD.Location = New System.Drawing.Point(12, 202) Me.TbFLD.Name = "TbFLD" - Me.TbFLD.Size = New Size(434, 20) + Me.TbFLD.Size = New System.Drawing.Size(434, 20) Me.TbFLD.TabIndex = 5 ' 'Label14 ' Me.Label14.AutoSize = True - Me.Label14.Location = New Point(12, 186) + Me.Label14.Location = New System.Drawing.Point(12, 186) Me.Label14.Name = "Label14" - Me.Label14.Size = New Size(128, 13) + Me.Label14.Size = New System.Drawing.Size(128, 13) Me.Label14.TabIndex = 38 Me.Label14.Text = "Full Load and Drag Curve" ' 'BtFLD ' - Me.BtFLD.Image = My.Resources.Resources.Open_icon - Me.BtFLD.Location = New Point(446, 200) + Me.BtFLD.Image = Global.TUGraz.VECTO.My.Resources.Resources.Open_icon + Me.BtFLD.Location = New System.Drawing.Point(446, 200) Me.BtFLD.Name = "BtFLD" - Me.BtFLD.Size = New Size(24, 24) + Me.BtFLD.Size = New System.Drawing.Size(24, 24) Me.BtFLD.TabIndex = 6 Me.BtFLD.TabStop = False Me.BtFLD.UseVisualStyleBackColor = True ' 'BtFLDopen ' - Me.BtFLDopen.Image = My.Resources.Resources.application_export_icon_small - Me.BtFLDopen.Location = New Point(469, 200) + Me.BtFLDopen.Image = Global.TUGraz.VECTO.My.Resources.Resources.application_export_icon_small + Me.BtFLDopen.Location = New System.Drawing.Point(469, 200) Me.BtFLDopen.Name = "BtFLDopen" - Me.BtFLDopen.Size = New Size(24, 24) + Me.BtFLDopen.Size = New System.Drawing.Size(24, 24) Me.BtFLDopen.TabIndex = 7 Me.BtFLDopen.TabStop = False Me.BtFLDopen.UseVisualStyleBackColor = True ' - 'F_ENG + 'lblColdHotFactor + ' + Me.lblColdHotFactor.AutoSize = True + Me.lblColdHotFactor.Location = New System.Drawing.Point(3, 63) + Me.lblColdHotFactor.Name = "lblColdHotFactor" + Me.lblColdHotFactor.Size = New System.Drawing.Size(185, 13) + Me.lblColdHotFactor.TabIndex = 5 + Me.lblColdHotFactor.Text = "Cold/Hot Emmission Balancing Factor" + ' + 'TbColdHotFactor + ' + Me.TbColdHotFactor.Location = New System.Drawing.Point(194, 60) + Me.TbColdHotFactor.Name = "TbColdHotFactor" + Me.TbColdHotFactor.Size = New System.Drawing.Size(57, 20) + Me.TbColdHotFactor.TabIndex = 6 + ' + 'EngineForm ' Me.AcceptButton = Me.ButOK - Me.AutoScaleDimensions = New SizeF(6.0!, 13.0!) - Me.AutoScaleMode = AutoScaleMode.Font Me.CancelButton = Me.ButCancel - Me.ClientSize = New Size(985, 517) + Me.ClientSize = New System.Drawing.Size(985, 517) Me.Controls.Add(Me.PicBox) Me.Controls.Add(Me.GrWHTC) Me.Controls.Add(Me.PnInertia) @@ -534,23 +591,25 @@ Partial Class EngineForm Me.Controls.Add(Me.Label40) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TbName) - Me.FormBorderStyle = FormBorderStyle.FixedSingle - Me.Icon = CType(resources.GetObject("$this.Icon"), Icon) + Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximizeBox = False Me.Name = "EngineForm" - Me.StartPosition = FormStartPosition.CenterParent + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "F_ENG" Me.ToolStrip1.ResumeLayout(False) Me.ToolStrip1.PerformLayout() Me.StatusStrip1.ResumeLayout(False) Me.StatusStrip1.PerformLayout() - CType(Me.PictureBox1, ISupportInitialize).EndInit() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.CmOpenFile.ResumeLayout(False) Me.PnInertia.ResumeLayout(False) Me.PnInertia.PerformLayout() Me.GrWHTC.ResumeLayout(False) - Me.GrWHTC.PerformLayout() - CType(Me.PicBox, ISupportInitialize).EndInit() + Me.PnWhtcDeclaration.ResumeLayout(False) + Me.PnWhtcDeclaration.PerformLayout() + Me.PnWhtcEngineering.ResumeLayout(False) + Me.PnWhtcEngineering.PerformLayout() + CType(Me.PicBox, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() @@ -602,4 +661,10 @@ Partial Class EngineForm Friend WithEvents BtFLD As Button Friend WithEvents BtFLDopen As Button Friend WithEvents BtWHTCimport As Button + Friend WithEvents TbWHTCEngineering As System.Windows.Forms.TextBox + Friend WithEvents lblWhtcEngineering As System.Windows.Forms.Label + Friend WithEvents PnWhtcDeclaration As System.Windows.Forms.Panel + Friend WithEvents PnWhtcEngineering As System.Windows.Forms.Panel + Friend WithEvents lblColdHotFactor As System.Windows.Forms.Label + Friend WithEvents TbColdHotFactor As System.Windows.Forms.TextBox End Class diff --git a/VECTO/GUI/EngineForm.vb b/VECTO/GUI/EngineForm.vb index 523ac4287414cd54c5171da37b43c25ab8dfe42f..e041ee0857f5fa2f189ce69689a46dcbbf1f6de7 100644 --- a/VECTO/GUI/EngineForm.vb +++ b/VECTO/GUI/EngineForm.vb @@ -1,12 +1,20 @@ Imports System.Drawing.Imaging Imports System.IO +Imports System.Linq Imports System.Text.RegularExpressions Imports System.Windows.Forms.DataVisualization.Charting Imports System.Xml.Linq +Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.FileIO.JSON +Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine +Imports TUGraz.VectoCore.Utils +Imports VectoAuxiliaries ' Copyright 2014 European Union. ' Licensed under the EUPL (the 'Licence'); ' @@ -40,8 +48,8 @@ Public Class EngineForm Private Sub EngineFormLoad(sender As Object, e As EventArgs) Handles Me.Load PnInertia.Enabled = Not Cfg.DeclMode - GrWHTC.Enabled = Cfg.DeclMode - + PnWhtcDeclaration.Enabled = Cfg.DeclMode + PnWhtcEngineering.Enabled = Not Cfg.DeclMode _changed = False NewEngine() @@ -52,10 +60,8 @@ Public Class EngineForm If Not Cfg.DeclMode Then Exit Sub - TbInertia.Text = - CStr( - DeclarationData.Engine.EngineInertia((fTextboxToNumString(TbDispl.Text) / 1000.0 / 1000.0).SI(Of CubicMeter), - GearboxType.AMT).Value()) + TbInertia.Text = DeclarationData.Engine.EngineInertia((TbDispl.Text.ToDouble(0.0) / 1000.0 / 1000.0).SI(Of CubicMeter), + GearboxType.AMT).ToGUIFormat() End Sub @@ -92,7 +98,7 @@ Public Class EngineForm If Not VectoJobForm.Visible Then JobDir = "" VectoJobForm.Show() - VectoJobForm.VECTOnew() + VectoJobForm.VectoNew() Else VectoJobForm.WindowState = FormWindowState.Normal End If @@ -102,11 +108,11 @@ Public Class EngineForm 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 = + Dim browserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString - Dim DefaultBrowserPath As String = - Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - Process.Start(DefaultBrowserPath, + Dim defaultBrowserPath As String = + Regex.Match(browserRegistryString, "(\"".*?\"")").Captures(0).ToString + Process.Start(defaultBrowserPath, String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#engine-editor")) Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) @@ -142,21 +148,18 @@ Public Class EngineForm End Sub 'Open VENG file - Public Sub OpenEngineFile(ByVal file As String) - Dim ENG0 As Engine + Public Sub OpenEngineFile(file As String) + Dim engine As IEngineEngineeringInputData If ChangeCheckCancel() Then Exit Sub - ENG0 = New Engine + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), + IEngineeringInputDataProvider) - ENG0.FilePath = file + engine = inputData.EngineInputData - If Not ENG0.ReadFile Then - MsgBox("Cannot read " & file & "!") - Exit Sub - End If - If Cfg.DeclMode <> ENG0.SavedInDeclMode Then + If Cfg.DeclMode <> engine.SavedInDeclarationMode Then Select Case WrongMode() Case 1 Close() @@ -164,21 +167,22 @@ Public Class EngineForm MainForm.OpenVectoFile(file) Case -1 Exit Sub - Case Else '0 - 'Continue... End Select End If - TbName.Text = ENG0.ModelName - TbDispl.Text = ENG0.Displacement.ToString - TbInertia.Text = ENG0.EngineInertia.ToString - TbNleerl.Text = ENG0.IdleSpeed.ToString + Dim basePath As String = Path.GetDirectoryName(file) + TbName.Text = engine.ModelName + TbDispl.Text = (engine.Displacement * 1000 * 1000).ToGUIFormat() + TbInertia.Text = engine.Inertia.ToGUIFormat() + TbNleerl.Text = engine.IdleSpeed.AsRPM.ToGUIFormat() - TbMAP.Text = ENG0.PathMAP(True) - TbFLD.Text = ENG0.PathFLD(True) - TbWHTCurban.Text = ENG0.WHTCurban - TbWHTCrural.Text = ENG0.WHTCrural - TbWHTCmw.Text = ENG0.WHTCmw + TbMAP.Text = GetRelativePath(engine.FuelConsumptionMap.Source, basePath) + TbFLD.Text = GetRelativePath(engine.FullLoadCurve.Source, basePath) + TbWHTCurban.Text = engine.WHTCUrban.ToGUIFormat() + TbWHTCrural.Text = engine.WHTCRural.ToGUIFormat() + TbWHTCmw.Text = engine.WHTCMotorway.ToGUIFormat() + TbWHTCEngineering.Text = engine.WHTCEngineering.ToGUIFormat() + TbColdHotFactor.Text = engine.ColdHotBalancingFactor.ToGUIFormat() DeclInit() @@ -193,8 +197,8 @@ Public Class EngineForm End Sub 'Save or Save As function = true if file is saved - Private Function SaveOrSaveAs(ByVal SaveAs As Boolean) As Boolean - If _engFile = "" Or SaveAs Then + Private Function SaveOrSaveAs(ByVal saveAs As Boolean) As Boolean + If _engFile = "" Or saveAs Then If EngineFileBrowser.SaveDialog(_engFile) Then _engFile = EngineFileBrowser.Files(0) Else @@ -212,17 +216,20 @@ Public Class EngineForm engine.ModelName = TbName.Text If Trim(engine.ModelName) = "" Then engine.ModelName = "Undefined" - engine.Displacement = CSng(fTextboxToNumString(TbDispl.Text)) - engine.EngineInertia = CSng(fTextboxToNumString(TbInertia.Text)) - engine.IdleSpeed = CSng(fTextboxToNumString(TbNleerl.Text)) + engine.Displacement = TbDispl.Text.ToDouble(0) + engine.EngineInertia = TbInertia.Text.ToDouble(0) + engine.IdleSpeed = TbNleerl.Text.ToDouble(0) + + engine.PathFld = TbFLD.Text + engine.PathMap = TbMAP.Text - engine.PathFLD = TbFLD.Text - engine.PathMAP = TbMAP.Text + engine.WHTCUrbanInput = TbWHTCurban.Text.ToDouble(0) + engine.WHTCRuralInput = TbWHTCrural.Text.ToDouble(0) + engine.WHTCMotorwayInput = TbWHTCmw.Text.ToDouble(0) + engine.WHTCEngineeringInput = TbWHTCEngineering.Text.ToDouble(0) - engine.WHTCurban = CSng(fTextboxToNumString(TbWHTCurban.Text)) - engine.WHTCrural = CSng(fTextboxToNumString(TbWHTCrural.Text)) - engine.WHTCmw = CSng(fTextboxToNumString(TbWHTCmw.Text)) + engine.ColdHotBalancingFactorInput = TbColdHotFactor.Text.ToDouble(0) If Not engine.SaveFile Then @@ -232,7 +239,7 @@ Public Class EngineForm If AutoSendTo Then If VectoJobForm.Visible Then - If UCase(fFileRepl(VectoJobForm.TbENG.Text, JobDir)) <> UCase(file) Then _ + If UCase(FileRepl(VectoJobForm.TbENG.Text, JobDir)) <> UCase(file) Then _ VectoJobForm.TbENG.Text = GetFilenameWithoutDirectory(file, JobDir) VectoJobForm.UpdatePic() End If @@ -321,7 +328,7 @@ Public Class EngineForm 'Browse for VMAP file Private Sub BtMAP_Click(sender As Object, e As EventArgs) Handles BtMAP.Click - If FuelConsumptionMapFileBrowser.OpenDialog(fFileRepl(TbMAP.Text, GetPath(_engFile))) Then _ + If FuelConsumptionMapFileBrowser.OpenDialog(FileRepl(TbMAP.Text, GetPath(_engFile))) Then _ TbMAP.Text = GetFilenameWithoutDirectory(FuelConsumptionMapFileBrowser.Files(0), GetPath(_engFile)) End Sub @@ -330,12 +337,12 @@ Public Class EngineForm Private Sub BtMAPopen_Click(sender As Object, e As EventArgs) Handles BtMAPopen.Click Dim fldfile As String - fldfile = fFileRepl(TbFLD.Text, GetPath(_engFile)) + fldfile = FileRepl(TbFLD.Text, GetPath(_engFile)) - If fldfile <> sKey.NoFile AndAlso File.Exists(fldfile) Then - OpenFiles(fFileRepl(TbMAP.Text, GetPath(_engFile)), fldfile) + If fldfile <> NoFile AndAlso File.Exists(fldfile) Then + OpenFiles(FileRepl(TbMAP.Text, GetPath(_engFile)), fldfile) Else - OpenFiles(fFileRepl(TbMAP.Text, GetPath(_engFile))) + OpenFiles(FileRepl(TbMAP.Text, GetPath(_engFile))) End If End Sub @@ -351,96 +358,94 @@ Public Class EngineForm End Sub Private Sub UpdatePic() + Dim fullLoadCurve As FullLoadCurve = Nothing + Dim fcMap As FuelConsumptionMap = Nothing - Dim fldOK As Boolean = False - Dim mapOK As Boolean = False - Dim fullLoadCurve As New EngineFullLoadCurve - Dim fcMap As New FuelconsumptionMap - Dim chart As Chart - Dim s As Series - Dim a As ChartArea - Dim img As Image PicBox.Image = Nothing - Try - - 'Read Files - fullLoadCurve.FilePath = fFileRepl(TbFLD.Text, GetPath(_engFile)) - fldOK = fullLoadCurve.ReadFile(False, False) - - fcMap.FilePath = fFileRepl(TbMAP.Text, GetPath(_engFile)) - mapOK = fcMap.ReadFile(False) + 'If Not File.Exists(_engFile) Then Exit Sub + Try + Dim fldFile As String = + If(Not String.IsNullOrWhiteSpace(_engFile), Path.Combine(Path.GetDirectoryName(_engFile), TbFLD.Text), TbFLD.Text) + fullLoadCurve = FullLoadCurveReader.Create(VectoCSVFile.Read(fldFile), engineFld:=True) Catch ex As Exception + End Try + Try + Dim fcFile As String = + If(Not String.IsNullOrWhiteSpace(_engFile), Path.Combine(Path.GetDirectoryName(_engFile), TbMAP.Text), TbMAP.Text) + fcMap = FuelConsumptionMapReader.Create(VectoCSVFile.Read(fcFile)) + Catch ex As Exception End Try - If Not fldOK And Not mapOK Then Exit Sub + If fullLoadCurve Is Nothing AndAlso fcMap Is Nothing Then Exit Sub 'Create plot - chart = New Chart + Dim chart As Chart = New Chart chart.Width = PicBox.Width chart.Height = PicBox.Height - a = New ChartArea - - If fldOK Then - - s = New Series - s.Points.DataBindXY(fullLoadCurve.EngineSpeedList, fullLoadCurve.MaxTorqueList) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkBlue - s.Name = "Full load (" & GetFilenameWithoutPath(fullLoadCurve.FilePath, True) & ")" - chart.Series.Add(s) - - s = New Series - s.Points.DataBindXY(fullLoadCurve.EngineSpeedList, fullLoadCurve.DragTorqueList) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.Blue - s.Name = "Motoring (" & GetFilenameWithoutPath(fullLoadCurve.FilePath, True) & ")" - chart.Series.Add(s) - + Dim chartArea As ChartArea = New ChartArea + + If Not fullLoadCurve Is Nothing Then + Dim series As Series = New Series + series.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) + series.ChartType = SeriesChartType.FastLine + series.BorderWidth = 2 + series.Color = Color.DarkBlue + series.Name = "Full load (" & TbFLD.Text & ")" + chart.Series.Add(series) + + series = New Series + series.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value()).ToArray()) + series.ChartType = SeriesChartType.FastLine + series.BorderWidth = 2 + series.Color = Color.Blue + series.Name = "Motoring (" & Path.GetFileNameWithoutExtension(TbMAP.Text) & ")" + chart.Series.Add(series) End If - If mapOK Then - s = New Series - s.Points.DataBindXY(fcMap.nU, fcMap.Tq) - s.ChartType = SeriesChartType.Point - s.MarkerSize = 3 - s.Color = Color.Red - s.Name = "Map" - chart.Series.Add(s) + If Not fcMap Is Nothing Then + Dim series As Series = New Series + series.Points.DataBindXY(fcMap.Entries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fcMap.Entries.Select(Function(x) x.Torque.Value()).ToArray()) + series.ChartType = SeriesChartType.Point + series.MarkerSize = 3 + series.Color = Color.Red + series.Name = "Map" + chart.Series.Add(series) End If - a.Name = "main" + chartArea.Name = "main" - a.AxisX.Title = "engine speed [1/min]" - a.AxisX.TitleFont = New Font("Helvetica", 10) - a.AxisX.LabelStyle.Font = New Font("Helvetica", 8) - a.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None - a.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot + chartArea.AxisX.Title = "engine speed [1/min]" + chartArea.AxisX.TitleFont = New Font("Helvetica", 10) + chartArea.AxisX.LabelStyle.Font = New Font("Helvetica", 8) + chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None + chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot - a.AxisY.Title = "engine torque [Nm]" - a.AxisY.TitleFont = New Font("Helvetica", 10) - a.AxisY.LabelStyle.Font = New Font("Helvetica", 8) - a.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None - a.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot + chartArea.AxisY.Title = "engine torque [Nm]" + chartArea.AxisY.TitleFont = New Font("Helvetica", 10) + chartArea.AxisY.LabelStyle.Font = New Font("Helvetica", 8) + chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None + chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot - a.AxisX.Minimum = 300 - a.BorderDashStyle = ChartDashStyle.Solid - a.BorderWidth = 1 + chartArea.AxisX.Minimum = 300 + chartArea.BorderDashStyle = ChartDashStyle.Solid + chartArea.BorderWidth = 1 - a.BackColor = Color.GhostWhite + chartArea.BackColor = Color.GhostWhite - chart.ChartAreas.Add(a) + chart.ChartAreas.Add(chartArea) chart.Update() - img = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb) + Dim img As Bitmap = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb) chart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height)) @@ -450,13 +455,13 @@ Public Class EngineForm #Region "Open File Context Menu" - Private CmFiles As String() + Private _contextMenuFiles As String() Private Sub OpenFiles(ParamArray files() As String) If files.Length = 0 Then Exit Sub - CmFiles = files + _contextMenuFiles = files OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName @@ -465,14 +470,14 @@ Public Class EngineForm Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenWithToolStripMenuItem.Click - If Not FileOpenAlt(CmFiles(0)) Then MsgBox("Failed to open file!") + If Not FileOpenAlt(_contextMenuFiles(0)) Then MsgBox("Failed to open file!") End Sub Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ShowInFolderToolStripMenuItem.Click - If File.Exists(CmFiles(0)) Then + If File.Exists(_contextMenuFiles(0)) Then Try - Process.Start("explorer", "/select,""" & CmFiles(0) & "") + Process.Start("explorer", "/select,""" & _contextMenuFiles(0) & "") Catch ex As Exception MsgBox("Failed to open file!") End Try @@ -485,16 +490,16 @@ Public Class EngineForm Private Sub BtFLD_Click(sender As Object, e As EventArgs) Handles BtFLD.Click - If FullLoadCurveFileBrowser.OpenDialog(fFileRepl(TbFLD.Text, GetPath(_engFile))) Then _ + If FullLoadCurveFileBrowser.OpenDialog(FileRepl(TbFLD.Text, GetPath(_engFile))) Then _ TbFLD.Text = GetFilenameWithoutDirectory(FullLoadCurveFileBrowser.Files(0), GetPath(_engFile)) End Sub Private Sub BtFLDopen_Click(sender As Object, e As EventArgs) Handles BtFLDopen.Click Dim fldfile As String - fldfile = fFileRepl(TbFLD.Text, GetPath(_engFile)) + fldfile = FileRepl(TbFLD.Text, GetPath(_engFile)) - If fldfile <> sKey.NoFile AndAlso File.Exists(fldfile) Then + If fldfile <> NoFile AndAlso File.Exists(fldfile) Then OpenFiles(fldfile) End If End Sub @@ -518,4 +523,10 @@ Public Class EngineForm MsgBox("Failed to load file! " & ex.Message, MsgBoxStyle.Critical) End Try End Sub + + Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TbWHTCEngineering.TextChanged + End Sub + + Private Sub Label9_Click(sender As Object, e As EventArgs) Handles lblWhtcEngineering.Click + End Sub End Class diff --git a/VECTO/GUI/FileSignDialog.vb b/VECTO/GUI/FileSignDialog.vb index 9431398f0b607d11737567a8a38100a12270889f..0e96fa5cc1220fce90cfdbc98f12a53718108a3b 100644 --- a/VECTO/GUI/FileSignDialog.vb +++ b/VECTO/GUI/FileSignDialog.vb @@ -47,7 +47,7 @@ Public Class FileSignDialog For Each listViewItem In lvFiles.Items - Lic.FileSigning.AddFile(fFileRepl(listViewItem.SubItems(0).Text, mainDirectory)) + Lic.FileSigning.AddFile(FileRepl(listViewItem.SubItems(0).Text, mainDirectory)) listViewItem.SubItems(1).Text = "" listViewItem.ForeColor = Color.Black Next @@ -121,7 +121,7 @@ Public Class FileSignDialog End Sub 'Clear form - Private Sub ClearForm(ClearFileList As Boolean) + Private Sub ClearForm(clearFileList As Boolean) If ClearFileList Then lvFiles.Items.Clear() TbLicStr.Text = "" TbPubKey.Text = "" @@ -141,7 +141,7 @@ Public Class FileSignDialog Dim fb As New FileBrowser("sig", False, True) fb.Extensions = New String() {"vsig"} - If fb.CustomDialog(TbSigFile.Text, False, False, tFbExtMode.ForceExt, False, "vsig") Then + If fb.CustomDialog(TbSigFile.Text, False, False, FileBrowserFileExtensionMode.ForceExt, False, "vsig") Then TbSigFile.Text = fb.Files(0) End If @@ -205,7 +205,7 @@ Public Class FileSignDialog 'Remove File Private Sub RemoveFile() - Dim i0 As Int16 + Dim i0 As Integer If lvFiles.Items.Count = 0 Then Exit Sub diff --git a/VECTO/GUI/GUI_Subs.vb b/VECTO/GUI/GUI_Subs.vb index 43cc81fd325193c22c9de01df02e64d6cfdeab4e..cac6fccedca58d1e7023a27ad86f2c7e5956655e 100644 --- a/VECTO/GUI/GUI_Subs.vb +++ b/VECTO/GUI/GUI_Subs.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. + ''' <summary> ''' Methods for GUI interaction ''' </summary> @@ -20,7 +21,7 @@ Public Module GUI_Subs 'Status Message => Msg-Listview Public Sub WorkerMsg(ByVal id As MessageType, ByVal msg As String, ByVal source As String, Optional ByVal link As String = "") - Dim workProg As New BackgroundWorkerMessage(tWorkMsgType.StatusListBox) + Dim workProg As New BackgroundWorkerMessage(WorkerMessageType.StatusListBox) workProg.ID = id Select Case id Case MessageType.Err @@ -41,8 +42,8 @@ Public Module GUI_Subs 'Status message ' ReSharper disable once InconsistentNaming - Public Sub GUIMsg(ByVal ID As MessageType, ByVal Msg As String) - MainForm.MSGtoForm(ID, Msg, "", "") + Public Sub GUIMsg(ByVal id As MessageType, ByVal msg As String) + MainForm.MSGtoForm(id, msg, "", "") End Sub 'Statusbar @@ -59,7 +60,7 @@ Public Module GUI_Subs 'Class used to pass Messages from BackgroundWorker to GUI Private Class BackgroundWorkerMessage - Public Sub New(msgTarget As tWorkMsgType) + Public Sub New(msgTarget As WorkerMessageType) Source = "" End Sub @@ -82,27 +83,26 @@ Public Module GUI_Subs #Region "Textbox text conversion for file open/save operations" 'Text-to-number - Public Function fTextboxToNumString(ByVal txt As String) As String - If Not IsNumeric(txt) Then - Return "0" - Else - Return txt - End If - End Function + 'Public Function ParseNumber(txt As String) As Double + ' If Not IsNumeric(txt) Then + ' Return 0 + ' End If + ' Return Double.Parse(txt, CultureInfo.InvariantCulture) + 'End Function #End Region 'Open File with software defined in Config Public Function FileOpenAlt(ByVal file As String) As Boolean - Dim PSI As New ProcessStartInfo + Dim psi As New ProcessStartInfo If Not IO.File.Exists(file) Then Return False - PSI.FileName = Cfg.OpenCmd - PSI.Arguments = ChrW(34) & file & ChrW(34) + psi.FileName = Cfg.OpenCmd + psi.Arguments = ChrW(34) & file & ChrW(34) Try - Process.Start(PSI) + Process.Start(psi) Return True Catch ex As Exception Return False diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb index d2cfded1da87282eb9a8b18f99da2d2c5d2f1609..851ee73589574087809f43e115b4b2bf3aceb29f 100644 --- a/VECTO/GUI/GearboxForm.vb +++ b/VECTO/GUI/GearboxForm.vb @@ -19,10 +19,12 @@ Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.Configuration +Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Impl +Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ''' <summary> @@ -39,14 +41,12 @@ Public Class GearboxForm MaxTorque = 4 End Enum - Private GbxFile As String = "" + Private _gbxFile As String = "" Public AutoSendTo As Boolean = False Public JobDir As String = "" - Private GearDia As GearboxGearDialog + Private _gearDialog As GearboxGearDialog - Private Init As Boolean = False - - Private Changed As Boolean = False + Private _changed As Boolean = False 'Before closing Editor: Check if file was changed and ask to save. Private Sub F_GBX_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing @@ -58,8 +58,7 @@ Public Class GearboxForm 'Initialise. Private Sub F_GBX_Load(sender As Object, e As EventArgs) Handles Me.Load - Init = False - GearDia = New GearboxGearDialog + _gearDialog = New GearboxGearDialog PnInertiaTI.Enabled = Not Cfg.DeclMode GrGearShift.Enabled = Not Cfg.DeclMode @@ -81,36 +80,34 @@ Public Class GearboxForm .Select(Function(type) New With {Key .Value = type, .Label = type.GetLabel()}).ToList() End If - Init = True - DeclInit() - Changed = False - newGBX() + _changed = False + NewGbx() End Sub 'Set generic values for Declaration mode. Private Sub DeclInit() - Dim GStype As GearboxType + Dim gbxType As GearboxType Dim lv0 As ListViewItem If Not Cfg.DeclMode Then Exit Sub - TBI_getr.Text = DeclarationData.Gearbox.Inertia.Value() 'cDeclaration.GbInertia + TBI_getr.Text = DeclarationData.Gearbox.Inertia.ToGUIFormat() 'cDeclaration.GbInertia - GStype = CbGStype.SelectedValue 'CType(Me.CbGStype.SelectedIndex, tGearbox) + gbxType = CType(CbGStype.SelectedValue, GearboxType) 'CType(Me.CbGStype.SelectedIndex, tGearbox) - TbTracInt.Text = GStype.TractionInterruption().Value() - TbShiftTime.Text = DeclarationData.Gearbox.MinTimeBetweenGearshifts.Value() 'cDeclaration.ShiftTime(GStype) + TbTracInt.Text = gbxType.TractionInterruption().ToGUIFormat() + TbShiftTime.Text = DeclarationData.Gearbox.MinTimeBetweenGearshifts.ToGUIFormat() 'cDeclaration.ShiftTime(GStype) - TbTqResv.Text = DeclarationData.Gearbox.TorqueReserve ' cDeclaration.TqResv - TbTqResvStart.Text = DeclarationData.Gearbox.TorqueReserveStart 'cDeclaration.TqResvStart - TbStartSpeed.Text = DeclarationData.Gearbox.StartSpeed.Value() 'cDeclaration.StartSpeed - TbStartAcc.Text = DeclarationData.Gearbox.StartAcceleration.Value() ' cDeclaration.StartAcc + TbTqResv.Text = DeclarationData.Gearbox.TorqueReserve.ToGUIFormat() ' cDeclaration.TqResv + TbTqResvStart.Text = DeclarationData.Gearbox.TorqueReserveStart.ToGUIFormat() 'cDeclaration.TqResvStart + TbStartSpeed.Text = DeclarationData.Gearbox.StartSpeed.ToGUIFormat() 'cDeclaration.StartSpeed + TbStartAcc.Text = DeclarationData.Gearbox.StartAcceleration.ToGUIFormat() ' cDeclaration.StartAcc - tbUpshiftMinAcceleration.Text = DeclarationData.Gearbox.UpshiftMinAcceleration.Value() - tbDownshiftAfterUpshift.Text = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay.Value() - tbUpshiftAfterDownshift.Text = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay.Value() + tbUpshiftMinAcceleration.Text = DeclarationData.Gearbox.UpshiftMinAcceleration.ToGUIFormat() + tbDownshiftAfterUpshift.Text = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay.ToGUIFormat() + tbUpshiftAfterDownshift.Text = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay.ToGUIFormat() 'ChTCon.Checked = GStype.AutomaticTransmission() For Each lv0 In LvGears.Items @@ -121,11 +118,11 @@ Public Class GearboxForm #Region "Toolbar" Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click - newGBX() + NewGbx() End Sub Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click - If GearboxFileBrowser.OpenDialog(GbxFile) Then openGBX(GearboxFileBrowser.Files(0)) + If GearboxFileBrowser.OpenDialog(_gbxFile) Then OpenGbx(GearboxFileBrowser.Files(0)) End Sub Private Sub ToolStripBtSave_Click(sender As Object, e As EventArgs) Handles ToolStripBtSave.Click @@ -140,7 +137,7 @@ Public Class GearboxForm If ChangeCheckCancel() Then Exit Sub - If GbxFile = "" Then + If _gbxFile = "" Then If MsgBox("Save file now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then If Not SaveOrSaveAs(True) Then Exit Sub Else @@ -151,22 +148,22 @@ Public Class GearboxForm If Not VectoJobForm.Visible Then JobDir = "" VectoJobForm.Show() - VectoJobForm.VECTOnew() + VectoJobForm.VectoNew() Else VectoJobForm.WindowState = FormWindowState.Normal End If - VectoJobForm.TbGBX.Text = GetFilenameWithoutDirectory(GbxFile, JobDir) + VectoJobForm.TbGBX.Text = GetFilenameWithoutDirectory(_gbxFile, JobDir) End Sub 'Help 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 = + Dim browserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString - Dim DefaultBrowserPath As String = - Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - Process.Start(DefaultBrowserPath, + Dim defaultBrowserPath As String = + Regex.Match(browserRegistryString, "(\"".*?\"")").Captures(0).ToString + Process.Start(defaultBrowserPath, String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#gearbox-editor")) Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) @@ -176,7 +173,7 @@ Public Class GearboxForm #End Region 'New file - Private Sub newGBX() + Private Sub NewGbx() 'Dim lvi As ListViewItem If ChangeCheckCancel() Then Exit Sub @@ -189,15 +186,19 @@ Public Class GearboxForm LvGears.Items.Clear() - LvGears.Items.Add(CreateListviewItem("Axle", "-", 0, 0, "", "")) + LvGears.Items.Add(CreateListviewItem("Axle", 1, "1", "", "")) 'Me.ChSkipGears.Checked = False 'set by CbGStype.SelectedIndexChanged 'Me.ChShiftInside.Checked = False 'set by CbGStype.SelectedIndexChanged - TbTqResv.Text = "" - TbShiftTime.Text = "" - TbTqResvStart.Text = "" - TbStartSpeed.Text = "" - TbStartAcc.Text = "" + TbTqResv.Text = DeclarationData.Gearbox.TorqueReserve.ToGUIFormat() + TbShiftTime.Text = DeclarationData.Gearbox.MinTimeBetweenGearshifts.ToGUIFormat() + TbTqResvStart.Text = DeclarationData.Gearbox.TorqueReserveStart.ToGUIFormat() + TbStartSpeed.Text = DeclarationData.Gearbox.StartSpeed.ToGUIFormat() ' in m/s! + TbStartAcc.Text = DeclarationData.Gearbox.StartAcceleration.ToGUIFormat() + + tbUpshiftMinAcceleration.Text = DeclarationData.Gearbox.UpshiftMinAcceleration.ToGUIFormat() + tbDownshiftAfterUpshift.Text = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay.ToGUIFormat() + tbUpshiftAfterDownshift.Text = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay.ToGUIFormat() 'ChTCon.Checked = False 'set by CbGStype.SelectedIndexChanged TbTCfile.Text = "" @@ -206,32 +207,26 @@ Public Class GearboxForm DeclInit() - GbxFile = "" + _gbxFile = "" Text = "GBX Editor" LbStatus.Text = "" - Changed = False + + _changed = False UpdatePic() End Sub 'Open file - Public Sub openGBX(ByVal file As String) - Dim GBX0 As Gearbox - Dim i As Integer - 'Dim lv0 As ListViewItem + Public Sub OpenGbx(file As String) If ChangeCheckCancel() Then Exit Sub - GBX0 = New Gearbox - - GBX0.FilePath = file - - If Not GBX0.ReadFile Then - MsgBox("Cannot read " & file & "!") - Exit Sub - End If + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), + IEngineeringInputDataProvider) + Dim gearbox As IGearboxEngineeringInputData = inputData.GearboxInputData + Dim axlegear As IAxleGearInputData = inputData.AxleGearInputData - If Cfg.DeclMode <> GBX0.SavedInDeclMode Then + If Cfg.DeclMode <> gearbox.SavedInDeclarationMode Then Select Case WrongMode() Case 1 Close() @@ -239,57 +234,55 @@ Public Class GearboxForm MainForm.OpenVectoFile(file) Case -1 Exit Sub - Case Else '0 - 'Continue... End Select End If - TbName.Text = GBX0.ModelName - TbTracInt.Text = GBX0.TracIntrSi.ToString - TBI_getr.Text = GBX0.GbxInertia.ToString - - 'ChTCon.Checked = GBX0.TorqueConverterEnabled + Dim basePath As String = Path.GetDirectoryName(file) + TbName.Text = gearbox.ModelName + TbTracInt.Text = gearbox.TractionInterruption.ToGUIFormat() + TBI_getr.Text = gearbox.Inertia.ToGUIFormat() LvGears.Items.Clear() - For i = 0 To GBX0.GearRatios.Count - 1 - - If i = 0 Then - 'lv0 = New ListViewItem("Axle") - LvGears.Items.Add(CreateListviewItem("Axle", "-", GBX0.GearRatios(i), GBX0.GearLossMap(i, True), - GBX0.ShiftPolygonFile(i, True), - GBX0.MaxTorque(i))) - Else - 'lv0 = New ListViewItem(i.ToString("00")) - LvGears.Items.Add(CreateListviewItem(i.ToString("00"), "-", GBX0.GearRatios(i), GBX0.GearLossMap(i, True), - GBX0.ShiftPolygonFile(i, True), GBX0.MaxTorque(i))) - End If + LvGears.Items.Add(CreateListviewItem("Axle", axlegear.Ratio, + If(axlegear.LossMap Is Nothing, axlegear.Efficiency.ToGUIFormat(), + GetRelativePath(axlegear.LossMap.Source, basePath)), "", "")) + For Each gear As ITransmissionInputData In gearbox.Gears + LvGears.Items.Add(CreateListviewItem(gear.Gear.ToString("00"), gear.Ratio, + If(gear.LossMap Is Nothing, gear.Efficiency.ToGUIFormat(), gear.LossMap.Source), + If(gear.ShiftPolygon Is Nothing, "", GetRelativePath(gear.ShiftPolygon.Source, basePath)), + If(gear.MaxTorque Is Nothing, "", gear.MaxTorque.ToGUIFormat()))) Next - ChSkipGears.Checked = GBX0.SkipGears - TbTqResv.Text = GBX0.TorqueResv.ToString - TbShiftTime.Text = GBX0.ShiftTime.ToString - TbTqResvStart.Text = GBX0.TorqueResvStart.ToString - TbStartSpeed.Text = GBX0.StartSpeed.ToString - TbStartAcc.Text = GBX0.StartAcc.ToString - ChShiftInside.Checked = GBX0.ShiftInside - - TbTCfile.Text = GBX0.TorqueConverterFile(True) - TbTCrefrpm.Text = GBX0.TorqueConverterReferenceRpm - TbTCinertia.Text = GBX0.TorqueConverterInertia - TBTCShiftPolygon.Text = GBX0.TorqueConverterShiftPolygonFile - - tbUpshiftMinAcceleration.Text = GBX0.UpshiftMinAcceleration - tbDownshiftAfterUpshift.Text = GBX0.DownshiftAfterUpshift - tbUpshiftAfterDownshift.Text = GBX0.UpshiftAfterDownshift - - CbGStype.SelectedValue = GBX0.Type - 'If CType(GBX0.gs_Type, Integer) <= Me.CbGStype.Items.Count - 1 Then - ' Me.CbGStype.SelectedIndex = CType(GBX0.gs_Type, Integer) - 'Else - ' Me.CbGStype.SelectedIndex = 0 - 'End If + ChSkipGears.Checked = gearbox.SkipGears + TbTqResv.Text = gearbox.TorqueReserve.ToGUIFormat() + TbShiftTime.Text = gearbox.ShiftTime.ToGUIFormat() + TbTqResvStart.Text = gearbox.StartTorqueReserve.ToGUIFormat() + TbStartSpeed.Text = gearbox.StartSpeed.ToGUIFormat() + TbStartAcc.Text = gearbox.StartAcceleration.ToGUIFormat() + ChShiftInside.Checked = gearbox.EarlyShiftUp + + Dim torqueConverter As ITorqueConverterEngineeringInputData = gearbox.TorqueConverter + If torqueConverter Is Nothing Then + TbTCfile.Text = "" + TbTCrefrpm.Text = "" + TbTCinertia.Text = "" + TBTCShiftPolygon.Text = "" + Else + TbTCfile.Text = If(torqueConverter.TCData Is Nothing, "", GetRelativePath(torqueConverter.TCData.Source, basePath)) + TbTCrefrpm.Text = torqueConverter.ReferenceRPM.AsRPM.ToGUIFormat() + TbTCinertia.Text = torqueConverter.Inertia.ToGUIFormat() + TBTCShiftPolygon.Text = + If(torqueConverter.ShiftPolygon Is Nothing, "", GetRelativePath(torqueConverter.ShiftPolygon.Source, basePath)) + End If + + tbUpshiftMinAcceleration.Text = gearbox.UpshiftMinAcceleration.ToGUIFormat() + tbDownshiftAfterUpshift.Text = gearbox.DownshiftAferUpshiftDelay.ToGUIFormat() + tbUpshiftAfterDownshift.Text = gearbox.UpshiftAfterDownshiftDelay.ToGUIFormat() + + CbGStype.SelectedValue = gearbox.Type + DeclInit() @@ -297,90 +290,90 @@ Public Class GearboxForm GearboxFileBrowser.UpdateHistory(file) Text = GetFilenameWithoutPath(file, True) LbStatus.Text = "" - GbxFile = file + _gbxFile = file Activate() - Changed = False + _changed = False UpdatePic() End Sub - Private Function CreateListviewItem(gear As String, tc As String, ratio As Single, getrMap As String, - shiftPolygon As String, fldFile As String) As ListViewItem + Private Function CreateListviewItem(gear As String, ratio As Double, getrMap As String, + shiftPolygon As String, maxTorque As String) As ListViewItem Dim retVal As ListViewItem = New ListViewItem(gear) 'retVal.SubItems.Add(tc) - retVal.SubItems.Add(ratio) + retVal.SubItems.Add(ratio.ToGUIFormat()) retVal.SubItems.Add(getrMap) retVal.SubItems.Add(shiftPolygon) - retVal.SubItems.Add(fldFile) + retVal.SubItems.Add(maxTorque) Return retVal End Function 'Save or Save As function = true if file is saved - Private Function SaveOrSaveAs(ByVal SaveAs As Boolean) As Boolean - If GbxFile = "" Or SaveAs Then - If GearboxFileBrowser.SaveDialog(GbxFile) Then - GbxFile = GearboxFileBrowser.Files(0) + Private Function SaveOrSaveAs(saveAs As Boolean) As Boolean + If _gbxFile = "" Or saveAs Then + If GearboxFileBrowser.SaveDialog(_gbxFile) Then + _gbxFile = GearboxFileBrowser.Files(0) Else Return False End If End If - Return saveGBX(GbxFile) + Return SaveGbx(_gbxFile) End Function 'Save file - Private Function saveGBX(ByVal file As String) As Boolean - Dim GBX0 As Gearbox - Dim i As Int16 + Private Function SaveGbx(file As String) As Boolean + Dim gearbox As Gearbox + Dim i As Integer - GBX0 = New Gearbox - GBX0.FilePath = file + gearbox = New Gearbox + gearbox.FilePath = file - GBX0.ModelName = TbName.Text - If Trim(GBX0.ModelName) = "" Then GBX0.ModelName = "Undefined" + gearbox.ModelName = TbName.Text + If Trim(gearbox.ModelName) = "" Then gearbox.ModelName = "Undefined" - GBX0.TracIntrSi = fTextboxToNumString(TbTracInt.Text) - GBX0.GbxInertia = fTextboxToNumString(TBI_getr.Text) + gearbox.TracIntrSi = TbTracInt.Text.ToDouble(0) + gearbox.GbxInertia = TBI_getr.Text.ToDouble(0) For i = 0 To LvGears.Items.Count - 1 'GBX0.IsTCgear.Add(Me.LvGears.Items(i).SubItems(GearboxTbl.TorqueConverter).Text = "on" And i > 0) - GBX0.GearRatios.Add(CSng(LvGears.Items(i).SubItems(GearboxTbl.Ratio).Text)) - GBX0.GearLossmaps.Add(New SubPath) - GBX0.GearLossMap(i) = LvGears.Items(i).SubItems(GearboxTbl.LossMapEfficiency).Text - GBX0.GearshiftFiles.Add(New SubPath) - GBX0.ShiftPolygonFile(i) = LvGears.Items(i).SubItems(GearboxTbl.ShiftPolygons).Text + gearbox.GearRatios.Add(CSng(LvGears.Items(i).SubItems(GearboxTbl.Ratio).Text)) + gearbox.GearLossmaps.Add(New SubPath) + gearbox.GearLossMap(i) = LvGears.Items(i).SubItems(GearboxTbl.LossMapEfficiency).Text + gearbox.GearshiftFiles.Add(New SubPath) + gearbox.ShiftPolygonFile(i) = LvGears.Items(i).SubItems(GearboxTbl.ShiftPolygons).Text 'GBX0.FldFiles.Add(New cSubPath) 'GBX0.FldFile(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.MaxTorque).Text - GBX0.MaxTorque.Add(LvGears.Items(i).SubItems(GearboxTbl.MaxTorque).Text) + gearbox.MaxTorque.Add(LvGears.Items(i).SubItems(GearboxTbl.MaxTorque).Text) Next - GBX0.TorqueResv = fTextboxToNumString(TbTqResv.Text) - GBX0.SkipGears = ChSkipGears.Checked - GBX0.ShiftTime = fTextboxToNumString(TbShiftTime.Text) - GBX0.TorqueResvStart = fTextboxToNumString(TbTqResvStart.Text) - GBX0.StartSpeed = fTextboxToNumString(TbStartSpeed.Text) - GBX0.StartAcc = fTextboxToNumString(TbStartAcc.Text) - GBX0.ShiftInside = ChShiftInside.Checked + gearbox.TorqueResv = TbTqResv.Text.ToDouble(0) + gearbox.SkipGears = ChSkipGears.Checked + gearbox.ShiftTime = TbShiftTime.Text.ToDouble(0) + gearbox.TorqueResvStart = TbTqResvStart.Text.ToDouble(0) + gearbox.StartSpeed = TbStartSpeed.Text.ToDouble(0) + gearbox.StartAcc = TbStartAcc.Text.ToDouble(0) + gearbox.ShiftInside = ChShiftInside.Checked - GBX0.Type = CbGStype.SelectedValue + gearbox.Type = CType(CbGStype.SelectedValue, GearboxType) - GBX0.TorqueConverterEnabled = GBX0.Type.AutomaticTransmission() - GBX0.TorqueConverterFile = TbTCfile.Text - GBX0.TorqueConverterReferenceRpm = fTextboxToNumString(TbTCrefrpm.Text) - GBX0.TorqueConverterInertia = fTextboxToNumString(TbTCinertia.Text) - GBX0.TorqueConverterShiftPolygonFile = TBTCShiftPolygon.Text + gearbox.TorqueConverterEnabled = gearbox.Type.AutomaticTransmission() + gearbox.TorqueConverterFile = TbTCfile.Text + gearbox.TorqueConverterReferenceRpm = TbTCrefrpm.Text.ToDouble(0) + gearbox.TorqueConverterInertia = TbTCinertia.Text.ToDouble(0) + gearbox.TorqueConverterShiftPolygonFile = TBTCShiftPolygon.Text - GBX0.DownshiftAfterUpshift = fTextboxToNumString(tbDownshiftAfterUpshift.Text) - GBX0.UpshiftAfterDownshift = fTextboxToNumString(tbUpshiftAfterDownshift.Text) - GBX0.UpshiftMinAcceleration = fTextboxToNumString(tbUpshiftMinAcceleration.Text) + gearbox.DownshiftAfterUpshift = tbDownshiftAfterUpshift.Text.ToDouble(0) + gearbox.UpshiftAfterDownshift = tbUpshiftAfterDownshift.Text.ToDouble(0) + gearbox.UpshiftMinAcceleration = tbUpshiftMinAcceleration.Text.ToDouble(0) - If Not GBX0.SaveFile Then + If Not gearbox.SaveFile Then MsgBox("Cannot safe to " & file, MsgBoxStyle.Critical) Return False End If If AutoSendTo Then If VectoJobForm.Visible Then - If UCase(fFileRepl(VectoJobForm.TbGBX.Text, JobDir)) <> UCase(file) Then _ + If UCase(FileRepl(VectoJobForm.TbGBX.Text, JobDir)) <> UCase(file) Then _ VectoJobForm.TbGBX.Text = GetFilenameWithoutDirectory(file, JobDir) VectoJobForm.UpdatePic() End If @@ -390,7 +383,7 @@ Public Class GearboxForm Text = GetFilenameWithoutPath(file, True) LbStatus.Text = "" - Changed = False + _changed = False Return True End Function @@ -399,23 +392,23 @@ Public Class GearboxForm 'Change Status ändern |@@| Change Status change Private Sub Change() - If Not Changed Then + If Not _changed Then LbStatus.Text = "Unsaved changes in current file" - Changed = True + _changed = True End If End Sub ' "Save changes ?" ...liefert True wenn User Vorgang abbricht |@@| Save changes? "... Returns True if user aborts Private Function ChangeCheckCancel() As Boolean - If Changed Then + If _changed Then Select Case MsgBox("Save changes ?", MsgBoxStyle.YesNoCancel) Case MsgBoxResult.Yes Return Not SaveOrSaveAs(False) Case MsgBoxResult.Cancel Return True Case Else 'MsgBoxResult.No - Changed = False + _changed = False Return False End Select @@ -507,14 +500,14 @@ Public Class GearboxForm 'Enable/Disable settings for specific transmission types Private Sub CbGStype_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbGStype.SelectedIndexChanged - Dim GStype As GearboxType = CbGStype.SelectedItem.Value + Dim gStype As GearboxType = CType(CbGStype.SelectedValue, GearboxType) Change() - ChShiftInside.Enabled = (GStype.EarlyShiftGears()) - ChSkipGears.Enabled = (GStype.SkipGears()) + ChShiftInside.Enabled = (gStype.EarlyShiftGears()) + ChSkipGears.Enabled = (gStype.SkipGears()) 'ChTCon.Enabled = (GStype.AutomaticTransmission()) - PnTC.Enabled = GStype.AutomaticTransmission() + PnTC.Enabled = gStype.AutomaticTransmission() End Sub @@ -559,35 +552,35 @@ Public Class GearboxForm Do 'GearDia.ChIsTCgear.Enabled = (Me.ChTCon.Checked And Me.LvGears.SelectedIndices(0) > 0) - GearDia.PnShiftPoly.Enabled = (Not Cfg.DeclMode And LvGears.SelectedIndices(0) > 0) - GearDia.PnFld.Enabled = (LvGears.SelectedIndices(0) > 0) - GearDia.GbxPath = GetPath(GbxFile) - GearDia.TbGear.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.GearNr).Text - GearDia.TbRatio.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text - GearDia.TbMapPath.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text + _gearDialog.PnShiftPoly.Enabled = (Not Cfg.DeclMode And LvGears.SelectedIndices(0) > 0) + _gearDialog.PnFld.Enabled = (LvGears.SelectedIndices(0) > 0) + _gearDialog.GbxPath = GetPath(_gbxFile) + _gearDialog.TbGear.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.GearNr).Text + _gearDialog.TbRatio.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text + _gearDialog.TbMapPath.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text If LvGears.SelectedIndices(0) > 0 Then - GearDia.TbShiftPolyFile.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text - GearDia.TbMaxTorque.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text + _gearDialog.TbShiftPolyFile.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text + _gearDialog.TbMaxTorque.Text = LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text Else - GearDia.TbShiftPolyFile.Text = "" - GearDia.TbMaxTorque.Text = "" + _gearDialog.TbShiftPolyFile.Text = "" + _gearDialog.TbMaxTorque.Text = "" End If If LvGears.SelectedItems(0).Index = 0 Then - GearDia.BtPrevious.Enabled = False + _gearDialog.BtPrevious.Enabled = False Else - GearDia.BtPrevious.Enabled = True + _gearDialog.BtPrevious.Enabled = True End If - If GearDia.ShowDialog = DialogResult.OK Then + If _gearDialog.ShowDialog = DialogResult.OK Then 'Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.TorqueConverter).Text = "-" - LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text = GearDia.TbRatio.Text - LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text = GearDia.TbMapPath.Text - LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text = GearDia.TbShiftPolyFile.Text - LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text = GearDia.TbMaxTorque.Text + LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text = _gearDialog.TbRatio.Text + LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text = _gearDialog.TbMapPath.Text + LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text = _gearDialog.TbShiftPolyFile.Text + LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text = _gearDialog.TbMaxTorque.Text UpdatePic() Change() @@ -598,24 +591,24 @@ Public Class GearboxForm End If - If GearDia.NextGear Then + If _gearDialog.NextGear Then If LvGears.Items.Count - 1 = LvGears.SelectedIndices(0) Then AddGear() LvGears.Items(LvGears.SelectedIndices(0) + 1).Selected = True End If - If GearDia.PreviousGear AndAlso LvGears.SelectedIndices(0) > 0 Then + If _gearDialog.PreviousGear AndAlso LvGears.SelectedIndices(0) > 0 Then LvGears.Items(LvGears.SelectedIndices(0) - 1).Selected = True End If - Loop Until Not (GearDia.NextGear OrElse GearDia.PreviousGear) + Loop Until Not (_gearDialog.NextGear OrElse _gearDialog.PreviousGear) End Sub 'Add Gear Private Sub AddGear() Dim lvi As ListViewItem - lvi = CreateListviewItem(LvGears.Items.Count.ToString("00"), "-", 1, "", "", "") + lvi = CreateListviewItem(LvGears.Items.Count.ToString("00"), 1, "", "", "") LvGears.Items.Add(lvi) @@ -627,9 +620,9 @@ Public Class GearboxForm End Sub 'Remove Gear - Private Sub RemoveGear(ByVal NoChange As Boolean) - Dim i0 As Int16 - Dim i As Int16 + Private Sub RemoveGear(noChange As Boolean) + Dim i0 As Integer + Dim i As Integer Dim lv0 As ListViewItem If LvGears.Items.Count < 2 Then Exit Sub @@ -657,7 +650,7 @@ Public Class GearboxForm LvGears.Focus() UpdatePic() - If Not NoChange Then Change() + If Not noChange Then Change() End Sub @@ -666,13 +659,13 @@ Public Class GearboxForm #Region "Open File Context Menu" - Private CmFiles As String() + Private _contextMenuFiles As String() Private Sub OpenFiles(ParamArray files() As String) If files.Length = 0 Then Exit Sub - CmFiles = files + _contextMenuFiles = files OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName @@ -681,14 +674,14 @@ Public Class GearboxForm Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenWithToolStripMenuItem.Click - If Not FileOpenAlt(CmFiles(0)) Then MsgBox("Failed to open file!") + If Not FileOpenAlt(_contextMenuFiles(0)) Then MsgBox("Failed to open file!") End Sub Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ShowInFolderToolStripMenuItem.Click - If File.Exists(CmFiles(0)) Then + If File.Exists(_contextMenuFiles(0)) Then Try - Process.Start("explorer", "/select,""" & CmFiles(0) & "") + Process.Start("explorer", "/select,""" & _contextMenuFiles(0) & "") Catch ex As Exception MsgBox("Failed to open file!") End Try @@ -702,144 +695,98 @@ Public Class GearboxForm Private Sub UpdatePic() - Dim f As CsvFile Dim path As String - Dim lM As List(Of Single) = Nothing - Dim lup As List(Of Single) = Nothing - Dim ldown As List(Of Single) = Nothing - Dim line As String() - Dim MyChart As Chart + + Dim chart As Chart Dim s As Series Dim a As ChartArea - Dim img As Image - Dim Gear As Integer - Dim fldOK As Boolean - Dim fldpath As String - Dim FLD0 As EngineFullLoadCurve = Nothing - Dim ShiftOK As Boolean + Dim img As Bitmap + Dim gear As Integer + 'Dim fullLoadCurve As EngineFullLoadCurve = Nothing + 'Dim shiftOk As Boolean PicBox.Image = Nothing - Try - - 'Check Files - If LvGears.Items.Count > 1 Then - - If LvGears.SelectedItems.Count > 0 AndAlso LvGears.SelectedIndices(0) > 0 Then - path = fFileRepl(LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(GbxFile)) - 'fldpath = fFileRepl(LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text, fPATH(GbxFile)) - Gear = LvGears.SelectedIndices(0) - Else - path = fFileRepl(LvGears.Items(1).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(GbxFile)) - 'fldpath = fFileRepl(Me.LvGears.Items(1).SubItems(GearboxTbl.MaxTorque).Text, fPATH(GbxFile)) - Gear = 1 - End If - - f = New CsvFile - ShiftOK = f.OpenRead(path) - - fldpath = VectoJobForm.FLDfile + Dim shiftPolygon As ShiftPolygon = Nothing + 'Dim engineFld As FullLoadCurve - fldOK = Not IsNothing(fldpath) AndAlso fldpath.Trim <> "" - - If fldOK Then - FLD0 = New EngineFullLoadCurve - FLD0.FilePath = fldpath - fldOK = FLD0.ReadFile(True, False) - End If + If LvGears.Items.Count <= 1 Then Exit Sub + Try + If LvGears.SelectedItems.Count > 0 AndAlso LvGears.SelectedIndices(0) > 0 Then + path = FileRepl(LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(_gbxFile)) + gear = LvGears.SelectedIndices(0) Else - - Exit Sub - + path = FileRepl(LvGears.Items(1).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(_gbxFile)) + gear = 1 End If + shiftPolygon = ShiftPolygonReader.ReadFromFile(path) + Catch ex As Exception - Exit Sub End Try - 'Read ShiftPolygon - If ShiftOK Then - - 'Header - f.ReadLine() - - Try - lM = New List(Of Single) - lup = New List(Of Single) - ldown = New List(Of Single) - - Do While Not f.EndOfFile - line = f.ReadLine - lM.Add(CSng(line(0))) - lup.Add(CSng(line(1))) - ldown.Add(CSng(line(2))) - Loop - - f.Close() - - Catch ex As Exception - f.Close() - Exit Sub - End Try - - If lM.Count < 2 Then ShiftOK = False - - End If - - - 'Create plot - If Not ShiftOK And Not fldOK Then Exit Sub - - MyChart = New Chart - MyChart.Width = PicBox.Width - MyChart.Height = PicBox.Height + chart = New Chart + chart.Width = PicBox.Width + chart.Height = PicBox.Height a = New ChartArea 'Shiftpolygons from file - If ShiftOK Then + + If Not shiftPolygon Is Nothing Then s = New Series - s.Points.DataBindXY(lup, lM) + s.Points.DataBindXY(shiftPolygon.Upshift.Select(Function(x) x.AngularSpeed.AsRPM).ToArray(), + shiftPolygon.Upshift.Select(Function(x) x.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed s.Name = "Upshift curve" - MyChart.Series.Add(s) + chart.Series.Add(s) s = New Series - s.Points.DataBindXY(ldown, lM) + s.Points.DataBindXY(shiftPolygon.Downshift.Select(Function(x) x.AngularSpeed.AsRPM).ToArray(), + shiftPolygon.Downshift.Select(Function(x) x.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed s.Name = "Downshift curve" - MyChart.Series.Add(s) + chart.Series.Add(s) End If - Dim vectoJob As VectoJob = New VectoJob() With {.FilePath = VectoJobForm.VECTOfile} - Dim vectoOk As Boolean = vectoJob.ReadFile() - Dim vehicle As Vehicle = New Vehicle() With {.FilePath = vectoJob.PathVeh(False)} - Dim vehicleOk As Boolean = vehicle.ReadFile(False) + 'Dim vectoJob As VectoJob = New VectoJob() With {.FilePath = VectoJobForm.VECTOfile} + 'Dim vectoOk As Boolean = vectoJob.ReadFile() + Dim jobFile As String = VectoJobForm.VectoFile + If Not jobFile Is Nothing AndAlso File.Exists(jobFile) Then + + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadJsonJob(jobFile), + IEngineeringInputDataProvider) + If (inputData Is Nothing) Then + Exit Sub + End If + Dim vehicle As IVehicleEngineeringInputData = inputData.VehicleInputData + 'inputData = TryCast(JSONInputDataFactory.ReadComponentData(vectoJob.PathEng(False)), IEngineeringInputDataProvider) + Dim engine As IEngineEngineeringInputData = inputData.EngineInputData + Dim engineFld As EngineFullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve) - 'Fld - If fldOK AndAlso vectoOk AndAlso vehicleOk Then s = New Series - s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.MaxTorqueList) + s.Points.DataBindXY(engineFld.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + engineFld.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkBlue s.Name = "Full load" - MyChart.Series.Add(s) + chart.Series.Add(s) - If VectoJobForm.Visible AndAlso VectoJobForm.n_idle > 0 Then + If VectoJobForm.Visible AndAlso engine.IdleSpeed > 0 Then 'If FLD0.Init(VectoJobForm.n_idle) Then 'Dim fullLoadCurve As FullLoadCurve = ConvertToFullLoadCurve(FLD0.LnU, FLD0.LTq) Dim gears As IList(Of ITransmissionInputData) = ConvertToGears(LvGears.Items) - Dim shiftLines As ShiftPolygon = GetShiftLines(FLD0, vehicle, gears, Gear) + Dim shiftLines As ShiftPolygon = GetShiftLines(engine.IdleSpeed, engineFld, vehicle, gears, gear) If (CType(CbGStype.SelectedValue, GearboxType).ManualTransmission() AndAlso Not IsNothing(shiftLines)) Then @@ -847,33 +794,33 @@ Public Class GearboxForm 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) s.Points.DataBindXY( - shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) + shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.AsRPM). + ToArray(), + shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed s.BorderDashStyle = ChartDashStyle.Dash s.Name = "Upshift curve (generic)" - MyChart.Series.Add(s) + chart.Series.Add(s) s = New Series 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) s.Points.DataBindXY( - shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) + shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.AsRPM) _ + .ToArray(), + shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed s.BorderDashStyle = ChartDashStyle.Dash s.Name = "Downshift curve (generic)" - MyChart.Series.Add(s) + chart.Series.Add(s) End If 'End If End If - End If - a.Name = "main" a.AxisX.Title = "engine speed [1/min]" @@ -894,27 +841,28 @@ Public Class GearboxForm a.BackColor = Color.GhostWhite - MyChart.ChartAreas.Add(a) + chart.ChartAreas.Add(a) - MyChart.Titles.Add("Gear " & Gear & " shift polygons") - MyChart.Titles(0).Font = New Font("Helvetica", 12) + chart.Titles.Add("Gear " & gear & " shift polygons") + chart.Titles(0).Font = New Font("Helvetica", 12) - MyChart.Update() + chart.Update() - img = New Bitmap(MyChart.Width, MyChart.Height, PixelFormat.Format32bppArgb) - MyChart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height)) + img = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb) + chart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height)) PicBox.Image = img End Sub - Private Function GetShiftLines(engineFullLoadCurve As EngineFullLoadCurve, vehicle As Vehicle, - gears As IList(Of ITransmissionInputData), gear As UInteger) As ShiftPolygon - Dim engine As CombustionEngineData = ConvertToEngineData(engineFullLoadCurve, VectoJobForm.n_idle) + Private Function GetShiftLines(ByVal idleSpeed As PerSecond, engineFullLoadCurve As EngineFullLoadCurve, + vehicle As IVehicleEngineeringInputData, gears As IList(Of ITransmissionInputData), ByVal gear As Integer) _ + As ShiftPolygon + Dim engine As CombustionEngineData = ConvertToEngineData(engineFullLoadCurve, idleSpeed) If gears.Count <= 1 Then Return Nothing End If - Dim rDyn As Meter = (vehicle.DynamicTyreRadius / 1000.0).SI(Of Meter)() + Dim rDyn As Meter = vehicle.DynamicTyreRadius If rDyn.IsEqual(0) Then If (vehicle.Axles.Count < 2) Then Return Nothing @@ -941,7 +889,7 @@ Public Class GearboxForm Then retVal.Add( New TransmissionInputData() _ - With {.Ratio = Double.Parse(value, CultureInfo.InvariantCulture)}) + With {.Ratio = value}) End If Next @@ -954,14 +902,14 @@ Public Class GearboxForm 'Browse TC file Private Sub BtTCfileBrowse_Click(sender As Object, e As EventArgs) Handles BtTCfileBrowse.Click - If TorqueConverterFileBrowser.OpenDialog(fFileRepl(TbTCfile.Text, GetPath(GbxFile))) Then - TbTCfile.Text = GetFilenameWithoutDirectory(TorqueConverterFileBrowser.Files(0), GetPath(GbxFile)) + If TorqueConverterFileBrowser.OpenDialog(FileRepl(TbTCfile.Text, GetPath(_gbxFile))) Then + TbTCfile.Text = GetFilenameWithoutDirectory(TorqueConverterFileBrowser.Files(0), GetPath(_gbxFile)) End If End Sub 'Open TC file Private Sub BtTCfileOpen_Click(sender As Object, e As EventArgs) Handles BtTCfileOpen.Click - OpenFiles(fFileRepl(TbTCfile.Text, GetPath(GbxFile))) + OpenFiles(FileRepl(TbTCfile.Text, GetPath(_gbxFile))) End Sub @@ -979,8 +927,11 @@ Public Class GearboxForm End Sub Private Sub BtTCShiftFileBrowse_Click(sender As Object, e As EventArgs) Handles BtTCShiftFileBrowse.Click - If fbTCCShift.OpenDialog(fFileRepl(TBTCShiftPolygon.Text, GetPath(GbxFile))) Then - TBTCShiftPolygon.Text = GetFilenameWithoutDirectory(fbTCCShift.Files(0), GetPath(GbxFile)) + If TorqueConverterShiftPolygonFileBrowser.OpenDialog(FileRepl(TBTCShiftPolygon.Text, GetPath(_gbxFile))) Then + TBTCShiftPolygon.Text = GetFilenameWithoutDirectory(TorqueConverterShiftPolygonFileBrowser.Files(0), + GetPath(_gbxFile)) End If End Sub End Class + + diff --git a/VECTO/GUI/GearboxGearDialog.vb b/VECTO/GUI/GearboxGearDialog.vb index b4de37c3b57d2ed84bb65980a61d0ddf754a8f88..f7f89c398e06466813a3f8dd1185479c7f43ea9f 100644 --- a/VECTO/GUI/GearboxGearDialog.vb +++ b/VECTO/GUI/GearboxGearDialog.vb @@ -8,7 +8,16 @@ ' 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 +Imports System.ComponentModel.DataAnnotations +Imports System.IO +Imports System.Linq Imports System.Windows.Forms +Imports TUGraz.VectoCommon.Models +Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.Reader +Imports TUGraz.VectoCore.InputData.Reader.ComponentData +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ''' <summary> @@ -22,18 +31,10 @@ Public Class GearboxGearDialog 'Save and Close Private Sub OK_Button_Click(sender As Object, e As EventArgs) Handles OK_Button.Click - - If Not IsNumeric(TbRatio.Text) Then - MsgBox("Gear ratio is invalid!") - TbRatio.Focus() - TbRatio.SelectAll() - Exit Sub - End If - - If IsNumeric(TbMapPath.Text) AndAlso (TbMapPath.Text < 0 OrElse TbMapPath.Text > 1) Then - MsgBox("Efficiency is invalid! Must be between 0 and 1.") - TbMapPath.Focus() - TbMapPath.SelectAll() + Dim results As IList(Of String) = ValidateGear() + If results.Any() Then + MsgBox("Invalid input:" + Environment.NewLine + String.Join(Environment.NewLine, results), MsgBoxStyle.OkOnly, + "Failed to save gear") Exit Sub End If @@ -43,6 +44,45 @@ Public Class GearboxGearDialog Close() End Sub + Private Function ValidateGear() As IList(Of String) + If String.IsNullOrWhiteSpace(TbMapPath.Text) Then _ + Return New List(Of String)() From {"Loss-Map or Efficiency required"} + Try + Dim lossMapFile As String = + If(Not String.IsNullOrWhiteSpace(GbxPath), Path.Combine(GbxPath, TbMapPath.Text), TbMapPath.Text) + Dim lossmap As TransmissionLossMap + If File.Exists(lossMapFile) Then + lossmap = TransmissionLossMapReader.ReadFromFile(lossMapFile, TbRatio.Text.ToDouble(0), "gear " + TbGear.Text) + Else + lossmap = TransmissionLossMapReader.Create(TbMapPath.Text.ToDouble(0), TbRatio.Text.ToDouble(0), + "gear " + TbGear.Text) + End If + Dim shiftPolygon As ShiftPolygon = Nothing + If (Not String.IsNullOrWhiteSpace(TbShiftPolyFile.Text)) Then + Dim shiftPolygonFile As String = + If(Not String.IsNullOrWhiteSpace(GbxPath), Path.Combine(GbxPath, TbShiftPolyFile.Text), TbShiftPolyFile.Text) + shiftPolygon = ShiftPolygonReader.ReadFromFile(shiftPolygonFile) + End If + Dim gearData As GearData = New GearData() With { + .Ratio = TbRatio.Text.ToDouble(0), + .LossMap = lossmap, + .ShiftPolygon = shiftPolygon, + .MaxTorque = + If(String.IsNullOrWhiteSpace(TbMaxTorque.Text), Nothing, TbMaxTorque.Text.ToDouble().SI(Of NewtonMeter)) + } + Dim results As IList(Of ValidationResult) = + gearData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + + If (results.Any()) Then + Return results.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())).ToList() + End If + Catch ex As Exception + Return New List(Of String)() From {ex.Message} + End Try + + Return New List(Of String)() + End Function + 'Cancel Private Sub Cancel_Button_Click(sender As Object, e As EventArgs) Handles Cancel_Button.Click NextGear = False @@ -61,7 +101,7 @@ Public Class GearboxGearDialog Exit Sub End If - If IsNumeric(TbMapPath.Text) AndAlso (TbMapPath.Text < 0 OrElse TbMapPath.Text > 1) Then + If IsNumeric(TbMapPath.Text) AndAlso (TbMapPath.Text.ToDouble() < 0 OrElse TbMapPath.Text.ToDouble() > 1) Then MsgBox("Efficiency is invalid! Must be between 0 and 1.") TbMapPath.Focus() TbMapPath.SelectAll() @@ -76,14 +116,14 @@ Public Class GearboxGearDialog 'Browse for transmission loss map Private Sub BtBrowse_Click(sender As Object, e As EventArgs) Handles BtBrowse.Click - If TransmissionLossMapFileBrowser.OpenDialog(fFileRepl(TbMapPath.Text, GbxPath)) Then + If TransmissionLossMapFileBrowser.OpenDialog(FileRepl(TbMapPath.Text, GbxPath)) Then TbMapPath.Text = GetFilenameWithoutDirectory(TransmissionLossMapFileBrowser.Files(0), GbxPath) End If End Sub 'Browse for shift polygons file Private Sub BtShiftPolyBrowse_Click(sender As Object, e As EventArgs) Handles BtShiftPolyBrowse.Click - If GearboxShiftPolygonFileBrowser.OpenDialog(fFileRepl(TbShiftPolyFile.Text, GbxPath)) Then + If GearboxShiftPolygonFileBrowser.OpenDialog(FileRepl(TbShiftPolyFile.Text, GbxPath)) Then TbShiftPolyFile.Text = GetFilenameWithoutDirectory(GearboxShiftPolygonFileBrowser.Files(0), GbxPath) End If End Sub @@ -96,7 +136,7 @@ Public Class GearboxGearDialog Exit Sub End If - If IsNumeric(TbMapPath.Text) AndAlso (TbMapPath.Text < 0 OrElse TbMapPath.Text > 1) Then + If IsNumeric(TbMapPath.Text) AndAlso (TbMapPath.Text.ToDouble() < 0 OrElse TbMapPath.Text.ToDouble() > 1) Then MsgBox("Efficiency is invalid! Must be between 0 and 1.") TbMapPath.Focus() TbMapPath.SelectAll() diff --git a/VECTO/GUI/GraphForm.vb b/VECTO/GUI/GraphForm.vb index e577284338b0fc5353b218bf09b640a311931d5a..cf3bd2673f8451ac0654b88d7dbe0febfd0c0ef1 100644 --- a/VECTO/GUI/GraphForm.vb +++ b/VECTO/GUI/GraphForm.vb @@ -15,6 +15,9 @@ Imports System.IO Imports System.Linq Imports System.Text.RegularExpressions Imports System.Windows.Forms.DataVisualization.Charting +Imports TUGraz.VectoCommon.InputData +Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.Utils Public Class GraphForm Private _filepath As String @@ -22,10 +25,10 @@ Public Class GraphForm Private _distanceList As List(Of Single) Private _timeList As List(Of Single) - Private _xMin As Single - Private _xMax As Single + Private _xMin As Double + Private _xMax As Double - Private _xMax0 As Single + Private _xMax0 As Double Public Sub New() @@ -79,70 +82,47 @@ Public Class GraphForm End Sub Private Sub LoadFile() - Dim file As CsvFile - Dim i As Integer - Dim sDim As Integer - Dim line As String() - Dim c0 As Channel - Dim l0 As List(Of String) - - - file = New CsvFile - If file.OpenRead(_filepath) Then + Try - Try + _channels.Clear() - _channels.Clear() + Dim data As TableData = VectoCSVFile.Read(_filepath) + For Each column As DataColumn In data.Columns + Dim values As List(Of String) = New List(Of String) + For Each row As DataRow In data.Rows + values.Add(row(column).ToString()) + Next + _channels.Add(New Channel() With { + .Name = column.ColumnName, + .Values = values}) + Next - 'Header - line = file.ReadLine - sDim = UBound(line) + _timeList = Nothing + _distanceList = Nothing - For i = 0 To sDim - c0 = New Channel - c0.Name = line(i) - c0.Values = New List(Of String) - _channels.Add(c0) - Next + For Each channel As Channel In _channels + If (channel.Name = "time" AndAlso _timeList Is Nothing) Then + _timeList = channel.Values.Select(Function(x) CSng(x)).ToList() + End If + If (channel.Name = "dist" AndAlso _distanceList Is Nothing) Then + _distanceList = channel.Values.Select(Function(x) CSng(x)).ToList() + End If + Next - 'Values - Do While Not file.EndOfFile - line = file.ReadLine - For i = 0 To sDim - _channels(i).Values.Add(line(i)) - Next - Loop - - file.Close() - - l0 = _channels(0).Values - _timeList = Nothing - _distanceList = Nothing - - For Each channel As Channel In _channels - If (channel.Name = "time [s]" AndAlso _timeList Is Nothing) Then - _timeList = channel.Values.Select(Function(x) CSng(x)).ToList() - End If - If (channel.Name = "dist [m]" AndAlso _distanceList Is Nothing) Then - _distanceList = channel.Values.Select(Function(x) CSng(x)).ToList() - End If - Next + SetxMax0() - SetxMax0() + TbXmin.Text = 0.ToGUIFormat() + TbXmax.Text = _xMax0.ToGUIFormat() - TbXmin.Text = 0 - TbXmax.Text = _xMax0 + Text = GetFilenameWithoutPath(_filepath, True) - Text = GetFilenameWithoutPath(_filepath, True) + Catch ex As Exception - Catch ex As Exception - file.Close() - Exit Sub - End Try + Exit Sub + End Try - End If UpdateGraph() End Sub @@ -191,9 +171,9 @@ Public Class GraphForm Dim chartSeries As Series = New Series If overDist Then - chartSeries.Points.DataBindXY(_distanceList, _channels(listViewItem.Tag).Values) + chartSeries.Points.DataBindXY(_distanceList, _channels(CType(listViewItem.Tag, Integer)).Values) Else - chartSeries.Points.DataBindXY(_timeList, _channels(listViewItem.Tag).Values) + chartSeries.Points.DataBindXY(_timeList, _channels(CType(listViewItem.Tag, Integer)).Values) End If chartSeries.ChartType = SeriesChartType.FastLine @@ -289,18 +269,18 @@ Public Class GraphForm chart.Update() - Dim img As Image = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb) + Dim img As Bitmap = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb) chart.DrawToBitmap(img, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height)) PictureBox1.Image = img End Sub - Private Function AutoIntervalXAxis() As Single - Dim xyd(3) As Single - Dim xya(3) As Single + Private Function AutoIntervalXAxis() As Double + Dim xyd(3) As Double + Dim xya(3) As Double Dim i As Int16 - Dim inv As Single = (_xMax - _xMin) / 10 + Dim inv As Double = (_xMax - _xMin) / 10 Dim grx As Long = 20 Do While 10 ^ grx > inv @@ -315,8 +295,8 @@ Public Class GraphForm xya(i) = Math.Abs(inv - xyd(i)) Next - Dim xyamin As Single = xya(0) - Dim xydmin As Single = xyd(0) + Dim xyamin As Double = xya(0) + Dim xydmin As Double = xyd(0) For i = 1 To 3 If xya(i) < xyamin Then xyamin = xya(i) @@ -394,7 +374,7 @@ Public Class GraphForm dlog.RbRight.Checked = True End If - dlog.ComboBox1.SelectedIndex = lv0.Tag + dlog.ComboBox1.SelectedIndex = CType(lv0.Tag, Integer) If dlog.ShowDialog = DialogResult.OK Then i = dlog.ComboBox1.SelectedIndex @@ -413,7 +393,7 @@ Public Class GraphForm End Sub Private Sub RemoveChannel() - Dim i0 As Int16 + Dim i0 As Integer If ListView1.Items.Count = 0 Then Exit Sub @@ -459,31 +439,31 @@ Public Class GraphForm Private Sub CbXaxis_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbXaxis.SelectedIndexChanged SetxMax0() - TbXmin.Text = 0 - TbXmax.Text = _xMax0 + TbXmin.Text = 0.ToGUIFormat() + TbXmax.Text = _xMax0.ToGUIFormat() UpdateGraph() End Sub Private Sub BtReset_Click(sender As Object, e As EventArgs) Handles BtReset.Click _xMin = 0 _xMax = _xMax0 - TbXmin.Text = 0 - TbXmax.Text = _xMax0 + TbXmin.Text = 0.ToGUIFormat() + TbXmax.Text = _xMax0.ToGUIFormat() End Sub Private Sub TbXmin_TextChanged(sender As Object, e As EventArgs) Handles TbXmin.TextChanged - If IsNumeric(TbXmin.Text) Then _xMin = TbXmin.Text + If IsNumeric(TbXmin.Text) Then _xMin = TbXmin.Text.ToDouble() UpdateGraph() End Sub Private Sub TbXmax_TextChanged(sender As Object, e As EventArgs) Handles TbXmax.TextChanged - If IsNumeric(TbXmax.Text) Then _xMax = TbXmax.Text + If IsNumeric(TbXmax.Text) Then _xMax = TbXmax.Text.ToDouble() UpdateGraph() End Sub Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles ToolStripButton3.Click - Dim FGraph As New GraphForm - FGraph.Show() + Dim graph As New GraphForm + graph.Show() End Sub Private Sub F_Graph_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged @@ -491,7 +471,7 @@ Public Class GraphForm End Sub Private Sub BtZoomIn_Click(sender As Object, e As EventArgs) Handles BtZoomIn.Click - Dim d As Single + Dim d As Double d = (_xMax - _xMin) / 10 @@ -504,12 +484,12 @@ Public Class GraphForm _xMin = Math.Round(_xMin, 0) End If - TbXmin.Text = _xMin - TbXmax.Text = _xMax + TbXmin.Text = _xMin.ToGUIFormat() + TbXmax.Text = _xMax.ToGUIFormat() End Sub Private Sub BtZoomOut_Click(sender As Object, e As EventArgs) Handles BtZoomOut.Click - Dim d As Single + Dim d As Double d = (_xMax - _xMin) / 10 @@ -522,12 +502,12 @@ Public Class GraphForm _xMin = Math.Round(_xMin, 0) End If - TbXmin.Text = _xMin - TbXmax.Text = _xMax + TbXmin.Text = _xMin.ToGUIFormat() + TbXmax.Text = _xMax.ToGUIFormat() End Sub Private Sub BtMoveL_Click(sender As Object, e As EventArgs) Handles BtMoveL.Click - Dim d As Single + Dim d As Double If _xMin <= 0 Then Exit Sub @@ -541,12 +521,12 @@ Public Class GraphForm _xMin = Math.Round(_xMin, 0) End If - TbXmin.Text = _xMin - TbXmax.Text = _xMax + TbXmin.Text = _xMin.ToGUIFormat() + TbXmax.Text = _xMax.ToGUIFormat() End Sub Private Sub BtMoveR_Click(sender As Object, e As EventArgs) Handles BtMoveR.Click - Dim d As Single + Dim d As Double If _xMax >= _xMax0 Then Exit Sub @@ -560,17 +540,17 @@ Public Class GraphForm _xMin = Math.Round(_xMin, 0) End If - TbXmin.Text = _xMin - TbXmax.Text = _xMax + TbXmin.Text = _xMin.ToGUIFormat() + TbXmax.Text = _xMax.ToGUIFormat() End Sub 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 = + Dim browserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString - Dim DefaultBrowserPath As String = - Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - Process.Start(DefaultBrowserPath, + Dim defaultBrowserPath As String = + Regex.Match(browserRegistryString, "(\"".*?\"")").Captures(0).ToString + Process.Start(defaultBrowserPath, String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#graph-window")) Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index 89a6b435dde83f021d0c26ed309f14795f59d979..dc4e4a6bfaab3cd51fe86c836b5c13d4df208257 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -39,6 +39,7 @@ Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports System.Text Imports System.Text.RegularExpressions Imports System.Threading +Imports Microsoft.VisualBasic.FileIO Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils @@ -52,38 +53,38 @@ Imports TUGraz.VectoCore.Utils ''' <remarks></remarks> Public Class MainForm - Private JobListView As cFileListView - Private CycleListView As cFileListView + Private _jobListView As FileListView + Private _cycleListView As FileListView - Private LastModeName As String - Private ConMenTarget As ListView - Private ConMenTarJob As Boolean + Private _lastModeName As String + Private _conMenTarget As ListView + Private _conMenTarJob As Boolean - Private GUIlocked As Boolean + Private _guIlocked As Boolean - Private CheckLock As Boolean - Private GENchecked As Integer - Private GENcheckAllLock As Boolean + Private _checkLock As Boolean + Private _genChecked As Integer + Private _genCheckAllLock As Boolean - Private CbDeclLock As Boolean = False + Private _cbDeclLock As Boolean = False #Region "SLEEP Control - Prevent sleep while VECTO is running" Private Declare Function SetThreadExecutionState Lib "kernel32" (esFlags As Long) As Long - Private Sub AllowSleepOFF() + Private Shared Sub AllowSleepOff() #If Not PLATFORM = "x86" Then - SetThreadExecutionState(tEXECUTION_STATE.ES_CONTINUOUS Or tEXECUTION_STATE.ES_SYSTEM_REQUIRED) + SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS Or EXECUTION_STATE.ES_SYSTEM_REQUIRED) #End If End Sub - Private Sub AllowSleepON() + Private Shared Sub AllowSleepOn() #If Not PLATFORM = "x86" Then - SetThreadExecutionState(tEXECUTION_STATE.ES_CONTINUOUS) + SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS) #End If End Sub - Private Enum tEXECUTION_STATE As Integer + Private Enum EXECUTION_STATE As Integer ''' Informs the system that the state being set should remain in effect until the next call that uses ES_CONTINUOUS and one of the other state flags is cleared. ES_CONTINUOUS = &H80000000 ''' Forces the display to be on by resetting the display idle timer. @@ -119,10 +120,10 @@ Public Class MainForm GearboxShiftPolygonFileBrowser = New FileBrowser("vgbs") RetarderLossMapFileBrowser = New FileBrowser("vrlm") TransmissionLossMapFileBrowser = New FileBrowser("vtlm") - fbPTOLM = New FileBrowser("vptol") + PtoLossMapFileBrowser = New FileBrowser("vptol") TorqueConverterFileBrowser = New FileBrowser("vtcc") - fbTCCShift = New FileBrowser("vgbs") - fbCDx = New FileBrowser("vcdx") + TorqueConverterShiftPolygonFileBrowser = New FileBrowser("vgbs") + CrossWindCorrectionFileBrowser = New FileBrowser("vcdx") DriverDecisionFactorVelocityDropFileBrowser = New FileBrowser("DfVelocityDrop") DriverDecisionFactorTargetSpeedFileBrowser = New FileBrowser("DfTargetSpeed") DriverDecisionFactorVelocityDropFileBrowser.Extensions = New String() {"csv"} @@ -145,10 +146,10 @@ Public Class MainForm GearboxShiftPolygonFileBrowser.Extensions = New String() {"vgbs"} RetarderLossMapFileBrowser.Extensions = New String() {"vrlm"} TransmissionLossMapFileBrowser.Extensions = New String() {"vtlm"} - fbPTOLM.Extensions = New String() {"vptol"} + PtoLossMapFileBrowser.Extensions = New String() {"vptol"} TorqueConverterFileBrowser.Extensions = New String() {"vtcc"} - fbTCCShift.Extensions = New String() {"vgbs"} - fbCDx.Extensions = New String() {"vcdv", "vcdb"} + TorqueConverterShiftPolygonFileBrowser.Extensions = New String() {"vgbs"} + CrossWindCorrectionFileBrowser.Extensions = New String() {"vcdv", "vcdb"} ModalResultsFileBrowser.Extensions = New String() {"vmod"} End Sub @@ -168,29 +169,29 @@ Public Class MainForm GearboxShiftPolygonFileBrowser.Close() RetarderLossMapFileBrowser.Close() TransmissionLossMapFileBrowser.Close() - fbPTOLM.Close() + PtoLossMapFileBrowser.Close() TorqueConverterFileBrowser.Close() - fbTCCShift.Close() - fbCDx.Close() + TorqueConverterShiftPolygonFileBrowser.Close() + CrossWindCorrectionFileBrowser.Close() ModalResultsFileBrowser.Close() End Sub #End Region 'Lock certain GUI elements while VECTO is running - Private Sub LockGUI(Lock As Boolean) - GUIlocked = Lock + Private Sub LockGUI(lock As Boolean) + _guIlocked = lock - PanelOptAllg.Enabled = Not Lock + PanelOptAllg.Enabled = Not lock - BtGENup.Enabled = Not Lock - BtGENdown.Enabled = Not Lock - ButtonGENadd.Enabled = Not Lock - ButtonGENremove.Enabled = Not Lock - LvGEN.LabelEdit = Not Lock - ChBoxAllGEN.Enabled = Not Lock + BtGENup.Enabled = Not lock + BtGENdown.Enabled = Not lock + ButtonGENadd.Enabled = Not lock + ButtonGENremove.Enabled = Not lock + LvGEN.LabelEdit = Not lock + ChBoxAllGEN.Enabled = Not lock - btStartV3.Enabled = Not Lock + btStartV3.Enabled = Not lock End Sub @@ -200,10 +201,10 @@ Public Class MainForm Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Dim x As Integer - GUIlocked = False - CheckLock = False - GENcheckAllLock = False - GENchecked = 0 + _guIlocked = False + _checkLock = False + _genCheckAllLock = False + _genChecked = 0 'Load Tabs properly (otherwise problem with ListViews) @@ -211,7 +212,7 @@ Public Class MainForm TabControl1.TabPages(x).Show() Next - LastModeName = "" + _lastModeName = "" FB_Initialize() @@ -219,11 +220,11 @@ Public Class MainForm 'FileLists - JobListView = New cFileListView(MyConfPath & "joblist.txt") - JobListView.LVbox = LvGEN - CycleListView = New cFileListView(MyConfPath & "cyclelist.txt") + _jobListView = New FileListView(MyConfPath & "joblist.txt") + _jobListView.LVbox = LvGEN + _cycleListView = New FileListView(MyConfPath & "cyclelist.txt") - JobListView.LoadList() + _jobListView.LoadList() LoadOptions() @@ -248,7 +249,7 @@ Public Class MainForm #If DEBUG Then Const LicCheck As Boolean = False #Else - Const LicCheck as Boolean = True + Const LicCheck As Boolean = True #End If 'License check @@ -268,12 +269,13 @@ Public Class MainForm DeclOnOff() End Sub + ' ReSharper disable once UnusedMember.Global -- used via Logging Framework! Public Shared Sub LogMethod(level As String, message As String) Try If level = "Warn" Then - VectoWorkerV3.ReportProgress(100, New With {.Target = "ListBoxWarning", .Message = message}) + VectoWorkerV3.ReportProgress(100, New VectoProgress With {.Target = "ListBoxWarning", .Message = message}) ElseIf level = "Error" Or level = "Fatal" Then - VectoWorkerV3.ReportProgress(100, New With {.Target = "ListBoxError", .Message = message}) + VectoWorkerV3.ReportProgress(100, New VectoProgress With {.Target = "ListBoxError", .Message = message}) End If Catch e As InvalidOperationException @@ -292,12 +294,12 @@ Public Class MainForm End If If Cfg.DeclMode Then - LastModeName = "Declaration" + _lastModeName = "Declaration" Else - LastModeName = "Engineering" + _lastModeName = "Engineering" End If - Status(LastModeName & " Mode") + Status(_lastModeName & " Mode") LoadOptions() @@ -338,16 +340,16 @@ Public Class MainForm #End Region 'Open file - Job, vehicle, engine, gearbox or signature file - Public Sub OpenVectoFile(File As String) + Public Sub OpenVectoFile(file As String) - If Not IO.File.Exists(File) Then + If Not IO.File.Exists(file) Then - GUIMsg(MessageType.Err, "File not found! (" & File & ")") - MsgBox("File not found! (" & File & ")", MsgBoxStyle.Critical) + GUIMsg(MessageType.Err, "File not found! (" & file & ")") + MsgBox("File not found! (" & file & ")", MsgBoxStyle.Critical) Else - Select Case UCase(GetExtension(File)) + Select Case UCase(GetExtension(file)) Case ".VGBX" If Not GearboxForm.Visible Then GearboxForm.Show() @@ -356,7 +358,7 @@ Public Class MainForm If GearboxForm.WindowState = FormWindowState.Minimized Then GearboxForm.WindowState = FormWindowState.Normal GearboxForm.BringToFront() End If - GearboxForm.openGBX(File) + GearboxForm.OpenGbx(file) Case ".VVEH" If Not VehicleForm.Visible Then VehicleForm.Show() @@ -365,7 +367,11 @@ Public Class MainForm If VehicleForm.WindowState = FormWindowState.Minimized Then VehicleForm.WindowState = FormWindowState.Normal VehicleForm.BringToFront() End If - VehicleForm.OpenVehicle(File) + Try + VehicleForm.OpenVehicle(file) + Catch ex As Exception + MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Vehicle File") + End Try Case ".VENG" If Not EngineForm.Visible Then EngineForm.Show() @@ -374,13 +380,13 @@ Public Class MainForm If EngineForm.WindowState = FormWindowState.Minimized Then EngineForm.WindowState = FormWindowState.Normal EngineForm.BringToFront() End If - EngineForm.OpenEngineFile(File) + EngineForm.OpenEngineFile(file) Case ".VECTO" - OpenVECTOeditor(File) + OpenVECTOeditor(file) Case ".VSIG" - OpenSigFile(File) + OpenSigFile(file) Case Else - MsgBox("Type '" & GetExtension(File) & "' unknown!", MsgBoxStyle.Critical) + MsgBox("Type '" & GetExtension(file) & "' unknown!", MsgBoxStyle.Critical) End Select End If @@ -403,7 +409,7 @@ Public Class MainForm Handles LvGEN.KeyDown Select Case e.KeyCode Case Keys.Delete, Keys.Back - If Not GUIlocked Then RemoveJobFile() + If Not _guIlocked Then RemoveJobFile() Case Keys.Enter OpenJobFile() End Select @@ -420,37 +426,37 @@ Public Class MainForm Handles LvGEN.ItemChecked If e.Item.Checked Then - GENchecked += 1 + _genChecked += 1 Else - GENchecked -= 1 + _genChecked -= 1 End If - If CheckLock Then Exit Sub + If _checkLock Then Exit Sub UpdateJobTabText() End Sub Private Sub ChBoxAllGEN_CheckedChanged(sender As Object, e As EventArgs) _ Handles ChBoxAllGEN.CheckedChanged - If GENcheckAllLock And ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub + If _genCheckAllLock And ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub - CheckAllGEN(ChBoxAllGEN.Checked) + CheckAllGen(ChBoxAllGEN.Checked) End Sub - Private Sub CheckAllGEN(Check As Boolean) + Private Sub CheckAllGen(check As Boolean) Dim x As ListViewItem - CheckLock = True + _checkLock = True LvGEN.BeginUpdate() For Each x In LvGEN.Items - x.Checked = Check + x.Checked = check Next LvGEN.EndUpdate() - CheckLock = False + _checkLock = False - GENchecked = LvGEN.CheckedItems.Count + _genChecked = LvGEN.CheckedItems.Count UpdateJobTabText() End Sub @@ -464,7 +470,7 @@ Public Class MainForm Private Sub ListGEN_DragDrop(sender As Object, e As DragEventArgs) _ Handles LvGEN.DragDrop Dim f As String() - f = CType(e.Data.GetData(DataFormats.FileDrop), Array) + f = CType(e.Data.GetData(DataFormats.FileDrop), String()) AddToJobListView(f) End Sub @@ -481,7 +487,7 @@ Public Class MainForm 'Remove selected file(s) from job list Private Sub RemoveJobFile() Dim lastindx As Integer - Dim SelIx() As Integer + Dim selIx() As Integer Dim i As Integer If LvGEN.SelectedItems.Count < 1 Then @@ -493,15 +499,15 @@ Public Class MainForm End If LvGEN.BeginUpdate() - CheckLock = True + _checkLock = True - ReDim SelIx(LvGEN.SelectedItems.Count - 1) - LvGEN.SelectedIndices.CopyTo(SelIx, 0) + ReDim selIx(LvGEN.SelectedItems.Count - 1) + LvGEN.SelectedIndices.CopyTo(selIx, 0) lastindx = LvGEN.SelectedIndices(LvGEN.SelectedItems.Count - 1) - For i = UBound(SelIx) To 0 Step -1 - LvGEN.Items.RemoveAt(SelIx(i)) + For i = UBound(selIx) To 0 Step -1 + LvGEN.Items.RemoveAt(selIx(i)) Next If lastindx < LvGEN.Items.Count Then @@ -511,26 +517,26 @@ Public Class MainForm End If LvGEN.EndUpdate() - CheckLock = False + _checkLock = False - GENchecked = LvGEN.CheckedItems.Count + _genChecked = LvGEN.CheckedItems.Count UpdateJobTabText() End Sub 'Browse for job file(s) and add to job list with AddToJobListView Private Sub AddJobFile() Dim x As String() - Dim Chck As Boolean = False + Dim chck As Boolean = False x = New String() {""} 'STANDARD/BATCH If JobfileFileBrowser.OpenDialog("", True, "vecto") Then - Chck = True + chck = True x = JobfileFileBrowser.Files End If - If Chck Then AddToJobListView(x) + If chck Then AddToJobListView(x) End Sub 'Open file in list @@ -546,7 +552,7 @@ Public Class MainForm End If f = LvGEN.SelectedItems(0).SubItems(0).Text - f = fFileRepl(f) + f = FileRepl(f) If Not File.Exists(f) Then MsgBox(f & " not found!") Else @@ -555,23 +561,23 @@ Public Class MainForm End Sub 'Add File to job listview (multiple files) - Private Sub AddToJobListView(Path As String(), Optional ByVal Txt As String = " ") - Dim pDim As Int16 - Dim p As Int16 - Dim f As Int16 + Private Sub AddToJobListView(path As String(), Optional ByVal txt As String = " ") + Dim pDim As Integer + Dim p As Integer + Dim f As Integer Dim fList As String() - Dim fListDim As Int16 = -1 - Dim ListViewItem0 As ListViewItem + Dim fListDim As Integer = -1 + Dim listViewItem As ListViewItem 'If VECTO runs: Cancel operation (because Mode-change during calculation is not very clever) If VectoWorkerV3.IsBusy Then Exit Sub - pDim = UBound(Path) + pDim = UBound(path) ReDim fList(0) 'um Nullverweisausnahme-Warnung zu verhindern '******************************************* Begin Update '******************************************* LvGEN.BeginUpdate() - CheckLock = True + _checkLock = True LvGEN.SelectedIndices.Clear() @@ -579,7 +585,7 @@ Public Class MainForm fListDim = LvGEN.Items.Count - 1 ReDim fList(fListDim) For f = 0 To fListDim - fList(f) = fFileRepl(LvGEN.Items(f).SubItems(0).Text) + fList(f) = FileRepl(LvGEN.Items(f).SubItems(0).Text) Next End If @@ -590,10 +596,10 @@ Public Class MainForm For f = 0 To fListDim 'If file already exists in the list: Do not append (only when a single file) - If UCase(Path(p)) = UCase(fList(f)) Then + If UCase(path(p)) = UCase(fList(f)) Then 'Status reset - LvGEN.Items(f).SubItems(1).Text = Txt + LvGEN.Items(f).SubItems(1).Text = txt LvGEN.Items(f).BackColor = Color.FromKnownColor(KnownColor.Window) LvGEN.Items(f).ForeColor = Color.FromKnownColor(KnownColor.WindowText) @@ -609,49 +615,48 @@ Public Class MainForm End If 'Otherwise: Add File (without WorkDir) - ListViewItem0 = New ListViewItem(Path(p)) 'fFileWD(Path(p))) - ListViewItem0.SubItems.Add(" ") - ListViewItem0.Checked = True - ListViewItem0.Selected = True - LvGEN.Items.Add(ListViewItem0) - ListViewItem0.EnsureVisible() + listViewItem = New ListViewItem(path(p)) 'fFileWD(Path(p))) + listViewItem.SubItems.Add(" ") + listViewItem.Checked = True + listViewItem.Selected = True + LvGEN.Items.Add(listViewItem) + listViewItem.EnsureVisible() lbFound: Next LvGEN.EndUpdate() - CheckLock = False + _checkLock = False '******************************************* End Update '******************************************* 'Number update - GENchecked = LvGEN.CheckedItems.Count + _genChecked = LvGEN.CheckedItems.Count UpdateJobTabText() End Sub 'Add File to job listview (single file) - Public Sub AddToJobListView(Path As String, Optional ByVal Txt As String = " ") + Public Sub AddToJobListView(path As String, Optional ByVal txt As String = " ") Dim p(0) As String - p(0) = Path - AddToJobListView(p, Txt) + p(0) = path + AddToJobListView(p, txt) End Sub 'Update job files counter in tab titel Private Sub UpdateJobTabText() - Dim c As Integer - c = LvGEN.Items.Count + Dim count As Integer = LvGEN.Items.Count - TabPageGEN.Text = "Job Files ( " & GENchecked & " / " & c & " )" + TabPageGEN.Text = String.Format("Job Files ( {0} / {1} )", _genChecked, count) - GENcheckAllLock = True + _genCheckAllLock = True - If GENchecked = 0 Then + If _genChecked = 0 Then ChBoxAllGEN.CheckState = CheckState.Unchecked - ElseIf GENchecked = c Then + ElseIf _genChecked = count Then ChBoxAllGEN.CheckState = CheckState.Checked Else ChBoxAllGEN.CheckState = CheckState.Indeterminate End If - GENcheckAllLock = False + _genCheckAllLock = False End Sub @@ -707,8 +712,8 @@ lbFound: Private Sub GraphToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles GraphToolStripMenuItem.Click - Dim FGraph As New GraphForm - FGraph.Show() + Dim graphForm As New GraphForm + graphForm.Show() End Sub Private Sub SignOrVerifyFilesToolStripMenuItem_Click(sender As Object, e As EventArgs) _ @@ -734,11 +739,11 @@ lbFound: Private Sub UserManualToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles UserManualToolStripMenuItem.Click If File.Exists(MyAppPath & "User Manual\help.html") Then - Dim BrowserRegistryString As String = + Dim browserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString - Dim DefaultBrowserPath As String = - Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - Process.Start(DefaultBrowserPath, Uri.EscapeDataString(MyAppPath & "User Manual\help.html")) + Dim defaultBrowserPath As String = + Regex.Match(browserRegistryString, "(\"".*?\"")").Captures(0).ToString + Process.Start(defaultBrowserPath, Uri.EscapeDataString(MyAppPath & "User Manual\help.html")) Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) End If @@ -779,53 +784,53 @@ lbFound: #End Region 'Move job/cycle file up or down in list view - Private Sub MoveItem(ByRef ListV As ListView, MoveUp As Boolean) - Dim x As Int32 - Dim y As Int32 - Dim y1 As Int32 + Private Sub MoveItem(ByRef listView As ListView, moveUp As Boolean) + Dim x As Integer + Dim y As Integer + Dim y1 As Integer Dim items() As String Dim check() As Boolean Dim index() As Integer - Dim ListViewItem0 As ListViewItem + Dim listViewItem As ListViewItem - If GUIlocked Then Exit Sub + If _guIlocked Then Exit Sub 'Cache Selected Items - y1 = ListV.SelectedItems.Count - 1 + y1 = listView.SelectedItems.Count - 1 ReDim items(y1) ReDim check(y1) ReDim index(y1) y = 0 - For Each x In ListV.SelectedIndices - items(y) = ListV.Items(x).SubItems(0).Text - check(y) = ListV.Items(x).Checked - If MoveUp Then + For Each x In listView.SelectedIndices + items(y) = listView.Items(x).SubItems(0).Text + check(y) = listView.Items(x).Checked + If moveUp Then If x = 0 Then Exit Sub index(y) = x - 1 Else - If x = ListV.Items.Count - 1 Then Exit Sub + If x = listView.Items.Count - 1 Then Exit Sub index(y) = x + 1 End If y += 1 Next - ListV.BeginUpdate() + listView.BeginUpdate() 'Delete Selected Items - For Each ListViewItem0 In ListV.SelectedItems - ListViewItem0.Remove() + For Each listViewItem In listView.SelectedItems + listViewItem.Remove() Next 'Items select and Insert For y = 0 To y1 - If Not check(y) Then GENchecked += 1 - ListViewItem0 = ListV.Items.Insert(index(y), items(y)) - ListViewItem0.SubItems.Add(" ") - ListViewItem0.Checked = check(y) - ListV.SelectedIndices.Add(index(y)) + If Not check(y) Then _genChecked += 1 + listViewItem = listView.Items.Insert(index(y), items(y)) + listViewItem.SubItems.Add(" ") + listViewItem.Checked = check(y) + listView.SelectedIndices.Add(index(y)) Next - ListV.EndUpdate() + listView.EndUpdate() End Sub @@ -835,10 +840,10 @@ lbFound: Private Sub SaveListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles SaveListToolStripMenuItem.Click If TextFileBrowser.SaveDialog("") Then - If ConMenTarJob Then - JobListView.SaveList(TextFileBrowser.Files(0)) + If _conMenTarJob Then + _jobListView.SaveList(TextFileBrowser.Files(0)) Else - CycleListView.SaveList(TextFileBrowser.Files(0)) + _cycleListView.SaveList(TextFileBrowser.Files(0)) End If End If End Sub @@ -847,17 +852,17 @@ lbFound: Private Sub LoadListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles LoadListToolStripMenuItem.Click - If GUIlocked Then Exit Sub + If _guIlocked Then Exit Sub If TextFileBrowser.OpenDialog("") Then - If ConMenTarJob Then 'GEN - JobListView.LoadList(TextFileBrowser.Files(0)) - GENchecked = LvGEN.CheckedItems.Count + If _conMenTarJob Then 'GEN + _jobListView.LoadList(TextFileBrowser.Files(0)) + _genChecked = LvGEN.CheckedItems.Count UpdateJobTabText() Else 'DRI 'Mode toggle - CycleListView.LoadList(TextFileBrowser.Files(0)) + _cycleListView.LoadList(TextFileBrowser.Files(0)) End If End If @@ -867,16 +872,16 @@ lbFound: Private Sub LoadDefaultListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles LoadDefaultListToolStripMenuItem.Click - If GUIlocked Then Exit Sub + If _guIlocked Then Exit Sub - If ConMenTarJob Then + If _conMenTarJob Then - JobListView.LoadList() + _jobListView.LoadList() - GENchecked = LvGEN.CheckedItems.Count + _genChecked = LvGEN.CheckedItems.Count UpdateJobTabText() Else - CycleListView.LoadList() + _cycleListView.LoadList() End If End Sub @@ -885,11 +890,11 @@ lbFound: Private Sub ClearListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ClearListToolStripMenuItem.Click - If GUIlocked Then Exit Sub + If _guIlocked Then Exit Sub - ConMenTarget.Items.Clear() - If ConMenTarJob Then - GENchecked = LvGEN.CheckedItems.Count + _conMenTarget.Items.Clear() + If _conMenTarJob Then + _genChecked = LvGEN.CheckedItems.Count UpdateJobTabText() End If End Sub @@ -912,7 +917,9 @@ lbFound: Status("Launching VECTO ...") JobFileList.Clear() - JobFileList.AddRange(From listViewItem In LvGEN.CheckedItems Select fFileRepl(listViewItem.SubItems(0).Text)) + JobFileList.AddRange( + From listViewItem As ListViewItem In LvGEN.CheckedItems.Cast(Of ListViewItem)() + Select fFileRepl = FileRepl(listViewItem.SubItems(0).Text)) SetOptions() Cfg.Save() @@ -936,8 +943,12 @@ lbFound: End If End Sub - Private Sub VectoWorkerV3_OnDoWork(sender As BackgroundWorker, e As DoWorkEventArgs) - AllowSleepOFF() + + Private Sub VectoWorkerV3_OnDoWork(theSender As Object, e As DoWorkEventArgs) + Dim sender As BackgroundWorker = TryCast(theSender, BackgroundWorker) + If sender Is Nothing Then Exit Sub + + AllowSleepOff() Dim sumFileWriter As FileOutputWriter = New FileOutputWriter(JobFileList(0)) Dim sumWriter As SummaryDataContainer = New SummaryDataContainer(sumFileWriter) @@ -950,7 +961,7 @@ lbFound: mode = ExecutionMode.Engineering Physics.FuelDensity = New SI(Cfg.FuelDens).Kilo.Gramm.Per.Cubic.Dezi.Meter.Cast(Of KilogramPerCubicMeter)() Physics.AirDensity = New SI(Cfg.AirDensity).Kilo.Gramm.Per.Cubic.Meter.Cast(Of KilogramPerCubicMeter)() - Physics.CO2PerFuelWeight = Cfg.CO2perFC + Physics.CO2PerFuelWeight = Cfg.Co2PerFc End If 'dictionary of run-identifiers to fileWriters (used for output directory of modfile) @@ -961,7 +972,8 @@ lbFound: For Each jobFile As String In JobFileList Try - sender.ReportProgress(0, New With {.Target = "ListBox", .Message = "Reading File " + jobFile, .Link = jobFile}) + sender.ReportProgress(0, + New VectoProgress With {.Target = "ListBox", .Message = "Reading File " + jobFile, .Link = jobFile}) Dim dataProvider As IInputDataProvider = JSONInputDataFactory.ReadJsonJob(jobFile) Dim fileWriter As FileOutputWriter = New FileOutputWriter(jobFile) @@ -974,11 +986,12 @@ lbFound: fileWriters.Add(runId, fileWriter) Next - sender.ReportProgress(0, New With {.Target = "ListBox", .Message = "Finished Reading Data for job: " + jobFile}) + sender.ReportProgress(0, + New VectoProgress With {.Target = "ListBox", .Message = "Finished Reading Data for job: " + jobFile}) 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}) + sender.ReportProgress(0, New VectoProgress With {.Target = "ListBoxError", .Message = ex.Message}) Return End Try Next @@ -986,12 +999,11 @@ lbFound: 'print detected cycles For Each cycle As JobContainer.CycleTypeDescription In jobContainer.GetCycleTypes() sender.ReportProgress(0, - New With {.Target = "ListBox", .Message = String.Format("Detected Cycle {0}: {1}", cycle.Name, cycle.CycleType)}) + New VectoProgress _ + With {.Target = "ListBox", .Message = String.Format("Detected Cycle {0}: {1}", cycle.Name, cycle.CycleType)}) Next - sender.ReportProgress(0, - New _ - With {.Target = "ListBox", + sender.ReportProgress(0, New VectoProgress With {.Target = "ListBox", .Message = _ String.Format("Starting Simulation ({0} Jobs, {1} Runs)", JobFileList.Count, jobContainer.GetProgress().Count)}) @@ -1010,7 +1022,8 @@ lbFound: Dim sumProgress As Double = progress.Sum(Function(pair) pair.Value.Progress) Dim duration As Double = (DateTime.Now() - start).TotalSeconds - sender.ReportProgress(Int((sumProgress * 100.0) / progress.Count), New With {.Target = "Status", + sender.ReportProgress(Convert.ToInt32((sumProgress * 100.0) / progress.Count), + New VectoProgress With {.Target = "Status", .Message = _ String.Format("Duration: {0:0}s, Current Progress: {1:P} ({2})", duration, sumProgress / progress.Count, String.Join(", ", progress.Select(Function(pair) String.Format("{0,4:P}", pair.Value.Progress))))}) @@ -1032,14 +1045,15 @@ lbFound: fileWriters.Clear() For Each progressEntry As KeyValuePair(Of Integer, JobContainer.ProgressEntry) In jobContainer.GetProgress() - sender.ReportProgress(100, New With {.Target = "ListBox", + sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", .Message = String.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", String.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, progressEntry.Value.RunSuffix), progressEntry.Value.Progress, progressEntry.Value.ExecTime / 1000.0, IIf(progressEntry.Value.Success, "Success", "Aborted"))}) If (Not progressEntry.Value.Success) Then - sender.ReportProgress(100, New With {.Target = "ListBox", .Message = progressEntry.Value.Error.Message}) + sender.ReportProgress(100, + New VectoProgress With {.Target = "ListBox", .Message = progressEntry.Value.Error.Message}) End If Next @@ -1047,23 +1061,19 @@ lbFound: For Each job As String In JobFileList Dim report As String = New FileOutputWriter(job).PDFReportName If File.Exists(report) Then - sender.ReportProgress(100, - New _ - With {.Target = "ListBox", + sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", .Message = String.Format("PDF-Report for '{0}' written to {1}", Path.GetFileName(job), report), .Link = "<RUN>" + report}) End If Next If File.Exists(sumFileWriter.SumFileName) Then - sender.ReportProgress(100, New With {.Target = "ListBox", + sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", .Message = String.Format("Sum File written to {0}", sumFileWriter.SumFileName), .Link = sumFileWriter.SumFileName}) End If - sender.ReportProgress(100, - New _ - With {.Target = "ListBox", + sender.ReportProgress(100, New VectoProgress With {.Target = "ListBox", .Message = String.Format("Simulation Finished in {0:0}s", (DateTime.Now() - start).TotalSeconds)}) End Sub @@ -1072,25 +1082,22 @@ lbFound: fileWriters As Dictionary(Of Integer, FileOutputWriter)) For Each p As KeyValuePair(Of Integer, JobContainer.ProgressEntry) In progress Dim modFilename As String = fileWriters(p.Key).GetModDataFileName(p.Value.RunName, p.Value.CycleName, - p.Value.RunSuffix + IIf(Cfg.Mod1Hz, "_1Hz", "")) + p.Value.RunSuffix + If(Cfg.Mod1Hz, "_1Hz", "")) Dim runName As String = String.Format("{0} {1} {2}", p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix) If Not p.Value.Error Is Nothing Then - VectoWorkerV3.ReportProgress(0, - New _ - With {.Target = "ListBoxError", + VectoWorkerV3.ReportProgress(0, New VectoProgress With {.Target = "ListBoxError", .Message = String.Format("Finished Run {0} with ERROR: {1}", runName, p.Value.Error.Message), .Link = modFilename}) Else VectoWorkerV3.ReportProgress(0, - New With {.Target = "ListBox", .Message = String.Format("Finished Run {0} successfully.", runName)}) + New VectoProgress _ + With {.Target = "ListBox", .Message = String.Format("Finished Run {0} successfully.", runName)}) End If If (File.Exists(modFilename)) Then - VectoWorkerV3.ReportProgress(0, - New _ - With {.Target = "ListBox", + VectoWorkerV3.ReportProgress(0, New VectoProgress With {.Target = "ListBox", .Message = String.Format("Run {0}: Modal Results written to {1}", runName, modFilename), .Link = modFilename }) End If @@ -1098,21 +1105,24 @@ lbFound: End Sub Private Sub VectoWorkerV3_OnProgressChanged(sender As Object, e As ProgressChangedEventArgs) - Select Case e.UserState.Target + Dim progress As VectoProgress = TryCast(e.UserState, VectoProgress) + If progress Is Nothing Then Exit Sub + + Select Case progress.Target Case "ListBox" - If e.UserState.GetType().GetProperty("Link") Is Nothing Then - MSGtoForm(MessageType.Normal, e.UserState.Message, "", "") + If progress.Link Is Nothing Then + MsgToForm(MessageType.Normal, progress.Message, "", "") Else - MSGtoForm(MessageType.Normal, e.UserState.Message, "", e.UserState.Link) + MsgToForm(MessageType.Normal, progress.Message, "", progress.Link) End If Case "ListBoxWarning" - MSGtoForm(MessageType.Warn, e.UserState.Message, "", "") + MsgToForm(MessageType.Warn, progress.Message, "", "") Return Case "ListBoxError" - MSGtoForm(MessageType.Err, e.UserState.Message, "", "") + MsgToForm(MessageType.Err, progress.Message, "", "") Return Case "Status" - Status(e.UserState.Message) + Status(progress.Message) End Select ToolStripProgBarOverall.Value = e.ProgressPercentage @@ -1139,112 +1149,114 @@ lbFound: LockGUI(False) btStartV3.Text = "START" btStartV3.Image = My.Resources.Play_icon - Status(LastModeName & " Mode") + Status(_lastModeName & " Mode") 'SLEEP reactivate - AllowSleepON() + AllowSleepOn() End Sub Private Sub ModeUpdate() 'Save lists - JobListView.SaveList() + _jobListView.SaveList() 'GUI changes according to current mode If Cfg.DeclMode Then - LastModeName = "Declaration" + _lastModeName = "Declaration" Else - LastModeName = "Engineering" + _lastModeName = "Engineering" End If 'Update job counter - GENchecked = LvGEN.CheckedItems.Count + _genChecked = LvGEN.CheckedItems.Count UpdateJobTabText() 'Status label - Status(LastModeName & " Mode") + Status(_lastModeName & " Mode") End Sub 'Class for ListView control - Job and cycle lists - Private Class cFileListView - Private ReadOnly FilePath As String - Private LoadedDefault As Boolean + Private Class FileListView + Private ReadOnly _filePath As String + Private _loadedDefault As Boolean Public LVbox As ListView - Public Sub New(Path As String) - FilePath = Path - LoadedDefault = False + Public Sub New(path As String) + _filePath = path + _loadedDefault = False End Sub - Public Sub SaveList(Optional ByVal Path As String = "") - Dim x As Int32 - Dim file As CsvFile - 'If LVbox.Items.Count = 0 Then Exit Sub - file = New CsvFile - If Path = "" Then - If Not LoadedDefault Then Exit Sub - Path = FilePath + Public Sub SaveList(Optional ByVal path As String = "") + Dim x As Integer + If path = "" Then + If Not _loadedDefault Then Exit Sub + path = _filePath End If - file.OpenWrite(Path, "?") + Dim file As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(path, False, Encoding.UTF8) For x = 1 To LVbox.Items.Count - file.WriteLine(LVbox.Items(x - 1).SubItems(0).Text, Math.Abs(CInt(LVbox.Items(x - 1).Checked))) + file.WriteLine(String.Join("?", LVbox.Items(x - 1).SubItems(0).Text, Math.Abs(CInt(LVbox.Items(x - 1).Checked)))) Next file.Close() End Sub - Public Sub LoadList(Optional ByVal Path As String = "") - Dim line As String() - Dim NoCheck As Boolean - Dim file As CsvFile - Dim ListViewItem0 As ListViewItem + Public Sub LoadList(Optional ByVal path As String = "") + 'Dim line As String() + Dim noCheck As Boolean + 'Dim file As CsvFile + Dim listViewItem As ListViewItem - If Path = "" Then - Path = FilePath - LoadedDefault = True + If path = "" Then + path = _filePath + _loadedDefault = True End If - file = New CsvFile + 'file = New CsvFile - If Not file.OpenRead(Path, "?") Then - If Not LoadedDefault Then GUIMsg(MessageType.Err, "Cannot open file (" & Path & ")!") + If Not File.Exists(path) Then + If Not _loadedDefault Then GUIMsg(MessageType.Err, "Cannot open file (" & path & ")!") Exit Sub End If - MainForm.CheckLock = True + MainForm._checkLock = True LVbox.BeginUpdate() LVbox.Items.Clear() - NoCheck = False - Do While Not file.EndOfFile - line = file.ReadLine + noCheck = False + Dim reader As TextFieldParser = New TextFieldParser(path, Encoding.Default) + reader.TextFieldType = FieldType.Delimited + reader.Delimiters = New String() {"?"} + + Do While Not reader.EndOfData + Dim line As String() = reader.ReadFields() + If Strings.Left(Trim(line(0)), 1) = "#" Then Continue Do - ListViewItem0 = New ListViewItem(line(0)) - ListViewItem0.SubItems.Add(" ") + listViewItem = New ListViewItem(line(0)) + listViewItem.SubItems.Add(" ") - If NoCheck Then - ListViewItem0.Checked = True + If noCheck Then + listViewItem.Checked = True Else If UBound(line) < 1 Then - NoCheck = True - ListViewItem0.Checked = True + noCheck = True + listViewItem.Checked = True Else If IsNumeric(line(1)) Then - ListViewItem0.Checked = CBool(line(1)) + listViewItem.Checked = CBool(line(1)) Else - ListViewItem0.Checked = True + listViewItem.Checked = True End If End If End If - LVbox.Items.Add(ListViewItem0) + LVbox.Items.Add(listViewItem) Loop - file.Close() + reader.Close() LVbox.EndUpdate() - MainForm.CheckLock = False + MainForm._checkLock = False If LVbox.Items.Count > 0 Then LVbox.Items(LVbox.Items.Count - 1).EnsureVisible() End Sub @@ -1262,7 +1274,7 @@ lbFound: End If If x = "<New>" Then - VectoJobForm.VECTOnew() + VectoJobForm.VectoNew() Else VectoJobForm.VECTOload2Form(x) End If @@ -1284,7 +1296,7 @@ lbFound: 'Save job and cycle file lists Private Sub SaveFileLists() - JobListView.SaveList() + _jobListView.SaveList() 'If Cfg.BatchMode Then CycleListView.SaveList() End Sub @@ -1302,8 +1314,8 @@ lbFound: 'Timer to update progress bar regularly Private Sub TmProgSec_Tick(sender As Object, e As EventArgs) Handles TmProgSec.Tick - If GUItest0.TestActive Then - Call GUItest0.TestTick() + If _guItest.TestActive Then + Call _guItest.TestTick() Exit Sub Else If Not ProgBarCtrl.ProgLock Then ProgSecUpdate() @@ -1358,7 +1370,7 @@ lbFound: 'Add message to message list - Public Sub MSGtoForm(ID As MessageType, Msg As String, Source As String, Link As String) + Public Sub MsgToForm(id As MessageType, msg As String, source As String, link As String) If (InvokeRequired) Then 'Me.Invoke(New MsgToFormDelegate(AddressOf MSGtoForm), ID, Msg, Source, Link) @@ -1367,15 +1379,15 @@ lbFound: Dim lv0 As ListViewItem lv0 = New ListViewItem - lv0.Text = Msg + lv0.Text = msg lv0.SubItems.Add(Now.ToString("HH:mm:ss.ff")) - lv0.SubItems.Add(Source) + lv0.SubItems.Add(source) If LvMsg.Items.Count > 9999 Then LvMsg.Items.RemoveAt(0) - LogFile.WriteToLog(ID, Msg & vbTab & Source) + LogFile.WriteToLog(id, msg & vbTab & source) - Select Case ID + Select Case id Case MessageType.Err @@ -1389,17 +1401,17 @@ lbFound: Case Else - If ID = MessageType.NewJob Then + If id = MessageType.NewJob Then lv0.BackColor = Color.LightGray lv0.ForeColor = Color.DarkBlue End If End Select - If Link <> "" Then - If Not ID = MessageType.Err Then lv0.ForeColor = Color.Blue + If link <> "" Then + If Not id = MessageType.Err Then lv0.ForeColor = Color.Blue lv0.SubItems(0).Font = New Font(LvMsg.Font, FontStyle.Underline) - lv0.Tag = Link + lv0.Tag = link End If @@ -1456,7 +1468,7 @@ lbFound: Else LvMsg.Cursor = Cursors.Hand End If - If mouseDownOnListView Then + If _mouseDownOnListView Then Try LvMsg.HitTest(e.Location).Item.Selected = True Catch @@ -1466,16 +1478,16 @@ lbFound: #Region "Open File Context Menu" - Private CmFiles As String() + Private _contextMenuFiles As String() 'Initialise and open context menu Private Sub OpenFiles(ParamArray files() As String) If files.Length = 0 Then Exit Sub - CmFiles = files + _contextMenuFiles = files - OpenInGraphWindowToolStripMenuItem.Enabled = (UCase(GetExtension(CmFiles(0))) = ".VMOD") + OpenInGraphWindowToolStripMenuItem.Enabled = (UCase(GetExtension(_contextMenuFiles(0))) = ".VMOD") OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName @@ -1486,22 +1498,22 @@ lbFound: 'Open with tool defined in Settings Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenWithToolStripMenuItem.Click - If Not FileOpenAlt(CmFiles(0)) Then MsgBox("Failed to open file!") + If Not FileOpenAlt(_contextMenuFiles(0)) Then MsgBox("Failed to open file!") End Sub Private Sub OpenInGraphWindowToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenInGraphWindowToolStripMenuItem.Click - Dim FGraph As New GraphForm - FGraph.Show() - FGraph.LoadNewFile(CmFiles(0)) + Dim graphForm As New GraphForm + graphForm.Show() + graphForm.LoadNewFile(_contextMenuFiles(0)) End Sub 'Show in folder Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ShowInFolderToolStripMenuItem.Click - If File.Exists(CmFiles(0)) Then + If File.Exists(_contextMenuFiles(0)) Then Try - Process.Start("explorer", "/select,""" & CmFiles(0) & "") + Process.Start("explorer", "/select,""" & _contextMenuFiles(0) & "") Catch ex As Exception MsgBox("Failed to open file!") End Try @@ -1514,12 +1526,12 @@ lbFound: 'Change Declaraion Mode Private Sub RbDecl_CheckedChanged(sender As Object, e As EventArgs) Handles RbDecl.CheckedChanged - If CbDeclLock Then Exit Sub + If _cbDeclLock Then Exit Sub If VectoJobForm.Visible Or VehicleForm.Visible Or GearboxForm.Visible Or EngineForm.Visible Then - CbDeclLock = True + _cbDeclLock = True RbDecl.Checked = Not RbDecl.Checked - CbDeclLock = False + _cbDeclLock = False MsgBox("Please close all dialog windows (e.g. Job Editor) before changing mode!") Else Cfg.DeclMode = RbDecl.Checked @@ -1531,352 +1543,351 @@ lbFound: #Region "GUI Tests" - Private ReadOnly GUItest0 As New GUItest(Me) - Private mouseDownOnListView As Boolean + Private ReadOnly _guItest As New GUItest(Me) + Private _mouseDownOnListView As Boolean Private Class GUItest - Private RowLim As Int16 = 9 - Private ColLim As Int16 = 45 + Private Const RowLim As Integer = 9 + Private Const ColLim As Integer = 45 Public TestActive As Boolean = False - Private TestAborted As Boolean - Private xCtrl As Int16 - Private xPanel As Int16 - Private Scr As Int32 - Private PRbAlt As Boolean - Private ReadOnly Ctrls(RowLim + 1) As Int16 - Private ReadOnly Pnls(RowLim + 1) As Int16 - Private CtrlC As Int16 - Private CtrlCL As Int16 - Private PnDir As Int16 - Private PnDirC As Int16 - Private PnDirCL As Int16 - Private PnDirRnd As Int16 - Private CtrlRnd As Int16 - Private DiffC As Int16 - Private DiffLvl As Int16 - Private bInit As Int16 - Private ReadOnly MyForm As MainForm - Private ReadOnly KeyCode As List(Of Integer) + Private _testAborted As Boolean + Private _xCtrl As Integer + Private _xPanel As Integer + Private _scr As Integer + Private _pRbAlt As Boolean + Private ReadOnly _ctrls(RowLim + 1) As Integer + Private ReadOnly _pnls(RowLim + 1) As Integer + Private _ctrlC As Integer + Private _ctrlCl As Integer + Private _pnDir As Integer + Private _pnDirC As Integer + Private _pnDirCl As Integer + Private _pnDirRnd As Integer + Private _ctrlRnd As Integer + Private _diffC As Integer + Private _diffLvl As Integer + Private _bInit As Integer + Private ReadOnly _mainForm As MainForm + Private ReadOnly _keyCode As List(Of Integer) Private Sub TestRun() - Dim z As Int16 - - xPanel = ColLim - 10 - xCtrl = ColLim - 10 - PRbAlt = False - Scr = 0 - PnDir = 0 - PnDirCL = 10 - PnDirC = 0 ' StrDirCL - CtrlCL = 5 - CtrlC = CtrlCL - PnDirRnd = 5 - CtrlRnd = 8 - DiffC = 0 - DiffLvl = 1 - bInit = 0 - TestAborted = False + Dim z As Integer + + _xPanel = ColLim - 10 + _xCtrl = ColLim - 10 + _pRbAlt = False + _scr = 0 + _pnDir = 0 + _pnDirCl = 10 + _pnDirC = 0 ' StrDirCL + _ctrlCl = 5 + _ctrlC = _ctrlCl + _pnDirRnd = 5 + _ctrlRnd = 8 + _diffC = 0 + _diffLvl = 1 + _bInit = 0 + _testAborted = False Randomize() - MyForm.LvMsg.Items.Clear() - MyForm.ToolStripLbStatus.Text = "Score: 0000 Press <Esc> to Quit" + _mainForm.LvMsg.Items.Clear() + _mainForm.ToolStripLbStatus.Text = "Score: 0000 Press <Esc> to Quit" For z = 1 To RowLim - 6 - PRbAlt = Not PRbAlt - If Not PRbAlt Then - MyForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| |*") + _pRbAlt = Not _pRbAlt + If Not _pRbAlt Then + _mainForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| |*") Else - MyForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| | |*") + _mainForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| | |*") End If Next - PRbAlt = False + _pRbAlt = False - MyForm.LvMsg.Items.Add(" VECTO Interactive Mode" & Space(ColLim - 35) & "*| |*") - MyForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| | |*") - MyForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| |*") - MyForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| | |*") - MyForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| |*") - MyForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| ∆ |*") + _mainForm.LvMsg.Items.Add(" VECTO Interactive Mode" & Space(ColLim - 35) & "*| |*") + _mainForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| | |*") + _mainForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| |*") + _mainForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| | |*") + _mainForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| |*") + _mainForm.LvMsg.Items.Add(Space(ColLim - 11) & "*| ∆ |*") For z = 1 To RowLim + 1 - Pnls(z) = ColLim - 10 - Ctrls(z) = 0 + _pnls(z) = ColLim - 10 + _ctrls(z) = 0 Next - MyForm.TmProgSec.Interval = 200 + _mainForm.TmProgSec.Interval = 200 - MyForm.LvMsg.Focus() + _mainForm.LvMsg.Focus() - MyForm.TmProgSec.Start() + _mainForm.TmProgSec.Start() End Sub Public Sub TestStop() - MyForm.TmProgSec.Stop() + _mainForm.TmProgSec.Stop() TestActive = False - MyForm.LvMsg.Items.Clear() - CtrlC = 0 - MyForm.ToolStripLbStatus.Text = MyForm.LastModeName & " Mode" + _mainForm.LvMsg.Items.Clear() + _ctrlC = 0 + _mainForm.ToolStripLbStatus.Text = _mainForm._lastModeName & " Mode" End Sub Public Sub TestTick() - If bInit = 24 Then GoTo LbRace - bInit += 1 + If _bInit = 24 Then GoTo LbRace + _bInit += 1 - Select Case bInit + Select Case _bInit Case 10 - MyForm.LvMsg.Items.RemoveAt(RowLim - 6) - MyForm.LvMsg.Items.RemoveAt(RowLim - 5) - MyForm.LvMsg.Items.Insert(RowLim - 6, Space(ColLim - 11) & "*| |*") - MyForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " 3 " & Space(10) & "*| |*") + _mainForm.LvMsg.Items.RemoveAt(RowLim - 6) + _mainForm.LvMsg.Items.RemoveAt(RowLim - 5) + _mainForm.LvMsg.Items.Insert(RowLim - 6, Space(ColLim - 11) & "*| |*") + _mainForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " 3 " & Space(10) & "*| |*") Case 14 - MyForm.LvMsg.Items.RemoveAt(RowLim - 4) - MyForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " 2 " & Space(10) & "*| |*") + _mainForm.LvMsg.Items.RemoveAt(RowLim - 4) + _mainForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " 2 " & Space(10) & "*| |*") Case 18 - MyForm.LvMsg.Items.RemoveAt(RowLim - 4) - MyForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " 1 " & Space(10) & "*| |*") + _mainForm.LvMsg.Items.RemoveAt(RowLim - 4) + _mainForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " 1 " & Space(10) & "*| |*") Case 22 - MyForm.LvMsg.Items.RemoveAt(RowLim - 4) - MyForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " Go! " & Space(10) & "*| |*") + _mainForm.LvMsg.Items.RemoveAt(RowLim - 4) + _mainForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " Go! " & Space(10) & "*| |*") Case 24 - MyForm.LvMsg.Items.RemoveAt(RowLim - 4) - MyForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " " & Space(10) & "*| |*") + _mainForm.LvMsg.Items.RemoveAt(RowLim - 4) + _mainForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " " & Space(10) & "*| |*") End Select Exit Sub LbRace: - PRbAlt = Not PRbAlt + _pRbAlt = Not _pRbAlt - MyForm.LvMsg.BeginUpdate() + _mainForm.LvMsg.BeginUpdate() - sLists() + Lists() - sAlign() + Align() - sSetCtrl() + SetCtrl() - sSetPanel() + SetPanel() - MyForm.LvMsg.Items.RemoveAt(RowLim) + _mainForm.LvMsg.Items.RemoveAt(RowLim) - sUpdateCtrl() + UpdateCtrl() - MyForm.LvMsg.EndUpdate() + _mainForm.LvMsg.EndUpdate() - If Math.Abs(xCtrl - Pnls(2)) > 4 Then - sAbort() + If Math.Abs(_xCtrl - _pnls(2)) > 4 Then + Abort() Exit Sub - ElseIf Ctrls(2) <> 0 Then - If xCtrl = Pnls(2) + Ctrls(2) - 4 Then - sAbort() + ElseIf _ctrls(2) <> 0 Then + If _xCtrl = _pnls(2) + _ctrls(2) - 4 Then + Abort() Exit Sub End If - Scr += 5 * DiffLvl + _scr += 5 * _diffLvl End If - Scr += DiffLvl - DiffC += 1 + _scr += _diffLvl + _diffC += 1 'Erhöhe Schwierigkeitsgrad - If DiffC = (DiffLvl + 3) * 4 Then - DiffC = 0 - DiffLvl += 1 - If DiffLvl > 2 And DiffLvl < 7 Then MyForm.TmProgSec.Interval = 300 - (DiffLvl) * 30 - Scr += 100 - Select Case DiffLvl + If _diffC = (_diffLvl + 3) * 4 Then + _diffC = 0 + _diffLvl += 1 + If _diffLvl > 2 And _diffLvl < 7 Then _mainForm.TmProgSec.Interval = 300 - (_diffLvl) * 30 + _scr += 100 + Select Case _diffLvl Case 3 - PnDirCL = 3 - CtrlCL = 4 - CtrlRnd = 6 + _pnDirCl = 3 + _ctrlCl = 4 + _ctrlRnd = 6 Case 5 - PnDirCL = 2 - PnDirRnd = 4 + _pnDirCl = 2 + _pnDirRnd = 4 Case 8 - CtrlCL = 2 + _ctrlCl = 2 Case 10 - CtrlRnd = 4 - PnDirRnd = 3 + _ctrlRnd = 4 + _pnDirRnd = 3 End Select End If End Sub - Public Sub TestKey(Key0 As Integer) + Public Sub TestKey(key As Integer) If TestActive Then - Select Case Key0 + Select Case key Case Keys.Left - xCtrl -= 1 - sUpdateCtrl() + _xCtrl -= 1 + UpdateCtrl() Case Keys.Right - xCtrl += 1 - sUpdateCtrl() + _xCtrl += 1 + UpdateCtrl() Case Keys.Escape TestStop() End Select Else - If KeyCode(CtrlC) = Key0 Then - CtrlC += 1 - If CtrlC = KeyCode.Count Then + If _keyCode(_ctrlC) = key Then + _ctrlC += 1 + If _ctrlC = _keyCode.Count Then TestActive = True TestRun() End If Else - CtrlC = 0 + _ctrlC = 0 End If End If End Sub - Private Sub sAbort() + Private Sub Abort() Dim s As String, s1 As String - If TestAborted Then Exit Sub + If _testAborted Then Exit Sub - TestAborted = True + _testAborted = True - MyForm.TmProgSec.Stop() + _mainForm.TmProgSec.Stop() - MyForm.LvMsg.BeginUpdate() + _mainForm.LvMsg.BeginUpdate() - s = MyForm.LvMsg.Items(0).Text - MyForm.LvMsg.Items.RemoveAt(0) - MyForm.LvMsg.Items.Insert(0, "You crashed!" & Microsoft.VisualBasic.Right(s, Len(s) - 12)) + s = _mainForm.LvMsg.Items(0).Text + _mainForm.LvMsg.Items.RemoveAt(0) + _mainForm.LvMsg.Items.Insert(0, "You crashed!" & Microsoft.VisualBasic.Right(s, Len(s) - 12)) - s = MyForm.LvMsg.Items(1).Text - s1 = "Score: " & Scr & " " - MyForm.LvMsg.Items.RemoveAt(1) - MyForm.LvMsg.Items.Insert(1, s1 & Microsoft.VisualBasic.Right(s, Len(s) - Len(s1))) + s = _mainForm.LvMsg.Items(1).Text + s1 = "Score: " & _scr & " " + _mainForm.LvMsg.Items.RemoveAt(1) + _mainForm.LvMsg.Items.Insert(1, s1 & Microsoft.VisualBasic.Right(s, Len(s) - Len(s1))) - MyForm.LvMsg.EndUpdate() + _mainForm.LvMsg.EndUpdate() - LogFile.WriteToLog(MessageType.Normal, "*** Race Score: " & Scr.ToString("0000") & " ***") + LogFile.WriteToLog(MessageType.Normal, "*** Race Score: " & _scr.ToString("0000") & " ***") - CtrlC = 0 + _ctrlC = 0 TestActive = False - MyForm.ToolStripLbStatus.Text = MyForm.LastModeName & " Mode" + _mainForm.ToolStripLbStatus.Text = _mainForm._lastModeName & " Mode" End Sub - Private Sub sSetCtrl() - Dim x As Int16 - If Scr < 10 Then Exit Sub - Ctrls(RowLim + 1) = 0 - CtrlC += 1 - If CtrlC < CtrlCL Then Exit Sub - Select Case CInt(Int((CtrlRnd * Rnd()) + 1)) + Private Sub SetCtrl() + Dim x As Integer + If _scr < 10 Then Exit Sub + _ctrls(RowLim + 1) = 0 + _ctrlC += 1 + If _ctrlC < _ctrlCl Then Exit Sub + Select Case CInt(Int((_ctrlRnd * Rnd()) + 1)) Case 1, 2 - CtrlC = 0 + _ctrlC = 0 x = CInt(Int((7 * Rnd()) + 1)) - Ctrls(RowLim + 1) = x - Case Else + _ctrls(RowLim + 1) = x End Select End Sub - Private Sub sUpdateCtrl() + Private Sub UpdateCtrl() Dim s As String - If bInit < 21 Then - xCtrl = ColLim - 10 + If _bInit < 21 Then + _xCtrl = ColLim - 10 Exit Sub End If - If Math.Abs(xCtrl - Pnls(1)) > 5 Then - sAbort() + If Math.Abs(_xCtrl - _pnls(1)) > 5 Then + Abort() Exit Sub End If - s = Replace(MyForm.LvMsg.Items(RowLim - 1).Text.ToString, "∆", " ") & " " + s = Replace(_mainForm.LvMsg.Items(RowLim - 1).Text.ToString, "∆", " ") & " " s = Microsoft.VisualBasic.Left(s, ColLim + 15) 's = s.Remove(0, 20) 's = "Press <Esc> to Quit " & s - If Mid(s, xCtrl + 5, 1) = "X" Then - sAbort() + If Mid(s, _xCtrl + 5, 1) = "X" Then + Abort() Exit Sub End If - s = s.Remove(xCtrl + 4, 1) + s = s.Remove(_xCtrl + 4, 1) 's = Trim(s.Insert(xCar + 4, "∆")) & Space(ColLim + 5 - Streets(2)) & "Pts: " & Pts & " Lv: " & DiffLvl - s = Space(Pnls(2) - 1) & Trim(s.Insert(xCtrl + 4, "∆")) - MyForm.LvMsg.Items.RemoveAt(RowLim - 1) - MyForm.LvMsg.Items.Insert(RowLim - 1, s) - MyForm.ToolStripLbStatus.Text = "Score: " & Scr.ToString("0000") & " Press <Esc> to Quit" + s = Space(_pnls(2) - 1) & Trim(s.Insert(_xCtrl + 4, "∆")) + _mainForm.LvMsg.Items.RemoveAt(RowLim - 1) + _mainForm.LvMsg.Items.Insert(RowLim - 1, s) + _mainForm.ToolStripLbStatus.Text = "Score: " & _scr.ToString("0000") & " Press <Esc> to Quit" End Sub - Private Sub sSetPanel() + Private Sub SetPanel() Dim s As String s = "*| | |*" - If PRbAlt Then + If _pRbAlt Then s = s.Remove(5, 1) s = s.Insert(5, " ") End If - If Ctrls(RowLim + 1) <> 0 Then - s = s.Remove(Ctrls(RowLim + 1) + 1, 1) - s = s.Insert(Ctrls(RowLim + 1) + 1, "X") + If _ctrls(RowLim + 1) <> 0 Then + s = s.Remove(_ctrls(RowLim + 1) + 1, 1) + s = s.Insert(_ctrls(RowLim + 1) + 1, "X") End If - Select Case xPanel - Pnls(RowLim) + Select Case _xPanel - _pnls(RowLim) Case -1 s = Replace(s, "|", "\") Case 1 s = Replace(s, "|", "/") End Select - MyForm.LvMsg.Items.Insert(0, Space(xPanel - 1) & s) + _mainForm.LvMsg.Items.Insert(0, Space(_xPanel - 1) & s) End Sub - Private Sub sAlign() - PnDirC += 1 - If PnDirC < PnDirCL Then GoTo Lb1 - PnDirC = 0 - Select Case CInt(Int((PnDirRnd * Rnd()) + 1)) + Private Sub Align() + _pnDirC += 1 + If _pnDirC < _pnDirCl Then GoTo Lb1 + _pnDirC = 0 + Select Case CInt(Int((_pnDirRnd * Rnd()) + 1)) Case 1 - PnDir = 1 + _pnDir = 1 Case 2 - PnDir = -1 + _pnDir = -1 Case Else - PnDir = 0 + _pnDir = 0 End Select Lb1: - xPanel += PnDir - If xPanel > ColLim Then - xPanel = ColLim - ElseIf xPanel < 22 Then - xPanel = 22 + _xPanel += _pnDir + If _xPanel > ColLim Then + _xPanel = ColLim + ElseIf _xPanel < 22 Then + _xPanel = 22 End If - Pnls(RowLim + 1) = xPanel + _pnls(RowLim + 1) = _xPanel End Sub - Private Sub sLists() - Dim x As Int16 + Private Sub Lists() + Dim x As Integer For x = 2 To RowLim + 1 - Ctrls(x - 1) = Ctrls(x) - Pnls(x - 1) = Pnls(x) + _ctrls(x - 1) = _ctrls(x) + _pnls(x - 1) = _pnls(x) Next End Sub - Public Sub New(Form As MainForm) - MyForm = Form - KeyCode = New List(Of Integer) - KeyCode.Add(Keys.Up) - KeyCode.Add(Keys.Up) - KeyCode.Add(Keys.Down) - KeyCode.Add(Keys.Down) - KeyCode.Add(Keys.Left) - KeyCode.Add(Keys.Right) - KeyCode.Add(Keys.Left) - KeyCode.Add(Keys.Right) - KeyCode.Add(Keys.B) - KeyCode.Add(Keys.A) - CtrlC = 0 + Public Sub New(form As MainForm) + _mainForm = form + _keyCode = New List(Of Integer) + _keyCode.Add(Keys.Up) + _keyCode.Add(Keys.Up) + _keyCode.Add(Keys.Down) + _keyCode.Add(Keys.Down) + _keyCode.Add(Keys.Left) + _keyCode.Add(Keys.Right) + _keyCode.Add(Keys.Left) + _keyCode.Add(Keys.Right) + _keyCode.Add(Keys.B) + _keyCode.Add(Keys.A) + _ctrlC = 0 End Sub End Class Private Sub LvMsg_KeyDown(sender As Object, e As KeyEventArgs) Handles LvMsg.KeyDown - GUItest0.TestKey(e.KeyValue) - If GUItest0.TestActive Then e.SuppressKeyPress = True + _guItest.TestKey(e.KeyValue) + If _guItest.TestActive Then e.SuppressKeyPress = True End Sub Private Sub LvMsg_LostFocus(sender As Object, e As EventArgs) Handles LvMsg.LostFocus - If GUItest0.TestActive Then GUItest0.TestStop() + If _guItest.TestActive Then _guItest.TestStop() End Sub #End Region @@ -1894,22 +1905,22 @@ Lb1: End Sub Private Sub LvMsg_MouseDown(sender As Object, e As MouseEventArgs) Handles LvMsg.MouseDown - mouseDownOnListView = True + _mouseDownOnListView = True End Sub Private Sub LvMsg_MouseUp(sender As Object, e As MouseEventArgs) Handles LvMsg.MouseUp - mouseDownOnListView = False + _mouseDownOnListView = False End Sub Private Sub LvGEN_MouseUp(sender As Object, e As MouseEventArgs) Handles LvGEN.MouseUp If e.Button = MouseButtons.Right Then - ConMenTarget = LvGEN - ConMenTarJob = True + _conMenTarget = LvGEN + _conMenTarJob = True 'Locked functions show/hide - LoadListToolStripMenuItem.Enabled = Not GUIlocked - LoadDefaultListToolStripMenuItem.Enabled = Not GUIlocked - ClearListToolStripMenuItem.Enabled = Not GUIlocked + LoadListToolStripMenuItem.Enabled = Not _guIlocked + LoadDefaultListToolStripMenuItem.Enabled = Not _guIlocked + ClearListToolStripMenuItem.Enabled = Not _guIlocked ConMenFilelist.Show(MousePosition) End If @@ -1917,4 +1928,13 @@ Lb1: Private Sub RbDev_CheckedChanged(sender As Object, e As EventArgs) Handles RbDev.CheckedChanged End Sub + + + Private Class VectoProgress + Public Target As String + Public Message As String + Public Link As String + End Class End Class + + diff --git a/VECTO/GUI/Settings.vb b/VECTO/GUI/Settings.vb index 1503e05c3dd4ff3bbb4cfd02dd192edcdd63dfb2..d379733cf07684e89bf0910629d4cbc7c9eddfce 100644 --- a/VECTO/GUI/Settings.vb +++ b/VECTO/GUI/Settings.vb @@ -10,6 +10,7 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.IO Imports System.Text.RegularExpressions +Imports TUGraz.VectoCommon.Utils ''' <summary> ''' Settings form @@ -24,7 +25,7 @@ Public Class Settings Private Sub LoadSettings() - TextBoxLogSize.Text = Cfg.LogSize + TextBoxLogSize.Text = Cfg.LogSize.ToGUIFormat() TbAirDensity.Text = CStr(Cfg.AirDensity) TbOpenCmd.Text = Cfg.OpenCmd TbOpenCmdName.Text = Cfg.OpenCmdName @@ -72,11 +73,11 @@ Public Class Settings 'Help button Private Sub BtHelp_Click(sender As Object, e As EventArgs) Handles BtHelp.Click If File.Exists(MyAppPath & "User Manual\help.html") Then - Dim BrowserRegistryString As String = + Dim browserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString - Dim DefaultBrowserPath As String = - Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - Process.Start(DefaultBrowserPath, + Dim defaultBrowserPath As String = + Regex.Match(browserRegistryString, "(\"".*?\"")").Captures(0).ToString + Process.Start(defaultBrowserPath, String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#settings")) Else MsgBox("User Manual not found!", MsgBoxStyle.Critical) diff --git a/VECTO/GUI/VectoJobForm.Designer.vb b/VECTO/GUI/VectoJobForm.Designer.vb index 2cf5335deed16983df889b2386888155cf3d907e..0970652f0169f7261d15f7000d2c3e0918764b11 100644 --- a/VECTO/GUI/VectoJobForm.Designer.vb +++ b/VECTO/GUI/VectoJobForm.Designer.vb @@ -25,116 +25,121 @@ Partial Class VectoJobForm 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. <DebuggerStepThrough()> _ Private Sub InitializeComponent() - Me.components = New Container() - Dim resources As ComponentResourceManager = New ComponentResourceManager(GetType(VectoJobForm)) - Me.TabPgGen = New TabPage() - Me.GrCycles = New GroupBox() - Me.Label2 = New Label() - Me.LvCycles = New ListView() - Me.ColumnHeader1 = CType(New ColumnHeader(), ColumnHeader) - Me.BtDRIrem = New Button() - Me.BtDRIadd = New Button() - Me.GrAux = New GroupBox() - Me.btnAAUXOpen = New Button() - Me.Label1 = New Label() - Me.btnBrowseAAUXFile = New Button() - Me.txtAdvancedAuxiliaryFile = New TextBox() - Me.picAuxInfo = New PictureBox() - Me.cboAdvancedAuxiliaries = New ComboBox() - Me.lbAdvancedAuxiliaries = New Label() - Me.Label32 = New Label() - Me.LvAux = New ListView() - Me.ColumnHeader4 = CType(New ColumnHeader(), ColumnHeader) - Me.ColumnHeader5 = CType(New ColumnHeader(), ColumnHeader) - Me.ColumnHeader6 = CType(New ColumnHeader(), ColumnHeader) - Me.ButAuxRem = New Button() - Me.ButAuxAdd = New Button() - Me.TbGBX = New TextBox() - Me.TbENG = New TextBox() - Me.TbVEH = New TextBox() - Me.ButOpenGBX = New Button() - Me.ButOpenENG = New Button() - Me.ButOpenVEH = New Button() - Me.ButtonVEH = New Button() - Me.ButtonGBX = New Button() - Me.ButtonMAP = New Button() - Me.TabControl1 = New TabControl() - Me.TabPgDriver = New TabPage() - Me.GrVACC = New GroupBox() - Me.TbDesMaxFile = New TextBox() - Me.BtDesMaxBr = New Button() - Me.BtAccOpen = New Button() - Me.GrLAC = New GroupBox() - Me.Label12 = New Label() - Me.tbDfCoastingScale = New TextBox() - Me.CbLookAhead = New CheckBox() - Me.Label11 = New Label() - Me.Label3 = New Label() - Me.tbDfCoastingOffset = New TextBox() - Me.tbLacDfTargetSpeedFile = New TextBox() - Me.Label10 = New Label() - Me.Label4 = New Label() - Me.Label5 = New Label() - Me.btnDfTargetSpeed = New Button() - Me.tbLacPreviewFactor = New TextBox() - Me.tbLacDfVelocityDropFile = New TextBox() - Me.GroupBox1 = New GroupBox() - Me.PnEcoRoll = New Panel() - Me.Label21 = New Label() - Me.Label20 = New Label() - Me.Label14 = New Label() - Me.TbVmin = New TextBox() - Me.TbUnderSpeed = New TextBox() - Me.TbOverspeed = New TextBox() - Me.Label23 = New Label() - Me.Label22 = New Label() - Me.Label13 = New Label() - Me.RdEcoRoll = New RadioButton() - Me.RdOverspeed = New RadioButton() - Me.RdOff = New RadioButton() - Me.GrStartStop = New GroupBox() - Me.PnStartStop = New Panel() - Me.Label31 = New Label() - Me.Label27 = New Label() - Me.TbSSspeed = New TextBox() - Me.LabelSSspeed = New Label() - Me.Label26 = New Label() - Me.Label30 = New Label() - Me.LabelSStime = New Label() - Me.TbSSdelay = New TextBox() - Me.TbSStime = New TextBox() - Me.ChBStartStop = New CheckBox() - Me.StatusStrip1 = New StatusStrip() - Me.ToolStripStatusLabelGEN = New ToolStripStatusLabel() - Me.ButOK = New Button() - Me.ButCancel = New Button() - Me.ToolStrip1 = New ToolStrip() - Me.ToolStripBtNew = New ToolStripButton() - Me.ToolStripBtOpen = New ToolStripButton() - Me.ToolStripBtSave = New ToolStripButton() - Me.ToolStripBtSaveAs = New ToolStripButton() - Me.ToolStripSeparator1 = New ToolStripSeparator() - Me.ToolStripBtSendTo = New ToolStripButton() - Me.ToolStripSeparator2 = New ToolStripSeparator() - Me.ToolStripButton1 = New ToolStripButton() - Me.PictureBox1 = New PictureBox() - Me.CbEngOnly = New CheckBox() - Me.CmOpenFile = New ContextMenuStrip(Me.components) - Me.OpenWithToolStripMenuItem = New ToolStripMenuItem() - Me.ShowInFolderToolStripMenuItem = New ToolStripMenuItem() - Me.PicVehicle = New PictureBox() - Me.PicBox = New PictureBox() - Me.TbEngTxt = New TextBox() - Me.TbVehCat = New TextBox() - Me.TbAxleConf = New TextBox() - Me.TbHVCclass = New TextBox() - Me.TbGbxTxt = New TextBox() - Me.TbMass = New TextBox() - Me.ToolTip1 = New ToolTip(Me.components) + Me.components = New System.ComponentModel.Container() + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(VectoJobForm)) + Me.TabPgGen = New System.Windows.Forms.TabPage() + Me.GrCycles = New System.Windows.Forms.GroupBox() + Me.Label2 = New System.Windows.Forms.Label() + Me.LvCycles = New System.Windows.Forms.ListView() + Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.BtDRIrem = New System.Windows.Forms.Button() + Me.BtDRIadd = New System.Windows.Forms.Button() + Me.GrAux = New System.Windows.Forms.GroupBox() + Me.btnAAUXOpen = New System.Windows.Forms.Button() + Me.Label1 = New System.Windows.Forms.Label() + Me.btnBrowseAAUXFile = New System.Windows.Forms.Button() + Me.txtAdvancedAuxiliaryFile = New System.Windows.Forms.TextBox() + Me.picAuxInfo = New System.Windows.Forms.PictureBox() + Me.cboAdvancedAuxiliaries = New System.Windows.Forms.ComboBox() + Me.lbAdvancedAuxiliaries = New System.Windows.Forms.Label() + Me.Label32 = New System.Windows.Forms.Label() + Me.LvAux = New System.Windows.Forms.ListView() + Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader5 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader6 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ButAuxRem = New System.Windows.Forms.Button() + Me.ButAuxAdd = New System.Windows.Forms.Button() + Me.TbGBX = New System.Windows.Forms.TextBox() + Me.TbENG = New System.Windows.Forms.TextBox() + Me.TbVEH = New System.Windows.Forms.TextBox() + Me.ButOpenGBX = New System.Windows.Forms.Button() + Me.ButOpenENG = New System.Windows.Forms.Button() + Me.ButOpenVEH = New System.Windows.Forms.Button() + Me.ButtonVEH = New System.Windows.Forms.Button() + Me.ButtonGBX = New System.Windows.Forms.Button() + Me.ButtonMAP = New System.Windows.Forms.Button() + Me.TabControl1 = New System.Windows.Forms.TabControl() + Me.TabPgDriver = New System.Windows.Forms.TabPage() + Me.GrVACC = New System.Windows.Forms.GroupBox() + Me.TbDesMaxFile = New System.Windows.Forms.TextBox() + Me.BtDesMaxBr = New System.Windows.Forms.Button() + Me.BtAccOpen = New System.Windows.Forms.Button() + Me.GrLAC = New System.Windows.Forms.GroupBox() + Me.CbLookAhead = New System.Windows.Forms.CheckBox() + Me.GroupBox1 = New System.Windows.Forms.GroupBox() + Me.PnEcoRoll = New System.Windows.Forms.Panel() + Me.Label21 = New System.Windows.Forms.Label() + Me.Label20 = New System.Windows.Forms.Label() + Me.Label14 = New System.Windows.Forms.Label() + Me.TbVmin = New System.Windows.Forms.TextBox() + Me.TbUnderSpeed = New System.Windows.Forms.TextBox() + Me.TbOverspeed = New System.Windows.Forms.TextBox() + Me.Label23 = New System.Windows.Forms.Label() + Me.Label22 = New System.Windows.Forms.Label() + Me.Label13 = New System.Windows.Forms.Label() + Me.RdEcoRoll = New System.Windows.Forms.RadioButton() + Me.RdOverspeed = New System.Windows.Forms.RadioButton() + Me.RdOff = New System.Windows.Forms.RadioButton() + Me.GrStartStop = New System.Windows.Forms.GroupBox() + Me.PnStartStop = New System.Windows.Forms.Panel() + Me.Label31 = New System.Windows.Forms.Label() + Me.Label27 = New System.Windows.Forms.Label() + Me.TbSSspeed = New System.Windows.Forms.TextBox() + Me.LabelSSspeed = New System.Windows.Forms.Label() + Me.Label26 = New System.Windows.Forms.Label() + Me.Label30 = New System.Windows.Forms.Label() + Me.LabelSStime = New System.Windows.Forms.Label() + Me.TbSSdelay = New System.Windows.Forms.TextBox() + Me.TbSStime = New System.Windows.Forms.TextBox() + Me.ChBStartStop = New System.Windows.Forms.CheckBox() + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() + Me.ToolStripStatusLabelGEN = New System.Windows.Forms.ToolStripStatusLabel() + Me.ButOK = New System.Windows.Forms.Button() + Me.ButCancel = New System.Windows.Forms.Button() + Me.ToolStrip1 = New System.Windows.Forms.ToolStrip() + Me.ToolStripBtNew = New System.Windows.Forms.ToolStripButton() + Me.ToolStripBtOpen = New System.Windows.Forms.ToolStripButton() + Me.ToolStripBtSave = New System.Windows.Forms.ToolStripButton() + Me.ToolStripBtSaveAs = New System.Windows.Forms.ToolStripButton() + Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator() + Me.ToolStripBtSendTo = New System.Windows.Forms.ToolStripButton() + Me.ToolStripSeparator2 = New System.Windows.Forms.ToolStripSeparator() + Me.ToolStripButton1 = New System.Windows.Forms.ToolStripButton() + Me.PictureBox1 = New System.Windows.Forms.PictureBox() + Me.CbEngOnly = New System.Windows.Forms.CheckBox() + Me.CmOpenFile = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.OpenWithToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.ShowInFolderToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.PicVehicle = New System.Windows.Forms.PictureBox() + Me.PicBox = New System.Windows.Forms.PictureBox() + Me.TbEngTxt = New System.Windows.Forms.TextBox() + Me.TbVehCat = New System.Windows.Forms.TextBox() + Me.TbAxleConf = New System.Windows.Forms.TextBox() + Me.TbHVCclass = New System.Windows.Forms.TextBox() + Me.TbGbxTxt = New System.Windows.Forms.TextBox() + Me.TbMass = New System.Windows.Forms.TextBox() + Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) + Me.pnLookAheadCoasting = New System.Windows.Forms.Panel() + Me.btnDfVelocityDrop = New System.Windows.Forms.Button() + Me.Label12 = New System.Windows.Forms.Label() + Me.tbDfCoastingScale = New System.Windows.Forms.TextBox() + Me.Label11 = New System.Windows.Forms.Label() + Me.Label3 = New System.Windows.Forms.Label() + Me.tbDfCoastingOffset = New System.Windows.Forms.TextBox() + Me.tbLacDfTargetSpeedFile = New System.Windows.Forms.TextBox() + Me.Label10 = New System.Windows.Forms.Label() + Me.Label4 = New System.Windows.Forms.Label() + Me.Label5 = New System.Windows.Forms.Label() + Me.btnDfTargetSpeed = New System.Windows.Forms.Button() + Me.tbLacPreviewFactor = New System.Windows.Forms.TextBox() + Me.tbLacDfVelocityDropFile = New System.Windows.Forms.TextBox() + Me.Label6 = New System.Windows.Forms.Label() + Me.tbLacMinSpeed = New System.Windows.Forms.TextBox() + Me.Label7 = New System.Windows.Forms.Label() Me.TabPgGen.SuspendLayout() Me.GrCycles.SuspendLayout() Me.GrAux.SuspendLayout() - CType(Me.picAuxInfo, ISupportInitialize).BeginInit() + CType(Me.picAuxInfo, System.ComponentModel.ISupportInitialize).BeginInit() Me.TabControl1.SuspendLayout() Me.TabPgDriver.SuspendLayout() Me.GrVACC.SuspendLayout() @@ -145,10 +150,11 @@ Partial Class VectoJobForm Me.PnStartStop.SuspendLayout() Me.StatusStrip1.SuspendLayout() Me.ToolStrip1.SuspendLayout() - CType(Me.PictureBox1, ISupportInitialize).BeginInit() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.CmOpenFile.SuspendLayout() - CType(Me.PicVehicle, ISupportInitialize).BeginInit() - CType(Me.PicBox, ISupportInitialize).BeginInit() + CType(Me.PicVehicle, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.PicBox, System.ComponentModel.ISupportInitialize).BeginInit() + Me.pnLookAheadCoasting.SuspendLayout() Me.SuspendLayout() ' 'TabPgGen @@ -164,58 +170,58 @@ Partial Class VectoJobForm Me.TabPgGen.Controls.Add(Me.ButtonVEH) Me.TabPgGen.Controls.Add(Me.ButtonGBX) Me.TabPgGen.Controls.Add(Me.ButtonMAP) - Me.TabPgGen.Location = New Point(4, 22) + Me.TabPgGen.Location = New System.Drawing.Point(4, 22) Me.TabPgGen.Name = "TabPgGen" - Me.TabPgGen.Padding = New Padding(3) - Me.TabPgGen.Size = New Size(527, 534) + Me.TabPgGen.Padding = New System.Windows.Forms.Padding(3) + Me.TabPgGen.Size = New System.Drawing.Size(527, 534) Me.TabPgGen.TabIndex = 0 Me.TabPgGen.Text = "General" Me.TabPgGen.UseVisualStyleBackColor = True ' 'GrCycles ' - Me.GrCycles.Anchor = CType((((AnchorStyles.Top Or AnchorStyles.Bottom) _ - Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) + Me.GrCycles.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.GrCycles.Controls.Add(Me.Label2) Me.GrCycles.Controls.Add(Me.LvCycles) Me.GrCycles.Controls.Add(Me.BtDRIrem) Me.GrCycles.Controls.Add(Me.BtDRIadd) - Me.GrCycles.Location = New Point(9, 314) + Me.GrCycles.Location = New System.Drawing.Point(9, 314) Me.GrCycles.Name = "GrCycles" - Me.GrCycles.Size = New Size(515, 184) + Me.GrCycles.Size = New System.Drawing.Size(515, 184) Me.GrCycles.TabIndex = 10 Me.GrCycles.TabStop = False Me.GrCycles.Text = "Cycles" ' 'Label2 ' - Me.Label2.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) + Me.Label2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.Label2.AutoSize = True - Me.Label2.Location = New Point(379, 148) + Me.Label2.Location = New System.Drawing.Point(379, 148) Me.Label2.Name = "Label2" - Me.Label2.Size = New Size(133, 13) + Me.Label2.Size = New System.Drawing.Size(133, 13) Me.Label2.TabIndex = 3 Me.Label2.Text = "(Double-Click to Open File)" ' 'LvCycles ' - Me.LvCycles.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.LvCycles.Columns.AddRange(New ColumnHeader() {Me.ColumnHeader1}) + Me.LvCycles.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.LvCycles.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1}) Me.LvCycles.FullRowSelect = True Me.LvCycles.GridLines = True - Me.LvCycles.HeaderStyle = ColumnHeaderStyle.None + Me.LvCycles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None Me.LvCycles.HideSelection = False Me.LvCycles.LabelEdit = True - Me.LvCycles.Location = New Point(6, 25) + Me.LvCycles.Location = New System.Drawing.Point(6, 25) Me.LvCycles.MultiSelect = False Me.LvCycles.Name = "LvCycles" - Me.LvCycles.Size = New Size(503, 123) + Me.LvCycles.Size = New System.Drawing.Size(503, 123) Me.LvCycles.TabIndex = 0 Me.LvCycles.TabStop = False Me.LvCycles.UseCompatibleStateImageBehavior = False - Me.LvCycles.View = View.Details + Me.LvCycles.View = System.Windows.Forms.View.Details ' 'ColumnHeader1 ' @@ -224,29 +230,29 @@ Partial Class VectoJobForm ' 'BtDRIrem ' - Me.BtDRIrem.Anchor = CType((AnchorStyles.Bottom Or AnchorStyles.Left), AnchorStyles) - Me.BtDRIrem.Image = My.Resources.Resources.minus_circle_icon - Me.BtDRIrem.Location = New Point(29, 149) + Me.BtDRIrem.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.BtDRIrem.Image = Global.TUGraz.VECTO.My.Resources.Resources.minus_circle_icon + Me.BtDRIrem.Location = New System.Drawing.Point(29, 149) Me.BtDRIrem.Name = "BtDRIrem" - Me.BtDRIrem.Size = New Size(24, 24) + Me.BtDRIrem.Size = New System.Drawing.Size(24, 24) Me.BtDRIrem.TabIndex = 2 Me.BtDRIrem.UseVisualStyleBackColor = True ' 'BtDRIadd ' - Me.BtDRIadd.Anchor = CType((AnchorStyles.Bottom Or AnchorStyles.Left), AnchorStyles) - Me.BtDRIadd.Image = My.Resources.Resources.plus_circle_icon - Me.BtDRIadd.Location = New Point(5, 149) + Me.BtDRIadd.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.BtDRIadd.Image = Global.TUGraz.VECTO.My.Resources.Resources.plus_circle_icon + Me.BtDRIadd.Location = New System.Drawing.Point(5, 149) Me.BtDRIadd.Name = "BtDRIadd" - Me.BtDRIadd.Size = New Size(24, 24) + Me.BtDRIadd.Size = New System.Drawing.Size(24, 24) Me.BtDRIadd.TabIndex = 1 Me.BtDRIadd.UseVisualStyleBackColor = True ' 'GrAux ' - Me.GrAux.Anchor = CType((((AnchorStyles.Top Or AnchorStyles.Bottom) _ - Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) + Me.GrAux.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.GrAux.Controls.Add(Me.btnAAUXOpen) Me.GrAux.Controls.Add(Me.Label1) Me.GrAux.Controls.Add(Me.btnBrowseAAUXFile) @@ -258,102 +264,102 @@ Partial Class VectoJobForm Me.GrAux.Controls.Add(Me.LvAux) Me.GrAux.Controls.Add(Me.ButAuxRem) Me.GrAux.Controls.Add(Me.ButAuxAdd) - Me.GrAux.Location = New Point(6, 87) + Me.GrAux.Location = New System.Drawing.Point(6, 87) Me.GrAux.Name = "GrAux" - Me.GrAux.Size = New Size(515, 221) + Me.GrAux.Size = New System.Drawing.Size(515, 221) Me.GrAux.TabIndex = 9 Me.GrAux.TabStop = False Me.GrAux.Text = "Auxiliaries" ' 'btnAAUXOpen ' - Me.btnAAUXOpen.Image = My.Resources.Resources.application_export_icon_small - Me.btnAAUXOpen.Location = New Point(465, 45) + Me.btnAAUXOpen.Image = Global.TUGraz.VECTO.My.Resources.Resources.application_export_icon_small + Me.btnAAUXOpen.Location = New System.Drawing.Point(465, 45) Me.btnAAUXOpen.Name = "btnAAUXOpen" - Me.btnAAUXOpen.Size = New Size(24, 24) + Me.btnAAUXOpen.Size = New System.Drawing.Size(24, 24) Me.btnAAUXOpen.TabIndex = 41 Me.btnAAUXOpen.UseVisualStyleBackColor = True ' 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New Point(7, 52) + Me.Label1.Location = New System.Drawing.Point(7, 52) Me.Label1.Name = "Label1" - Me.Label1.Size = New Size(96, 13) + Me.Label1.Size = New System.Drawing.Size(96, 13) Me.Label1.TabIndex = 40 Me.Label1.Text = "Advanced Aux File" ' 'btnBrowseAAUXFile ' - Me.btnBrowseAAUXFile.Image = My.Resources.Resources.Open_icon - Me.btnBrowseAAUXFile.Location = New Point(441, 45) + Me.btnBrowseAAUXFile.Image = Global.TUGraz.VECTO.My.Resources.Resources.Open_icon + Me.btnBrowseAAUXFile.Location = New System.Drawing.Point(441, 45) Me.btnBrowseAAUXFile.Name = "btnBrowseAAUXFile" - Me.btnBrowseAAUXFile.Size = New Size(24, 24) + Me.btnBrowseAAUXFile.Size = New System.Drawing.Size(24, 24) Me.btnBrowseAAUXFile.TabIndex = 39 Me.ToolTip1.SetToolTip(Me.btnBrowseAAUXFile, "Configure/Browser Advanced Auxiliary Files") Me.btnBrowseAAUXFile.UseVisualStyleBackColor = True ' 'txtAdvancedAuxiliaryFile ' - Me.txtAdvancedAuxiliaryFile.Location = New Point(119, 47) + Me.txtAdvancedAuxiliaryFile.Location = New System.Drawing.Point(119, 47) Me.txtAdvancedAuxiliaryFile.Name = "txtAdvancedAuxiliaryFile" - Me.txtAdvancedAuxiliaryFile.Size = New Size(321, 20) + Me.txtAdvancedAuxiliaryFile.Size = New System.Drawing.Size(321, 20) Me.txtAdvancedAuxiliaryFile.TabIndex = 38 ' 'picAuxInfo ' - Me.picAuxInfo.Image = My.Resources.Resources.Information_icon - Me.picAuxInfo.InitialImage = My.Resources.Resources.Information_icon - Me.picAuxInfo.Location = New Point(451, 19) + Me.picAuxInfo.Image = Global.TUGraz.VECTO.My.Resources.Resources.Information_icon + Me.picAuxInfo.InitialImage = Global.TUGraz.VECTO.My.Resources.Resources.Information_icon + Me.picAuxInfo.Location = New System.Drawing.Point(451, 19) Me.picAuxInfo.Name = "picAuxInfo" - Me.picAuxInfo.Size = New Size(16, 16) - Me.picAuxInfo.SizeMode = PictureBoxSizeMode.AutoSize + Me.picAuxInfo.Size = New System.Drawing.Size(16, 16) + Me.picAuxInfo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize Me.picAuxInfo.TabIndex = 37 Me.picAuxInfo.TabStop = False ' 'cboAdvancedAuxiliaries ' Me.cboAdvancedAuxiliaries.FormattingEnabled = True - Me.cboAdvancedAuxiliaries.Location = New Point(119, 18) + Me.cboAdvancedAuxiliaries.Location = New System.Drawing.Point(119, 18) Me.cboAdvancedAuxiliaries.Name = "cboAdvancedAuxiliaries" - Me.cboAdvancedAuxiliaries.Size = New Size(321, 21) + Me.cboAdvancedAuxiliaries.Size = New System.Drawing.Size(321, 21) Me.cboAdvancedAuxiliaries.TabIndex = 36 ' 'lbAdvancedAuxiliaries ' Me.lbAdvancedAuxiliaries.AutoSize = True - Me.lbAdvancedAuxiliaries.Location = New Point(7, 21) + Me.lbAdvancedAuxiliaries.Location = New System.Drawing.Point(7, 21) Me.lbAdvancedAuxiliaries.Name = "lbAdvancedAuxiliaries" - Me.lbAdvancedAuxiliaries.Size = New Size(72, 13) + Me.lbAdvancedAuxiliaries.Size = New System.Drawing.Size(72, 13) Me.lbAdvancedAuxiliaries.TabIndex = 35 Me.lbAdvancedAuxiliaries.Text = "Auxiliary Type" ' 'Label32 ' - Me.Label32.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) + Me.Label32.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.Label32.AutoSize = True - Me.Label32.Location = New Point(406, 189) + Me.Label32.Location = New System.Drawing.Point(406, 189) Me.Label32.Name = "Label32" - Me.Label32.Size = New Size(106, 13) + Me.Label32.Size = New System.Drawing.Size(106, 13) Me.Label32.TabIndex = 3 Me.Label32.Text = "(Double-Click to Edit)" ' 'LvAux ' - Me.LvAux.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.LvAux.Columns.AddRange(New ColumnHeader() {Me.ColumnHeader4, Me.ColumnHeader5, Me.ColumnHeader6}) + Me.LvAux.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.LvAux.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader4, Me.ColumnHeader5, Me.ColumnHeader6}) Me.LvAux.FullRowSelect = True Me.LvAux.GridLines = True Me.LvAux.HideSelection = False - Me.LvAux.Location = New Point(6, 72) + Me.LvAux.Location = New System.Drawing.Point(6, 72) Me.LvAux.MultiSelect = False Me.LvAux.Name = "LvAux" - Me.LvAux.Size = New Size(503, 117) + Me.LvAux.Size = New System.Drawing.Size(503, 117) Me.LvAux.TabIndex = 0 Me.LvAux.TabStop = False Me.LvAux.UseCompatibleStateImageBehavior = False - Me.LvAux.View = View.Details + Me.LvAux.View = System.Windows.Forms.View.Details ' 'ColumnHeader4 ' @@ -372,54 +378,54 @@ Partial Class VectoJobForm ' 'ButAuxRem ' - Me.ButAuxRem.Image = My.Resources.Resources.minus_circle_icon - Me.ButAuxRem.Location = New Point(29, 190) + Me.ButAuxRem.Image = Global.TUGraz.VECTO.My.Resources.Resources.minus_circle_icon + Me.ButAuxRem.Location = New System.Drawing.Point(29, 190) Me.ButAuxRem.Name = "ButAuxRem" - Me.ButAuxRem.Size = New Size(24, 24) + Me.ButAuxRem.Size = New System.Drawing.Size(24, 24) Me.ButAuxRem.TabIndex = 2 Me.ButAuxRem.UseVisualStyleBackColor = True ' 'ButAuxAdd ' - Me.ButAuxAdd.Image = My.Resources.Resources.plus_circle_icon - Me.ButAuxAdd.Location = New Point(5, 190) + Me.ButAuxAdd.Image = Global.TUGraz.VECTO.My.Resources.Resources.plus_circle_icon + Me.ButAuxAdd.Location = New System.Drawing.Point(5, 190) Me.ButAuxAdd.Name = "ButAuxAdd" - Me.ButAuxAdd.Size = New Size(24, 24) + Me.ButAuxAdd.Size = New System.Drawing.Size(24, 24) Me.ButAuxAdd.TabIndex = 1 Me.ButAuxAdd.UseVisualStyleBackColor = True ' 'TbGBX ' - Me.TbGBX.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.TbGBX.Location = New Point(84, 60) + Me.TbGBX.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TbGBX.Location = New System.Drawing.Point(84, 60) Me.TbGBX.Name = "TbGBX" - Me.TbGBX.Size = New Size(411, 20) + Me.TbGBX.Size = New System.Drawing.Size(411, 20) Me.TbGBX.TabIndex = 7 ' 'TbENG ' - Me.TbENG.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.TbENG.Location = New Point(84, 33) + Me.TbENG.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TbENG.Location = New System.Drawing.Point(84, 33) Me.TbENG.Name = "TbENG" - Me.TbENG.Size = New Size(411, 20) + Me.TbENG.Size = New System.Drawing.Size(411, 20) Me.TbENG.TabIndex = 4 ' 'TbVEH ' - Me.TbVEH.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.TbVEH.Location = New Point(84, 7) + Me.TbVEH.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TbVEH.Location = New System.Drawing.Point(84, 7) Me.TbVEH.Name = "TbVEH" - Me.TbVEH.Size = New Size(411, 20) + Me.TbVEH.Size = New System.Drawing.Size(411, 20) Me.TbVEH.TabIndex = 1 ' 'ButOpenGBX ' - Me.ButOpenGBX.Location = New Point(6, 60) + Me.ButOpenGBX.Location = New System.Drawing.Point(6, 60) Me.ButOpenGBX.Name = "ButOpenGBX" - Me.ButOpenGBX.Size = New Size(72, 21) + Me.ButOpenGBX.Size = New System.Drawing.Size(72, 21) Me.ButOpenGBX.TabIndex = 6 Me.ButOpenGBX.TabStop = False Me.ButOpenGBX.Text = "Gearbox" @@ -427,9 +433,9 @@ Partial Class VectoJobForm ' 'ButOpenENG ' - Me.ButOpenENG.Location = New Point(6, 33) + Me.ButOpenENG.Location = New System.Drawing.Point(6, 33) Me.ButOpenENG.Name = "ButOpenENG" - Me.ButOpenENG.Size = New Size(72, 21) + Me.ButOpenENG.Size = New System.Drawing.Size(72, 21) Me.ButOpenENG.TabIndex = 3 Me.ButOpenENG.TabStop = False Me.ButOpenENG.Text = "Engine" @@ -437,9 +443,9 @@ Partial Class VectoJobForm ' 'ButOpenVEH ' - Me.ButOpenVEH.Location = New Point(6, 6) + Me.ButOpenVEH.Location = New System.Drawing.Point(6, 6) Me.ButOpenVEH.Name = "ButOpenVEH" - Me.ButOpenVEH.Size = New Size(72, 21) + Me.ButOpenVEH.Size = New System.Drawing.Size(72, 21) Me.ButOpenVEH.TabIndex = 0 Me.ButOpenVEH.TabStop = False Me.ButOpenVEH.Text = "Vehicle" @@ -447,48 +453,48 @@ Partial Class VectoJobForm ' 'ButtonVEH ' - Me.ButtonVEH.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) - Me.ButtonVEH.Image = CType(resources.GetObject("ButtonVEH.Image"), Image) - Me.ButtonVEH.Location = New Point(496, 5) + Me.ButtonVEH.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonVEH.Image = CType(resources.GetObject("ButtonVEH.Image"), System.Drawing.Image) + Me.ButtonVEH.Location = New System.Drawing.Point(496, 5) Me.ButtonVEH.Name = "ButtonVEH" - Me.ButtonVEH.Size = New Size(24, 24) + Me.ButtonVEH.Size = New System.Drawing.Size(24, 24) Me.ButtonVEH.TabIndex = 2 Me.ButtonVEH.TabStop = False Me.ButtonVEH.UseVisualStyleBackColor = True ' 'ButtonGBX ' - Me.ButtonGBX.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) - Me.ButtonGBX.Image = CType(resources.GetObject("ButtonGBX.Image"), Image) - Me.ButtonGBX.Location = New Point(496, 58) + Me.ButtonGBX.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonGBX.Image = CType(resources.GetObject("ButtonGBX.Image"), System.Drawing.Image) + Me.ButtonGBX.Location = New System.Drawing.Point(496, 58) Me.ButtonGBX.Name = "ButtonGBX" - Me.ButtonGBX.Size = New Size(24, 24) + Me.ButtonGBX.Size = New System.Drawing.Size(24, 24) Me.ButtonGBX.TabIndex = 8 Me.ButtonGBX.TabStop = False Me.ButtonGBX.UseVisualStyleBackColor = True ' 'ButtonMAP ' - Me.ButtonMAP.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) - Me.ButtonMAP.Image = CType(resources.GetObject("ButtonMAP.Image"), Image) - Me.ButtonMAP.Location = New Point(496, 31) + Me.ButtonMAP.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonMAP.Image = CType(resources.GetObject("ButtonMAP.Image"), System.Drawing.Image) + Me.ButtonMAP.Location = New System.Drawing.Point(496, 31) Me.ButtonMAP.Name = "ButtonMAP" - Me.ButtonMAP.Size = New Size(24, 24) + Me.ButtonMAP.Size = New System.Drawing.Size(24, 24) Me.ButtonMAP.TabIndex = 5 Me.ButtonMAP.TabStop = False Me.ButtonMAP.UseVisualStyleBackColor = True ' 'TabControl1 ' - Me.TabControl1.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) + Me.TabControl1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.TabControl1.Controls.Add(Me.TabPgGen) Me.TabControl1.Controls.Add(Me.TabPgDriver) - Me.TabControl1.Location = New Point(1, 107) + Me.TabControl1.Location = New System.Drawing.Point(1, 107) Me.TabControl1.Name = "TabControl1" Me.TabControl1.SelectedIndex = 0 - Me.TabControl1.Size = New Size(535, 560) - Me.TabControl1.SizeMode = TabSizeMode.Fixed + Me.TabControl1.Size = New System.Drawing.Size(535, 560) + Me.TabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed Me.TabControl1.TabIndex = 0 ' 'TabPgDriver @@ -497,10 +503,10 @@ Partial Class VectoJobForm Me.TabPgDriver.Controls.Add(Me.GrLAC) Me.TabPgDriver.Controls.Add(Me.GroupBox1) Me.TabPgDriver.Controls.Add(Me.GrStartStop) - Me.TabPgDriver.Location = New Point(4, 22) + Me.TabPgDriver.Location = New System.Drawing.Point(4, 22) Me.TabPgDriver.Name = "TabPgDriver" - Me.TabPgDriver.Padding = New Padding(3) - Me.TabPgDriver.Size = New Size(527, 534) + Me.TabPgDriver.Padding = New System.Windows.Forms.Padding(3) + Me.TabPgDriver.Size = New System.Drawing.Size(527, 534) Me.TabPgDriver.TabIndex = 7 Me.TabPgDriver.Text = "Driver Assist" Me.TabPgDriver.UseVisualStyleBackColor = True @@ -510,193 +516,75 @@ Partial Class VectoJobForm Me.GrVACC.Controls.Add(Me.TbDesMaxFile) Me.GrVACC.Controls.Add(Me.BtDesMaxBr) Me.GrVACC.Controls.Add(Me.BtAccOpen) - Me.GrVACC.Location = New Point(6, 459) + Me.GrVACC.Location = New System.Drawing.Point(6, 459) Me.GrVACC.Name = "GrVACC" - Me.GrVACC.Size = New Size(515, 65) + Me.GrVACC.Size = New System.Drawing.Size(515, 65) Me.GrVACC.TabIndex = 3 Me.GrVACC.TabStop = False Me.GrVACC.Text = "Max. acceleration and brake curves" ' 'TbDesMaxFile ' - Me.TbDesMaxFile.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.TbDesMaxFile.Location = New Point(6, 29) + Me.TbDesMaxFile.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TbDesMaxFile.Location = New System.Drawing.Point(6, 29) Me.TbDesMaxFile.Name = "TbDesMaxFile" - Me.TbDesMaxFile.Size = New Size(440, 20) + Me.TbDesMaxFile.Size = New System.Drawing.Size(433, 20) Me.TbDesMaxFile.TabIndex = 0 ' 'BtDesMaxBr ' - Me.BtDesMaxBr.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) - Me.BtDesMaxBr.Image = My.Resources.Resources.Open_icon - Me.BtDesMaxBr.Location = New Point(446, 27) + Me.BtDesMaxBr.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.BtDesMaxBr.Image = Global.TUGraz.VECTO.My.Resources.Resources.Open_icon + Me.BtDesMaxBr.Location = New System.Drawing.Point(446, 27) Me.BtDesMaxBr.Name = "BtDesMaxBr" - Me.BtDesMaxBr.Size = New Size(24, 24) + Me.BtDesMaxBr.Size = New System.Drawing.Size(24, 24) Me.BtDesMaxBr.TabIndex = 1 Me.BtDesMaxBr.UseVisualStyleBackColor = True ' 'BtAccOpen ' - Me.BtAccOpen.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) - Me.BtAccOpen.Image = My.Resources.Resources.application_export_icon_small - Me.BtAccOpen.Location = New Point(469, 27) + Me.BtAccOpen.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.BtAccOpen.Image = Global.TUGraz.VECTO.My.Resources.Resources.application_export_icon_small + Me.BtAccOpen.Location = New System.Drawing.Point(469, 27) Me.BtAccOpen.Name = "BtAccOpen" - Me.BtAccOpen.Size = New Size(24, 24) + Me.BtAccOpen.Size = New System.Drawing.Size(24, 24) Me.BtAccOpen.TabIndex = 2 Me.BtAccOpen.TabStop = False Me.BtAccOpen.UseVisualStyleBackColor = True ' 'GrLAC ' - Me.GrLAC.Controls.Add(Me.Label12) - Me.GrLAC.Controls.Add(Me.tbDfCoastingScale) + Me.GrLAC.Controls.Add(Me.pnLookAheadCoasting) Me.GrLAC.Controls.Add(Me.CbLookAhead) - Me.GrLAC.Controls.Add(Me.Label11) - Me.GrLAC.Controls.Add(Me.Label3) - Me.GrLAC.Controls.Add(Me.tbDfCoastingOffset) - Me.GrLAC.Controls.Add(Me.tbLacDfTargetSpeedFile) - Me.GrLAC.Controls.Add(Me.Label10) - Me.GrLAC.Controls.Add(Me.Label4) - Me.GrLAC.Controls.Add(Me.Label5) - Me.GrLAC.Controls.Add(Me.btnDfTargetSpeed) - Me.GrLAC.Controls.Add(Me.tbLacPreviewFactor) - Me.GrLAC.Controls.Add(Me.tbLacDfVelocityDropFile) - Me.GrLAC.Location = New Point(7, 290) + Me.GrLAC.Location = New System.Drawing.Point(7, 280) Me.GrLAC.Name = "GrLAC" - Me.GrLAC.Size = New Size(514, 163) + Me.GrLAC.Size = New System.Drawing.Size(514, 173) Me.GrLAC.TabIndex = 2 Me.GrLAC.TabStop = False Me.GrLAC.Text = "Look-Ahead Coasting" ' - 'Label12 - ' - Me.Label12.AutoSize = True - Me.Label12.Location = New Point(279, 133) - Me.Label12.Name = "Label12" - Me.Label12.Size = New Size(130, 13) - Me.Label12.TabIndex = 17 - Me.Label12.Text = "* DF_vTarget * DF_vDrop" - ' - 'tbDfCoastingScale - ' - Me.tbDfCoastingScale.Location = New Point(236, 130) - Me.tbDfCoastingScale.Name = "tbDfCoastingScale" - Me.tbDfCoastingScale.Size = New Size(37, 20) - Me.tbDfCoastingScale.TabIndex = 16 - ' 'CbLookAhead ' Me.CbLookAhead.AutoSize = True Me.CbLookAhead.Checked = True - Me.CbLookAhead.CheckState = CheckState.Checked - Me.CbLookAhead.Location = New Point(16, 21) + Me.CbLookAhead.CheckState = System.Windows.Forms.CheckState.Checked + Me.CbLookAhead.Location = New System.Drawing.Point(16, 21) Me.CbLookAhead.Name = "CbLookAhead" - Me.CbLookAhead.Size = New Size(65, 17) + Me.CbLookAhead.Size = New System.Drawing.Size(65, 17) Me.CbLookAhead.TabIndex = 0 Me.CbLookAhead.Text = "Enabled" Me.CbLookAhead.UseVisualStyleBackColor = True ' - 'Label11 - ' - Me.Label11.AutoSize = True - Me.Label11.Location = New Point(219, 132) - Me.Label11.Name = "Label11" - Me.Label11.Size = New Size(13, 13) - Me.Label11.TabIndex = 15 - Me.Label11.Text = "- " - ' - 'Label3 - ' - Me.Label3.AutoSize = True - Me.Label3.Location = New Point(50, 54) - Me.Label3.Name = "Label3" - Me.Label3.Size = New Size(118, 13) - Me.Label3.TabIndex = 4 - Me.Label3.Text = "Preview distance factor" - Me.Label3.TextAlign = ContentAlignment.MiddleRight - ' - 'tbDfCoastingOffset - ' - Me.tbDfCoastingOffset.Location = New Point(175, 130) - Me.tbDfCoastingOffset.Name = "tbDfCoastingOffset" - Me.tbDfCoastingOffset.Size = New Size(37, 20) - Me.tbDfCoastingOffset.TabIndex = 14 - ' - 'tbLacDfTargetSpeedFile - ' - Me.tbLacDfTargetSpeedFile.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.tbLacDfTargetSpeedFile.Location = New Point(174, 77) - Me.tbLacDfTargetSpeedFile.Name = "tbLacDfTargetSpeedFile" - Me.tbLacDfTargetSpeedFile.Size = New Size(264, 20) - Me.tbLacDfTargetSpeedFile.TabIndex = 6 - ' - 'Label10 - ' - Me.Label10.AutoSize = True - Me.Label10.Location = New Point(89, 133) - Me.Label10.Name = "Label10" - Me.Label10.Size = New Size(79, 13) - Me.Label10.TabIndex = 12 - Me.Label10.Text = "DF_coasting = " - ' - 'Label4 - ' - Me.Label4.AutoSize = True - Me.Label4.Location = New Point(13, 80) - Me.Label4.Name = "Label4" - Me.Label4.Size = New Size(155, 13) - Me.Label4.TabIndex = 8 - Me.Label4.Text = "Decision Factor - Target Speed" - Me.Label4.TextAlign = ContentAlignment.MiddleRight - ' - 'Label5 - ' - Me.Label5.AutoSize = True - Me.Label5.Location = New Point(15, 107) - Me.Label5.Name = "Label5" - Me.Label5.Size = New Size(153, 13) - Me.Label5.TabIndex = 11 - Me.Label5.Text = "Decision Factor - Velocity Drop" - Me.Label5.TextAlign = ContentAlignment.MiddleRight - ' - 'btnDfTargetSpeed - ' - Me.btnDfTargetSpeed.Anchor = CType((AnchorStyles.Top Or AnchorStyles.Right), AnchorStyles) - Me.btnDfTargetSpeed.Image = CType(resources.GetObject("btnDfTargetSpeed.Image"), Image) - Me.btnDfTargetSpeed.Location = New Point(438, 76) - Me.btnDfTargetSpeed.Name = "btnDfTargetSpeed" - Me.btnDfTargetSpeed.Size = New Size(24, 24) - Me.btnDfTargetSpeed.TabIndex = 7 - Me.btnDfTargetSpeed.TabStop = False - Me.btnDfTargetSpeed.UseVisualStyleBackColor = True - ' - 'tbLacPreviewFactor - ' - Me.tbLacPreviewFactor.Location = New Point(174, 51) - Me.tbLacPreviewFactor.Name = "tbLacPreviewFactor" - Me.tbLacPreviewFactor.Size = New Size(64, 20) - Me.tbLacPreviewFactor.TabIndex = 5 - ' - 'tbLacDfVelocityDropFile - ' - Me.tbLacDfVelocityDropFile.Anchor = CType(((AnchorStyles.Top Or AnchorStyles.Left) _ - Or AnchorStyles.Right), AnchorStyles) - Me.tbLacDfVelocityDropFile.Location = New Point(174, 104) - Me.tbLacDfVelocityDropFile.Name = "tbLacDfVelocityDropFile" - Me.tbLacDfVelocityDropFile.Size = New Size(264, 20) - Me.tbLacDfVelocityDropFile.TabIndex = 9 - ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.PnEcoRoll) Me.GroupBox1.Controls.Add(Me.RdEcoRoll) Me.GroupBox1.Controls.Add(Me.RdOverspeed) Me.GroupBox1.Controls.Add(Me.RdOff) - Me.GroupBox1.Location = New Point(6, 149) + Me.GroupBox1.Location = New System.Drawing.Point(6, 149) Me.GroupBox1.Name = "GroupBox1" - Me.GroupBox1.Size = New Size(515, 135) + Me.GroupBox1.Size = New System.Drawing.Size(515, 125) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Overspeed / Eco-Roll" @@ -712,83 +600,83 @@ Partial Class VectoJobForm Me.PnEcoRoll.Controls.Add(Me.Label23) Me.PnEcoRoll.Controls.Add(Me.Label22) Me.PnEcoRoll.Controls.Add(Me.Label13) - Me.PnEcoRoll.Location = New Point(137, 16) + Me.PnEcoRoll.Location = New System.Drawing.Point(137, 16) Me.PnEcoRoll.Name = "PnEcoRoll" - Me.PnEcoRoll.Size = New Size(232, 102) + Me.PnEcoRoll.Size = New System.Drawing.Size(232, 102) Me.PnEcoRoll.TabIndex = 3 ' 'Label21 ' Me.Label21.AutoSize = True - Me.Label21.Location = New Point(178, 61) + Me.Label21.Location = New System.Drawing.Point(178, 61) Me.Label21.Name = "Label21" - Me.Label21.Size = New Size(38, 13) + Me.Label21.Size = New System.Drawing.Size(38, 13) Me.Label21.TabIndex = 3 Me.Label21.Text = "[km/h]" ' 'Label20 ' Me.Label20.AutoSize = True - Me.Label20.Location = New Point(178, 35) + Me.Label20.Location = New System.Drawing.Point(178, 35) Me.Label20.Name = "Label20" - Me.Label20.Size = New Size(38, 13) + Me.Label20.Size = New System.Drawing.Size(38, 13) Me.Label20.TabIndex = 3 Me.Label20.Text = "[km/h]" ' 'Label14 ' Me.Label14.AutoSize = True - Me.Label14.Location = New Point(178, 9) + Me.Label14.Location = New System.Drawing.Point(178, 9) Me.Label14.Name = "Label14" - Me.Label14.Size = New Size(38, 13) + Me.Label14.Size = New System.Drawing.Size(38, 13) Me.Label14.TabIndex = 3 Me.Label14.Text = "[km/h]" ' 'TbVmin ' - Me.TbVmin.Location = New Point(108, 58) + Me.TbVmin.Location = New System.Drawing.Point(108, 58) Me.TbVmin.Name = "TbVmin" - Me.TbVmin.Size = New Size(64, 20) + Me.TbVmin.Size = New System.Drawing.Size(64, 20) Me.TbVmin.TabIndex = 2 ' 'TbUnderSpeed ' - Me.TbUnderSpeed.Location = New Point(108, 32) + Me.TbUnderSpeed.Location = New System.Drawing.Point(108, 32) Me.TbUnderSpeed.Name = "TbUnderSpeed" - Me.TbUnderSpeed.Size = New Size(64, 20) + Me.TbUnderSpeed.Size = New System.Drawing.Size(64, 20) Me.TbUnderSpeed.TabIndex = 1 ' 'TbOverspeed ' - Me.TbOverspeed.Location = New Point(108, 6) + Me.TbOverspeed.Location = New System.Drawing.Point(108, 6) Me.TbOverspeed.Name = "TbOverspeed" - Me.TbOverspeed.Size = New Size(64, 20) + Me.TbOverspeed.Size = New System.Drawing.Size(64, 20) Me.TbOverspeed.TabIndex = 0 ' 'Label23 ' Me.Label23.AutoSize = True - Me.Label23.Location = New Point(22, 61) + Me.Label23.Location = New System.Drawing.Point(22, 61) Me.Label23.Name = "Label23" - Me.Label23.Size = New Size(80, 13) + Me.Label23.Size = New System.Drawing.Size(80, 13) Me.Label23.TabIndex = 1 Me.Label23.Text = "Minimum speed" ' 'Label22 ' Me.Label22.AutoSize = True - Me.Label22.Location = New Point(11, 35) + Me.Label22.Location = New System.Drawing.Point(11, 35) Me.Label22.Name = "Label22" - Me.Label22.Size = New Size(91, 13) + Me.Label22.Size = New System.Drawing.Size(91, 13) Me.Label22.TabIndex = 1 Me.Label22.Text = "Max. Underspeed" ' 'Label13 ' Me.Label13.AutoSize = True - Me.Label13.Location = New Point(17, 9) + Me.Label13.Location = New System.Drawing.Point(17, 9) Me.Label13.Name = "Label13" - Me.Label13.Size = New Size(85, 13) + Me.Label13.Size = New System.Drawing.Size(85, 13) Me.Label13.TabIndex = 1 Me.Label13.Text = "Max. Overspeed" ' @@ -796,9 +684,9 @@ Partial Class VectoJobForm ' Me.RdEcoRoll.AutoSize = True Me.RdEcoRoll.Checked = True - Me.RdEcoRoll.Location = New Point(13, 68) + Me.RdEcoRoll.Location = New System.Drawing.Point(13, 68) Me.RdEcoRoll.Name = "RdEcoRoll" - Me.RdEcoRoll.Size = New Size(65, 17) + Me.RdEcoRoll.Size = New System.Drawing.Size(65, 17) Me.RdEcoRoll.TabIndex = 2 Me.RdEcoRoll.TabStop = True Me.RdEcoRoll.Text = "Eco-Roll" @@ -807,9 +695,9 @@ Partial Class VectoJobForm 'RdOverspeed ' Me.RdOverspeed.AutoSize = True - Me.RdOverspeed.Location = New Point(13, 45) + Me.RdOverspeed.Location = New System.Drawing.Point(13, 45) Me.RdOverspeed.Name = "RdOverspeed" - Me.RdOverspeed.Size = New Size(77, 17) + Me.RdOverspeed.Size = New System.Drawing.Size(77, 17) Me.RdOverspeed.TabIndex = 1 Me.RdOverspeed.Text = "Overspeed" Me.RdOverspeed.UseVisualStyleBackColor = True @@ -817,9 +705,9 @@ Partial Class VectoJobForm 'RdOff ' Me.RdOff.AutoSize = True - Me.RdOff.Location = New Point(13, 22) + Me.RdOff.Location = New System.Drawing.Point(13, 22) Me.RdOff.Name = "RdOff" - Me.RdOff.Size = New Size(39, 17) + Me.RdOff.Size = New System.Drawing.Size(39, 17) Me.RdOff.TabIndex = 0 Me.RdOff.Text = "Off" Me.RdOff.UseVisualStyleBackColor = True @@ -828,9 +716,9 @@ Partial Class VectoJobForm ' Me.GrStartStop.Controls.Add(Me.PnStartStop) Me.GrStartStop.Controls.Add(Me.ChBStartStop) - Me.GrStartStop.Location = New Point(6, 6) + Me.GrStartStop.Location = New System.Drawing.Point(6, 6) Me.GrStartStop.Name = "GrStartStop" - Me.GrStartStop.Size = New Size(515, 137) + Me.GrStartStop.Size = New System.Drawing.Size(515, 137) Me.GrStartStop.TabIndex = 0 Me.GrStartStop.TabStop = False Me.GrStartStop.Text = "Engine Start Stop" @@ -846,104 +734,104 @@ Partial Class VectoJobForm Me.PnStartStop.Controls.Add(Me.LabelSStime) Me.PnStartStop.Controls.Add(Me.TbSSdelay) Me.PnStartStop.Controls.Add(Me.TbSStime) - Me.PnStartStop.Location = New Point(87, 21) + Me.PnStartStop.Location = New System.Drawing.Point(87, 21) Me.PnStartStop.Name = "PnStartStop" - Me.PnStartStop.Size = New Size(422, 95) + Me.PnStartStop.Size = New System.Drawing.Size(422, 95) Me.PnStartStop.TabIndex = 1 ' 'Label31 ' Me.Label31.AutoSize = True - Me.Label31.Location = New Point(228, 58) + Me.Label31.Location = New System.Drawing.Point(228, 58) Me.Label31.Name = "Label31" - Me.Label31.Size = New Size(18, 13) + Me.Label31.Size = New System.Drawing.Size(18, 13) Me.Label31.TabIndex = 38 Me.Label31.Text = "[s]" ' 'Label27 ' Me.Label27.AutoSize = True - Me.Label27.Location = New Point(228, 32) + Me.Label27.Location = New System.Drawing.Point(228, 32) Me.Label27.Name = "Label27" - Me.Label27.Size = New Size(18, 13) + Me.Label27.Size = New System.Drawing.Size(18, 13) Me.Label27.TabIndex = 38 Me.Label27.Text = "[s]" ' 'TbSSspeed ' - Me.TbSSspeed.Location = New Point(158, 3) + Me.TbSSspeed.Location = New System.Drawing.Point(158, 3) Me.TbSSspeed.Name = "TbSSspeed" - Me.TbSSspeed.Size = New Size(64, 20) + Me.TbSSspeed.Size = New System.Drawing.Size(64, 20) Me.TbSSspeed.TabIndex = 0 ' 'LabelSSspeed ' Me.LabelSSspeed.AutoSize = True - Me.LabelSSspeed.Location = New Point(91, 6) + Me.LabelSSspeed.Location = New System.Drawing.Point(91, 6) Me.LabelSSspeed.Name = "LabelSSspeed" - Me.LabelSSspeed.Size = New Size(61, 13) + Me.LabelSSspeed.Size = New System.Drawing.Size(61, 13) Me.LabelSSspeed.TabIndex = 37 Me.LabelSSspeed.Text = "Max Speed" ' 'Label26 ' Me.Label26.AutoSize = True - Me.Label26.Location = New Point(228, 6) + Me.Label26.Location = New System.Drawing.Point(228, 6) Me.Label26.Name = "Label26" - Me.Label26.Size = New Size(38, 13) + Me.Label26.Size = New System.Drawing.Size(38, 13) Me.Label26.TabIndex = 38 Me.Label26.Text = "[km/h]" ' 'Label30 ' Me.Label30.AutoSize = True - Me.Label30.Location = New Point(68, 58) + Me.Label30.Location = New System.Drawing.Point(68, 58) Me.Label30.Name = "Label30" - Me.Label30.Size = New Size(84, 13) + Me.Label30.Size = New System.Drawing.Size(84, 13) Me.Label30.TabIndex = 35 Me.Label30.Text = "Activation Delay" ' 'LabelSStime ' Me.LabelSStime.AutoSize = True - Me.LabelSStime.Location = New Point(65, 32) + Me.LabelSStime.Location = New System.Drawing.Point(65, 32) Me.LabelSStime.Name = "LabelSStime" - Me.LabelSStime.Size = New Size(87, 13) + Me.LabelSStime.Size = New System.Drawing.Size(87, 13) Me.LabelSStime.TabIndex = 35 Me.LabelSStime.Text = "Min ICE-On Time" ' 'TbSSdelay ' - Me.TbSSdelay.Location = New Point(158, 55) + Me.TbSSdelay.Location = New System.Drawing.Point(158, 55) Me.TbSSdelay.Name = "TbSSdelay" - Me.TbSSdelay.Size = New Size(64, 20) + Me.TbSSdelay.Size = New System.Drawing.Size(64, 20) Me.TbSSdelay.TabIndex = 2 ' 'TbSStime ' - Me.TbSStime.Location = New Point(158, 29) + Me.TbSStime.Location = New System.Drawing.Point(158, 29) Me.TbSStime.Name = "TbSStime" - Me.TbSStime.Size = New Size(64, 20) + Me.TbSStime.Size = New System.Drawing.Size(64, 20) Me.TbSStime.TabIndex = 1 ' 'ChBStartStop ' Me.ChBStartStop.AutoSize = True Me.ChBStartStop.Checked = True - Me.ChBStartStop.CheckState = CheckState.Checked - Me.ChBStartStop.Location = New Point(16, 21) + Me.ChBStartStop.CheckState = System.Windows.Forms.CheckState.Checked + Me.ChBStartStop.Location = New System.Drawing.Point(16, 21) Me.ChBStartStop.Name = "ChBStartStop" - Me.ChBStartStop.Size = New Size(65, 17) + Me.ChBStartStop.Size = New System.Drawing.Size(65, 17) Me.ChBStartStop.TabIndex = 0 Me.ChBStartStop.Text = "Enabled" Me.ChBStartStop.UseVisualStyleBackColor = True ' 'StatusStrip1 ' - Me.StatusStrip1.Items.AddRange(New ToolStripItem() {Me.ToolStripStatusLabelGEN}) - Me.StatusStrip1.Location = New Point(0, 672) + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabelGEN}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 672) Me.StatusStrip1.Name = "StatusStrip1" - Me.StatusStrip1.Size = New Size(944, 22) + Me.StatusStrip1.Size = New System.Drawing.Size(944, 22) Me.StatusStrip1.SizingGrip = False Me.StatusStrip1.TabIndex = 6 Me.StatusStrip1.Text = "StatusStrip1" @@ -951,221 +839,386 @@ Partial Class VectoJobForm 'ToolStripStatusLabelGEN ' Me.ToolStripStatusLabelGEN.Name = "ToolStripStatusLabelGEN" - Me.ToolStripStatusLabelGEN.Size = New Size(121, 17) + Me.ToolStripStatusLabelGEN.Size = New System.Drawing.Size(121, 17) Me.ToolStripStatusLabelGEN.Text = "ToolStripStatusLabel1" ' 'ButOK ' - Me.ButOK.Anchor = CType((AnchorStyles.Bottom Or AnchorStyles.Right), AnchorStyles) - Me.ButOK.Location = New Point(779, 646) + Me.ButOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButOK.Location = New System.Drawing.Point(779, 646) Me.ButOK.Name = "ButOK" - Me.ButOK.Size = New Size(75, 23) + Me.ButOK.Size = New System.Drawing.Size(75, 23) Me.ButOK.TabIndex = 0 Me.ButOK.Text = "Save" Me.ButOK.UseVisualStyleBackColor = True ' 'ButCancel ' - Me.ButCancel.Anchor = CType((AnchorStyles.Bottom Or AnchorStyles.Right), AnchorStyles) - Me.ButCancel.DialogResult = DialogResult.Cancel - Me.ButCancel.Location = New Point(860, 646) + Me.ButCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.ButCancel.Location = New System.Drawing.Point(860, 646) Me.ButCancel.Name = "ButCancel" - Me.ButCancel.Size = New Size(75, 23) + Me.ButCancel.Size = New System.Drawing.Size(75, 23) Me.ButCancel.TabIndex = 1 Me.ButCancel.Text = "Cancel" Me.ButCancel.UseVisualStyleBackColor = True ' 'ToolStrip1 ' - Me.ToolStrip1.GripStyle = ToolStripGripStyle.Hidden - Me.ToolStrip1.Items.AddRange(New ToolStripItem() {Me.ToolStripBtNew, Me.ToolStripBtOpen, Me.ToolStripBtSave, Me.ToolStripBtSaveAs, Me.ToolStripSeparator1, Me.ToolStripBtSendTo, Me.ToolStripSeparator2, Me.ToolStripButton1}) - Me.ToolStrip1.Location = New Point(0, 0) + Me.ToolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden + Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripBtNew, Me.ToolStripBtOpen, Me.ToolStripBtSave, Me.ToolStripBtSaveAs, Me.ToolStripSeparator1, Me.ToolStripBtSendTo, Me.ToolStripSeparator2, Me.ToolStripButton1}) + Me.ToolStrip1.Location = New System.Drawing.Point(0, 0) Me.ToolStrip1.Name = "ToolStrip1" - Me.ToolStrip1.Size = New Size(944, 25) + Me.ToolStrip1.Size = New System.Drawing.Size(944, 25) Me.ToolStrip1.TabIndex = 20 Me.ToolStrip1.Text = "ToolStrip1" ' 'ToolStripBtNew ' - Me.ToolStripBtNew.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtNew.Image = My.Resources.Resources.blue_document_icon - Me.ToolStripBtNew.ImageTransparentColor = Color.Magenta + Me.ToolStripBtNew.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtNew.Image = Global.TUGraz.VECTO.My.Resources.Resources.blue_document_icon + Me.ToolStripBtNew.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtNew.Name = "ToolStripBtNew" - Me.ToolStripBtNew.Size = New Size(23, 22) + Me.ToolStripBtNew.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtNew.Text = "New" Me.ToolStripBtNew.ToolTipText = "New" ' 'ToolStripBtOpen ' - Me.ToolStripBtOpen.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtOpen.Image = My.Resources.Resources.Open_icon - Me.ToolStripBtOpen.ImageTransparentColor = Color.Magenta + Me.ToolStripBtOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtOpen.Image = Global.TUGraz.VECTO.My.Resources.Resources.Open_icon + Me.ToolStripBtOpen.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtOpen.Name = "ToolStripBtOpen" - Me.ToolStripBtOpen.Size = New Size(23, 22) + Me.ToolStripBtOpen.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtOpen.Text = "Open" Me.ToolStripBtOpen.ToolTipText = "Open..." ' 'ToolStripBtSave ' - Me.ToolStripBtSave.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtSave.Image = My.Resources.Resources.Actions_document_save_icon - Me.ToolStripBtSave.ImageTransparentColor = Color.Magenta + Me.ToolStripBtSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtSave.Image = Global.TUGraz.VECTO.My.Resources.Resources.Actions_document_save_icon + Me.ToolStripBtSave.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtSave.Name = "ToolStripBtSave" - Me.ToolStripBtSave.Size = New Size(23, 22) + Me.ToolStripBtSave.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtSave.Text = "Save" Me.ToolStripBtSave.ToolTipText = "Save" ' 'ToolStripBtSaveAs ' - Me.ToolStripBtSaveAs.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtSaveAs.Image = My.Resources.Resources.Actions_document_save_as_icon - Me.ToolStripBtSaveAs.ImageTransparentColor = Color.Magenta + Me.ToolStripBtSaveAs.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtSaveAs.Image = Global.TUGraz.VECTO.My.Resources.Resources.Actions_document_save_as_icon + Me.ToolStripBtSaveAs.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtSaveAs.Name = "ToolStripBtSaveAs" - Me.ToolStripBtSaveAs.Size = New Size(23, 22) + Me.ToolStripBtSaveAs.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtSaveAs.Text = "Save As" Me.ToolStripBtSaveAs.ToolTipText = "Save As..." ' 'ToolStripSeparator1 ' Me.ToolStripSeparator1.Name = "ToolStripSeparator1" - Me.ToolStripSeparator1.Size = New Size(6, 25) + Me.ToolStripSeparator1.Size = New System.Drawing.Size(6, 25) ' 'ToolStripBtSendTo ' - Me.ToolStripBtSendTo.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripBtSendTo.Image = My.Resources.Resources.export_icon - Me.ToolStripBtSendTo.ImageTransparentColor = Color.Magenta + Me.ToolStripBtSendTo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripBtSendTo.Image = Global.TUGraz.VECTO.My.Resources.Resources.export_icon + Me.ToolStripBtSendTo.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripBtSendTo.Name = "ToolStripBtSendTo" - Me.ToolStripBtSendTo.Size = New Size(23, 22) + Me.ToolStripBtSendTo.Size = New System.Drawing.Size(23, 22) Me.ToolStripBtSendTo.Text = "Send to Job List" Me.ToolStripBtSendTo.ToolTipText = "Send to Job List" ' 'ToolStripSeparator2 ' Me.ToolStripSeparator2.Name = "ToolStripSeparator2" - Me.ToolStripSeparator2.Size = New Size(6, 25) + Me.ToolStripSeparator2.Size = New System.Drawing.Size(6, 25) ' 'ToolStripButton1 ' - Me.ToolStripButton1.DisplayStyle = ToolStripItemDisplayStyle.Image - Me.ToolStripButton1.Image = My.Resources.Resources.Help_icon - Me.ToolStripButton1.ImageTransparentColor = Color.Magenta + Me.ToolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripButton1.Image = Global.TUGraz.VECTO.My.Resources.Resources.Help_icon + Me.ToolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripButton1.Name = "ToolStripButton1" - Me.ToolStripButton1.Size = New Size(23, 22) + Me.ToolStripButton1.Size = New System.Drawing.Size(23, 22) Me.ToolStripButton1.Text = "Help" ' 'PictureBox1 ' - Me.PictureBox1.BackColor = Color.White - Me.PictureBox1.Image = My.Resources.Resources.VECTO_VECTO - Me.PictureBox1.Location = New Point(12, 28) + Me.PictureBox1.BackColor = System.Drawing.Color.White + Me.PictureBox1.Image = Global.TUGraz.VECTO.My.Resources.Resources.VECTO_VECTO + Me.PictureBox1.Location = New System.Drawing.Point(12, 28) Me.PictureBox1.Name = "PictureBox1" - Me.PictureBox1.Size = New Size(920, 40) + Me.PictureBox1.Size = New System.Drawing.Size(920, 40) Me.PictureBox1.TabIndex = 21 Me.PictureBox1.TabStop = False ' 'CbEngOnly ' Me.CbEngOnly.AutoSize = True - Me.CbEngOnly.Location = New Point(17, 84) + Me.CbEngOnly.Location = New System.Drawing.Point(17, 84) Me.CbEngOnly.Name = "CbEngOnly" - Me.CbEngOnly.Size = New Size(113, 17) + Me.CbEngOnly.Size = New System.Drawing.Size(113, 17) Me.CbEngOnly.TabIndex = 0 Me.CbEngOnly.Text = "Engine Only Mode" Me.CbEngOnly.UseVisualStyleBackColor = True ' 'CmOpenFile ' - Me.CmOpenFile.Items.AddRange(New ToolStripItem() {Me.OpenWithToolStripMenuItem, Me.ShowInFolderToolStripMenuItem}) + Me.CmOpenFile.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OpenWithToolStripMenuItem, Me.ShowInFolderToolStripMenuItem}) Me.CmOpenFile.Name = "CmOpenFile" - Me.CmOpenFile.Size = New Size(153, 48) + Me.CmOpenFile.Size = New System.Drawing.Size(153, 48) ' 'OpenWithToolStripMenuItem ' Me.OpenWithToolStripMenuItem.Name = "OpenWithToolStripMenuItem" - Me.OpenWithToolStripMenuItem.Size = New Size(152, 22) + Me.OpenWithToolStripMenuItem.Size = New System.Drawing.Size(152, 22) Me.OpenWithToolStripMenuItem.Text = "Open with ..." ' 'ShowInFolderToolStripMenuItem ' Me.ShowInFolderToolStripMenuItem.Name = "ShowInFolderToolStripMenuItem" - Me.ShowInFolderToolStripMenuItem.Size = New Size(152, 22) + Me.ShowInFolderToolStripMenuItem.Size = New System.Drawing.Size(152, 22) Me.ShowInFolderToolStripMenuItem.Text = "Show in Folder" ' 'PicVehicle ' - Me.PicVehicle.BackColor = Color.LightGray - Me.PicVehicle.Location = New Point(542, 122) + Me.PicVehicle.BackColor = System.Drawing.Color.LightGray + Me.PicVehicle.Location = New System.Drawing.Point(542, 122) Me.PicVehicle.Name = "PicVehicle" - Me.PicVehicle.Size = New Size(300, 88) - Me.PicVehicle.SizeMode = PictureBoxSizeMode.StretchImage + Me.PicVehicle.Size = New System.Drawing.Size(300, 88) + Me.PicVehicle.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage Me.PicVehicle.TabIndex = 36 Me.PicVehicle.TabStop = False ' 'PicBox ' - Me.PicBox.BackColor = Color.LightGray - Me.PicBox.Location = New Point(542, 268) + Me.PicBox.BackColor = System.Drawing.Color.LightGray + Me.PicBox.Location = New System.Drawing.Point(542, 268) Me.PicBox.Name = "PicBox" - Me.PicBox.Size = New Size(390, 327) + Me.PicBox.Size = New System.Drawing.Size(390, 327) Me.PicBox.TabIndex = 36 Me.PicBox.TabStop = False ' 'TbEngTxt ' - Me.TbEngTxt.Location = New Point(542, 216) + Me.TbEngTxt.Location = New System.Drawing.Point(542, 216) Me.TbEngTxt.Name = "TbEngTxt" Me.TbEngTxt.ReadOnly = True - Me.TbEngTxt.Size = New Size(390, 20) + Me.TbEngTxt.Size = New System.Drawing.Size(390, 20) Me.TbEngTxt.TabIndex = 6 ' 'TbVehCat ' - Me.TbVehCat.Location = New Point(848, 126) + Me.TbVehCat.Location = New System.Drawing.Point(848, 126) Me.TbVehCat.Name = "TbVehCat" Me.TbVehCat.ReadOnly = True - Me.TbVehCat.Size = New Size(87, 20) + Me.TbVehCat.Size = New System.Drawing.Size(87, 20) Me.TbVehCat.TabIndex = 2 ' 'TbAxleConf ' - Me.TbAxleConf.Location = New Point(904, 155) + Me.TbAxleConf.Location = New System.Drawing.Point(904, 155) Me.TbAxleConf.Name = "TbAxleConf" Me.TbAxleConf.ReadOnly = True - Me.TbAxleConf.Size = New Size(31, 20) + Me.TbAxleConf.Size = New System.Drawing.Size(31, 20) Me.TbAxleConf.TabIndex = 4 ' 'TbHVCclass ' - Me.TbHVCclass.Location = New Point(848, 184) + Me.TbHVCclass.Location = New System.Drawing.Point(848, 184) Me.TbHVCclass.Name = "TbHVCclass" Me.TbHVCclass.ReadOnly = True - Me.TbHVCclass.Size = New Size(87, 20) + Me.TbHVCclass.Size = New System.Drawing.Size(87, 20) Me.TbHVCclass.TabIndex = 5 ' 'TbGbxTxt ' - Me.TbGbxTxt.Location = New Point(542, 242) + Me.TbGbxTxt.Location = New System.Drawing.Point(542, 242) Me.TbGbxTxt.Name = "TbGbxTxt" Me.TbGbxTxt.ReadOnly = True - Me.TbGbxTxt.Size = New Size(390, 20) + Me.TbGbxTxt.Size = New System.Drawing.Size(390, 20) Me.TbGbxTxt.TabIndex = 7 ' 'TbMass ' - Me.TbMass.Location = New Point(848, 155) + Me.TbMass.Location = New System.Drawing.Point(848, 155) Me.TbMass.Name = "TbMass" Me.TbMass.ReadOnly = True - Me.TbMass.Size = New Size(50, 20) + Me.TbMass.Size = New System.Drawing.Size(50, 20) Me.TbMass.TabIndex = 3 ' - 'F_VECTO + 'pnLookAheadCoasting + ' + Me.pnLookAheadCoasting.Controls.Add(Me.Label7) + Me.pnLookAheadCoasting.Controls.Add(Me.Label6) + Me.pnLookAheadCoasting.Controls.Add(Me.tbLacMinSpeed) + Me.pnLookAheadCoasting.Controls.Add(Me.btnDfVelocityDrop) + Me.pnLookAheadCoasting.Controls.Add(Me.Label12) + Me.pnLookAheadCoasting.Controls.Add(Me.tbDfCoastingScale) + Me.pnLookAheadCoasting.Controls.Add(Me.Label11) + Me.pnLookAheadCoasting.Controls.Add(Me.Label3) + Me.pnLookAheadCoasting.Controls.Add(Me.tbDfCoastingOffset) + Me.pnLookAheadCoasting.Controls.Add(Me.tbLacDfTargetSpeedFile) + Me.pnLookAheadCoasting.Controls.Add(Me.Label10) + Me.pnLookAheadCoasting.Controls.Add(Me.Label4) + Me.pnLookAheadCoasting.Controls.Add(Me.Label5) + Me.pnLookAheadCoasting.Controls.Add(Me.btnDfTargetSpeed) + Me.pnLookAheadCoasting.Controls.Add(Me.tbLacPreviewFactor) + Me.pnLookAheadCoasting.Controls.Add(Me.tbLacDfVelocityDropFile) + Me.pnLookAheadCoasting.Location = New System.Drawing.Point(16, 37) + Me.pnLookAheadCoasting.Name = "pnLookAheadCoasting" + Me.pnLookAheadCoasting.Size = New System.Drawing.Size(467, 129) + Me.pnLookAheadCoasting.TabIndex = 20 + ' + 'btnDfVelocityDrop + ' + Me.btnDfVelocityDrop.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnDfVelocityDrop.Image = CType(resources.GetObject("btnDfVelocityDrop.Image"), System.Drawing.Image) + Me.btnDfVelocityDrop.Location = New System.Drawing.Point(435, 78) + Me.btnDfVelocityDrop.Name = "btnDfVelocityDrop" + Me.btnDfVelocityDrop.Size = New System.Drawing.Size(24, 24) + Me.btnDfVelocityDrop.TabIndex = 32 + Me.btnDfVelocityDrop.TabStop = False + Me.btnDfVelocityDrop.UseVisualStyleBackColor = True + ' + 'Label12 + ' + Me.Label12.AutoSize = True + Me.Label12.Location = New System.Drawing.Point(269, 110) + Me.Label12.Name = "Label12" + Me.Label12.Size = New System.Drawing.Size(130, 13) + Me.Label12.TabIndex = 31 + Me.Label12.Text = "* DF_vTarget * DF_vDrop" + ' + 'tbDfCoastingScale + ' + Me.tbDfCoastingScale.Location = New System.Drawing.Point(226, 107) + Me.tbDfCoastingScale.Name = "tbDfCoastingScale" + Me.tbDfCoastingScale.Size = New System.Drawing.Size(37, 20) + Me.tbDfCoastingScale.TabIndex = 30 + ' + 'Label11 + ' + Me.Label11.AutoSize = True + Me.Label11.Location = New System.Drawing.Point(209, 109) + Me.Label11.Name = "Label11" + Me.Label11.Size = New System.Drawing.Size(13, 13) + Me.Label11.TabIndex = 29 + Me.Label11.Text = "- " + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(40, 31) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(118, 13) + Me.Label3.TabIndex = 20 + Me.Label3.Text = "Preview distance factor" + Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight + ' + 'tbDfCoastingOffset + ' + Me.tbDfCoastingOffset.Location = New System.Drawing.Point(165, 107) + Me.tbDfCoastingOffset.Name = "tbDfCoastingOffset" + Me.tbDfCoastingOffset.Size = New System.Drawing.Size(37, 20) + Me.tbDfCoastingOffset.TabIndex = 28 + ' + 'tbLacDfTargetSpeedFile + ' + Me.tbLacDfTargetSpeedFile.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.tbLacDfTargetSpeedFile.Location = New System.Drawing.Point(164, 54) + Me.tbLacDfTargetSpeedFile.Name = "tbLacDfTargetSpeedFile" + Me.tbLacDfTargetSpeedFile.Size = New System.Drawing.Size(264, 20) + Me.tbLacDfTargetSpeedFile.TabIndex = 22 + ' + 'Label10 + ' + Me.Label10.AutoSize = True + Me.Label10.Location = New System.Drawing.Point(79, 110) + Me.Label10.Name = "Label10" + Me.Label10.Size = New System.Drawing.Size(79, 13) + Me.Label10.TabIndex = 27 + Me.Label10.Text = "DF_coasting = " + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(3, 57) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(155, 13) + Me.Label4.TabIndex = 24 + Me.Label4.Text = "Decision Factor - Target Speed" + Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Location = New System.Drawing.Point(5, 84) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(153, 13) + Me.Label5.TabIndex = 26 + Me.Label5.Text = "Decision Factor - Velocity Drop" + Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight + ' + 'btnDfTargetSpeed + ' + Me.btnDfTargetSpeed.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnDfTargetSpeed.Image = CType(resources.GetObject("btnDfTargetSpeed.Image"), System.Drawing.Image) + Me.btnDfTargetSpeed.Location = New System.Drawing.Point(434, 54) + Me.btnDfTargetSpeed.Name = "btnDfTargetSpeed" + Me.btnDfTargetSpeed.Size = New System.Drawing.Size(24, 24) + Me.btnDfTargetSpeed.TabIndex = 23 + Me.btnDfTargetSpeed.TabStop = False + Me.btnDfTargetSpeed.UseVisualStyleBackColor = True + ' + 'tbLacPreviewFactor + ' + Me.tbLacPreviewFactor.Location = New System.Drawing.Point(164, 28) + Me.tbLacPreviewFactor.Name = "tbLacPreviewFactor" + Me.tbLacPreviewFactor.Size = New System.Drawing.Size(64, 20) + Me.tbLacPreviewFactor.TabIndex = 21 + ' + 'tbLacDfVelocityDropFile + ' + Me.tbLacDfVelocityDropFile.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.tbLacDfVelocityDropFile.Location = New System.Drawing.Point(164, 81) + Me.tbLacDfVelocityDropFile.Name = "tbLacDfVelocityDropFile" + Me.tbLacDfVelocityDropFile.Size = New System.Drawing.Size(264, 20) + Me.tbLacDfVelocityDropFile.TabIndex = 25 + ' + 'Label6 + ' + Me.Label6.AutoSize = True + Me.Label6.Location = New System.Drawing.Point(91, 6) + Me.Label6.Name = "Label6" + Me.Label6.Size = New System.Drawing.Size(67, 13) + Me.Label6.TabIndex = 33 + Me.Label6.Text = "Min. Velocity" + Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight + ' + 'tbLacMinSpeed + ' + Me.tbLacMinSpeed.Location = New System.Drawing.Point(164, 3) + Me.tbLacMinSpeed.Name = "tbLacMinSpeed" + Me.tbLacMinSpeed.Size = New System.Drawing.Size(64, 20) + Me.tbLacMinSpeed.TabIndex = 34 + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(234, 6) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(38, 13) + Me.Label7.TabIndex = 4 + Me.Label7.Text = "[km/h]" + ' + 'VectoJobForm ' Me.AcceptButton = Me.ButOK - Me.AutoScaleDimensions = New SizeF(6.0!, 13.0!) - Me.AutoScaleMode = AutoScaleMode.Font Me.CancelButton = Me.ButCancel - Me.ClientSize = New Size(944, 694) + Me.ClientSize = New System.Drawing.Size(944, 694) Me.Controls.Add(Me.TbHVCclass) Me.Controls.Add(Me.TbMass) Me.Controls.Add(Me.TbAxleConf) @@ -1181,11 +1234,10 @@ Partial Class VectoJobForm Me.Controls.Add(Me.TabControl1) Me.Controls.Add(Me.ButOK) Me.Controls.Add(Me.StatusStrip1) - Me.FormBorderStyle = FormBorderStyle.FixedSingle - Me.Icon = CType(resources.GetObject("$this.Icon"), Icon) + Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximizeBox = False Me.Name = "VectoJobForm" - Me.StartPosition = FormStartPosition.CenterParent + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "Job Editor" Me.TabPgGen.ResumeLayout(False) Me.TabPgGen.PerformLayout() @@ -1193,7 +1245,7 @@ Partial Class VectoJobForm Me.GrCycles.PerformLayout() Me.GrAux.ResumeLayout(False) Me.GrAux.PerformLayout() - CType(Me.picAuxInfo, ISupportInitialize).EndInit() + CType(Me.picAuxInfo, System.ComponentModel.ISupportInitialize).EndInit() Me.TabControl1.ResumeLayout(False) Me.TabPgDriver.ResumeLayout(False) Me.GrVACC.ResumeLayout(False) @@ -1212,10 +1264,12 @@ Partial Class VectoJobForm Me.StatusStrip1.PerformLayout() Me.ToolStrip1.ResumeLayout(False) Me.ToolStrip1.PerformLayout() - CType(Me.PictureBox1, ISupportInitialize).EndInit() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.CmOpenFile.ResumeLayout(False) - CType(Me.PicVehicle, ISupportInitialize).EndInit() - CType(Me.PicBox, ISupportInitialize).EndInit() + CType(Me.PicVehicle, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.PicBox, System.ComponentModel.ISupportInitialize).EndInit() + Me.pnLookAheadCoasting.ResumeLayout(False) + Me.pnLookAheadCoasting.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() @@ -1312,16 +1366,21 @@ Partial Class VectoJobForm Friend WithEvents txtAdvancedAuxiliaryFile As TextBox Friend WithEvents lbAdvancedAuxiliaries As Label Friend WithEvents btnAAUXOpen As Button - Friend WithEvents Label12 As Label - Friend WithEvents tbDfCoastingScale As TextBox - Friend WithEvents Label11 As Label - Friend WithEvents Label3 As Label - Friend WithEvents tbDfCoastingOffset As TextBox - Friend WithEvents tbLacDfTargetSpeedFile As TextBox - Friend WithEvents Label10 As Label - Friend WithEvents Label4 As Label - Friend WithEvents Label5 As Label - Friend WithEvents btnDfTargetSpeed As Button - Friend WithEvents tbLacPreviewFactor As TextBox - Friend WithEvents tbLacDfVelocityDropFile As TextBox + Friend WithEvents pnLookAheadCoasting As System.Windows.Forms.Panel + Friend WithEvents btnDfVelocityDrop As System.Windows.Forms.Button + Friend WithEvents Label12 As System.Windows.Forms.Label + Friend WithEvents tbDfCoastingScale As System.Windows.Forms.TextBox + Friend WithEvents Label11 As System.Windows.Forms.Label + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents tbDfCoastingOffset As System.Windows.Forms.TextBox + Friend WithEvents tbLacDfTargetSpeedFile As System.Windows.Forms.TextBox + Friend WithEvents Label10 As System.Windows.Forms.Label + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents Label5 As System.Windows.Forms.Label + Friend WithEvents btnDfTargetSpeed As System.Windows.Forms.Button + Friend WithEvents tbLacPreviewFactor As System.Windows.Forms.TextBox + Friend WithEvents tbLacDfVelocityDropFile As System.Windows.Forms.TextBox + Friend WithEvents Label6 As System.Windows.Forms.Label + Friend WithEvents tbLacMinSpeed As System.Windows.Forms.TextBox + Friend WithEvents Label7 As System.Windows.Forms.Label End Class diff --git a/VECTO/GUI/VectoJobForm.resx b/VECTO/GUI/VectoJobForm.resx index 087e6067950a3b7e0a6a1305861d5674430ef6b6..e89a5da4d25ff01ecfa847660f4f5ede2ef06659 100644 --- a/VECTO/GUI/VectoJobForm.resx +++ b/VECTO/GUI/VectoJobForm.resx @@ -124,7 +124,7 @@ <data name="ButtonVEH.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADr8AAA6/ATgFUyQAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADr4AAA6+AepCscAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 @@ -142,7 +142,7 @@ <data name="ButtonGBX.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADr8AAA6/ATgFUyQAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADr4AAA6+AepCscAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 @@ -160,7 +160,25 @@ <data name="ButtonMAP.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADr8AAA6/ATgFUyQAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADr4AAA6+AepCscAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ + 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC + AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 + FJKv98Rjo/ca0J9AqakKxr5ye7iU7sCufBuFSfBjIYduXldvQnKdMg5r3fEmQVe1AO7FtkecH1rDvtAK + TtnsDCpYmxNjddbIjBgreki+2BELXWccVEoRAqu8EPTEC2Sp03223KqUCbsMSw0VrEzfhG4qG7rJbCwb + Ifnsmyt4/1oAX5kHqtUSnKj2pQIHsZWCCKzTLUAFSxNZWBrPwnfCWCa0ekiuaL6As408yNVSxPYI4FbI + gWM2u4ybxwIRsJKZBoH2ayYWRzOg+ULQX+HndMikpxDSxINC9wJRyiAcatiJPQUcuBTawOGxQWCZYG4Q + kIJ6OA3qoTTMD6bhW08iAmp98GqlBdHKABxrcacCb7kj3CQcKmAVM8G8vE1BBfODqZhTpWJ2IIUevV3C + x1HZfkS1+yOk1XOLgFvGgmWcuYYZzvChAlKc7ruBqY/JVNBYEobiB4HgFbnCv9HdJPCs4MIxl43tMWYj + zEv6MhlSIMXJnuuY6DL8gTVFoajMP4+68ovg5bvisHw3FXDTWBDn8ehNmKatIlSjehmDcWUSxt4lUkF5 + znEUpPhBmncStY+CcSDLGT4VzrBPtkJz2TnD5j/TLQ/ndEjD5F01Qgy3XkWnXIj4yIOx+ld7DV8wGLax + DI5ltLncQmRWZoy2Tnsl/zQ5DTnBvRQ/b2P8n2EwfgPZDDiygt3V8AAAAABJRU5ErkJggg== +</value> + </data> + <data name="btnDfVelocityDrop.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADrwAAA68AZW8ckkAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 @@ -178,7 +196,7 @@ <data name="btnDfTargetSpeed.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADr4AAA6+AepCscAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADrwAAA68AZW8ckkAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index 7469061cbc384b20fcddbca9c04e0fc077082a23..6b3457089f922e33dfe8037aaf487165c48b600e 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -8,7 +8,7 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. -Option Infer On +'Option Infer On Imports System.Collections.Generic Imports System.Drawing.Imaging @@ -17,26 +17,29 @@ Imports System.Linq Imports System.Text.RegularExpressions Imports System.Windows.Forms.DataVisualization.Charting Imports TUGraz.VECTO.Input_Files +Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.FileIO.JSON +Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ''' <summary> ''' Job Editor. Create/Edit VECTO job files (.vecto) ''' </summary> ''' <remarks></remarks> Public Class VectoJobForm - Public VECTOfile As String - Private Changed As Boolean = False + Public VectoFile As String + Private _changed As Boolean = False - Private pgDriver As TabPage + Private _pgDriver As TabPage - Private pgDriverON As Boolean = True + Private _pgDriverOn As Boolean = True - Private AuxDlog As VehicleAuxiliariesDialog - - Public n_idle As Single - Public FLDfile As String + Private _auxDialog As VehicleAuxiliariesDialog 'AA-TB 'Populate Advanced Auxiliaries @@ -51,14 +54,11 @@ Public Class VectoJobForm 'Initialise form Private Sub F02_GEN_Load(sender As Object, e As EventArgs) Handles Me.Load - Dim x As Int16 - - n_idle = -1 - FLDfile = "" + Dim x As Integer - AuxDlog = New VehicleAuxiliariesDialog + _auxDialog = New VehicleAuxiliariesDialog - pgDriver = TabPgDriver + _pgDriver = TabPgDriver For x = 0 To TabControl1.TabCount - 1 TabControl1.TabPages(x).Show() @@ -83,7 +83,7 @@ Public Class VectoJobForm ButAuxRem.Enabled = Not Cfg.DeclMode PnEcoRoll.Enabled = Not Cfg.DeclMode - Changed = False + _changed = False 'AA-TB PopulateAdvancedAuxiliaries() @@ -108,66 +108,68 @@ Public Class VectoJobForm If Not RdEcoRoll.Checked Then RdOverspeed.Checked = True CbLookAhead.Checked = True - TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph() 'cDeclaration.SSspeed - TbSStime.Text = DeclarationData.Driver.StartStop.MinTime.Value() 'cDeclaration.SStime - TbSSdelay.Text = DeclarationData.Driver.StartStop.Delay.Value() ' cDeclaration.SSdelay - - tbLacPreviewFactor.Text = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor + TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat() 'cDeclaration.SSspeed + TbSStime.Text = DeclarationData.Driver.StartStop.MinTime.ToGUIFormat() 'cDeclaration.SStime + TbSSdelay.Text = DeclarationData.Driver.StartStop.Delay.ToGUIFormat() ' cDeclaration.SSdelay + tbLacPreviewFactor.Text = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor.ToGUIFormat() tbLacDfTargetSpeedFile.Text = "" tbLacDfVelocityDropFile.Text = "" - TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph() 'cDeclaration.Overspeed - TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph() ' cDeclaration.Underspeed - TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph() 'cDeclaration.ECvmin + TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat() 'cDeclaration.Overspeed + TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat() _ + ' cDeclaration.Underspeed + TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat() 'cDeclaration.ECvmin If _ LvAux.Items.Count <> 5 OrElse - (LvAux.Items(0).Text <> sKey.AUX.Fan OrElse LvAux.Items(1).Text <> sKey.AUX.SteerPump OrElse - LvAux.Items(2).Text <> sKey.AUX.HVAC OrElse LvAux.Items(3).Text <> sKey.AUX.ElecSys OrElse - LvAux.Items(4).Text <> sKey.AUX.PneumSys) Then + (LvAux.Items(0).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.Fan OrElse + LvAux.Items(1).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.SteeringPump OrElse + LvAux.Items(2).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.HeatingVentilationAirCondition OrElse + LvAux.Items(3).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.ElectricSystem OrElse + LvAux.Items(4).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.PneumaticSystem) Then LvAux.Items.Clear() - LvAux.Items.Add(GetTechListForAux(sKey.AUX.Fan, "Fan", DeclarationData.Fan)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.Fan, DeclarationData.Fan)) - LvAux.Items.Add(GetTechListForAux(sKey.AUX.SteerPump, "Steering pump", DeclarationData.SteeringPump)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.SteeringPump, DeclarationData.SteeringPump)) - LvAux.Items.Add(GetTechListForAux(sKey.AUX.HVAC, "HVAC", DeclarationData.HeatingVentilationAirConditioning)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.HVAC, DeclarationData.HeatingVentilationAirConditioning)) - LvAux.Items.Add(GetTechListForAux(sKey.AUX.ElecSys, "Electric System", DeclarationData.ElectricSystem)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.ElectricSystem, DeclarationData.ElectricSystem)) - LvAux.Items.Add(GetTechListForAux(sKey.AUX.PneumSys, "Pneumatic System", DeclarationData.PneumaticSystem)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.PneumaticSystem, DeclarationData.PneumaticSystem)) End If End Sub - Protected Function GetTechListForAux(key As String, nameStr As String, aux As IDeclarationAuxiliaryTable) _ + Protected Function GetTechListForAux(type As AuxiliaryType, aux As IDeclarationAuxiliaryTable) _ As ListViewItem - Dim LV0 As ListViewItem + Dim listViewItem As ListViewItem - LV0 = New ListViewItem(key) - LV0.SubItems.Add(nameStr) + listViewItem = New ListViewItem(type.Key()) + listViewItem.SubItems.Add(type.Name()) Dim auxtech As String() = aux.GetTechnologies() If auxtech.Count > 1 Then - LV0.SubItems.Add("") + listViewItem.SubItems.Add("") Else - LV0.SubItems.Add(auxtech(0)) + listViewItem.SubItems.Add(auxtech(0)) End If - Return LV0 + Return listViewItem End Function 'Show/Hide "Driver Assist" Tab Private Sub SetDrivertab(onOff As Boolean) If onOff Then - If Not pgDriverON Then - pgDriverON = True - TabControl1.TabPages.Insert(1, pgDriver) + If Not _pgDriverOn Then + _pgDriverOn = True + TabControl1.TabPages.Insert(1, _pgDriver) End If Else - If pgDriverON Then - pgDriverON = False - TabControl1.Controls.Remove(pgDriver) + If _pgDriverOn Then + _pgDriverOn = False + TabControl1.Controls.Remove(_pgDriver) End If End If End Sub @@ -176,31 +178,31 @@ Public Class VectoJobForm #Region "Browse Buttons" Private Sub ButtonVEH_Click(sender As Object, e As EventArgs) Handles ButtonVEH.Click - If VehicleFileBrowser.OpenDialog(fFileRepl(TbVEH.Text, GetPath(VECTOfile))) Then - TbVEH.Text = GetFilenameWithoutDirectory(VehicleFileBrowser.Files(0), GetPath(VECTOfile)) + If VehicleFileBrowser.OpenDialog(FileRepl(TbVEH.Text, GetPath(VectoFile))) Then + TbVEH.Text = GetFilenameWithoutDirectory(VehicleFileBrowser.Files(0), GetPath(VectoFile)) End If End Sub Private Sub ButtonMAP_Click(sender As Object, e As EventArgs) Handles ButtonMAP.Click - If EngineFileBrowser.OpenDialog(fFileRepl(TbENG.Text, GetPath(VECTOfile))) Then - TbENG.Text = GetFilenameWithoutDirectory(EngineFileBrowser.Files(0), GetPath(VECTOfile)) + If EngineFileBrowser.OpenDialog(FileRepl(TbENG.Text, GetPath(VectoFile))) Then + TbENG.Text = GetFilenameWithoutDirectory(EngineFileBrowser.Files(0), GetPath(VectoFile)) End If End Sub Private Sub ButtonGBX_Click(sender As Object, e As EventArgs) Handles ButtonGBX.Click - If GearboxFileBrowser.OpenDialog(fFileRepl(TbGBX.Text, GetPath(VECTOfile))) Then - TbGBX.Text = GetFilenameWithoutDirectory(GearboxFileBrowser.Files(0), GetPath(VECTOfile)) + If GearboxFileBrowser.OpenDialog(FileRepl(TbGBX.Text, GetPath(VectoFile))) Then + TbGBX.Text = GetFilenameWithoutDirectory(GearboxFileBrowser.Files(0), GetPath(VectoFile)) End If End Sub Private Sub BtDesMaxBr_Click_1(sender As Object, e As EventArgs) Handles BtDesMaxBr.Click - If DriverAccelerationFileBrowser.OpenDialog(fFileRepl(TbDesMaxFile.Text, GetPath(VECTOfile))) Then - TbDesMaxFile.Text = GetFilenameWithoutDirectory(DriverAccelerationFileBrowser.Files(0), GetPath(VECTOfile)) + If DriverAccelerationFileBrowser.OpenDialog(FileRepl(TbDesMaxFile.Text, GetPath(VectoFile))) Then + TbDesMaxFile.Text = GetFilenameWithoutDirectory(DriverAccelerationFileBrowser.Files(0), GetPath(VectoFile)) End If End Sub Private Sub BtAccOpen_Click(sender As Object, e As EventArgs) Handles BtAccOpen.Click - OpenFiles(fFileRepl(TbDesMaxFile.Text, GetPath(VECTOfile))) + OpenFiles(FileRepl(TbDesMaxFile.Text, GetPath(VectoFile))) End Sub #End Region @@ -210,10 +212,10 @@ Public Class VectoJobForm 'Open Vehicle Editor Private Sub ButOpenVEH_Click(sender As Object, e As EventArgs) Handles ButOpenVEH.Click Dim f As String - f = fFileRepl(TbVEH.Text, GetPath(VECTOfile)) + f = FileRepl(TbVEH.Text, GetPath(VectoFile)) 'Thus Veh-file is returned - VehicleForm.JobDir = GetPath(VECTOfile) + VehicleForm.JobDir = GetPath(VectoFile) VehicleForm.AutoSendTo = True If Not Trim(f) = "" Then @@ -230,16 +232,22 @@ Public Class VectoJobForm VehicleForm.BringToFront() End If - If Not Trim(f) = "" Then VehicleForm.OpenVehicle(f) + If Not Trim(f) = "" Then + Try + VehicleForm.OpenVehicle(f) + Catch ex As Exception + MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Vehicle File") + End Try + End If End Sub 'Open Engine Editor Private Sub ButOpenENG_Click(sender As Object, e As EventArgs) Handles ButOpenENG.Click Dim f As String - f = fFileRepl(TbENG.Text, GetPath(VECTOfile)) + f = FileRepl(TbENG.Text, GetPath(VectoFile)) 'Thus Veh-file is returned - EngineForm.JobDir = GetPath(VECTOfile) + EngineForm.JobDir = GetPath(VectoFile) EngineForm.AutoSendTo = True If Not Trim(f) = "" Then @@ -262,10 +270,10 @@ Public Class VectoJobForm 'Open Gearbox Editor Private Sub ButOpenGBX_Click(sender As Object, e As EventArgs) Handles ButOpenGBX.Click Dim f As String - f = fFileRepl(TbGBX.Text, GetPath(VECTOfile)) + f = FileRepl(TbGBX.Text, GetPath(VectoFile)) 'Thus Veh-file is returned - GearboxForm.JobDir = GetPath(VECTOfile) + GearboxForm.JobDir = GetPath(VectoFile) GearboxForm.AutoSendTo = True If Not Trim(f) = "" Then @@ -282,7 +290,7 @@ Public Class VectoJobForm GearboxForm.BringToFront() End If - If Not Trim(f) = "" Then GearboxForm.openGBX(f) + If Not Trim(f) = "" Then GearboxForm.OpenGbx(f) End Sub #End Region @@ -291,12 +299,12 @@ Public Class VectoJobForm 'New Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click - VECTOnew() + VectoNew() End Sub 'Open Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click - If JobfileFileBrowser.OpenDialog(VECTOfile, False, "vecto") Then VECTOload2Form(JobfileFileBrowser.Files(0)) + If JobfileFileBrowser.OpenDialog(VectoFile, False, "vecto") Then VECTOload2Form(JobfileFileBrowser.Files(0)) End Sub 'Save @@ -306,27 +314,27 @@ Public Class VectoJobForm 'Save As Private Sub ToolStripBtSaveAs_Click(sender As Object, e As EventArgs) Handles ToolStripBtSaveAs.Click - If JobfileFileBrowser.SaveDialog(VECTOfile) Then Call VECTOsave(JobfileFileBrowser.Files(0)) + If JobfileFileBrowser.SaveDialog(VectoFile) Then Call VECTOsave(JobfileFileBrowser.Files(0)) End Sub 'Send to Job file list in main form Private Sub ToolStripBtSendTo_Click(sender As Object, e As EventArgs) Handles ToolStripBtSendTo.Click If ChangeCheckCancel() Then Exit Sub - If VECTOfile = "" Then + If VectoFile = "" Then MsgBox("File not found!" & ChrW(10) & ChrW(10) & "Save file and try again.") Else - MainForm.AddToJobListView(VECTOfile) + MainForm.AddToJobListView(VectoFile) End If End Sub 'Help 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 = + Dim browserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString - Dim DefaultBrowserPath As String = - Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - Process.Start(DefaultBrowserPath, + Dim defaultBrowserPath As String = + 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) @@ -338,36 +346,34 @@ Public Class VectoJobForm 'Save ("Save" or "Save As" when new file) Private Function Save() As Boolean - If VECTOfile = "" Then + If VectoFile = "" Then If JobfileFileBrowser.SaveDialog("") Then - VECTOfile = JobfileFileBrowser.Files(0) + VectoFile = JobfileFileBrowser.Files(0) Else Return False End If End If - Return VECTOsave(VECTOfile) + Try + Return VECTOsave(VectoFile) + Catch ex As Exception + MsgBox("Error when saving file" + Environment.NewLine + ex.Message) + Return False + End Try End Function 'Open file Public Sub VECTOload2Form(file As String) + If ChangeCheckCancel() Then Exit Sub - VECTOnew() + VectoNew() 'Read GEN - Dim VEC0 = New VectoJob - VEC0.FilePath = file - Try - If Not VEC0.ReadFile() Then - MsgBox("Failed to load " & GetFilenameWithoutPath(file, True) & "!") - Exit Sub - End If - Catch ex As Exception - MsgBox("Failed to load " & GetFilenameWithoutPath(file, True) & "!") - Exit Sub - End Try + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), + IEngineeringInputDataProvider) + Dim vectoJob As IEngineeringJobInputData = inputData.JobInputData() - If Cfg.DeclMode <> VEC0.SavedInDeclMode Then + If Cfg.DeclMode <> vectoJob.SavedInDeclarationMode Then Select Case WrongMode() Case 1 Close() @@ -375,82 +381,104 @@ Public Class VectoJobForm MainForm.OpenVectoFile(file) Case -1 Exit Sub - Case Else '0 - 'Continue... End Select End If - + VectoFile = file + _basePath = Path.GetDirectoryName(file) 'Update Form 'Files ----------------------------- - TbVEH.Text = VEC0.PathVeh(True) - TbENG.Text = VEC0.PathEng(True) - TbGBX.Text = VEC0.PathGbx(True) + TbVEH.Text = GetRelativePath(inputData.VehicleInputData.Source, _basePath) + TbENG.Text = GetRelativePath(inputData.EngineInputData.Source, _basePath) + TbGBX.Text = GetRelativePath(inputData.GearboxInputData.Source, _basePath) 'Start/Stop - ChBStartStop.Checked = VEC0.StartStop - TbSSspeed.Text = VEC0.StStV.ToString() - TbSStime.Text = VEC0.StStT.ToString() - TbSSdelay.Text = VEC0.StartStopDelay.ToString() + Dim driver As IDriverEngineeringInputData = inputData.DriverInputData + ChBStartStop.Checked = driver.StartStop.Enabled + TbSSspeed.Text = driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat() + TbSStime.Text = driver.StartStop.MinTime.ToGUIFormat() + TbSSdelay.Text = driver.StartStop.Delay.ToGUIFormat() - 'VACC - TbDesMaxFile.Text = VEC0.DesMaxFile(True) + If (Cfg.DeclMode) Then + TbDesMaxFile.Text = "" + 'AA-TB + 'Try and Select any previously selected Auxiliary Type + Dim declarationInput As IDeclarationInputDataProvider = CType(inputData, IDeclarationInputDataProvider) + Dim auxInput As IAuxiliariesDeclarationInputData = declarationInput.AuxiliaryInputData() + cboAdvancedAuxiliaries.SelectedIndex = 0 - 'AA-TB - 'Try and Select any previously selected Auxiliary Type - For Each item As AdvancedAuxiliary In cboAdvancedAuxiliaries.Items - If item.AssemblyName = VEC0.AuxiliaryAssembly AndAlso VEC0.AuxiliaryVersion = item.AuxiliaryVersion Then - cboAdvancedAuxiliaries.SelectedItem = item - Exit For - End If - Next - 'AA-TB - 'Assign any previously saved Axiliary FilePath - txtAdvancedAuxiliaryFile.Text = VEC0.AdvancedAuxiliaryFilePath + LvAux.Items.Clear() + Dim entry As IAuxiliaryDeclarationInputData + For Each entry In auxInput.Auxiliaries + Dim lv0 As ListViewItem = New ListViewItem + lv0.SubItems(0).Text = AuxiliaryTypeHelper.GetAuxKey(entry.Type) + lv0.SubItems.Add(AuxiliaryTypeHelper.ToString(entry.Type)) + lv0.SubItems.Add(String.Join(", ", entry.Technology)) + LvAux.Items.Add(lv0) + Next + Else + 'VACC + TbDesMaxFile.Text = + If(driver.AccelerationCurve Is Nothing, "", GetRelativePath(driver.AccelerationCurve.Source, _basePath)) + + + Dim auxInput As IAuxiliariesEngineeringInputData = inputData.AuxiliaryInputData() + For Each item As AdvancedAuxiliary In cboAdvancedAuxiliaries.Items + If _ + item.AssemblyName = auxInput.AuxiliaryAssembly.ToString() AndAlso auxInput.AuxiliaryVersion = item.AuxiliaryVersion _ + Then + cboAdvancedAuxiliaries.SelectedItem = item + Exit For + End If + Next + 'AA-TB + 'Assign any previously saved Axiliary FilePath + txtAdvancedAuxiliaryFile.Text = auxInput.AdvancedAuxiliaryFilePath + LvAux.Items.Clear() + For Each entry As IAuxiliaryEngineeringInputData In auxInput.Auxiliaries + Dim lv0 As ListViewItem = New ListViewItem + lv0.SubItems(0).Text = entry.ID + lv0.SubItems.Add(entry.AuxiliaryType.ToString()) + lv0.SubItems.Add(If(entry.DemandMap Is Nothing, "", entry.DemandMap.Source)) + LvAux.Items.Add(lv0) + Next - LvAux.Items.Clear() - For Each AuxEntryKV In VEC0.AuxPaths - Dim lv0 = New ListViewItem - lv0.SubItems(0).Text = AuxEntryKV.Key - lv0.SubItems.Add(AuxEntryKV.Value.Type) - If Cfg.DeclMode Then - lv0.SubItems.Add(AuxEntryKV.Value.TechStr) - Else - lv0.SubItems.Add(AuxEntryKV.Value.Path.OriginalPath) - End If - LvAux.Items.Add(lv0) - Next + End If - For Each sb In VEC0.CycleFiles - Dim lv0 = New ListViewItem - lv0.Text = sb.OriginalPath + Dim sb As ICycleData + For Each sb In vectoJob.Cycles + Dim lv0 As ListViewItem = New ListViewItem + lv0.Text = sb.Name LvCycles.Items.Add(lv0) Next - CbEngOnly.Checked = VEC0.EngineOnly + CbEngOnly.Checked = vectoJob.EngineOnlyMode - If VEC0.EcoRollOn Then + If driver.OverSpeedEcoRoll.Mode = DriverMode.EcoRoll Then RdEcoRoll.Checked = True - ElseIf VEC0.OverSpeedOn Then + ElseIf driver.OverSpeedEcoRoll.Mode = DriverMode.Overspeed Then RdOverspeed.Checked = True Else RdOff.Checked = True End If - TbOverspeed.Text = CStr(VEC0.OverSpeed) - TbUnderSpeed.Text = CStr(VEC0.UnderSpeed) - TbVmin.Text = CStr(VEC0.VMin) - CbLookAhead.Checked = VEC0.LookAheadOn + TbOverspeed.Text = driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat() + TbUnderSpeed.Text = driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat() + TbVmin.Text = driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat() + CbLookAhead.Checked = driver.Lookahead.Enabled 'TbAlookahead.Text = CStr(VEC0.ALookahead) + tbLacMinSpeed.Text = driver.Lookahead.MinSpeed.AsKmph.ToGUIFormat() 'TbVminLA.Text = CStr(VEC0.VMinLa) - tbLacPreviewFactor.Text = CStr(VEC0.LacPreviewFactor) - tbDfCoastingOffset.Text = CStr(VEC0.LacDfOffset) - tbDfCoastingScale.Text = CStr(VEC0.LacDfScale) + tbLacPreviewFactor.Text = driver.Lookahead.LookaheadDistanceFactor.ToGUIFormat() + tbDfCoastingOffset.Text = driver.Lookahead.CoastingDecisionFactorOffset.ToGUIFormat() + tbDfCoastingScale.Text = driver.Lookahead.CoastingDecisionFactorScaling.ToGUIFormat() - tbLacDfTargetSpeedFile.Text = VEC0.LacDfTargetSpeedFile - tbLacDfVelocityDropFile.Text = VEC0.LacDfVelocityDropFile + tbLacDfTargetSpeedFile.Text = If(driver.Lookahead.CoastingDecisionFactorTargetSpeedLookup Is Nothing, "", + GetRelativePath(driver.Lookahead.CoastingDecisionFactorTargetSpeedLookup.Source, _basePath)) + tbLacDfVelocityDropFile.Text = If(driver.Lookahead.CoastingDecisionFactorVelocityDropLookup Is Nothing, "", + GetRelativePath(driver.Lookahead.CoastingDecisionFactorVelocityDropLookup.Source, _basePath)) '------------------------------------------------------------- @@ -462,14 +490,12 @@ Public Class VectoJobForm VehicleForm.AutoSendTo = False - VECTOfile = file - - Dim x As Short = Len(file) + Dim x As Integer = Len(file) While Mid(file, x, 1) <> "\" And x > 0 x = x - 1 End While Text = Mid(file, x + 1, Len(file) - x) - Changed = False + _changed = False ToolStripStatusLabelGEN.Text = "" 'file & " opened." UpdatePic() @@ -487,10 +513,10 @@ Public Class VectoJobForm If cboAdvancedAuxiliaries.SelectedIndex > 0 Then 'resolve absolute path for auxiliary file. - Dim absoluteAAUxFile = ResolveAAUXFilePath(GetPath(VECTOfile), txtAdvancedAuxiliaryFile.Text) + Dim absoluteAAUxFile As String = ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text) - Dim aaAssemblyName = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AssemblyName - Dim aaAssemblyVersion = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AuxiliaryVersion + Dim aaAssemblyName As String = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AssemblyName + Dim aaAssemblyVersion As String = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AuxiliaryVersion If Not ValidateAAUXFile(absoluteAAUxFile, aaAssemblyName, aaAssemblyVersion, message) Then @@ -503,96 +529,94 @@ Public Class VectoJobForm End If - Dim vec0 = New VectoJob - vec0.FilePath = file + Dim vectoJob As VectoJob = New VectoJob + vectoJob.FilePath = file 'Files ------------------------------------------------- ----------------- - vec0.PathVeh = TbVEH.Text - vec0.PathEng = TbENG.Text + vectoJob.PathVeh = TbVEH.Text + vectoJob.PathEng = TbENG.Text For Each lv0 As ListViewItem In LvCycles.Items - Dim sb = New SubPath + Dim sb As SubPath = New SubPath sb.Init(GetPath(file), lv0.Text) - vec0.CycleFiles.Add(sb) + vectoJob.CycleFiles.Add(sb) Next - vec0.PathGbx = TbGBX.Text + vectoJob.PathGbx = TbGBX.Text 'Start/Stop - vec0.StartStop = ChBStartStop.Checked - vec0.StStV = CSng(fTextboxToNumString(TbSSspeed.Text)) - vec0.StStT = CSng(fTextboxToNumString(TbSStime.Text)) - vec0.StartStopDelay = CInt(fTextboxToNumString(TbSSdelay.Text)) + vectoJob.StartStop = ChBStartStop.Checked + vectoJob.StartStopMaxSpeed = TbSSspeed.Text.ToDouble() + vectoJob.StartStopTime = TbSStime.Text.ToDouble() + vectoJob.StartStopDelay = TbSSdelay.Text.ToDouble() 'a_DesMax - vec0.DesMaxFile = TbDesMaxFile.Text + vectoJob.DesMaxFile = TbDesMaxFile.Text 'AA-TB - vec0.AuxiliaryAssembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AssemblyName - vec0.AuxiliaryVersion = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AuxiliaryVersion - vec0.AdvancedAuxiliaryFilePath = txtAdvancedAuxiliaryFile.Text + vectoJob.AuxiliaryAssembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AssemblyName + vectoJob.AuxiliaryVersion = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AuxiliaryVersion + vectoJob.AdvancedAuxiliaryFilePath = txtAdvancedAuxiliaryFile.Text For Each lv0 As ListViewItem In LvAux.Items - Dim auxEntry = New VectoJob.AuxEntry + Dim auxEntry As VectoJob.AuxEntry = New VectoJob.AuxEntry If Cfg.DeclMode Then - auxEntry.TechStr = lv0.SubItems(2).Text + auxEntry.TechnologyList.Clear() + auxEntry.TechnologyList.Add(lv0.SubItems(2).Text) Else auxEntry.Path.Init(GetPath(file), lv0.SubItems(2).Text) End If auxEntry.Type = lv0.SubItems(1).Text - vec0.AuxPaths.Add(lv0.SubItems(0).Text, auxEntry) + vectoJob.AuxPaths.Add(lv0.SubItems(0).Text, auxEntry) Next - vec0.EngineOnly = CbEngOnly.Checked + vectoJob.EngineOnly = CbEngOnly.Checked - vec0.EcoRollOn = RdEcoRoll.Checked - vec0.OverSpeedOn = RdOverspeed.Checked - vec0.OverSpeed = CSng(fTextboxToNumString(TbOverspeed.Text)) - vec0.UnderSpeed = CSng(fTextboxToNumString(TbUnderSpeed.Text)) - vec0.VMin = CSng(fTextboxToNumString(TbVmin.Text)) - vec0.LookAheadOn = CbLookAhead.Checked + vectoJob.EcoRollOn = RdEcoRoll.Checked + vectoJob.OverSpeedOn = RdOverspeed.Checked + vectoJob.OverSpeed = TbOverspeed.Text.ToDouble(0) + vectoJob.UnderSpeed = TbUnderSpeed.Text.ToDouble(0) + vectoJob.VMin = TbVmin.Text.ToDouble(0) + vectoJob.LookAheadOn = CbLookAhead.Checked 'vec0.ALookahead = CSng(fTextboxToNumString(TbAlookahead.Text)) 'vec0.VMinLa = CSng(fTextboxToNumString(TbVminLA.Text)) - - vec0.LacPreviewFactor = CSng(fTextboxToNumString(tbLacPreviewFactor.Text)) - vec0.LacDfOffset = CSng(fTextboxToNumString(tbDfCoastingOffset.Text)) - vec0.LacDfScale = CSng(fTextboxToNumString(tbDfCoastingScale.Text)) - vec0.LacDfTargetSpeedFile = tbLacDfTargetSpeedFile.Text - vec0.LacDfVelocityDropFile = tbLacDfVelocityDropFile.Text + vectoJob.LookAheadMinSpeed = tbLacMinSpeed.Text.ToDouble(0) + vectoJob.LacPreviewFactor = tbLacPreviewFactor.Text.ToDouble(0) + vectoJob.LacDfOffset = tbDfCoastingOffset.Text.ToDouble(0) + vectoJob.LacDfScale = tbDfCoastingScale.Text.ToDouble(0) + vectoJob.LacDfTargetSpeedFile = tbLacDfTargetSpeedFile.Text + vectoJob.LacDfVelocityDropFile = tbLacDfVelocityDropFile.Text '------------------------------------------------------------ 'SAVE - If Not vec0.SaveFile Then + If Not vectoJob.SaveFile Then MsgBox("Cannot safe to " & file, MsgBoxStyle.Critical) Return False End If - VECTOfile = file + VectoFile = file - file = GetFilenameWithoutPath(VECTOfile, True) + file = GetFilenameWithoutPath(VectoFile, True) Text = file ToolStripStatusLabelGEN.Text = "" - MainForm.AddToJobListView(VECTOfile) + MainForm.AddToJobListView(VectoFile) - Changed = False + _changed = False Return True End Function 'New file - Public Sub VECTOnew() + Public Sub VectoNew() If ChangeCheckCancel() Then Exit Sub - n_idle = -1 - FLDfile = "" - 'Files TbVEH.Text = "" TbENG.Text = "" @@ -601,8 +625,9 @@ Public Class VectoJobForm TbDesMaxFile.Text = "" 'Start/Stop - TbSSspeed.Text = "5" - TbSStime.Text = "5" + TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat() + TbSStime.Text = DeclarationData.Driver.StartStop.MinTime.ToGUIFormat() + TbSSdelay.Text = DeclarationData.Driver.StartStop.Delay.ToGUIFormat() ChBStartStop.Checked = False LvAux.Items.Clear() @@ -612,13 +637,15 @@ Public Class VectoJobForm RdOff.Checked = True CbLookAhead.Checked = True 'TbAlookahead.Text = "-0.5" - TbOverspeed.Text = "" - TbUnderSpeed.Text = "" - TbVmin.Text = "" + TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat() + TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat() + TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat() + 'TbVminLA.Text = "50" - tbLacPreviewFactor.Text = "10" - tbDfCoastingOffset.Text = "2.5" - tbDfCoastingScale.Text = "1.5" + tbLacMinSpeed.Text = DeclarationData.Driver.LookAhead.MinimumSpeed.AsKmph.ToGUIFormat() + tbLacPreviewFactor.Text = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor.ToGUIFormat() + tbDfCoastingOffset.Text = DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset.ToGUIFormat() + tbDfCoastingScale.Text = DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling.ToGUIFormat() tbLacDfTargetSpeedFile.Text = "" tbLacDfVelocityDropFile.Text = "" @@ -628,10 +655,10 @@ Public Class VectoJobForm EngineForm.AutoSendTo = False - VECTOfile = "" + VectoFile = "" Text = "Job Editor" ToolStripStatusLabelGEN.Text = "" - Changed = False + _changed = False UpdatePic() End Sub @@ -694,16 +721,16 @@ Public Class VectoJobForm #End Region Private Sub Change() - If Not Changed Then + If Not _changed Then ToolStripStatusLabelGEN.Text = "Unsaved changes in current file" - Changed = True + _changed = True End If End Sub ' "Save changes? "... Returns True if User aborts Private Function ChangeCheckCancel() As Boolean - If Changed Then + If _changed Then Select Case MsgBox("Save changes ?", MsgBoxStyle.YesNoCancel) Case MsgBoxResult.Yes @@ -711,7 +738,7 @@ Public Class VectoJobForm Case MsgBoxResult.Cancel Return True Case Else 'MsgBoxResult.No - Changed = False + _changed = False Return False End Select @@ -727,33 +754,33 @@ Public Class VectoJobForm #Region "Aux Listview" Private Sub ButAuxAdd_Click(sender As Object, e As EventArgs) Handles ButAuxAdd.Click - Dim ID As String + Dim id As String - AuxDlog.VehPath = GetPath(VECTOfile) - AuxDlog.TbPath.Text = "" - AuxDlog.CbType.SelectedIndex = -1 - AuxDlog.CbType.Text = "" - AuxDlog.TbID.Text = "" '!!! Set Type before ID, because changing the type will overwrite the id !!! + _auxDialog.VehPath = GetPath(VectoFile) + _auxDialog.TbPath.Text = "" + _auxDialog.CbType.SelectedIndex = -1 + _auxDialog.CbType.Text = "" + _auxDialog.TbID.Text = "" '!!! Set Type before ID, because changing the type will overwrite the id !!! lbDlog: - If AuxDlog.ShowDialog = DialogResult.OK Then + If _auxDialog.ShowDialog = DialogResult.OK Then - ID = UCase(Trim(AuxDlog.TbID.Text)) + id = UCase(Trim(_auxDialog.TbID.Text)) Dim lv0 As ListViewItem For Each lv0 In LvAux.Items - If lv0.SubItems(0).Text = ID Then - MsgBox("ID '" & ID & "' already defined!", MsgBoxStyle.Critical) - AuxDlog.TbID.SelectAll() - AuxDlog.TbID.Focus() + If lv0.SubItems(0).Text = id Then + MsgBox("ID '" & id & "' already defined!", MsgBoxStyle.Critical) + _auxDialog.TbID.SelectAll() + _auxDialog.TbID.Focus() GoTo lbDlog End If Next lv0 = New ListViewItem - lv0.SubItems(0).Text = UCase(Trim(AuxDlog.TbID.Text)) - lv0.SubItems.Add(Trim(AuxDlog.CbType.Text)) - lv0.SubItems.Add(Trim(AuxDlog.TbPath.Text)) + lv0.SubItems(0).Text = UCase(Trim(_auxDialog.TbID.Text)) + lv0.SubItems.Add(Trim(_auxDialog.CbType.Text)) + lv0.SubItems.Add(Trim(_auxDialog.TbPath.Text)) LvAux.Items.Add(lv0) Change() End If @@ -781,29 +808,29 @@ lbDlog: Exit Sub End If - Dim selItem = LvAux.SelectedItems(0) + Dim selItem As ListViewItem = LvAux.SelectedItems(0) - AuxDlog.VehPath = GetPath(VECTOfile) - AuxDlog.CbType.SelectedIndex = -1 - AuxDlog.CbType.Text = selItem.SubItems(1).Text - AuxDlog.TbID.Text = selItem.SubItems(0).Text 'After Type-set! + _auxDialog.VehPath = GetPath(VectoFile) + _auxDialog.CbType.SelectedIndex = -1 + _auxDialog.CbType.Text = selItem.SubItems(1).Text + _auxDialog.TbID.Text = selItem.SubItems(0).Text 'After Type-set! If Cfg.DeclMode Then - AuxDlog.CbTech.Text = selItem.SubItems(2).Text - AuxDlog.TbPath.Text = "" + _auxDialog.CbTech.Text = selItem.SubItems(2).Text + _auxDialog.TbPath.Text = "" Else - AuxDlog.CbTech.SelectedIndex = -1 - AuxDlog.TbPath.Text = selItem.SubItems(2).Text + _auxDialog.CbTech.SelectedIndex = -1 + _auxDialog.TbPath.Text = selItem.SubItems(2).Text End If - If AuxDlog.ShowDialog = DialogResult.OK Then - selItem.SubItems(0).Text = UCase(Trim(AuxDlog.TbID.Text)) - selItem.SubItems(1).Text = Trim(AuxDlog.CbType.Text) + If _auxDialog.ShowDialog = DialogResult.OK Then + selItem.SubItems(0).Text = UCase(Trim(_auxDialog.TbID.Text)) + selItem.SubItems(1).Text = Trim(_auxDialog.CbType.Text) If Cfg.DeclMode Then - selItem.SubItems(2).Text = Trim(AuxDlog.CbTech.Text) + selItem.SubItems(2).Text = Trim(_auxDialog.CbTech.Text) Else - selItem.SubItems(2).Text = Trim(AuxDlog.TbPath.Text) + selItem.SubItems(2).Text = Trim(_auxDialog.TbPath.Text) End If Change() @@ -854,7 +881,7 @@ lbDlog: Private Sub LvCycles_DoubleClick(sender As Object, e As EventArgs) Handles LvCycles.DoubleClick If LvCycles.SelectedItems.Count > 0 Then _ - OpenFiles(fFileRepl(LvCycles.SelectedItems(0).SubItems(0).Text, GetPath(VECTOfile))) + OpenFiles(FileRepl(LvCycles.SelectedItems(0).SubItems(0).Text, GetPath(VectoFile))) End Sub Private Sub LvCycles_KeyDown(sender As Object, e As KeyEventArgs) Handles LvCycles.KeyDown @@ -867,9 +894,10 @@ lbDlog: End Sub Private Sub BtDRIadd_Click(sender As Object, e As EventArgs) Handles BtDRIadd.Click - Dim genDir As String = GetPath(VECTOfile) + Dim genDir As String = GetPath(VectoFile) If DrivingCycleFileBrowser.OpenDialog("", True) Then + Dim s As String For Each s In DrivingCycleFileBrowser.Files LvCycles.Items.Add(GetFilenameWithoutDirectory(s, genDir)) Next @@ -920,19 +948,19 @@ lbDlog: End Sub Private Sub CheckEngOnly() - Dim OnOff As Boolean + Dim onOff As Boolean - OnOff = Not CbEngOnly.Checked + onOff = Not CbEngOnly.Checked - SetDrivertab(OnOff) + SetDrivertab(onOff) - ButOpenVEH.Enabled = OnOff - TbVEH.Enabled = OnOff - ButtonVEH.Enabled = OnOff - ButOpenGBX.Enabled = OnOff - TbGBX.Enabled = OnOff - ButtonGBX.Enabled = OnOff - GrAux.Enabled = OnOff + ButOpenVEH.Enabled = onOff + TbVEH.Enabled = onOff + ButtonVEH.Enabled = onOff + ButOpenGBX.Enabled = onOff + TbGBX.Enabled = onOff + ButtonGBX.Enabled = onOff + GrAux.Enabled = onOff End Sub 'Start/Stop changed @@ -946,54 +974,38 @@ lbDlog: Private Sub CbLookAhead_CheckedChanged(sender As Object, e As EventArgs) _ Handles CbLookAhead.CheckedChanged Change() + pnLookAheadCoasting.Enabled = CbLookAhead.Checked End Sub 'EcoRoll / Overspeed changed 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 + Dim ecoRoll As Boolean + Dim overspeed As Boolean Change() - EcoR = RdEcoRoll.Checked - Ovr = RdOverspeed.Checked + ecoRoll = RdEcoRoll.Checked + overspeed = RdOverspeed.Checked - TbOverspeed.Enabled = Ovr Or EcoR - Label13.Enabled = Ovr Or EcoR - Label14.Enabled = Ovr Or EcoR + TbOverspeed.Enabled = overspeed Or ecoRoll + Label13.Enabled = overspeed Or ecoRoll + Label14.Enabled = overspeed Or ecoRoll - TbUnderSpeed.Enabled = EcoR - Label22.Enabled = EcoR - Label20.Enabled = EcoR + TbUnderSpeed.Enabled = ecoRoll + Label22.Enabled = ecoRoll + Label20.Enabled = ecoRoll - TbVmin.Enabled = Ovr Or EcoR - Label23.Enabled = Ovr Or EcoR - Label21.Enabled = Ovr Or EcoR + TbVmin.Enabled = overspeed Or ecoRoll + Label23.Enabled = overspeed Or ecoRoll + Label21.Enabled = overspeed Or ecoRoll End Sub #End Region Public Sub UpdatePic() - Dim VEH0 As New Vehicle - Dim i As Integer - Dim pmax As Single - - Dim f As CsvFile - Dim lM As List(Of Single) - Dim lup As List(Of Single) - Dim ldown As List(Of Single) - Dim line As String() - - Dim HDVclass As String - 'Dim m0 As - - Dim s As Series - Dim a As ChartArea - Dim img As Image - Dim EngOK = False TbHVCclass.Text = "" TbVehCat.Text = "" @@ -1004,278 +1016,272 @@ lbDlog: PicVehicle.Image = Nothing PicBox.Image = Nothing + UpdateVehiclePic() - VEH0.FilePath = fFileRepl(TbVEH.Text, GetPath(VECTOfile)) - If VEH0.ReadFile(False) Then - Dim maxMass = (VEH0.MassMax * 1000).SI(Of Kilogram)() 'CSng(fTextboxToNumString(TbMassMass.Text)) + Dim chart As Chart = Nothing + UpdateEnginePic(chart) - Dim s0 As Segment = Nothing - Try - s0 = DeclarationData.Segments.Lookup(VEH0.VehicleCategory, VEH0.AxleConfiguration, maxMass, 0.SI(Of Kilogram), True) - Catch - End Try - If Not s0 Is Nothing Then - HDVclass = s0.VehicleClass.GetClassNumber() - - If Cfg.DeclMode Then - LvCycles.Items.Clear() - For Each m0 In s0.Missions - LvCycles.Items.Add(m0.MissionType.ToString()) - Next - End If - Else - HDVclass = "-" - End If + UpdateGearboxPic(chart) - PicVehicle.Image = ConvPicPath(HDVclass, False) 'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False)) + If chart Is Nothing Then Return - TbHVCclass.Text = "HDV Class " & HDVclass - TbVehCat.Text = VEH0.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True) - TbMass.Text = VEH0.MassMax & " t" - TbAxleConf.Text = VEH0.AxleConfiguration.GetName() 'ConvAxleConf(VEH0.AxleConf) + Dim chartArea As ChartArea = New ChartArea() + chartArea.Name = "main" - End If + chartArea.AxisX.Title = "engine speed [1/min]" + chartArea.AxisX.TitleFont = New Font("Helvetica", 10) + chartArea.AxisX.LabelStyle.Font = New Font("Helvetica", 8) + chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None + chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot + chartArea.AxisY.Title = "engine torque [Nm]" + chartArea.AxisY.TitleFont = New Font("Helvetica", 10) + chartArea.AxisY.LabelStyle.Font = New Font("Helvetica", 8) + chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None + chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot - Dim OkCount = 0 + chartArea.AxisX.Minimum = 300 + chartArea.BorderDashStyle = ChartDashStyle.Solid + chartArea.BorderWidth = 1 - Dim ENG0 = New Engine - ENG0.FilePath = fFileRepl(TbENG.Text, GetPath(VECTOfile)) + chartArea.BackColor = Color.GhostWhite - 'Create plot - Dim MyChart = New Chart - MyChart.Width = PicBox.Width - MyChart.Height = PicBox.Height + chart.ChartAreas.Add(chartArea) + chart.Update() - a = New ChartArea + Dim img As Bitmap = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb) + chart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height)) - Dim FLD0 = New EngineFullLoadCurve + PicBox.Image = img + End Sub - If ENG0.ReadFile(False) Then + Private Sub UpdateGearboxPic(ByRef chartArea As Chart) + Dim s As Series + Dim i As Integer - n_idle = ENG0.IdleSpeed - FLDfile = ENG0.PathFLD + Dim gearbox As IGearboxEngineeringInputData = Nothing + Dim gearboxFile As String = + If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbGBX.Text), TbGBX.Text) + If File.Exists(gearboxFile) Then + Try + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(gearboxFile), + IEngineeringInputDataProvider) + gearbox = inputData.GearboxInputData + Catch + End Try + End If - EngOK = True - FLD0.FilePath = ENG0.PathFLD + If gearbox Is Nothing Then Return - If FLD0.ReadFile(False, False) Then + TbGbxTxt.Text = String.Format("{0}-Speed {1} {2}", gearbox.Gears.Count, gearbox.Type.ShortName(), gearbox.ModelName) + If Cfg.DeclMode Then + For i = 1 To gearbox.Gears.Count + 'If FLD0.Init(ENG0.Nidle) Then '' use engine from below... + + 'Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle) + 'Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, + ' engine.FullLoadCurve, gears, + ' engine, + ' Double.Parse(LvGears.Items(0).SubItems(F_GBX.GearboxTbl.Ratio).Text, + ' CultureInfo.InvariantCulture), + ' (.rdyn / 1000.0).SI(Of Meter)) + + 's = New Series + 's.Points.DataBindXY(shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + ' shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) + 's.ChartType = SeriesChartType.FastLine + 's.BorderWidth = 2 + 's.Color = Color.DarkRed + 's.Name = "Upshift curve (" & i & ")" + 'MyChart.Series.Add(s) + + 's = New Series + 's.Points.DataBindXY( + ' shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + ' shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) + 's.ChartType = SeriesChartType.FastLine + 's.BorderWidth = 2 + 's.Color = Color.DarkRed + 's.Name = "Downshift curve (" & i & ")" + 'MyChart.Series.Add(s) + 'End If + + ' OkCount += 1 + + ' pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) + + 'End If + Next + Else + For Each gear As ITransmissionInputData In gearbox.Gears + If gear.ShiftPolygon Is Nothing OrElse gear.ShiftPolygon.Rows.Count = 0 Then Continue For + Dim shiftPolygon As ShiftPolygon = ShiftPolygonReader.Create(gear.ShiftPolygon) s = New Series - s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.MaxTorqueList) + s.Points.DataBindXY(shiftPolygon.Upshift.Select(Function(x) x.AngularSpeed), + shiftPolygon.Upshift.Select(Function(x) x.Torque)) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 - s.Color = Color.DarkBlue - s.Name = "Full load" - MyChart.Series.Add(s) + s.Color = Color.DarkRed + s.Name = "Upshift curve" + ' MyChart.Series.Add(s) 'MQ 2016-06-20: do not plot shift lines in engine dialog s = New Series - s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.DragTorqueList) + s.Points.DataBindXY(shiftPolygon.Downshift.Select(Function(x) x.AngularSpeed), + shiftPolygon.Downshift.Select(Function(x) x.Torque)) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 - s.Color = Color.Blue - s.Name = "Motoring" - MyChart.Series.Add(s) - - OkCount += 1 - - pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) - - End If - - TbEngTxt.Text = (ENG0.Displacement / 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " & ENG0.ModelName - - - Dim MAP0 = New FuelconsumptionMap - MAP0.FilePath = ENG0.PathMAP - - If MAP0.ReadFile(False) Then - - s = New Series - s.Points.DataBindXY(MAP0.nU, MAP0.Tq) - s.ChartType = SeriesChartType.Point - s.MarkerSize = 3 - s.Color = Color.Red - s.Name = "Map" - MyChart.Series.Add(s) - - OkCount += 1 - - End If - + s.Color = Color.DarkRed + s.Name = "Downshift curve" + 'MyChart.Series.Add(s) 'MQ 2016-06-20:do not plot shift lines in engine dialog + Next End If + End Sub - Dim GBX0 = New Gearbox - GBX0.FilePath = fFileRepl(TbGBX.Text, GetPath(VECTOfile)) - - If GBX0.ReadFile(False) Then - - TbGbxTxt.Text = GBX0.GearCount & "-Speed " & GBX0.Type.ShortName() & " " & GBX0.ModelName - - If Cfg.DeclMode Then - - If EngOK Then - - For i = 1 To GBX0.GearCount - - FLD0.FilePath = ENG0.PathFLD - - If FLD0.ReadFile(True, False) Then - - 'If FLD0.Init(ENG0.Nidle) Then '' use engine from below... + Private Sub UpdateEnginePic(ByRef chart As Chart) + Dim s As Series + Dim pmax As Double - 'Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle) - 'Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, - ' engine.FullLoadCurve, gears, - ' engine, - ' Double.Parse(LvGears.Items(0).SubItems(F_GBX.GearboxTbl.Ratio).Text, - ' CultureInfo.InvariantCulture), - ' (.rdyn / 1000.0).SI(Of Meter)) + Dim engine As IEngineEngineeringInputData = Nothing + Dim engineFile As String = + If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbENG.Text), TbENG.Text) + If File.Exists(engineFile) Then + Try + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(engineFile), + IEngineeringInputDataProvider) + engine = inputData.EngineInputData + Catch + Return + End Try + End If - 's = New Series - 's.Points.DataBindXY(shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - ' shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) - 's.ChartType = SeriesChartType.FastLine - 's.BorderWidth = 2 - 's.Color = Color.DarkRed - 's.Name = "Upshift curve (" & i & ")" - 'MyChart.Series.Add(s) + 'engine.FilePath = fFileRepl(TbENG.Text, GetPath(VECTOfile)) - 's = New Series - 's.Points.DataBindXY( - ' shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - ' shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) - 's.ChartType = SeriesChartType.FastLine - 's.BorderWidth = 2 - 's.Color = Color.DarkRed - 's.Name = "Downshift curve (" & i & ")" - 'MyChart.Series.Add(s) - 'End If + 'Create plot + chart = New Chart + chart.Width = PicBox.Width + chart.Height = PicBox.Height - OkCount += 1 + 'Dim FLD0 As EngineFullLoadCurve = New EngineFullLoadCurve - pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) + If engine Is Nothing Then Return - End If - Next + engine.IdleSpeed.Value() - End If + Dim fullLoadCurve As FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve) - Else + s = New Series + s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkBlue + s.Name = "Full load" + chart.Series.Add(s) - f = New CsvFile - For i = 1 To GBX0.GearCount + s = New Series + s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value()).ToArray()) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.Blue + s.Name = "Motoring" + chart.Series.Add(s) - lM = New List(Of Single) - lup = New List(Of Single) - ldown = New List(Of Single) + pmax = fullLoadCurve.MaxPower.Value() / 1000 'FLD0.Pfull(FLD0.EngineRatedSpeed) - If f.OpenRead(GBX0.ShiftPolygonFile(i)) Then - f.ReadLine() + TbEngTxt.Text = String.Format("{0} l {1} kw {2}", (engine.Displacement.Value() * 1000).ToString("0.0"), pmax.ToString("#"), engine.ModelName) - Try + Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.FuelConsumptionMap) - Do While Not f.EndOfFile - line = f.ReadLine - lM.Add(CSng(line(0))) - lup.Add(CSng(line(1))) - ldown.Add(CSng(line(2))) - Loop + s = New Series + s.Points.DataBindXY(fuelConsumptionMap.Entries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fuelConsumptionMap.Entries.Select(Function(x) x.Torque.Value()).ToArray()) + s.ChartType = SeriesChartType.Point + s.MarkerSize = 3 + s.Color = Color.Red + s.Name = "Map" + chart.Series.Add(s) + End Sub - s = New Series - s.Points.DataBindXY(lup, lM) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.Name = "Upshift curve" - ' MyChart.Series.Add(s) 'MQ 2016-06-20: do not plot shift lines in engine dialog + Private Sub UpdateVehiclePic() + Dim HDVclass As String - s = New Series - s.Points.DataBindXY(ldown, lM) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.Name = "Downshift curve" - 'MyChart.Series.Add(s) 'MQ 2016-06-20:do not plot shift lines in engine dialog + Dim vehicle As IVehicleEngineeringInputData = Nothing - OkCount += 1 + Dim vehicleFile As String = + If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbVEH.Text), TbVEH.Text) + If File.Exists(vehicleFile) Then + Try + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(vehicleFile), + IEngineeringInputDataProvider) + vehicle = inputData.VehicleInputData + Catch + End Try + End If - f.Close() + If vehicle Is Nothing Then Return - Catch ex As Exception - f.Close() - End Try + Dim maxMass As Kilogram = vehicle.GrossVehicleMassRating 'CSng(fTextboxToNumString(TbMassMass.Text)) - End If + Dim s0 As Segment = Nothing + Try + s0 = DeclarationData.Segments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, maxMass, 0.SI(Of Kilogram), + True) + Catch + End Try + If s0 Is Nothing Then + HDVclass = "-" + Else + HDVclass = s0.VehicleClass.GetClassNumber() + If Cfg.DeclMode Then + LvCycles.Items.Clear() + Dim m0 As Mission + For Each m0 In s0.Missions + LvCycles.Items.Add(m0.MissionType.ToString()) Next - End If End If - If OkCount > 0 Then - - a.Name = "main" + PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, HDVclass.ToInt()), False) _ + 'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False)) - a.AxisX.Title = "engine speed [1/min]" - a.AxisX.TitleFont = New Font("Helvetica", 10) - a.AxisX.LabelStyle.Font = New Font("Helvetica", 8) - a.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None - a.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot - - a.AxisY.Title = "engine torque [Nm]" - a.AxisY.TitleFont = New Font("Helvetica", 10) - a.AxisY.LabelStyle.Font = New Font("Helvetica", 8) - a.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None - a.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot - - a.AxisX.Minimum = 300 - a.BorderDashStyle = ChartDashStyle.Solid - a.BorderWidth = 1 - - a.BackColor = Color.GhostWhite - - MyChart.ChartAreas.Add(a) - - MyChart.Update() - - img = New Bitmap(MyChart.Width, MyChart.Height, PixelFormat.Format32bppArgb) - MyChart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height)) - - PicBox.Image = img - - - End If + TbHVCclass.Text = String.Format("HDV Class {0}", HDVclass) + TbVehCat.Text = vehicle.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True) + TbMass.Text = (vehicle.GrossVehicleMassRating.Value() / 1000) & " t" + TbAxleConf.Text = vehicle.AxleConfiguration.GetName() 'ConvAxleConf(VEH0.AxleConf) End Sub #Region "Open File Context Menu" - Private CmFiles As String() + Private _contextMenuFiles As String() + Private _basePath As String = "" Private Sub OpenFiles(ParamArray files() As String) If files.Length = 0 Then Exit Sub - CmFiles = files + _contextMenuFiles = files OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName CmOpenFile.Show(Windows.Forms.Cursor.Position) End Sub Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenWithToolStripMenuItem.Click - If Not FileOpenAlt(CmFiles(0)) Then MsgBox("Failed to open file!") + If Not FileOpenAlt(_contextMenuFiles(0)) Then MsgBox("Failed to open file!") End Sub Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ShowInFolderToolStripMenuItem.Click - If File.Exists(CmFiles(0)) Then + If File.Exists(_contextMenuFiles(0)) Then Try - Process.Start("explorer", "/select,""" & CmFiles(0) & "") + Process.Start("explorer", "/select,""" & _contextMenuFiles(0) & "") Catch ex As Exception MsgBox("Failed to open file!") End Try @@ -1314,14 +1320,14 @@ lbDlog: 'AA-TB Private Sub btnBrowseAAUXFile_Click(sender As Object, e As EventArgs) Handles btnBrowseAAUXFile.Click - If String.IsNullOrEmpty(VECTOfile) Then + If String.IsNullOrEmpty(VectoFile) Then MessageBox.Show( "Please complete and save a valid new .vecto file before adding/configuring advanced bus auxiliaries.") Return End If Dim aauxFileValidated As Boolean = False - Dim fbAux As New FileBrowser(True, False) + Dim fbAux As New FileBrowser("aaux", True, False) Dim message As String = String.Empty Dim absoluteAuxPath As String Dim assembly As AdvancedAuxiliary @@ -1330,7 +1336,7 @@ lbDlog: If cboAdvancedAuxiliaries.SelectedIndex = 0 Then Return 'Get Absolute Path for AAUX FILE. - absoluteAuxPath = ResolveAAUXFilePath(GetPath(VECTOfile), txtAdvancedAuxiliaryFile.Text) + absoluteAuxPath = ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text) 'Set Extensions fbAux.Extensions = New String() {"AAUX"} @@ -1345,7 +1351,7 @@ lbDlog: If fileExists AndAlso validAAUXFile Then ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion, - txtAdvancedAuxiliaryFile.Text, VECTOfile) + txtAdvancedAuxiliaryFile.Text, VectoFile) Else Dim needToFindOrCreateFile As Boolean = True @@ -1353,16 +1359,17 @@ lbDlog: While needToFindOrCreateFile 'Find / Create file and configure. - If fbAux.CustomDialog(absoluteAuxPath, False, False, tFbExtMode.ForceExt, False, String.Empty) Then - txtAdvancedAuxiliaryFile.Text = GetFilenameWithoutDirectory(fbAux.Files(0), GetPath(VECTOfile)) + If fbAux.CustomDialog(absoluteAuxPath, False, False, FileBrowserFileExtensionMode.ForceExt, False, String.Empty) _ + Then + txtAdvancedAuxiliaryFile.Text = GetFilenameWithoutDirectory(fbAux.Files(0), GetPath(VectoFile)) assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary) If _ - File.Exists(ResolveAAUXFilePath(GetPath(VECTOfile), txtAdvancedAuxiliaryFile.Text)) OrElse + File.Exists(ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text)) OrElse MsgBox("Do you want to create a new .AAUX file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then needToFindOrCreateFile = False ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion, - txtAdvancedAuxiliaryFile.Text, VECTOfile) + txtAdvancedAuxiliaryFile.Text, VectoFile) End If Else needToFindOrCreateFile = False @@ -1399,14 +1406,25 @@ lbDlog: 'AA-TB Private Sub btnAAUXOpen_Click(sender As Object, e As EventArgs) Handles btnAAUXOpen.Click - OpenFiles(fFileRepl(txtAdvancedAuxiliaryFile.Text, GetPath(VECTOfile))) + OpenFiles(FileRepl(txtAdvancedAuxiliaryFile.Text, GetPath(VectoFile))) End Sub - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnDfTargetSpeed.Click - If DriverDecisionFactorTargetSpeedFileBrowser.OpenDialog(fFileRepl(tbLacDfTargetSpeedFile.Text, GetPath(VECTOfile))) _ + + Private Sub btnDfTargetSpeed_Click(sender As Object, e As EventArgs) Handles btnDfTargetSpeed.Click + If DriverDecisionFactorTargetSpeedFileBrowser.OpenDialog(FileRepl(tbLacDfTargetSpeedFile.Text, GetPath(VectoFile))) _ Then _ tbLacDfTargetSpeedFile.Text = GetFilenameWithoutDirectory(DriverDecisionFactorTargetSpeedFileBrowser.Files(0), - GetPath(VECTOfile)) + GetPath(VectoFile)) + End Sub + + Private Sub btnDfVelocityDrop_Click_1(sender As Object, e As EventArgs) Handles btnDfVelocityDrop.Click + If DriverDecisionFactorVelocityDropFileBrowser.OpenDialog(FileRepl(tbLacDfVelocityDropFile.Text, GetPath(VectoFile))) _ + Then _ + tbLacDfVelocityDropFile.Text = GetFilenameWithoutDirectory(DriverDecisionFactorVelocityDropFileBrowser.Files(0), + GetPath(VectoFile)) + End Sub + + Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click End Sub End Class diff --git a/VECTO/GUI/VehicleAuxiliariesDialog.vb b/VECTO/GUI/VehicleAuxiliariesDialog.vb index 831bc43416450ca7b9dd03daed98936eb9a6e6fc..3e25d287e0604a46f01216acb4d4437e8f561e1c 100644 --- a/VECTO/GUI/VehicleAuxiliariesDialog.vb +++ b/VECTO/GUI/VehicleAuxiliariesDialog.vb @@ -40,15 +40,15 @@ Public Class VehicleAuxiliariesDialog Private Sub DeclInit() CbTech.Items.Clear() Select Case TbID.Text - Case sKey.AUX.Fan + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.Fan CbTech.Items.AddRange(DeclarationData.Fan.GetTechnologies()) - Case sKey.AUX.SteerPump + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.SteeringPump CbTech.Items.AddRange(DeclarationData.SteeringPump.GetTechnologies()) - Case sKey.AUX.HVAC + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.HeatingVentilationAirCondition CbTech.Items.AddRange(DeclarationData.HeatingVentilationAirConditioning.GetTechnologies()) - Case sKey.AUX.ElecSys + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.ElectricSystem CbTech.Items.AddRange(DeclarationData.ElectricSystem.GetTechnologies()) - Case sKey.AUX.PneumSys + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.PneumaticSystem CbTech.Items.AddRange(DeclarationData.PneumaticSystem.GetTechnologies()) End Select If CbTech.Items.Count > 0 Then @@ -94,7 +94,8 @@ Public Class VehicleAuxiliariesDialog 'Browse for .vaux files Private Sub BtBrowse_Click(sender As Object, e As EventArgs) Handles BtBrowse.Click - If AuxFileBrowser.OpenDialog(fFileRepl(TbPath.Text, VehPath)) Then TbPath.Text = GetFilenameWithoutDirectory(AuxFileBrowser.Files(0), VehPath) + If AuxFileBrowser.OpenDialog(FileRepl(TbPath.Text, VehPath)) Then _ + TbPath.Text = GetFilenameWithoutDirectory(AuxFileBrowser.Files(0), VehPath) End Sub 'Update ID when Aux Type was changed @@ -106,12 +107,12 @@ Public Class VehicleAuxiliariesDialog If Cfg.DeclMode Then Select Case CbType.SelectedIndex Case 0 - TbID.Text = sKey.AUX.Fan + TbID.Text = VectoCore.Configuration.Constants.Auxiliaries.IDs.Fan Case 1 - TbID.Text = sKey.AUX.SteerPump + TbID.Text = VectoCore.Configuration.Constants.Auxiliaries.IDs.SteeringPump Case Else '2 - TbID.Text = sKey.AUX.HVAC + TbID.Text = VectoCore.Configuration.Constants.Auxiliaries.IDs.HeatingVentilationAirCondition End Select Else @@ -128,7 +129,7 @@ Public Class VehicleAuxiliariesDialog If Trim(TbID.Text) = "" Or Cfg.DeclMode Then LbIDhelp.Text = "" Else - LbIDhelp.Text = "Header in Driving cycle: <AUX_" & Trim(TbID.Text) & ">" + LbIDhelp.Text = String.Format("Header in Driving cycle: <AUX_{1}>", Trim(TbID.Text)) End If End Sub End Class diff --git a/VECTO/GUI/VehicleAxleDialog.vb b/VECTO/GUI/VehicleAxleDialog.vb index 43a6468b5273d0f3d11592c440f5e1f35695bb7f..9763d04bccfbd73f058342edf08d3e4a5da96632 100644 --- a/VECTO/GUI/VehicleAxleDialog.vb +++ b/VECTO/GUI/VehicleAxleDialog.vb @@ -12,6 +12,12 @@ Option Infer On Option Strict On Option Explicit On +Imports System.Collections.Generic +Imports System.ComponentModel.DataAnnotations +Imports System.Linq +Imports TUGraz.VectoCommon.Models +Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.Impl Imports TUGraz.VectoCore.Models.Declaration @@ -43,20 +49,23 @@ Public Class VehicleAxleDialog 'Save and close Private Sub OK_Button_Click(sender As Object, e As EventArgs) Handles OK_Button.Click - If Not Cfg.DeclMode Then - If Not IsNumeric(TbAxleShare.Text) OrElse Trim(TbAxleShare.Text) = "" Then - MsgBox("Weight input is not valid!") - Exit Sub - End If - End If + Dim axleData As Axle = New Axle With { + .AxleWeightShare = TbAxleShare.Text.ToDouble(0), + .RollResistanceCoefficient = TbRRC.Text.ToDouble(0), + .TyreTestLoad = TbFzISO.Text.ToDouble(0).SI(Of Newton)(), + .TwinTyres = CbTwinT.Checked, + .WheelsDimension = CbWheels.SelectedItem.ToString(), + .Inertia = TbI_wheels.Text.ToDouble(0).SI(Of KilogramSquareMeter)() + } - If Not IsNumeric(TbRRC.Text) OrElse Trim(TbRRC.Text) = "" Then - MsgBox("RRC input is not valid!") - Exit Sub - End If + Dim results As IList(Of ValidationResult) = + axleData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) - If Not IsNumeric(TbFzISO.Text) OrElse Trim(TbFzISO.Text) = "" Then - MsgBox("Fz ISO input is not valid!") + If results.Any() Then + Dim messages As IEnumerable(Of String) = + results.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + MsgBox("Invalid input:" + Environment.NewLine + String.Join(Environment.NewLine, messages), MsgBoxStyle.OkOnly, + "Failed to save axle gear") Exit Sub End If diff --git a/VECTO/GUI/VehicleForm.vb b/VECTO/GUI/VehicleForm.vb index 28d309b0149914ddce063fc4409f6f041e158816..d17350647b9b7e7880a7f573c2488dc458c70851 100644 --- a/VECTO/GUI/VehicleForm.vb +++ b/VECTO/GUI/VehicleForm.vb @@ -8,19 +8,31 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. -Option Infer On +'Option Infer On Imports System.IO Imports System.Linq Imports System.Text.RegularExpressions +Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.Models.Declaration ''' <summary> ''' Vehicle Editor. ''' </summary> Public Class VehicleForm + Private Enum AxleTbl + AxleNumber = 0 + RelativeLoad = 1 + TwinTyres = 2 + RRC = 3 + FzISO = 4 + WheelsDimension = 5 + Inertia = 6 + End Enum + Private _axlDlog As VehicleAxleDialog Private _hdVclass As String Private _vehFile As String @@ -31,14 +43,14 @@ Public Class VehicleForm Public JobDir As String = "" 'Close - Check for unsaved changes - Private Sub F_VEH_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing + Private Sub VehicleFormClosing(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(sender As Object, e As EventArgs) Handles MyBase.Load + Private Sub VehicleFormLoad(sender As Object, e As EventArgs) Handles MyBase.Load TbLoadingMax.Text = "-" PnLoad.Enabled = Not Cfg.DeclMode ButAxlAdd.Enabled = Not Cfg.DeclMode @@ -90,12 +102,12 @@ Public Class VehicleForm 'Set HDVclasss Private Sub SetHdVclass() - If String.IsNullOrEmpty(TbMassMass.Text) Then + If String.IsNullOrEmpty(TbMassMass.Text) OrElse Not IsNumeric(TbMassMass.Text) Then TbHDVclass.Text = "-" Exit Sub End If - Dim vehC As VehicleCategory = CbCat.SelectedValue - Dim axlC As AxleConfiguration = CbAxleConfig.SelectedValue + Dim vehC As VehicleCategory = CType(CbCat.SelectedValue, VehicleCategory) + Dim axlC As AxleConfiguration = CType(CbAxleConfig.SelectedValue, AxleConfiguration) Dim maxMass As Kilogram = (TbMassMass.Text.ToDouble() * 1000).SI(Of Kilogram)() _hdVclass = "-" @@ -107,12 +119,12 @@ Public Class VehicleForm ' no segment found - ignore End Try If Not s0 Is Nothing Then - _hdVclass = s0.VehicleClass + _hdVclass = s0.VehicleClass.GetClassNumber() End If TbHDVclass.Text = _hdVclass - PicVehicle.Image = ConvPicPath(_hdVclass, False) + PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, _hdVclass.ToInt()), False) End Sub @@ -124,9 +136,9 @@ Public Class VehicleForm TbHDVclass.Text = "-" Exit Sub End If - Dim vehC = CbCat.SelectedValue - Dim axlC = CbAxleConfig.SelectedValue - Dim maxMass = (TbMassMass.Text.ToDouble() * 1000).SI(Of Kilogram)() + Dim vehC As VehicleCategory = CType(CbCat.SelectedValue, VehicleCategory) + Dim axlC As AxleConfiguration = CType(CbAxleConfig.SelectedValue, AxleConfiguration) + Dim maxMass As Kilogram = (TbMassMass.Text.ToDouble() * 1000).SI(Of Kilogram)() Dim s0 As Segment = Nothing Try @@ -135,21 +147,14 @@ Public Class VehicleForm ' no segment found - ignore End Try If Not s0 Is Nothing Then - _hdVclass = s0.VehicleClass - Dim axleCount As Short = s0.Missions(0).AxleWeightDistribution.Count() - Dim i0 = LvRRC.Items.Count + _hdVclass = s0.VehicleClass.GetClassNumber() + Dim axleCount As Integer = s0.Missions(0).AxleWeightDistribution.Count() + Dim i0 As Integer = LvRRC.Items.Count + Dim i As Integer 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") - lvi.SubItems.Add("") - lvi.SubItems.Add("") - lvi.SubItems.Add("-") - lvi.SubItems.Add("-") - LvRRC.Items.Add(lvi) + LvRRC.Items.Add(CreateListViewItem(i + i0, Double.NaN, False, Double.NaN, Double.NaN, "", Double.NaN)) Next ElseIf axleCount < LvRRC.Items.Count Then @@ -170,13 +175,13 @@ Public Class VehicleForm CbCdMode.SelectedValue = CrossWindCorrectionMode.DeclarationModeCorrection TbCdFile.Text = "" - Dim rdyn As Single + Dim rdyn As Double rdyn = -1 If rdyn < 0 Then TBrdyn.Text = "-" Else - TBrdyn.Text = rdyn + TBrdyn.Text = rdyn.ToGUIFormat() End If End Sub @@ -190,7 +195,14 @@ Public Class VehicleForm 'Open Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click - If VehicleFileBrowser.OpenDialog(_vehFile) Then OpenVehicle(VehicleFileBrowser.Files(0)) + If VehicleFileBrowser.OpenDialog(_vehFile) Then + Try + OpenVehicle(VehicleFileBrowser.Files(0)) + Catch ex As Exception + MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Vehicle File") + End Try + + End If End Sub 'Save @@ -220,7 +232,7 @@ Public Class VehicleForm If Not VectoJobForm.Visible Then JobDir = "" VectoJobForm.Show() - VectoJobForm.VECTOnew() + VectoJobForm.VectoNew() Else VectoJobForm.WindowState = FormWindowState.Normal End If @@ -231,8 +243,9 @@ Public Class VehicleForm 'Help Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click If File.Exists(MyAppPath & "User Manual\help.html") Then - Dim registryString = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString - Dim defaultBrowserPath = Regex.Match(registryString, "(\"".*?\"")").Captures(0).ToString + Dim registryString As String = + My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString + Dim defaultBrowserPath As String = Regex.Match(registryString, "(\"".*?\"")").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) @@ -305,19 +318,17 @@ Public Class VehicleForm 'Open VEH Sub OpenVehicle(file As String) - Dim inertia As Single If ChangeCheckCancel() Then Exit Sub - Dim veh = New Vehicle - veh.FilePath = file - - If Not veh.ReadFile Then - MsgBox("Cannot read " & file & "!") - Exit Sub - End If + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), + IEngineeringInputDataProvider) + Dim vehicle As IVehicleEngineeringInputData = inputData.VehicleInputData + Dim retarder As IRetarderInputData = inputData.RetarderInputData + Dim angularGear As IAngularGearInputData = inputData.AngularGearInputData + Dim pto As IPTOTransmissionInputData = inputData.PTOTransmissionInputData - If Cfg.DeclMode <> veh.SavedInDeclMode Then + If Cfg.DeclMode <> vehicle.SavedInDeclarationMode Then Select Case WrongMode() Case 1 Close() @@ -328,71 +339,57 @@ Public Class VehicleForm End Select End If - TbMass.Text = veh.Mass - TbMassExtra.Text = veh.MassExtra - TbLoad.Text = veh.Loading - TBrdyn.Text = veh.DynamicTyreRadius + Dim basePath As String = Path.GetDirectoryName(file) + CbCat.SelectedValue = vehicle.VehicleCategory + CbAxleConfig.SelectedValue = vehicle.AxleConfiguration + TbMassMass.Text = (vehicle.GrossVehicleMassRating.Value() / 1000).ToGUIFormat() - CbCdMode.SelectedValue = veh.CrossWindCorrectionMode - TbCdFile.Text = veh.CrossWindCorrectionFile.OriginalPath + TbMass.Text = vehicle.CurbWeightChassis.ToGUIFormat() + TbMassExtra.Text = vehicle.CurbWeightExtra.ToGUIFormat() + TbLoad.Text = vehicle.Loading.ToGUIFormat() + TBrdyn.Text = (vehicle.DynamicTyreRadius.Value() * 1000).ToGUIFormat() - CbRtType.SelectedValue = veh.RetarderType - TbRtRatio.Text = veh.RetarderRatio - TbRtPath.Text = veh.RetarderLossMapFile.OriginalPath + CbCdMode.SelectedValue = vehicle.CrossWindCorrectionMode + TbCdFile.Text = + If(vehicle.CrosswindCorrectionMap Is Nothing, "", GetRelativePath(vehicle.CrosswindCorrectionMap.Source, basePath)) - cbAngularGearType.SelectedValue = veh.AngularGearType - tbAngularGearRatio.Text = veh.AngularGearRatio - tbAngularGearLossMapPath.Text = veh.AngularGearLossMapFile.OriginalPath + CbRtType.SelectedValue = retarder.Type + TbRtRatio.Text = retarder.Ratio.ToGUIFormat() + TbRtPath.Text = If(retarder.LossMap Is Nothing, "", GetRelativePath(retarder.LossMap.Source, basePath)) - CbCat.SelectedValue = veh.VehicleCategory + cbAngularGearType.SelectedValue = angularGear.Type + tbAngularGearRatio.Text = angularGear.Ratio.ToGUIFormat() + tbAngularGearLossMapPath.Text = + If(angularGear.LossMap Is Nothing, "", GetRelativePath(angularGear.LossMap.Source, basePath)) LvRRC.Items.Clear() - Dim i = 0 - For Each a0 In veh.Axles + Dim i As Integer = 0 + Dim a0 As IAxleEngineeringInputData + For Each a0 In vehicle.Axles i += 1 - Dim lvi = New ListViewItem - lvi.SubItems(0).Text = i.ToString - - If Cfg.DeclMode Then - lvi.SubItems.Add("-") - Else - lvi.SubItems.Add(a0.Share) - End If - If a0.TwinTire Then - lvi.SubItems.Add("yes") - Else - lvi.SubItems.Add("no") - End If - lvi.SubItems.Add(a0.RRC) - lvi.SubItems.Add(a0.FzISO) - lvi.SubItems.Add(a0.Wheels) If Cfg.DeclMode Then - inertia = DeclarationData.Wheels.Lookup(a0.Wheels).Inertia.Value() - If inertia < 0 Then - lvi.SubItems.Add("-") - Else - lvi.SubItems.Add(inertia) - End If + Dim inertia As Double = DeclarationData.Wheels.Lookup(a0.Wheels).Inertia.Value() + LvRRC.Items.Add(CreateListViewItem(i, Double.NaN, a0.TwinTyres, a0.RollResistanceCoefficient, + a0.TyreTestLoad.Value(), a0.Wheels, inertia)) Else - lvi.SubItems.Add(a0.Inertia) + LvRRC.Items.Add(CreateListViewItem(i, a0.AxleWeightShare, a0.TwinTyres, a0.RollResistanceCoefficient, + a0.TyreTestLoad.Value(), a0.Wheels, a0.Inertia.Value())) + End If - LvRRC.Items.Add(lvi) Next - TbMassMass.Text = veh.MassMax - TbMassExtra.Text = veh.MassExtra - CbAxleConfig.SelectedValue = veh.AxleConfiguration + 'TbMassExtra.Text = veh.MassExtra.ToGUIFormat() - TBcdA.Text = veh.CdA0 + TBcdA.Text = vehicle.AirDragArea.ToGUIFormat() - cbPTOType.SelectedValue = veh.PTOType - tbPTOLossMap.Text = veh.PTOLossMap.OriginalPath - tbPTOCycle.Text = veh.PTOCycle.OriginalPath + cbPTOType.SelectedValue = pto.PTOTransmissionType + tbPTOLossMap.Text = If(pto.PTOLossMap Is Nothing, "", GetRelativePath(pto.PTOLossMap.Source, basePath)) + tbPTOCycle.Text = If(pto.PTOCycle Is Nothing, "", GetRelativePath(pto.PTOCycle.Source, basePath)) DeclInit() @@ -405,56 +402,71 @@ Public Class VehicleForm _changed = False End Sub + Private Function CreateListViewItem(axleNumber As Integer, share As Double, twinTire As Boolean, rrc As Double, + fzIso As Double, wheels As String, inertia As Double) As ListViewItem + Dim retVal As New ListViewItem + retVal.SubItems(0).Text = axleNumber.ToGUIFormat() + FillDoubleValue(retVal, share, "-") + retVal.SubItems.Add(If(twinTire, "yes", "no")) + FillDoubleValue(retVal, rrc) + FillDoubleValue(retVal, fzIso) + retVal.SubItems.Add(wheels) + FillDoubleValue(retVal, inertia) + Return retVal + End Function + + Private Sub FillDoubleValue(listViewItem As ListViewItem, share As Double, Optional defaultValue As String = "") + + If Double.IsNaN(share) Then + listViewItem.SubItems.Add(defaultValue) + Else + listViewItem.SubItems.Add(share.ToGUIFormat()) + End If + End Sub + 'Save VEH Private Function SaveVehicle(file As String) As Boolean - Dim veh = New Vehicle + Dim veh As Vehicle = New Vehicle veh.FilePath = file - veh.Mass = CSng(fTextboxToNumString(TbMass.Text)) - veh.MassExtra = CSng(fTextboxToNumString(TbMassExtra.Text)) - veh.Loading = CSng(fTextboxToNumString(TbLoad.Text)) + veh.Mass = TbMass.Text.ToDouble(0) + veh.MassExtra = TbMassExtra.Text.ToDouble(0) + veh.Loading = TbLoad.Text.ToDouble(0) - veh.CdA0 = CSng(fTextboxToNumString(TBcdA.Text)) + veh.CdA0 = TBcdA.Text.ToDouble(0) - veh.DynamicTyreRadius = CSng(fTextboxToNumString(TBrdyn.Text)) - veh.CrossWindCorrectionMode = CbCdMode.SelectedValue + veh.DynamicTyreRadius = TBrdyn.Text.ToDouble(0) + veh.CrossWindCorrectionMode = CType(CbCdMode.SelectedValue, CrossWindCorrectionMode) veh.CrossWindCorrectionFile.Init(GetPath(file), TbCdFile.Text) - veh.RetarderType = CbRtType.SelectedValue - veh.RetarderRatio = CSng(fTextboxToNumString(TbRtRatio.Text)) + veh.RetarderType = CType(CbRtType.SelectedValue, RetarderType) + veh.RetarderRatio = TbRtRatio.Text.ToDouble(0) veh.RetarderLossMapFile.Init(GetPath(file), TbRtPath.Text) - veh.AngularGearType = cbAngularGearType.SelectedValue - veh.AngularGearRatio = CSng(fTextboxToNumString(tbAngularGearRatio.Text)) + veh.AngularGearType = CType(cbAngularGearType.SelectedValue, AngularGearType) + veh.AngularGearRatio = tbAngularGearRatio.Text.ToDouble(0) veh.AngularGearLossMapFile.Init(GetPath(file), tbAngularGearLossMapPath.Text) - veh.VehicleCategory = CbCat.SelectedValue 'CType(CbCat.SelectedIndex, tVehCat) - - Dim axleShareCheck As Double - For Each LV0 In LvRRC.Items - Dim a0 = New Vehicle.Axle - a0.Share = fTextboxToNumString(LV0.SubItems(1).Text) - axleShareCheck += a0.Share - a0.TwinTire = (LV0.SubItems(2).Text = "yes") - a0.RRC = fTextboxToNumString(LV0.SubItems(3).Text) - a0.FzISO = fTextboxToNumString(LV0.SubItems(4).Text) - a0.Wheels = LV0.SubItems(5).Text - a0.Inertia = fTextboxToNumString(LV0.SubItems(6).Text) + veh.VehicleCategory = CType(CbCat.SelectedValue, VehicleCategory) 'CType(CbCat.SelectedIndex, tVehCat) + + For Each entry As ListViewItem In LvRRC.Items + Dim a0 As Vehicle.Axle = New Vehicle.Axle + a0.Share = entry.SubItems(AxleTbl.RelativeLoad).Text.ToDouble(0) + a0.TwinTire = (entry.SubItems(AxleTbl.TwinTyres).Text = "yes") + a0.RRC = entry.SubItems(AxleTbl.RRC).Text.ToDouble(0) + a0.FzISO = entry.SubItems(AxleTbl.FzISO).Text.ToDouble(0) + a0.Wheels = entry.SubItems(AxleTbl.WheelsDimension).Text + a0.Inertia = entry.SubItems(AxleTbl.Inertia).Text.ToDouble(0) veh.Axles.Add(a0) Next - veh.PTOType = cbPTOType.SelectedValue - veh.PTOLossMap.Init(GetPath(file), tbPTOLossMap.Text) - veh.PTOCycle.Init(GetPath(file), tbPTOCycle.Text) - - 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 + veh.PtoType = CType(cbPTOType.SelectedValue, String) + veh.PtoLossMap.Init(GetPath(file), tbPTOLossMap.Text) + veh.PtoCycle.Init(GetPath(file), tbPTOCycle.Text) - veh.MassMax = CSng(fTextboxToNumString(TbMassMass.Text)) - veh.MassExtra = CSng(fTextboxToNumString(TbMassExtra.Text)) - veh.AxleConfiguration = CbAxleConfig.SelectedValue + veh.MassMax = TbMassMass.Text.ToDouble(0) + veh.MassExtra = TbMassExtra.Text.ToDouble(0) + veh.AxleConfiguration = CType(CbAxleConfig.SelectedValue, AxleConfiguration) '--------------------------------------------------------------------------------- @@ -465,7 +477,7 @@ Public Class VehicleForm If AutoSendTo Then If VectoJobForm.Visible Then - If UCase(fFileRepl(VectoJobForm.TbVEH.Text, JobDir)) <> UCase(file) Then _ + If UCase(FileRepl(VectoJobForm.TbVEH.Text, JobDir)) <> UCase(file) Then _ VectoJobForm.TbVEH.Text = GetFilenameWithoutDirectory(file, JobDir) VectoJobForm.UpdatePic() End If @@ -523,13 +535,13 @@ Public Class VehicleForm ex = "vcdb" End If - If fbCDx.OpenDialog(fFileRepl(TbCdFile.Text, GetPath(_vehFile)), False, ex) Then _ - TbCdFile.Text = GetFilenameWithoutDirectory(fbCDx.Files(0), GetPath(_vehFile)) + If CrossWindCorrectionFileBrowser.OpenDialog(FileRepl(TbCdFile.Text, GetPath(_vehFile)), False, ex) Then _ + TbCdFile.Text = GetFilenameWithoutDirectory(CrossWindCorrectionFileBrowser.Files(0), GetPath(_vehFile)) End Sub 'Open Cd File Private Sub BtCdFileOpen_Click(sender As Object, e As EventArgs) Handles BtCdFileOpen.Click - OpenFiles(fFileRepl(TbCdFile.Text, GetPath(_vehFile))) + OpenFiles(FileRepl(TbCdFile.Text, GetPath(_vehFile))) End Sub #End Region @@ -558,7 +570,7 @@ Public Class VehicleForm 'Rt File Browse Private Sub BtRtBrowse_Click(sender As Object, e As EventArgs) Handles BtRtBrowse.Click - If RetarderLossMapFileBrowser.OpenDialog(fFileRepl(TbRtPath.Text, GetPath(_vehFile))) Then _ + If RetarderLossMapFileBrowser.OpenDialog(FileRepl(TbRtPath.Text, GetPath(_vehFile))) Then _ TbRtPath.Text = GetFilenameWithoutDirectory(RetarderLossMapFileBrowser.Files(0), GetPath(_vehFile)) End Sub @@ -647,27 +659,11 @@ Public Class VehicleForm #Region "Axle Configuration" Private Sub ButAxlAdd_Click(sender As Object, e As EventArgs) Handles ButAxlAdd.Click - Dim lv0 As ListViewItem - _axlDlog.Clear() - If _axlDlog.ShowDialog = DialogResult.OK Then - lv0 = New ListViewItem - - lv0.SubItems(0).Text = LvRRC.Items.Count + 1 - lv0.SubItems.Add(Trim(_axlDlog.TbAxleShare.Text)) - If _axlDlog.CbTwinT.Checked Then - lv0.SubItems.Add("yes") - Else - lv0.SubItems.Add("no") - End If - lv0.SubItems.Add(Trim(_axlDlog.TbRRC.Text)) - lv0.SubItems.Add(Trim(_axlDlog.TbFzISO.Text)) - lv0.SubItems.Add(Trim(_axlDlog.CbWheels.Text)) - lv0.SubItems.Add(Trim(_axlDlog.TbI_wheels.Text)) - - LvRRC.Items.Add(lv0) - + LvRRC.Items.Add(CreateListViewItem(LvRRC.Items.Count + 1, _axlDlog.TbAxleShare.Text.ToDouble(0), + _axlDlog.CbTwinT.Checked, _axlDlog.TbRRC.Text.ToDouble(0), _axlDlog.TbFzISO.Text.ToDouble(0), + _axlDlog.CbWheels.Text, _axlDlog.TbI_wheels.Text.ToDouble(0))) Change() DeclInit() @@ -710,7 +706,7 @@ Public Class VehicleForm i = 0 For Each lv0 In LvRRC.Items i += 1 - lv0.SubItems(0).Text = i.ToString + lv0.SubItems(AxleTbl.AxleNumber).Text = i.ToString Next LvRRC.Items(LvRRC.Items.Count - 1).Selected = True @@ -723,26 +719,26 @@ Public Class VehicleForm Private Sub EditAxleItem() If LvRRC.SelectedItems.Count = 0 Then Exit Sub - Dim lv0 = LvRRC.SelectedItems(0) + Dim lv0 As ListViewItem = 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(AxleTbl.RelativeLoad).Text + _axlDlog.CbTwinT.Checked = (lv0.SubItems(AxleTbl.TwinTyres).Text = "yes") + _axlDlog.TbRRC.Text = lv0.SubItems(AxleTbl.RRC).Text + _axlDlog.TbFzISO.Text = lv0.SubItems(AxleTbl.FzISO).Text + _axlDlog.TbI_wheels.Text = lv0.SubItems(AxleTbl.Inertia).Text + _axlDlog.CbWheels.Text = lv0.SubItems(AxleTbl.WheelsDimension).Text If _axlDlog.ShowDialog = DialogResult.OK Then - lv0.SubItems(1).Text = _axlDlog.TbAxleShare.Text + lv0.SubItems(AxleTbl.RelativeLoad).Text = _axlDlog.TbAxleShare.Text If _axlDlog.CbTwinT.Checked Then - lv0.SubItems(2).Text = "yes" + lv0.SubItems(AxleTbl.TwinTyres).Text = "yes" Else - lv0.SubItems(2).Text = "no" + lv0.SubItems(AxleTbl.TwinTyres).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(AxleTbl.RRC).Text = _axlDlog.TbRRC.Text + lv0.SubItems(AxleTbl.FzISO).Text = _axlDlog.TbFzISO.Text + lv0.SubItems(AxleTbl.WheelsDimension).Text = _axlDlog.CbWheels.Text + lv0.SubItems(AxleTbl.Inertia).Text = _axlDlog.TbI_wheels.Text Change() DeclInit() @@ -800,7 +796,7 @@ Public Class VehicleForm End Sub Private Sub btAngularGearLossMapBrowse_Click(sender As Object, e As EventArgs) Handles btAngularGearLossMapBrowse.Click - If TransmissionLossMapFileBrowser.OpenDialog(fFileRepl(TbRtPath.Text, GetPath(_vehFile))) Then _ + If TransmissionLossMapFileBrowser.OpenDialog(FileRepl(TbRtPath.Text, GetPath(_vehFile))) Then _ tbAngularGearLossMapPath.Text = GetFilenameWithoutDirectory(TransmissionLossMapFileBrowser.Files(0), GetPath(_vehFile)) End Sub @@ -820,13 +816,13 @@ Public Class VehicleForm End Sub Private Sub btPTOLossMapBrowse_Click(sender As Object, e As EventArgs) Handles btPTOLossMapBrowse.Click - If fbPTOLM.OpenDialog(fFileRepl(tbPTOLossMap.Text, GetPath(_vehFile))) Then - tbPTOLossMap.Text = GetFilenameWithoutDirectory(fbPTOLM.Files(0), GetPath(_vehFile)) + If PtoLossMapFileBrowser.OpenDialog(FileRepl(tbPTOLossMap.Text, GetPath(_vehFile))) Then + tbPTOLossMap.Text = GetFilenameWithoutDirectory(PtoLossMapFileBrowser.Files(0), GetPath(_vehFile)) End If End Sub Private Sub btPTOCycle_Click(sender As Object, e As EventArgs) Handles btPTOCycle.Click - If DrivingCycleFileBrowser.OpenDialog(fFileRepl(tbPTOCycle.Text, GetPath(_vehFile))) Then + If DrivingCycleFileBrowser.OpenDialog(FileRepl(tbPTOCycle.Text, GetPath(_vehFile))) Then tbPTOCycle.Text = GetFilenameWithoutDirectory(DrivingCycleFileBrowser.Files(0), GetPath(_vehFile)) End If End Sub diff --git a/VECTO/Input Files/Engine.vb b/VECTO/Input Files/Engine.vb index 464e0898b92a8194920559f02a76c02da64ab756..68a7383b55da3e4374002c8b12ccb3d1c959b9e2 100644 --- a/VECTO/Input Files/Engine.vb +++ b/VECTO/Input Files/Engine.vb @@ -9,26 +9,33 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.ComponentModel.DataAnnotations Imports System.IO +Imports System.Linq +Imports Newtonsoft.Json.Linq Imports TUGraz.VECTO.Input_Files +Imports TUGraz.VectoCommon.Exceptions +Imports TUGraz.VectoCommon.InputData +Imports TUGraz.VectoCommon.Models +Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Utils ''' <summary> ''' Engine input file ''' </summary> ''' <remarks></remarks> +<CustomValidation(GetType(Engine), "ValidateEngine")> Public Class Engine + Implements IEngineEngineeringInputData, IEngineDeclarationInputData + ''' <summary> ''' Current format version ''' </summary> ''' <remarks></remarks> Private Const FormatVersion As Short = 3 - ''' <summary> - ''' Format version of input file. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Private _fileVersion As Short - ''' <summary> ''' Engine description (model, type, etc.). Saved in input file. ''' </summary> @@ -39,19 +46,19 @@ Public Class Engine ''' Engine displacement [ccm]. Saved in input file. ''' </summary> ''' <remarks></remarks> - Public Displacement As Single + Public Displacement As Double ''' <summary> ''' Idling speed [1/min]. Saved in input file. ''' </summary> ''' <remarks></remarks> - Public IdleSpeed As Single + Public IdleSpeed As Double ''' <summary> ''' Rotational inertia including flywheel [kgm²]. Saved in input file. Overwritten by generic value in Declaration mode. ''' </summary> ''' <remarks></remarks> - Public EngineInertia As Single + Public EngineInertia As Double ''' <summary> ''' List of full load/motoring curve files (.vfld) @@ -82,22 +89,24 @@ Public Class Engine ''' WHTC Urban test results. Saved in input file. ''' </summary> ''' <remarks></remarks> - Public WHTCurban As Single + Public WHTCUrbanInput As Double ''' <summary> ''' WHTC Rural test results. Saved in input file. ''' </summary> ''' <remarks></remarks> - Public WHTCrural As Single + Public WHTCRuralInput As Double ''' <summary> ''' WHTC Motorway test results. Saved in input file. ''' </summary> ''' <remarks></remarks> - Public WHTCmw As Single + Public WHTCMotorwayInput As Double + Public WHTCEngineeringInput As Double - Public SavedInDeclMode As Boolean + + Public ColdHotBalancingFactorInput As Double ''' <summary> @@ -126,11 +135,10 @@ Public Class Engine _fuelConsumptionMapPath.Clear() _fullLoadCurvePath.Clear() - WHTCurban = 0 - WHTCrural = 0 - WHTCmw = 0 - - SavedInDeclMode = False + WHTCUrbanInput = 0 + WHTCRuralInput = 0 + WHTCMotorwayInput = 0 + WHTCEngineeringInput = 1 End Sub ''' <summary> @@ -139,96 +147,50 @@ Public Class Engine ''' <returns>True if successful.</returns> ''' <remarks></remarks> Public Function SaveFile() As Boolean - Dim JSON As New JSONParser - Dim dic As Dictionary(Of String, Object) - - 'Header - dic = New Dictionary(Of String, Object) - dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") - dic.Add("Date", Now.ToUniversalTime().ToString("o")) - 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("ModelName", ModelName) - - dic.Add("Displacement", Displacement) - dic.Add("IdlingSpeed", IdleSpeed) - dic.Add("Inertia", EngineInertia) - - dic.Add("FullLoadCurve", _fullLoadCurvePath.PathOrDummy) - - dic.Add("FuelMap", _fuelConsumptionMapPath.PathOrDummy) - - dic.Add("WHTC-Urban", WHTCurban) - dic.Add("WHTC-Rural", WHTCrural) - dic.Add("WHTC-Motorway", WHTCmw) - - JSON.Content.Add("Body", dic) + Dim validationResults As IList(Of ValidationResult) = + Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If validationResults.Count > 0 Then + Dim messages As IEnumerable(Of String) = + validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + MsgBox("Invalid input." + Environment.NewLine + String.Join(Environment.NewLine, messages), MsgBoxStyle.OkOnly, + "Failed to save gearbox") + Return False + End If - Return JSON.WriteFile(_filePath) - End Function - - ''' <summary> - ''' Read file. <see cref="P:VECTO.cENG.FilePath" /> must be set before calling. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean - Dim MsgSrc As String - Dim JSON As New JSONParser - - MsgSrc = "ENG/ReadFile" - - SetDefault() + Dim json As New JSONWriter + 'Header + Dim header As Dictionary(Of String, Object) = New Dictionary(Of String, Object) + header.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + header.Add("Date", Now.ToUniversalTime().ToString("o")) + header.Add("AppVersion", VECTOvers) + header.Add("FileVersion", FormatVersion) - If Not JSON.ReadFile(_filePath) Then Return False + 'Body + Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) - Try + body.Add("SavedInDeclMode", Cfg.DeclMode) - _fileVersion = JSON.Content("Header")("FileVersion") + body.Add("ModelName", ModelName) - If _fileVersion > 1 Then - SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If + body.Add("Displacement", Displacement) + body.Add("IdlingSpeed", IdleSpeed) + body.Add("Inertia", EngineInertia) - ModelName = JSON.Content("Body")("ModelName") + body.Add("FullLoadCurve", _fullLoadCurvePath.PathOrDummy) - Displacement = JSON.Content("Body")("Displacement") - IdleSpeed = JSON.Content("Body")("IdlingSpeed") - EngineInertia = JSON.Content("Body")("Inertia") + body.Add("FuelMap", _fuelConsumptionMapPath.PathOrDummy) - If _fileVersion < 3 Then - _fullLoadCurvePath.Init(_myPath, JSON.Content("Body")("FullLoadCurves")(0)("Path")) - Else - _fullLoadCurvePath.Init(_myPath, JSON.Content("Body")("FullLoadCurve")) - End If + body.Add("WHTC-Urban", WHTCUrbanInput) + body.Add("WHTC-Rural", WHTCRuralInput) + body.Add("WHTC-Motorway", WHTCMotorwayInput) + body.Add("ColdHotBalancingFactor", ColdHotBalancingFactorInput) - _fuelConsumptionMapPath.Init(_myPath, JSON.Content("Body")("FuelMap")) + json.Content = JToken.FromObject(New Dictionary(Of String, Object) From {{"Header", header}, {"Body", body}}) - If _fileVersion > 2 AndAlso Not JSON.Content("Body")("WHTC-Urban") Is Nothing Then - WHTCurban = CSng(JSON.Content("Body")("WHTC-Urban")) - WHTCrural = CSng(JSON.Content("Body")("WHTC-Rural")) - WHTCmw = CSng(JSON.Content("Body")("WHTC-Motorway")) - End If - - Catch ex As Exception - If ShowMsg Then WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) - Return False - End Try - - Return True + Return json.WriteFile(_filePath) End Function @@ -253,9 +215,9 @@ Public Class Engine End Property - Public Property PathFLD(Optional ByVal Original As Boolean = False) As String + Public Property PathFld(Optional ByVal original As Boolean = False) As String Get - If Original Then + If original Then Return _fullLoadCurvePath.OriginalPath Else Return _fullLoadCurvePath.FullPath @@ -269,13 +231,13 @@ Public Class Engine ''' <summary> ''' Get or set file path (cSubPath) to FC map (.vmap) ''' </summary> - ''' <param name="Original">True= (relative) file path as saved in file; False= full file path</param> + ''' <param name="original">True= (relative) file path as saved in file; False= full file path</param> ''' <value></value> ''' <returns>Relative or absolute file path to FC map</returns> ''' <remarks></remarks> - Public Property PathMAP(Optional ByVal Original As Boolean = False) As String + Public Property PathMap(Optional ByVal original As Boolean = False) As String Get - If Original Then + If original Then Return _fuelConsumptionMapPath.OriginalPath Else Return _fuelConsumptionMapPath.FullPath @@ -285,4 +247,165 @@ Public Class Engine _fuelConsumptionMapPath.Init(_myPath, value) End Set End Property + + + ' ReSharper disable once UnusedMember.Global -- used for Validation + Public Shared Function ValidateEngine(engine As Engine, validationContext As ValidationContext) As ValidationResult + Dim engineData As CombustionEngineData + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + ExecutionModeServiceContainer) + Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) + + Try + If mode = ExecutionMode.Declaration Then + Dim doa As DeclarationDataAdapter = New DeclarationDataAdapter() + + engineData = doa.CreateEngineData(engine, GearboxType.AMT) + Else + Dim doa As EngineeringDataAdapter = New EngineeringDataAdapter() + engineData = doa.CreateEngineData(engine, Nothing) + End If + + Dim result As IList(Of ValidationResult) = + engineData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + + If Not result.Any() Then Return ValidationResult.Success + + Return New ValidationResult("Engine Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + Catch ex As Exception + Return New ValidationResult(ex.Message) + End Try + End Function + +#Region "IInputData" + + Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Get + Return DataSourceType.JSONFile + End Get + End Property + + Public ReadOnly Property Source As String Implements IComponentInputData.Source + Get + Return FilePath + End Get + End Property + + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IComponentInputData.SavedInDeclarationMode + Get + Return Cfg.DeclMode + End Get + End Property + + Public ReadOnly Property Vendor As String Implements IComponentInputData.Vendor + Get + Return "N.A." ' TODO: MQ 20160919 + End Get + End Property + + Public ReadOnly Property Creator As String Implements IComponentInputData.Creator + Get + Return Lic.LicString + End Get + End Property + + Public ReadOnly Property [Date] As String Implements IComponentInputData.[Date] + Get + Return Now.ToUniversalTime().ToString("o") + End Get + End Property + + Public ReadOnly Property TypeId As String Implements IComponentInputData.TypeId + Get + Return "N.A." ' Todo: MQ 20160919 + End Get + End Property + + Public ReadOnly Property DigestValue As String Implements IComponentInputData.DigestValue + Get + Return "" + End Get + End Property + + Public ReadOnly Property IntegrityStatus As IntegrityStatus Implements IComponentInputData.IntegrityStatus + Get + Return IntegrityStatus.NotChecked + End Get + End Property + + Public ReadOnly Property IComponentInputData_ModelName As String Implements IComponentInputData.ModelName + Get + Return ModelName + End Get + End Property + + Public ReadOnly Property IEngineDeclarationInputData_Displacement As CubicMeter _ + Implements IEngineDeclarationInputData.Displacement + Get + Return (Displacement / 1000.0 / 1000.0).SI(Of CubicMeter)() + End Get + End Property + + Public ReadOnly Property IEngineDeclarationInputData_IdleSpeed As PerSecond _ + Implements IEngineDeclarationInputData.IdleSpeed + Get + Return IdleSpeed.RPMtoRad() + End Get + End Property + + Public ReadOnly Property WHTCMotorway As Double Implements IEngineDeclarationInputData.WHTCMotorway + Get + Return WHTCMotorwayInput + End Get + End Property + + Public ReadOnly Property WHTCRural As Double Implements IEngineDeclarationInputData.WHTCRural + Get + Return WHTCRuralInput + End Get + End Property + + Public ReadOnly Property WHTCUrban As Double Implements IEngineDeclarationInputData.WHTCUrban + Get + Return WHTCUrbanInput + End Get + End Property + + Public ReadOnly Property ColdHotBalancingFactor As Double Implements IEngineDeclarationInputData.ColdHotBalancingFactor + Get + Return ColdHotBalancingFactorInput + End Get + End Property + + Public ReadOnly Property FuelConsumptionMap As TableData Implements IEngineDeclarationInputData.FuelConsumptionMap + Get + If Not File.Exists(_fuelConsumptionMapPath.FullPath) Then _ + Throw New VectoException("FuelConsumptionMap is missing or invalid") + Return VectoCSVFile.Read(_fuelConsumptionMapPath.FullPath) + End Get + End Property + + Public ReadOnly Property FullLoadCurve As TableData Implements IEngineDeclarationInputData.FullLoadCurve + Get + If Not File.Exists(_fullLoadCurvePath.FullPath) Then _ + Throw New VectoException("Full-Load Curve is missing or invalid") + Return VectoCSVFile.Read(_fullLoadCurvePath.FullPath) + End Get + End Property + + Public ReadOnly Property Inertia As KilogramSquareMeter Implements IEngineEngineeringInputData.Inertia + Get + Return EngineInertia.SI(Of KilogramSquareMeter)() + End Get + End Property + + Public ReadOnly Property WHTCEngineering As Double Implements IEngineEngineeringInputData.WHTCEngineering + Get + Return WHTCEngineeringInput + End Get + End Property + +#End Region End Class + + diff --git a/VECTO/Input Files/EngineFullLoadCurve.vb b/VECTO/Input Files/EngineFullLoadCurve.vb deleted file mode 100644 index da6b43cd41f7320d1fc80b310237d718ebd5157e..0000000000000000000000000000000000000000 --- a/VECTO/Input Files/EngineFullLoadCurve.vb +++ /dev/null @@ -1,341 +0,0 @@ -' Copyright 2014 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports System.Collections.Generic -Imports System.Linq - -''' <summary> -''' Full load/motoring curve input file -''' </summary> -''' <remarks></remarks> -Public Class EngineFullLoadCurve - ''' <summary> - ''' List of full load torque values [Nm] - ''' </summary> - ''' <remarks></remarks> - Public MaxTorqueList As List(Of Single) - - ''' <summary> - ''' List of motoring torque values [Nm] - ''' </summary> - ''' <remarks></remarks> - Public DragTorqueList As List(Of Single) - - ''' <summary> - ''' List of engine speed values [1/min] - ''' </summary> - ''' <remarks></remarks> - Public EngineSpeedList As List(Of Single) - - ''' <summary> - ''' List of PT1 values [s] - ''' </summary> - ''' <remarks></remarks> - Private _pt1List As List(Of Single) - - ''' <summary> - ''' Read file. FilePath must be set before calling. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function ReadFile(tqOnly As Boolean, Optional ByVal showMsg As Boolean = True) As Boolean - Dim pt1Set As Boolean - - Const msgSrc As String = "Main/ReadInp/FLD" - - 'Reset - MaxTorqueList = Nothing - DragTorqueList = Nothing - EngineSpeedList = Nothing - _pt1List = Nothing - Dim lineCount As Integer = -1 - - 'Stop if there's no file - If FilePath = "" OrElse Not IO.File.Exists(FilePath) Then - If showMsg Then WorkerMsg(MessageType.Err, "FLD file '" & FilePath & "' not found!", msgSrc) - Return False - End If - - 'Open file - Dim file As CsvFile = New CsvFile - If Not file.OpenRead(FilePath) Then - If showMsg Then WorkerMsg(MessageType.Err, "Failed to open file (" & FilePath & ") !", msgSrc) - - Return False - End If - - 'Skip Header - file.ReadLine() - - 'Initialize Lists - MaxTorqueList = New List(Of Single) - DragTorqueList = New List(Of Single) - EngineSpeedList = New List(Of Single) - _pt1List = New List(Of Single) - - Dim firstLine As Boolean = True - Try - - Do While Not file.EndOfFile - - 'Read Line - Dim line As String() = file.ReadLine - - 'VECTO: M => Pe - Dim rpm As Double = CDbl(line(0)) - - EngineSpeedList.Add(rpm) - MaxTorqueList.Add(CDbl(line(1))) - - If tqOnly Then - DragTorqueList.Add(0) - Else - DragTorqueList.Add(CDbl(line(2))) - End If - - If firstLine Then - pt1Set = (Not tqOnly) AndAlso (UBound(line) > 2) - firstLine = False - End If - - 'If PT1 not defined, use default value (0) - If pt1Set Then - _pt1List.Add(CSng(line(3))) - Else - _pt1List.Add(0) - End If - - 'Line-counter up (was reset in ResetMe) - lineCount += 1 - - - Loop - - Catch ex As Exception - - If showMsg Then _ - WorkerMsg(MessageType.Err, "Error during file read! Line number: " & lineCount + 1 & " (" & FilePath & ")", msgSrc, - FilePath) - GoTo lbEr - - End Try - - - 'Close file - file.Close() - - Return True - - - 'ERROR-label for clean Abort -lbEr: - file.Close() - - - Return False - End Function - - ''' <summary> - ''' Returns stationary full load power [kW] at given engine speed. - ''' </summary> - ''' <param name="nU">engine speed [1/min]</param> - ''' <returns>stationary full load power [kW]</returns> - ''' <remarks></remarks> - Public Function Pfull(nU As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If EngineSpeedList(0) >= nU Then - 'If LnU(0) > nU Then MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While EngineSpeedList(i) < nU And i < EngineSpeedList.Count - 1 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If EngineSpeedList(i) < nU Then - 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If - -lbInt: - 'Interpolation - Return _ - nMtoPe(nU, - (nU - EngineSpeedList(i - 1)) * (MaxTorqueList(i) - MaxTorqueList(i - 1)) / - (EngineSpeedList(i) - EngineSpeedList(i - 1)) + MaxTorqueList(i - 1)) - End Function - - ''' <summary> - ''' Returns stationary full load torque [Nm] at given engine speed. - ''' </summary> - ''' <param name="nU">engine speed [1/min]</param> - ''' <returns>stationary full load torque [Nm]</returns> - ''' <remarks></remarks> - Private Function Torque(ByVal nU As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If EngineSpeedList(0) >= nU Then - 'If LnU(0) > nU Then MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While EngineSpeedList(i) < nU And i < EngineSpeedList.Count - 1 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If EngineSpeedList(i) < nU Then - 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If - -lbInt: - 'Interpolation - Return _ - (nU - EngineSpeedList(i - 1)) * (MaxTorqueList(i) - MaxTorqueList(i - 1)) / (EngineSpeedList(i) - EngineSpeedList(i - 1)) + - MaxTorqueList(i - 1) - End Function - - ' ''' <summary> - ' ''' Calculates and returns Npref [1/min]. Speed at 51% torque/speed-integral between idling and N95h. Defined in Init. - ' ''' </summary> - ' ''' <returns>Npref [1/min]</returns> - ' ''' <remarks></remarks> - ' Public Function fNpref(ByVal Nidle As Single) As Single - ' Dim i As Integer - ' Dim Amax As Single - ' Dim N95h As Single - ' Dim n As Single - ' Dim T0 As Single - ' Dim dn As Single - ' Dim A As Single - ' Dim k As Single - ' - ' - ' dn = 0.001 - ' - ' N95h = fnUofPfull(0.95 * Pfull(fnUrated), False) - ' - ' If N95h < 0 Then Return -1 - ' - ' Amax = Area(Nidle, N95h) - ' - ' For i = 0 To iDim - 1 - ' - ' If Area(Nidle, LnU(i + 1)) > 0.51 * Amax Then - ' - ' n = LnU(i) - ' T0 = LTq(i) - ' A = Area(Nidle, n) - ' - ' k = (LTq(i + 1) - LTq(i)) / (LnU(i + 1) - LnU(i)) - ' - ' Do While A < 0.51 * Amax - ' n += dn - ' A += dn * (2 * T0 + k * dn) / 2 - ' Loop - ' - ' Exit For - ' - ' End If - ' - ' Next - ' - ' Return n - ' End Function - - ' ''' <summary> - ' ''' Calculates torque/speed-integral between two engine speed limits. Used for Npref. - ' ''' </summary> - ' ''' <param name="nFrom">lower engine speed limit [1/min]</param> - ' ''' <param name="nTo">upper engine speed limit [1/min]</param> - ' ''' <returns>torque/speed-integral between nFrom and nTo [Nm/min]</returns> - ' ''' <remarks></remarks> - ' Private Function Area(ByVal nFrom As Single, ByVal nTo As Single) As Single - ' Dim A As Single - ' Dim i As Integer - ' - ' - ' A = 0 - ' For i = 1 To iDim - ' - ' If LnU(i - 1) >= nTo Then Exit For - ' - ' If LnU(i - 1) >= nFrom Then - ' - ' - ' If LnU(i) <= nTo Then - ' - ' 'Add full segment - ' A += (LnU(i) - LnU(i - 1)) * (LTq(i) + LTq(i - 1)) / 2 - ' - ' Else - ' - ' 'Add segment till nTo - ' A += (nTo - LnU(i - 1)) * (Tq(nTo) + LTq(i - 1)) / 2 - ' - ' End If - ' - ' Else - ' - ' If LnU(i) > nFrom Then - ' - ' 'Add segment starting from nFrom - ' A += (LnU(i) - nFrom) * (LTq(i) + Tq(nFrom)) / 2 - ' - ' End If - ' - ' End If - ' - ' Next - ' - ' Return A - ' End Function - - ''' <summary> - ''' Calculates and returns engine speed at maximum power [1/min]. - ''' </summary> - ''' <returns>engine speed at maximum power [1/min]</returns> - ''' <remarks></remarks> - Public Function EngineRatedSpeed() As Single - - Dim stepSize As Single = 1 - Dim maxPower As Single = 0 - Dim rpm As Single = EngineSpeedList(0) - Dim maxSpeed As Single = EngineSpeedList.Last() - Dim ratedSpeed As Single = rpm - - Do - Dim power As Single = nMtoPe(rpm, Torque(rpm)) - If power > maxPower Then - maxPower = power - ratedSpeed = rpm - End If - rpm += stepSize - Loop Until rpm > maxSpeed - - Return ratedSpeed - End Function - - - ''' <summary> - ''' Get or set Filepath before calling ReadFile - ''' </summary> - ''' <value></value> - ''' <returns>Full filepath</returns> - ''' <remarks></remarks> - Public Property FilePath As String -End Class diff --git a/VECTO/Input Files/FuelconsumptionMap.vb b/VECTO/Input Files/FuelconsumptionMap.vb deleted file mode 100644 index 2989b09df620a031459389f872ff907ebd0ff371..0000000000000000000000000000000000000000 --- a/VECTO/Input Files/FuelconsumptionMap.vb +++ /dev/null @@ -1,139 +0,0 @@ -' Copyright 2014 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports System.Collections.Generic - -Public Class FuelconsumptionMap - 'Implements IFuelConsumptionMap - - Private _angularSpeedList As List(Of Single) - Private _torqueList As List(Of Single) - Private _fuelconsumptionList As List(Of Single) - - Private _filePath As String - - Private Sub ResetMe() - _fuelconsumptionList = Nothing - _torqueList = Nothing - _angularSpeedList = Nothing - End Sub - - Public Function ReadFile(Optional ByVal showMsg As Boolean = True) As Boolean - - Const msgSrc As String = "Main/ReadInp/MAP" - - 'Reset - ResetMe() - - 'Stop if there's no file - If _filePath = "" OrElse Not IO.File.Exists(_filePath) Then - If showMsg Then WorkerMsg(MessageType.Err, "Map file not found! (" & _filePath & ")", msgSrc) - Return False - End If - - 'Open file - Dim file As CsvFile = New CsvFile - If Not file.OpenRead(_filePath) Then - - If showMsg Then WorkerMsg(MessageType.Err, "Failed to open file (" & _filePath & ") !", msgSrc) - Return False - End If - - 'Skip Header - file.ReadLine() - - 'Initi Lists (before version check so ReadOldFormat works) - _fuelconsumptionList = New List(Of Single) - _torqueList = New List(Of Single) - _angularSpeedList = New List(Of Single) - - Dim lineCount As Integer = -1 - - Try - Do While Not file.EndOfFile - - 'Line read - Dim line As String() = file.ReadLine - - 'Line counter up (was reset in ResetMe) - lineCount += 1 - - 'Revolutions - Dim rpm As Double = CDbl(line(0)) - - _angularSpeedList.Add(rpm) - - 'Power - _torqueList.Add(line(1)) - - 'FC - 'Check sign - If CSng(line(2)) < 0 Then - file.Close() - If showMsg Then WorkerMsg(MessageType.Err, "FC < 0 in map at " & rpm & " [1/min], " & line(1) & " [Nm]", msgSrc) - Return False - End If - - _fuelconsumptionList.Add(CSng(line(2))) - - - Loop - Catch ex As Exception - - If showMsg Then _ - WorkerMsg(MessageType.Err, "Error during file read! Line number " & lineCount + 1 & " (" & _filePath & ")", msgSrc, - _filePath) - GoTo lbEr - - End Try - - 'Close file - file.Close() - - - Return True - - - 'ERROR-label for clean Abort -lbEr: - file.Close() - - - Return False - End Function - - -#Region "Properties" - - Public Property FilePath() As String - Get - Return _filePath - End Get - Set(ByVal value As String) - _filePath = value - End Set - End Property - - Public ReadOnly Property Tq As List(Of Single) - Get - Return _torqueList - End Get - End Property - - Public ReadOnly Property nU As List(Of Single) - Get - Return _angularSpeedList - End Get - End Property - -#End Region -End Class - - diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index bb60b420ba222a0e3eb19bb5c236f4559c5e57c5..6f5deab06803de468c26d83e0cd895dc2de554f4 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -9,23 +9,38 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.ComponentModel.DataAnnotations Imports System.IO +Imports System.Linq +Imports System.Runtime.CompilerServices +Imports Newtonsoft.Json.Linq Imports TUGraz.VECTO.Input_Files +Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils - +Imports TUGraz.VectoCore.InputData.FileIO.JSON +Imports TUGraz.VectoCore.InputData.Impl +Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine +Imports TUGraz.VectoCore.Utils + +<CustomValidation(GetType(Gearbox), "ValidateGearbox")> Public Class Gearbox + Implements IGearboxEngineeringInputData, IGearboxDeclarationInputData, IAxleGearInputData, + ITorqueConverterEngineeringInputData, + ITorqueConverterDeclarationInputData + Private Const FormatVersion As Short = 6 - Private _fileVersion As Short Private _myPath As String Private _filePath As String Public ModelName As String - Public GbxInertia As Single - Public TracIntrSi As Single + Public GbxInertia As Double + Public TracIntrSi As Double - Public GearRatios As List(Of Single) + Public GearRatios As List(Of Double) Public GearLossmaps As List(Of SubPath) 'Gear shift polygons @@ -33,28 +48,27 @@ Public Class Gearbox Public MaxTorque As List(Of String) - Public TorqueResv As Single + Public TorqueResv As Double Public SkipGears As Boolean - Public ShiftTime As Integer - Public TorqueResvStart As Single - Public StartSpeed As Single - Public StartAcc As Single + Public ShiftTime As Double + Public TorqueResvStart As Double + Public StartSpeed As Double + Public StartAcc As Double Public ShiftInside As Boolean Public Type As GearboxType 'Torque Converter Input Public TorqueConverterEnabled As Boolean - Public TorqueConverterReferenceRpm As Single + Public TorqueConverterReferenceRpm As Double Private ReadOnly _torqueConverterFile As New SubPath - Public TorqueConverterInertia As Single + Public TorqueConverterInertia As Double Public TorqueConverterShiftPolygonFile As String - Public SavedInDeclMode As Boolean - Public UpshiftMinAcceleration As Single - Public DownshiftAfterUpshift As Single - Public UpshiftAfterDownshift As Single + Public UpshiftMinAcceleration As Double + Public DownshiftAfterUpshift As Double + Public UpshiftAfterDownshift As Double Public Sub New() @@ -69,7 +83,7 @@ Public Class Gearbox GbxInertia = 0 TracIntrSi = 0 - GearRatios = New List(Of Single) + GearRatios = New List(Of Double) GearLossmaps = New List(Of SubPath) GearshiftFiles = New List(Of SubPath) MaxTorque = New List(Of String) @@ -89,35 +103,43 @@ Public Class Gearbox _torqueConverterFile.Clear() TorqueConverterInertia = 0 - - SavedInDeclMode = False End Sub Public Function SaveFile() As Boolean + + Dim validationResults As IList(Of ValidationResult) = + Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + + If validationResults.Count > 0 Then + Dim messages As IEnumerable(Of String) = + validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + MsgBox("Invalid input." + Environment.NewLine + String.Join("; ", messages), MsgBoxStyle.OkOnly, + "Failed to save gearbox") + Return False + End If + Dim i As Integer - Dim writer As New JSONParser - Dim content As Dictionary(Of String, Object) + Dim json As New JSONWriter 'Header - content = New Dictionary(Of String, Object) - content.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") - content.Add("Date", Now.ToUniversalTime().ToString("o")) - content.Add("AppVersion", VECTOvers) - content.Add("FileVersion", FormatVersion) - writer.Content.Add("Header", content) + Dim header As Dictionary(Of String, Object) = New Dictionary(Of String, Object) + header.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + header.Add("Date", Now.ToUniversalTime().ToString("o")) + header.Add("AppVersion", VECTOvers) + header.Add("FileVersion", FormatVersion) + 'Body - content = New Dictionary(Of String, Object) + Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) - content.Add("SavedInDeclMode", Cfg.DeclMode) - SavedInDeclMode = Cfg.DeclMode + body.Add("SavedInDeclMode", Cfg.DeclMode) - content.Add("ModelName", ModelName) + body.Add("ModelName", ModelName) - content.Add("Inertia", GbxInertia) - content.Add("TracInt", TracIntrSi) + body.Add("Inertia", GbxInertia) + body.Add("TracInt", TracIntrSi) - Dim ls As New List(Of Object) + Dim ls As New List(Of Dictionary(Of String, Object)) For i = 0 To GearRatios.Count - 1 Dim gearDict As New Dictionary(Of String, Object) gearDict.Add("Ratio", GearRatios(i)) @@ -133,18 +155,18 @@ Public Class Gearbox ls.Add(gearDict) Next - content.Add("Gears", ls) + body.Add("Gears", ls) - content.Add("TqReserve", TorqueResv) - content.Add("SkipGears", SkipGears) - content.Add("ShiftTime", ShiftTime) - content.Add("EaryShiftUp", ShiftInside) + body.Add("TqReserve", TorqueResv) + body.Add("SkipGears", SkipGears) + body.Add("ShiftTime", ShiftTime) + body.Add("EaryShiftUp", ShiftInside) - content.Add("StartTqReserve", TorqueResvStart) - content.Add("StartSpeed", StartSpeed) - content.Add("StartAcc", StartAcc) + body.Add("StartTqReserve", TorqueResvStart) + body.Add("StartSpeed", StartSpeed) + body.Add("StartAcc", StartAcc) - content.Add("GearboxType", Type) + body.Add("GearboxType", Type) Dim torqueConverterDict As New Dictionary(Of String, Object) torqueConverterDict.Add("Enabled", TorqueConverterEnabled) @@ -152,123 +174,16 @@ Public Class Gearbox torqueConverterDict.Add("RefRPM", TorqueConverterReferenceRpm) torqueConverterDict.Add("Inertia", TorqueConverterInertia) torqueConverterDict.Add("ShiftPolygon", TorqueConverterShiftPolygonFile) - content.Add("TorqueConverter", torqueConverterDict) - - - content.Add("DownshiftAferUpshiftDelay", DownshiftAfterUpshift) - content.Add("UpshiftAfterDownshiftDelay", UpshiftAfterDownshift) - content.Add("UpshiftMinAcceleration", UpshiftMinAcceleration) - - writer.Content.Add("Body", content) - - Return writer.WriteFile(_filePath) - End Function - - Public Function ReadFile(Optional ByVal showMsg As Boolean = True) As Boolean - Dim i As Integer - Dim parser As New JSONParser - Dim dic As Object - - Const msgSrc As String = "GBX/ReadFile" - - SetDefault() - - If Not parser.ReadFile(_filePath) Then Return False - - Try - - _fileVersion = parser.Content("Header")("FileVersion") - - If _fileVersion > 3 Then - SavedInDeclMode = parser.Content("Body")("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If - - ModelName = parser.Content("Body")("ModelName") - GbxInertia = parser.Content("Body")("Inertia") - TracIntrSi = parser.Content("Body")("TracInt") - - i = -1 - For Each dic In parser.Content("Body")("Gears") - i += 1 + body.Add("TorqueConverter", torqueConverterDict) - GearRatios.Add(dic("Ratio")) - GearLossmaps.Add(New SubPath) - - If dic("Efficiency") Is Nothing Then - GearLossmaps(i).Init(_myPath, dic("LossMap")) - Else - GearLossmaps(i).Init(_myPath, dic("Efficiency")) - End If - - MaxTorque.Add(dic("MaxTorque")) - GearshiftFiles.Add(New SubPath) - - If i = 0 Then - GearshiftFiles(i).Init(_myPath, sKey.NoFile) - Else - If _fileVersion < 2 Then - GearshiftFiles(i).Init(_myPath, parser.Content("Body")("ShiftPolygons")) - Else - GearshiftFiles(i).Init(_myPath, dic("ShiftPolygon")) - End If - End If - - Next - - TorqueResv = parser.Content("Body")("TqReserve") - SkipGears = parser.Content("Body")("SkipGears") - ShiftTime = parser.Content("Body")("ShiftTime") - TorqueResvStart = parser.Content("Body")("StartTqReserve") - StartSpeed = parser.Content("Body")("StartSpeed") - StartAcc = parser.Content("Body")("StartAcc") - ShiftInside = parser.Content("Body")("EaryShiftUp") - - Type = parser.Content("Body")("GearboxType").ToString.ParseEnum(Of GearboxType)() - - If parser.Content("Body")("UpshiftMinAcceleration") Is Nothing Then - UpshiftMinAcceleration = 0.1 - Else - UpshiftMinAcceleration = parser.Content("Body")("UpshiftMinAcceleration") - End If - If parser.Content("Body")("DownshiftAferUpshiftDelay") Is Nothing Then - DownshiftAfterUpshift = 10 - Else - DownshiftAfterUpshift = parser.Content("Body")("DownshiftAferUpshiftDelay") - End If - - If parser.Content("Body")("UpshiftAfterDownshiftDelay") Is Nothing Then - UpshiftAfterDownshift = 10 - Else - UpshiftAfterDownshift = parser.Content("Body")("UpshiftAfterDownshiftDelay") - End If - - - If parser.Content("Body")("TorqueConverter") Is Nothing Then - TorqueConverterEnabled = False - Else - TorqueConverterEnabled = parser.Content("Body")("TorqueConverter")("Enabled") - _torqueConverterFile.Init(_myPath, parser.Content("Body")("TorqueConverter")("File")) - TorqueConverterReferenceRpm = parser.Content("Body")("TorqueConverter")("RefRPM") - If _fileVersion > 2 Then - TorqueConverterInertia = parser.Content("Body")("TorqueConverter")("Inertia") - End If - If _fileVersion > 5 Then - TorqueConverterShiftPolygonFile = parser.Content("Body")("TorqueConverter")("ShiftPolygon") - End If - End If - Catch ex As Exception - If showMsg Then WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, msgSrc) - Return False - End Try - Return True - End Function + body.Add("DownshiftAferUpshiftDelay", DownshiftAfterUpshift) + body.Add("UpshiftAfterDownshiftDelay", UpshiftAfterDownshift) + body.Add("UpshiftMinAcceleration", UpshiftMinAcceleration) + json.Content = JToken.FromObject(New Dictionary(Of String, Object) From {{"Header", header}, {"Body", body}}) - Public Function GearCount() As Integer - Return GearRatios.Count - 1 + Return json.WriteFile(_filePath) End Function @@ -286,9 +201,9 @@ Public Class Gearbox End Set End Property - Public Property GearLossMap(ByVal gearNr As Short, Optional ByVal original As Boolean = False) As String + Public Property GearLossMap(ByVal gearNr As Integer, Optional ByVal original As Boolean = False) As String Get - If Original Then + If original Then Return GearLossmaps(gearNr).OriginalPath Else Return GearLossmaps(gearNr).FullPath @@ -299,7 +214,7 @@ Public Class Gearbox End Set End Property - Public Property ShiftPolygonFile(ByVal gearNr As Short, Optional ByVal original As Boolean = False) As String + Public Property ShiftPolygonFile(ByVal gearNr As Integer, Optional ByVal original As Boolean = False) As String Get If original Then Return GearshiftFiles(gearNr).OriginalPath @@ -314,7 +229,7 @@ Public Class Gearbox Public Property TorqueConverterFile(Optional ByVal original As Boolean = False) As String Get - If Original Then + If original Then Return _torqueConverterFile.OriginalPath Else Return _torqueConverterFile.FullPath @@ -324,5 +239,307 @@ Public Class Gearbox _torqueConverterFile.Init(_myPath, value) End Set End Property + + + ' ReSharper disable once UnusedMember.Global -- used by Validation + Public Shared Function ValidateGearbox(gearbox As Gearbox, validationContext As ValidationContext) As ValidationResult + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + ExecutionModeServiceContainer) + Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) + + Dim axlegearData As AxleGearData + Dim gearboxData As GearboxData + + Try + 'Dim vectoJob As VectoJob = New VectoJob() With {.FilePath = VectoJobForm.VECTOfile} + Dim vectoFile As String = VectoJobForm.VectoFile + Dim inputData As IEngineeringInputDataProvider = + TryCast(JSONInputDataFactory.ReadComponentData(vectoFile), + IEngineeringInputDataProvider) + 'Dim vehicle As IVehicleEngineeringInputData = inputData.VehicleInputData + Dim engine As CombustionEngineData + Dim rdyn As Meter = 0.5.SI(Of Meter)() + If mode = ExecutionMode.Declaration Then + Dim doa As DeclarationDataAdapter = New DeclarationDataAdapter() + + Try + engine = doa.CreateEngineData(inputData.EngineInputData, gearbox.Type) + Catch + engine = GetDefaultEngine() + End Try + + axlegearData = doa.CreateAxleGearData(gearbox, False) + gearboxData = doa.CreateGearboxData(gearbox, engine, axlegearData.AxleGear.Ratio, rdyn, False) + Else + Dim doa As EngineeringDataAdapter = New EngineeringDataAdapter() + Try + engine = doa.CreateEngineData(inputData.EngineInputData, gearbox) + Catch + engine = GetDefaultEngine() + End Try + + axlegearData = doa.CreateAxleGearData(gearbox, True) + gearboxData = doa.CreateGearboxData(gearbox, engine, axlegearData.AxleGear.Ratio, rdyn, True) + End If + + Dim result As IList(Of ValidationResult) = + gearboxData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Gearbox Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + result = axlegearData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Axlegear Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + Return ValidationResult.Success + + Catch ex As Exception + Return New ValidationResult(ex.Message) + End Try + End Function + + Private Shared Function GetDefaultEngine() As CombustionEngineData + Dim fldData As MemoryStream = New MemoryStream() + Dim writer As StreamWriter = New StreamWriter(fldData) + writer.WriteLine("engine speed, full load torque, motoring torque") + writer.WriteLine(" 500, 2000, -500") + writer.WriteLine("2500, 2000, -500") + writer.Flush() + fldData.Seek(0, SeekOrigin.Begin) + + Dim fldCurve As EngineFullLoadCurve = EngineFullLoadCurve.Create(VectoCSVFile.ReadStream(fldData)) + Return New CombustionEngineData() With { + .IdleSpeed = 600.RPMtoRad(), + .FullLoadCurve = fldCurve + } + End Function + + + Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Get + Return DataSourceType.JSONFile + End Get + End Property + + Public ReadOnly Property Source As String Implements IComponentInputData.Source + Get + Return FilePath + End Get + End Property + + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IComponentInputData.SavedInDeclarationMode + Get + Return Cfg.DeclMode + End Get + End Property + + Public ReadOnly Property Vendor As String Implements IComponentInputData.Vendor + Get + Return "N.A." ' Todo MQ 20160915 + End Get + End Property + + Public ReadOnly Property Creator As String Implements IComponentInputData.Creator + Get + Return Lic.LicString + End Get + End Property + + Public ReadOnly Property [Date] As String Implements IComponentInputData.[Date] + Get + Return Now.ToUniversalTime().ToString("o") + End Get + End Property + + Public ReadOnly Property TypeId As String Implements IComponentInputData.TypeId + Get + Return "N.A." ' todo MQ 20160915 + End Get + End Property + + Public ReadOnly Property DigestValue As String Implements IComponentInputData.DigestValue + Get + Return "" + End Get + End Property + + Public ReadOnly Property IntegrityStatus As IntegrityStatus Implements IComponentInputData.IntegrityStatus + Get + Return IntegrityStatus.NotChecked + End Get + End Property + + Public ReadOnly Property IComponentInputData_ModelName As String Implements IComponentInputData.ModelName + Get + Return "N.A." ' todo MQ 20160915 + End Get + End Property + + Public ReadOnly Property IGearboxDeclarationInputData_Type As GearboxType Implements IGearboxDeclarationInputData.Type + Get + Return Type + End Get + End Property + + Public ReadOnly Property Gears As IList(Of ITransmissionInputData) Implements IGearboxDeclarationInputData.Gears + Get + Dim ls As IList(Of ITransmissionInputData) = New List(Of ITransmissionInputData) + Dim i As Integer + For i = 1 To GearRatios.Count - 1 + Dim gearDict As New TransmissionInputData With { + .Ratio = GearRatios(i) + } + If File.Exists(GearshiftFiles(i).OriginalPath) Then + gearDict.ShiftPolygon = VectoCSVFile.Read(GearshiftFiles(i).OriginalPath) + End If + If Not String.IsNullOrWhiteSpace(MaxTorque(i)) AndAlso IsNumeric(MaxTorque(i)) Then + gearDict.MaxTorque = MaxTorque(i).ToDouble().SI(Of NewtonMeter)() + End If + If IsNumeric(GearLossMap(i, True)) Then + gearDict.Efficiency = GearLossMap(i, True).ToDouble() + Else + gearDict.LossMap = VectoCSVFile.Read(GearLossmaps(i).PathOrDummy) + End If + + ls.Add(gearDict) + Next + Return ls + End Get + End Property + + Public ReadOnly Property ReferenceRPM As PerSecond Implements ITorqueConverterEngineeringInputData.ReferenceRPM + Get + Return TorqueConverterReferenceRpm.RPMtoRad() + End Get + End Property + + Public ReadOnly Property ITorqueConverterEngineeringInputData_Inertia As KilogramSquareMeter _ + Implements ITorqueConverterEngineeringInputData.Inertia + Get + Return TorqueConverterInertia.SI(Of KilogramSquareMeter)() + End Get + End Property + + Public ReadOnly Property Inertia As KilogramSquareMeter Implements IGearboxEngineeringInputData.Inertia + Get + Return GbxInertia.SI(Of KilogramSquareMeter)() + End Get + End Property + + Public ReadOnly Property ShiftPolygon As TableData Implements ITorqueConverterEngineeringInputData.ShiftPolygon + Get + Return VectoCSVFile.Read(TorqueConverterShiftPolygonFile) + End Get + End Property + + Public ReadOnly Property TractionInterruption As Second Implements IGearboxEngineeringInputData.TractionInterruption + Get + Return TracIntrSi.SI(Of Second)() + End Get + End Property + + Public ReadOnly Property EarlyShiftUp As Boolean Implements IGearboxEngineeringInputData.EarlyShiftUp + Get + Return ShiftInside + End Get + End Property + + Public ReadOnly Property TorqueReserve As Double Implements IGearboxEngineeringInputData.TorqueReserve + Get + Return TorqueResv + End Get + End Property + + Public ReadOnly Property StartAcceleration As MeterPerSquareSecond _ + Implements IGearboxEngineeringInputData.StartAcceleration + Get + Return StartAcc.SI(Of MeterPerSquareSecond)() + End Get + End Property + + Public ReadOnly Property StartTorqueReserve As Double Implements IGearboxEngineeringInputData.StartTorqueReserve + Get + Return TorqueResvStart + End Get + End Property + + Public ReadOnly Property TorqueConverter As ITorqueConverterEngineeringInputData _ + Implements IGearboxEngineeringInputData.TorqueConverter + Get + Return Me + End Get + End Property + + Public ReadOnly Property DownshiftAferUpshiftDelay As Second _ + Implements IGearboxEngineeringInputData.DownshiftAferUpshiftDelay + Get + Return DownshiftAfterUpshift.SI(Of Second)() + End Get + End Property + + Public ReadOnly Property UpshiftAfterDownshiftDelay As Second _ + Implements IGearboxEngineeringInputData.UpshiftAfterDownshiftDelay + Get + Return UpshiftAfterDownshift.SI(Of Second)() + End Get + End Property + + Public ReadOnly Property IGearboxEngineeringInputData_UpshiftMinAcceleration As MeterPerSquareSecond _ + Implements IGearboxEngineeringInputData.UpshiftMinAcceleration + Get + Return UpshiftMinAcceleration.SI(Of MeterPerSquareSecond)() + End Get + End Property + + Public ReadOnly Property IGearboxEngineeringInputData_SkipGears As Boolean _ + Implements IGearboxEngineeringInputData.SkipGears + Get + Return SkipGears + End Get + End Property + + Public ReadOnly Property IGearboxEngineeringInputData_StartSpeed As MeterPerSecond _ + Implements IGearboxEngineeringInputData.StartSpeed + Get + Return StartSpeed.SI(Of MeterPerSecond)() + End Get + End Property + + Public ReadOnly Property IGearboxEngineeringInputData_ShiftTime As Second _ + Implements IGearboxEngineeringInputData.ShiftTime + Get + Return ShiftTime.SI(Of Second)() + End Get + End Property + + Public ReadOnly Property TCData As TableData Implements ITorqueConverterDeclarationInputData.TCData + Get + Return VectoCSVFile.Read(_torqueConverterFile.OriginalPath) + End Get + End Property + + + Public ReadOnly Property Ratio As Double Implements IAxleGearInputData.Ratio + Get + Return GearRatios(0) + End Get + End Property + + Public ReadOnly Property LossMap As TableData Implements IAxleGearInputData.LossMap + Get + If Not File.Exists(GearLossmaps(0).FullPath) Then Return Nothing + Return VectoCSVFile.Read(GearLossmaps(0).FullPath) + End Get + End Property + + Public ReadOnly Property Efficiency As Double Implements IAxleGearInputData.Efficiency + Get + Return GearLossMap(0, True).ToDouble(0) + End Get + End Property End Class diff --git a/VECTO/Input Files/SubPath.vb b/VECTO/Input Files/SubPath.vb index 011151ed1664eb1de9d91eb406f55e209ead9d2c..24c7cdf0e801ff5535d65d78e789382ad2fa12c7 100644 --- a/VECTO/Input Files/SubPath.vb +++ b/VECTO/Input Files/SubPath.vb @@ -24,12 +24,12 @@ Namespace Input_Files Else _valid = True _originalPath = path - _fullPath = fFileRepl(path, parentDir) + _fullPath = FileRepl(path, parentDir) End If End Sub Private Function CheckFilenameGiven(f As String) As String - If Trim(UCase(f)) = sKey.NoFile Then + If Trim(UCase(f)) = NoFile Then Return "" Else Return f @@ -66,7 +66,7 @@ Namespace Input_Files If _valid Then Return _originalPath Else - Return sKey.NoFile + Return NoFile End If End Get End Property diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index d67674d414a9a33dda0ec4f4e5887c29f305e5e1..7eb0020e01eff8e2256136933653c9b2e72ec87a 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -8,16 +8,30 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. -Option Infer On -Option Explicit On +'Option Infer On +'Option Explicit On Imports System.Collections.Generic +Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq Imports Newtonsoft.Json.Linq Imports TUGraz.VECTO.Input_Files - +Imports TUGraz.VectoCommon.Exceptions +Imports TUGraz.VectoCommon.InputData +Imports TUGraz.VectoCommon.Models +Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.FileIO.JSON +Imports TUGraz.VectoCore.InputData.Impl +Imports TUGraz.VectoCore.InputData.Reader.Impl +Imports TUGraz.VectoCore.Models.Simulation.Data +Imports TUGraz.VectoCore.Utils + +<CustomValidation(GetType(VectoJob), "ValidateJob")> Public Class VectoJob + Implements IEngineeringInputDataProvider, IDeclarationInputDataProvider, IEngineeringJobInputData, + IDeclarationJobInputData, IDriverEngineeringInputData, IDriverDeclarationInputData + Private Const FormatVersion As Short = 3 'AA-TB @@ -35,9 +49,7 @@ Public Class VectoJob Private ReadOnly _gearboxFile As SubPath Private _startStop As Boolean - Private _startStopMaxSpeed As Single - Private _startStopMinTime As Single - Public StartStopDelay As Integer + Public StartStopDelay As Double Private ReadOnly _driverAccelerationFile As SubPath @@ -48,22 +60,31 @@ Public Class VectoJob Public EngineOnly As Boolean - Public VMin As Single + Public VMin As Double Public LookAheadOn As Boolean Public OverSpeedOn As Boolean - Public OverSpeed As Single - Public UnderSpeed As Single + Public OverSpeed As Double + Public UnderSpeed As Double Public EcoRollOn As Boolean Public SavedInDeclMode As Boolean + Private _vehicleInputData As JSONComponentInputData + Private _engineInputData As JSONComponentInputData + Private _gearboxInputData As JSONComponentInputData + Public LookAheadMinSpeed As Double + + Public Property StartStopMaxSpeed As Double + + Public Property StartStopTime As Double Public Class AuxEntry Public Type As String Public ReadOnly Path As SubPath - Public TechStr As String = "" + Public ReadOnly TechnologyList As List(Of String) Public Sub New() Path = New SubPath + TechnologyList = New List(Of String)() End Sub End Class @@ -84,54 +105,65 @@ Public Class VectoJob End Sub Public Function SaveFile() As Boolean - Dim json As New JSONParser + Dim json As New JSONWriter + + Dim validationResults As IList(Of ValidationResult) = + Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + + If validationResults.Count > 0 Then + Dim messages As IEnumerable(Of String) = + validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + MsgBox("Invalid input." + Environment.NewLine + String.Join(Environment.NewLine, messages), MsgBoxStyle.OkOnly, + "Failed to save Vecto Job") + Return False + End If 'Header - json.Content.Add("Header", New Dictionary(Of String, Object) From { - {"CreatedBy", Lic.LicString & " (" & Lic.GUID & ")"}, - {"Date", Now.ToUniversalTime().ToString("o")}, - {"AppVersion", VECTOvers}, - {"FileVersion", FormatVersion}}) + Dim header As Dictionary(Of String, Object) = New Dictionary(Of String, Object) From { + {"CreatedBy", Lic.LicString & " (" & Lic.GUID & ")"}, + {"Date", Now.ToUniversalTime().ToString("o")}, + {"AppVersion", VECTOvers}, + {"FileVersion", FormatVersion}} 'Body - Dim dic0 = New Dictionary(Of String, Object) + Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) - dic0.Add("SavedInDeclMode", Cfg.DeclMode) + body.Add("SavedInDeclMode", Cfg.DeclMode) SavedInDeclMode = Cfg.DeclMode 'Main Files - dic0.Add("VehicleFile", _vehicleFile.PathOrDummy) - dic0.Add("EngineFile", _engineFile.PathOrDummy) - dic0.Add("GearboxFile", _gearboxFile.PathOrDummy) + body.Add("VehicleFile", _vehicleFile.PathOrDummy) + body.Add("EngineFile", _engineFile.PathOrDummy) + body.Add("GearboxFile", _gearboxFile.PathOrDummy) 'Cycles If CycleFiles.Count > 0 Then - dic0.Add("Cycles", CycleFiles.Select(Function(sb) sb.PathOrDummy)) + body.Add("Cycles", CycleFiles.Select(Function(sb) sb.PathOrDummy)) End If 'AA-TB 'ADVANCED AUXILIARIES - dic0.Add("AuxiliaryAssembly", AuxiliaryAssembly) - dic0.Add("AuxiliaryVersion", AuxiliaryVersion) - dic0.Add("AdvancedAuxiliaryFilePath", AdvancedAuxiliaryFilePath) + body.Add("AuxiliaryAssembly", AuxiliaryAssembly) + body.Add("AuxiliaryVersion", AuxiliaryVersion) + body.Add("AdvancedAuxiliaryFilePath", AdvancedAuxiliaryFilePath) If AuxPaths.Any() Then - dic0.Add("Aux", AuxPaths.Select(Function(kv) New Dictionary(Of String, Object) From { + body.Add("Aux", AuxPaths.Select(Function(kv) New Dictionary(Of String, Object) From { {"ID", Trim(UCase(kv.Key))}, {"Type", kv.Value.Type}, {"Path", kv.Value.Path.PathOrDummy}, - {"Technology", IIf(kv.Value.TechStr = "", New List(Of String), New List(Of String) From {kv.Value.TechStr})} + {"Technology", kv.Value.TechnologyList} })) End If - dic0.Add("VACC", _driverAccelerationFile.PathOrDummy) - dic0.Add("EngineOnlyMode", EngineOnly) - dic0.Add("StartStop", New Dictionary(Of String, Object) From { + body.Add("VACC", _driverAccelerationFile.PathOrDummy) + body.Add("EngineOnlyMode", EngineOnly) + body.Add("StartStop", New Dictionary(Of String, Object) From { {"Enabled", _startStop}, - {"MaxSpeed", _startStopMaxSpeed}, - {"MinTime", _startStopMinTime}, + {"MaxSpeed", StartStopMaxSpeed}, + {"MinTime", StartStopTime}, {"Delay", StartStopDelay}}) - dic0.Add("LAC", New Dictionary(Of String, Object) From { + body.Add("LAC", New Dictionary(Of String, Object) From { {"Enabled", LookAheadOn}, {"PreviewDistanceFactor", LacPreviewFactor}, {"DF_offset", LacDfOffset}, @@ -140,7 +172,7 @@ Public Class VectoJob {"Df_velocityDropLookup", LacDfVelocityDropFile}}) 'Overspeed / EcoRoll - Dim overspeedDic = New Dictionary(Of String, Object) + Dim overspeedDic As Dictionary(Of String, Object) = New Dictionary(Of String, Object) If EcoRollOn Then overspeedDic.Add("Mode", "EcoRoll") ElseIf OverSpeedOn Then @@ -151,214 +183,221 @@ Public Class VectoJob overspeedDic.Add("MinSpeed", VMin) overspeedDic.Add("OverSpeed", OverSpeed) overspeedDic.Add("UnderSpeed", UnderSpeed) - dic0.Add("OverSpeedEcoRoll", overspeedDic) + body.Add("OverSpeedEcoRoll", overspeedDic) - json.Content.Add("Body", dic0) + json.Content = JToken.FromObject(New Dictionary(Of String, Object) From {{"Header", header}, {"Body", body}}) Return json.WriteFile(_sFilePath) End Function - Public Function ReadFile() As Boolean - Const msgSrc = "Main/ReadInp/GEN" - - SetDefault() - - Dim json As New JSONParser - If Not json.ReadFile(_sFilePath) Then Return False - - Try - Dim fileVersion = json.Content("Header")("FileVersion") - - Dim body As JObject = json.Content("Body") - - If fileVersion > 1 Then - SavedInDeclMode = body("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If - - If Not body("VehicleFile") Is Nothing Then _ - _vehicleFile.Init(_myPath, body("VehicleFile")) - - _engineFile.Init(_myPath, body("EngineFile")) - - If Not body("GearboxFile") Is Nothing Then _ - _gearboxFile.Init(_myPath, body("GearboxFile")) - - If Not body("Cycles") Is Nothing Then - For Each str As String In body("Cycles") - Dim subPath = New SubPath - subPath.Init(_myPath, str) - CycleFiles.Add(subPath) - Next - End If - - 'AA-TB - 'ADVANCED AUXILIARIES - If Not body("AuxiliaryAssembly") Is Nothing AndAlso - Not body("AuxiliaryVersion") Is Nothing Then - - AuxiliaryAssembly = body("AuxiliaryAssembly").ToString() - AuxiliaryVersion = body("AuxiliaryVersion").ToString() - - End If - If Not body("AdvancedAuxiliaryFilePath") Is Nothing Then - AdvancedAuxiliaryFilePath = body("AdvancedAuxiliaryFilePath").ToString() - End If - - - If Not body("Aux") Is Nothing Then - For Each dic In body("Aux") - - Dim auxId As String = UCase(Trim(dic("ID").ToString)) - - If AuxPaths.ContainsKey(auxId) Then - WorkerMsg(MessageType.Err, "Multiple definitions of the same auxiliary type (" & auxId & ")!", msgSrc) - Return False - End If - - Dim auxEntry = New AuxEntry - - auxEntry.Type = dic("Type") - auxEntry.Path.Init(_myPath, dic("Path")) - - If Not dic("Technology") Is Nothing Then - If fileVersion = 2 Then - auxEntry.TechStr = dic("Technology") - End If - If fileVersion = 3 Then - auxEntry.TechStr = dic("Technology").FirstOrDefault() - End If - End If - - If (auxId = sKey.AUX.HVAC) Then - If Not String.IsNullOrWhiteSpace(auxEntry.TechStr) Then - auxEntry.TechStr = "" - WorkerMsg(MessageType.Normal, "Aux: Automatically Upgraded HVAC to new format.", msgSrc) - End If - End If - - If auxId = sKey.AUX.ElecSys Then - If auxEntry.TechStr = "Custom Technology List" OrElse String.IsNullOrWhiteSpace(auxEntry.TechStr) Then - Dim hasTech = False - - If Not dic("TechList") Is Nothing Then - For Each t In dic("TechList") - hasTech = True - Next - End If - - If Not hasTech Then - auxEntry.TechStr = "Standard technology" - Else - auxEntry.TechStr = "Standard technology - LED headlights, all" - End If - WorkerMsg(MessageType.Normal, - "Aux: Automatically Upgraded Electric System to new format: '" + auxEntry.TechStr + "'", - msgSrc) - End If - End If - - If auxId = sKey.AUX.SteerPump Then - Select Case auxEntry.TechStr - Case "Variable displacement" - WorkerMsg(MessageType.Warn, "Aux: Steering Pump Technology not automatically convertible. Please set new value.", - msgSrc) - Case "Hydraulic supported by electric" - WorkerMsg(MessageType.Warn, "Aux: Steering Pump Technology not automatically convertible. Please set new value.", - msgSrc) - End Select - End If - - If auxId = sKey.AUX.Fan Then - Select Case auxEntry.TechStr - Case "Crankshaft mounted - Electronically controlled visco clutch (Default)" - auxEntry.TechStr = "Crankshaft mounted - Electronically controlled visco clutch" - Case "Crankshaft mounted - On/Off clutch" - auxEntry.TechStr = "Crankshaft mounted - On/off clutch" - Case "Belt driven or driven via transm. - On/Off clutch" - auxEntry.TechStr = "Belt driven or driven via transm. - On/off clutch" - End Select - End If - - If fileVersion = 2 AndAlso auxId = sKey.AUX.PneumSys Then - auxEntry.TechStr = "" - WorkerMsg(MessageType.Warn, "Aux: Pneumatic System must be updated. Please set new value.", - msgSrc) - End If - - AuxPaths.Add(auxId, auxEntry) - - Next - End If - - If Not body("VACC") Is Nothing Then - _driverAccelerationFile.Init(_myPath, body("VACC")) - End If - - EngineOnly = body("EngineOnlyMode") - - If Not body("StartStop") Is Nothing Then - Dim dic = body("StartStop") - _startStop = dic("Enabled") - _startStopMaxSpeed = dic("MaxSpeed") - _startStopMinTime = dic("MinTime") - StartStopDelay = dic("Delay") - Else - _startStop = False - End If - - If Not body("LAC") Is Nothing Then - Dim dic = body("LAC") - LookAheadOn = dic("Enabled") - LacPreviewFactor = If(dic("PreviewDistanceFactor") Is Nothing, 10, dic("PreviewDistanceFactor")) - LacDfOffset = If(dic("DF_offset") Is Nothing, 2.5, dic("DF_offset")) - LacDfScale = If(dic("DF_scaling") Is Nothing, 1.5, dic("DF_scaling")) - LacDfTargetSpeedFile = If(Not dic("DF_targetSpeedLookup") Is Nothing, dic("DF_targetSpeedLookup"), "") - LacDfVelocityDropFile = If(Not dic("Df_velocityDropLookup") Is Nothing, dic("Df_velocityDropLookup"), "") - Else - LookAheadOn = False - End If - - If Not body("OverSpeedEcoRoll") Is Nothing Then - Dim dic = body("OverSpeedEcoRoll") + 'Public Function ReadFile() As Boolean + ' Const msgSrc = "Main/ReadInp/GEN" - Select Case UCase(dic("Mode").ToString).Trim - Case "ECOROLL" - OverSpeedOn = False - EcoRollOn = True + ' SetDefault() - Case "OVERSPEED" - OverSpeedOn = True - EcoRollOn = False - - Case "OFF" - OverSpeedOn = False - EcoRollOn = False - - Case Else - WorkerMsg(MessageType.Err, "Value '" & dic("Mode").ToString() & "' is not valid for OverSpeedEcoRoll/Mode!", - msgSrc) - Return False - End Select - - VMin = dic("MinSpeed") - OverSpeed = dic("OverSpeed") - If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic("UnderSpeed") - - Else - OverSpeedOn = False - EcoRollOn = False - End If - - - Catch ex As Exception - WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, msgSrc) - Return False - End Try - - - Return True - End Function + ' Dim json As New JSONParser + ' If Not json.ReadFile(_sFilePath) Then Return False + + ' Try + + ' Dim fileVersion As Integer = json.Content.GetEx("Header").GetEx(Of Integer)("FileVersion") + + ' Dim body As JToken = json.Content.GetEx("Body") + + ' If fileVersion > 1 Then + ' SavedInDeclMode = body.GetEx(Of Boolean)("SavedInDeclMode") + ' Else + ' SavedInDeclMode = Cfg.DeclMode + ' End If + + ' If Not body("VehicleFile") Is Nothing Then _ + ' _vehicleFile.Init(_myPath, body.GetEx(Of String)("VehicleFile")) + + ' _engineFile.Init(_myPath, body.GetEx(Of String)("EngineFile")) + + ' If Not body("GearboxFile") Is Nothing Then _ + ' _gearboxFile.Init(_myPath, body.GetEx(Of String)("GearboxFile")) + + ' If Not body("Cycles") Is Nothing Then + ' For Each entry As JToken In body.GetEx("Cycles") + ' Dim subPath = New SubPath + ' subPath.Init(_myPath, entry.Value(Of String)) + ' CycleFiles.Add(subPath) + ' Next + ' End If + + ' 'AA-TB + ' 'ADVANCED AUXILIARIES + ' If Not body("AuxiliaryAssembly") Is Nothing AndAlso + ' Not body("AuxiliaryVersion") Is Nothing Then + + ' AuxiliaryAssembly = body("AuxiliaryAssembly").ToString() + ' AuxiliaryVersion = body("AuxiliaryVersion").ToString() + + ' End If + ' If Not body("AdvancedAuxiliaryFilePath") Is Nothing Then + ' AdvancedAuxiliaryFilePath = body("AdvancedAuxiliaryFilePath").ToString() + ' End If + + + ' If Not body("Aux") Is Nothing Then + ' For Each dic As JToken In body.GetEx("Aux") + + ' Dim auxId As String = UCase(Trim(dic.GetEx(Of String)("ID"))) + + ' If AuxPaths.ContainsKey(auxId) Then + ' WorkerMsg(MessageType.Err, "Multiple definitions of the same auxiliary type (" & auxId & ")!", msgSrc) + ' Return False + ' End If + + ' Dim auxEntry = New AuxEntry + + ' auxEntry.Type = dic.GetEx(Of String)("Type") + ' auxEntry.Path.Init(_myPath, dic.GetEx(Of String)("Path")) + + ' If Not dic("Technology") Is Nothing Then + ' If fileVersion = 2 Then + ' auxEntry.TechnologyList.Add(dic.GetEx(Of String)("Technology")) + ' End If + ' If fileVersion = 3 Then + ' auxEntry.TechnologyList = dic.GetEx("Technology").ToObject(Of List(Of String))() '.FirstOrDefault() + ' End If + ' End If + + ' If (auxId = Constants.AuxiliaryKey.HVAC) Then + ' If auxEntry.TechnologyList.Count > 0 Then ' Not String.IsNullOrWhiteSpace(auxEntry.TechStr) Then + ' auxEntry.TechnologyList.Clear() + ' WorkerMsg(MessageType.Normal, "Aux: Automatically Upgraded HVAC to new format.", msgSrc) + ' End If + ' End If + + ' If auxId = Constants.AuxiliaryKey.ElecSys Then + ' If auxEntry.TechnologyList.Contains("Custom Technology List") OrElse auxEntry.TechnologyList.Count > 0 Then + ' Dim hasTech = False + + ' If Not dic("TechList") Is Nothing Then + ' For Each t In dic("TechList") + ' hasTech = True + ' Next + ' End If + + ' auxEntry.TechnologyList.Clear() + ' If Not hasTech Then + ' auxEntry.TechnologyList.Add("Standard technology") + ' Else + ' auxEntry.TechnologyList.Add("Standard technology - LED headlights, all") + ' End If + ' WorkerMsg(MessageType.Normal, + ' "Aux: Automatically Upgraded Electric System to new format: '" + auxEntry.TechnologyList.FirstOrDefault() + "'", + ' msgSrc) + ' End If + ' End If + + ' If auxId = Constants.AuxiliaryKey.SteerPump Then + ' If _ + ' auxEntry.TechnologyList.Contains("Variable displacement") OrElse + ' auxEntry.TechnologyList.Contains("Hydraulic supported by electric") Then + ' auxEntry.TechnologyList.Clear() + ' WorkerMsg(MessageType.Warn, "Aux: Steering Pump Technology not automatically convertible. Please set new value.", + ' msgSrc) + ' End If + ' End If + + ' If auxId = Constants.AuxiliaryKey.Fan Then + ' If auxEntry.TechnologyList.Contains("Crankshaft mounted - Electronically controlled visco clutch (Default)") Then + ' auxEntry.TechnologyList.Clear() + ' auxEntry.TechnologyList.Add("Crankshaft mounted - Electronically controlled visco clutch") + ' End If + ' If auxEntry.TechnologyList.Contains("Crankshaft mounted - On/Off clutch") Then + ' auxEntry.TechnologyList.Clear() + ' auxEntry.TechnologyList.Add("Crankshaft mounted - On/off clutch") + ' End If + ' If auxEntry.TechnologyList.Contains("Belt driven or driven via transm. - On/Off clutch") Then + ' auxEntry.TechnologyList.Clear() + ' auxEntry.TechnologyList.Add("Belt driven or driven via transm. - On/off clutch") + ' End If + ' End If + + ' If fileVersion = 2 AndAlso auxId = Constants.AuxiliaryKey.PneumSys Then + ' auxEntry.TechnologyList.Clear() + ' WorkerMsg(MessageType.Warn, "Aux: Pneumatic System must be updated. Please set new value.", + ' msgSrc) + ' End If + + ' AuxPaths.Add(auxId, auxEntry) + + ' Next + ' End If + + ' If Not body("VACC") Is Nothing Then + ' _driverAccelerationFile.Init(_myPath, body.GetEx(Of String)("VACC")) + ' End If + + ' EngineOnly = body.GetEx(Of Boolean)("EngineOnlyMode") + + ' If Not body("StartStop") Is Nothing Then + ' Dim startStop As JToken = body.GetEx("StartStop") + ' _startStop = startStop.GetEx(Of Boolean)("Enabled") + ' _startStopMaxSpeed = startStop.GetEx(Of Double)("MaxSpeed") + ' _startStopMinTime = startStop.GetEx(Of Double)("MinTime") + ' StartStopDelay = startStop.GetEx(Of Double)("Delay") + ' Else + ' _startStop = False + ' End If + + ' If Not body("LAC") Is Nothing Then + ' Dim lac = body.GetEx("LAC") + ' LookAheadOn = lac.GetEx(Of Boolean)("Enabled") + ' LacPreviewFactor = If(lac("PreviewDistanceFactor") Is Nothing, 10, lac.GetEx(Of Double)("PreviewDistanceFactor")) + ' LacDfOffset = If(lac("DF_offset") Is Nothing, 2.5, lac.GetEx(Of Double)("DF_offset")) + ' LacDfScale = If(lac("DF_scaling") Is Nothing, 1.5, lac.GetEx(Of Double)("DF_scaling")) + ' LacDfTargetSpeedFile = + ' If(Not lac("DF_targetSpeedLookup") Is Nothing, lac.GetEx(Of String)("DF_targetSpeedLookup"), "") + ' LacDfVelocityDropFile = + ' If(Not lac("Df_velocityDropLookup") Is Nothing, lac.GetEx(Of String)("Df_velocityDropLookup"), "") + ' Else + ' LookAheadOn = False + ' End If + + ' If Not body("OverSpeedEcoRoll") Is Nothing Then + ' Dim dic = body("OverSpeedEcoRoll") + + ' Select Case UCase(dic("Mode").ToString).Trim + ' Case "ECOROLL" + ' OverSpeedOn = False + ' EcoRollOn = True + + ' Case "OVERSPEED" + ' OverSpeedOn = True + ' EcoRollOn = False + + ' Case "OFF" + ' OverSpeedOn = False + ' EcoRollOn = False + + ' Case Else + ' WorkerMsg(MessageType.Err, "Value '" & dic("Mode").ToString() & "' is not valid for OverSpeedEcoRoll/Mode!", + ' msgSrc) + ' Return False + ' End Select + + ' VMin = dic.GetEx(Of Double)("MinSpeed") + ' OverSpeed = dic.GetEx(Of Double)("OverSpeed") + ' If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic.GetEx(Of Double)("UnderSpeed") + + ' Else + ' OverSpeedOn = False + ' EcoRollOn = False + ' End If + + + ' Catch ex As Exception + ' WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, msgSrc) + ' Return False + ' End Try + + + ' Return True + 'End Function Private Sub SetDefault() @@ -368,8 +407,8 @@ Public Class VectoJob _startStop = False - _startStopMaxSpeed = 5 - _startStopMinTime = 5 + StartStopMaxSpeed = 5 + StartStopTime = 5 StartStopDelay = 0 _vehicleFile.Clear() @@ -453,6 +492,13 @@ Public Class VectoJob End Property + Public ReadOnly Property IDriverDeclarationInputData_SavedInDeclarationMode As Boolean _ + Implements IDriverDeclarationInputData.SavedInDeclarationMode + Get + Return SavedInDeclMode + End Get + End Property + Public Property StartStop As Boolean Get Return _startStop @@ -462,24 +508,81 @@ Public Class VectoJob End Set End Property - Public Property StStV As Single + Public ReadOnly Property IDriverEngineeringInputData_OverSpeedEcoRoll As IOverSpeedEcoRollEngineeringInputData _ + Implements IDriverEngineeringInputData.OverSpeedEcoRoll Get - Return _startStopMaxSpeed + Dim mode As DriverMode = DriverMode.Off + If EcoRollOn Then + mode = DriverMode.EcoRoll + ElseIf OverSpeedOn Then + mode = DriverMode.Overspeed + End If + + Return New OverSpeedEcoRollInputData() With { + .Mode = mode, + .MinSpeed = VMin.KMPHtoMeterPerSecond(), + .OverSpeed = OverSpeed.KMPHtoMeterPerSecond(), + .UnderSpeed = UnderSpeed.KMPHtoMeterPerSecond() + } End Get - Set(value As Single) - _startStopMaxSpeed = value - End Set End Property - Public Property StStT As Single + Public ReadOnly Property IDriverEngineeringInputData_StartStop As IStartStopEngineeringInputData _ + Implements IDriverEngineeringInputData.StartStop Get - Return _startStopMinTime + Return New StartStopInputData With { + .Enabled = _startStop, + .MaxSpeed = StartStopMaxSpeed.KMPHtoMeterPerSecond(), + .MinTime = StartStopTime.SI(Of Second)(), + .Delay = StartStopDelay.SI(Of Second)() + } + End Get + End Property + + Public ReadOnly Property OverSpeedEcoRoll As IOverSpeedEcoRollDeclarationInputData _ + Implements IDriverDeclarationInputData.OverSpeedEcoRoll + Get + Return IDriverEngineeringInputData_OverSpeedEcoRoll End Get - Set(value As Single) - _startStopMinTime = value - End Set End Property + Public ReadOnly Property AccelerationCurve As TableData Implements IDriverEngineeringInputData.AccelerationCurve + Get + If String.IsNullOrWhiteSpace(_driverAccelerationFile.FullPath) Then Return Nothing + If Not File.Exists(_driverAccelerationFile.FullPath) Then + Try + Dim cycleDataRes As Stream = + RessourceHelper.ReadStream( + RessourceHelper.Namespace + "VACC." + _driverAccelerationFile.OriginalPath + + VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve) + Return VectoCSVFile.ReadStream(cycleDataRes) + Catch ex As Exception + Return Nothing + End Try + End If + Return VectoCSVFile.Read(_driverAccelerationFile.FullPath) + End Get + End Property + + Public ReadOnly Property Lookahead As ILookaheadCoastingInputData Implements IDriverEngineeringInputData.Lookahead + Get + Dim lacTargetLookup As TableData = + If(File.Exists(LacDfTargetSpeedFile), VectoCSVFile.Read(LacDfTargetSpeedFile), Nothing) + Dim lacVdropLookup As TableData = + If(File.Exists(LacDfVelocityDropFile), VectoCSVFile.Read(LacDfVelocityDropFile), Nothing) + Return New LookAheadCoastingInputData With { + .Enabled = LookAheadOn, + .MinSpeed = LookAheadMinSpeed.KMPHtoMeterPerSecond(), + .CoastingDecisionFactorScaling = LacDfScale, + .CoastingDecisionFactorOffset = LacDfOffset, + .LookaheadDistanceFactor = LacPreviewFactor, + .CoastingDecisionFactorTargetSpeedLookup = lacTargetLookup, + .CoastingDecisionFactorVelocityDropLookup = lacVdropLookup + } + End Get + End Property + + Public Property DesMaxFile(Optional ByVal original As Boolean = False) As String Get If original Then @@ -493,13 +596,305 @@ Public Class VectoJob End Set End Property - Public Property LacPreviewFactor As Single - Public Property LacDfOffset As Single - Public Property LacDfScale As Single + Public Property LacPreviewFactor As Double + Public Property LacDfOffset As Double + Public Property LacDfScale As Double Public Property LacDfTargetSpeedFile As String Public Property LacDfVelocityDropFile As String +#End Region + + ' ReSharper disable once UnusedMember.Global -- used by Validation + Public Shared Function ValidateJob(vectoJob As VectoJob, validationContext As ValidationContext) As ValidationResult + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + ExecutionModeServiceContainer) + Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) + + Dim jobData As IEnumerable(Of VectoRunData) + + vectoJob._vehicleInputData = New JSONComponentInputData(vectoJob._vehicleFile.FullPath) + vectoJob._engineInputData = New JSONComponentInputData(vectoJob._engineFile.FullPath) + vectoJob._gearboxInputData = New JSONComponentInputData(vectoJob._gearboxFile.FullPath) + + + Dim result As IList(Of ValidationResult) = New List(Of ValidationResult) + + If vectoJob._vehicleInputData.VehicleInputData Is Nothing Then _ + result.Add(New ValidationResult("Vehicle File is missing or invalid")) + If vectoJob._engineInputData.EngineInputData Is Nothing Then _ + result.Add(New ValidationResult("Engine File is missing or invalid")) + If vectoJob._gearboxInputData.GearboxInputData Is Nothing Then _ + result.Add(New ValidationResult("Gearbox File is missing or invalid")) + + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + Try + If mode = ExecutionMode.Declaration Then + If Not vectoJob._vehicleInputData.VehicleInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Vehicle File is not in Declaration Mode")) + End If + If Not vectoJob._engineInputData.EngineInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Engine File is not in Declaration Mode")) + End If + If Not vectoJob._gearboxInputData.GearboxInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Gearbox File is not in Declaration Mode")) + End If + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + Dim dataFactory As DeclarationModeVectoRunDataFactory = New DeclarationModeVectoRunDataFactory(vectoJob, Nothing) + + jobData = dataFactory.NextRun() + Else + If vectoJob._vehicleInputData.VehicleInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Vehicle File is not in Engineering Mode")) + End If + If vectoJob._engineInputData.EngineInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Engine File is not in Engineering Mode")) + End If + If vectoJob._gearboxInputData.GearboxInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Gearbox File is not in Engineering Mode")) + End If + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + Dim dataFactory As EngineeringModeVectoRunDataFactory = New EngineeringModeVectoRunDataFactory(vectoJob) + jobData = dataFactory.NextRun() + End If + + + jobData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + + Return ValidationResult.Success + + Catch ex As Exception + Return New ValidationResult(ex.Message) + Finally + vectoJob._vehicleInputData = Nothing + vectoJob._engineInputData = Nothing + vectoJob._gearboxInputData = Nothing + End Try + End Function + + +#Region "IInputData" + + Public Function JobInputData() As IEngineeringJobInputData Implements IEngineeringInputDataProvider.JobInputData + Return Me + End Function + + Public ReadOnly Property IDeclarationInputDataProvider_VehicleInputData As IVehicleDeclarationInputData _ + Implements IDeclarationInputDataProvider.VehicleInputData + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public Function IDeclarationInputDataProvider_JobInputData() As IDeclarationJobInputData _ + Implements IDeclarationInputDataProvider.JobInputData + Throw New NotImplementedException + End Function + + Public ReadOnly Property VehicleInputData As IVehicleEngineeringInputData _ + Implements IEngineeringInputDataProvider.VehicleInputData + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_GearboxInputData As IGearboxDeclarationInputData _ + Implements IDeclarationInputDataProvider.GearboxInputData + Get + Return _gearboxInputData.GearboxInputData + End Get + End Property + + Public ReadOnly Property GearboxInputData As IGearboxEngineeringInputData _ + Implements IEngineeringInputDataProvider.GearboxInputData + Get + Return _gearboxInputData.GearboxInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_TorqueConverterInputData As ITorqueConverterDeclarationInputData _ + Implements IDeclarationInputDataProvider.TorqueConverterInputData + Get + Return _gearboxInputData.TorqueConverterInputData + End Get + End Property + + Public ReadOnly Property TorqueConverterInputData As ITorqueConverterEngineeringInputData _ + Implements IEngineeringInputDataProvider.TorqueConverterInputData + Get + Return _gearboxInputData.TorqueConverterInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_AxleGearInputData As IAxleGearInputData _ + Implements IDeclarationInputDataProvider.AxleGearInputData + Get + Return _gearboxInputData.AxleGearInputData + End Get + End Property + + Public ReadOnly Property AxleGearInputData As IAxleGearInputData _ + Implements IEngineeringInputDataProvider.AxleGearInputData + Get + Return _gearboxInputData.AxleGearInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_AngularGearInputData As IAngularGearInputData _ + Implements IDeclarationInputDataProvider.AngularGearInputData + Get + Return _vehicleInputData.AngularGearInputData + End Get + End Property + + Public ReadOnly Property AngularGearInputData As IAngularGearInputData _ + Implements IEngineeringInputDataProvider.AngularGearInputData + Get + Return _vehicleInputData.AngularGearInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_EngineInputData As IEngineDeclarationInputData _ + Implements IDeclarationInputDataProvider.EngineInputData + Get + Return _engineInputData.EngineInputData + End Get + End Property + + Public ReadOnly Property EngineInputData As IEngineEngineeringInputData _ + Implements IEngineeringInputDataProvider.EngineInputData + Get + Return _engineInputData.EngineInputData + End Get + End Property + + Public Function AuxiliaryInputData() As IAuxiliariesEngineeringInputData _ + Implements IEngineeringInputDataProvider.AuxiliaryInputData + + Throw New NotImplementedException + End Function + + Public ReadOnly Property IDeclarationInputDataProvider_RetarderInputData As IRetarderInputData _ + Implements IDeclarationInputDataProvider.RetarderInputData + Get + Return _vehicleInputData.RetarderInputData + End Get + End Property + + Public Function IDeclarationInputDataProvider_AuxiliaryInputData() As IAuxiliariesDeclarationInputData _ + Implements IDeclarationInputDataProvider.AuxiliaryInputData + Throw New NotImplementedException + End Function + + Public ReadOnly Property RetarderInputData As IRetarderInputData _ + Implements IEngineeringInputDataProvider.RetarderInputData + Get + Return _vehicleInputData.RetarderInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_DriverInputData As IDriverDeclarationInputData _ + Implements IDeclarationInputDataProvider.DriverInputData + Get + Return Me + End Get + End Property + + Public ReadOnly Property DriverInputData As IDriverEngineeringInputData _ + Implements IEngineeringInputDataProvider.DriverInputData + Get + Return Me + End Get + End Property + + Public ReadOnly Property PTOTransmissionInputData As IPTOTransmissionInputData _ + Implements IEngineeringInputDataProvider.PTOTransmissionInputData + Get + Return _vehicleInputData.PTOTransmissionInputData + End Get + End Property + + + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IDeclarationJobInputData.SavedInDeclarationMode + Get + Return SavedInDeclMode + End Get + End Property + + Public ReadOnly Property IDriverDeclarationInputData_StartStop As IStartStopDeclarationInputData _ + Implements IDriverDeclarationInputData.StartStop + Get + Return IDriverEngineeringInputData_StartStop + End Get + End Property + + Public ReadOnly Property IEngineeringJobInputData_Vehicle As IVehicleEngineeringInputData _ + Implements IEngineeringJobInputData.Vehicle + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public ReadOnly Property Vehicle As IVehicleDeclarationInputData Implements IDeclarationJobInputData.Vehicle + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public ReadOnly Property Cycles As IList(Of ICycleData) Implements IEngineeringJobInputData.Cycles + Get + Dim retVal As ICycleData() = New ICycleData(CycleFiles.Count) {} + Dim i As Integer = 0 + For Each cycleFile As SubPath In CycleFiles + Dim cycleData As TableData + If (File.Exists(cycleFile.FullPath)) Then + cycleData = VectoCSVFile.Read(cycleFile.FullPath) + Else + Try + Dim cycleDataRes As Stream = + RessourceHelper.ReadStream(RessourceHelper.Namespace + "MissionCycles." + cycleFile.OriginalPath + ".vdri") + cycleData = VectoCSVFile.ReadStream(cycleDataRes) + Catch ex As Exception + Throw New VectoException("Driving Cycle could not be read: " + cycleFile.OriginalPath) + End Try + End If + retVal(i) = New CycleInputData With { + .Name = Path.GetFileNameWithoutExtension(cycleFile.FullPath), + .CycleData = cycleData + } + i += 1 + Next + Return retVal + End Get + End Property + + Public ReadOnly Property EngineOnlyMode As Boolean Implements IEngineeringJobInputData.EngineOnlyMode + Get + Return EngineOnly + End Get + End Property + + Public ReadOnly Property JobName As String Implements IDeclarationJobInputData.JobName + Get + Return Path.GetFileNameWithoutExtension(FilePath) + End Get + End Property + #End Region End Class diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index e8eccb79de762b051d96c1ae6f6f1fc9c9c77d6a..d67e58fa65e4fd3b123b451ca14b0a4533e5c18a 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -8,62 +8,70 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. -Option Infer On +'Option Infer On Imports System.Collections.Generic +Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq +Imports Newtonsoft.Json.Linq Imports TUGraz.VECTO.Input_Files +Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.Impl +Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter Imports TUGraz.VectoCore.Models.Declaration +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Utils - +<CustomValidation(GetType(Vehicle), "ValidateVehicle")> Public Class Vehicle + Implements IVehicleEngineeringInputData, IVehicleDeclarationInputData, IRetarderInputData, IPTOTransmissionInputData, + IAngularGearInputData 'V2 MassMax is now saved in [t] instead of [kg] Private Const FormatVersion As Short = 7 - Private _fileVersion As Short Private _filePath As String Private _path As String - Public Mass As Single - Public Loading As Single + Public Mass As Double + Public Loading As Double - Public CdA0 As Single + Public CdA0 As Double Public CrossWindCorrectionMode As CrossWindCorrectionMode Public ReadOnly CrossWindCorrectionFile As SubPath - Public RetarderType As RetarderType - Public RetarderRatio As Single = 0 + <ValidateObject()> Public RetarderType As RetarderType + Public RetarderRatio As Double = 0 Public ReadOnly RetarderLossMapFile As SubPath - Public DynamicTyreRadius As Single + Public DynamicTyreRadius As Double Public ReadOnly Axles As List(Of Axle) Public VehicleCategory As VehicleCategory - Public MassExtra As Single - Public MassMax As Single + Public MassExtra As Double + Public MassMax As Double Public AxleConfiguration As AxleConfiguration Public SavedInDeclMode As Boolean Public AngularGearType As AngularGearType - Public AngularGearRatio As Single + Public AngularGearRatio As Double Public ReadOnly AngularGearLossMapFile As SubPath - Public PTOType As String - Public PTOLossMap As SubPath - Public PTOCycle As SubPath + Public PtoType As String + Public ReadOnly PtoLossMap As SubPath + Public ReadOnly PtoCycle As SubPath Public Class Axle - Public RRC As Single - Public Share As Single + Public RRC As Double + Public Share As Double Public TwinTire As Boolean - Public FzISO As Single + Public FzISO As Double Public Wheels As String - Public Inertia As Single + Public Inertia As Double End Class @@ -76,11 +84,77 @@ Public Class Vehicle AngularGearLossMapFile = New SubPath() Axles = New List(Of Axle) - PTOLossMap = New SubPath() - PTOCycle = New SubPath() + PtoLossMap = New SubPath() + PtoCycle = New SubPath() SetDefault() End Sub + + ' ReSharper disable once UnusedMember.Global -- used for Validation + Public Shared Function ValidateVehicle(vehicle As Vehicle, validationContext As ValidationContext) As ValidationResult + + Dim vehicleData As VehicleData + Dim retarderData As RetarderData + Dim ptoData As PTOData = Nothing + Dim angledriveData As AngularGearData + + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + ExecutionModeServiceContainer) + Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) + + Try + If mode = ExecutionMode.Declaration Then + Dim doa As DeclarationDataAdapter = New DeclarationDataAdapter() + Dim segment As Segment = DeclarationData.Segments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, + vehicle.GrossVehicleMassRating, vehicle.CurbWeightChassis) + vehicleData = doa.CreateVehicleData(vehicle, segment.Missions.First(), + segment.Missions.First().Loadings.First().Value) + retarderData = doa.CreateRetarderData(vehicle) + angledriveData = doa.CreateAngularGearData(vehicle, False) + Else + Dim doa As EngineeringDataAdapter = New EngineeringDataAdapter() + vehicleData = doa.CreateVehicleData(vehicle) + retarderData = doa.CreateRetarderData(vehicle) + angledriveData = doa.CreateAngularGearData(vehicle, True) + ptoData = doa.CreatePTOTransmissionData(vehicle) + End If + + Dim result As IList(Of ValidationResult) = + vehicleData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Vehicle Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + result = retarderData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Retarder Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + If vehicle.AngularGearType = AngularGearType.SeparateAngularGear Then + result = angledriveData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("AngleDrive Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + End If + + If Not vehicle.PTOTransmissionType = "None" Then + result = ptoData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("PTO Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + End If + + Return ValidationResult.Success + + Catch ex As Exception + Return New ValidationResult(ex.Message) + End Try + End Function + Private Sub SetDefault() Mass = 0 MassExtra = 0 @@ -102,9 +176,9 @@ Public Class Vehicle AngularGearLossMapFile.Clear() AngularGearRatio = 1 - PTOType = PTOTransmission.NoPTO - PTOLossMap.Clear() - PTOCycle.Clear() + PtoType = PTOTransmission.NoPTO + PtoLossMap.Clear() + PtoCycle.Clear() Axles.Clear() VehicleCategory = VehicleCategory.RigidTruck 'tVehCat.Undef @@ -114,180 +188,69 @@ Public Class Vehicle SavedInDeclMode = False End Sub - Public Function ReadFile(Optional showMsg As Boolean = True) As Boolean - Const msgSrc = "VEH/ReadFile" - SetDefault() - - Dim json As New JSONParser - If Not json.ReadFile(_filePath) Then Return False - Try - Dim header = json.Content("Header") - Dim body = json.Content("Body") - - _fileVersion = header("FileVersion") - If _fileVersion > 4 Then - SavedInDeclMode = body("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If - - Mass = body("CurbWeight") - MassExtra = body("CurbWeightExtra") - Loading = body("Loading") - VehicleCategory = body("VehCat").ToString.ParseEnum(Of VehicleCategory)() 'ConvVehCat(body("VehCat").ToString) - AxleConfiguration = AxleConfigurationHelper.Parse(body("AxleConfig")("Type").ToString) - If _fileVersion < 2 Then - 'convert kg to ton - MassMax /= 1000 - Else - MassMax = body("MassMax") - End If - - If _fileVersion < 7 Then - 'calc CdA from Cd and area value - CdA0 = CSng(body("Cd")) * CSng(body("CrossSecArea")) - Else - CdA0 = body("CdA") - End If - - 'CdA02 = CdA0 - - CrossWindCorrectionMode = CrossWindCorrectionModeHelper.Parse(body("CdCorrMode").ToString) - If Not body("CdCorrFile") Is Nothing Then - CrossWindCorrectionFile.Init(_path, body("CdCorrFile")) - End If - - If body("Retarder") Is Nothing Then - RetarderType = RetarderType.None - Else - RetarderType = RetarderTypeHelper.Parse(body("Retarder")("Type").ToString) - If Not body("Retarder")("Ratio") Is Nothing Then - RetarderRatio = body("Retarder")("Ratio") - End If - If Not body("Retarder")("File") Is Nothing Then - RetarderLossMapFile.Init(_path, body("Retarder")("File")) - End If - End If - - If body("AngularGear") Is Nothing Then - AngularGearType = AngularGearType.None - Else - AngularGearType = body("AngularGear")("Type").ToString.ParseEnum(Of AngularGearType)() - If Not body("AngularGear")("Ratio") Is Nothing Then - AngularGearRatio = body("AngularGear")("Ratio") - End If - If Not body("AngularGear")("LossMap") Is Nothing Then - AngularGearLossMapFile.Init(_path, body("AngularGear")("LossMap")) - End If - End If - - Dim inertiaTemp As Single - If _fileVersion < 3 Then - inertiaTemp = body("WheelsInertia") - DynamicTyreRadius = 1000 * body("WheelsDiaEff") / 2 - Else - DynamicTyreRadius = body("rdyn") - End If - - Dim axleCount = body("AxleConfig")("Axles").Count() - For Each axleEntry In body("AxleConfig")("Axles") - Dim axle = New Axle With { - .Share = CSng(axleEntry("AxleWeightShare")), - .TwinTire = CBool(axleEntry("TwinTyres")), - .RRC = CSng(axleEntry("RRCISO")), - .FzISO = CSng(axleEntry("FzISO"))} - - If _fileVersion < 3 Then - axle.Wheels = "-" - axle.Inertia = inertiaTemp / (IIf(axle.TwinTire, 4, 2) * axleCount) - Else - axle.Wheels = CStr(axleEntry("Wheels")).Replace("R ", "R") - axle.Inertia = CSng(axleEntry("Inertia")) - End If - Axles.Add(axle) - Next - - PTOType = PTOTransmission.NoPTO - If Not body("PTO") Is Nothing Then - Dim ptoStr = body("PTO")("Type") - - If String.IsNullOrWhiteSpace(ptoStr) Then - PTOType = PTOTransmission.NoPTO - WorkerMsg(MessageType.Normal, "PTO automatically updated to '" + PTOType + "'", msgSrc) - Else - Try - DeclarationData.PTOTransmission.Lookup(ptoStr) - PTOType = ptoStr - Catch ex As Exception - PTOType = PTOTransmission.NoPTO - WorkerMsg(MessageType.Normal, "PTO '" + ptoStr + "' not found, automatically updated to '" + PTOType + "'", msgSrc) - End Try - End If - - End If + Public Function SaveFile() As Boolean + SavedInDeclMode = Cfg.DeclMode - If Not PTOType.Equals(PTOTransmission.NoPTO) Then - PTOLossMap.Init(_path, body("PTO")("LossMap")) - PTOCycle.Init(_path, body("PTO")("Cycle")) - End If + Dim validationResults As IList(Of ValidationResult) = + Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) - Catch ex As Exception - If showMsg Then WorkerMsg(MessageType.Err, "Failed to read Vehicle file! " & ex.Message, msgSrc) + If validationResults.Count > 0 Then + Dim messages As IEnumerable(Of String) = + validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + MsgBox("Invalid input." + Environment.NewLine + String.Join(Environment.NewLine, messages), MsgBoxStyle.OkOnly, + "Failed to save vehicle") Return False - End Try - - Return True - End Function + End If - Public Function SaveFile() As Boolean - SavedInDeclMode = Cfg.DeclMode - - Dim json As New JSONParser + Dim json As New JSONWriter 'Header - json.Content.Add("Header", New Dictionary(Of String, Object) From { - {"CreatedBy", Lic.LicString & " (" & Lic.GUID & ")"}, - {"Date", Now.ToUniversalTime().ToString("o")}, - {"AppVersion", VECTOvers}, - {"FileVersion", FormatVersion}}) + Dim header As Dictionary(Of String, Object) = New Dictionary(Of String, Object) From { + {"CreatedBy", Lic.LicString & " (" & Lic.GUID & ")"}, + {"Date", Now.ToUniversalTime().ToString("o")}, + {"AppVersion", VECTOvers}, + {"FileVersion", FormatVersion}} 'Body - Dim dic As Dictionary(Of String, Object) - dic = New Dictionary(Of String, Object) From { - {"SavedInDeclMode", Cfg.DeclMode}, - {"VehCat", VehicleCategory.ToString()}, - {"CurbWeight", Mass}, - {"CurbWeightExtra", MassExtra}, - {"Loading", Loading}, - {"MassMax", MassMax}, - {"CdA", CdA0}, - {"rdyn", DynamicTyreRadius}, - {"CdCorrMode", CrossWindCorrectionMode.GetName()}, - {"CdCorrFile", CrossWindCorrectionFile.PathOrDummy}, - {"Retarder", New Dictionary(Of String, Object) From { + Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) From { + {"SavedInDeclMode", Cfg.DeclMode}, + {"VehCat", VehicleCategory.ToString()}, + {"CurbWeight", Mass}, + {"CurbWeightExtra", MassExtra}, + {"Loading", Loading}, + {"MassMax", MassMax}, + {"CdA", CdA0}, + {"rdyn", DynamicTyreRadius}, + {"CdCorrMode", CrossWindCorrectionMode.GetName()}, + {"CdCorrFile", CrossWindCorrectionFile.PathOrDummy}, + {"Retarder", New Dictionary(Of String, Object) From { {"Type", RetarderType.GetName()}, {"Ratio", RetarderRatio}, {"File", RetarderLossMapFile.PathOrDummy}}}, - {"AngularGear", New Dictionary(Of String, Object) From { + {"AngularGear", New Dictionary(Of String, Object) From { {"Type", AngularGearType.ToString()}, {"Ratio", AngularGearRatio}, {"LossMap", AngularGearLossMapFile.PathOrDummy}}}, - {"PTO", New Dictionary(Of String, Object) From { - {"Type", PTOType}, - {"LossMap", PTOLossMap.PathOrDummy}, - {"Cycle", PTOCycle.PathOrDummy}}}, - {"AxleConfig", New Dictionary(Of String, Object) From { + {"PTO", New Dictionary(Of String, Object) From { + {"Type", PtoType}, + {"LossMap", PtoLossMap.PathOrDummy}, + {"Cycle", PtoCycle.PathOrDummy}}}, + {"AxleConfig", New Dictionary(Of String, Object) From { {"Type", AxleConfiguration.GetName()}, {"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) + {"Inertia", axle.Inertia}, + {"Wheels", axle.Wheels}, + {"AxleWeightShare", axle.Share}, + {"TwinTyres", axle.TwinTire}, + {"RRCISO", axle.RRC}, + {"FzISO", axle.FzISO} + } + )} + } + } + } + + json.Content = JToken.FromObject(New Dictionary(Of String, Object) From {{"Header", header}, {"Body", body}}) Return json.WriteFile(_filePath) End Function @@ -310,4 +273,224 @@ Public Class Vehicle End Property #End Region + +#Region "IInputData" + + Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Get + Return DataSourceType.JSONFile + End Get + End Property + + Public ReadOnly Property Source As String Implements IComponentInputData.Source + Get + Return FilePath + End Get + End Property + + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IComponentInputData.SavedInDeclarationMode + Get + Return Cfg.DeclMode + End Get + End Property + + Public ReadOnly Property Vendor As String Implements IComponentInputData.Vendor + Get + Return "N.A." ' TODO: MQ 20160908 + End Get + End Property + + Public ReadOnly Property ModelName As String Implements IComponentInputData.ModelName + Get + Return "N.A." ' Todo: MQ 20160908 + End Get + End Property + + Public ReadOnly Property Creator As String Implements IComponentInputData.Creator + Get + Return Lic.LicString + End Get + End Property + + Public ReadOnly Property [Date] As String Implements IComponentInputData.[Date] + Get + Return Now.ToUniversalTime().ToString("o") + End Get + End Property + + Public ReadOnly Property TypeId As String Implements IComponentInputData.TypeId + Get + Return "N.A." ' ToDo: MQ 20160908 + End Get + End Property + + Public ReadOnly Property DigestValue As String Implements IComponentInputData.DigestValue + Get + Return "" + End Get + End Property + + Public ReadOnly Property IntegrityStatus As IntegrityStatus Implements IComponentInputData.IntegrityStatus + Get + Return IntegrityStatus.NotChecked + End Get + End Property + + Public ReadOnly Property IVehicleDeclarationInputData_VehicleCategory As VehicleCategory _ + Implements IVehicleDeclarationInputData.VehicleCategory + Get + Return VehicleCategory + End Get + End Property + + Public ReadOnly Property IVehicleDeclarationInputData_AxleConfiguration As AxleConfiguration _ + Implements IVehicleDeclarationInputData.AxleConfiguration + Get + Return AxleConfiguration + End Get + End Property + + Public ReadOnly Property CurbWeightChassis As Kilogram Implements IVehicleDeclarationInputData.CurbWeightChassis + Get + Return MassExtra.SI(Of Kilogram)() + End Get + End Property + + Public ReadOnly Property GrossVehicleMassRating As Kilogram _ + Implements IVehicleDeclarationInputData.GrossVehicleMassRating + Get + Return MassMax.SI().Ton.Cast(Of Kilogram)() + End Get + End Property + + Public ReadOnly Property AirDragArea As SquareMeter Implements IVehicleDeclarationInputData.AirDragArea + Get + Return CdA0.SI(Of SquareMeter)() + End Get + End Property + + Public ReadOnly Property IVehicleEngineeringInputData_Axles As IList(Of IAxleEngineeringInputData) _ + Implements IVehicleEngineeringInputData.Axles + Get + Return AxleWheels().Cast(Of IAxleEngineeringInputData)().ToList() + End Get + End Property + + Public ReadOnly Property IVehicleDeclarationInputData_Axles As IList(Of IAxleDeclarationInputData) _ + Implements IVehicleDeclarationInputData.Axles + Get + Return AxleWheels().Cast(Of IAxleDeclarationInputData)().ToList() + End Get + End Property + + Private Function AxleWheels() As IEnumerable(Of AxleInputData) + Return Axles.Select(Function(axle) New AxleInputData With { + .SourceType = DataSourceType.JSONFile, + .Source = FilePath, + .Inertia = axle.Inertia.SI(Of KilogramSquareMeter)(), + .Wheels = axle.Wheels, + .AxleWeightShare = axle.Share, + .TwinTyres = axle.TwinTire, + .RollResistanceCoefficient = axle.RRC, + .TyreTestLoad = axle.FzISO.SI(Of Newton)() + }) + End Function + + Public ReadOnly Property CurbWeightExtra As Kilogram Implements IVehicleEngineeringInputData.CurbWeightExtra + Get + Return Mass.SI(Of Kilogram)() + End Get + End Property + + Public ReadOnly Property CrosswindCorrectionMap As TableData _ + Implements IVehicleEngineeringInputData.CrosswindCorrectionMap + Get + Return VectoCSVFile.Read(CrossWindCorrectionFile.FullPath) + End Get + End Property + + Public ReadOnly Property IVehicleEngineeringInputData_CrossWindCorrectionMode As CrossWindCorrectionMode _ + Implements IVehicleEngineeringInputData.CrossWindCorrectionMode + Get + Return CrossWindCorrectionMode.DeclarationModeCorrection + End Get + End Property + + Public ReadOnly Property IVehicleEngineeringInputData_DynamicTyreRadius As Meter _ + Implements IVehicleEngineeringInputData.DynamicTyreRadius + Get + Return DynamicTyreRadius.SI().Milli.Meter.Cast(Of Meter)() + End Get + End Property + + Public ReadOnly Property IVehicleEngineeringInputData_Loading As Kilogram _ + Implements IVehicleEngineeringInputData.Loading + Get + Return Loading.SI(Of Kilogram)() + End Get + End Property + + + Public ReadOnly Property Type As RetarderType Implements IRetarderInputData.Type + Get + Return RetarderType + End Get + End Property + + Public ReadOnly Property IAngularGearInputData_Ratio As Double Implements IAngularGearInputData.Ratio + Get + Return AngularGearRatio + End Get + End Property + + Public ReadOnly Property IAngularGearInputData_Type As AngularGearType Implements IAngularGearInputData.Type + Get + Return AngularGearType + End Get + End Property + + Public ReadOnly Property Ratio As Double Implements IRetarderInputData.Ratio + Get + Return RetarderRatio + End Get + End Property + + Public ReadOnly Property IAngularGearInputData_LossMap As TableData Implements IAngularGearInputData.LossMap + Get + Return VectoCSVFile.Read(AngularGearLossMapFile.FullPath) + End Get + End Property + + Public ReadOnly Property LossMap As TableData Implements IRetarderInputData.LossMap + Get + Return VectoCSVFile.Read(RetarderLossMapFile.FullPath) + End Get + End Property + + Public ReadOnly Property Efficiency As Double Implements IAngularGearInputData.Efficiency + Get + Return If(IsNumeric(AngularGearLossMapFile.OriginalPath), AngularGearLossMapFile.OriginalPath.ToDouble(), -1.0) + End Get + End Property + +#End Region + + Public ReadOnly Property PTOTransmissionType As String Implements IPTOTransmissionInputData.PTOTransmissionType + Get + Return PTOType + End Get + End Property + + Public ReadOnly Property IPTOTransmissionInputData_PTOCycle As TableData Implements IPTOTransmissionInputData.PTOCycle + Get + Return VectoCSVFile.Read(PTOCycle.FullPath) + End Get + End Property + + Public ReadOnly Property IPTOTransmissionInputData_PTOLossMap As TableData _ + Implements IPTOTransmissionInputData.PTOLossMap + Get + Return VectoCSVFile.Read(PTOLossMap.FullPath) + End Get + End Property End Class \ No newline at end of file diff --git a/VECTO/JSONparser.vb b/VECTO/JSONWriter.vb similarity index 59% rename from VECTO/JSONparser.vb rename to VECTO/JSONWriter.vb index 8a4cbcf7972a17e5af2c96cfac13cd12ff8824d6..7cabc5ab5db7e3e219dc9313429509710961bafe 100644 --- a/VECTO/JSONparser.vb +++ b/VECTO/JSONWriter.vb @@ -8,61 +8,23 @@ ' 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 + Imports System.IO -Imports Microsoft.VisualBasic.FileIO +Imports System.Linq Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq ''' <summary> ''' uses JSON.NET http://json.codeplex.com/ ''' </summary> ''' <remarks></remarks> -Public Class JSONParser - Public Content As Dictionary(Of String, Object) +Public Class JSONWriter + Public Content As JToken 'Dictionary(Of String, Object) Public Sub New() - Content = New Dictionary(Of String, Object) + 'Content = New Dictionary(Of String, Object) End Sub - ''' <summary> - ''' Reads a JSON File into the Content variable. - ''' </summary> - ''' <param name="path"></param> - ''' <returns></returns> - ''' <remarks></remarks> - Public Function ReadFile(path As String) As Boolean - Dim file As TextFieldParser - Dim str As String - - Content.Clear() - - If Not IO.File.Exists(path) Then - Return False - End If - - Try - file = New TextFieldParser(path) - Catch ex As Exception - Return False - End Try - - If file.EndOfData Then - file.Close() - Return False - End If - - str = file.ReadToEnd - - file.Close() - - Try - Content = JsonConvert.DeserializeObject(str, Content.GetType) - Catch ex As Exception - Return False - End Try - - Return True - End Function ''' <summary> ''' Writes the Content variable into a JSON file. diff --git a/VECTO/MainModule.vb b/VECTO/MainModule.vb index 8796e1298553b7520b48b49a300fcbc98ab9a69b..2c751604f661e67da22b4e450aa02083a5055bb1 100644 --- a/VECTO/MainModule.vb +++ b/VECTO/MainModule.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.IO Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.Models.SimulationComponent.Data Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine @@ -20,35 +21,20 @@ Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Module MainModule Public JobFileList As List(Of String) - Public Function ConvertToEngineData(fld As EngineFullLoadCurve, nIdle As Single) As CombustionEngineData + Public Function ConvertToEngineData(fld As EngineFullLoadCurve, nIdle As PerSecond) As CombustionEngineData Dim retVal As CombustionEngineData = New CombustionEngineData() - retVal.FullLoadCurve = New TUGraz.VectoCore.Models.SimulationComponent.Data.Engine.EngineFullLoadCurve() - retVal.FullLoadCurve.FullLoadEntries = New List(Of FullLoadCurve.FullLoadCurveEntry) - For i As Integer = 0 To fld.EngineSpeedList.Count - 1 - retVal.FullLoadCurve.FullLoadEntries.Add( - New FullLoadCurve.FullLoadCurveEntry() _ - With {.EngineSpeed = CType(fld.EngineSpeedList(i), Double).RPMtoRad(), - .TorqueFullLoad = CType(fld.MaxTorqueList(i), Double).SI(Of NewtonMeter)(), - .TorqueDrag = CType(fld.DragTorqueList(i), Double).SI(Of NewtonMeter)()}) - Next - - retVal.IdleSpeed = CType(nIdle, Double).RPMtoRad() + retVal.FullLoadCurve = fld + retVal.IdleSpeed = nIdle Return retVal End Function - Public Function ConvPicPath(hdVclass As String, isLongHaul As Boolean) As Bitmap - Dim longHaulFlag As String = "" - If isLongHaul Then - longHaulFlag = "t" - End If - + Public Function ConvPicPath(hdVclass As Integer, isLongHaul As Boolean) As Bitmap Select Case hdVclass Case 1, 2, 3 Return My.Resources._4x2r ' resourcePath & "4x2r.png" Case 4 If isLongHaul Then Return My.Resources._4x2rt - Return My.Resources._4x2r 'resourcePath & "4x2r" & longHaulFlag & ".png" Case 5 Return My.Resources._4x2tt ' resourcePath & "4x2tt.png" @@ -62,4 +48,13 @@ Module MainModule End Select End Function + Public Function GetRelativePath(filePath As String, basePath As String) As String + If (String.IsNullOrEmpty(filePath) OrElse String.IsNullOrEmpty(basePath)) Then + Return "" + End If + If (Path.GetDirectoryName(filePath).Equals(basePath, StringComparison.OrdinalIgnoreCase)) Then + Return Path.GetFileName(filePath) + End If + Return filePath + End Function End Module diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index db7fea4f09c165e2c734ca51ac73364d39df7116..7343c3210e32bddf930e2a33abc75cf098c4a15c 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -47,11 +47,13 @@ <DefineTrace>false</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <DocumentationFile>VECTO.xml</DocumentationFile> - <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> + <NoWarn> + </NoWarn> <Prefer32Bit>false</Prefer32Bit> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <WarningLevel>1</WarningLevel> <UseVSHostingProcess>true</UseVSHostingProcess> + <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>None</DebugType> @@ -60,11 +62,13 @@ <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DocumentationFile>VECTO.xml</DocumentationFile> - <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> + <NoWarn> + </NoWarn> <RemoveIntegerChecks>false</RemoveIntegerChecks> <PlatformTarget>AnyCPU</PlatformTarget> <Prefer32Bit>false</Prefer32Bit> <WarningLevel>1</WarningLevel> + <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors> </PropertyGroup> <PropertyGroup> <ApplicationManifest>My Project\app.manifest</ApplicationManifest> @@ -75,7 +79,8 @@ <DefineTrace>true</DefineTrace> <OutputPath>bin\x86\Debug\</OutputPath> <DocumentationFile>VECTO.xml</DocumentationFile> - <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> + <NoWarn> + </NoWarn> <DebugType>full</DebugType> <PlatformTarget>x86</PlatformTarget> <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets> @@ -83,12 +88,14 @@ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> <Prefer32Bit>false</Prefer32Bit> <WarningLevel>1</WarningLevel> + <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <DefineTrace>true</DefineTrace> <OutputPath>bin\x86\Release\</OutputPath> <DocumentationFile>VECTO.xml</DocumentationFile> - <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> + <NoWarn> + </NoWarn> <DebugType>None</DebugType> <PlatformTarget>x86</PlatformTarget> <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets> @@ -96,6 +103,7 @@ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> <Prefer32Bit>false</Prefer32Bit> <WarningLevel>1</WarningLevel> + <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors> </PropertyGroup> <PropertyGroup> <ManifestCertificateThumbprint>B392FDC8053AEBCC6B0860DD32DEC702EB46BD4A</ManifestCertificateThumbprint> @@ -115,11 +123,15 @@ <PropertyGroup> <SignAssembly>false</SignAssembly> </PropertyGroup> + <PropertyGroup> + <OptionStrict>On</OptionStrict> + </PropertyGroup> <ItemGroup> <Reference Include="itextsharp, Version=5.5.9.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\iTextSharp.5.5.9\lib\itextsharp.dll</HintPath> </Reference> + <Reference Include="Microsoft.Build.Framework" /> <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> @@ -129,6 +141,7 @@ <HintPath>..\packages\NLog.4.2.3\lib\net45\NLog.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> <Reference Include="System.Deployment" /> <Reference Include="System.Design" /> @@ -156,7 +169,7 @@ <ItemGroup> <Compile Include="ApplicationEvents.vb" /> <Compile Include="Input Files\AdvancedAuxiliary.vb" /> - <Compile Include="JSONparser.vb" /> + <Compile Include="JSONWriter.vb" /> <Compile Include="GUI\FileSignDialog.Designer.vb"> <DependentUpon>FileSignDialog.vb</DependentUpon> </Compile> @@ -228,8 +241,6 @@ <Compile Include="File Browser\FileBrowserFavoritesDialog.vb"> <SubType>Form</SubType> </Compile> - <Compile Include="Input Files\EngineFullLoadCurve.vb" /> - <Compile Include="Input Files\FuelconsumptionMap.vb" /> <Compile Include="Input Files\VectoJob.vb" /> <Compile Include="Input Files\Vehicle.vb" /> <Compile Include="GUI\GearboxGearDialog.Designer.vb"> @@ -245,7 +256,6 @@ <Compile Include="GUI\VectoJobForm.vb"> <SubType>Form</SubType> </Compile> - <Compile Include="CsvFile.vb" /> <Compile Include="VECTO_Global.vb" /> <Compile Include="VECTO_Types.vb" /> <Compile Include="GUI\GUI_Subs.vb" /> diff --git a/VECTO/VECTO_Global.vb b/VECTO/VECTO_Global.vb index 06fd0798aac2774cb3bb759725b9366e358166f0..c6c48b3deda86246944c20bddeb1b6b12578e40f 100644 --- a/VECTO/VECTO_Global.vb +++ b/VECTO/VECTO_Global.vb @@ -22,7 +22,7 @@ Public Module VECTO_Global Public MyConfPath As String - Public LogFile As cLogFile + Public LogFile As FileLogger 'to ensure correct format for backgroundworker thread @@ -30,7 +30,7 @@ Public Module VECTO_Global Public Cfg As Configuration - Public sKey As csKey + 'Public sKey As csKey Public ReadOnly FileFormat As Encoding = Encoding.UTF8 @@ -41,25 +41,14 @@ Public Module VECTO_Global Public ProgBarCtrl As ProgressbarControl - ''' <summary> - ''' Converts engine speed and torque to power. - ''' </summary> - ''' <param name="nU">engine speed</param> - ''' <param name="M">Torque</param> - ''' <returns>Power</returns> - ''' <remarks></remarks> - Public Function nMtoPe(nU As Double, M As Double) As Double - Return (nU * 2 * Math.PI / 60) * M / 1000 - End Function - - Public Class cLogFile - Private LOGstream As StreamWriter + Public Class FileLogger + Private _logStream As StreamWriter Public Function StartLog() As Boolean Try - LOGstream = My.Computer.FileSystem.OpenTextFileWriter(MyAppPath & "LOG.txt", True, FileFormat) - LOGstream.AutoFlush = True + _logStream = My.Computer.FileSystem.OpenTextFileWriter(MyAppPath & "LOG.txt", True, FileFormat) + _logStream.AutoFlush = True WriteToLog(MessageType.Normal, "Starting Session " & Now) WriteToLog(MessageType.Normal, "VECTO " & VECTOvers) Catch ex As Exception @@ -71,7 +60,7 @@ Public Module VECTO_Global Public Function SizeCheck() As Boolean Dim logfDetail As FileInfo - Dim BackUpError As Boolean + Dim backUpError As Boolean 'Start new log if file size limit reached If File.Exists(MyAppPath & "LOG.txt") Then @@ -83,20 +72,20 @@ Public Module VECTO_Global If logfDetail.Length / (2 ^ 20) > Cfg.LogSize Then WriteToLog(MessageType.Normal, "Starting new logfile") - LOGstream.Close() + _logStream.Close() - BackUpError = False + backUpError = False Try If File.Exists(MyAppPath & "LOG_backup.txt") Then File.Delete(MyAppPath & "LOG_backup.txt") File.Move(MyAppPath & "LOG.txt", MyAppPath & "LOG_backup.txt") Catch ex As Exception - BackUpError = True + backUpError = True End Try If Not StartLog() Then Return False - If BackUpError Then + If backUpError Then WriteToLog(MessageType.Err, "Failed to backup logfile! (" & MyAppPath & "LOG_backup.txt)") Else WriteToLog(MessageType.Normal, "Logfile restarted. Old log saved to LOG_backup.txt") @@ -112,7 +101,7 @@ Public Module VECTO_Global Public Function CloseLog() As Boolean Try WriteToLog(MessageType.Normal, "Closing Session " & Now) - LOGstream.Close() + _logStream.Close() Catch ex As Exception Return False End Try @@ -121,20 +110,20 @@ Public Module VECTO_Global End Function - Public Function WriteToLog(MsgType As MessageType, Msg As String) As Boolean - Dim MsgTypeStr As String + Public Function WriteToLog(msgType As MessageType, msg As String) As Boolean + Dim msgTypeStr As String - Select Case MsgType + Select Case msgType Case MessageType.Err - MsgTypeStr = "Error" + msgTypeStr = "Error" Case MessageType.Warn - MsgTypeStr = "Warning" + msgTypeStr = "Warning" Case Else - MsgTypeStr = "-" + msgTypeStr = "-" End Select Try - LOGstream.WriteLine(Now.ToString("yyyy/MM/dd-HH:mm:ss") & vbTab & MsgTypeStr & vbTab & Msg) + _logStream.WriteLine(Now.ToString("yyyy/MM/dd-HH:mm:ss") & vbTab & msgTypeStr & vbTab & msg) Return True Catch ex As Exception Return False @@ -145,9 +134,9 @@ Public Module VECTO_Global #Region "File path functions" 'When no path is specified, then insert either HomeDir or MainDir Special-folders - Public Function fFileRepl(file As String, Optional ByVal MainDir As String = "") As String + Public Function FileRepl(file As String, Optional ByVal mainDir As String = "") As String - Dim ReplPath As String + Dim replPath As String 'Trim Path file = Trim(file) @@ -156,20 +145,20 @@ Public Module VECTO_Global If file = "" Then Return "" 'Replace sKeys - file = Replace(file, sKey.DefVehPath & "\", MyAppPath & "Default Vehicles\", 1, -1, + file = Replace(file, DefVehPath & "\", MyAppPath & "Default Vehicles\", 1, -1, CompareMethod.Text) - file = Replace(file, sKey.HomePath & "\", MyAppPath, 1, -1, CompareMethod.Text) + file = Replace(file, HomePath & "\", MyAppPath, 1, -1, CompareMethod.Text) 'Replace - Determine folder - If MainDir = "" Then - ReplPath = MyAppPath + If mainDir = "" Then + replPath = MyAppPath Else - ReplPath = MainDir + replPath = mainDir End If ' "..\" => One folder-level up - Do While ReplPath.Length > 0 AndAlso Left(file, 3) = "..\" - ReplPath = fPathUp(ReplPath) + Do While replPath.Length > 0 AndAlso Left(file, 3) = "..\" + replPath = PathUp(replPath) file = file.Substring(3) Loop @@ -177,7 +166,7 @@ Public Module VECTO_Global 'Supplement Path, if not available If GetPath(file) = "" Then - Return ReplPath & file + Return replPath & file Else Return file @@ -185,22 +174,22 @@ Public Module VECTO_Global End Function 'Path one-level-up "C:\temp\ordner1\" >> "C:\temp\" - Private Function fPathUp(Pfad As String) As String - Dim x As Int16 + Private Function PathUp(pfad As String) As String + Dim x As Integer - Pfad = Pfad.Substring(0, Pfad.Length - 1) + pfad = pfad.Substring(0, pfad.Length - 1) - x = Pfad.LastIndexOf("\") + x = pfad.LastIndexOf("\", StringComparison.Ordinal) If x = -1 Then Return "" - Return Pfad.Substring(0, x + 1) + Return pfad.Substring(0, x + 1) End Function 'File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" Public Function GetFilenameWithoutPath(file As String, includeFileExtension As Boolean) As String _ 'GetFilenameWithoutPath - Dim x As Int16 + Dim x As Integer x = file.LastIndexOf("\", StringComparison.Ordinal) + 1 file = Right(file, Len(file) - x) If Not includeFileExtension Then @@ -239,7 +228,7 @@ Public Module VECTO_Global 'Extension alone "C:\temp\TEST.txt" >> ".txt" Public Function GetExtension(file As String) As String 'GetExtension - Dim x As Int16 + Dim x As Integer x = file.LastIndexOf(".", StringComparison.Ordinal) If x = -1 Then Return "" @@ -253,26 +242,42 @@ Public Module VECTO_Global End Module -Public Class csKey - Public ReadOnly AUX As csKeyAux +Module Constants + 'Public ReadOnly AUX As AuxiliaryKey + + Public Const HomePath As String = "<HOME>" + Public Const DefVehPath As String = "<VEHDIR>" + Public Const NoFile As String = "<NOFILE>" + + 'Public Sub New() + + ' AUX = New AuxiliaryKey + 'End Sub + + + ' ReSharper disable once ClassNeverInstantiated.Global + +End Module + + + + + + + + + + + + + + + + - Public HomePath As String = "<HOME>" - Public DefVehPath As String = "<VEHDIR>" - Public NoFile As String = "<NOFILE>" - Public Sub New() - AUX = New csKeyAux - End Sub - Public Class csKeyAux - Public Fan As String = "FAN" - Public SteerPump As String = "STP" - Public HVAC As String = "AC" - Public ElecSys As String = "ES" - Public PneumSys As String = "PS" - End Class -End Class diff --git a/VECTO/VECTO_Types.vb b/VECTO/VECTO_Types.vb index f3bddb403e9c8de3c4bf71e78a20766a12a30e16..76140e455fcea745bba9f75b580334715a3357cf 100644 --- a/VECTO/VECTO_Types.vb +++ b/VECTO/VECTO_Types.vb @@ -8,22 +8,20 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. -Option Infer On +'Option Infer On -Imports System.Collections.Generic -Imports System.Linq ''' <summary> ''' Determines how file extensions are set in the File Browser ''' </summary> ''' <remarks></remarks> -Public Enum tFbExtMode As Integer +Public Enum FileBrowserFileExtensionMode As Integer ForceExt = 0 MultiExt = 1 SingleExt = 2 End Enum -Public Enum tWorkMsgType +Public Enum WorkerMessageType StatusBar StatusListBox ProgBars diff --git a/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs b/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs index 502b8e1b8c22b349c5534b3794b3b59566ee201a..8dd07914048d2566ef171fbaa9cb9b7720836f7a 100644 --- a/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs +++ b/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs @@ -75,7 +75,7 @@ namespace TUGraz.VectoCommon.Exceptions Response = (IResponse)info.GetValue("Response", typeof(IResponse)); } - public IResponse Response; + public readonly IResponse Response; public UnexpectedResponseException(string message, IResponse resp) : base(message + Environment.NewLine + "{0}", resp) diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index 7820aa09230cd7d82924e8a1745d928af7141a40..bbc06175f338f3274c583030474c2d43f37ca4ea 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -30,7 +30,6 @@ */ using System.Collections.Generic; -using System.Data; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -47,6 +46,10 @@ namespace TUGraz.VectoCommon.InputData public interface IComponentInputData { + DataSourceType SourceType { get; } + + string Source { get; } + bool SavedInDeclarationMode { get; } string Vendor { get; } @@ -129,7 +132,7 @@ namespace TUGraz.VectoCommon.InputData /// P057, P058 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable LossMap { get; } + TableData LossMap { get; } } public interface IAngularGearInputData : IComponentInputData @@ -147,7 +150,7 @@ namespace TUGraz.VectoCommon.InputData /// <summary> /// P173, P174, P175 /// </summary> - DataTable LossMap { get; } + TableData LossMap { get; } /// <summary> /// P177 @@ -215,7 +218,7 @@ namespace TUGraz.VectoCommon.InputData /// P096, P097, P098 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable LossMap { get; } + TableData LossMap { get; } /// <summary> /// P079 @@ -239,7 +242,7 @@ namespace TUGraz.VectoCommon.InputData /// P093, P094, P095 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable ShiftPolygon { get; } + TableData ShiftPolygon { get; } ///// <summary> ///// P077 @@ -261,7 +264,7 @@ namespace TUGraz.VectoCommon.InputData /// P096, P097, P098 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable LossMap { get; } + TableData LossMap { get; } /// <summary> /// P079 @@ -278,7 +281,7 @@ namespace TUGraz.VectoCommon.InputData /// cf. VECTO Input Parameters.xlsx /// </summary> // ReSharper disable once InconsistentNaming - DataTable TCData { get; } + TableData TCData { get; } } public interface IEngineDeclarationInputData : IComponentInputData @@ -313,20 +316,25 @@ namespace TUGraz.VectoCommon.InputData /// </summary> double WHTCUrban { get; } + /// <summary> + /// P159 + /// </summary> + double ColdHotBalancingFactor { get; } + /// <summary> /// P067 /// P072, P073, P074 /// cf. VECTO Input Parameters.xlsx /// engine speed in rpm, torque in NM, fuel consumption in g/h /// </summary> - DataTable FuelConsumptionMap { get; } + TableData FuelConsumptionMap { get; } /// <summary> /// P144 /// P068, P069, P70, P71 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable FullLoadCurve { get; } + TableData FullLoadCurve { get; } } public interface IAuxiliariesDeclarationInputData @@ -344,7 +352,7 @@ namespace TUGraz.VectoCommon.InputData /// P028, P029, P030, P031, P032, P119, P120, P121, P122, P123, P124, P125, P126 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable CycleData { get; } + TableData CycleData { get; } } public interface IDriverDeclarationInputData diff --git a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs index e8c7d4a14eb7bb77b80c2f9a1bfc6d59b49c35ce..538ed4e621c1cc252cb7fc9c17b13da03ea84143 100644 --- a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs +++ b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs @@ -31,7 +31,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Data; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -92,7 +91,7 @@ namespace TUGraz.VectoCommon.InputData /// P055, P056 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable CrosswindCorrectionMap { get; } + TableData CrosswindCorrectionMap { get; } } public interface IPTOTransmissionInputData @@ -105,9 +104,9 @@ namespace TUGraz.VectoCommon.InputData /// <summary> /// The PTO Loss map for idling losses of the "consumer" part. /// </summary> - DataTable PTOLossMap { get; } + TableData PTOLossMap { get; } - DataTable PTOCycle { get; } + TableData PTOCycle { get; } } public interface IAxleEngineeringInputData : IAxleDeclarationInputData @@ -219,7 +218,7 @@ namespace TUGraz.VectoCommon.InputData /// </summary> KilogramSquareMeter Inertia { get; } - DataTable ShiftPolygon { get; } + TableData ShiftPolygon { get; } } public interface IEngineEngineeringInputData : IEngineDeclarationInputData @@ -258,7 +257,7 @@ namespace TUGraz.VectoCommon.InputData /// P009; P033, P034, P035 /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable AccelerationCurve { get; } + TableData AccelerationCurve { get; } ILookaheadCoastingInputData Lookahead { get; } } @@ -322,16 +321,17 @@ namespace TUGraz.VectoCommon.InputData /// P021 /// cf. VECTO Input Parameters.xlsx /// </summary> - //MeterPerSecond MinSpeed { get; } + MeterPerSecond MinSpeed { get; } + double CoastingDecisionFactorOffset { get; } double CoastingDecisionFactorScaling { get; } double LookaheadDistanceFactor { get; } - DataTable CoastingDecisionFactorTargetSpeedLookup { get; } + TableData CoastingDecisionFactorTargetSpeedLookup { get; } - DataTable CoastingDecisionFactorVelocityDropLookup { get; } + TableData CoastingDecisionFactorVelocityDropLookup { get; } } public interface IAuxiliaryEngineeringInputData @@ -369,7 +369,7 @@ namespace TUGraz.VectoCommon.InputData /// P025, P026, P027 Aux-InputFile: map /// cf. VECTO Input Parameters.xlsx /// </summary> - DataTable DemandMap { get; } + TableData DemandMap { get; } /// <summary> /// P178 diff --git a/VectoCommon/VectoCommon/InputData/TableData.cs b/VectoCommon/VectoCommon/InputData/TableData.cs new file mode 100644 index 0000000000000000000000000000000000000000..218a4f67a3f2047322a64e879e65d585113c9022 --- /dev/null +++ b/VectoCommon/VectoCommon/InputData/TableData.cs @@ -0,0 +1,23 @@ +using System.Data; + +namespace TUGraz.VectoCommon.InputData +{ + public class TableData : DataTable + { + public TableData(string fileName) + { + SourceType = DataSourceType.CSVFile; + Source = fileName; + } + + public TableData() + { + SourceType = DataSourceType.Embedded; + Source = ""; + } + + public DataSourceType SourceType { get; protected set; } + + public string Source { get; protected set; } + } +} \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Models/AuxiliaryModel.cs b/VectoCommon/VectoCommon/Models/AuxiliaryModel.cs index e7b39dc8d5589eb98a3e2b3c958730a4357bfaa6..f86b29c2a24cb9e36267f4e880474afbe2858538 100644 --- a/VectoCommon/VectoCommon/Models/AuxiliaryModel.cs +++ b/VectoCommon/VectoCommon/Models/AuxiliaryModel.cs @@ -37,7 +37,7 @@ namespace TUGraz.VectoCommon.Models Advanced } - public class AuxiliaryModelHelper + public static class AuxiliaryModelHelper { public static AuxiliaryModel Parse(string auxAssemblyStr) { diff --git a/VectoCommon/VectoCommon/Models/AxleConfiguration.cs b/VectoCommon/VectoCommon/Models/AxleConfiguration.cs index 031f88e587ce326875103705f7417bb873d91e4f..7317e3aa7af5f7278b44a57dd5a503f6b92e245c 100644 --- a/VectoCommon/VectoCommon/Models/AxleConfiguration.cs +++ b/VectoCommon/VectoCommon/Models/AxleConfiguration.cs @@ -68,5 +68,24 @@ namespace TUGraz.VectoCommon.Models { return (Prefix + typeString).ParseEnum<AxleConfiguration>(); } + + public static int NumAxles(this AxleConfiguration self) + { + switch (self) { + case AxleConfiguration.AxleConfig_4x2: + case AxleConfiguration.AxleConfig_4x4: + return 2; + case AxleConfiguration.AxleConfig_6x2: + case AxleConfiguration.AxleConfig_6x4: + case AxleConfiguration.AxleConfig_6x6: + return 3; + case AxleConfiguration.AxleConfig_8x2: + case AxleConfiguration.AxleConfig_8x4: + case AxleConfiguration.AxleConfig_8x6: + case AxleConfiguration.AxleConfig_8x8: + return 4; + } + return 0; + } } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Models/IResponse.cs b/VectoCommon/VectoCommon/Models/IResponse.cs index ce8922fc0c44e63638861fd0c81a2fe6ace2e5b1..f2252936aae39d16abd00544e7393fb1a8e0e9d1 100644 --- a/VectoCommon/VectoCommon/Models/IResponse.cs +++ b/VectoCommon/VectoCommon/Models/IResponse.cs @@ -29,7 +29,6 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCommon.Models diff --git a/VectoCommon/VectoCommon/Models/VehicleCategory.cs b/VectoCommon/VectoCommon/Models/VehicleCategory.cs index 609a21b2efc6b32ceb6b27b949b186910ed269b8..0b8bf3e37789f94e201675cfeb4ca6b1ffeabeb9 100644 --- a/VectoCommon/VectoCommon/Models/VehicleCategory.cs +++ b/VectoCommon/VectoCommon/Models/VehicleCategory.cs @@ -29,8 +29,6 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; - namespace TUGraz.VectoCommon.Models { public enum VehicleCategory diff --git a/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs index fb05531236dd1278e35c5803fe0fee2b32b168de..57684ac528cd3fb360efae0e70725d651bd5612f 100644 --- a/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; namespace TUGraz.VectoCommon.Utils @@ -184,11 +185,6 @@ namespace TUGraz.VectoCommon.Utils return SI<MeterPerSecond>(self / 3.6); } - public static PerSecond RadToRPM(this double self) - { - return SI<PerSecond>(self * 60.0 / (2 * Math.PI)); - } - public static double ToDegree(this double self) { return self * 180.0 / Math.PI; @@ -215,6 +211,11 @@ namespace TUGraz.VectoCommon.Utils { return self.Select(x => x.SI<T>()); } + + public static string ToGUIFormat(this double self) + { + return self.ToString(CultureInfo.InvariantCulture); + } } public static class FloatExtensionMethods @@ -225,4 +226,12 @@ namespace TUGraz.VectoCommon.Utils return SIBase<T>.Create(value); } } + + public static class IntegerExtensionMethods + { + public static string ToGUIFormat(this int self) + { + return self.ToString(); + } + } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs index 6ccdbe2f4b6aedad66ecf7758064e3d1747acdcd..666526060e53e3b4a7479f161d1c7d9021159985 100644 --- a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs @@ -55,6 +55,7 @@ namespace TUGraz.VectoCommon.Utils return false; } + // ReSharper disable once LoopCanBeConvertedToQuery for (var i = 0; i < self.Length; i++) { if (self[i].CompareTo(other[i]) != 0) { return self.OrderBy(x => x).SequenceEqual(other.OrderBy(x => x)); diff --git a/VectoCommon/VectoCommon/Utils/SI.cs b/VectoCommon/VectoCommon/Utils/SI.cs index 30bfd20894b3e46a461c4433e519d547fe80678e..c51e9f87f2489d9535db969240c1bdb28d0f66f8 100644 --- a/VectoCommon/VectoCommon/Utils/SI.cs +++ b/VectoCommon/VectoCommon/Utils/SI.cs @@ -611,7 +611,7 @@ namespace TUGraz.VectoCommon.Utils /// <summary> /// SI Class for one per second [1/s]. /// </summary> - [DebuggerDisplay("rad/s: {this} | rpm: {ConvertTo().Rounds.Per.Minute}")] + [DebuggerDisplay("rad/s: {Val} | rpm: {AsRPM}")] public class PerSecond : SIBase<PerSecond> { private static readonly Unit[] DenominatorDefault = { Unit.s }; @@ -628,7 +628,7 @@ namespace TUGraz.VectoCommon.Utils /// <summary> /// SI Class for Meter per second [m/s]. /// </summary> - [DebuggerDisplay("{this} | {ConvertTo().Kilo.Meter.Per.Hour}")] + [DebuggerDisplay("{Val} | {AsKmph}")] public class MeterPerSecond : SIBase<MeterPerSecond> { private static readonly Unit[] NumeratorDefault = { Unit.m }; @@ -637,10 +637,11 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private MeterPerSecond(double val) : base(val, NumeratorDefault, DenominatorDefault) {} - public double AsKmph() + public double AsKmph { - return Val * 3.6; + get { return Val * 3.6; } } + /// <summary> /// Implements the operator /. /// </summary> @@ -833,8 +834,9 @@ namespace TUGraz.VectoCommon.Utils /// <param name="val">The value of the SI object.</param> public static T Create(double val) { - if (val == 0) + if (val == 0) { return ZeroPrototype; + } return Constructor(val); } @@ -1905,18 +1907,27 @@ namespace TUGraz.VectoCommon.Utils /// <summary> /// Returns the Unit Part of the SI Unit Expression. /// </summary> - private string GetUnitString() + public string GetUnitString() { if (Denominator.Any()) { if (Numerator.Any()) { - return string.Concat(Numerator) + "/" + string.Concat(Denominator); - } else { - return "1/" + string.Concat(Denominator); + return string.Concat( + Numerator.GroupBy(x => x) + .Select(x => x.Count() == 1 ? x.Key.ToString() : string.Format("{0}^{1}", x.Key, x.Count()))) + + "/" + + string.Concat( + Denominator.GroupBy(x => x) + .Select(x => x.Count() == 1 ? x.Key.ToString() : string.Format("{0}^{1}", x.Key, x.Count()))); } + return "1/" + string.Concat( + Denominator.GroupBy(x => x) + .Select(x => x.Count() == 1 ? x.Key.ToString() : string.Format("{0}^{1}", x.Key, x.Count()))); } if (Numerator.Any()) { - return string.Concat(Numerator); + return string.Concat( + Numerator.GroupBy(x => x) + .Select(x => x.Count() == 1 ? x.Key.ToString() : string.Format("{0}^{1}", x.Key, x.Count()))); } return "-"; @@ -2183,7 +2194,7 @@ namespace TUGraz.VectoCommon.Utils /// </returns> public int CompareTo(object obj) { - var si = (obj as SI); + var si = obj as SI; if (si == null) { return 1; } @@ -2249,5 +2260,10 @@ namespace TUGraz.VectoCommon.Utils return (Val * outputFactor.Value).ToString("F" + decimals.Value, CultureInfo.InvariantCulture); } + + public string ToGUIFormat() + { + return Val.ToGUIFormat(); + } } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs index 5c56ba1f5587541588b11ebd3a6394c39b7c74d6..c78ef4f209e0316489f28fd52d58eae4ca1b015e 100644 --- a/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs @@ -51,6 +51,18 @@ namespace TUGraz.VectoCommon.Utils } } + public static int ToInt(this string self, int? defaultValue = null) + { + try { + return int.Parse(self, CultureInfo.InvariantCulture); + } catch (FormatException) { + if (defaultValue.HasValue) { + return defaultValue.Value; + } + throw; + } + } + public static bool ToBoolean(this string self) { if (string.IsNullOrEmpty(self)) { diff --git a/VectoCommon/VectoCommon/Utils/Validation.cs b/VectoCommon/VectoCommon/Utils/Validation.cs index 860cb375033f47bc1ebcac4f294550bbd3b3b89e..2ab037be88e735995b47090c0ce627e5a6dfc1f3 100644 --- a/VectoCommon/VectoCommon/Utils/Validation.cs +++ b/VectoCommon/VectoCommon/Utils/Validation.cs @@ -54,6 +54,8 @@ namespace TUGraz.VectoCommon.Utils /// <returns>Null, if the validation was successfull. Otherwise a list of ValidationResults with the ErrorMessages.</returns> public static IList<ValidationResult> Validate<T>(this T entity, ExecutionMode mode) { + if (entity == null) + return new[] { new ValidationResult(string.Format("null value given for {0}", typeof(T)))}; var context = new ValidationContext(entity); context.ServiceContainer.AddService(typeof(ExecutionMode), new ExecutionModeServiceContainer(mode)); var results = new List<ValidationResult>(); @@ -167,11 +169,29 @@ namespace TUGraz.VectoCommon.Utils if (enumerable != null) { var i = 0; foreach (var element in enumerable) { - var results = element.Validate(mode); - if (results.Any()) { - return new ValidationResult( - string.Format("{1}[{0}] in {1} invalid: {2}", i, validationContext.DisplayName, - string.Join("\n", results))); + if (element != null) { + var valueType = element.GetType(); + if (valueType.IsGenericType) { + var baseType = valueType.GetGenericTypeDefinition(); + if (baseType == typeof(KeyValuePair<,>)) { + var kvResults = new List<ValidationResult>(); + kvResults.AddRange(valueType.GetProperty("Key").GetValue(element).Validate(mode)); + kvResults.AddRange(valueType.GetProperty("Value").GetValue(element).Validate(mode)); + if (kvResults.Any()) { + return new ValidationResult( + string.Format("{1}[{0}] in {1} invalid: {2}", valueType.GetProperty("Key").GetValue(element), + validationContext.DisplayName, + string.Join("\n", kvResults))); + } + } + } + + var results = element.Validate(mode); + if (results.Any()) { + return new ValidationResult( + string.Format("{1}[{0}] in {1} invalid: {2}", i, validationContext.DisplayName, + string.Join("\n", results))); + } } i++; } @@ -198,6 +218,7 @@ namespace TUGraz.VectoCommon.Utils public class SIRangeAttribute : RangeAttribute { private ExecutionMode? _mode; + private string _unit = "-"; /// <summary> /// Checks the Min-Max Range of SI Objects. @@ -233,7 +254,6 @@ namespace TUGraz.VectoCommon.Utils /// </summary> /// <param name="minimum">The minimum.</param> /// <param name="maximum">The maximum.</param> - /// <param name="mode">if specified the validation is only performed in the corresponding mode</param> public SIRangeAttribute(double minimum, double maximum) : base(minimum, maximum) {} /// <summary> @@ -252,7 +272,6 @@ namespace TUGraz.VectoCommon.Utils /// </summary> /// <param name="minimum">The minimum.</param> /// <param name="maximum">The maximum.</param> - /// <param name="mode">if specified the validation is only performed in the corresponding mode</param> public SIRangeAttribute(SI minimum, SI maximum) : base(minimum.Value(), maximum.Value()) {} /// <summary> @@ -267,6 +286,10 @@ namespace TUGraz.VectoCommon.Utils { var si = value as SI; + if (si != null) { + _unit = si.GetUnitString(); + } + var modeService = validationContext.GetService(typeof(ExecutionMode)) as ExecutionModeServiceContainer; var mode = modeService == null ? (ExecutionMode?)null : modeService.Mode; if (mode == null) { @@ -277,6 +300,13 @@ namespace TUGraz.VectoCommon.Utils } return ValidationResult.Success; } + + public override string FormatErrorMessage(string name) + { + const string unitString = "{0} [{1}]"; + return string.Format(ErrorMessageString, name, string.Format(unitString, Minimum, _unit), + string.Format(unitString, Maximum, _unit)); + } } /// <summary> diff --git a/VectoCommon/VectoCommon/Utils/VectoMath.cs b/VectoCommon/VectoCommon/Utils/VectoMath.cs index a6a0629cd9e84c7be48324a79015def78ff21116..3f801863df03a528c33ed2908dd7a658b35ab3fc 100644 --- a/VectoCommon/VectoCommon/Utils/VectoMath.cs +++ b/VectoCommon/VectoCommon/Utils/VectoMath.cs @@ -154,7 +154,7 @@ namespace TUGraz.VectoCommon.Utils retVal.Add((-b - Math.Sqrt(d)) / (2 * a)); } else { // only one solution possible - retVal.Add((-b / (2 * a))); + retVal.Add(-b / (2 * a)); } return retVal; } @@ -186,7 +186,7 @@ namespace TUGraz.VectoCommon.Utils } var t = tNumer / denom; - return new Point(line1.P1.X + (t * s10X), line1.P1.Y + t * s10Y); + return new Point(line1.P1.X + t * s10X, line1.P1.Y + t * s10Y); } /// <summary> @@ -261,31 +261,17 @@ namespace TUGraz.VectoCommon.Utils return Math.Ceiling(si.Value()).SI<T>(); } - public static List<double> CubicEquationSolver(double A, double B, double C, double D) + public static List<double> CubicEquationSolver(double a, double b, double c, double d) { - //var a = B / A; - //var b = C / A; - //var d = D / A; - - //var p = b / a - a * a / 3; - //var q = 2 * a * a / 27 - a * b / 3 + C; - - //var R = q * q / 4 + p * p * p / 27; - //if (R > 0) { - // // one real and two complex solutions - we are only interested on the real solution - - //} else { - // // three real solutions (two may coincide) - //} var solutions = new List<double>(); - if (A.IsEqual(0, 1e-12)) { - return QuadraticEquationSolver(B, C, D); + if (a.IsEqual(0, 1e-12)) { + return QuadraticEquationSolver(b, c, d); } - var w = B / (3 * A); - var p = Math.Pow(C / (3 * A) - w * w, 3); - var q = -0.5 * (2 * (w * w * w) - (C * w - D) / A); - var d = q * q + p; // discriminant - if (d < 0.0) { + var w = b / (3 * a); + var p = Math.Pow(c / (3 * a) - w * w, 3); + var q = -0.5 * (2 * (w * w * w) - (c * w - d) / a); + var discriminant = q * q + p; + if (discriminant < 0.0) { // 3 real solutions var h = q / Math.Sqrt(-p); var phi = Math.Acos(Math.Max(-1.0, Math.Min(1.0, h))); @@ -295,15 +281,15 @@ namespace TUGraz.VectoCommon.Utils } } else { // only one real solution - d = Math.Sqrt(d); - solutions.Add(Cbrt(q + d) + Cbrt(q - d) - w); + discriminant = Math.Sqrt(discriminant); + solutions.Add(Cbrt(q + discriminant) + Cbrt(q - discriminant) - w); } // 1 Newton iteration step in order to minimize round-off errors for (var i = 0; i < solutions.Count; i++) { - var h = C + solutions[i] * (2 * B + 3 * solutions[i] * A); + var h = c + solutions[i] * (2 * b + 3 * solutions[i] * a); if (!h.IsEqual(0, 1e-12)) { - solutions[i] -= (D + solutions[i] * (C + solutions[i] * (B + solutions[i] * A))) / h; + solutions[i] -= (d + solutions[i] * (c + solutions[i] * (b + solutions[i] * a))) / h; } } solutions.Sort(); @@ -431,10 +417,10 @@ namespace TUGraz.VectoCommon.Utils [DebuggerDisplay("Plane({X}, {Y}, {Z}, {W})")] public class Plane { - public double X; - public double Y; - public double Z; - public double W; + public readonly double X; + public readonly double Y; + public readonly double Z; + public readonly double W; public Plane(double x, double y, double z, double w) { diff --git a/VectoCommon/VectoCommon/VectoCommon.csproj b/VectoCommon/VectoCommon/VectoCommon.csproj index 1132531c6f72d50ca2acd874590b1387f462952e..767d0d4874514eb826aa59d86499fc953d7e02dc 100644 --- a/VectoCommon/VectoCommon/VectoCommon.csproj +++ b/VectoCommon/VectoCommon/VectoCommon.csproj @@ -44,6 +44,10 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="InputData\DataSourceType.cs" /> + <Compile Include="InputData\TableData.cs"> + <SubType>Component</SubType> + </Compile> <Compile Include="Models\AuxiliaryType.cs" /> <Compile Include="Exceptions\VectoExceptions.cs" /> <Compile Include="Exceptions\VectoSimulationException.cs" /> diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index d6bd3f87c8ab7b189d6a28a0898cf4ca7334bc47..493c3c14e6c8e03f778807199aaa210930bb8a29 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -64,29 +64,29 @@ namespace VectoConsole Commandline Interface for Vecto. Synopsis: - vectocmd.exe [-h] [-v] FILE1.(vecto|xml) [FILE2.(vecto|xml) ...] + vectocmd.exe [-h] [-v] FILE1.(vecto|xml) [FILE2.(vecto|xml) ...] Description: - FILE1.vecto [FILE2.vecto ...]: A list of vecto-job files (with the - extension: .vecto). At least one file must be given. Delimited by - whitespace. - - -t: output information about execution times - -mod: write mod-data in addition to sum-data - -1Hz: convert mod-data to 1Hz resolution - -eng: switch to engineering mode (implies -mod) - -v: Shows verbose information (errors and warnings will be displayed) + FILE1.vecto [FILE2.vecto ...]: A list of vecto-job files (with the + extension: .vecto). At least one file must be given. Delimited by + whitespace. + + -t: output information about execution times + -mod: write mod-data in addition to sum-data + -1Hz: convert mod-data to 1Hz resolution + -eng: switch to engineering mode (implies -mod) + -v: Shows verbose information (errors and warnings will be displayed) -vv: Shows more verbose information (infos will be displayed) -vvv: Shows debug messages (slow!) -vvvv: Shows all verbose information (everything, slow!) - -V: show version information - -h: Displays this help. + -V: show version information + -h: Displays this help. Examples: - vecto.exe ""12t Delivery Truck.vecto"" 40t_Long_Haul_Truck.vecto - vecto.exe 24tCoach.vecto 40t_Long_Haul_Truck.vecto - vecto.exe -v 24tCoach.vecto - vecto.exe -v jobs\40t_Long_Haul_Truck.vecto + vecto.exe ""12t Delivery Truck.vecto"" 40t_Long_Haul_Truck.vecto + vecto.exe 24tCoach.vecto 40t_Long_Haul_Truck.vecto + vecto.exe -v 24tCoach.vecto + vecto.exe -v jobs\40t_Long_Haul_Truck.vecto vecto.exe -h "; diff --git a/VectoConsole/Properties/Version.cs b/VectoConsole/Properties/Version.cs index 70953ae2e91733e7f7fb770f74c2d05a3dbebffe..d73061c36d524f677c5b99abd36af77cde2c6177 100644 --- a/VectoConsole/Properties/Version.cs +++ b/VectoConsole/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.0.3.613")] -[assembly: AssemblyFileVersion("3.0.3.613")] +[assembly: AssemblyVersion("3.0.3.628")] +[assembly: AssemblyFileVersion("3.0.3.628")] diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index d8b0f2f0aacfbbd861ec2d399228573b117f09c3..03637f20859940c47e163d128e36be000c004468 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -77,6 +77,11 @@ namespace TUGraz.VectoCore.Configuration public const string EngineDataFile = ".veng"; + public const string VehicleDataFile = ".vveh"; + + public const string GearboxDataFile = ".vgbx"; + + public const string CycleFile = ".vdri"; public const string DriverAccelerationCurve = ".vacc"; diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..e9ec1f8864b116ddd539091e35d6547a709000c6 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs @@ -0,0 +1,139 @@ +using System; +using System.IO; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.JSON +{ + public class JSONComponentInputData : IEngineeringInputDataProvider, IDeclarationInputDataProvider + { + protected IGearboxEngineeringInputData Gearbox; + protected IAxleGearInputData AxleGear; + protected ITorqueConverterEngineeringInputData TorqueConverter; + protected IAngularGearInputData AngularGear; + protected IEngineEngineeringInputData Engine; + protected IVehicleEngineeringInputData VehicleData; + protected IRetarderInputData Retarder; + protected IPTOTransmissionInputData PTOTransmission; + + + public JSONComponentInputData(string filename) + { + var extension = Path.GetExtension(filename); + object tmp = null; + switch (extension) { + case Constants.FileExtensions.VehicleDataFile: + tmp = JSONInputDataFactory.ReadJsonVehicle(filename); + break; + case Constants.FileExtensions.EngineDataFile: + tmp = JSONInputDataFactory.ReadEngine(filename); + break; + case Constants.FileExtensions.GearboxDataFile: + tmp = JSONInputDataFactory.ReadGearbox(filename); + break; + } + tmp.Switch() + .If<IVehicleEngineeringInputData>(c => VehicleData = c) + .If<IEngineEngineeringInputData>(c => Engine = c) + .If<IGearboxEngineeringInputData>(c => Gearbox = c) + .If<IAxleGearInputData>(c => AxleGear = c) + .If<IRetarderInputData>(c => Retarder = c) + .If<ITorqueConverterEngineeringInputData>(c => TorqueConverter = c) + .If<IAngularGearInputData>(c => AngularGear = c) + .If<IPTOTransmissionInputData>(c => PTOTransmission = c); + } + + + public IEngineeringJobInputData JobInputData() + { + throw new NotImplementedException(); + } + + + IVehicleDeclarationInputData IDeclarationInputDataProvider.VehicleInputData + { + get { return VehicleData; } + } + + IGearboxDeclarationInputData IDeclarationInputDataProvider.GearboxInputData + { + get { return GearboxInputData; } + } + + ITorqueConverterDeclarationInputData IDeclarationInputDataProvider.TorqueConverterInputData + { + get { return TorqueConverterInputData; } + } + + IDeclarationJobInputData IDeclarationInputDataProvider.JobInputData() + { + throw new NotImplementedException(); + } + + public IVehicleEngineeringInputData VehicleInputData + { + get { return VehicleData; } + } + + public IGearboxEngineeringInputData GearboxInputData + { + get { return Gearbox; } + } + + public ITorqueConverterEngineeringInputData TorqueConverterInputData + { + get { return TorqueConverter; } + } + + public IAxleGearInputData AxleGearInputData + { + get { return AxleGear; } + } + + public IAngularGearInputData AngularGearInputData + { + get { return AngularGear; } + } + + IEngineDeclarationInputData IDeclarationInputDataProvider.EngineInputData + { + get { return EngineInputData; } + } + + public IEngineEngineeringInputData EngineInputData + { + get { return Engine; } + } + + public IAuxiliariesEngineeringInputData AuxiliaryInputData() + { + throw new NotImplementedException(); + } + + IAuxiliariesDeclarationInputData IDeclarationInputDataProvider.AuxiliaryInputData() + { + throw new NotImplementedException(); + } + + public IRetarderInputData RetarderInputData + { + get { return Retarder; } + } + + IDriverDeclarationInputData IDeclarationInputDataProvider.DriverInputData + { + get { throw new NotImplementedException(); } + } + + public IDriverEngineeringInputData DriverInputData + { + get { return DriverInputData; } + } + + public IPTOTransmissionInputData PTOTransmissionInputData + { + get { return PTOTransmission; } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs index 5dc1b8abaab6434a9e9a0b62aa8f6c0537f1d8d1..a5262b4ca36c2633ce4efd170ea7f04b3d5dbe3f 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs @@ -81,12 +81,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx<double>(JsonKeys.Engine_IdleSpeed).RPMtoRad(); } } - public virtual DataTable FuelConsumptionMap + + public virtual TableData FuelConsumptionMap { get { return ReadTableData(Body.GetEx<string>(JsonKeys.Engine_FuelConsumptionMap), "FuelConsumptionMap"); } } - public virtual DataTable FullLoadCurve + public virtual TableData FullLoadCurve { get { return ReadTableData(Body.GetEx<string>(JsonKeys.Engine_FullLoadCurveFile), "FullLoadCurve"); } } @@ -116,6 +117,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx<double>(JsonKeys.Engine_WHTC_Urban); } } + public double ColdHotBalancingFactor + { + get + { + if (Body["ColdHotBalancingFactor"] == null) { + return 1.0; + } + return Body.GetEx<double>("ColdHotBalancingFactor"); + } + } + public string Vendor { get { return "N/A"; } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs index 8cbf235a751dcf11a371e32c47ea6f0cc00eb350..0ca3625a09604af87ef3d6350374ea21e7739891 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs @@ -66,12 +66,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public override DataTable ShiftPolygon + public override TableData ShiftPolygon { get { return ReadTableData(Body.GetEx(JsonKeys.Gearbox_TorqueConverter) - .GetEx<string>("ShiftPolygon"), "TorqueConverter Shift Polygon"); + .GetEx<string>("ShiftPolygon"), "TorqueConverter Shift Polygon", false); } } } @@ -124,7 +124,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public DataTable LossMap + public TableData LossMap { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] @@ -182,12 +182,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx<double>(JsonKeys.Gearbox_Inertia).SI<KilogramSquareMeter>(); } } - public virtual DataTable ShiftPolygon + public virtual TableData ShiftPolygon { get { return ReadTableData(Body.GetEx(JsonKeys.Gearbox_Gears)[1].GetEx<string>("ShiftPolygon"), - "TorqueConverter Shift Polygon"); + "TorqueConverter Shift Polygon", false); } } @@ -365,13 +365,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual DataTable TCData + public virtual TableData TCData { get { return ReadTableData(Body.GetEx(JsonKeys.Gearbox_TorqueConverter).GetEx<string>(JsonKeys.Gearbox_TorqueConverter_TCMap), - "TorqueConverter Data"); + "TorqueConverter Data", false); } } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index a05c1eceae693849beeb08f3c0ad564e06d51972..c6b764db12e6f025f0e26bfec91969c581e71afd 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { public abstract class JSONFile : LoggingObject { - private string _basePath; + private readonly string _sourceFile; protected readonly JObject Header; protected readonly JObject Body; @@ -59,7 +59,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { Header = (JObject)data.GetEx(JsonKeys.JsonHeader); Body = (JObject)data.GetEx(JsonKeys.JsonBody); - BasePath = filename; + _sourceFile = Path.GetFullPath(filename); + } + + public DataSourceType SourceType + { + get { return DataSourceType.JSONFile; } + } + + public string Source + { + get { return _sourceFile; } } public bool SavedInDeclarationMode @@ -69,11 +79,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON internal string BasePath { - get { return _basePath; } - set { _basePath = Path.GetDirectoryName(Path.GetFullPath(value)); } + get { return Path.GetDirectoryName(_sourceFile); } } - protected DataTable ReadTableData(string filename, string tableType, bool required = true) + protected TableData ReadTableData(string filename, string tableType, bool required = true) { if (!EmptyOrInvalidFileName(filename)) { try { @@ -309,10 +318,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { var retVal = new List<ICycleData>(); + if (Body[JsonKeys.Job_Cycles] == null) { + return retVal; + } foreach (var cycle in Body.GetEx(JsonKeys.Job_Cycles)) { //.Select(cycle => var cycleFile = Path.Combine(BasePath, cycle.Value<string>()); - DataTable cycleData; + TableData cycleData; if (File.Exists(cycleFile)) { cycleData = VectoCSVFile.Read(cycleFile); } else { @@ -400,10 +412,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ? ReadTableData(lac.GetEx<string>("Df_velocityDropLookup"), "Lookahead Coasting Decisionfactor - Velocity drop", false) : null; + var minSpeed = lac["MinSpeed"] != null + ? lac.GetEx<double>(JsonKeys.DriverData_Lookahead_MinSpeed).KMPHtoMeterPerSecond() + : DeclarationData.Driver.LookAhead.MinimumSpeed; return new LookAheadCoastingInputData() { Enabled = lac.GetEx<bool>(JsonKeys.DriverData_Lookahead_Enabled), //Deceleration = lac.GetEx<double>(JsonKeys.DriverData_Lookahead_Deceleration).SI<MeterPerSquareSecond>(), - //MinSpeed = lac.GetEx<double>(JsonKeys.DriverData_Lookahead_MinSpeed).KMPHtoMeterPerSecond(), + MinSpeed = minSpeed, LookaheadDistanceFactor = distanceScalingFactor, CoastingDecisionFactorOffset = lacDfOffset, CoastingDecisionFactorScaling = lacDfScaling, @@ -433,7 +448,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public virtual DataTable AccelerationCurve + public virtual TableData AccelerationCurve { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] @@ -441,7 +456,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { var acceleration = Body[JsonKeys.DriverData_AccelerationCurve]; if (acceleration == null || EmptyOrInvalidFileName(acceleration.Value<string>())) { - throw new VectoException("AccelerationCurve (VACC) required"); + return null; +// throw new VectoException("AccelerationCurve (VACC) required"); } try { return ReadTableData(acceleration.Value<string>(), "DriverAccelerationCurve", false); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs index bbe30049c62d65b3b805d04dab6dae20cab20574..4d0cf7cb515046439d8e257c23f40cdd3acac2b8 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs @@ -29,11 +29,13 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.IO; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.Configuration; namespace TUGraz.VectoCore.InputData.FileIO.JSON { @@ -50,10 +52,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } + public static IInputDataProvider ReadComponentData(string filename) + { + if (Constants.FileExtensions.VectoJobFile.Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase)) { + return ReadJsonJob(filename); + } + return new JSONComponentInputData(filename); + } + public static IInputDataProvider ReadJsonJob(string filename) { var json = ReadFile(filename); var version = ReadVersion(json); + switch (version) { case 2: return new JSONInputDataV2(json, filename); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index 1c0f4846201ab1a828e771953ae0569c63a6b8b0..45c648a28899dbef63415149d2a08323f67fad88 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -87,21 +87,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx<double>(JsonKeys.Vehicle_DragCoefficient).SI<SquareMeter>(); } } - public virtual SquareMeter AirDragAreaRigidTruck - { - get { return Body.GetEx<double>(JsonKeys.Vehicle_DragCoefficientRigidTruck).SI<SquareMeter>(); } - } - public virtual CrossWindCorrectionMode CrossWindCorrectionMode { get { return CrossWindCorrectionModeHelper.Parse(Body.GetEx<string>("CdCorrMode")); } } - public virtual string Rim - { - get { return Body.GetEx<string>(JsonKeys.Vehicle_Rim); } - } - public virtual AxleConfiguration AxleConfiguration { get @@ -127,6 +117,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON return Body.GetEx(JsonKeys.Vehicle_AxleConfiguration).GetEx(JsonKeys.Vehicle_AxleConfiguration_Axles).Select( axle => new AxleInputData { + SourceType = DataSourceType.JSONFile, + Source = Source, Inertia = axle.GetEx<double>(JsonKeys.Vehicle_Axles_Inertia).SI<KilogramSquareMeter>(), Wheels = axle.GetEx<string>(JsonKeys.Vehicle_Axles_Wheels), TwinTyres = axle.GetEx<bool>(JsonKeys.Vehicle_Axles_TwinTyres), @@ -136,9 +128,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON }); } - public virtual DataTable CrosswindCorrectionMap + public virtual TableData CrosswindCorrectionMap { - get { return ReadTableData(Body.GetEx<string>("CdCorrFile"), "CrosswindCorrection File"); } + get { return ReadTableData(Body.GetEx<string>("CdCorrFile"), "CrosswindCorrection File", false); } } #endregion @@ -159,7 +151,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx(JsonKeys.Vehicle_Retarder).GetEx<double>(JsonKeys.Vehicle_Retarder_Ratio); } } - DataTable IRetarderInputData.LossMap + TableData IRetarderInputData.LossMap { get { @@ -167,7 +159,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ReadTableData( Body.GetEx(JsonKeys.Vehicle_Retarder) .GetEx<string>(JsonKeys.Vehicle_Retarder_LossMapFile), - "LossMap"); + "LossMap", false); } } @@ -180,8 +172,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { var angleDrive = Body[JsonKeys.Vehicle_AngularGear]; - if (angleDrive == null) + if (angleDrive == null) { return AngularGearType.None; + } return angleDrive.GetEx<string>(JsonKeys.Vehicle_AngularGear_Type).ParseEnum<AngularGearType>(); } @@ -192,14 +185,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx(JsonKeys.Vehicle_AngularGear).GetEx<double>(JsonKeys.Vehicle_AngularGear_Ratio); } } - DataTable IAngularGearInputData.LossMap + TableData IAngularGearInputData.LossMap { get { return ReadTableData( Body.GetEx(JsonKeys.Vehicle_AngularGear) .GetEx<string>(JsonKeys.Vehicle_AngularGear_LossMapFile), - "LossMap"); + "LossMap", false); } } @@ -224,17 +217,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - DataTable IPTOTransmissionInputData.PTOLossMap + TableData IPTOTransmissionInputData.PTOLossMap { get { - return ReadTableData(Body.GetEx(JsonKeys.Vehicle_PTO).GetEx<string>(JsonKeys.Vehicle_PTO_LossMapFile), "LossMap"); + return ReadTableData(Body.GetEx(JsonKeys.Vehicle_PTO).GetEx<string>(JsonKeys.Vehicle_PTO_LossMapFile), "LossMap", false); } } - public DataTable PTOCycle + public TableData PTOCycle { - get { return ReadTableData(Body.GetEx(JsonKeys.Vehicle_PTO).GetEx<string>(JsonKeys.Vehicle_PTO_Cycle), "Cycle"); } + get { return ReadTableData(Body.GetEx(JsonKeys.Vehicle_PTO).GetEx<string>(JsonKeys.Vehicle_PTO_Cycle), "Cycle", false); } } #endregion diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs index 629584d16b30f220eaf1a4dd7bad6ba270ff5476..a88e4115a9cbdb1cae783bcd71f6ea6d3ed5a9b5 100644 --- a/VectoCore/VectoCore/InputData/Impl/InputData.cs +++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs @@ -41,7 +41,7 @@ namespace TUGraz.VectoCore.InputData.Impl { public string Name { get; internal set; } - public DataTable CycleData { get; internal set; } + public TableData CycleData { get; internal set; } } public class StartStopInputData : IStartStopEngineeringInputData @@ -61,13 +61,13 @@ namespace TUGraz.VectoCore.InputData.Impl //public MeterPerSquareSecond Deceleration { get; internal set; } - //public MeterPerSecond MinSpeed { get; internal set; } + public MeterPerSecond MinSpeed { get; internal set; } public double CoastingDecisionFactorOffset { get; internal set; } public double CoastingDecisionFactorScaling { get; internal set; } public double LookaheadDistanceFactor { get; internal set; } - public DataTable CoastingDecisionFactorTargetSpeedLookup { get; internal set; } - public DataTable CoastingDecisionFactorVelocityDropLookup { get; internal set; } + public TableData CoastingDecisionFactorTargetSpeedLookup { get; internal set; } + public TableData CoastingDecisionFactorVelocityDropLookup { get; internal set; } } public class OverSpeedEcoRollInputData : IOverSpeedEcoRollEngineeringInputData @@ -87,13 +87,13 @@ namespace TUGraz.VectoCore.InputData.Impl public double Ratio { get; internal set; } - public DataTable LossMap { get; internal set; } + public TableData LossMap { get; internal set; } public double Efficiency { get; internal set; } public NewtonMeter MaxTorque { get; internal set; } - public DataTable ShiftPolygon { get; internal set; } + public TableData ShiftPolygon { get; internal set; } } public class AxleInputData : IAxleEngineeringInputData @@ -105,6 +105,10 @@ namespace TUGraz.VectoCore.InputData.Impl get { throw new System.NotImplementedException(); } } + public DataSourceType SourceType { get; internal set; } + + public string Source { get; internal set; } + public string Vendor { get; internal set; } public string ModelName { get; internal set; } @@ -156,7 +160,7 @@ namespace TUGraz.VectoCore.InputData.Impl public double EfficiencyToSupply { get; internal set; } - public DataTable DemandMap { get; internal set; } + public TableData DemandMap { get; internal set; } public Watt ConstantPowerDemand { get; internal set; } } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs index b62094acf4bd7961bed93d908129f652bb508828..d5195cbb30887f59e2bfdf21b84ccdd38e8c4b36 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs @@ -64,6 +64,12 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData /// <returns></returns> public static TransmissionLossMap Create(double efficiency, double gearRatio, string gearName) { + if (efficiency <= 0) { + throw new VectoException("Efficiency for gear {0} must be greater than 0", gearName); + } + if (efficiency > 1) { + throw new VectoException("Efficiency for gear {1} must not be greater than 1", gearName); + } var entries = new List<TransmissionLossMap.GearLossMapEntry> { new TransmissionLossMap.GearLossMapEntry(0.RPMtoRad(), 1e5.SI<NewtonMeter>(), (1 - efficiency) * 1e5.SI<NewtonMeter>()), diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index 4bb0ef3a468bf75b0d913cf96a40b652484935d2..783e7af47f442eb99c4e272d1b575891b742f3a4 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter var lookAheadData = new DriverData.LACData { Enabled = DeclarationData.Driver.LookAhead.Enabled, //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, - //MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, + MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, LookAheadDecisionFactor = new LACDecisionFactor(), LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, }; @@ -151,6 +151,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.WHTCUrban = engine.WHTCUrban; retVal.WHTCMotorway = engine.WHTCMotorway; retVal.WHTCRural = engine.WHTCRural; + retVal.ColdHotCorrectionFactor = engine.ColdHotBalancingFactor; retVal.Inertia = DeclarationData.Engine.EngineInertia(retVal.Displacement, gearboxType); retVal.FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve, true); retVal.FullLoadCurve.EngineData = retVal; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 908289bf36e81080fe2abd95bdcaf2f2b2ade568..dacd50e5cba58e5fe03be89d1ab4311283c222ef 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -127,9 +127,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter var retVal = SetCommonGearboxData(gearbox); //var gears = gearbox.Gears; - if (gearbox.Gears.Count < 1) { + if (gearbox.Gears.Count < 2) { throw new VectoSimulationException( - "At least one Gear-Entry must be defined in Gearbox!"); + "At least two Gear-Entries must be defined in Gearbox!"); } retVal.Inertia = gearbox.Inertia; @@ -142,7 +142,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.StartSpeed = gearbox.StartSpeed; retVal.StartAcceleration = gearbox.StartAcceleration; - var gearDifferenceRatio = gearbox.Gears[0].Ratio / gearbox.Gears[1].Ratio; + var gearDifferenceRatio = gearbox.Type.AutomaticTransmission() && gearbox.Gears.Count > 2 ? + gearbox.Gears[0].Ratio / gearbox.Gears[1].Ratio + : 1.0; var gears = new Dictionary<uint, GearData>(); @@ -273,7 +275,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter var lookAheadData = new DriverData.LACData { Enabled = driver.Lookahead.Enabled, //Deceleration = driver.Lookahead.Deceleration, - //MinSpeed = driver.Lookahead.MinSpeed, + MinSpeed = driver.Lookahead.MinSpeed, LookAheadDecisionFactor = new LACDecisionFactor(driver.Lookahead.CoastingDecisionFactorOffset, driver.Lookahead.CoastingDecisionFactorScaling, driver.Lookahead.CoastingDecisionFactorTargetSpeedLookup, @@ -302,7 +304,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter } //================================= - public RetarderData CreateRetarderData(IRetarderInputData retarder, IVehicleEngineeringInputData vehicle) + public RetarderData CreateRetarderData(IRetarderInputData retarder) { return SetCommonRetarderData(retarder); } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs index 8220d9731d6fdf09cea324e94a5ae2060dafaa7e..475f40b4b69fc0ad8d4790d9a1db8e9eb482bbef 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs @@ -122,7 +122,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl Mission = mission, }; simulationRunData.EngineData.WHTCCorrectionFactor = DeclarationData.WHTCCorrection.Lookup(mission.MissionType, - engineData.WHTCRural, engineData.WHTCUrban, engineData.WHTCMotorway); + engineData.WHTCRural, engineData.WHTCUrban, engineData.WHTCMotorway) * engineData.ColdHotCorrectionFactor; simulationRunData.Cycle.Name = mission.MissionType.ToString(); simulationRunData.VehicleData.VehicleClass = segment.VehicleClass; yield return simulationRunData; diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs index 4ea718fb179e8097c4742b151d5d3277f43d2f4a..d83f066d71cde95be6910d9cce1ca67bfc1f07c9 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs @@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = driver, Aux = dao.CreateAuxiliaryData(InputDataProvider.AuxiliaryInputData()), AdvancedAux = dao.CreateAdvancedAuxData(InputDataProvider.AuxiliaryInputData()), - Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData, InputDataProvider.VehicleInputData), + Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData), PTO = ptoTransmissionData, Cycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, crossWindRequired), ExecutionMode = ExecutionMode.Engineering diff --git a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs index c1f94c0cc4b27a410811a728acddbaec2c9ab632..e037090a0d476dfedeee82a0403a209eb63cedda 100644 --- a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs +++ b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs @@ -15,6 +15,14 @@ namespace TUGraz.VectoCore.Models.Declaration { AuxiliaryType.ElectricSystem, Constants.Auxiliaries.Names.ElectricSystem }, }; + private static readonly Dictionary<AuxiliaryType, string> AuxToKey = new Dictionary<AuxiliaryType, string> { + { AuxiliaryType.Fan, Constants.Auxiliaries.IDs.Fan }, + { AuxiliaryType.SteeringPump, Constants.Auxiliaries.IDs.SteeringPump }, + { AuxiliaryType.HVAC, Constants.Auxiliaries.IDs.HeatingVentilationAirCondition }, + { AuxiliaryType.PneumaticSystem, Constants.Auxiliaries.IDs.PneumaticSystem }, + { AuxiliaryType.ElectricSystem, Constants.Auxiliaries.IDs.ElectricSystem }, + }; + private static readonly Dictionary<string, AuxiliaryType> StrToAux = AuxToStr.ToDictionary(kv => kv.Value, kv => kv.Key); @@ -28,5 +36,20 @@ namespace TUGraz.VectoCore.Models.Declaration { return AuxToStr[t]; } + + public static string GetAuxKey(AuxiliaryType t) + { + return AuxToKey[t]; + } + + public static string Key(this AuxiliaryType t) + { + return AuxToKey[t]; + } + + public static string Name(this AuxiliaryType t) + { + return AuxToStr[t]; + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/Axle.cs b/VectoCore/VectoCore/Models/Declaration/Axle.cs index c902939bb1e7442e90a6ac5542692ebd0d3a6ea8..15b27a6fe1dae4af8c5fe25e6efdea1e8c515f81 100644 --- a/VectoCore/VectoCore/Models/Declaration/Axle.cs +++ b/VectoCore/VectoCore/Models/Declaration/Axle.cs @@ -39,7 +39,7 @@ namespace TUGraz.VectoCore.Models.Declaration { public class Axle : SimulationComponentData { - public object WheelsDimension { get; internal set; } + public string WheelsDimension { get; internal set; } [Required, SIRange(0, 100)] public KilogramSquareMeter Inertia { get; internal set; } @@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.Models.Declaration [Required, SIRange(500, 100000)] public Newton TyreTestLoad { get; internal set; } - [Required, SIRange(Double.MinValue, 1)] + [Required, SIRange(0, 1, ExecutionMode.Engineering), SIRange(double.MinValue, 1, ExecutionMode.Declaration)] public double AxleWeightShare { get; internal set; } public bool TwinTyres { get; internal set; } diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 94fe58d944ad73404e5ac6c6614ef94f3d042757..e7b4064c33310cb30598e77336179bc62dd94ed3 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -195,6 +195,7 @@ namespace TUGraz.VectoCore.Models.Declaration public const double DecisionFactorCoastingOffset = 2.5; public const double DecisionFactorCoastingScaling = 1.5; public const double LookAheadDistanceFactor = 10; + public static readonly MeterPerSecond MinimumSpeed = 50.KMPHtoMeterPerSecond(); } public static class OverSpeedEcoRoll diff --git a/VectoCore/VectoCore/Models/Declaration/Wheels.cs b/VectoCore/VectoCore/Models/Declaration/Wheels.cs index eed2c80c39fa65e46034c926cab6c1cc50d00863..d6d82850b5035c42deda1b6164bd309e271f655b 100644 --- a/VectoCore/VectoCore/Models/Declaration/Wheels.cs +++ b/VectoCore/VectoCore/Models/Declaration/Wheels.cs @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.Models.Declaration protected override string ErrorMessage { - get { return "Auxiliary Lookup Error: No value found for Wheels. Key: '{0}'"; } + get { return "Wheels Lookup Error: No value found for Wheels. Key: '{0}'"; } } public override Entry Lookup(string key) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs index 82e5d44bb4f97ecece54c980879e1bc9bd399750..2b651cdf9d3c915e9e39475034bcf841824c4f01 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs @@ -86,7 +86,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var zValidationRules = new[] { new RangeAttribute(0, 100.SI().Kilo.Watt.Value()) }; var results = new List<ValidationResult>(); - foreach (var entry in data._map.Points) { + foreach (var entry in data._map.Entries) { context.DisplayName = AuxiliaryDataReader.Fields.AuxSpeed; if (!Validator.TryValidateValue(entry.X, context, results, xValidationRules)) { return new ValidationResult(string.Concat(results)); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index 0dccb0c3258c56791a14f95005e7f0778f06d666..843925cacfcbd8223b25c91469852a94a1c86398 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.ComponentModel.DataAnnotations; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; @@ -62,6 +63,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [Required, ValidateObject] public EngineFullLoadCurve FullLoadCurve { get; internal set; } + [Required, Range(double.MinValue, double.MaxValue)] + public double ColdHotCorrectionFactor { get; internal set; } + internal double WHTCCorrectionFactor = 1; public CombustionEngineData() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs index 3ffe87fb9d5bc9daeb3b3f6d598c2ed2c6ec6b57..2825c1cc6a6f89456ee771683e5ccde1d6001ab0 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs @@ -29,8 +29,10 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.ComponentModel.DataAnnotations; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; @@ -38,10 +40,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { public class DriverData { - public VectoRunData.StartStopData StartStop; - public OverSpeedEcoRollData OverSpeedEcoRoll; - public LACData LookAheadCoasting; - public AccelerationCurveData AccelerationCurve; + [Required, ValidateObject] public VectoRunData.StartStopData StartStop; + + [Required, ValidateObject] public OverSpeedEcoRollData OverSpeedEcoRoll; + + [Required, ValidateObject] public LACData LookAheadCoasting; + + [Required, ValidateObject] public AccelerationCurveData AccelerationCurve; public static DriverMode ParseDriverMode(string mode) { @@ -51,19 +56,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public class OverSpeedEcoRollData { public DriverMode Mode; - public MeterPerSecond MinSpeed; - public MeterPerSecond OverSpeed; - public MeterPerSecond UnderSpeed; + + [Required, SIRange(0, 120 / Constants.MeterPerSecondToKMH)] public MeterPerSecond MinSpeed; + + [Required, SIRange(0, 50 / Constants.MeterPerSecondToKMH)] public MeterPerSecond OverSpeed; + + [Required, SIRange(0, 50 / Constants.MeterPerSecondToKMH)] public MeterPerSecond UnderSpeed; } public class LACData { public bool Enabled; + //public MeterPerSquareSecond Deceleration; - //public MeterPerSecond MinSpeed; - public double LookAheadDistanceFactor; - public LACDecisionFactor LookAheadDecisionFactor; + [Required, SIRange(0, 120 / Constants.MeterPerSecondToKMH)] public MeterPerSecond MinSpeed; + + [Required, Range(0, 20)] public double LookAheadDistanceFactor; + + [Required, ValidateObject] public LACDecisionFactor LookAheadDecisionFactor; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs index 94f64c6bfc185ba98a7db8aeb966147f7b8196f9..10ddce62dc96433df1715a5fe3111b3b85d606ec 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics; using TUGraz.VectoCommon.Exceptions; @@ -72,6 +73,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine angularVelocity.AsRPM); } + public IReadOnlyCollection<Entry> Entries + { + get + { + var entries = _fuelMap.Entries; + var retVal = new Entry[entries.Count]; + var i = 0; + foreach (var entry in entries) { + retVal[i++] = new Entry(entry.Y.SI<PerSecond>(), entry.X.SI<NewtonMeter>(), entry.Z.SI<KilogramPerSecond>()); + } + return retVal; + } + } + public class Entry { [Required, SIRange(0, 5000 * Constants.RPMToRad)] public readonly PerSecond EngineSpeed; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs index 83b07b0710f7aa3de8fba1fe9533e5b555e1016b..1f7ac5ff1b2e87c08760b99644330ae9de62147a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -42,7 +43,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// Class for Gearbox Data. Gears can be accessed via Gears-Dictionary and range from 1 upwards. /// </summary> /// <remarks>The Axle Gear has its own Property "AxleGearData" and is *not included* in the Gears-Dictionary.</remarks> - [DataContract] + [DataContract, CustomValidation(typeof(GearboxData), "ValidateGearboxData")] public class GearboxData : SimulationComponentData { public GearboxType Type { get; internal set; } @@ -112,5 +113,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [Required, SIRange(0, double.MaxValue)] public MeterPerSquareSecond UpshiftMinAcceleration { get; internal set; } + + // ReSharper disable once UnusedMember.Global -- used via Validation + public static ValidationResult ValidateGearboxData(GearboxData gearboxData, ValidationContext validationContext) + { + var mode = GetExecutionMode(validationContext); + + var result = new List<ValidationResult>(); + if (gearboxData.Type.AutomaticTransmission()) { + result.AddRange(gearboxData.TorqueConverterData.Validate(mode)); + } + + if (result.Any()) { + return new ValidationResult("Validation of Gearbox Data failed", result.Select(x => x.ErrorMessage)); + } + return ValidationResult.Success; + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index 70cb17b7a150a778cc79e39de1a3a5f1186e17e4..8d484b39a51d16d93be0be34fd71fcc74330a512 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -85,7 +85,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// <summary> /// The Gross Vehicle Weight of the Vehicle. /// </summary> - [Required, SIRange(3500, 40000, ExecutionMode.Declaration), SIRange(0, 1000000, ExecutionMode.Engineering)] + [Required, + SIRange(3500, 40000, ExecutionMode.Declaration), + SIRange(0, 1000000, ExecutionMode.Engineering)] public Kilogram GrossVehicleWeight { get; internal set; } /// <summary> @@ -109,7 +111,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data internal set { _wheelsInertia = value; } } - [Required, SIRange(0, 1E12)] + //[Required, SIRange(0, 1E12)] public double TotalRollResistanceCoefficient { get @@ -153,13 +155,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var rrc = 0.0.SI<Scalar>(); var wheelsInertia = 0.0.SI<KilogramSquareMeter>(); foreach (var axle in _axleData) { + if (axle.AxleWeightShare.IsEqual(0, 1e-12)) { + continue; + } var nrWheels = axle.TwinTyres ? 4 : 2; var baseValue = (axle.AxleWeightShare * TotalVehicleWeight() * g / axle.TyreTestLoad / nrWheels).Value(); - if (baseValue.IsEqual(0)) { - throw new VectoSimulationException( - "Axle Roll Resistance Coefficient could not be calculated. One of the values is 0: AxleWeightShare: {0}, TotalVehicleWeight: {1}, TyreTestLoad: {2}, nrWheels: {3}", - axle.AxleWeightShare, TotalVehicleWeight(), axle.TyreTestLoad, nrWheels); - } + rrc += axle.AxleWeightShare * axle.RollResistanceCoefficient * Math.Pow(baseValue, Physics.RollResistanceExponent - 1); wheelsInertia += nrWheels * axle.Inertia; @@ -168,16 +169,33 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data WheelsInertia = wheelsInertia; } + // ReSharper disable once UnusedMember.Global -- used via Validation public static ValidationResult ValidateVehicleData(VehicleData vehicleData, ValidationContext validationContext) { var mode = GetExecutionMode(validationContext); + if (vehicleData.AxleData.Count < 1) { + return new ValidationResult("At least two axles need to be specified"); + } + var weightShareSum = vehicleData.AxleData.Sum(axle => axle.AxleWeightShare); if (!weightShareSum.IsEqual(1.0, 1E-10)) { return new ValidationResult( string.Format("Sum of axle weight share is not 1! sum: {0}, difference: {1}", weightShareSum, 1 - weightShareSum)); } + for (var i = 0; i < vehicleData.AxleData.Count; i++) { + if (vehicleData.AxleData[i].TyreTestLoad.IsSmallerOrEqual(0)) { + return new ValidationResult(string.Format("Tyre test load (FzISO) for axle {0} must be greater than 0.", i)); + } + } + + + if (vehicleData.TotalRollResistanceCoefficient <= 0) { + return + new ValidationResult(string.Format("Total rolling resistance must be greater than 0! {0}", + vehicleData.TotalRollResistanceCoefficient)); + } // total gvw is limited by max gvw (40t) var gvwTotal = VectoMath.Min(vehicleData.GrossVehicleWeight + vehicleData.TrailerGrossVehicleWeight, @@ -185,6 +203,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (mode != ExecutionMode.Declaration) { return ValidationResult.Success; } + // vvvvvvv these checks apply only for declaration mode! vvvvvv + + if (vehicleData.AxleConfiguration.NumAxles() != vehicleData.AxleData.Count) { + return + new ValidationResult( + string.Format("For a {0} type vehicle exactly {1} number of axles have to pe specified. Found {2}", + vehicleData.AxleConfiguration.GetName(), vehicleData.AxleConfiguration.NumAxles(), vehicleData.AxleData.Count)); + } if (vehicleData.TotalVehicleWeight() > gvwTotal) { return new ValidationResult( diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 5145b3c88a59ba749c8eb517180b0564f3354e8a..6cdc927f7b8be49ed042c0e5f4f6863cf7c6c495 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -207,8 +207,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // get max. torque as limited by gearbox. gearbox only limits torqueOut! var gearboxFullLoad = DataBus.GearMaxTorque; - var deltaFull = ComputeDelta(torqueOut, totalTorqueDemand + (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()), CurrentState.DynamicFullLoadTorque, gearboxFullLoad, true); - var deltaDrag = ComputeDelta(torqueOut, totalTorqueDemand - (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()), CurrentState.FullDragTorque, + var deltaFull = ComputeDelta(torqueOut, + totalTorqueDemand + (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()), + CurrentState.DynamicFullLoadTorque, gearboxFullLoad, true); + var deltaDrag = ComputeDelta(torqueOut, + totalTorqueDemand - (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()), + CurrentState.FullDragTorque, gearboxFullLoad != null ? -gearboxFullLoad : null, false); if (dryRun) { @@ -332,12 +336,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { if (CurrentState.FullDragTorque >= 0 && torqueDemand < 0) { throw new VectoSimulationException("P_engine_drag > 0! Tq_drag: {1}, Tq_eng: {2}, n_eng_avg: {0} [1/min] ", - CurrentState.EngineSpeed.Value().RadToRPM(), CurrentState.FullDragTorque, CurrentState.EngineTorque); + CurrentState.EngineSpeed.AsRPM, CurrentState.FullDragTorque, CurrentState.EngineTorque); } if (CurrentState.DynamicFullLoadTorque <= 0 && torqueDemand > 0) { throw new VectoSimulationException("P_engine_full < 0! Tq_drag: {1}, Tq_eng: {2}, n_eng_avg: {0} [1/min] ", - CurrentState.EngineSpeed.Value().RadToRPM(), CurrentState.FullDragTorque, CurrentState.EngineTorque); + CurrentState.EngineSpeed.AsRPM, CurrentState.FullDragTorque, CurrentState.EngineTorque); } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 8359471720f383b0d84e1b233e0212be18dc8ba0..503426de7d635ca4d112e04995a75fe9e3dd5930 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -189,13 +189,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var coastingDistance = ComputeCoastingDistance(currentSpeed, entry); var brakingDistance = Driver.ComputeDecelerationDistance(nextTargetSpeed) + BrakingSafetyMargin; - if (coastingDistance < 0) { + if (!Driver.DriverData.LookAheadCoasting.Enabled || coastingDistance < 0) { Log.Debug( "adding 'Braking' starting at distance {0}. brakingDistance: {1}, triggerDistance: {2}, nextTargetSpeed: {3}", entry.Distance - brakingDistance, brakingDistance, entry.Distance, nextTargetSpeed); + coastingDistance = brakingDistance; } else { //var coastingDistance = ComputeCoastingDistance(currentSpeed, nextTargetSpeed); - if (currentSpeed > 50.KMPHtoMeterPerSecond()) { + if (currentSpeed > Driver.DriverData.LookAheadCoasting.MinSpeed) { action = DrivingBehavior.Coasting; Log.Debug( diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs index a86a4665b998b690488bc057d0e2c86235c4acbb..05a700519e6d4a3347570f5f82b6c1af3f8e8cd3 100644 --- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs @@ -35,6 +35,7 @@ using System.Linq; using System.Runtime.CompilerServices; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +// ReSharper disable MemberCanBePrivate.Global -- used by API! namespace TUGraz.VectoCore.OutputData { @@ -46,66 +47,66 @@ namespace TUGraz.VectoCore.OutputData public class SummaryDataContainer : LoggingObject, IDisposable { // ReSharper disable InconsistentNaming - private const string JOB = "Job [-]"; - private const string INPUTFILE = "Input File [-]"; - private const string CYCLE = "Cycle [-]"; - private const string STATUS = "Status"; - private const string MASS = "Mass [kg]"; - private const string LOADING = "Loading [kg]"; - private const string TIME = "time [s]"; - private const string DISTANCE = "distance [km]"; - private const string SPEED = "speed [km/h]"; - private const string ALTITUDE_DELTA = "altitudeDelta [m]"; - - private const string FCMAP_H = "FC-Map [g/h]"; - private const string FCMAP_KM = "FC-Map [g/km]"; - private const string FCAUXC_H = "FC-AUXc [g/h]"; - private const string FCAUXC_KM = "FC-AUXc [g/km]"; - private const string FCWHTCC_H = "FC-WHTCc [g/h]"; - private const string FCWHTCC_KM = "FC-WHTCc [g/km]"; - private const string FCAAUX_H = "FC-AAUX [g/h]"; - private const string FCAAUX_KM = "FC-AAUX [g/km]"; - - private const string FCFINAL_H = "FC-Final [g/h]"; - private const string FCFINAL_KM = "FC-Final [g/km]"; - private const string FCFINAL_LITERPER100KM = "FC-Final [l/100km]"; - private const string FCFINAL_LITERPER100TKM = "FC-Final [l/100tkm]"; - - private const string CO2_KM = "CO2 [g/km]"; - private const string CO2_TKM = "CO2 [g/tkm]"; - - private const string P_WHEEL_POS = "P_wheel_in_pos [kW]"; - private const string P_BRAKE_LOSS = "P_brake_loss [kW]"; - private const string P_CLUTCH_POS = "P_clutch_pos [kW]"; - private const string P_CLUTCH_NEG = "P_clutch_neg [kW]"; - private const string P_FCMAP_POS = "P_fcmap_pos [kW]"; - private const string P_ANGLE_LOSS = "P_angle_loss [kW]"; - private const string P_TC_LOSS = "P_tc_loss [kW]"; - - private const string E_AUX_FORMAT = "E_aux_{0} [kWh]"; - private const string E_AUX = "E_aux_sum [kWh]"; - - private const string E_AIR = "E_air [kWh]"; - private const string E_ROLL = "E_roll [kWh]"; - private const string E_GRAD = "E_grad [kWh]"; - private const string E_INERTIA = "E_inertia [kWh]"; - private const string E_BRAKE = "E_brake [kWh]"; - private const string E_GBX_AXL_LOSS = "E_gbx_axl_loss [kWh]"; - private const string E_RET_LOSS = "E_ret_loss [kWh]"; - private const string E_TC_LOSS = "E_tc_loss [kWh]"; - private const string E_ANGLE_LOSS = "E_angle_loss [kWh]"; - private const string E_CLUTCH_POS = "E_clutch_pos [kWh]"; - private const string E_CLUTCH_NEG = "E_clutch_neg [kWh]"; - private const string E_FCMAP_POS = "E_fcmap_pos [kWh]"; - - private const string ACC = "a [m/s^2]"; - private const string ACC_POS = "a_pos [m/s^2]"; - private const string ACC_NEG = "a_neg [m/s^2]"; - - private const string ACC_TIMESHARE = "AccelerationTimeShare [%]"; - private const string DEC_TIMESHARE = "DecelerationTimeShare [%]"; - private const string CRUISE_TIMESHARE = "CruiseTimeShare [%]"; - private const string STOP_TIMESHARE = "StopTimeShare [%]"; + public const string JOB = "Job [-]"; + public const string INPUTFILE = "Input File [-]"; + public const string CYCLE = "Cycle [-]"; + public const string STATUS = "Status"; + public const string MASS = "Mass [kg]"; + public const string LOADING = "Loading [kg]"; + public const string TIME = "time [s]"; + public const string DISTANCE = "distance [km]"; + public const string SPEED = "speed [km/h]"; + public const string ALTITUDE_DELTA = "altitudeDelta [m]"; + + public const string FCMAP_H = "FC-Map [g/h]"; + public const string FCMAP_KM = "FC-Map [g/km]"; + public const string FCAUXC_H = "FC-AUXc [g/h]"; + public const string FCAUXC_KM = "FC-AUXc [g/km]"; + public const string FCWHTCC_H = "FC-WHTCc [g/h]"; + public const string FCWHTCC_KM = "FC-WHTCc [g/km]"; + public const string FCAAUX_H = "FC-AAUX [g/h]"; + public const string FCAAUX_KM = "FC-AAUX [g/km]"; + + public const string FCFINAL_H = "FC-Final [g/h]"; + public const string FCFINAL_KM = "FC-Final [g/km]"; + public const string FCFINAL_LITERPER100KM = "FC-Final [l/100km]"; + public const string FCFINAL_LITERPER100TKM = "FC-Final [l/100tkm]"; + + public const string CO2_KM = "CO2 [g/km]"; + public const string CO2_TKM = "CO2 [g/tkm]"; + + public const string P_WHEEL_POS = "P_wheel_in_pos [kW]"; + public const string P_BRAKE_LOSS = "P_brake_loss [kW]"; + public const string P_CLUTCH_POS = "P_clutch_pos [kW]"; + public const string P_CLUTCH_NEG = "P_clutch_neg [kW]"; + public const string P_FCMAP_POS = "P_fcmap_pos [kW]"; + public const string P_ANGLE_LOSS = "P_angle_loss [kW]"; + public const string P_TC_LOSS = "P_tc_loss [kW]"; + + public const string E_AUX_FORMAT = "E_aux_{0} [kWh]"; + public const string E_AUX = "E_aux_sum [kWh]"; + + public const string E_AIR = "E_air [kWh]"; + public const string E_ROLL = "E_roll [kWh]"; + public const string E_GRAD = "E_grad [kWh]"; + public const string E_INERTIA = "E_inertia [kWh]"; + public const string E_BRAKE = "E_brake [kWh]"; + public const string E_GBX_AXL_LOSS = "E_gbx_axl_loss [kWh]"; + public const string E_RET_LOSS = "E_ret_loss [kWh]"; + public const string E_TC_LOSS = "E_tc_loss [kWh]"; + public const string E_ANGLE_LOSS = "E_angle_loss [kWh]"; + public const string E_CLUTCH_POS = "E_clutch_pos [kWh]"; + public const string E_CLUTCH_NEG = "E_clutch_neg [kWh]"; + public const string E_FCMAP_POS = "E_fcmap_pos [kWh]"; + + public const string ACC = "a [m/s^2]"; + public const string ACC_POS = "a_pos [m/s^2]"; + public const string ACC_NEG = "a_neg [m/s^2]"; + + public const string ACC_TIMESHARE = "AccelerationTimeShare [%]"; + public const string DEC_TIMESHARE = "DecelerationTimeShare [%]"; + public const string CRUISE_TIMESHARE = "CruiseTimeShare [%]"; + public const string STOP_TIMESHARE = "StopTimeShare [%]"; // ReSharper restore InconsistentNaming private readonly DataTable _table; diff --git a/VectoCore/VectoCore/Properties/Version.cs b/VectoCore/VectoCore/Properties/Version.cs index dddd78a9157bf98224fa80dd8405c5b870d56b07..a07564838339dd59a0908c69fd7fad380ba2b4b4 100644 --- a/VectoCore/VectoCore/Properties/Version.cs +++ b/VectoCore/VectoCore/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.0.90.613")] -[assembly: AssemblyFileVersion("3.0.90.613")] +[assembly: AssemblyVersion("3.0.90.628")] +[assembly: AssemblyFileVersion("3.0.90.628")] diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index 661a91b450ea2f2b8e6e00f033f7103b66277c28..f7c751035d3bf68c16d6c6f884b60ddf4347da01 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -46,7 +46,7 @@ namespace TUGraz.VectoCore.Utils { public sealed class DelaunayMap : LoggingObject { - internal ICollection<Point> Points = new HashSet<Point>(); + private ICollection<Point> Points = new HashSet<Point>(); private Triangle[] _triangles; private Edge[] _convexHull; @@ -66,6 +66,19 @@ namespace TUGraz.VectoCore.Utils Points.Add(new Point(x, y, z)); } + public IReadOnlyCollection<Point> Entries + { + get + { + var retVal = new Point[Points.Count]; + var i = 0; + foreach (var pt in Points) { + retVal[i++] = new Point(pt.X * (_maxX - _minX) + _minX, pt.Y * (_maxY - _minY) + _minY, pt.Z); + } + return retVal; + } + } + /// <summary> /// Triangulate the points. /// </summary> @@ -229,23 +242,27 @@ namespace TUGraz.VectoCore.Utils [MethodImpl(MethodImplOptions.AggressiveInlining)] public double? Interpolate(double x, double y) { - if (_triangles == null) + if (_triangles == null) { throw new VectoException("Interpolation not possible. Call DelaunayMap.Triangulate first."); + } x = (x - _minX) / (_maxX - _minX); y = (y - _minY) / (_maxY - _minY); var i = 0; - while (i < _triangles.Length && !_triangles[i].IsInside(x, y, true)) + while (i < _triangles.Length && !_triangles[i].IsInside(x, y, true)) { i++; + } if (i == _triangles.Length) { i = 0; - while (i < _triangles.Length && !_triangles[i].IsInside(x, y, false)) + while (i < _triangles.Length && !_triangles[i].IsInside(x, y, false)) { i++; + } } - if (i == _triangles.Length) + if (i == _triangles.Length) { return null; + } var tr = _triangles[i]; var plane = new Plane(tr); diff --git a/VectoCore/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/VectoCore/Utils/VectoCSVFile.cs index f23b674ce9df66b536e53eb0e03acba30c122ced..7148af44831517dcc8c309c6605331aa33f132fe 100644 --- a/VectoCore/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/VectoCore/Utils/VectoCSVFile.cs @@ -38,6 +38,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -69,11 +70,13 @@ namespace TUGraz.VectoCore.Utils /// <param name="ignoreEmptyColumns">set true, if empty columns should be ignored. default: false.</param> /// <param name="fullHeader">set true is column names should be preserved. Otherwise units are trimed away. default: false.</param> /// <returns>A DataTable which represents the CSV File.</returns> - public static DataTable Read(string fileName, bool ignoreEmptyColumns = false, bool fullHeader = false) + public static TableData Read(string fileName, bool ignoreEmptyColumns = false, bool fullHeader = false) { try { using (var fs = new FileStream(fileName, FileMode.Open)) { - return ReadStream(fs, ignoreEmptyColumns, fullHeader); + var retVal = new TableData(fileName); + ReadCSV(retVal, fs, ignoreEmptyColumns, fullHeader); + return retVal; } } catch (Exception e) { LogManager.GetLogger(typeof(VectoCSVFile).FullName).Error(e); @@ -88,7 +91,14 @@ namespace TUGraz.VectoCore.Utils /// <param name="ignoreEmptyColumns">set true, if empty columns should be ignored. default: false.</param> /// <param name="fullHeader">set true is column names should be preserved. Otherwise units are trimed away. default: false.</param> /// <returns>A DataTable which represents the CSV File.</returns> - public static DataTable ReadStream(Stream stream, bool ignoreEmptyColumns = false, bool fullHeader = false) + public static TableData ReadStream(Stream stream, bool ignoreEmptyColumns = false, bool fullHeader = false) + { + var retVal = new TableData(); + ReadCSV(retVal, stream, ignoreEmptyColumns, fullHeader); + return retVal; + } + + private static void ReadCSV(DataTable table, Stream stream, bool ignoreEmptyColumns, bool fullHeader) { var p = new TextFieldParser(stream) { TextFieldType = FieldType.Delimited, @@ -125,13 +135,13 @@ namespace TUGraz.VectoCore.Utils columns = colsWithoutComment.Select((_, i) => i.ToString()).ToList(); } - var table = new DataTable(); + //var table = new DataTable(); foreach (var col in columns) { table.Columns.Add(col); } if (p.EndOfData) { - return table; + return; } var lineNumber = 1; @@ -158,8 +168,6 @@ namespace TUGraz.VectoCore.Utils } lineNumber++; } while (!p.EndOfData); - - return table; } /// <summary> diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index fdc7a9bbdf5e6e16700e0710aa89df91a1f8f225..757e6a811a36b9553b9b630ccf2dec1a388b75a2 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -109,6 +109,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Configuration\Constants.cs" /> + <Compile Include="InputData\FileIO\JSON\JSONComponentInputData.cs" /> <Compile Include="InputData\FileIO\JSON\JsonExtensionMethods.cs" /> <Compile Include="InputData\Impl\InputData.cs" /> <Compile Include="InputData\FileIO\JSON\JSONEngineData.cs" /> diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index 8cf5160bf56efc47a213838bfbcace89318a4e47..76c98f6cede854e66e3e98be51d2d415f2979e5d 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -63,8 +63,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation { var container = new VehicleContainer(ExecutionMode.Engineering); var inputData = @"<t>,<Pwheel>,<gear>,<n>,<Padd> - 1,89,2,1748,1.300 - 2,120,2,1400,0.4"; + 1,89,2,1748,1.300 + 2,120,2,1400,0.4"; var cycleFile = new MemoryStream(Encoding.UTF8.GetBytes(inputData)); var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycleFile, CycleType.PWheel, "", false); @@ -105,8 +105,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation { // prepare input data var inputData = @"<t>,<Pwheel>,<gear>,<n>, <Padd> - 1, 89, 2, 1748, 1.3 - 2, 120, 2, 1400, 0.4"; + 1, 89, 2, 1748, 1.3 + 2, 120, 2, 1400, 0.4"; var cycleFile = new MemoryStream(Encoding.UTF8.GetBytes(inputData)); var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycleFile, CycleType.PWheel, "", false); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs index 2531db52bc16e69f3b9577c708841f83ce4b5867..baebf0c15a603c4e3c210afca12fdc311e67be1a 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs @@ -35,6 +35,7 @@ using System.ComponentModel.DataAnnotations; using System.Data; using System.Diagnostics.CodeAnalysis; using System.Linq; +using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader; @@ -101,7 +102,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData [TestMethod] public void Validation_CombustionEngineData_Engineering() { - var fuelConsumption = new DataTable(); + var fuelConsumption = new TableData(); fuelConsumption.Columns.Add(""); fuelConsumption.Columns.Add(""); fuelConsumption.Columns.Add(""); @@ -109,7 +110,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData fuelConsumption.Rows.Add("2", "2", "2"); fuelConsumption.Rows.Add("3", "3", "3"); - var fullLoad = new DataTable(); + var fullLoad = new TableData(); fullLoad.Columns.Add("Engine speed"); fullLoad.Columns.Add("max torque"); fullLoad.Columns.Add("drag torque"); @@ -136,7 +137,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData [TestMethod] public void Validation_CombustionEngineData_Declaration() { - var fuelConsumption = new DataTable(); + var fuelConsumption = new TableData(); fuelConsumption.Columns.Add(""); fuelConsumption.Columns.Add(""); fuelConsumption.Columns.Add(""); @@ -144,7 +145,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData fuelConsumption.Rows.Add("2", "2", "2"); fuelConsumption.Rows.Add("3", "3", "3"); - var fullLoad = new DataTable(); + var fullLoad = new TableData(); fullLoad.Columns.Add("Engine speed"); fullLoad.Columns.Add("max torque"); fullLoad.Columns.Add("drag torque"); @@ -332,6 +333,20 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData "Validation Error: " + string.Join("\n_eng_avg", results.Select(r => r.ErrorMessage))); } + [TestMethod] + public void ValidateDictionaryTest() + { + var container = new ContainerObject() { + Elements = new Dictionary<int, WrapperObject>() { + { 2, new WrapperObject() { Value = 41 } }, + { 4, new WrapperObject() { Value = -30 } } + } + }; + + var results = container.Validate(ExecutionMode.Declaration); + Assert.AreEqual(1, results.Count); + } + /// <summary> /// VECTO-249: check upshift is above downshift /// </summary> @@ -363,6 +378,16 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData Assert.IsTrue(results.Any()); } + public class ContainerObject + { + [Required, ValidateObject] public Dictionary<int, WrapperObject> Elements; + } + + public class WrapperObject + { + [Required, Range(0, 100)] public int Value = 0; + } + public class DeepDataObject { [Required, Range(41, 42)] protected int public_field = 5; diff --git a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs index 6ae0e66a4d1826097ae5fad8888830efad3ea0dd..c99795d2e784712d64da7fb9526d95995ff13899 100644 --- a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs +++ b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs @@ -37,6 +37,8 @@ namespace TUGraz.VectoCore.Tests.Utils { public class MockEngineDataProvider : IEngineEngineeringInputData { + public DataSourceType SourceType { get; set; } + public string Source { get; set; } public bool SavedInDeclarationMode { get; set; } public string Vendor { get; set; } public string ModelName { get; set; } @@ -50,8 +52,9 @@ namespace TUGraz.VectoCore.Tests.Utils public double WHTCMotorway { get; set; } public double WHTCRural { get; set; } public double WHTCUrban { get; set; } - public DataTable FuelConsumptionMap { get; set; } - public DataTable FullLoadCurve { get; set; } + public double ColdHotBalancingFactor { get; set; } + public TableData FuelConsumptionMap { get; set; } + public TableData FullLoadCurve { get; set; } public KilogramSquareMeter Inertia { get; set; } public double WHTCEngineering { get; set; } } diff --git a/VectoCore/VectoCoreTest/Utils/SITest.cs b/VectoCore/VectoCoreTest/Utils/SITest.cs index 0a44af7b0f25412a8f2103a9ea59377811351008..e54670fdb529e71b54ed30a2f6f26c12fcd6b6a8 100644 --- a/VectoCore/VectoCoreTest/Utils/SITest.cs +++ b/VectoCore/VectoCoreTest/Utils/SITest.cs @@ -129,7 +129,7 @@ namespace TUGraz.VectoCore.Tests.Utils var si4 = si2 * si3; Assert.AreEqual("10.0000 [W/s]", si4.ToString()); Assert.IsTrue(si4.HasEqualUnit(new SI().Watt.Per.Second)); - Assert.AreEqual("10.0000 [kgmm/ssss]", si4.ToBasicUnits().ToString()); + Assert.AreEqual("10.0000 [kgm^2/s^4]", si4.ToBasicUnits().ToString()); var kg = 5.SI().Kilo.Gramm; Assert.AreEqual(5.0, kg.Value()); @@ -437,6 +437,12 @@ namespace TUGraz.VectoCore.Tests.Utils Assert.AreEqual("3.50 [N]", 3.5.SI<Newton>().ToOutputFormat(2, showUnit: true)); Assert.AreEqual("18.00 [m/s]", 5.SI<MeterPerSecond>().ToOutputFormat(2, 3.6, true)); Assert.AreEqual("18.0000", 5.SI<MeterPerSecond>().ToOutputFormat(outputFactor: 3.6)); + + Assert.AreEqual("10.0000 [m^2]", 10.SI<SquareMeter>().ToOutputFormat(showUnit: true)); + + Assert.AreEqual("10.0000 [m^3]", 10.SI<CubicMeter>().ToOutputFormat(showUnit: true)); + + Assert.AreEqual("0.5000 [m/s^2]", 0.5.SI<MeterPerSquareSecond>().ToOutputFormat(showUnit: true)); } } } \ No newline at end of file