diff --git a/VECTO/ApplicationEvents.vb b/VECTO/ApplicationEvents.vb index d65723267de1ee7cffcffa8c298550aef5cb6f94..915b69e17ded3977d2c1b236fdcd43187fd809fa 100644 --- a/VECTO/ApplicationEvents.vb +++ b/VECTO/ApplicationEvents.vb @@ -1,4 +1,4 @@ -' Copyright 2014 European Union. +' Copyright 2014 European Union. ' Licensed under the EUPL (the 'Licence'); ' ' * You may not use this work except in compliance with the Licence. @@ -103,13 +103,13 @@ Namespace My DEV = New cDEV Declaration = New cDeclaration - Cfg = New cConfig 'ACHTUNG: cConfig.New löst cConfig.SetDefault aus welches sKey benötigt dehalb muss sKey schon vorher initialisiert werden!! + Cfg = New Configuration 'ACHTUNG: Configuration.New löst Configuration.SetDefault aus welches sKey benötigt dehalb muss sKey schon vorher initialisiert werden!! Cfg.FilePath = MyConfPath & "settings.json" ProgBarCtrl = New cProgBarCtrl 'Config - Cfg.ConfigLOAD() + Cfg.Load() 'Restart log if log file too large LogFile.SizeCheck() diff --git a/VECTO/cConfig.vb b/VECTO/Configuration.vb similarity index 63% rename from VECTO/cConfig.vb rename to VECTO/Configuration.vb index 72fe1471669f19e7ee607abd2404252b39e54da5..613fc83ba340059db8600ae2e02c2aa5ef8f17ba 100644 --- a/VECTO/cConfig.vb +++ b/VECTO/Configuration.vb @@ -1,149 +1,140 @@ -' 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 cConfig - Public FilePath As String - - Private Const FormatVersion As Short = 2 - Private FileVersion As Short - - Public GnUfromCycle As Boolean - Public BatchMode As Boolean - Public ModOut As Boolean - Public BATCHoutpath As String 'Output path for BATCH Mode - Public BATCHoutSubD As Boolean - Public DistCorr As Boolean - Public LogSize As Single - Public AirDensity As Single - Public OpenCmd As String - Public OpenCmdName As String - - Public FuelDens As Single - Public CO2perFC As Single - - Public FirstRun As Boolean - - Public DeclMode As Boolean - - - Public Sub New() - SetDefault() - End Sub - - Public Sub DeclInit() - AirDensity = cDeclaration.AirDensity - FuelDens = cDeclaration.FuelDens - CO2perFC = cDeclaration.CO2perFC - DistCorr = True - GnUfromCycle = False - End Sub - - Public Sub SetDefault() - - - GnUfromCycle = True - BatchMode = False - ModOut = True - BATCHoutpath = sKey.JobPath - BATCHoutSubD = False - DistCorr = True - LogSize = 2 - AirDensity = 1.2 - OpenCmd = "notepad" - OpenCmdName = "Notepad" - - FuelDens = 0.835 - CO2perFC = 3.153 - - FirstRun = True - - DeclMode = True - End Sub - - Public Sub ConfigLOAD() - - Dim JSON As New cJSON - - SetDefault() - - If Not IO.File.Exists(FilePath) Then Exit Sub - - - If Not JSON.ReadFile(FilePath) Then GUImsg(tMsgID.Err, "Failed to load settings! Using default settings.") - - Try - - FileVersion = JSON.Content("Header")("FileVersion") - - If FileVersion < 2 Then - BatchMode = (JSON.Content("Body")("LastMode") = 1) - Else - BatchMode = JSON.Content("Body")("LastModeBatch") - End If - ModOut = JSON.Content("Body")("ModOut") - DistCorr = JSON.Content("Body")("DistCorrection") - GnUfromCycle = JSON.Content("Body")("UseGnUfromCycle") - LogSize = JSON.Content("Body")("LogSize") - BATCHoutpath = JSON.Content("Body")("BATCHoutpath") - BATCHoutSubD = JSON.Content("Body")("BATCHoutSubD") - 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") - - - Catch ex As Exception - - GUImsg(tMsgID.Err, "Error while loading settings!") - - End Try - End Sub - - Public Sub ConfigSAVE() - Dim JSON As New cJSON - 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.ToString) - dic.Add("AppVersion", VECTOvers) - dic.Add("FileVersion", FormatVersion) - JSON.Content.Add("Header", dic) - - 'Body - dic = New Dictionary(Of String, Object) - - dic.Add("LastModeBatch", BatchMode) - dic.Add("ModOut", ModOut) - dic.Add("DistCorrection", DistCorr) - dic.Add("UseGnUfromCycle", GnUfromCycle) - dic.Add("LogSize", LogSize) - dic.Add("BATCHoutpath", BATCHoutpath) - dic.Add("BATCHoutSubD", BATCHoutSubD) - 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) - - JSON.WriteFile(FilePath) - End Sub -End Class - +' Copyright 2016 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 Configuration + Public FilePath As String + Public GnUfromCycle As Boolean + Public BatchMode As Boolean + Public ModOut As Boolean + Public Mod1Hz As Boolean + Public BATCHoutpath As String 'Output path for BATCH Mode + Public BATCHoutSubD As Boolean + Public DistCorr As Boolean + Public LogSize As Single + Public AirDensity As Single + Public OpenCmd As String + Public OpenCmdName As String + Public FuelDens As Single + Public CO2perFC As Single + Public FirstRun As Boolean + Public DeclMode As Boolean + + Private Const FormatVersion As Short = 2 + + Public Sub New() + SetDefault() + End Sub + + Public Sub DeclInit() + AirDensity = cDeclaration.AirDensity + FuelDens = cDeclaration.FuelDens + CO2perFC = cDeclaration.CO2perFC + DistCorr = True + GnUfromCycle = False + End Sub + + Public Sub SetDefault() + GnUfromCycle = True + BatchMode = False + ModOut = True + Mod1Hz = False + BATCHoutpath = sKey.JobPath + BATCHoutSubD = False + DistCorr = True + LogSize = 2 + AirDensity = 1.2 + OpenCmd = "notepad" + OpenCmdName = "Notepad" + FuelDens = 0.835 + CO2perFC = 3.153 + FirstRun = True + DeclMode = True + End Sub + + Public Sub Load() + SetDefault() + + If Not IO.File.Exists(FilePath) Then + Exit Sub + End If + + Dim json As New JSON + If Not json.ReadFile(FilePath) Then + GUImsg(tMsgID.Err, "Failed to load settings! Using default settings.") + Exit Sub + End If + + Try + Dim fileVersion As Short = json.Content("Header")("FileVersion") + + If fileVersion < 2 Then + BatchMode = (json.Content("Body")("LastMode") = 1) + Else + BatchMode = json.Content("Body")("LastModeBatch") + End If + + Try + Mod1Hz = json.Content("Body")("Mod1Hz") + Catch + End Try + + ModOut = json.Content("Body")("ModOut") + DistCorr = json.Content("Body")("DistCorrection") + GnUfromCycle = json.Content("Body")("UseGnUfromCycle") + LogSize = json.Content("Body")("LogSize") + BATCHoutpath = json.Content("Body")("BATCHoutpath") + BATCHoutSubD = json.Content("Body")("BATCHoutSubD") + 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") + Catch ex As Exception + GUImsg(tMsgID.Err, "Error while loading settings!") + End Try + End Sub + + Public Sub Save() + Dim json As New JSON + Dim dic As Dictionary(Of String, Object) + + dic = New Dictionary(Of String, Object) + dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + dic.Add("Date", Now.ToString) + dic.Add("AppVersion", VECTOvers) + dic.Add("FileVersion", FormatVersion) + json.Content.Add("Header", dic) + + dic = New Dictionary(Of String, Object) + dic.Add("LastModeBatch", BatchMode) + dic.Add("ModOut", ModOut) + dic.Add("Mod1Hz", Mod1Hz) + dic.Add("DistCorrection", DistCorr) + dic.Add("UseGnUfromCycle", GnUfromCycle) + dic.Add("LogSize", LogSize) + dic.Add("BATCHoutpath", BATCHoutpath) + dic.Add("BATCHoutSubD", BATCHoutSubD) + 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) + + json.WriteFile(FilePath) + End Sub +End Class + diff --git a/VECTO/GUI/F_MAINForm.Designer.vb b/VECTO/GUI/F_MAINForm.Designer.vb index 3e6e8ab366cd6d0302d98154682a1146376baa79..45a7f915fd12007e1a5fef95b2c22d0163356b66 100644 --- a/VECTO/GUI/F_MAINForm.Designer.vb +++ b/VECTO/GUI/F_MAINForm.Designer.vb @@ -74,6 +74,7 @@ Partial Class F_MAINForm Me.GrBoxSTD = New System.Windows.Forms.GroupBox() Me.ChBoxAutoSD = New System.Windows.Forms.CheckBox() Me.PanelOptAllg = New System.Windows.Forms.Panel() + Me.ChBoxMod1Hz = New System.Windows.Forms.CheckBox() Me.ChBoxModOut = New System.Windows.Forms.CheckBox() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.RbDev = New System.Windows.Forms.RadioButton() @@ -588,20 +589,31 @@ Partial Class F_MAINForm ' 'PanelOptAllg ' + Me.PanelOptAllg.Controls.Add(Me.ChBoxMod1Hz) Me.PanelOptAllg.Controls.Add(Me.ChBoxModOut) Me.PanelOptAllg.Controls.Add(Me.GroupBox1) Me.PanelOptAllg.Controls.Add(Me.PnDeclOpt) Me.PanelOptAllg.Location = New System.Drawing.Point(6, 6) Me.PanelOptAllg.Name = "PanelOptAllg" - Me.PanelOptAllg.Size = New System.Drawing.Size(358, 212) + Me.PanelOptAllg.Size = New System.Drawing.Size(519, 212) Me.PanelOptAllg.TabIndex = 0 ' + 'ChBoxMod1Hz + ' + Me.ChBoxMod1Hz.AutoSize = True + Me.ChBoxMod1Hz.Location = New System.Drawing.Point(9, 182) + Me.ChBoxMod1Hz.Name = "ChBoxMod1Hz" + Me.ChBoxMod1Hz.Size = New System.Drawing.Size(121, 17) + Me.ChBoxMod1Hz.TabIndex = 16 + Me.ChBoxMod1Hz.Text = "Modal results in 1Hz" + Me.ChBoxMod1Hz.UseVisualStyleBackColor = True + ' 'ChBoxModOut ' Me.ChBoxModOut.AutoSize = True Me.ChBoxModOut.Checked = True Me.ChBoxModOut.CheckState = System.Windows.Forms.CheckState.Checked - Me.ChBoxModOut.Location = New System.Drawing.Point(9, 180) + Me.ChBoxModOut.Location = New System.Drawing.Point(9, 159) Me.ChBoxModOut.Name = "ChBoxModOut" Me.ChBoxModOut.Size = New System.Drawing.Size(115, 17) Me.ChBoxModOut.TabIndex = 0 @@ -649,7 +661,7 @@ Partial Class F_MAINForm Me.PnDeclOpt.Controls.Add(Me.ChBoxUseGears) Me.PnDeclOpt.Location = New System.Drawing.Point(3, 81) Me.PnDeclOpt.Name = "PnDeclOpt" - Me.PnDeclOpt.Size = New System.Drawing.Size(202, 93) + Me.PnDeclOpt.Size = New System.Drawing.Size(202, 72) Me.PnDeclOpt.TabIndex = 13 ' 'CbBatch @@ -665,7 +677,7 @@ Partial Class F_MAINForm 'ChBoxCyclDistCor ' Me.ChBoxCyclDistCor.AutoSize = True - Me.ChBoxCyclDistCor.Location = New System.Drawing.Point(6, 41) + Me.ChBoxCyclDistCor.Location = New System.Drawing.Point(6, 26) Me.ChBoxCyclDistCor.Name = "ChBoxCyclDistCor" Me.ChBoxCyclDistCor.Size = New System.Drawing.Size(148, 17) Me.ChBoxCyclDistCor.TabIndex = 0 @@ -675,7 +687,7 @@ Partial Class F_MAINForm 'ChBoxUseGears ' Me.ChBoxUseGears.AutoSize = True - Me.ChBoxUseGears.Location = New System.Drawing.Point(6, 64) + Me.ChBoxUseGears.Location = New System.Drawing.Point(6, 49) Me.ChBoxUseGears.Name = "ChBoxUseGears" Me.ChBoxUseGears.Size = New System.Drawing.Size(188, 17) Me.ChBoxUseGears.TabIndex = 0 @@ -1167,5 +1179,6 @@ Partial Class F_MAINForm Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents ReportBugViaCITnetToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents btStartV3 As System.Windows.Forms.Button + Friend WithEvents ChBoxMod1Hz As System.Windows.Forms.CheckBox End Class diff --git a/VECTO/GUI/F_MAINForm.vb b/VECTO/GUI/F_MAINForm.vb index 7ea944ad45a5dba432350c813aae740997c18c46..4f6f97ade0983662be03e559d397a291d0ac56bb 100644 --- a/VECTO/GUI/F_MAINForm.vb +++ b/VECTO/GUI/F_MAINForm.vb @@ -30,18 +30,17 @@ ' Imports System.Collections.Generic +Imports System.Collections.ObjectModel Imports System.ComponentModel +Imports System.Globalization Imports System.IO Imports System.Linq Imports System.Reflection Imports TUGraz.VectoCore.Models.Simulation.Impl -Imports TUGraz.VectoCore.InputData Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports System.Text +Imports System.Text.RegularExpressions Imports System.Threading -Imports NLog -Imports NLog.Config -Imports NLog.Targets Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils @@ -54,7 +53,7 @@ Imports TUGraz.VectoCore.Utils ''' </summary> ''' <remarks></remarks> - Public Class F_MAINForm +Public Class F_MAINForm Private JobListView As cFileListView Private CycleListView As cFileListView @@ -87,7 +86,7 @@ Imports TUGraz.VectoCore.Utils #Region "SLEEP Control - Prevent sleep while VECTO is running" - Private Declare Function SetThreadExecutionState Lib "kernel32" (ByVal esFlags As Long) As Long + Private Declare Function SetThreadExecutionState Lib "kernel32" (esFlags As Long) As Long Private Sub AllowSleepOFF() #If Not PLATFORM = "x86" Then @@ -117,7 +116,7 @@ Imports TUGraz.VectoCore.Utils Private Sub FB_Initialize() FB_Init = False Try - VECTO_Global.COREvers = Assembly.LoadFrom("VectoCore.dll").GetName().Version.ToString() + COREvers = Assembly.LoadFrom("VectoCore.dll").GetName().Version.ToString() Catch ex As Exception LogFile.WriteToLog(tMsgID.Err, ex.StackTrace) End Try @@ -199,20 +198,20 @@ Imports TUGraz.VectoCore.Utils End If 'Delete GENlist-Selection - Me.LvGEN.SelectedItems.Clear() + LvGEN.SelectedItems.Clear() 'If more than 100 calculations, ask whether to write by-second results If _ - Cfg.BatchMode And ((Me.LvGEN.CheckedItems.Count) * (Me.LvDRI.CheckedItems.Count) > 100) And - Me.ChBoxModOut.Checked _ + Cfg.BatchMode And ((LvGEN.CheckedItems.Count) * (LvDRI.CheckedItems.Count) > 100) And + ChBoxModOut.Checked _ Then Select Case _ MsgBox( "You are about to run Batch Mode with " & - (Me.LvGEN.CheckedItems.Count) * (Me.LvDRI.CheckedItems.Count) & + (LvGEN.CheckedItems.Count) * (LvDRI.CheckedItems.Count) & " calculations!" & ChrW(10) & "Do you still want to write modal results?", MsgBoxStyle.YesNoCancel) Case MsgBoxResult.No - Me.ChBoxModOut.Checked = False + ChBoxModOut.Checked = False Case MsgBoxResult.Cancel GUImsg(tMsgID.Normal, "Aborted by User") Exit Sub @@ -254,32 +253,32 @@ Imports TUGraz.VectoCore.Utils End Sub 'Lock certain GUI elements while VECTO is running - Private Sub LockGUI(ByVal Lock As Boolean) + Private Sub LockGUI(Lock As Boolean) GUIlocked = Lock - Me.PanelOptAllg.Enabled = Not Lock - Me.GrBoxSTD.Enabled = Not Lock - Me.GrBoxBATCH.Enabled = Not Lock + PanelOptAllg.Enabled = Not Lock + GrBoxSTD.Enabled = Not Lock + GrBoxBATCH.Enabled = Not Lock - Me.BtGENup.Enabled = Not Lock - Me.BtGENdown.Enabled = Not Lock - Me.ButtonGENadd.Enabled = Not Lock - Me.ButtonGENremove.Enabled = Not Lock - Me.LvGEN.LabelEdit = Not Lock - Me.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 - Me.BtDRIup.Enabled = Not Lock - Me.BtDRIdown.Enabled = Not Lock - Me.ButtonDRIadd.Enabled = Not Lock - Me.ButtonDRIremove.Enabled = Not Lock - Me.LvDRI.LabelEdit = Not Lock - Me.ChBoxAllDRI.Enabled = Not Lock + BtDRIup.Enabled = Not Lock + BtDRIdown.Enabled = Not Lock + ButtonDRIadd.Enabled = Not Lock + ButtonDRIremove.Enabled = Not Lock + LvDRI.LabelEdit = Not Lock + ChBoxAllDRI.Enabled = Not Lock Button1.Enabled = Not Lock btStartV3.Enabled = Not Lock If DEV.Enabled Then - Me.LvDEVoptions.Enabled = Not Lock + LvDEVoptions.Enabled = Not Lock End If End Sub @@ -292,7 +291,7 @@ Imports TUGraz.VectoCore.Utils CheckedItems.Clear() x = -1 - For Each LV0 In Me.LvGEN.CheckedItems + For Each LV0 In LvGEN.CheckedItems x += 1 LV0.SubItems(1).Text = "" CheckedItems.Add(LV0) @@ -308,14 +307,14 @@ Imports TUGraz.VectoCore.Utils JobCycleList.Clear() If Cfg.BatchMode Then - For Each LV0 In Me.LvDRI.CheckedItems + For Each LV0 In LvDRI.CheckedItems JobCycleList.Add(fFileRepl(LV0.SubItems(0).Text)) Next End If End Sub 'Job Launcher - Private Sub Job_Launcher(ByVal ProgOverallEnabled As Boolean) + Private Sub Job_Launcher(ProgOverallEnabled As Boolean) If VECTOworker.IsBusy Then Exit Sub @@ -323,7 +322,7 @@ Imports TUGraz.VectoCore.Utils SetOptions() 'Save Config - Cfg.ConfigSAVE() + Cfg.Save() If DEV.Enabled Then DEV.SaveToFile() @@ -335,14 +334,14 @@ Imports TUGraz.VectoCore.Utils 'Button switch Button1.Enabled = True - Me.Button1.Text = "STOP" - Me.Button1.Image = My.Resources.Stop_icon + Button1.Text = "STOP" + Button1.Image = My.Resources.Stop_icon 'ProgBars start If ProgOverallEnabled Then - Me.ToolStripProgBarOverall.Value = 0 - Me.ToolStripProgBarOverall.Style = ProgressBarStyle.Marquee - Me.ToolStripProgBarOverall.Visible = True + ToolStripProgBarOverall.Value = 0 + ToolStripProgBarOverall.Style = ProgressBarStyle.Marquee + ToolStripProgBarOverall.Visible = True End If ProgBarCtrl.ProgJobInt = 0 @@ -354,9 +353,9 @@ Imports TUGraz.VectoCore.Utils 'Abort Job Private Sub JobAbort() - Me.Button1.Enabled = False - Me.Button1.Text = "Aborting..." - Me.Button1.Image = My.Resources.Play_icon_gray + Button1.Enabled = False + Button1.Text = "Aborting..." + Button1.Image = My.Resources.Play_icon_gray VECTOworker.CancelAsync() End Sub @@ -364,7 +363,7 @@ Imports TUGraz.VectoCore.Utils #Region "BackgroundWorker Events" 'DoWork - Start Calculations - Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) _ + Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) _ Handles BackgroundWorker1.DoWork 'Prevent SLEEP @@ -372,7 +371,7 @@ Imports TUGraz.VectoCore.Utils If SetCulture Then Try - System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US") + Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US") Catch ex As Exception GUImsg(tMsgID.Err, "Failed to set thread culture 'en-US'! Check system decimal- and group- separators!") End Try @@ -382,8 +381,8 @@ Imports TUGraz.VectoCore.Utils End Sub 'Progress Report - Progressbar, Messages, etc. - Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, - ByVal e As System.ComponentModel.ProgressChangedEventArgs) _ + Private Sub BackgroundWorker1_ProgressChanged(sender As Object, + e As ProgressChangedEventArgs) _ Handles BackgroundWorker1.ProgressChanged Dim x As cWorkProg x = e.UserState @@ -396,7 +395,7 @@ Imports TUGraz.VectoCore.Utils Status(e.UserState.Msg) Case tWorkMsgType.ProgBars - Me.ToolStripProgBarOverall.Value = e.ProgressPercentage + ToolStripProgBarOverall.Value = e.ProgressPercentage ProgSecStart() Case tWorkMsgType.JobStatus @@ -405,12 +404,12 @@ Imports TUGraz.VectoCore.Utils Case tWorkMsgType.CycleStatus Try - Me.LvDRI.CheckedItems(x.FileIndex).SubItems(1).Text = x.Msg + LvDRI.CheckedItems(x.FileIndex).SubItems(1).Text = x.Msg Catch ex As Exception End Try Case tWorkMsgType.InitProgBar - Me.ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous + ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous Case Else ' tWorkMsgType.Abort JobAbort() @@ -419,20 +418,20 @@ Imports TUGraz.VectoCore.Utils End Sub 'Work completed - Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, - ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _ + Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, + e As RunWorkerCompletedEventArgs) _ Handles BackgroundWorker1.RunWorkerCompleted Dim Result As tCalcResult 'Progbar reset - Me.ToolStripProgBarOverall.Visible = False - Me.ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous - Me.ToolStripProgBarOverall.Value = 0 + ToolStripProgBarOverall.Visible = False + ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous + ToolStripProgBarOverall.Value = 0 ProgSecStop() 'So ListView-Item Colors (Warning = Yellow, etc..) are correctly visible - Me.LvGEN.SelectedIndices.Clear() + LvGEN.SelectedIndices.Clear() Result = e.Result @@ -441,25 +440,25 @@ Imports TUGraz.VectoCore.Utils MsgBox("An Unexpected Error occurred!" & ChrW(10) & ChrW(10) & e.Error.Message.ToString, MsgBoxStyle.Critical, "Unexpected Error") LogFile.WriteToLog(tMsgID.Err, ">>>Unexpected Error:" & e.Error.ToString()) - Me.Close() + Close() End If 'Options enable / GUI reset LockGUI(False) - Me.Button1.Text = "START V2.2" - Me.Button1.Image = My.Resources.Play_icon + Button1.Text = "START V2.2" + Button1.Image = My.Resources.Play_icon Status(LastModeName & " Mode") 'Command Line Shutdown - If ComLineShutDown Then Me.Close() + If ComLineShutDown Then Close() 'Auto Shutdown - If Me.ChBoxAutoSD.Checked Then - Me.ChBoxAutoSD.Checked = False + If ChBoxAutoSD.Checked Then + ChBoxAutoSD.Checked = False If Not Result = tCalcResult.Abort Then If F_ShutDown.ShutDown Then GUImsg(tMsgID.Warn, "Shutting down...") - Me.Close() + Close() End If End If End If @@ -475,7 +474,7 @@ Imports TUGraz.VectoCore.Utils #Region "Form Init/Close" 'Initialise - Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Dim x As Integer GUIlocked = False @@ -488,15 +487,15 @@ Imports TUGraz.VectoCore.Utils CheckedItems = New List(Of ListViewItem) 'Load Tabs properly (otherwise problem with ListViews) - For x = 0 To Me.TabControl1.TabCount - 1 - Me.TabControl1.TabPages(x).Show() + For x = 0 To TabControl1.TabCount - 1 + TabControl1.TabPages(x).Show() Next CycleTabPageVisible = True - CycleTabPage = Me.TabPageDRI + CycleTabPage = TabPageDRI - DEVpage = Me.TabPageDEV - 'Me.TabControl1.Controls.Remove(DEVpage) + DEVpage = TabPageDEV + 'TabControl1.Controls.Remove(DEVpage) LastModeName = "" @@ -504,14 +503,14 @@ Imports TUGraz.VectoCore.Utils FB_Initialize() - Me.Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers + Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers 'FileLists JobListView = New cFileListView(MyConfPath & "joblist.txt") - JobListView.LVbox = Me.LvGEN + JobListView.LVbox = LvGEN CycleListView = New cFileListView(MyConfPath & "cyclelist.txt") - CycleListView.LVbox = Me.LvDRI + CycleListView.LVbox = LvDRI JobListView.LoadList() @@ -519,12 +518,12 @@ Imports TUGraz.VectoCore.Utils LoadOptions() 'Resize columns ... after Loading the @file-lists - Me.LvGEN.Columns(1).Width = -2 - Me.LvDRI.Columns(1).Width = -2 - Me.LvMsg.Columns(2).Width = -2 + LvGEN.Columns(1).Width = -2 + LvDRI.Columns(1).Width = -2 + LvMsg.Columns(2).Width = -2 'Initialize BackgroundWorker - VECTOworker = Me.BackgroundWorker1 + VECTOworker = BackgroundWorker1 VECTOworker.WorkerReportsProgress = True VECTOworker.WorkerSupportsCancellation = True @@ -554,7 +553,7 @@ Imports TUGraz.VectoCore.Utils Else MsgBox("Failed to create Activation File! Is Directory Read-Only?") End If - Me.Close() + Close() Else GUImsg(tMsgID.Normal, "License File validated.") If Lic.TimeWarn Then GUImsg(tMsgID.Warn, "License expiring date (y/m/d): " & Lic.ExpTime) @@ -587,11 +586,11 @@ Imports TUGraz.VectoCore.Utils Private Sub DeclOnOff() If Cfg.DeclMode Then - Me.Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers & " - Declaration Mode" - Me.CbBatch.Checked = False + Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers & " - Declaration Mode" + CbBatch.Checked = False Cfg.DeclInit() Else - Me.Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers + Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers End If If Cfg.DeclMode Then @@ -606,31 +605,31 @@ Imports TUGraz.VectoCore.Utils If DEV.Enabled Then If Not Cfg.DeclMode Then - If Not Me.TabControl1.TabPages.Contains(DEVpage) Then _ - Me.TabControl1.TabPages.Insert(Me.TabControl1.TabPages.Count, DEVpage) + If Not TabControl1.TabPages.Contains(DEVpage) Then _ + TabControl1.TabPages.Insert(TabControl1.TabPages.Count, DEVpage) LoadDEVconfigs() Else - If Me.TabControl1.TabPages.Contains(DEVpage) Then Me.TabControl1.Controls.Remove(DEVpage) + If TabControl1.TabPages.Contains(DEVpage) Then TabControl1.Controls.Remove(DEVpage) DEV.SetDefault() End If End If Status(LastModeName & " Mode") - Me.LoadOptions() + LoadOptions() - Me.LbDecl.Visible = Cfg.DeclMode + LbDecl.Visible = Cfg.DeclMode - Me.PnDeclOpt.Enabled = Not Cfg.DeclMode + PnDeclOpt.Enabled = Not Cfg.DeclMode End Sub 'Shown Event (Form-Load finished) ... here StartUp Forms are loaded (DEV, GEN/ADV- Editor ..) - Private Sub F01_MAINForm_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown + Private Sub F01_MAINForm_Shown(sender As Object, e As EventArgs) Handles Me.Shown Dim fwelcome As F_Welcome 'DEV Form 'If DEV.Enabled And Not Cfg.DeclMode Then - ' Me.TabControl1.TabPages.Insert(Me.TabControl1.TabPages.Count, DEVpage) + ' TabControl1.TabPages.Insert(TabControl1.TabPages.Count, DEVpage) 'End If 'VECTO Init @@ -649,7 +648,7 @@ Imports TUGraz.VectoCore.Utils End Sub 'Open file - Private Sub CmdLineCtrl(ByVal ComLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) + Private Sub CmdLineCtrl(ComLineArgs As ReadOnlyCollection(Of String)) Dim bBATCH As Boolean Dim bRUN As Boolean Dim x As Object @@ -686,7 +685,7 @@ Imports TUGraz.VectoCore.Utils 'Mode switch and load Driving Cycles If bBATCH Then - Me.CbBatch.Checked = True + CbBatch.Checked = True If driFiles.Count > 0 Then LvDRI.Items.Clear() @@ -694,7 +693,7 @@ Imports TUGraz.VectoCore.Utils End If Else - Me.CbBatch.Checked = False + CbBatch.Checked = False End If 'Load Vecto files or open editor (if only one file) @@ -716,8 +715,7 @@ Imports TUGraz.VectoCore.Utils End Sub 'Close - Private Sub F01_MAINForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) _ - Handles Me.FormClosing + Private Sub F01_MAINForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing 'Save File-Lists SaveFileLists() @@ -727,7 +725,7 @@ Imports TUGraz.VectoCore.Utils 'Config save SetOptions() - Cfg.ConfigSAVE() + Cfg.Save() If DEV.Enabled Then DEV.SaveToFile() 'File browser instances close @@ -737,7 +735,7 @@ Imports TUGraz.VectoCore.Utils #End Region 'Open file - Job, vehicle, engine, gearbox or signature file - Public Sub OpenVectoFile(ByVal File As String) + Public Sub OpenVectoFile(File As String) If Not IO.File.Exists(File) Then @@ -789,30 +787,30 @@ Imports TUGraz.VectoCore.Utils #Region "Events" - Private Sub ButtonGENremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ButtonGENremove_Click(sender As Object, e As EventArgs) _ Handles ButtonGENremove.Click RemoveJobFile() End Sub - Private Sub ButtonGENadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ButtonGENadd_Click(sender As Object, e As EventArgs) _ Handles ButtonGENadd.Click AddJobFile() End Sub - Private Sub ButtonGENoptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ButtonGENoptions_Click(sender As Object, e As EventArgs) _ Handles ButtonGENopt.Click - ConMenTarget = Me.LvGEN + ConMenTarget = LvGEN ConMenTarJob = True 'Locked functions show/hide - Me.LoadListToolStripMenuItem.Enabled = Not GUIlocked - Me.LoadDefaultListToolStripMenuItem.Enabled = Not GUIlocked - Me.ClearListToolStripMenuItem.Enabled = Not GUIlocked + LoadListToolStripMenuItem.Enabled = Not GUIlocked + LoadDefaultListToolStripMenuItem.Enabled = Not GUIlocked + ClearListToolStripMenuItem.Enabled = Not GUIlocked - Me.ConMenFilelist.Show(Control.MousePosition) + ConMenFilelist.Show(MousePosition) End Sub - Private Sub ListViewGEN_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ + Private Sub ListViewGEN_KeyDown(sender As Object, e As KeyEventArgs) _ Handles LvGEN.KeyDown Select Case e.KeyCode Case Keys.Delete, Keys.Back @@ -822,14 +820,14 @@ Imports TUGraz.VectoCore.Utils End Select End Sub - Private Sub ListViewGEN_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LvGEN.DoubleClick - If Me.LvGEN.SelectedItems.Count > 0 Then - Me.LvGEN.SelectedItems(0).Checked = Not Me.LvGEN.SelectedItems(0).Checked + Private Sub ListViewGEN_DoubleClick(sender As Object, e As EventArgs) Handles LvGEN.DoubleClick + If LvGEN.SelectedItems.Count > 0 Then + LvGEN.SelectedItems(0).Checked = Not LvGEN.SelectedItems(0).Checked OpenJobFile() End If End Sub - Private Sub LvGEN_ItemChecked(sender As Object, e As System.Windows.Forms.ItemCheckedEventArgs) _ + Private Sub LvGEN_ItemChecked(sender As Object, e As ItemCheckedEventArgs) _ Handles LvGEN.ItemChecked If e.Item.Checked Then @@ -842,50 +840,50 @@ Imports TUGraz.VectoCore.Utils UpdateJobTabText() End Sub - Private Sub ChBoxAllGEN_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ChBoxAllGEN_CheckedChanged(sender As Object, e As EventArgs) _ Handles ChBoxAllGEN.CheckedChanged - If GENcheckAllLock And Me.ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub + If GENcheckAllLock And ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub - CheckAllGEN(Me.ChBoxAllGEN.Checked) + CheckAllGEN(ChBoxAllGEN.Checked) End Sub - Private Sub CheckAllGEN(ByVal Check As Boolean) + Private Sub CheckAllGEN(Check As Boolean) Dim x As ListViewItem CheckLock = True - Me.LvGEN.BeginUpdate() + LvGEN.BeginUpdate() - For Each x In Me.LvGEN.Items + For Each x In LvGEN.Items x.Checked = Check Next - Me.LvGEN.EndUpdate() + LvGEN.EndUpdate() CheckLock = False - GENchecked = Me.LvGEN.CheckedItems.Count + GENchecked = LvGEN.CheckedItems.Count UpdateJobTabText() End Sub - Private Sub ListGEN_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _ + Private Sub ListGEN_DragEnter(sender As Object, e As DragEventArgs) _ Handles LvGEN.DragEnter If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then e.Effect = DragDropEffects.Copy End If End Sub - Private Sub ListGEN_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _ + 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) AddToJobListView(f) End Sub - Private Sub BtGENup_Click(sender As System.Object, e As System.EventArgs) Handles BtGENup.Click + Private Sub BtGENup_Click(sender As Object, e As EventArgs) Handles BtGENup.Click MoveItem(LvGEN, True) End Sub - Private Sub BtGENdown_Click(sender As System.Object, e As System.EventArgs) Handles BtGENdown.Click + Private Sub BtGENdown_Click(sender As Object, e As EventArgs) Handles BtGENdown.Click MoveItem(LvGEN, False) End Sub @@ -897,9 +895,9 @@ Imports TUGraz.VectoCore.Utils Dim SelIx() As Integer Dim i As Integer - If Me.LvGEN.SelectedItems.Count < 1 Then - If Me.LvGEN.Items.Count = 1 Then - Me.LvGEN.Items(0).Selected = True + If LvGEN.SelectedItems.Count < 1 Then + If LvGEN.Items.Count = 1 Then + LvGEN.Items(0).Selected = True Else Exit Sub End If @@ -950,17 +948,17 @@ Imports TUGraz.VectoCore.Utils Private Sub OpenJobFile() Dim f As String - If Me.LvGEN.SelectedItems.Count < 1 Then - If Me.LvGEN.Items.Count = 1 Then - Me.LvGEN.Items(0).Selected = True + If LvGEN.SelectedItems.Count < 1 Then + If LvGEN.Items.Count = 1 Then + LvGEN.Items(0).Selected = True Else Exit Sub End If End If - f = Me.LvGEN.SelectedItems(0).SubItems(0).Text + f = LvGEN.SelectedItems(0).SubItems(0).Text f = fFileRepl(f) - If Not IO.File.Exists(f) Then + If Not File.Exists(f) Then MsgBox(f & " not found!") Else OpenVECTOeditor(f) @@ -968,7 +966,7 @@ Imports TUGraz.VectoCore.Utils End Sub 'Add File to job listview (multiple files) - Private Sub AddToJobListView(ByVal Path As String(), Optional ByVal Txt As String = " ") + Private Sub AddToJobListView(Path As String(), Optional ByVal Txt As String = " ") Dim pDim As Int16 Dim p As Int16 Dim f As Int16 @@ -983,16 +981,16 @@ Imports TUGraz.VectoCore.Utils ReDim fList(0) 'um Nullverweisausnahme-Warnung zu verhindern '******************************************* Begin Update '******************************************* - Me.LvGEN.BeginUpdate() + LvGEN.BeginUpdate() CheckLock = True - Me.LvGEN.SelectedIndices.Clear() + LvGEN.SelectedIndices.Clear() If pDim = 0 Then - fListDim = Me.LvGEN.Items.Count - 1 + fListDim = LvGEN.Items.Count - 1 ReDim fList(fListDim) For f = 0 To fListDim - fList(f) = fFileRepl(Me.LvGEN.Items(f).SubItems(0).Text) + fList(f) = fFileRepl(LvGEN.Items(f).SubItems(0).Text) Next End If @@ -1006,14 +1004,14 @@ Imports TUGraz.VectoCore.Utils If UCase(Path(p)) = UCase(fList(f)) Then 'Status reset - Me.LvGEN.Items(f).SubItems(1).Text = Txt - Me.LvGEN.Items(f).BackColor = Color.FromKnownColor(KnownColor.Window) - Me.LvGEN.Items(f).ForeColor = Color.FromKnownColor(KnownColor.WindowText) + LvGEN.Items(f).SubItems(1).Text = Txt + LvGEN.Items(f).BackColor = Color.FromKnownColor(KnownColor.Window) + LvGEN.Items(f).ForeColor = Color.FromKnownColor(KnownColor.WindowText) 'Element auswählen und anhaken |@@| Element selection and hook - Me.LvGEN.Items(f).Selected = True - Me.LvGEN.Items(f).Checked = True - Me.LvGEN.Items(f).EnsureVisible() + LvGEN.Items(f).Selected = True + LvGEN.Items(f).Checked = True + LvGEN.Items(f).EnsureVisible() GoTo lbFound End If @@ -1026,22 +1024,22 @@ Imports TUGraz.VectoCore.Utils ListViewItem0.SubItems.Add(" ") ListViewItem0.Checked = True ListViewItem0.Selected = True - Me.LvGEN.Items.Add(ListViewItem0) + LvGEN.Items.Add(ListViewItem0) ListViewItem0.EnsureVisible() lbFound: Next - Me.LvGEN.EndUpdate() + LvGEN.EndUpdate() CheckLock = False '******************************************* End Update '******************************************* 'Number update - GENchecked = Me.LvGEN.CheckedItems.Count + GENchecked = LvGEN.CheckedItems.Count UpdateJobTabText() End Sub 'Add File to job listview (single file) - Public Sub AddToJobListView(ByVal 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) @@ -1050,19 +1048,19 @@ lbFound: 'Update job files counter in tab titel Private Sub UpdateJobTabText() Dim c As Integer - c = Me.LvGEN.Items.Count + c = LvGEN.Items.Count - Me.TabPageGEN.Text = "Job Files ( " & GENchecked & " / " & c & " )" - 'Me.TabPageGEN.Text = "Job Files (" & c & ")" + TabPageGEN.Text = "Job Files ( " & GENchecked & " / " & c & " )" + 'TabPageGEN.Text = "Job Files (" & c & ")" GENcheckAllLock = True If GENchecked = 0 Then - Me.ChBoxAllGEN.CheckState = CheckState.Unchecked + ChBoxAllGEN.CheckState = CheckState.Unchecked ElseIf GENchecked = c Then - Me.ChBoxAllGEN.CheckState = CheckState.Checked + ChBoxAllGEN.CheckState = CheckState.Checked Else - Me.ChBoxAllGEN.CheckState = CheckState.Indeterminate + ChBoxAllGEN.CheckState = CheckState.Indeterminate End If GENcheckAllLock = False @@ -1075,24 +1073,24 @@ lbFound: #Region "Events" - Private Sub ButtonDRIadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ButtonDRIadd_Click(sender As Object, e As EventArgs) _ Handles ButtonDRIadd.Click AddCycle() End Sub - Private Sub ButtonDRIremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ButtonDRIremove_Click(sender As Object, e As EventArgs) _ Handles ButtonDRIremove.Click RemoveCycle() End Sub - Private Sub ButtonDRIoptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ButtonDRIoptions_Click(sender As Object, e As EventArgs) _ Handles ButtonDRIedit.Click - ConMenTarget = Me.LvDRI + ConMenTarget = LvDRI ConMenTarJob = False - Me.ConMenFilelist.Show(Control.MousePosition) + ConMenFilelist.Show(MousePosition) End Sub - Private Sub LvDRI_ItemChecked(sender As Object, e As System.Windows.Forms.ItemCheckedEventArgs) _ + Private Sub LvDRI_ItemChecked(sender As Object, e As ItemCheckedEventArgs) _ Handles LvDRI.ItemChecked If e.Item.Checked Then @@ -1105,39 +1103,39 @@ lbFound: UpdateCycleTabText() End Sub - Private Sub ChBoxAllDRI_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ChBoxAllDRI_CheckedChanged(sender As Object, e As EventArgs) _ Handles ChBoxAllDRI.CheckedChanged Dim Check As Boolean Dim x As ListViewItem - If DRIcheckAllLock Or Me.ChBoxAllDRI.CheckState = CheckState.Indeterminate Then Exit Sub + If DRIcheckAllLock Or ChBoxAllDRI.CheckState = CheckState.Indeterminate Then Exit Sub - Check = Me.ChBoxAllDRI.Checked + Check = ChBoxAllDRI.Checked CheckLock = True - Me.LvDRI.BeginUpdate() + LvDRI.BeginUpdate() - For Each x In Me.LvDRI.Items + For Each x In LvDRI.Items x.Checked = Check Next - Me.LvDRI.EndUpdate() + LvDRI.EndUpdate() CheckLock = False - DRIchecked = Me.LvDRI.CheckedItems.Count + DRIchecked = LvDRI.CheckedItems.Count UpdateCycleTabText() End Sub - Private Sub ListViewDRI_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LvDRI.DoubleClick - If Me.LvDRI.SelectedItems.Count > 0 Then - Me.LvDRI.SelectedItems(0).Checked = Not Me.LvDRI.SelectedItems(0).Checked + Private Sub ListViewDRI_DoubleClick(sender As Object, e As EventArgs) Handles LvDRI.DoubleClick + If LvDRI.SelectedItems.Count > 0 Then + LvDRI.SelectedItems(0).Checked = Not LvDRI.SelectedItems(0).Checked OpenCycle() Else AddCycle() End If End Sub - Private Sub ListViewDRI_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ + Private Sub ListViewDRI_KeyDown(sender As Object, e As KeyEventArgs) _ Handles LvDRI.KeyDown Select Case e.KeyCode Case Keys.Delete, Keys.Back @@ -1148,12 +1146,12 @@ lbFound: End Sub 'Drag n' Drop - Private Sub ListDRI_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _ + Private Sub ListDRI_DragEnter(sender As Object, e As DragEventArgs) _ Handles LvDRI.DragEnter If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then e.Effect = DragDropEffects.Copy End Sub - Private Sub ListDRI_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _ + Private Sub ListDRI_DragDrop(sender As Object, e As DragEventArgs) _ Handles LvDRI.DragDrop Dim f As String() f = CType(e.Data.GetData(DataFormats.FileDrop), Array) @@ -1161,11 +1159,11 @@ lbFound: If LvDRI.Items.Count > 0 Then LvDRI.Items(LvDRI.Items.Count - 1).Selected = True End Sub - Private Sub BtDRIup_Click(sender As System.Object, e As System.EventArgs) Handles BtDRIup.Click + Private Sub BtDRIup_Click(sender As Object, e As EventArgs) Handles BtDRIup.Click MoveItem(LvDRI, True) End Sub - Private Sub BtDRIdown_Click(sender As System.Object, e As System.EventArgs) Handles BtDRIdown.Click + Private Sub BtDRIdown_Click(sender As Object, e As EventArgs) Handles BtDRIdown.Click MoveItem(LvDRI, False) End Sub @@ -1177,9 +1175,9 @@ lbFound: Dim SelIx() As Integer Dim i As Integer - If Me.LvDRI.SelectedItems.Count < 1 Then - If Me.LvDRI.Items.Count = 1 Then - Me.LvDRI.Items(0).Selected = True + If LvDRI.SelectedItems.Count < 1 Then + If LvDRI.Items.Count = 1 Then + LvDRI.Items(0).Selected = True Else Exit Sub End If @@ -1221,49 +1219,49 @@ lbFound: 'Open cycle in list Private Sub OpenCycle() - If Me.LvDRI.SelectedItems.Count < 1 Then - If Me.LvDRI.Items.Count = 1 Then - Me.LvDRI.Items(0).Selected = True + If LvDRI.SelectedItems.Count < 1 Then + If LvDRI.Items.Count = 1 Then + LvDRI.Items(0).Selected = True Else Exit Sub End If End If - OpenFiles(fFileRepl(Me.LvDRI.SelectedItems(0).SubItems(0).Text)) + OpenFiles(fFileRepl(LvDRI.SelectedItems(0).SubItems(0).Text)) End Sub 'Add File to cycle listview (multiple files) - Private Sub AddToCycleListView(ByVal Path As String()) + Private Sub AddToCycleListView(Path As String()) Dim pDim As Int16 Dim p As Int16 Dim ListViewItem0 As ListViewItem pDim = UBound(Path) - Me.LvDRI.BeginUpdate() + LvDRI.BeginUpdate() CheckLock = True 'Mode switch if necessary - If Not Me.CbBatch.Checked Then Me.CbBatch.Checked = True + If Not CbBatch.Checked Then CbBatch.Checked = True For p = 0 To pDim ListViewItem0 = New ListViewItem(Path(p)) 'fFileWD(Path(p))) ListViewItem0.SubItems.Add(" ") ListViewItem0.Checked = True - Me.LvDRI.Items.Add(ListViewItem0) + LvDRI.Items.Add(ListViewItem0) lbFound: Next - Me.LvDRI.EndUpdate() + LvDRI.EndUpdate() CheckLock = False 'Number update - DRIchecked = Me.LvDRI.CheckedItems.Count + DRIchecked = LvDRI.CheckedItems.Count UpdateCycleTabText() End Sub 'Add File to cycle listview (single file) - Private Sub AddToCycleListView(ByVal Path As String) + Private Sub AddToCycleListView(Path As String) Dim p(0) As String p(0) = Path AddToCycleListView(p) @@ -1272,19 +1270,19 @@ lbFound: 'Update cycle files counter in tab titel Private Sub UpdateCycleTabText() Dim c As Integer - c = Me.LvDRI.Items.Count + c = LvDRI.Items.Count - Me.TabPageDRI.Text = "Driving Cycles ( " & DRIchecked & " / " & c & " )" - 'Me.TabPageDRI.Text = "Driving Cycles (" & c & ")" + TabPageDRI.Text = "Driving Cycles ( " & DRIchecked & " / " & c & " )" + 'TabPageDRI.Text = "Driving Cycles (" & c & ")" DRIcheckAllLock = True If DRIchecked = 0 Then - Me.ChBoxAllDRI.CheckState = CheckState.Unchecked + ChBoxAllDRI.CheckState = CheckState.Unchecked ElseIf DRIchecked = c Then - Me.ChBoxAllDRI.CheckState = CheckState.Checked + ChBoxAllDRI.CheckState = CheckState.Checked Else - Me.ChBoxAllDRI.CheckState = CheckState.Indeterminate + ChBoxAllDRI.CheckState = CheckState.Indeterminate End If DRIcheckAllLock = False @@ -1295,24 +1293,24 @@ lbFound: #Region "Toolstrip" 'New Job file - Private Sub ToolStripBtNew_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtNew.Click + Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click OpenVECTOeditor("<New>") End Sub 'Open input file - Private Sub ToolStripBtOpen_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripBtOpen.Click + Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click If fbVECTO.OpenDialog("", False, "vecto,vveh,vgbx,veng,vsig") Then OpenVectoFile(fbVECTO.Files(0)) End If End Sub - Private Sub GENEditorToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub GENEditorToolStripMenuItem1_Click(sender As Object, e As EventArgs) _ Handles GENEditorToolStripMenuItem1.Click OpenVECTOeditor("<New>") End Sub - Private Sub VEHEditorToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub VEHEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles VEHEditorToolStripMenuItem.Click If Not F_VEH.Visible Then F_VEH.Show() @@ -1322,7 +1320,7 @@ lbFound: End If End Sub - Private Sub EngineEditorToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub EngineEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles EngineEditorToolStripMenuItem.Click If Not F_ENG.Visible Then F_ENG.Show() @@ -1332,7 +1330,7 @@ lbFound: End If End Sub - Private Sub GearboxEditorToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub GearboxEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles GearboxEditorToolStripMenuItem.Click If Not F_GBX.Visible Then F_GBX.Show() @@ -1342,13 +1340,13 @@ lbFound: End If End Sub - Private Sub GraphToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub GraphToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles GraphToolStripMenuItem.Click Dim FGraph As New F_Graph FGraph.Show() End Sub - Private Sub SignOrVerifyFilesToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub SignOrVerifyFilesToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles SignOrVerifyFilesToolStripMenuItem.Click If Not F_FileSign.Visible Then F_FileSign.Show() @@ -1358,33 +1356,33 @@ lbFound: End If End Sub - Private Sub OpenLogToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub OpenLogToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenLogToolStripMenuItem.Click - System.Diagnostics.Process.Start(MyAppPath & "log.txt") + Process.Start(MyAppPath & "log.txt") End Sub - Private Sub SettingsToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub SettingsToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles SettingsToolStripMenuItem.Click F_Settings.ShowDialog() End Sub - Private Sub UserManualToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub UserManualToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles UserManualToolStripMenuItem.Click - If IO.File.Exists(MyAppPath & "User Manual\help.html") Then + If File.Exists(MyAppPath & "User Manual\help.html") Then Dim BrowserRegistryString As String = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString Dim DefaultBrowserPath As String = - System.Text.RegularExpressions.Regex.Match(BrowserRegistryString, "(\"".*?\"")").Captures(0).ToString - System.Diagnostics.Process.Start(DefaultBrowserPath, Uri.EscapeDataString(MyAppPath & "User Manual\help.html")) + 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 End Sub - Private Sub UpdateNotesToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub UpdateNotesToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles UpdateNotesToolStripMenuItem.Click - If IO.File.Exists(MyAppPath & "User Manual\Release Notes.pdf") Then - System.Diagnostics.Process.Start(MyAppPath & "User Manual\Release Notes.pdf") + If File.Exists(MyAppPath & "User Manual\Release Notes.pdf") Then + Process.Start(MyAppPath & "User Manual\Release Notes.pdf") Else MsgBox("Release Notes not found!", MsgBoxStyle.Critical) End If @@ -1395,7 +1393,7 @@ lbFound: F_JIRA.ShowDialog() End Sub - Private Sub CreateActivationFileToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub CreateActivationFileToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles CreateActivationFileToolStripMenuItem.Click If MsgBox("Create Activation File ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then If Lic.CreateActFile(MyAppPath & "ActivationCode.dat") Then @@ -1407,7 +1405,7 @@ lbFound: End If End Sub - Private Sub AboutVECTOToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub AboutVECTOToolStripMenuItem1_Click(sender As Object, e As EventArgs) _ Handles AboutVECTOToolStripMenuItem1.Click F_AboutBox.ShowDialog() End Sub @@ -1416,7 +1414,7 @@ lbFound: #End Region 'Move job/cycle file up or down in list view - Private Sub MoveItem(ByRef ListV As ListView, ByVal MoveUp As Boolean) + Private Sub MoveItem(ByRef ListV As ListView, MoveUp As Boolean) Dim x As Int32 Dim y As Int32 Dim y1 As Int32 @@ -1470,7 +1468,7 @@ lbFound: #Region "job/cycle file List - Context Menu" 'Save List - Private Sub SaveListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub SaveListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles SaveListToolStripMenuItem.Click If fbFileLists.SaveDialog("") Then If ConMenTarJob Then @@ -1482,7 +1480,7 @@ lbFound: End Sub 'Load List - Private Sub LoadListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub LoadListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles LoadListToolStripMenuItem.Click If GUIlocked Then Exit Sub @@ -1491,13 +1489,13 @@ lbFound: If ConMenTarJob Then 'GEN JobListView.LoadList(fbFileLists.Files(0)) - GENchecked = Me.LvGEN.CheckedItems.Count + GENchecked = LvGEN.CheckedItems.Count UpdateJobTabText() Else 'DRI 'Mode toggle - If Not Me.CbBatch.Checked Then Me.CbBatch.Checked = True + If Not CbBatch.Checked Then CbBatch.Checked = True CycleListView.LoadList(fbFileLists.Files(0)) - DRIchecked = Me.LvDRI.CheckedItems.Count + DRIchecked = LvDRI.CheckedItems.Count UpdateCycleTabText() End If @@ -1505,7 +1503,7 @@ lbFound: End Sub 'Load Default List - Private Sub LoadDefaultListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub LoadDefaultListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles LoadDefaultListToolStripMenuItem.Click If GUIlocked Then Exit Sub @@ -1514,17 +1512,17 @@ lbFound: JobListView.LoadList() - GENchecked = Me.LvGEN.CheckedItems.Count + GENchecked = LvGEN.CheckedItems.Count UpdateJobTabText() Else CycleListView.LoadList() - DRIchecked = Me.LvDRI.CheckedItems.Count + DRIchecked = LvDRI.CheckedItems.Count UpdateCycleTabText() End If End Sub 'Clear List - Private Sub ClearListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ClearListToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ClearListToolStripMenuItem.Click 'Dim ListViewItem0 As ListViewItem 'For Each ListViewItem0 In ConMenTarget.SelectedItems @@ -1534,10 +1532,10 @@ lbFound: ConMenTarget.Items.Clear() If ConMenTarJob Then - GENchecked = Me.LvGEN.CheckedItems.Count + GENchecked = LvGEN.CheckedItems.Count UpdateJobTabText() Else - DRIchecked = Me.LvDRI.CheckedItems.Count + DRIchecked = LvDRI.CheckedItems.Count UpdateCycleTabText() End If End Sub @@ -1545,7 +1543,7 @@ lbFound: #End Region 'VECTO Start button - Calls VECTO_Launcher or aborts calculation - Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'VECTO Start/Stop If VECTOworker.IsBusy Then @@ -1584,7 +1582,7 @@ lbFound: JobFileList.AddRange(From listViewItem In LvGEN.CheckedItems Select fFileRepl(listViewItem.SubItems(0).Text)) SetOptions() - Cfg.ConfigSAVE() + Cfg.Save() ClearMSG() LockGUI(True) @@ -1621,13 +1619,13 @@ lbFound: Physics.AirDensity = New SI(Cfg.AirDensity).Kilo.Gramm.Per.Cubic.Meter Physics.CO2PerFuelWeight = Cfg.CO2perFC End If - + 'dictionary of run-identifiers to fileWriters (used for output directory of modfile) Dim fileWriters As Dictionary(Of Integer, FileOutputWriter) = New Dictionary(Of Integer, FileOutputWriter) 'list of finished runs Dim finishedRuns As List(Of Integer) = New List(Of Integer) - + For Each jobFile As String In JobFileList Try sender.ReportProgress(0, New With {.Target = "ListBox", .Message = "Reading File " + jobFile, .Link = jobFile}) @@ -1637,6 +1635,7 @@ lbFound: Dim runsFactory As SimulatorFactory = New SimulatorFactory(mode, dataProvider, fileWriter) runsFactory.WriteModalResults = Cfg.ModOut + runsFactory.ModalResults1Hz = Cfg.Mod1Hz For Each runId As Integer In jobContainer.AddRuns(runsFactory) fileWriters.Add(runId, fileWriter) @@ -1680,7 +1679,7 @@ lbFound: finishedRuns.AddRange(justFinished.Select(Function(pair) pair.Key)) Thread.Sleep(100) End While - + Dim remainingRuns As Dictionary(Of Integer, JobContainer.ProgressEntry) = jobContainer.GetProgress().Where(Function(proc) proc.Value.Done AndAlso Not finishedRuns.Contains(proc.Key)).ToDictionary(Function(pair) pair.Key, Function(pair) pair.Value) PrintRuns(remainingRuns, fileWriters) @@ -1718,7 +1717,7 @@ lbFound: Private Shared Sub PrintRuns(progress As Dictionary(Of Integer, JobContainer.ProgressEntry), 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) + Dim modFilename As String = fileWriters(p.Key).GetModDataFileName(p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix + IIf(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 @@ -1785,7 +1784,7 @@ lbFound: End Sub 'Mode Change (STANDARD/BATCH) - Private Sub CbBatch_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CbBatch.CheckedChanged + Private Sub CbBatch_CheckedChanged(sender As Object, e As EventArgs) Handles CbBatch.CheckedChanged ModeUpdate() End Sub @@ -1796,7 +1795,7 @@ lbFound: If Cfg.BatchMode Then CycleListView.SaveList() 'New mode - Cfg.BatchMode = Me.CbBatch.Checked + Cfg.BatchMode = CbBatch.Checked 'GUI changes according to current mode @@ -1808,16 +1807,16 @@ lbFound: CycleListView.LoadList() 'Update cycle counter - DRIchecked = Me.LvDRI.CheckedItems.Count + DRIchecked = LvDRI.CheckedItems.Count UpdateCycleTabText() 'Show mode-specific settings - Me.GrBoxSTD.Visible = False - Me.GrBoxBATCH.Visible = True + GrBoxSTD.Visible = False + GrBoxBATCH.Visible = True 'Show Cycle Tab Page If Not CycleTabPageVisible Then - Me.TabControl1.TabPages.Insert(1, CycleTabPage) + TabControl1.TabPages.Insert(1, CycleTabPage) CycleTabPageVisible = True End If @@ -1830,19 +1829,19 @@ lbFound: End If 'Show mode-specific settings - Me.GrBoxSTD.Visible = False 'Currently no specific settings for STANDARD mode, therefore always 'False' - Me.GrBoxBATCH.Visible = False + GrBoxSTD.Visible = False 'Currently no specific settings for STANDARD mode, therefore always 'False' + GrBoxBATCH.Visible = False 'Hide Cycle Tab Page If CycleTabPageVisible Then - Me.TabControl1.Controls.Remove(CycleTabPage) + TabControl1.Controls.Remove(CycleTabPage) CycleTabPageVisible = False End If End If 'Update job counter - GENchecked = Me.LvGEN.CheckedItems.Count + GENchecked = LvGEN.CheckedItems.Count UpdateJobTabText() 'Status label @@ -1855,7 +1854,7 @@ lbFound: Private LoadedDefault As Boolean Public LVbox As ListView - Public Sub New(ByVal Path As String) + Public Sub New(Path As String) FilePath = Path LoadedDefault = False End Sub @@ -1934,7 +1933,7 @@ lbFound: End Class 'Set color of job files in list (Error, Warnings, Currently running, etc.) - Private Sub SetCheckedItemColor(ByVal LvID As Integer, ByVal Status As tJobStatus) + Private Sub SetCheckedItemColor(LvID As Integer, Status As tJobStatus) Dim lv0 As ListViewItem lv0 = CheckedItems(LvID) @@ -1962,7 +1961,7 @@ lbFound: End Sub 'Open Job Editor and open file (or new file) - Friend Sub OpenVECTOeditor(ByVal x As String) + Friend Sub OpenVECTOeditor(x As String) If Not F_VECTO.Visible Then F_VECTO.Show() @@ -1981,7 +1980,7 @@ lbFound: End Sub 'Open signature file (.vsig) - Friend Sub OpenSigFile(ByVal file As String) + Friend Sub OpenSigFile(file As String) If Not F_FileSign.Visible Then F_FileSign.Show() @@ -2003,21 +2002,21 @@ lbFound: 'Initialise progress bar (Start of next job in calculation) Private Sub ProgSecStart() - Me.ToolStripProgBarJob.Value = 0 - Me.ToolStripProgBarJob.Style = ProgressBarStyle.Marquee - Me.ToolStripProgBarJob.Visible = True - Me.TmProgSec.Start() + ToolStripProgBarJob.Value = 0 + ToolStripProgBarJob.Style = ProgressBarStyle.Marquee + ToolStripProgBarJob.Visible = True + TmProgSec.Start() End Sub 'Stop - Hide progress bar Private Sub ProgSecStop() - Me.TmProgSec.Stop() - Me.ToolStripProgBarJob.Visible = False - Me.ToolStripProgBarJob.Value = 0 + TmProgSec.Stop() + ToolStripProgBarJob.Visible = False + ToolStripProgBarJob.Value = 0 End Sub 'Timer to update progress bar regularly - Private Sub TmProgSec_Tick(sender As Object, e As System.EventArgs) Handles TmProgSec.Tick + Private Sub TmProgSec_Tick(sender As Object, e As EventArgs) Handles TmProgSec.Tick If GUItest0.TestActive Then Call GUItest0.TestTick() Exit Sub @@ -2031,8 +2030,8 @@ lbFound: With ProgBarCtrl - If .ProgJobInt > 0 AndAlso Me.ToolStripProgBarJob.Style = ProgressBarStyle.Marquee Then - Me.ToolStripProgBarJob.Style = ProgressBarStyle.Continuous + If .ProgJobInt > 0 AndAlso ToolStripProgBarJob.Style = ProgressBarStyle.Marquee Then + ToolStripProgBarJob.Style = ProgressBarStyle.Continuous End If If .ProgJobInt < 0 Then @@ -2041,11 +2040,11 @@ lbFound: .ProgJobInt = 100 End If - Me.ToolStripProgBarJob.Value = .ProgJobInt + ToolStripProgBarJob.Value = .ProgJobInt - If .ProgOverallStartInt > - 1 Then - Me.ToolStripProgBarOverall.Value = - CInt(.ProgOverallStartInt + (.PgroOverallEndInt - .ProgOverallStartInt)*.ProgJobInt/100) + If .ProgOverallStartInt > -1 Then + ToolStripProgBarOverall.Value = + CInt(.ProgOverallStartInt + (.PgroOverallEndInt - .ProgOverallStartInt) * .ProgJobInt / 100) End If End With @@ -2058,68 +2057,70 @@ lbFound: 'Load options from config class Public Sub LoadOptions() - Me.ChBoxCyclDistCor.Checked = Cfg.DistCorr - Me.ChBoxUseGears.Checked = Cfg.GnUfromCycle - Me.ChBoxModOut.Checked = Cfg.ModOut - CbBOmode.SelectedIndex = - 1 + ChBoxCyclDistCor.Checked = Cfg.DistCorr + ChBoxUseGears.Checked = Cfg.GnUfromCycle + ChBoxModOut.Checked = Cfg.ModOut + ChBoxMod1Hz.Checked = Cfg.Mod1Hz + CbBOmode.SelectedIndex = -1 Select Case UCase(Cfg.BATCHoutpath) Case sKey.JobPath CbBOmode.SelectedIndex = 0 Case Else CbBOmode.SelectedIndex = 1 - Me.TbBOpath.Text = Cfg.BATCHoutpath + TbBOpath.Text = Cfg.BATCHoutpath End Select - Me.ChBoxBatchSubD.Checked = Cfg.BATCHoutSubD + ChBoxBatchSubD.Checked = Cfg.BATCHoutSubD 'Set Mode - If Not Cfg.DeclMode Then Me.CbBatch.Checked = Cfg.BatchMode + If Not Cfg.DeclMode Then CbBatch.Checked = Cfg.BatchMode - Me.RbDecl.Checked = Cfg.DeclMode + RbDecl.Checked = Cfg.DeclMode End Sub 'Update config class from options in GUI, e.g. before running calculations Private Sub SetOptions() 'General(Allgemein) - Cfg.DistCorr = Me.ChBoxCyclDistCor.Checked - Cfg.GnUfromCycle = Me.ChBoxUseGears.Checked + Cfg.DistCorr = ChBoxCyclDistCor.Checked + Cfg.GnUfromCycle = ChBoxUseGears.Checked 'BATCH - Cfg.ModOut = Me.ChBoxModOut.Checked + Cfg.ModOut = ChBoxModOut.Checked + Cfg.Mod1Hz = ChBoxMod1Hz.Checked Select Case CbBOmode.SelectedIndex Case 0 Cfg.BATCHoutpath = sKey.JobPath Case Else - Cfg.BATCHoutpath = Trim(Me.TbBOpath.Text) + Cfg.BATCHoutpath = Trim(TbBOpath.Text) If Microsoft.VisualBasic.Right(Cfg.BATCHoutpath, 1) <> "\" Then Cfg.BATCHoutpath &= "\" End Select - Cfg.BATCHoutSubD = Me.ChBoxBatchSubD.Checked + Cfg.BATCHoutSubD = ChBoxBatchSubD.Checked DEV.SetOptions() End Sub #Region "Events" - Private Sub ChBoxAutoSD_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ChBoxAutoSD_CheckedChanged(sender As Object, e As EventArgs) _ Handles ChBoxAutoSD.CheckedChanged - Me.LbAutoShDown.Visible = Me.ChBoxAutoSD.Checked + LbAutoShDown.Visible = ChBoxAutoSD.Checked End Sub - Private Sub CbBOmode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub CbBOmode_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles CbBOmode.SelectedIndexChanged - Me.TbBOpath.Visible = (Me.CbBOmode.SelectedIndex = 2) - Me.ButBObrowse.Visible = (Me.CbBOmode.SelectedIndex = 2) + TbBOpath.Visible = (CbBOmode.SelectedIndex = 2) + ButBObrowse.Visible = (CbBOmode.SelectedIndex = 2) End Sub - Private Sub ButBObrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButBObrowse.Click - If fbFolder.OpenDialog(Me.TbBOpath.Text) Then - Me.TbBOpath.Text = fbFolder.Files(0) + Private Sub ButBObrowse_Click(sender As Object, e As EventArgs) Handles ButBObrowse.Click + If fbFolder.OpenDialog(TbBOpath.Text) Then + TbBOpath.Text = fbFolder.Files(0) End If End Sub - Private Sub ChBoxBatchOut_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Private Sub ChBoxBatchOut_CheckedChanged(sender As Object, e As EventArgs) _ Handles ChBoxModOut.CheckedChanged - Me.ChBoxBatchSubD.Enabled = Me.ChBoxModOut.Checked + ChBoxBatchSubD.Enabled = ChBoxModOut.Checked End Sub #End Region @@ -2135,9 +2136,9 @@ lbFound: Dim i As Integer Dim Config0 As KeyValuePair(Of String, cDEVoption) - Me.LvDEVoptions.Items.Clear() + LvDEVoptions.Items.Clear() - i = - 1 + i = -1 For Each Config0 In DEV.Options i += 1 @@ -2165,7 +2166,7 @@ lbFound: LV0.ForeColor = Color.DarkGray End If - Me.LvDEVoptions.Items.Add(LV0) + LvDEVoptions.Items.Add(LV0) UpdateDEVconfigs(LV0) @@ -2178,12 +2179,12 @@ lbFound: End Sub 'Change value of DEV option or execute action-type DEV options - Private Sub LvDEVoptions_DoubleClick(sender As Object, e As System.EventArgs) Handles LvDEVoptions.DoubleClick + Private Sub LvDEVoptions_DoubleClick(sender As Object, e As EventArgs) Handles LvDEVoptions.DoubleClick Dim Config0 As cDEVoption Dim str As String Dim i As Integer - Config0 = DEV.Options(Me.LvDEVoptions.SelectedItems(0).Tag) + Config0 = DEV.Options(LvDEVoptions.SelectedItems(0).Tag) If Not Config0.Enabled Then Exit Sub @@ -2196,11 +2197,11 @@ lbFound: Case tDEVconfType.tSelection - CmDEVitem = Me.LvDEVoptions.SelectedItems(0) + CmDEVitem = LvDEVoptions.SelectedItems(0) CmDEV.Items.Clear() - i = - 1 + i = -1 For Each str In Config0.Modes i += 1 CmDEV.Items.Add("(" & i & ") " & str) @@ -2226,11 +2227,11 @@ lbFound: Config0.StringVal = dlg.ShowDlog("New Value <" & Config0.TypeString & "> =", Config0.StringVal) End Select - UpdateDEVconfigs(Me.LvDEVoptions.SelectedItems(0)) + UpdateDEVconfigs(LvDEVoptions.SelectedItems(0)) End Sub 'Context menu for selection-type DEV options - Private Sub CmDEV_ItemClicked(sender As Object, e As System.Windows.Forms.ToolStripItemClickedEventArgs) _ + Private Sub CmDEV_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) _ Handles CmDEV.ItemClicked Dim i As Integer @@ -2245,7 +2246,7 @@ lbFound: #End Region 'Add message to message list - Public Sub MSGtoForm(ByVal ID As tMsgID, ByVal Msg As String, ByVal Source As String, ByVal Link As String) + Public Sub MSGtoForm(ID As tMsgID, Msg As String, Source As String, Link As String) Dim lv0 As ListViewItem @@ -2281,7 +2282,7 @@ lbFound: If Link <> "" Then If Not ID = tMsgID.Err Then lv0.ForeColor = Color.Blue - lv0.SubItems(0).Font = New Font(Me.LvMsg.Font, FontStyle.Underline) + lv0.SubItems(0).Font = New Font(LvMsg.Font, FontStyle.Underline) lv0.Tag = Link End If @@ -2293,47 +2294,47 @@ lbFound: 'Open link in message list - Private Sub LvMsg_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles LvMsg.MouseClick + Private Sub LvMsg_MouseClick(sender As Object, e As MouseEventArgs) Handles LvMsg.MouseClick Dim txt As String - If Me.LvMsg.SelectedIndices.Count > 0 Then - If Not Me.LvMsg.SelectedItems(0).Tag Is Nothing Then + If LvMsg.SelectedIndices.Count > 0 Then + If Not LvMsg.SelectedItems(0).Tag Is Nothing Then If _ - Len(CStr(Me.LvMsg.SelectedItems(0).Tag)) > 4 AndAlso - Microsoft.VisualBasic.Left(CStr(Me.LvMsg.SelectedItems(0).Tag), 4) = "<UM>" Then - txt = CStr(Me.LvMsg.SelectedItems(0).Tag).Replace("<UM>", MyAppPath & "User Manual") + Len(CStr(LvMsg.SelectedItems(0).Tag)) > 4 AndAlso + Microsoft.VisualBasic.Left(CStr(LvMsg.SelectedItems(0).Tag), 4) = "<UM>" Then + txt = CStr(LvMsg.SelectedItems(0).Tag).Replace("<UM>", MyAppPath & "User Manual") txt = txt.Replace(" ", "%20") txt = txt.Replace("\", "/") txt = "file:///" & txt Try - System.Diagnostics.Process.Start(txt) + Process.Start(txt) Catch ex As Exception MsgBox("Cannot open link! (-_-;)") End Try ElseIf _ - Len(CStr(Me.LvMsg.SelectedItems(0).Tag)) > 5 AndAlso - Microsoft.VisualBasic.Left(CStr(Me.LvMsg.SelectedItems(0).Tag), 5) = "<GUI>" Then - txt = CStr(Me.LvMsg.SelectedItems(0).Tag).Replace("<GUI>", "") + Len(CStr(LvMsg.SelectedItems(0).Tag)) > 5 AndAlso + Microsoft.VisualBasic.Left(CStr(LvMsg.SelectedItems(0).Tag), 5) = "<GUI>" Then + txt = CStr(LvMsg.SelectedItems(0).Tag).Replace("<GUI>", "") OpenVectoFile(txt) ElseIf _ - Len(CStr(Me.LvMsg.SelectedItems(0).Tag)) > 5 AndAlso - Microsoft.VisualBasic.Left(CStr(Me.LvMsg.SelectedItems(0).Tag), 5) = "<RUN>" Then - txt = CStr(Me.LvMsg.SelectedItems(0).Tag).Replace("<RUN>", "") + Len(CStr(LvMsg.SelectedItems(0).Tag)) > 5 AndAlso + Microsoft.VisualBasic.Left(CStr(LvMsg.SelectedItems(0).Tag), 5) = "<RUN>" Then + txt = CStr(LvMsg.SelectedItems(0).Tag).Replace("<RUN>", "") Try Process.Start(txt) Catch ex As Exception GUImsg(tMsgID.Err, "Could not run '" & txt & "'!") End Try Else - OpenFiles(CStr(Me.LvMsg.SelectedItems(0).Tag)) + OpenFiles(CStr(LvMsg.SelectedItems(0).Tag)) End If End If End If End Sub 'Link-cursor (Hand) for links - Private Sub LvMsg_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles LvMsg.MouseMove + Private Sub LvMsg_MouseMove(sender As Object, e As MouseEventArgs) Handles LvMsg.MouseMove Dim lv0 As ListViewItem - lv0 = Me.LvMsg.GetItemAt(e.Location.X, e.Location.Y) + lv0 = LvMsg.GetItemAt(e.Location.X, e.Location.Y) If lv0 Is Nothing OrElse lv0.Tag Is Nothing Then LvMsg.Cursor = Cursors.Arrow Else @@ -2358,7 +2359,7 @@ lbFound: CmFiles = files - Me.OpenInGraphWindowToolStripMenuItem.Enabled = (UCase(fEXT(CmFiles(0))) = ".VMOD") + OpenInGraphWindowToolStripMenuItem.Enabled = (UCase(fEXT(CmFiles(0))) = ".VMOD") OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName @@ -2367,12 +2368,12 @@ lbFound: End Sub 'Open with tool defined in Settings - Private Sub OpenWithToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenWithToolStripMenuItem.Click If Not FileOpenAlt(CmFiles(0)) Then MsgBox("Failed to open file!") End Sub - Private Sub OpenInGraphWindowToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub OpenInGraphWindowToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles OpenInGraphWindowToolStripMenuItem.Click Dim FGraph As New F_Graph FGraph.Show() @@ -2380,11 +2381,11 @@ lbFound: End Sub 'Show in folder - Private Sub ShowInFolderToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _ Handles ShowInFolderToolStripMenuItem.Click - If IO.File.Exists(CmFiles(0)) Then + If File.Exists(CmFiles(0)) Then Try - System.Diagnostics.Process.Start("explorer", "/select,""" & CmFiles(0) & "") + Process.Start("explorer", "/select,""" & CmFiles(0) & "") Catch ex As Exception MsgBox("Failed to open file!") End Try @@ -2396,17 +2397,17 @@ lbFound: #End Region 'Change Declaraion Mode - Private Sub RbDecl_CheckedChanged(sender As Object, e As System.EventArgs) Handles RbDecl.CheckedChanged + Private Sub RbDecl_CheckedChanged(sender As Object, e As EventArgs) Handles RbDecl.CheckedChanged If CbDeclLock Then Exit Sub If F_VECTO.Visible Or F_VEH.Visible Or F_GBX.Visible Or F_ENG.Visible Then CbDeclLock = True - Me.RbDecl.Checked = Not Me.RbDecl.Checked + RbDecl.Checked = Not RbDecl.Checked CbDeclLock = False MsgBox("Please close all dialog windows (e.g. Job Editor) before changing mode!") Else - Cfg.DeclMode = Me.RbDecl.Checked - Me.RbDev.Checked = Not Me.RbDecl.Checked + Cfg.DeclMode = RbDecl.Checked + RbDev.Checked = Not RbDecl.Checked DeclOnOff() End If End Sub @@ -2529,7 +2530,7 @@ lbFound: MyForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " " & Space(10) & "*| |*") End Select Exit Sub - LbRace: +LbRace: PRbAlt = Not PRbAlt @@ -2557,17 +2558,17 @@ lbFound: sAbort() Exit Sub End If - Scr += 5*DiffLvl + Scr += 5 * DiffLvl End If Scr += DiffLvl DiffC += 1 'Erhöhe Schwierigkeitsgrad - If DiffC = (DiffLvl + 3)*4 Then + If DiffC = (DiffLvl + 3) * 4 Then DiffC = 0 DiffLvl += 1 - If DiffLvl > 2 And DiffLvl < 7 Then MyForm.TmProgSec.Interval = 300 - (DiffLvl)*30 + If DiffLvl > 2 And DiffLvl < 7 Then MyForm.TmProgSec.Interval = 300 - (DiffLvl) * 30 Scr += 100 Select Case DiffLvl Case 3 @@ -2586,7 +2587,7 @@ lbFound: End If End Sub - Public Sub TestKey(ByVal Key0 As Integer) + Public Sub TestKey(Key0 As Integer) If TestActive Then Select Case Key0 @@ -2651,10 +2652,10 @@ lbFound: Ctrls(RowLim + 1) = 0 CtrlC += 1 If CtrlC < CtrlCL Then Exit Sub - Select Case CInt(Int((CtrlRnd*Rnd()) + 1)) + Select Case CInt(Int((CtrlRnd * Rnd()) + 1)) Case 1, 2 CtrlC = 0 - x = CInt(Int((7*Rnd()) + 1)) + x = CInt(Int((7 * Rnd()) + 1)) Ctrls(RowLim + 1) = x Case Else End Select @@ -2698,7 +2699,7 @@ lbFound: s = s.Insert(Ctrls(RowLim + 1) + 1, "X") End If Select Case xPanel - Pnls(RowLim) - Case - 1 + Case -1 s = Replace(s, "|", "\") Case 1 s = Replace(s, "|", "/") @@ -2710,15 +2711,15 @@ lbFound: PnDirC += 1 If PnDirC < PnDirCL Then GoTo Lb1 PnDirC = 0 - Select Case CInt(Int((PnDirRnd*Rnd()) + 1)) + Select Case CInt(Int((PnDirRnd * Rnd()) + 1)) Case 1 PnDir = 1 Case 2 - PnDir = - 1 + PnDir = -1 Case Else PnDir = 0 End Select - Lb1: +Lb1: xPanel += PnDir If xPanel > ColLim Then xPanel = ColLim @@ -2736,7 +2737,7 @@ lbFound: Next End Sub - Public Sub New(ByVal Form As F_MAINForm) + Public Sub New(Form As F_MAINForm) MyForm = Form KeyCode = New List(Of Integer) KeyCode.Add(Keys.Up) @@ -2753,12 +2754,12 @@ lbFound: End Sub End Class - Private Sub LvMsg_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles LvMsg.KeyDown + Private Sub LvMsg_KeyDown(sender As Object, e As KeyEventArgs) Handles LvMsg.KeyDown GUItest0.TestKey(e.KeyValue) If GUItest0.TestActive Then e.SuppressKeyPress = True End Sub - Private Sub LvMsg_LostFocus(sender As Object, e As System.EventArgs) Handles LvMsg.LostFocus + Private Sub LvMsg_LostFocus(sender As Object, e As EventArgs) Handles LvMsg.LostFocus If GUItest0.TestActive Then GUItest0.TestStop() End Sub @@ -2769,7 +2770,7 @@ lbFound: Dim builder As StringBuilder = New StringBuilder() For Each selectedItem As ListViewItem In LvMsg.SelectedItems builder.AppendLine(String.Join(", ", - selectedItem.SubItems.Cast (Of ListViewItem.ListViewSubItem).Select( + selectedItem.SubItems.Cast(Of ListViewItem.ListViewSubItem).Select( Function(item) item.Text))) Next Clipboard.SetText(builder.ToString()) diff --git a/VECTO/GUI/F_Settings.vb b/VECTO/GUI/F_Settings.vb index 3cc4f3f534467d0b61fe35c205f7bd0300b97731..73d618bb4633a0e58f1745af7a673c7063657a9f 100644 --- a/VECTO/GUI/F_Settings.vb +++ b/VECTO/GUI/F_Settings.vb @@ -57,7 +57,7 @@ Public Class F_Settings Cfg.CO2perFC = CSng(Me.TbCO2toFC.Text) '---------------------------------------------------- - Cfg.ConfigSAVE() + Cfg.Save() Me.Close() End Sub diff --git a/VECTO/Input Files/cENG.vb b/VECTO/Input Files/cENG.vb index dcc658ba95e11a2c910d9a91df3e385cb96862ca..665478465b5a5536860a9592041ff2b9b1984d3e 100644 --- a/VECTO/Input Files/cENG.vb +++ b/VECTO/Input Files/cENG.vb @@ -1,4 +1,4 @@ -' Copyright 2014 European Union. +' Copyright 2014 European Union. ' Licensed under the EUPL (the 'Licence'); ' ' * You may not use this work except in compliance with the Licence. @@ -187,7 +187,7 @@ End Property ''' <returns>True if successful.</returns> ''' <remarks></remarks> Public Function SaveFile() As Boolean - Dim JSON As New cJSON + Dim JSON As New JSON Dim dic As Dictionary(Of String, Object) 'Header @@ -234,7 +234,7 @@ End Property ''' <remarks></remarks> Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean Dim MsgSrc As String - Dim JSON As New cJSON + Dim JSON As New JSON MsgSrc = "ENG/ReadFile" diff --git a/VECTO/Input Files/cGBX.vb b/VECTO/Input Files/cGBX.vb index 784bc4938e1ff6bd690eba6a059745e45a735cad..8cb0603aa3e46c0870b95de62826dbcea85e04c0 100644 --- a/VECTO/Input Files/cGBX.vb +++ b/VECTO/Input Files/cGBX.vb @@ -1,4 +1,4 @@ -' Copyright 2014 European Union. +' Copyright 2014 European Union. ' Licensed under the EUPL (the 'Licence'); ' ' * You may not use this work except in compliance with the Licence. @@ -146,7 +146,7 @@ Public Class cGBX Public Function SaveFile() As Boolean Dim i As Integer - Dim JSON As New cJSON + Dim JSON As New JSON Dim dic As Dictionary(Of String, Object) Dim dic0 As Dictionary(Of String, Object) Dim ls As List(Of Object) @@ -215,7 +215,7 @@ Public Class cGBX Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean Dim i As Integer Dim MsgSrc As String - Dim JSON As New cJSON + Dim JSON As New JSON Dim dic As Object MsgSrc = "GBX/ReadFile" diff --git a/VECTO/Input Files/cVECTO.vb b/VECTO/Input Files/cVECTO.vb index f4746dc0a54b5cb4888353eea78abe89f10f086f..dd22112b39d668404960c5c4de26b663a6b8d822 100644 --- a/VECTO/Input Files/cVECTO.vb +++ b/VECTO/Input Files/cVECTO.vb @@ -165,7 +165,7 @@ Public Class cVECTO Dim AuxEntryKV As KeyValuePair(Of String, cAuxEntry) 'Dim s As String Dim sb As cSubPath - Dim JSON As New cJSON + Dim JSON As New JSON Dim ls As List(Of Object) Dim dic As Dictionary(Of String, Object) Dim dic0 As Dictionary(Of String, Object) @@ -272,7 +272,7 @@ Public Class cVECTO Dim AuxID As String Dim MsgSrc As String Dim SubPath As cSubPath - Dim JSON As New cJSON + Dim JSON As New JSON Dim str As String Dim dic As Object diff --git a/VECTO/Input Files/cVEH.vb b/VECTO/Input Files/cVEH.vb index 18c8c66d33bf4a263323e22c2768c3769fe1d3c9..eee1b8beeaa945734c8d6c6a61e6e03b386f70ec 100644 --- a/VECTO/Input Files/cVEH.vb +++ b/VECTO/Input Files/cVEH.vb @@ -1,4 +1,4 @@ -' Copyright 2014 European Union. +' Copyright 2014 European Union. ' Licensed under the EUPL (the 'Licence'); ' ' * You may not use this work except in compliance with the Licence. @@ -144,7 +144,7 @@ Public Class cVEH Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean Dim Itemp As Single Dim a0 As cAxle - Dim JSON As New cJSON + Dim JSON As New JSON Dim dic As Object Dim MsgSrc As String @@ -267,7 +267,7 @@ Public Class cVEH Dim dic0 As Dictionary(Of String, Object) Dim ls As List(Of Dictionary(Of String, Object)) Dim a0 As cAxle - Dim JSON As New cJSON + Dim JSON As New JSON 'Header diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index 0882913402ef443cb1ef5bd2b0d9be800b56cd3c..24edccaada55778d0cb4ff15181f2092ecae4afc 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -222,7 +222,7 @@ <Compile Include="Input Files\cAuxEntryPS.vb" /> <Compile Include="Input Files\cENG.vb" /> <Compile Include="Input Files\cGBX.vb" /> - <Compile Include="cConfig.vb" /> + <Compile Include="Configuration.vb" /> <Compile Include="cDelaunayMap.vb" /> <Compile Include="cDEV.vb" /> <Compile Include="File Browser\cFileBrowser.vb" /> diff --git a/VECTO/VECTO_Global.vb b/VECTO/VECTO_Global.vb index 2f7173066e2c8a7266f85b2727074fba58091614..9eab4688b6976511aef84aab13a4d9715de82946 100644 --- a/VECTO/VECTO_Global.vb +++ b/VECTO/VECTO_Global.vb @@ -8,39 +8,36 @@ ' 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 -Imports System.Reflection -Imports Microsoft.VisualBasic.ApplicationServices -Imports TUGraz.VectoCore.Models.Simulation.Impl +Imports System.ComponentModel +Imports System.IO +Imports System.Text +Imports vectolic Module VECTO_Global Public Const VECTOvers As String = "2.2" - Public COREvers As String = "NOT FOUND" 'Assembly.LoadFrom("VectoCore.dll").GetName().Version.ToString() + Public COREvers As String = "NOT FOUND" Public Const LicSigAppCode As String = "VECTO-Release-0093C61E0A2E4BFA9A7ED7E729C56AE4" Public MyAppPath As String Public MyConfPath As String Public MyDeclPath As String - 'Log Public LogFile As cLogFile - 'BackgroundWorker - Public VECTOworker As System.ComponentModel.BackgroundWorker - Public VECTOworkerV3 As System.ComponentModel.BackgroundWorker + 'to ensure correct format for backgroundworker thread + Public SetCulture As Boolean + + Public VECTOworker As BackgroundWorker + Public VECTOworkerV3 As BackgroundWorker - 'Log/Msg Public MSGerror As Integer Public MSGwarn As Integer - 'Config------------------------------------------------------- - Public Cfg As cConfig + Public Cfg As Configuration Public sKey As csKey - 'File format - Public FileFormat As System.Text.Encoding = System.Text.Encoding.UTF8 + Public FileFormat As Encoding = Encoding.UTF8 Public VEC As cVECTO Public VEH As cVEH @@ -49,7 +46,7 @@ Module VECTO_Global Public MAP As cMAP Public DRI As cDRI Public MODdata As cMOD - Public Lic As vectolic.cLicense + Public Lic As cLicense Public VSUM As cVSUM Public DEV As cDEV @@ -57,21 +54,33 @@ Module VECTO_Global Public ProgBarCtrl As cProgBarCtrl - Public SetCulture As Boolean 'Damit der Backgroundworker das richtige Format verwendet - - Public Function nMtoPe(ByVal nU As Double, ByVal M As Double) As Double - Return ((nU*2*Math.PI/60)*M/1000) + ''' <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 Function nPeToM(ByVal nU As Single, ByVal Pe As Double) As Single - Return Pe*1000/(nU*2*Math.PI/60) + ''' <summary> + ''' Convert engine speed and power to torque. + ''' </summary> + ''' <param name="nU">engine speed</param> + ''' <param name="Pe">Power</param> + ''' <returns>Torque</returns> + ''' <remarks></remarks> + Public Function nPeToM(nU As Single, Pe As Double) As Single + Return Pe * 1000 / (nU * 2 * Math.PI / 60) End Function #Region "sKey > Typ Umwandlung" - Public Function GearboxConv(ByVal Gearbox As tGearbox) As String + Public Function GearboxConv(Gearbox As tGearbox) As String Select Case Gearbox Case tGearbox.Manual Return "MT" @@ -84,7 +93,7 @@ Module VECTO_Global End Select End Function - Public Function GearboxConv(ByVal Gearbox As String) As tGearbox + Public Function GearboxConv(Gearbox As String) As tGearbox Select Case UCase(Trim(Gearbox)) Case "MT" Return tGearbox.Manual @@ -97,7 +106,7 @@ Module VECTO_Global End Select End Function - Public Function fDriComp(ByVal sK As String) As tDriComp + Public Function fDriComp(sK As String) As tDriComp sK = Trim(UCase(sK)) Select Case sK Case sKey.DRI.t @@ -134,13 +143,13 @@ Module VECTO_Global End Select End Function - Public Function fAuxComp(ByVal sK As String) As tAuxComp + Public Function fAuxComp(sK As String) As tAuxComp Dim x As Integer sK = Trim(UCase(sK)) x = sK.IndexOf("_") - If x = - 1 Then Return tAuxComp.Undefined + If x = -1 Then Return tAuxComp.Undefined sK = Left(sK, x + 1) @@ -153,20 +162,20 @@ Module VECTO_Global End Function - Public Function fCompSubStr(ByVal sK As String) As String + Public Function fCompSubStr(sK As String) As String Dim x As Integer sK = Trim(UCase(sK)) x = sK.IndexOf("_") - If x = - 1 Then Return "" + If x = -1 Then Return "" sK = Right(sK, Len(sK) - x - 1) x = CShort(sK.IndexOf(">")) - If x = - 1 Then Return "" + If x = -1 Then Return "" sK = Left(sK, x) @@ -178,7 +187,7 @@ Module VECTO_Global #Region "Typ > Name Conversion" - Public Function ConvLoading(ByVal load As tLoading) As String + Public Function ConvLoading(load As tLoading) As String Select Case load Case tLoading.FullLoaded Return "Full Loading" @@ -196,7 +205,7 @@ Module VECTO_Global End Function - Public Function ConvVehCat(ByVal VehCat As tVehCat, ByVal NiceName As Boolean) As String + Public Function ConvVehCat(VehCat As tVehCat, NiceName As Boolean) As String Select Case VehCat Case tVehCat.Citybus Return "Citybus" @@ -225,7 +234,7 @@ Module VECTO_Global End Select End Function - Public Function ConvVehCat(ByVal VehCat As String) As tVehCat + Public Function ConvVehCat(VehCat As String) As tVehCat Select Case UCase(Trim(VehCat)) Case "CITYBUS" Return tVehCat.Citybus @@ -242,7 +251,7 @@ Module VECTO_Global End Select End Function - Public Function ConvAxleConf(ByVal AxleConf As tAxleConf) As String + Public Function ConvAxleConf(AxleConf As tAxleConf) As String Select Case AxleConf Case tAxleConf.a4x2 Return "4x2" @@ -265,7 +274,7 @@ Module VECTO_Global End Select End Function - Public Function ConvAxleConf(ByVal AxleConf As String) As tAxleConf + Public Function ConvAxleConf(AxleConf As String) As tAxleConf Select Case UCase(Trim(AxleConf)) Case "4X2" Return tAxleConf.a4x2 @@ -288,7 +297,7 @@ Module VECTO_Global End Select End Function - Public Function ConvMission(ByVal Mission As tMission) As String + Public Function ConvMission(Mission As tMission) As String Select Case Mission Case tMission.LongHaul Return "LongHaul" @@ -315,7 +324,7 @@ Module VECTO_Global End Select End Function - Public Function ConvMission(ByVal Mission As String) As tMission + Public Function ConvMission(Mission As String) As tMission Select Case Mission Case "LongHaul" Return tMission.LongHaul @@ -343,7 +352,7 @@ Module VECTO_Global End Function - Public Function CdModeConv(ByVal CdMode As tCdMode) As String + Public Function CdModeConv(CdMode As tCdMode) As String Select Case CdMode Case tCdMode.CdOfBeta Return "CdOfBeta" @@ -356,7 +365,7 @@ Module VECTO_Global End Select End Function - Public Function CdModeConv(ByVal CdMode As String) As tCdMode + Public Function CdModeConv(CdMode As String) As tCdMode Select Case UCase(Trim(CdMode)) Case "CDOFBETA" Return tCdMode.CdOfBeta @@ -370,7 +379,7 @@ Module VECTO_Global End Function - Public Function RtTypeConv(ByVal RtType As tRtType) As String + Public Function RtTypeConv(RtType As tRtType) As String Select Case RtType Case tRtType.Primary Return "Primary" @@ -381,7 +390,7 @@ Module VECTO_Global End Select End Function - Public Function RtTypeConv(ByVal RtType As String) As tRtType + Public Function RtTypeConv(RtType As String) As tRtType Select Case UCase(Trim(RtType)) Case "PRIMARY" Return tRtType.Primary @@ -394,13 +403,10 @@ Module VECTO_Global #End Region - Public Class cLogFile - Private LOGstream As System.IO.StreamWriter + Private LOGstream As StreamWriter Public Function StartLog() As Boolean - - 'Log start Try LOGstream = My.Computer.FileSystem.OpenTextFileWriter(MyAppPath & "LOG.txt", True, FileFormat) LOGstream.AutoFlush = True @@ -414,17 +420,17 @@ Module VECTO_Global End Function Public Function SizeCheck() As Boolean - Dim logfDetail As IO.FileInfo + Dim logfDetail As FileInfo Dim BackUpError As Boolean 'Start new log if file size limit reached - If IO.File.Exists(MyAppPath & "LOG.txt") Then + If File.Exists(MyAppPath & "LOG.txt") Then 'File size check logfDetail = My.Computer.FileSystem.GetFileInfo(MyAppPath & "LOG.txt") 'If Log too large: Delete - If logfDetail.Length/(2^20) > Cfg.LogSize Then + If logfDetail.Length / (2 ^ 20) > Cfg.LogSize Then WriteToLog(tMsgID.Normal, "Starting new logfile") LOGstream.Close() @@ -432,8 +438,8 @@ Module VECTO_Global BackUpError = False Try - If IO.File.Exists(MyAppPath & "LOG_backup.txt") Then IO.File.Delete(MyAppPath & "LOG_backup.txt") - IO.File.Move(MyAppPath & "LOG.txt", MyAppPath & "LOG_backup.txt") + 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 End Try @@ -465,7 +471,7 @@ Module VECTO_Global End Function - Public Function WriteToLog(ByVal MsgType As tMsgID, ByVal Msg As String) As Boolean + Public Function WriteToLog(MsgType As tMsgID, Msg As String) As Boolean Dim MsgTypeStr As String Select Case MsgType @@ -489,7 +495,7 @@ Module VECTO_Global #Region "File path functions" 'When no path is specified, then insert either HomeDir or MainDir Special-folders - Public Function fFileRepl(ByVal file As String, Optional ByVal MainDir As String = "") As String + Public Function fFileRepl(file As String, Optional ByVal MainDir As String = "") As String Dim ReplPath As String @@ -500,9 +506,9 @@ Module VECTO_Global If file = "" Then Return "" 'Replace sKeys - file = Microsoft.VisualBasic.Strings.Replace(file, sKey.DefVehPath & "\", MyAppPath & "Default Vehicles\", 1, - 1, - CompareMethod.Text) - file = Microsoft.VisualBasic.Strings.Replace(file, sKey.HomePath & "\", MyAppPath, 1, - 1, CompareMethod.Text) + file = Replace(file, sKey.DefVehPath & "\", MyAppPath & "Default Vehicles\", 1, -1, + CompareMethod.Text) + file = Replace(file, sKey.HomePath & "\", MyAppPath, 1, -1, CompareMethod.Text) 'Replace - Determine folder If MainDir = "" Then @@ -529,37 +535,37 @@ Module VECTO_Global End Function 'Path one-level-up "C:\temp\ordner1\" >> "C:\temp\" - Private Function fPathUp(ByVal Pfad As String) As String + Private Function fPathUp(Pfad As String) As String Dim x As Int16 Pfad = Pfad.Substring(0, Pfad.Length - 1) x = Pfad.LastIndexOf("\") - If x = - 1 Then Return "" + If x = -1 Then Return "" Return Pfad.Substring(0, x + 1) End Function 'File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" - Public Function fFILE(ByVal Pfad As String, ByVal MitEndung As Boolean) As String + Public Function fFILE(Pfad As String, MitEndung As Boolean) As String Dim x As Int16 x = Pfad.LastIndexOf("\") + 1 - Pfad = Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) + Pfad = Right(Pfad, Len(Pfad) - x) If Not MitEndung Then x = Pfad.LastIndexOf(".") - If x > 0 Then Pfad = Microsoft.VisualBasic.Left(Pfad, x) + If x > 0 Then Pfad = Left(Pfad, x) End If Return Pfad End Function 'Filename without extension "C:\temp\TEST.txt" >> "C:\temp\TEST" - Public Function fFileWoExt(ByVal Path As String) As String + Public Function fFileWoExt(Path As String) As String Return fPATH(Path) & fFILE(Path, False) End Function 'Filename without path if Path = WorkDir or MainDir - Public Function fFileWoDir(ByVal file As String, Optional ByVal MainDir As String = "") As String + Public Function fFileWoDir(file As String, Optional ByVal MainDir As String = "") As String Dim path As String If MainDir = "" Then @@ -575,21 +581,21 @@ Module VECTO_Global 'Path alone "C:\temp\TEST.txt" >> "C:\temp\" ' "TEST.txt" >> "" - Public Function fPATH(ByVal Pfad As String) As String + Public Function fPATH(Pfad As String) As String Dim x As Int16 If Pfad Is Nothing OrElse Pfad.Length < 3 OrElse Pfad.Substring(1, 2) <> ":\" Then Return "" x = Pfad.LastIndexOf("\") - Return Microsoft.VisualBasic.Left(Pfad, x + 1) + Return Left(Pfad, x + 1) End Function 'Extension alone "C:\temp\TEST.txt" >> ".txt" - Public Function fEXT(ByVal Pfad As String) As String + Public Function fEXT(Pfad As String) As String Dim x As Int16 x = Pfad.LastIndexOf(".") - If x = - 1 Then + If x = -1 Then Return "" Else - Return Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) + Return Right(Pfad, Len(Pfad) - x) End If End Function diff --git a/VECTO/cJSONparser.vb b/VECTO/cJSONparser.vb index 198642ffafc39484b4744e0562625480e8901a71..e9c5fa55eb77a92866f259ea52939eb1955d30bd 100644 --- a/VECTO/cJSONparser.vb +++ b/VECTO/cJSONparser.vb @@ -9,421 +9,415 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.IO +Imports System.Text +Imports Microsoft.VisualBasic.FileIO Imports Newtonsoft.Json - -'uses JSON.NET http://json.codeplex.com/ - -Public Class cJSON - Public Content As Dictionary(Of String, Object) - Public ErrorMsg As String - - Public Sub New() - Content = New Dictionary(Of String, Object) - End Sub - - - Public Function ReadFile(ByVal path As String) As Boolean - Dim file As Microsoft.VisualBasic.FileIO.TextFieldParser - Dim str As String - - - Content.Clear() - - 'check if file exists - If Not IO.File.Exists(path) Then - ErrorMsg = "file not found" - Return False - End If - - 'open file - Try - file = New Microsoft.VisualBasic.FileIO.TextFieldParser(path) - Catch ex As Exception - ErrorMsg = ex.Message - Return False - End Try - - 'Check if file is empty - If file.EndOfData Then - file.Close() - ErrorMsg = "file is empty" - Return False - End If - - 'read file - str = file.ReadToEnd - - 'close file - file.Close() - - 'parse JSON to Dictionary - Try - 'JSONobj = JsonConvert.DeserializeObject(str) - Content = JsonConvert.DeserializeObject(str, Content.GetType) - Catch ex As Exception - ErrorMsg = ex.Message - Return False - End Try - - Return True - - End Function - - Public Function WriteFile(ByVal path As String) As Boolean - Dim file As System.IO.StreamWriter - Dim str As String - Dim First As Boolean = True - - If Content.Count = 0 Then Return False - - Try - str = Newtonsoft.Json.JsonConvert.SerializeObject(Content, Formatting.Indented) - file = My.Computer.FileSystem.OpenTextFileWriter(path, False) - Catch ex As Exception - Return False - End Try - - file.Write(str) - - file.Close() - - Return True - - End Function +''' <summary> +''' uses JSON.NET http://json.codeplex.com/ +''' </summary> +''' <remarks></remarks> +Public Class JSON + Public Content As Dictionary(Of String, Object) + Public ErrorMsg As String + + Public Sub New() + 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 + ErrorMsg = "file not found" + Return False + End If + + Try + file = New TextFieldParser(path) + Catch ex As Exception + ErrorMsg = ex.Message + Return False + End Try + + If file.EndOfData Then + file.Close() + ErrorMsg = "file is empty" + Return False + End If + + str = file.ReadToEnd + + file.Close() + + Try + Content = JsonConvert.DeserializeObject(str, Content.GetType) + Catch ex As Exception + ErrorMsg = ex.Message + Return False + End Try + + Return True + End Function + + ''' <summary> + ''' Writes the Content variable into a JSON file. + ''' </summary> + ''' <param name="path"></param> + ''' <returns></returns> + ''' <remarks></remarks> + Public Function WriteFile(path As String) As Boolean + Dim file As StreamWriter + Dim str As String + + If Content.Count = 0 Then + Return False + End If + + Try + str = JsonConvert.SerializeObject(Content, Formatting.Indented) + file = My.Computer.FileSystem.OpenTextFileWriter(path, False) + Catch ex As Exception + Return False + End Try + + file.Write(str) + file.Close() + + Return True + End Function #Region "old self-made parser" - Private fullfile As String - - Private Function ReadFileXXX(ByVal path As String) As Boolean - Dim file As Microsoft.VisualBasic.FileIO.TextFieldParser - - Content.Clear() - 'check if file exists - If Not IO.File.Exists(path) Then Return False + Private fullfile As String - 'open file - Try - file = New Microsoft.VisualBasic.FileIO.TextFieldParser(path) - Catch ex As Exception - Return False - End Try + Private Function ReadFileXXX(path As String) As Boolean + Dim file As TextFieldParser - 'Check if file is empty - If file.EndOfData Then - file.Close() - Return False - End If + Content.Clear() - 'read file - fullfile = file.ReadToEnd + 'check if file exists + If Not IO.File.Exists(path) Then Return False - 'close file - file.Close() + 'open file + Try + file = New TextFieldParser(path) + Catch ex As Exception + Return False + End Try - 'trim spaces - fullfile = fullfile.Trim + 'Check if file is empty + If file.EndOfData Then + file.Close() + Return False + End If - 'remove line breaks - fullfile = fullfile.Replace(vbCrLf, "") + 'read file + fullfile = file.ReadToEnd - If Left(fullfile, 1) <> "{" Or Right(fullfile, 1) <> "}" Then Return False + 'close file + file.Close() - 'parse JSON to Dictionary - Try - Content = GetObject() - Catch ex As Exception - Return False - End Try + 'trim spaces + fullfile = fullfile.Trim + 'remove line breaks + fullfile = fullfile.Replace(vbCrLf, "") - Return True + If Left(fullfile, 1) <> "{" Or Right(fullfile, 1) <> "}" Then Return False - End Function + 'parse JSON to Dictionary + Try + Content = GetObject() + Catch ex As Exception + Return False + End Try + Return True + End Function - Private Function WriteFileXXX(ByVal path As String) As Boolean - Dim file As System.IO.StreamWriter - Dim kv As KeyValuePair(Of String, Object) - Dim str As New System.Text.StringBuilder - Dim First As Boolean = True + Private Function WriteFileXXX(path As String) As Boolean + Dim file As StreamWriter + Dim kv As KeyValuePair(Of String, Object) + Dim str As New StringBuilder + Dim First As Boolean = True - If Content.Count = 0 Then Return False + If Content.Count = 0 Then Return False - Try - str.AppendLine("{") - For Each kv In Content - If First Then - First = False - Else - str.AppendLine(",") - End If - str.Append(GetKeyValString(1, kv)) - Next - str.AppendLine() - str.AppendLine("}") - Catch ex As Exception - Return False - End Try + Try + str.AppendLine("{") + For Each kv In Content + If First Then + First = False + Else + str.AppendLine(",") + End If + str.Append(GetKeyValString(1, kv)) + Next + str.AppendLine() + str.AppendLine("}") + Catch ex As Exception + Return False + End Try - Try - file = My.Computer.FileSystem.OpenTextFileWriter(path, False) - Catch ex As Exception - Return False - End Try + Try + file = My.Computer.FileSystem.OpenTextFileWriter(path, False) + Catch ex As Exception + Return False + End Try - file.Write(str.ToString) + file.Write(str.ToString) - file.Close() + file.Close() - Return True + Return True + End Function - End Function + Private Function GetKeyValString(TabLvl As Integer, ByRef kv As KeyValuePair(Of String, Object)) As String + Dim str As New StringBuilder + Dim obj As Object + Dim kv0 As KeyValuePair(Of String, Object) + Dim First As Boolean - Private Function GetKeyValString(ByVal TabLvl As Integer, ByRef kv As KeyValuePair(Of String, Object)) As String - Dim str As New System.Text.StringBuilder - Dim obj As Object - Dim kv0 As KeyValuePair(Of String, Object) - Dim First As Boolean + str.Append(Tabs(TabLvl) & ChrW(34) & kv.Key & ChrW(34) & ": ") - str.Append(Tabs(TabLvl) & ChrW(34) & kv.Key & ChrW(34) & ": ") + Select Case kv.Value.GetType - Select Case kv.Value.GetType + Case GetType(Dictionary(Of String, Object)) - Case GetType(Dictionary(Of String, Object)) + str.AppendLine("{") - str.AppendLine("{") + First = True + For Each kv0 In kv.Value + If First Then + First = False + Else + str.AppendLine(",") + End If + str.Append(GetKeyValString(TabLvl + 1, kv0)) + Next - First = True - For Each kv0 In kv.Value - If First Then - First = False - Else - str.AppendLine(",") - End If - str.Append(GetKeyValString(TabLvl + 1, kv0)) - Next + str.AppendLine() + str.Append(Tabs(TabLvl) & "}") - str.AppendLine() - str.Append(Tabs(TabLvl) & "}") + Case GetType(List(Of Object)) - Case GetType(List(Of Object)) + str.AppendLine("[") - str.AppendLine("[") + First = True + For Each obj In kv.Value + If First Then + First = False + Else + str.AppendLine(",") + End If + str.Append(Tabs(TabLvl + 1) & GetObjString(TabLvl + 1, obj)) + Next - First = True - For Each obj In kv.Value - If First Then - First = False - Else - str.AppendLine(",") - End If - str.Append(Tabs(TabLvl + 1) & GetObjString(TabLvl + 1, obj)) - Next + str.AppendLine() + str.Append(Tabs(TabLvl) & "]") - str.AppendLine() - str.Append(Tabs(TabLvl) & "]") + Case Else - Case Else + str.Append(GetObjString(TabLvl + 1, kv.Value)) - str.Append(GetObjString(TabLvl + 1, kv.Value)) + End Select - End Select + Return str.ToString + End Function - Return str.ToString + Private Function GetObjString(TabLvl As Integer, ByRef obj As Object) As String + Dim kv0 As KeyValuePair(Of String, Object) + Dim First As Boolean + Dim str As StringBuilder - End Function + If obj Is Nothing Then + Return "null" + Else + Select Case obj.GetType - Private Function GetObjString(ByVal TabLvl As Integer, ByRef obj As Object) As String - Dim kv0 As KeyValuePair(Of String, Object) - Dim First As Boolean - Dim str As System.Text.StringBuilder + Case GetType(Dictionary(Of String, Object)) - If obj Is Nothing Then - Return "null" - Else - Select Case obj.GetType + str = New StringBuilder + str.AppendLine("{") - Case GetType(Dictionary(Of String, Object)) + First = True + For Each kv0 In obj + If First Then + First = False + Else + str.AppendLine(",") + End If + str.Append(GetKeyValString(TabLvl + 1, kv0)) + Next - str = New System.Text.StringBuilder - str.AppendLine("{") + str.AppendLine() + str.Append(Tabs(TabLvl) & "}") - First = True - For Each kv0 In obj - If First Then - First = False - Else - str.AppendLine(",") - End If - str.Append(GetKeyValString(TabLvl + 1, kv0)) - Next + Return str.ToString - str.AppendLine() - str.Append(Tabs(TabLvl) & "}") + Case GetType(String) - Return str.ToString + Return ChrW(34) & CStr(obj) & ChrW(34) - Case GetType(String) + Case GetType(Boolean) - Return ChrW(34) & CStr(obj) & ChrW(34) + If CBool(obj) Then + Return "true" + Else + Return "false" + End If - Case GetType(Boolean) + Case Else - If CBool(obj) Then - Return "true" - Else - Return "false" - End If + Return CDbl(obj).ToString - Case Else + End Select + End If + End Function - Return CDbl(obj).ToString + Private Function Tabs(l As Integer) As String + Dim i As Integer + Dim str As String - End Select - End If + str = "" + For i = 1 To l + str &= vbTab + Next + Return str + End Function - End Function + Private Function GetObject() As Dictionary(Of String, Object) + Dim MyDic As Dictionary(Of String, Object) + Dim key As String + Dim obj As Object + Dim i As Integer + Dim i2 As Integer + Dim Valstr As String + Dim ValList As List(Of Object) = Nothing + Dim ArrayMode As Boolean = False - Private Function Tabs(ByVal l As Integer) As String - Dim i As Integer - Dim str As String + 'remove { + fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - str = "" - For i = 1 To l - str &= vbTab - Next + 'new list of key/value pairs + MyDic = New Dictionary(Of String, Object) - Return str - End Function - Private Function GetObject() As Dictionary(Of String, Object) - Dim MyDic As Dictionary(Of String, Object) - Dim key As String - Dim obj As Object - Dim i As Integer - Dim i2 As Integer - Dim Valstr As String - Dim ValList As List(Of Object) = Nothing - Dim ArrayMode As Boolean = False - - 'remove { - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - - 'new list of key/value pairs - MyDic = New Dictionary(Of String, Object) - - - 'loop through key/value pairs + 'loop through key/value pairs lb10: - If Left(fullfile, 1) <> ChrW(34) Then - Throw New Exception - Return Nothing - End If - - 'get key - i = fullfile.IndexOf(ChrW(34), 1) - key = Mid(fullfile, 2, i - 1) - fullfile = (Right(fullfile, Len(fullfile) - i - 1)).Trim - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - - If key = "" Then - Throw New Exception - Return Nothing - End If - - 'get value (object, number, boolean, array) - If Left(fullfile, 1) = "[" Then - ArrayMode = True - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - ValList = New List(Of Object) - End If + If Left(fullfile, 1) <> ChrW(34) Then + Throw New Exception + Return Nothing + End If + + 'get key + i = fullfile.IndexOf(ChrW(34), 1) + key = Mid(fullfile, 2, i - 1) + fullfile = (Right(fullfile, Len(fullfile) - i - 1)).Trim + fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim + + If key = "" Then + Throw New Exception + Return Nothing + End If + + 'get value (object, number, boolean, array) + If Left(fullfile, 1) = "[" Then + ArrayMode = True + fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim + ValList = New List(Of Object) + End If lb20: - If Left(fullfile, 1) = "{" Then - obj = GetObject() - Else - If Left(fullfile, 1) = ChrW(34) Then - 'string - i = fullfile.IndexOf(ChrW(34), 1) - obj = Mid(fullfile, 2, i - 1) - fullfile = (Right(fullfile, Len(fullfile) - i - 1)).Trim - Else - 'number/boolean - i = fullfile.IndexOf(",", 1) - i2 = fullfile.IndexOf("}", 1) - - If i = -1 Then - If i2 = -1 Then - Valstr = Right(fullfile, Len(fullfile) - 1) - fullfile = "" - Else - Valstr = Mid(fullfile, 1, i2) - fullfile = (Right(fullfile, Len(fullfile) - i2)).Trim - End If - Else - If i2 = -1 Or i < i2 Then - Valstr = Mid(fullfile, 1, i) - fullfile = (Right(fullfile, Len(fullfile) - i)).Trim - Else - Valstr = Mid(fullfile, 1, i2) - fullfile = (Right(fullfile, Len(fullfile) - i2)).Trim - End If - End If - - If IsNumeric(Valstr) Then - obj = CDbl(Valstr) - ElseIf (UCase(Valstr)).Trim = "FALSE" Then - obj = False - ElseIf (UCase(Valstr)).Trim = "TRUE" Then - obj = True - ElseIf (UCase(Valstr)).Trim = "NULL" Then - obj = Nothing - Else - Throw New Exception - Return Nothing - End If - - End If - End If - - If ArrayMode Then - ValList.Add(obj) - If Left(fullfile, 1) = "]" Then - ArrayMode = False - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - MyDic.Add(key, ValList) - End If - Else - MyDic.Add(key, obj) - End If - - If Left(fullfile, 1) = "," Then - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - If ArrayMode Then - GoTo lb20 - Else - GoTo lb10 - End If - End If - - If Left(fullfile, 1) = "}" Then - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - End If - - Return MyDic - - - End Function + If Left(fullfile, 1) = "{" Then + obj = GetObject() + Else + If Left(fullfile, 1) = ChrW(34) Then + 'string + i = fullfile.IndexOf(ChrW(34), 1) + obj = Mid(fullfile, 2, i - 1) + fullfile = (Right(fullfile, Len(fullfile) - i - 1)).Trim + Else + 'number/boolean + i = fullfile.IndexOf(",", 1) + i2 = fullfile.IndexOf("}", 1) + + If i = -1 Then + If i2 = -1 Then + Valstr = Right(fullfile, Len(fullfile) - 1) + fullfile = "" + Else + Valstr = Mid(fullfile, 1, i2) + fullfile = (Right(fullfile, Len(fullfile) - i2)).Trim + End If + Else + If i2 = -1 Or i < i2 Then + Valstr = Mid(fullfile, 1, i) + fullfile = (Right(fullfile, Len(fullfile) - i)).Trim + Else + Valstr = Mid(fullfile, 1, i2) + fullfile = (Right(fullfile, Len(fullfile) - i2)).Trim + End If + End If + + If IsNumeric(Valstr) Then + obj = CDbl(Valstr) + ElseIf (UCase(Valstr)).Trim = "FALSE" Then + obj = False + ElseIf (UCase(Valstr)).Trim = "TRUE" Then + obj = True + ElseIf (UCase(Valstr)).Trim = "NULL" Then + obj = Nothing + Else + Throw New Exception + Return Nothing + End If + + End If + End If + + If ArrayMode Then + ValList.Add(obj) + If Left(fullfile, 1) = "]" Then + ArrayMode = False + fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim + MyDic.Add(key, ValList) + End If + Else + MyDic.Add(key, obj) + End If + + If Left(fullfile, 1) = "," Then + fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim + If ArrayMode Then + GoTo lb20 + Else + GoTo lb10 + End If + End If + + If Left(fullfile, 1) = "}" Then + fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim + End If + + Return MyDic + End Function #End Region - - - End Class diff --git a/VECTO/cVSUM.vb b/VECTO/cVSUM.vb index b65693ba085ccf61c4460498bf097548b9762d81..b7b73471bb9c56e712b59e35e37d867f6da8672d 100644 --- a/VECTO/cVSUM.vb +++ b/VECTO/cVSUM.vb @@ -22,7 +22,7 @@ Class cVSUM Private VSUMentryList As List(Of String) 'Wird benötigt weil Dictionary nicht sortiert ist 'Needed because Dictionary is not sorted - Private vsumJSON As cJSON + Private vsumJSON As JSON Private ResList As List(Of Dictionary(Of String, Object)) @@ -523,7 +523,7 @@ Class cVSUM End Try 'JSON - vsumJSON = New cJSON + vsumJSON = New JSON dic = New Dictionary(Of String, Object) dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index 2cfa5c97201010363b8c144a345305db7c5fcf5a..56b9e13be24dcface21170e45d1ad87bad930974 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -44,7 +44,6 @@ using TUGraz.VectoCore.InputData; using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.OutputData; -using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.OutputData.PDF; using TUGraz.VectoCore.Utils; @@ -72,7 +71,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } var report = declarationReport ?? new PDFDeclarationReport(writer); var windowsIdentity = WindowsIdentity.GetCurrent(); - report.Creator = windowsIdentity != null ? windowsIdentity.Name : "N/A"; + report.Creator = windowsIdentity.Name; report.JobName = declDataProvider.JobInputData().JobName; DataReader = new DeclarationModeVectoRunDataFactory(declDataProvider, report); break; @@ -104,6 +103,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public int JobNumber { get; set; } public bool WriteModalResults { get; set; } + public bool ModalResults1Hz { get; set; } /// <summary> /// Creates powertrain and initializes it with the component's data. @@ -112,18 +112,24 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public IEnumerable<IVectoRun> SimulationRuns() { var i = 0; + var modDataFilter = ModalResults1Hz + ? new IModalDataFilter[] { new ModalDataContainer.ModalData1HzFilter() } + : new IModalDataFilter[0]; + foreach (var data in DataReader.NextRun()) { var d = data; IModalDataContainer modContainer = new ModalDataContainer(data, ModWriter, - writer => { + addReportResult: writer => { if (d.Report != null) { d.Report.AddResult(d.Loading, d.Mission, writer); } - }, _mode) { - WriteAdvancedAux = data.AdvancedAux != null && data.AdvancedAux.AuxiliaryAssembly == AuxiliaryModel.Advanced + }, + mode: _mode, + filter: modDataFilter) { + WriteAdvancedAux = data.AdvancedAux != null && data.AdvancedAux.AuxiliaryAssembly == AuxiliaryModel.Advanced, + WriteModalResults = WriteModalResults }; - modContainer.WriteModalResults = WriteModalResults; var current = i++; var builder = new PowertrainBuilder(modContainer, (writer, mass, loading) => SumData.Write(modContainer, d.JobName, string.Format("{0}-{1}", JobNumber, current), diff --git a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs index aa4646d9211ad4c649c2c361b2a7f29f92aee658..bc2aebf957ab49a52bcb70ce8c632e881933a4ae 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs @@ -38,14 +38,25 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.OutputData.FileIO { - public class FileOutputWriter : LoggingObject, IOutputDataWriter { private readonly string _jobFile; - private string BasePath { get { return Path.GetDirectoryName(_jobFile); } } - public string PDFReportName { get { return Path.ChangeExtension(_jobFile, Constants.FileExtensions.PDFReport); } } - public string SumFileName { get { return Path.ChangeExtension(_jobFile, Constants.FileExtensions.SumFile); } } + private string BasePath + { + get { return Path.GetDirectoryName(_jobFile); } + } + + public string PDFReportName + { + get { return Path.ChangeExtension(_jobFile, Constants.FileExtensions.PDFReport); } + } + + public string SumFileName + { + get { return Path.ChangeExtension(_jobFile, Constants.FileExtensions.SumFile); } + } + /// <summary> /// /// </summary> @@ -59,7 +70,7 @@ namespace TUGraz.VectoCore.OutputData.FileIO { VectoCSVFile.Write(SumFileName, data); } - + public string GetModDataFileName(string runName, string cycleName, string runSuffix) { string modFileName; diff --git a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs index 612c31c393a2774ce6bde709a4428ee92bab85e5..024dded1f520ddb77edd7b9ad297474297f3c607 100644 --- a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs @@ -40,6 +40,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.OutputData { + public interface IModalDataFilter + { + ModalResults Filter(ModalResults data); + string ID { get; } + } + public interface IModalDataContainer { /// <summary> diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 8b746b03f8be6c10fb85e1211603a3cef06ac0e3..5bc8ddb4cc98e3b9f22bdcaa9a39dd35de51f857 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -45,6 +45,7 @@ namespace TUGraz.VectoCore.OutputData public class ModalDataContainer : IModalDataContainer { private readonly ExecutionMode _mode; + private readonly IModalDataFilter[] _filters; private readonly Action<ModalDataContainer> _addReportResult; internal ModalResults Data { get; set; } private DataRow CurrentRow { get; set; } @@ -62,16 +63,15 @@ namespace TUGraz.VectoCore.OutputData public bool WriteAdvancedAux { get; set; } - public ModalDataContainer(string runName, IModalDataWriter writer, - ExecutionMode mode = ExecutionMode.Engineering) + public ModalDataContainer(string runName, IModalDataWriter writer, ExecutionMode mode) : this(runName, "", "", writer, _ => { }, mode) {} public ModalDataContainer(VectoRunData runData, IModalDataWriter writer, Action<ModalDataContainer> addReportResult, - ExecutionMode mode = ExecutionMode.Engineering) - : this(runData.JobName, runData.Cycle.Name, runData.ModFileSuffix, writer, addReportResult, mode) {} + ExecutionMode mode, params IModalDataFilter[] filter) + : this(runData.JobName, runData.Cycle.Name, runData.ModFileSuffix, writer, addReportResult, mode, filter) {} protected ModalDataContainer(string runName, string cycleName, string runSuffix, IModalDataWriter writer, - Action<ModalDataContainer> addReportResult, ExecutionMode mode) + Action<ModalDataContainer> addReportResult, ExecutionMode mode, params IModalDataFilter[] filters) { HasTorqueConverter = false; @@ -81,6 +81,7 @@ namespace TUGraz.VectoCore.OutputData _writer = writer; _mode = mode; + _filters = filters; _addReportResult = addReportResult; Data = new ModalResults(); @@ -192,8 +193,12 @@ namespace TUGraz.VectoCore.OutputData .Concat(_additionalColumns); if (_mode != ExecutionMode.Declaration || WriteModalResults) { - _writer.WriteModData(RunName, CycleName, RunSuffix, - new DataView(Data).ToTable(false, strCols.ToArray())); + var filteredData = Data; + foreach (var filter in _filters) { + RunSuffix += "_" + filter.ID; + filteredData = filter.Filter(filteredData); + } + _writer.WriteModData(RunName, CycleName, RunSuffix, new DataView(filteredData).ToTable(false, strCols.ToArray())); } if (_mode == ExecutionMode.Declaration) { @@ -230,11 +235,11 @@ namespace TUGraz.VectoCore.OutputData _additionalColumns.Add(fieldName); Data.Columns.Add(fieldName); } - if (value is double) { - CurrentRow[fieldName] = string.Format(CultureInfo.InvariantCulture, "{0}", value); - } else { - CurrentRow[fieldName] = value; - } + if (value is double) { + CurrentRow[fieldName] = string.Format(CultureInfo.InvariantCulture, "{0}", value); + } else { + CurrentRow[fieldName] = value; + } } public Dictionary<string, DataColumn> Auxiliaries { get; set; } @@ -255,5 +260,19 @@ namespace TUGraz.VectoCore.OutputData } } } + + public class ModalData1HzFilter : IModalDataFilter + { + public ModalResults Filter(ModalResults data) + { + //todo mk-2016-05-24: implement 1Hz filter + return data; + } + + public string ID + { + get { return "1Hz"; } + } + } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index d978b4c3d1ebb1198ffe4f99c63181d1f4c6587e..6048975f192c386d75ba50addda0dc14c64d3f75 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -72,8 +72,10 @@ namespace TUGraz.VectoCore.Tests.Integration bool overspeed = false) { var fileWriter = new FileOutputWriter(modFileName); - var modData = new ModalDataContainer(modFileName, fileWriter) { WriteAdvancedAux = true }; - var container = new VehicleContainer(ExecutionMode.Engineering, modData) { RunData = new VectoRunData { JobName = modFileName, Cycle = cycleData } }; + var modData = new ModalDataContainer(modFileName, fileWriter, ExecutionMode.Engineering) { WriteAdvancedAux = true }; + var container = new VehicleContainer(ExecutionMode.Engineering, modData) { + RunData = new VectoRunData { JobName = modFileName, Cycle = cycleData } + }; var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile); var axleGearData = CreateAxleGearData(); diff --git a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs index d4ec21b854905407772425a285500f5063a5d09b..f934b9422529fb186a54891d585781775e7f34cd 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs @@ -70,8 +70,10 @@ namespace TUGraz.VectoCore.Tests.Integration bool overspeed = false) { var fileWriter = new FileOutputWriter(modFileName); - var modData = new ModalDataContainer(modFileName, fileWriter); - var container = new VehicleContainer(ExecutionMode.Engineering, modData, null) { RunData = new VectoRunData{JobName = modFileName, Cycle = cycleData }}; + var modData = new ModalDataContainer(modFileName, fileWriter, ExecutionMode.Engineering); + var container = new VehicleContainer(ExecutionMode.Engineering, modData, null) { + RunData = new VectoRunData { JobName = modFileName, Cycle = cycleData } + }; var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile); var axleGearData = CreateAxleGearData(); diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index d83b5069791738f47513f2155216f02054401290..347fb572d133801672727e8ed4b747b37855a461 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns public void Test_FullPowertrain_SimpleGearbox() { var fileWriter = new FileOutputWriter("Coach_FullPowertrain_SimpleGearbox"); - var modData = new ModalDataContainer("Coach_FullPowertrain_SimpleGearbox", fileWriter); + var modData = new ModalDataContainer("Coach_FullPowertrain_SimpleGearbox", fileWriter, ExecutionMode.Engineering); var container = new VehicleContainer(ExecutionMode.Engineering, modData); var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile); @@ -129,7 +129,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns public void Test_FullPowertrain() { var fileWriter = new FileOutputWriter("Coach_FullPowertrain"); - var modData = new ModalDataContainer("Coach_FullPowertrain", fileWriter); + var modData = new ModalDataContainer("Coach_FullPowertrain", fileWriter, ExecutionMode.Engineering); var container = new VehicleContainer(ExecutionMode.Engineering, modData); var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile); @@ -203,7 +203,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns public void Test_FullPowertrain_LowSpeed() { var fileWriter = new FileOutputWriter("Coach_FullPowertrain_LowSpeed"); - var modData = new ModalDataContainer("Coach_FullPowertrain_LowSpeed", fileWriter); + var modData = new ModalDataContainer("Coach_FullPowertrain_LowSpeed", fileWriter, ExecutionMode.Engineering); var container = new VehicleContainer(ExecutionMode.Engineering, modData); var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile); @@ -299,7 +299,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns private static GearboxData CreateGearboxData() { var ratios = new[] { 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 }; - + return new GearboxData { Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs index e22700b2851f495b4b9ba39324984a63bcf3fab0..1989cb9949113927bbdc54d8e9731b68eef1558d 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs @@ -74,7 +74,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var driverData = CreateDriverData(AccelerationFile); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrainOverload"); - var modData = new ModalDataContainer("Coach_MinimalPowertrainOverload", fileWriter); //new TestModalDataWriter(); + var modData = new ModalDataContainer("Coach_MinimalPowertrainOverload", fileWriter, ExecutionMode.Engineering); var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var driver = new Driver(vehicleContainer, driverData, new DefaultDriverStrategy()); @@ -123,7 +123,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var driverData = CreateDriverData(AccelerationFile); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrain"); - var modData = new ModalDataContainer("Coach_MinimalPowertrain", fileWriter); //new TestModalDataWriter(); + var modData = new ModalDataContainer("Coach_MinimalPowertrain", fileWriter, ExecutionMode.Engineering); var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var cycle = new DistanceBasedDrivingCycle(vehicleContainer, cycleData); @@ -180,7 +180,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns Assert.IsInstanceOfType(response, typeof(ResponseCycleFinished)); modData.Finish(VectoRun.Status.Success); - + NLog.LogManager.EnableLogging(); } @@ -197,7 +197,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var driverData = CreateDriverData(AccelerationFile2); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrainOverload"); - var modData = new ModalDataContainer("Coach_MinimalPowertrainOverload", fileWriter); + var modData = new ModalDataContainer("Coach_MinimalPowertrainOverload", fileWriter, ExecutionMode.Engineering); var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var cycle = new DistanceBasedDrivingCycle(vehicleContainer, cycleData); diff --git a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs index efab444f691d75087924d2f91626e63f99c59154..256e883e4b72593976a5f9595b2b1c38b71798a5 100644 --- a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs @@ -82,8 +82,8 @@ namespace TUGraz.VectoCore.Tests.Integration Kilogram massExtra, Kilogram loading, bool overspeed = false) { var fileWriter = new FileOutputWriter(modFileName); - var modData = new ModalDataContainer(Path.GetFileName(modFileName), fileWriter); - var container = new VehicleContainer(executionMode: ExecutionMode.Engineering, modData: modData) { + var modData = new ModalDataContainer(Path.GetFileName(modFileName), fileWriter, ExecutionMode.Engineering); + var container = new VehicleContainer(ExecutionMode.Engineering, modData) { RunData = new VectoRunData { JobName = modFileName, Cycle = cycleData } }; @@ -111,7 +111,6 @@ namespace TUGraz.VectoCore.Tests.Integration aux.AddConstant("", 0.SI<Watt>()); engine.Connect(aux.Port()); - Port.AddComponent(tmp, engine); engine.IdleController.RequestPort = clutch.IdleControlPort; @@ -127,7 +126,7 @@ namespace TUGraz.VectoCore.Tests.Integration Tuple.Create((uint)i, new GearData { FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), - LossMap = TransmissionLossMap.ReadFromFile(ratio != 1.0 ? GearboxIndirectLoss : GearboxDirectLoss, ratio, + LossMap = TransmissionLossMap.ReadFromFile(ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(ShiftPolygonFile) diff --git a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs index 6aa4ff93fbc29f347cd9e06557d57db0ef84ee62..d90703f178edb694f1086d391c72ade03ba369ab 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation { var fileWriter = new FileOutputWriter("AuxWriteModFileSumFile"); - var modData = new ModalDataContainer("AuxWriteModFileSumFile", fileWriter); + var modData = new ModalDataContainer("AuxWriteModFileSumFile", fileWriter, ExecutionMode.Engineering); modData.AddAuxiliary("FAN"); modData.AddAuxiliary("PS"); modData.AddAuxiliary("STP"); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs index c2ab893d2c1b3c70277b00b0401522f58be25a36..068e6e9d472162a18f88d477d259fcfeceaea794 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var driverData = CreateDriverData(); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrain_Coasting"); - var modData = new ModalDataContainer("Coach_MinimalPowertrain_Coasting", fileWriter); + var modData = new ModalDataContainer("Coach_MinimalPowertrain_Coasting", fileWriter, ExecutionMode.Engineering); var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var driver = new Driver(vehicleContainer, driverData, new DefaultDriverStrategy()); @@ -124,7 +124,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var driverData = CreateDriverData(); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrain_Coasting"); - var modData = new ModalDataContainer("Coach_MinimalPowertrain_Coasting", fileWriter); + var modData = new ModalDataContainer("Coach_MinimalPowertrain_Coasting", fileWriter, ExecutionMode.Engineering); var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var driver = new Driver(vehicleContainer, driverData, new DefaultDriverStrategy()); @@ -182,7 +182,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var driverData = CreateDriverData(); var fileWriter = new FileOutputWriter("Coach_MinimalPowertrain"); - var modData = new ModalDataContainer("Coach_MinimalPowertrain", fileWriter); + var modData = new ModalDataContainer("Coach_MinimalPowertrain", fileWriter, ExecutionMode.Engineering); var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var cycle = new MockDrivingCycle(vehicleContainer, null); @@ -386,7 +386,9 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent }; return new VehicleData { AxleConfiguration = AxleConfiguration.AxleConfig_4x2, - CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), CrossWindCorrectionMode.NoCorrection), + CrossWindCorrectionCurve = + new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), + CrossWindCorrectionMode.NoCorrection), CurbWeight = 15700.SI<Kilogram>(), CurbWeigthExtra = 0.SI<Kilogram>(), Loading = loading, diff --git a/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs b/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs index 652f8f587d78664e1a7b52efe0f6b33765de18e7..383a5a0d8e80d81a2cde7617b9eea36260245b0c 100644 --- a/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs +++ b/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs @@ -30,6 +30,7 @@ */ using Microsoft.VisualStudio.TestTools.UnitTesting; +using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -48,7 +49,7 @@ namespace TUGraz.VectoCore.Tests.Reports var writer = new FileOutputWriter("testsumcalc_fixed"); var sumWriter = new SummaryDataContainer(writer); - var modData = new ModalDataContainer("testsumcalc_fixed", writer); + var modData = new ModalDataContainer("testsumcalc_fixed", writer, ExecutionMode.Engineering); modData.AddAuxiliary("FAN"); for (var i = 0; i < 500; i++) { @@ -98,7 +99,7 @@ namespace TUGraz.VectoCore.Tests.Reports var writer = new FileOutputWriter("testsumcalc_var"); var sumWriter = new SummaryDataContainer(writer); - var modData = new ModalDataContainer("testsumcalc_var", writer); + var modData = new ModalDataContainer("testsumcalc_var", writer, ExecutionMode.Engineering); modData.AddAuxiliary("FAN"); var timeSteps = new[]