diff --git a/VECTO Changelog.txt b/VECTO Changelog.txt index dc3e0fcfcbe7cfad753cc61b844912c59ac4b18e..cbfde1232c8e4c9d1368575b42a711955157732f 100644 --- a/VECTO Changelog.txt +++ b/VECTO Changelog.txt @@ -5,8 +5,6 @@ VECTO ?.? (future release) TODO GBX <DRAG> StStDelay -- Gearbox Rules must be set when loading .gbx file to aviod invalid settings (e.g. AT with Skip Gears) -- Correct Pg and Proll calculation (Road gradient)?? VECTO x.x (current source - next release) diff --git a/VECTO/GUI/F_ENG.vb b/VECTO/GUI/F_ENG.vb index 83000961393894addad058a9c7bba6223ab7700f..9e5d8f8f9769a9bda9f8b4ba600e71d4ab08a40f 100644 --- a/VECTO/GUI/F_ENG.vb +++ b/VECTO/GUI/F_ENG.vb @@ -138,6 +138,13 @@ Changed = False + If ENG0.NoJSON Then + If MsgBox("File is not in JSON format!" & vbCrLf & vbCrLf & "Convert now?" & vbCrLf & "(Backup will be created with '.ORIG' extension)", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + IO.File.Copy(EngFile, EngFile & ".ORIG", True) + SaveOrSaveAs(False) + End If + End If + End Sub 'Save or Save As function = true if file is saved diff --git a/VECTO/GUI/F_GBX.vb b/VECTO/GUI/F_GBX.vb index 342e5dc655539ba3af79aa5d0467da38ee716a52..3a77fcde16c5c584468b4150612476adada82e41 100644 --- a/VECTO/GUI/F_GBX.vb +++ b/VECTO/GUI/F_GBX.vb @@ -192,6 +192,13 @@ Changed = False + If GBX0.NoJSON Then + If MsgBox("File is not in JSON format!" & vbCrLf & vbCrLf & "Convert now?" & vbCrLf & "(Backup will be created with '.ORIG' extension)", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + IO.File.Copy(GbxFile, GbxFile & ".ORIG", True) + SaveOrSaveAs(False) + End If + End If + End Sub 'Save or Save As function = true if file is saved diff --git a/VECTO/GUI/F_GEN.vb b/VECTO/GUI/F_GEN.vb index eb794ced95c0214f443703adce512a6e50fa7d61..e3d1a9098e458157d89fb1cce1a7c2520a1fc9b0 100644 --- a/VECTO/GUI/F_GEN.vb +++ b/VECTO/GUI/F_GEN.vb @@ -700,16 +700,9 @@ Public Class F_GEN Me.TbAlookahead.Text = CStr(Gfile.a_lookahead) Me.TbVminLA.Text = CStr(Gfile.vMinLA) - '------------------------------------------------------------- - - - If Gfile.NoJSON Then MsgBox("File format is outdated! Save file again to update to current format!") - '------------------------------------------------------------- - Gfile = Nothing - Genfile = file x = Len(file) @@ -720,6 +713,16 @@ Public Class F_GEN Changed = False Me.ToolStripStatusLabelGEN.Text = "" 'file & " opened." + + '------------------------------------------------------------- + + If Gfile.NoJSON Then + If MsgBox("File is not in JSON format!" & vbCrLf & vbCrLf & "Convert now?" & vbCrLf & "(Backup will be created with '.ORIG' extension)", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + IO.File.Copy(Genfile, Genfile & ".ORIG", True) + Save() + End If + End If + End Sub 'GEN save from form diff --git a/VECTO/GUI/F_Options.Designer.vb b/VECTO/GUI/F_Options.Designer.vb index 0fc8ad10a03f22ef6ee6e42fb0940ec1cddd84a7..33e6f0f24edb19fe0d873d27bbfd5d30fb601f22 100644 --- a/VECTO/GUI/F_Options.Designer.vb +++ b/VECTO/GUI/F_Options.Designer.vb @@ -62,6 +62,7 @@ Partial Class F_Options Me.TextBoxEAVal = New System.Windows.Forms.TextBox() Me.ButReset = New System.Windows.Forms.Button() Me.BtHelp = New System.Windows.Forms.Button() + Me.CbJSON = New System.Windows.Forms.CheckBox() Me.GroupBoxWorDir.SuspendLayout() Me.GroupBox3.SuspendLayout() Me.GroupBox5.SuspendLayout() @@ -124,6 +125,7 @@ Partial Class F_Options ' 'GroupBox3 ' + Me.GroupBox3.Controls.Add(Me.CbJSON) Me.GroupBox3.Controls.Add(Me.GroupBox5) Me.GroupBox3.Controls.Add(Me.TextBoxLogSize) Me.GroupBox3.Controls.Add(Me.Label16) @@ -458,6 +460,16 @@ Partial Class F_Options Me.BtHelp.TabIndex = 14 Me.BtHelp.UseVisualStyleBackColor = True ' + 'CbJSON + ' + Me.CbJSON.AutoSize = True + Me.CbJSON.Location = New System.Drawing.Point(21, 80) + Me.CbJSON.Name = "CbJSON" + Me.CbJSON.Size = New System.Drawing.Size(168, 17) + Me.CbJSON.TabIndex = 15 + Me.CbJSON.Text = "In- and Output in JSON format" + Me.CbJSON.UseVisualStyleBackColor = True + ' 'F_Options ' Me.AcceptButton = Me.ButtonOK @@ -534,4 +546,5 @@ Partial Class F_Options Friend WithEvents GroupBox5 As System.Windows.Forms.GroupBox Friend WithEvents TbOpenCmdName As System.Windows.Forms.TextBox Friend WithEvents Label12 As System.Windows.Forms.Label + Friend WithEvents CbJSON As System.Windows.Forms.CheckBox End Class diff --git a/VECTO/GUI/F_Options.vb b/VECTO/GUI/F_Options.vb index 636a61ed53cde32bbaa5d1ee4b1cbc7f8716f4b6..aad47855d880c99a6affe531c9bddefd6fbdb683 100644 --- a/VECTO/GUI/F_Options.vb +++ b/VECTO/GUI/F_Options.vb @@ -24,6 +24,7 @@ Me.TbOpenCmdName.Text = Cfg.OpenCmdName Me.TbFuelDens.Text = Cfg.FuelDens.ToString Me.TbCO2toFC.Text = Cfg.CO2perFC.ToString + Me.CbJSON.Checked = Cfg.JSON End Sub 'Reset Button @@ -47,6 +48,7 @@ Cfg.OpenCmdName = Me.TbOpenCmdName.Text Cfg.FuelDens = CSng(Me.TbFuelDens.Text) Cfg.CO2perFC = CSng(Me.TbCO2toFC.Text) + Cfg.JSON = Me.CbJSON.Checked '---------------------------------------------------- Call Cfg.ConfigSAVE() diff --git a/VECTO/GUI/F_VEH.vb b/VECTO/GUI/F_VEH.vb index 6e053361c98805eb4b3dc34be3517908a9fd0ef4..73aa7ef99742c9e52155aa823d00e4f584f9aab9 100644 --- a/VECTO/GUI/F_VEH.vb +++ b/VECTO/GUI/F_VEH.vb @@ -218,7 +218,7 @@ Public Class F_VEH Me.TbMassMax.Text = VEH0.MassMax Me.TbMassExtra.Text = VEH0.MassExtra - Me.CbAxleConfig.SelectedIndex = CType(VEH0.AxcleConf, Integer) + Me.CbAxleConfig.SelectedIndex = CType(VEH0.AxleConf, Integer) 'TODO: AUTO: Me.TbHDVclass.Text 'AUTO: Me.TbLoadingMax.Text @@ -230,6 +230,13 @@ Public Class F_VEH Changed = False + If VEH0.NoJSON Then + If MsgBox("File is not in JSON format!" & vbCrLf & vbCrLf & "Convert now?" & vbCrLf & "(Backup will be created with '.ORIG' extension)", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + IO.File.Copy(file, file & ".ORIG", True) + SaveOrSaveAs(False) + End If + End If + End Sub 'Save VEH @@ -291,7 +298,7 @@ Public Class F_VEH VEH0.MassMax = CSng(fTextboxToNumString(Me.TbMassMax.Text)) VEH0.MassExtra = CSng(fTextboxToNumString(Me.TbMassExtra.Text)) - VEH0.AxcleConf = CType(Me.CbAxleConfig.SelectedIndex, tAxleConf) + VEH0.AxleConf = CType(Me.CbAxleConfig.SelectedIndex, tAxleConf) '--------------------------------------------------------------------------------- diff --git a/VECTO/GUI/F_VEH_Axle.Designer.vb b/VECTO/GUI/F_VEH_Axle.Designer.vb index a934cfa17a2c8239bf5bc4fc2e18e118c3c18c8d..fdb5685d0778ae2e804402f5db14ddd4a4bb6a09 100644 --- a/VECTO/GUI/F_VEH_Axle.Designer.vb +++ b/VECTO/GUI/F_VEH_Axle.Designer.vb @@ -34,6 +34,11 @@ Partial Class F_VEH_Axle Me.Label5 = New System.Windows.Forms.Label() Me.Label6 = New System.Windows.Forms.Label() Me.TbFzISO = New System.Windows.Forms.TextBox() + Me.Label7 = New System.Windows.Forms.Label() + Me.Label8 = New System.Windows.Forms.Label() + Me.Label9 = New System.Windows.Forms.Label() + Me.Label10 = New System.Windows.Forms.Label() + Me.Label11 = New System.Windows.Forms.Label() Me.TableLayoutPanel1.SuspendLayout() Me.SuspendLayout() ' @@ -45,7 +50,7 @@ Partial Class F_VEH_Axle Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0) Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0) - Me.TableLayoutPanel1.Location = New System.Drawing.Point(83, 98) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(232, 164) Me.TableLayoutPanel1.Name = "TableLayoutPanel1" Me.TableLayoutPanel1.RowCount = 1 Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) @@ -74,7 +79,7 @@ Partial Class F_VEH_Axle 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(33, 15) + Me.Label1.Location = New System.Drawing.Point(22, 15) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(72, 13) Me.Label1.TabIndex = 1 @@ -82,7 +87,7 @@ Partial Class F_VEH_Axle ' 'TbWeight ' - Me.TbWeight.Location = New System.Drawing.Point(109, 12) + Me.TbWeight.Location = New System.Drawing.Point(98, 12) Me.TbWeight.Name = "TbWeight" Me.TbWeight.Size = New System.Drawing.Size(84, 20) Me.TbWeight.TabIndex = 0 @@ -90,7 +95,7 @@ Partial Class F_VEH_Axle 'Label2 ' Me.Label2.AutoSize = True - Me.Label2.Location = New System.Drawing.Point(199, 15) + Me.Label2.Location = New System.Drawing.Point(188, 15) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(16, 13) Me.Label2.TabIndex = 1 @@ -99,16 +104,16 @@ Partial Class F_VEH_Axle 'Label3 ' Me.Label3.AutoSize = True - Me.Label3.Location = New System.Drawing.Point(73, 41) + Me.Label3.Location = New System.Drawing.Point(41, 41) Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(30, 13) + Me.Label3.Size = New System.Drawing.Size(51, 13) Me.Label3.TabIndex = 1 - Me.Label3.Text = "RRC" + Me.Label3.Text = "RRC ISO" ' 'Label4 ' Me.Label4.AutoSize = True - Me.Label4.Location = New System.Drawing.Point(199, 41) + Me.Label4.Location = New System.Drawing.Point(188, 41) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(16, 13) Me.Label4.TabIndex = 1 @@ -116,7 +121,7 @@ Partial Class F_VEH_Axle ' 'TbRRC ' - Me.TbRRC.Location = New System.Drawing.Point(109, 38) + Me.TbRRC.Location = New System.Drawing.Point(98, 38) Me.TbRRC.Name = "TbRRC" Me.TbRRC.Size = New System.Drawing.Size(84, 20) Me.TbRRC.TabIndex = 5 @@ -124,16 +129,16 @@ Partial Class F_VEH_Axle 'Label5 ' Me.Label5.AutoSize = True - Me.Label5.Location = New System.Drawing.Point(27, 67) + Me.Label5.Location = New System.Drawing.Point(226, 41) Me.Label5.Name = "Label5" - Me.Label5.Size = New System.Drawing.Size(78, 13) + Me.Label5.Size = New System.Drawing.Size(39, 13) Me.Label5.TabIndex = 1 - Me.Label5.Text = "Fz (ISO 28580)" + Me.Label5.Text = "Fz ISO" ' 'Label6 ' Me.Label6.AutoSize = True - Me.Label6.Location = New System.Drawing.Point(199, 67) + Me.Label6.Location = New System.Drawing.Point(361, 41) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(21, 13) Me.Label6.TabIndex = 1 @@ -141,24 +146,77 @@ Partial Class F_VEH_Axle ' 'TbFzISO ' - Me.TbFzISO.Location = New System.Drawing.Point(109, 64) + Me.TbFzISO.Location = New System.Drawing.Point(271, 38) Me.TbFzISO.Name = "TbFzISO" Me.TbFzISO.Size = New System.Drawing.Size(84, 20) Me.TbFzISO.TabIndex = 5 ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label7.Location = New System.Drawing.Point(25, 100) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(49, 13) + Me.Label7.TabIndex = 1 + Me.Label7.Text = "Fz ISO:" + ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label8.Location = New System.Drawing.Point(12, 77) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(62, 13) + Me.Label8.TabIndex = 1 + Me.Label8.Text = "RRC ISO:" + ' + 'Label9 + ' + Me.Label9.AutoSize = True + Me.Label9.Location = New System.Drawing.Point(80, 77) + Me.Label9.Name = "Label9" + Me.Label9.Size = New System.Drawing.Size(146, 13) + Me.Label9.TabIndex = 1 + Me.Label9.Text = "RRC according to ISO 28580" + ' + 'Label10 + ' + Me.Label10.AutoSize = True + Me.Label10.Location = New System.Drawing.Point(80, 100) + Me.Label10.Name = "Label10" + Me.Label10.Size = New System.Drawing.Size(299, 13) + Me.Label10.TabIndex = 1 + Me.Label10.Text = "Test load according to ISO 28580 (85% of max. load capacity)" + ' + 'Label11 + ' + Me.Label11.AutoSize = True + Me.Label11.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label11.Location = New System.Drawing.Point(12, 131) + Me.Label11.Name = "Label11" + Me.Label11.Size = New System.Drawing.Size(215, 13) + Me.Label11.TabIndex = 1 + Me.Label11.Text = "All values are per axle, NOT per tire!" + ' 'F_VEH_Axle ' Me.AcceptButton = Me.OK_Button Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.Cancel_Button - Me.ClientSize = New System.Drawing.Size(241, 139) + Me.ClientSize = New System.Drawing.Size(390, 205) Me.Controls.Add(Me.TbFzISO) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.TbRRC) Me.Controls.Add(Me.Label4) + Me.Controls.Add(Me.Label11) + Me.Controls.Add(Me.Label10) + Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.TbWeight) + Me.Controls.Add(Me.Label9) + Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) @@ -187,5 +245,10 @@ Partial Class F_VEH_Axle Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents TbFzISO As System.Windows.Forms.TextBox + Friend WithEvents Label7 As System.Windows.Forms.Label + Friend WithEvents Label8 As System.Windows.Forms.Label + Friend WithEvents Label9 As System.Windows.Forms.Label + Friend WithEvents Label10 As System.Windows.Forms.Label + Friend WithEvents Label11 As System.Windows.Forms.Label End Class diff --git a/VECTO/Input Files/cENG.vb b/VECTO/Input Files/cENG.vb index 3a007a849559cb0ce7059f6f7470a68f85cf7717..3a82ebe98a2b4cfae223d65b6d4ad831af27f477 100644 --- a/VECTO/Input Files/cENG.vb +++ b/VECTO/Input Files/cENG.vb @@ -2,6 +2,9 @@ Public Class cENG + Private Const FormatVersion As String = "1.0" + Private FileVersion As String + Public ModelName As String Public Pnenn As Single Public Displ As Single @@ -17,6 +20,8 @@ Public Class cENG Private MyPath As String Private sFilePath As String + Public NoJSON As Boolean + Private MyFileList As List(Of String) @@ -62,7 +67,7 @@ Public Class cENG fWHTC.Clear() End Sub - Public Function SaveFile() As Boolean + Private Function SaveFileOld() As Boolean Dim file As cFile_V3 Dim i As Integer @@ -109,7 +114,7 @@ Public Class cENG End Function - Public Function ReadFile() As Boolean + Private Function ReadFileOld() As Boolean Dim MsgSrc As String Dim file As cFile_V3 Dim line() As String @@ -180,6 +185,117 @@ Public Class cENG End Function + Public Function SaveFile() As Boolean + Dim i As Integer + Dim JSON As New cJSON + Dim dic As Dictionary(Of String, Object) + Dim dic0 As Dictionary(Of String, Object) + Dim ls As List(Of Object) + + If Not Cfg.JSON Then Return SaveFileOld() + + '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("ModelName", ModelName) + + dic.Add("Displacement", Displ) + dic.Add("RatedPower", Pnenn) + dic.Add("RatedSpeed", nnenn) + dic.Add("IdlingSpeed", nleerl) + dic.Add("Inertia", I_mot) + + ls = New List(Of Object) + For i = 0 To fFLD.Count - 1 + dic0 = New Dictionary(Of String, Object) + dic0.Add("Path", fFLD(i).PathOrDummy) + dic0.Add("Gears", FLDgears(i)) + ls.Add(dic0) + Next + dic.Add("FullLoadCurves", ls) + + dic.Add("FuelMap", fMAP.PathOrDummy) + dic.Add("WHTCresults", fWHTC.PathOrDummy) + + JSON.Content.Add("Body", dic) + + Return JSON.WriteFile(sFilePath) + + + End Function + + Public Function ReadFile() As Boolean + Dim MsgSrc As String + Dim i As Integer + Dim JSON As New cJSON + Dim dic As Object + + MsgSrc = "ENG/ReadFile" + + 'Flag for "File is not JSON" Warnings + NoJSON = False + + SetDefault() + + If Cfg.JSON Then + If Not JSON.ReadFile(sFilePath) Then + NoJSON = True + Try + Return ReadFileOld() + Catch ex As Exception + Return False + End Try + End If + Else + Try + Return ReadFileOld() + Catch ex As Exception + Return False + End Try + End If + + Try + + FileVersion = JSON.Content("Header")("FileVersion") + + ModelName = JSON.Content("Body")("ModelName") + + Pnenn = JSON.Content("Body")("RatedPower") + Displ = JSON.Content("Body")("Displacement") + nnenn = JSON.Content("Body")("RatedSpeed") + nleerl = JSON.Content("Body")("IdlingSpeed") + I_mot = JSON.Content("Body")("Inertia") + + i = -1 + For Each dic In JSON.Content("Body")("FullLoadCurves") + i += 1 + fFLD.Add(New cSubPath) + fFLD(i).Init(MyPath, dic("Path")) + FLDgears.Add(dic("Gears")) + Next + + fMAP.Init(MyPath, JSON.Content("Body")("FuelMap")) + fWHTC.Init(MyPath, JSON.Content("Body")("WHTCresults")) + + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) + Return False + End Try + + Return True + + End Function + + + Public ReadOnly Property FileList As List(Of String) Get Return MyFileList diff --git a/VECTO/Input Files/cGBX.vb b/VECTO/Input Files/cGBX.vb index 88eb0051ec8405b6ecf8c1f011e4bd9fe78d122d..c2f3f719e3a82cea52159643f30562f803841b64 100644 --- a/VECTO/Input Files/cGBX.vb +++ b/VECTO/Input Files/cGBX.vb @@ -2,6 +2,9 @@ Public Class cGBX + Private Const FormatVersion As String = "1.0" + Private FileVersion As String + Private MyPath As String Private sFilePath As String @@ -51,6 +54,8 @@ Public Class cGBX Public TCnout As Single Public TCmustReduce As Boolean + Public NoJSON As Boolean + Private MyFileList As List(Of String) @@ -118,7 +123,7 @@ Public Class cGBX End Sub - Public Function SaveFile() As Boolean + Private Function SaveFileOld() As Boolean Dim file As cFile_V3 Dim i As Integer file = New cFile_V3 @@ -183,7 +188,7 @@ Public Class cGBX End Function - Public Function ReadFile() As Boolean + Private Function ReadFileOld() As Boolean Dim line() As String Dim file As cFile_V3 Dim i As Integer @@ -276,6 +281,158 @@ Public Class cGBX End Function + Public Function SaveFile() As Boolean + Dim i As Integer + Dim JSON As New cJSON + Dim dic As Dictionary(Of String, Object) + Dim dic0 As Dictionary(Of String, Object) + Dim ls As List(Of Object) + + If Not Cfg.JSON Then Return SaveFileOld() + + '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("ModelName", ModelName) + + dic.Add("Inertia", I_Getriebe) + dic.Add("TracInt", TracIntrSi) + + ls = New List(Of Object) + For i = 0 To GetrI.Count - 1 + dic0 = New Dictionary(Of String, Object) + dic0.Add("Ratio", GetrI(i)) + If IsNumeric(Me.GetrMap(i, True)) Then + dic0.Add("Efficiency", GetrMaps(i).PathOrDummy) + Else + dic0.Add("LossMap", GetrMaps(i).PathOrDummy) + End If + dic0.Add("TCactive", IsTCgear(i)) + ls.Add(dic0) + Next + dic.Add("Gears", ls) + + dic.Add("ShiftPolygons", gs_file.PathOrDummy) + dic.Add("TqReserve", gs_TorqueResv) + dic.Add("SkipGears", gs_SkipGears) + dic.Add("ShiftTime", gs_ShiftTime) + dic.Add("EaryShiftUp", gs_ShiftInside) + + dic.Add("StartTqReserve", gs_TorqueResvStart) + dic.Add("StartSpeed", gs_StartSpeed) + dic.Add("StartAcc", gs_StartAcc) + + dic.Add("GearboxType", GearboxConv(gs_Type)) + + dic0 = New Dictionary(Of String, Object) + dic0.Add("Enabled", TCon) + dic0.Add("File", TC_file.PathOrDummy) + dic0.Add("RefRPM", TCrefrpm) + dic.Add("TorqueConverter", dic0) + + JSON.Content.Add("Body", dic) + + Return JSON.WriteFile(sFilePath) + + End Function + + Public Function ReadFile() As Boolean + Dim i As Integer + Dim MsgSrc As String + Dim JSON As New cJSON + Dim dic As Object + + MsgSrc = "GBX/ReadFile" + + 'Flag for "File is not JSON" Warnings + NoJSON = False + + SetDefault() + + If Cfg.JSON Then + If Not JSON.ReadFile(sFilePath) Then + NoJSON = True + Try + Return ReadFileOld() + Catch ex As Exception + Return False + End Try + End If + Else + Try + Return ReadFileOld() + Catch ex As Exception + Return False + End Try + End If + + Try + + FileVersion = JSON.Content("Header")("FileVersion") + + ModelName = JSON.Content("Body")("ModelName") + I_Getriebe = JSON.Content("Body")("Inertia") + TracIntrSi = JSON.Content("Body")("TracInt") + + i = -1 + For Each dic In JSON.Content("Body")("Gears") + i += 1 + + GetrI.Add(dic("Ratio")) + GetrMaps.Add(New cSubPath) + + If dic("Efficiency") Is Nothing Then + GetrMaps(i).Init(MyPath, dic("LossMap")) + Else + GetrMaps(i).Init(MyPath, dic("Efficiency")) + End If + + IsTCgear.Add(dic("TCactive")) + + Next + + iganganz = GetrI.Count - 1 + + gs_file.Init(MyPath, JSON.Content("Body")("ShiftPolygons")) + gs_TorqueResv = JSON.Content("Body")("TqReserve") + gs_SkipGears = JSON.Content("Body")("SkipGears") + gs_ShiftTime = JSON.Content("Body")("ShiftTime") + gs_TorqueResvStart = JSON.Content("Body")("StartTqReserve") + gs_StartSpeed = JSON.Content("Body")("StartSpeed") + gs_StartAcc = JSON.Content("Body")("StartAcc") + gs_ShiftInside = JSON.Content("Body")("EaryShiftUp") + + gs_Type = GearboxConv(JSON.Content("Body")("GearboxType").ToString) + + If JSON.Content("Body")("TorqueConverter") Is Nothing Then + TCon = False + Else + TCon = JSON.Content("Body")("TorqueConverter")("Enabled") + TC_file.Init(MyPath, JSON.Content("Body")("TorqueConverter")("File")) + TCrefrpm = JSON.Content("Body")("TorqueConverter")("RefRPM") + End If + + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) + Return False + End Try + + Return True + + + End Function + + + + Public Function TCinit() As Boolean Dim file As New cFile_V3 Dim MsgSrc As String @@ -727,5 +884,31 @@ lbInt: End Set End Property + Public Function GearboxConv(ByVal Gearbox As tGearbox) As String + Select Case Gearbox + Case tGearbox.Manual + Return "MT" + Case tGearbox.Automatic + Return "AT" + Case tGearbox.SemiAutomatic + Return "AMT" + Case Else 'tGearbox.Custom + Return "Custom" + End Select + End Function + + Public Function GearboxConv(ByVal Gearbox As String) As tGearbox + Select Case UCase(Trim(Gearbox)) + Case "MT" + Return tGearbox.Manual + Case "AT" + Return tGearbox.Automatic + Case "AMT" + Return tGearbox.SemiAutomatic + Case Else '"Custom" + Return tGearbox.Custom + End Select + End Function + End Class diff --git a/VECTO/Input Files/cGEN.vb b/VECTO/Input Files/cGEN.vb index b546dc528673ccdbd0bd8a744596357f3e604492..ad74250ef4d299603954553a713622d508b23608 100644 --- a/VECTO/Input Files/cGEN.vb +++ b/VECTO/Input Files/cGEN.vb @@ -2,8 +2,8 @@ Public Class cGEN - 'Private Const FormatVersion As Integer = 1 - 'Private FileVersion As Integer + Private Const FormatVersion As String = "1.0" + Private FileVersion As String Private sFilePath As String @@ -471,6 +471,241 @@ lbEr: End Function + Private Function SaveFileOld() As Boolean + Dim fGEN As New cFile_V3 + Dim AuxEntryKV As KeyValuePair(Of String, cVEH.cAuxEntry) + 'Dim s As String + Dim sb As cSubPath + + If Not fGEN.OpenWrite(sFilePath) Then Return False + + 'fGEN.WriteLine("V" & FormatVersion) + + fGEN.WriteLine("c VECTO Input File") + fGEN.WriteLine("c VECTO " & VECTOvers) + fGEN.WriteLine("c " & Now.ToString) + + 'fGEN.WriteLine("c Heavy Duty (0) or Passenger Car (1)") + 'fGEN.WriteLine(Math.Abs(CInt(boPKWja))) + + 'fGEN.WriteLine("c Transient emission correction (1/0)") + 'fGEN.WriteLine(Math.Abs(CInt(bodynkorja))) + + 'fGEN.WriteLine("c Emission Class (EURO ..)") + 'fGEN.WriteLine(ineklasse) + + 'fGEN.WriteLine("c Gear Shift Mode: NEDC (0), FTP (1), Model - MT (2)") + 'fGEN.WriteLine(inizykwael) + + 'fGEN.WriteLine("c Calculation Mode, EngAnalysis, CreateMap") + 'Select Case VehMode + ' Case tVehMode.StandardMode + ' s = "0" + ' Case tVehMode.EngineOnly + ' s = "1" + ' Case tVehMode.HEV + ' s = "2" + ' Case Else 'tVehMode.EV + ' s = "3" + 'End Select + 's &= "," & Math.Abs(CInt(EngAnalysis)) + 's &= "," & Math.Abs(CInt(CreateMap)) + 'fGEN.WriteLine(s) + + 'Map creation ------------------------------------------------ ------ + 'fGEN.WriteLine("c Settings for Emission Map Creation Mode:") + 'fGEN.WriteLine("c Increment Pe, n:") + 'fGEN.WriteLine(inPschrit & "," & innschrit) + + 'fGEN.WriteLine("c CutFull,CutDrag,InsertDrag,DragIntp:") + 'fGEN.WriteLine(Math.Abs(CInt(bKFcutFull)) & "," & Math.Abs(CInt(bKFcutDrag)) & "," & Math.Abs(CInt(bKFinsertDrag)) & "," & Math.Abs(CInt(bKFDragIntp))) + + 'fGEN.WriteLine("c Include Gear Shifts (1/0, Standard = 1)") + 'fGEN.WriteLine(Math.Abs(CInt(boMapSchaltja))) + + 'fGEN.WriteLine("c Averageing Period for Modal Values") + 'fGEN.WriteLine(iniMsek) + + 'fGEN.WriteLine("c ICE Type (Otto = 1, Diesel = 0") + 'fGEN.WriteLine(Math.Abs(CInt(boottoJa))) + + 'Kalt Start--------------------------------------------------------------- + 'fGEN.WriteLine("c Cold Start (1/0)") + 'fGEN.WriteLine(Math.Abs(CInt(bokaltst1))) + + 'fGEN.WriteLine("c t cat start [°C]") + 'fGEN.WriteLine(sitkat1) + + 'fGEN.WriteLine("c t coolant start [°C]") + 'fGEN.WriteLine(sitkw1) + + 'fGEN.WriteLine("c time of start [h.sec]") + 'fGEN.WriteLine(sihsstart) + + 'Dateien------------------------------------------------------------------ + fGEN.WriteLine("c Vehicle (.vveh):") + fGEN.WriteLine(stPathVEH.PathOrDummy) + + fGEN.WriteLine("c Engine (.veng):") + fGEN.WriteLine(stPathENG.PathOrDummy) + + fGEN.WriteLine("c Gearbox (*.vgbx):") + fGEN.WriteLine(stPathGBX.PathOrDummy) + + fGEN.WriteLine("c Driving Cycles (.vdri):") + For Each sb In CycleFiles + fGEN.WriteLine(sb.PathOrDummy) + Next + fGEN.WriteLine(sKey.Break) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing transient correction parameters (*.trs):") + 'fGEN.WriteLine(stdynspez.PathOrDummy) + + 'Kalt Start + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the catalyst map (*.maa):") + 'fGEN.WriteLine(stkatmap.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the map of cooling water (*.mac):") + 'fGEN.WriteLine(stkwmap.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the catalyst warm-up (*.wua):") + 'fGEN.WriteLine(stkatkurv.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the engine coolant warm-up (*.wuc):") + 'fGEN.WriteLine(stkwkurv.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the cooling parameters for catalyst and engine coolant (*.cdw):") + 'fGEN.WriteLine(stcooldown.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the ambient parameters (*.atc)") + 'fGEN.WriteLine(sttumgebung.PathOrDummy) + + 'HEV + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing battery specifications for HEV (*.bat)") + 'fGEN.WriteLine(stBatfile.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing specifications of the E-motor for HEV (*emo)") + 'fGEN.WriteLine(stEmospez.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the pattern of E-motor on/off for HEV (*ean)") + 'fGEN.WriteLine(stEANfile.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the efficiency of additional gearbox for HEV (*get)") + 'fGEN.WriteLine(stGetspez.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the control efficiency-File for HEV (*.ste)") + 'fGEN.WriteLine(stSTEnam.PathOrDummy) + + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c File containing the efficiency-maps for HEV-strategy control (*.ekf)") + 'fGEN.WriteLine(stEKFnam.PathOrDummy) + + 'EXS + 'fGEN.WriteLine("c ") + 'fGEN.WriteLine("c Exhaust System Simulation (1/0)") + 'fGEN.WriteLine(Math.Abs(CInt(boEXSja))) + + 'fGEN.WriteLine("c Exhaust System Simulation Configuration File") + 'fGEN.WriteLine(stPathExs.PathOrDummy) + + 'SOC-Start Iteration + 'fGEN.WriteLine("c SOC Start Iteration (1/0) - HEV only") + 'fGEN.WriteLine(Math.Abs(CInt(boSOCnJa))) + + ''SOC-Start + 'fGEN.WriteLine("c SOC Start - (H)EV only") + 'fGEN.WriteLine(siSOCstart) + + ''Getriebe-Verluste-Modell + 'fGEN.WriteLine("c Transmission Loss Model") + 'fGEN.WriteLine(CStr(GetrMod)) + + 'Coolantsim + 'fGEN.WriteLine("c Coolant System Simulation (1/0)") + 'fGEN.WriteLine(Math.Abs(CInt(CoolantsimJa))) + 'fGEN.WriteLine("c Coolant System Simulation Configuration File") + 'fGEN.WriteLine(stCoolantSimPath.PathOrDummy) + + fGEN.WriteLine("c Auxiliaries (.vaux)") + For Each AuxEntryKV In AuxPaths + fGEN.WriteLine(Trim(UCase(AuxEntryKV.Key)) & "," & AuxEntryKV.Value.Type & "," & AuxEntryKV.Value.Path.PathOrDummy) + Next + fGEN.WriteLine(sKey.Break) + + 'a_DesMax + fGEN.WriteLine("c Speed Dependent Desired Acceleration and Braking (.vacc)") + 'fGEN.WriteLine(Math.Abs(CInt(DesMaxJa))) + fGEN.WriteLine(stDesMaxFile.PathOrDummy) + + 'fGEN.WriteLine("c Gear shift behaviour:") + 'fGEN.WriteLine("c Gearshift model (Version fast driver)") + 'fGEN.WriteLine("c shift up at ratio rpm/rated rpm in actual gear greater than") + 'fGEN.WriteLine(CStr(hinauf)) + 'fGEN.WriteLine("c shift down when rpm/rated rpm in lower gear is higher than") + 'fGEN.WriteLine(CStr(hinunter)) + 'fGEN.WriteLine("c Gearshift model (Version economic driver)") + 'fGEN.WriteLine("c shift up at ratio rpm/rated rpm in higher gear greater than") + 'fGEN.WriteLine(CStr(lhinauf)) + 'fGEN.WriteLine("c Shift down when ratio rpm/rated rpm in actual gear is lower than") + 'fGEN.WriteLine(CStr(lhinunter)) + 'fGEN.WriteLine("c Share of version economic driver (0 to 1)") + 'fGEN.WriteLine(CStr(pspar)) + 'fGEN.WriteLine("c Share of version mixed model (0 to 1)") + 'fGEN.WriteLine(CStr(pmodell)) + + fGEN.WriteLine("c Engine Only Mode (1/0)") + fGEN.WriteLine(CStr(Math.Abs(CInt(EngOnly)))) + + 'Start/Stop + fGEN.WriteLine("c ICE Auto-Start/Stop (1/0) - Non HEV only") + fGEN.WriteLine(Math.Abs(CInt(boStartStop))) + fGEN.WriteLine("c Start/Stop Max Speed [km/h]") + fGEN.WriteLine(siStStV) + fGEN.WriteLine("c Start/Stop Min ICE-On Time [s]") + fGEN.WriteLine(siStStT) + + + fGEN.WriteLine("c Look Ahead reference deceleration [m/2²]") + fGEN.WriteLine(CStr(a_lookahead)) + fGEN.WriteLine("c Minimum target speed for Overspeed/Eco-Roll [km/h]") + fGEN.WriteLine(CStr(vMin)) + fGEN.WriteLine("c Look-Ahead with Coasting 1/0") + fGEN.WriteLine(CStr(Math.Abs(CInt(LookAheadOn)))) + fGEN.WriteLine("c Overspeed 1/0") + fGEN.WriteLine(CStr(Math.Abs(CInt(OverSpeedOn)))) + fGEN.WriteLine("c Eco-Roll 1/0") + fGEN.WriteLine(CStr(Math.Abs(CInt(EcoRollOn)))) + fGEN.WriteLine("c Allowed OverSpeed [km/h]") + fGEN.WriteLine(CStr(OverSpeed)) + fGEN.WriteLine("c Allowed UnderSpeed [km/h]") + fGEN.WriteLine(CStr(UnderSpeed)) + fGEN.WriteLine("c Minimum target speed for Look-Ahead with Coasting [km/h]") + fGEN.WriteLine(CStr(vMinLA)) + + + fGEN.WriteLine("c Start/Stop activation delay time [s]") + fGEN.WriteLine(StStDelay) + + + fGEN.Close() + fGEN = Nothing + + Return True + + End Function + Public Function SaveFile() As Boolean Dim AuxEntryKV As KeyValuePair(Of String, cVEH.cAuxEntry) 'Dim s As String @@ -478,18 +713,25 @@ lbEr: Dim JSON As New cJSON Dim ls As List(Of Object) Dim dic As Dictionary(Of String, Object) + Dim dic0 As Dictionary(Of String, Object) + + If Not Cfg.JSON Then Return SaveFileOld() - 'Meta + 'Header dic = New Dictionary(Of String, Object) dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") dic.Add("Date", Now.ToString) - dic.Add("Version", VECTOvers) - JSON.Content.Add("Info", dic) + dic.Add("AppVersion", VECTOvers) + dic.Add("FileVersion", FormatVersion) + JSON.Content.Add("Header", dic) + + 'Body + dic0 = New Dictionary(Of String, Object) 'Main Files - JSON.Content.Add("VehicleFile", stPathVEH.PathOrDummy) - JSON.Content.Add("EngineFile", stPathENG.PathOrDummy) - JSON.Content.Add("GearboxFile", stPathGBX.PathOrDummy) + dic0.Add("VehicleFile", stPathVEH.PathOrDummy) + dic0.Add("EngineFile", stPathENG.PathOrDummy) + dic0.Add("GearboxFile", stPathGBX.PathOrDummy) 'Cycles If CycleFiles.Count > 0 Then @@ -497,7 +739,7 @@ lbEr: For Each sb In CycleFiles ls.Add(sb.PathOrDummy) Next - JSON.Content.Add("Cycles", ls) + dic0.Add("Cycles", ls) End If 'Aux @@ -510,14 +752,14 @@ lbEr: dic.Add("Path", AuxEntryKV.Value.Path.PathOrDummy) ls.Add(dic) Next - JSON.Content.Add("Aux", ls) + dic0.Add("Aux", ls) End If 'VACC - JSON.Content.Add("VACC", stDesMaxFile.PathOrDummy) + dic0.Add("VACC", stDesMaxFile.PathOrDummy) 'EngineOnlyMode - JSON.Content.Add("EngineOnlyMode", EngOnly) + dic0.Add("EngineOnlyMode", EngOnly) 'Start Stop dic = New Dictionary(Of String, Object) @@ -525,14 +767,14 @@ lbEr: dic.Add("MaxSpeed", siStStV) dic.Add("MinTime", siStStT) dic.Add("Delay", StStDelay) - JSON.Content.Add("StartStop", dic) + dic0.Add("StartStop", dic) 'LAC dic = New Dictionary(Of String, Object) dic.Add("Enabled", LookAheadOn) dic.Add("Dec", a_lookahead) dic.Add("MinSpeed", vMinLA) - JSON.Content.Add("LAC", dic) + dic0.Add("LAC", dic) 'Overspeed / EcoRoll dic = New Dictionary(Of String, Object) @@ -546,8 +788,10 @@ lbEr: dic.Add("MinSpeed", vMin) dic.Add("OverSpeed", OverSpeed) dic.Add("UnderSpeed", UnderSpeed) - JSON.Content.Add("OverSpeedEcoRoll", dic) + dic0.Add("OverSpeedEcoRoll", dic) + + JSON.Content.Add("Body", dic0) Return JSON.WriteFile(sFilePath) @@ -567,13 +811,18 @@ lbEr: 'Flag for "File is not JSON" Warnings NoJSON = False - If sFilePath = "" Then Return False - If Not IO.File.Exists(sFilePath) Then Return False - SetDefault() - If Not JSON.ReadFile(sFilePath) Then - NoJSON = True + If Cfg.JSON Then + If Not JSON.ReadFile(sFilePath) Then + NoJSON = True + Try + Return ReadFileOld() + Catch ex As Exception + Return False + End Try + End If + Else Try Return ReadFileOld() Catch ex As Exception @@ -582,22 +831,25 @@ lbEr: End If Try - If JSON.Content.ContainsKey("VehicleFile") Then stPathVEH.Init(MyPath, JSON.Content("VehicleFile")) - stPathENG.Init(MyPath, JSON.Content("EngineFile")) + FileVersion = JSON.Content("Header")("FileVersion") - If JSON.Content.ContainsKey("GearboxFile") Then stPathGBX.Init(MyPath, JSON.Content("GearboxFile")) + If Not JSON.Content("Body")("VehicleFile") Is Nothing Then stPathVEH.Init(MyPath, JSON.Content("Body")("VehicleFile")) - If JSON.Content.ContainsKey("Cycles") Then - For Each str In JSON.Content("Cycles") + stPathENG.Init(MyPath, JSON.Content("Body")("EngineFile")) + + If Not JSON.Content("Body")("GearboxFile") Is Nothing Then stPathGBX.Init(MyPath, JSON.Content("Body")("GearboxFile")) + + If Not JSON.Content("Body")("Cycles") Is Nothing Then + For Each str In JSON.Content("Body")("Cycles") SubPath = New cSubPath SubPath.Init(MyPath, str) CycleFiles.Add(SubPath) Next End If - If JSON.Content.ContainsKey("Aux") Then - For Each dic In JSON.Content("Aux") + If Not JSON.Content("Body")("Aux") Is Nothing Then + For Each dic In JSON.Content("Body")("Aux") AuxID = UCase(Trim(dic("ID").ToString)) @@ -618,9 +870,9 @@ lbEr: Next End If - If JSON.Content.ContainsKey("VACC") Then stDesMaxFile.Init(MyPath, JSON.Content("VACC")) + If Not JSON.Content("Body")("VACC") Is Nothing Then stDesMaxFile.Init(MyPath, JSON.Content("Body")("VACC")) - EngOnly = JSON.Content("EngineOnlyMode") + EngOnly = JSON.Content("Body")("EngineOnlyMode") If EngOnly Then VehMode = tVehMode.EngineOnly @@ -628,8 +880,8 @@ lbEr: VehMode = tVehMode.StandardMode End If - If JSON.Content.ContainsKey("StartStop") Then - dic = JSON.Content("StartStop") + If Not JSON.Content("Body")("StartStop") Is Nothing Then + dic = JSON.Content("Body")("StartStop") boStartStop = dic("Enabled") siStStV = dic("MaxSpeed") siStStT = dic("MinTime") @@ -638,8 +890,8 @@ lbEr: boStartStop = False End If - If JSON.Content.ContainsKey("LAC") Then - dic = JSON.Content("LAC") + If Not JSON.Content("Body")("LAC") Is Nothing Then + dic = JSON.Content("Body")("LAC") LookAheadOn = dic("Enabled") a_lookahead = dic("Dec") vMinLA = dic("MinSpeed") @@ -647,9 +899,9 @@ lbEr: LookAheadOn = False End If - If JSON.Content.ContainsKey("OverSpeedEcoRoll") Then + If Not JSON.Content("Body")("OverSpeedEcoRoll") Is Nothing Then - dic = JSON.Content("OverSpeedEcoRoll") + dic = JSON.Content("Body")("OverSpeedEcoRoll") Select Case UCase(dic("Mode").ToString).Trim Case "ECOROLL" @@ -689,7 +941,6 @@ lbEr: End Function - Private Sub SetDefault() boPKWja = False bodynkorja = False diff --git a/VECTO/Input Files/cVEH.vb b/VECTO/Input Files/cVEH.vb index a162d07708ab8e5593f98a10af50fc60a2a1a264..1b81c2db7cb78d962fd50d3c26e9805f0badbcd6 100644 --- a/VECTO/Input Files/cVEH.vb +++ b/VECTO/Input Files/cVEH.vb @@ -2,6 +2,9 @@ Public Class cVEH + Private Const FormatVersion As String = "1.0" + Private FileVersion As String + Private sFilePath As String Private MyPath As String @@ -63,7 +66,9 @@ Public Class cVEH Public VehCat As tVehCat Public MassExtra As Single Public MassMax As Single - Public AxcleConf As tAxleConf + Public AxleConf As tAxleConf + + Public NoJSON As Boolean Private MyFileList As List(Of String) @@ -157,12 +162,11 @@ Public Class cVEH RtFile.Clear() RRCs.Clear() VehCat = tVehCat.Rigid - MassExtra = 0 MassMax = 0 - AxcleConf = tAxleConf.a4x2 + AxleConf = tAxleConf.a4x2 End Sub - Public Function ReadFile() As Boolean + Private Function ReadFileOld() As Boolean Dim file As cFile_V3 Dim line() As String Dim MsgSrc As String @@ -326,7 +330,7 @@ Public Class cVEH VehCat = CType(CInt(file.ReadLine(0)), tVehCat) MassExtra = CSng(file.ReadLine(0)) MassMax = CSng(file.ReadLine(0)) - AxcleConf = CType(CInt(file.ReadLine(0)), tAxleConf) + AxleConf = CType(CInt(file.ReadLine(0)), tAxleConf) Catch ex As Exception WorkerMsg(tMsgID.Err, ex.Message, MsgSrc) file.Close() @@ -347,7 +351,7 @@ lbError: End Function - Public Function SaveFile() As Boolean + Private Function SaveFileOld() As Boolean Dim file As cFile_V3 Dim sl As Single() @@ -451,7 +455,7 @@ lbError: file.WriteLine("c MassMax") file.WriteLine(CStr(MassMax)) file.WriteLine("c Axle Configuration") - file.WriteLine(CStr(CType(AxcleConf, Integer))) + file.WriteLine(CStr(CType(AxleConf, Integer))) file.Close() file = Nothing @@ -460,6 +464,147 @@ lbError: End Function + + Public Function ReadFile() As Boolean + Dim JSON As New cJSON + Dim dic As Object + + Dim MsgSrc As String + + + MsgSrc = "VEH/ReadFile" + + 'Flag for "File is not JSON" Warnings + NoJSON = False + + SetDefault() + + If Cfg.JSON Then + If Not JSON.ReadFile(sFilePath) Then + NoJSON = True + Try + Return ReadFileOld() + Catch ex As Exception + Return False + End Try + End If + Else + Try + Return ReadFileOld() + Catch ex As Exception + Return False + End Try + End If + + Try + + FileVersion = JSON.Content("Header")("FileVersion") + + siMass = JSON.Content("Body")("CurbWeight") + MassExtra = JSON.Content("Body")("CurbWeightExtra") + siLoading = JSON.Content("Body")("Loading") + MassMax = JSON.Content("Body")("MassMax") + + siCd0 = JSON.Content("Body")("Cd") + siAquers = JSON.Content("Body")("CrossSecArea") + + siI_wheels = JSON.Content("Body")("WheelsInertia") + siDreifen = JSON.Content("Body")("WheelsDiaEff") + + CdMode = CdModeConv(JSON.Content("Body")("CdCorrMode").ToString) + If Not JSON.Content("Body")("CdCorrFile") Is Nothing Then CdFile.Init(MyPath, JSON.Content("Body")("CdCorrFile")) + + If JSON.Content("Body")("Retarder") Is Nothing Then + RtType = tRtType.None + Else + RtType = RtTypeConv(JSON.Content("Body")("Retarder")("Type").ToString) + If Not JSON.Content("Body")("Retarder")("Ratio") Is Nothing Then RtRatio = JSON.Content("Body")("Retarder")("Ratio") + If Not JSON.Content("Body")("Retarder")("File") Is Nothing Then RtFile.Init(MyPath, JSON.Content("Body")("Retarder")("File")) + End If + + AxleConf = AxleConfConv(JSON.Content("Body")("AxleConfig")("Type").ToString) + For Each dic In JSON.Content("Body")("AxleConfig")("Axles") + RRCs.Add(New Single() {dic("AxleWeightShare"), dic("RRCISO"), dic("FzISO")}) + Next + + VehCat = VehCatConv(JSON.Content("Body")("VehCat").ToString) + + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Failed to read Vehicle file! " & ex.Message, MsgSrc) + Return False + End Try + + Return True + + + + End Function + + Public Function SaveFile() As Boolean + Dim sl As Single() + Dim dic As Dictionary(Of String, Object) + Dim dic0 As Dictionary(Of String, Object) + Dim ls As List(Of Dictionary(Of String, Object)) + Dim JSON As New cJSON + + + If Not Cfg.JSON Then Return SaveFileOld() + + '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("VehCat", VehCatConv(VehCat)) + + dic.Add("CurbWeight", siMass) + dic.Add("CurbWeightExtra", MassExtra) + dic.Add("Loading", siLoading) + dic.Add("MassMax", MassMax) + + dic.Add("Cd", siCd0) + dic.Add("CrossSecArea", siAquers) + + dic.Add("WheelsInertia", siI_wheels) + dic.Add("WheelsDiaEff", siDreifen) + + dic.Add("CdCorrMode", CdModeConv(CdMode)) + dic.Add("CdCorrFile", CdFile.PathOrDummy) + + dic0 = New Dictionary(Of String, Object) + dic0.Add("Type", RtTypeConv(RtType)) + dic0.Add("Ratio", RtRatio) + dic0.Add("File", RtFile.PathOrDummy) + dic.Add("Retarder", dic0) + + ls = New List(Of Dictionary(Of String, Object)) + For Each sl In RRCs + dic0 = New Dictionary(Of String, Object) + dic0.Add("AxleWeightShare", sl(0)) + dic0.Add("RRCISO", sl(1)) + dic0.Add("FzISO", sl(2)) + ls.Add(dic0) + Next + + dic0 = New Dictionary(Of String, Object) + dic0.Add("Type", AxleConfConv(AxleConf)) + dic0.Add("Axles", ls) + dic.Add("AxleConfig", dic0) + + JSON.Content.Add("Body", dic) + + Return JSON.WriteFile(sFilePath) + + + End Function + + Public Function VehmodeInit() As Boolean Dim MsgSrc As String @@ -506,7 +651,7 @@ lbError: sumprod = 0 For Each sl In RRCs - sumprod += sl(0) * (sl(1) * 100 * ((siLoading + siMass + MassExtra) * 9.81 * sl(0) / sl(2)) ^ (0.9 - 1)) 'Beta=0.9 + sumprod += sl(0) * (sl(1) * ((siLoading + siMass + MassExtra) * 9.81 * sl(0) / sl(2)) ^ (0.9 - 1)) 'Beta=0.9 Next siFr0 = sumprod / sumW @@ -1514,6 +1659,132 @@ lbInt: + Public Function VehCatConv(ByVal VehCat As tVehCat) As String + Select Case VehCat + Case tVehCat.Citybus + Return "Citybus" + Case tVehCat.Coach + Return "Coach" + Case tVehCat.InterurbanBus + Return "InterurbanBus" + Case tVehCat.Rigid + Return "Rigid" + Case Else 'tVehCat.Tractor + Return "Tractor" + End Select + End Function + + Public Function VehCatConv(ByVal VehCat As String) As tVehCat + Select Case UCase(Trim(VehCat)) + Case "CITYBUS" + Return tVehCat.Citybus + Case "COACH" + Return tVehCat.Coach + Case "INTERURBANBUS" + Return tVehCat.InterurbanBus + Case "RIGID" + Return tVehCat.Rigid + Case Else '"TRACTOR" + Return tVehCat.Tractor + End Select + End Function + + + Public Function CdModeConv(ByVal CdMode As tCdMode) As String + Select Case CdMode + Case tCdMode.CdOfBeta + Return "CdOfBeta" + Case tCdMode.CdOfV + Return "CdOfV" + Case Else 'tCdMode.ConstCd0 + Return "Off" + End Select + End Function + + Public Function CdModeConv(ByVal CdMode As String) As tCdMode + Select Case UCase(Trim(CdMode)) + Case "CDOFBETA" + Return tCdMode.CdOfBeta + Case "CDOFV" + Return tCdMode.CdOfV + Case Else '"OFF" + Return tCdMode.ConstCd0 + End Select + End Function + + Public Function AxleConfConv(ByVal AxleConf As tAxleConf) As String + Select Case AxleConf + Case tAxleConf.a4x2 + Return "4x2" + Case tAxleConf.a4x4 + Return "4x4" + Case tAxleConf.a6x2 + Return "6x2" + Case tAxleConf.a6x4 + Return "6x4" + Case tAxleConf.a6x6 + Return "6x6" + Case tAxleConf.a8x2 + Return "8x2" + Case tAxleConf.a8x4 + Return "8x4" + Case tAxleConf.a8x6 + Return "8x6" + Case Else 'tAxleConf.a8x8 + Return "8x8" + End Select + End Function + + Public Function AxleConfConv(ByVal AxleConf As String) As tAxleConf + Select Case UCase(Trim(AxleConf)) + Case "4X2" + Return tAxleConf.a4x2 + Case "4X4" + Return tAxleConf.a4x4 + Case "6X2" + Return tAxleConf.a6x2 + Case "6X4" + Return tAxleConf.a6x4 + Case "6X6" + Return tAxleConf.a6x6 + Case "8X2" + Return tAxleConf.a8x2 + Case "8X4" + Return tAxleConf.a8x4 + Case "8X6" + Return tAxleConf.a8x6 + Case Else '"8X8" + Return tAxleConf.a8x8 + End Select + End Function + + Public Function RtTypeConv(ByVal RtType As tRtType) As String + Select Case RtType + Case tRtType.Primary + Return "Primary" + Case tRtType.Secondary + Return "Secondary" + Case Else 'tRtType.None + Return "None" + End Select + End Function + + Public Function RtTypeConv(ByVal RtType As String) As tRtType + Select Case UCase(Trim(RtType)) + Case "PRIMARY" + Return tRtType.Primary + Case "SECONDARY" + Return tRtType.Secondary + Case Else '"NONE" + Return tRtType.None + End Select + End Function + + + + + + #End Region diff --git a/VECTO/M_Lese.vb b/VECTO/M_Lese.vb index 90cee2e1b8fc51392376d287c913f7f55eead33b..9d78803b29e3376ce04fc616b84c204aea5cfcc9 100644 --- a/VECTO/M_Lese.vb +++ b/VECTO/M_Lese.vb @@ -36,7 +36,7 @@ Module M_Lese Return False End Try - If GEN.NoJSON Then WorkerMsg(tMsgID.Warn, "VECTO file format is outdated! CLICK HERE to open and save file in Editor to update to current format!", MsgSrc, "<GUI>" & GenFile) + If GEN.NoJSON Then WorkerMsg(tMsgID.Warn, "VECTO file format is outdated! CLICK HERE to convert to current format!", MsgSrc, "<GUI>" & GenFile) 'VECTO: Defaultwerte für Parameter die nicht mehr in der .GEN/.VECTO sind werden beim Einlesen über SetDefault belegt. |@@| VECTO: Default values for the parameters are no longer in GEN/.VECTO but are allocated when Read about SetDefault. @@ -73,6 +73,9 @@ Module M_Lese VEH.lhinunter = (VEH.nLeerl / VEH.nNenn) + VEH.lhinunter * (1 - (VEH.nLeerl / VEH.nNenn)) End If + If VEH.NoJSON Then WorkerMsg(tMsgID.Warn, "Vehicle file format is outdated! CLICK HERE to convert to current format!", MsgSrc, "<GUI>" & GEN.PathVEH) + + '----------------------------- ~ENG~ ----------------------------- ENG = New cENG ENG.FilePath = GEN.PathENG @@ -83,6 +86,8 @@ Module M_Lese Return False End Try + If ENG.NoJSON Then WorkerMsg(tMsgID.Warn, "Engine file format is outdated! CLICK HERE to convert to current format!", MsgSrc, "<GUI>" & GEN.PathENG) + '----------------------------- ~GBX~ ----------------------------- GBX = New cGBX @@ -97,6 +102,9 @@ Module M_Lese End Try End If + If GBX.NoJSON Then WorkerMsg(tMsgID.Warn, "Gearbox file format is outdated! CLICK HERE to convert to current format!", MsgSrc, "<GUI>" & GEN.PathGBX) + + '----------------------------- VECTO ----------------------------- 'GEN => VEH VEH.AuxDef = GEN.AuxDef diff --git a/VECTO/M_MAIN.vb b/VECTO/M_MAIN.vb index e3b37e019fcc996ed4948cc6f034e392c17560b6..4b4ce366ddaf0aad0301b4033ab54a7cebcf147d 100644 --- a/VECTO/M_MAIN.vb +++ b/VECTO/M_MAIN.vb @@ -589,6 +589,13 @@ lbNextJob: WorkerMsg(tMsgID.Normal, "Summary Results written to: " & fFILE(ERG.ErgFile, True), MsgSrc, ERG.ErgFile) + 'JSON Erg Output + If ERG.WriteJSON() Then + WorkerMsg(tMsgID.Normal, "Summary Results (JSON) written to: " & fFILE(ERG.ErgFile & ".json", True), MsgSrc, ERG.ErgFile & ".json") + Else + WorkerMsg(tMsgID.Err, "Failed to write JSON Summary Results!", MsgSrc) + End If + 'Write file signatures WorkerMsg(tMsgID.Normal, "Signing files", MsgSrc) Lic.FileSigning.Mode = vectolic.cFileSigning.tMode.Auto diff --git a/VECTO/VECTO_Global.vb b/VECTO/VECTO_Global.vb index a9ddff278e8cd41c49f69b1e7607335117988664..99be7de2d525c34c27cd0cf4d3512a1fa807ea3c 100644 --- a/VECTO/VECTO_Global.vb +++ b/VECTO/VECTO_Global.vb @@ -2,7 +2,7 @@ Module VECTO_Global - Public Const VECTOvers As String = "1.4 RC2 JSON 2" + Public Const VECTOvers As String = "1.4 RC3" Public Const LicSigAppCode As String = "VECTO-Release-0093C61E0A2E4BFA9A7ED7E729C56AE4" Public MyAppPath As String Public MyConfPath As String diff --git a/VECTO/cConfig.vb b/VECTO/cConfig.vb index 5eaad5b4880734c82a11884fd01a8a6e1053ea3b..c74743d3bf21cfd4c2ca06f3876ca9f58bc427ea 100644 --- a/VECTO/cConfig.vb +++ b/VECTO/cConfig.vb @@ -28,6 +28,8 @@ Public FuelDens As Single Public CO2perFC As Single + Public JSON As Boolean + Public FirstRun As Boolean Public Sub New() @@ -114,7 +116,6 @@ OpenCmd = line(0) If UBound(line) > 0 Then OpenCmdName = line(1) - FuelDens = CSng(c.ReadLine(0)) CO2perFC = CSng(c.ReadLine(0)) @@ -122,6 +123,11 @@ FirstRun = CBool(c.ReadLine(0)) + If c.EndOfFile Then GoTo lbDone + + JSON = CBool(c.ReadLine(0)) + + lbDone: @@ -136,100 +142,6 @@ lbEr: End Function - Private Function ReadOldFormat() As Boolean - Dim c As New cFile_V3 - Dim line As String = "" - Dim x As Short - - 'Config.txt - 'Line Variable Type Description - '(01) WorkDPath String WorkDir - '(02) LastMode Short Last used mode (equivalent CBoxMODE.SelectedIndex) - '(03) IntpV2 Boolean New interpolator to use - '(04) nnormEngStop Single Stop engine if under this Revolutions - '(05) TEMpath String TEM_Data path - '(06) LastTEM String Last TEM file -not in Options Form!!!! - '(07) TEMexl Boolean Open TEM in Excel -not in Options Form!!! - '(08) EAAvInt Short Analysis intervals in seconds. If 0: Ask for Value - '(09) ModOut Boolean Dump Modal - '(10) WegKorJa Boolean Wegkorrektur damit bei Geschw. Reduktion Zyklus nicht kürzer wird |@@| 10) WegKorJa Boolean Path-correction in so speed. Reduction cycle is not shorter - '(11) GnVorgab Boolean Gear-per- Revolutions - '(12) LogSize Int16 Maximum Log-size [MiB] - '(13) FZPsort Boolean FZP sortieren (früher Standard da VISSIM die .fzp nach Sekunden sortiert ausgibt) |@@| 13) FZPsort Boolean FZP sort (formerly standard since the VISSIM. Fzp sorted according seconds) outputs - '(14) FZPsortExp Boolean Export FZP Sorted - '(15) BATCHoutpath Boolean Output path for BATCH mode: <WORKDIR>, <GENPATH> or path - '(16) BATCHoutSubD Boolean Dump-BATCH in Subfolders (per .gen File) - '(17) AirDensity Single Air-density - '(18) FinalEmOnly Boolean Dump only Final Emission - '(19) FCcorrection Boolean FC-Correction in BATCH-mode - - If Not IO.File.Exists(MyConfPath & "settings.txt") Then - GUImsg(tMsgID.Err, "Config-file not found! Using default settings.") - Return False - End If - - c.OpenRead(MyConfPath & "settings.txt", "+hugo+") - - For x = 1 To 19 - If c.EndOfFile Then GoTo lbEnd - line = c.ReadLine(0) - Select Case x - Case 1 - sWorkDPath = Trim(line) - If UCase(sWorkDPath) = sKey.HomePath Then - sWorkDPath = MyAppPath - WorkDirHome = True - End If - Case 2 - LastMode = line 'Früher GenLpath = line - Case 3 - 'Previously: IntpV2 = CBool(line) - Case 4 - nnormEngStop = CSng(line) - Case 5 - TEMpath = line - Case 6 - LastTEM = line - Case 7 - TEMexl = CBool(line) - Case 8 - EAAvInt = Val(line) - Case 9 - ModOut = CBool(line) - Case 10 - WegKorJa = CBool(line) - Case 11 - GnVorgab = CBool(line) - Case 12 - If IsNumeric(line) Then LogSize = line - Case 13 - FZPsort = CBool(line) - Case 14 - FZPsortExp = CBool(line) - Case 15 - BATCHoutpath = Trim(line) - Case 16 - BATCHoutSubD = CBool(line) - Case 17 - AirDensity = CSng(line) - Case 18 - FinalEmOnly = CBool(line) - Case 19 - FCcorrection = CBool(line) - End Select - Next - '------------------------------------------------ - GoTo lbDone -lbEnd: - GUImsg(tMsgID.Warn, "Missing parameters in Configuration File! Using default settings.") -lbDone: - c.Close() - c = Nothing - - Return True - - End Function - Public Sub SetDefault() GnVorgab = True sWorkDPath = "c:\" @@ -252,7 +164,6 @@ lbDone: OpenCmd = "notepad" OpenCmdName = "Notepad" - FuelDens = 0.835 CO2perFC = 3.153 @@ -260,6 +171,8 @@ lbDone: FirstRun = True + JSON = True + End Sub Public Sub ConfigSAVE() @@ -321,6 +234,9 @@ lbDone: c.WriteLine("c First Run (Show Quick Start Guide Prompt)") c.WriteLine(Math.Abs(CInt(FirstRun))) + c.WriteLine("c In- and Output in JSON format") + c.WriteLine(Math.Abs(CInt(JSON))) + c.Close() c = Nothing diff --git a/VECTO/cERG.vb b/VECTO/cERG.vb index 4c39eb0daeaa5de1381decc162cf504c9a2a90e3..75ec8d8137c773a100040afdda6c0a17867320be 100644 --- a/VECTO/cERG.vb +++ b/VECTO/cERG.vb @@ -2,6 +2,8 @@ Class cERG + Private Const FormatVersion As String = "1.0" + Private ERGpath As String Private Ferg As System.IO.StreamWriter Private HeadInitialized As Boolean @@ -9,6 +11,10 @@ Class cERG Private ErgEntries As Dictionary(Of String, cErgEntry) Private ErgEntryList As List(Of String) 'Wird benötigt weil Dictionary nicht sortiert ist + Private ergJSON As cJSON + Private ResList As List(Of Dictionary(Of String, Object)) + + Public Sub New() HeadInitialized = False ERGpath = "" @@ -61,13 +67,13 @@ Class cERG Dim First As Boolean For Each ErgEntry In ErgEntries.Values - ErgEntry.ValueString = "-" + ErgEntry.ValueString = Nothing Next t1 = MODdata.tDim 'Vehicle type-independent - ErgEntries("\\T").ValueString = (t1 + 1).ToString + ErgEntries("\\T").ValueString = (t1 + 1) ErgEntries("\\Prated").ValueString = VEH.Pnenn 'Length, Speed, Slope @@ -80,8 +86,8 @@ Class cERG Next Vquer = 3.6 * sum / (t1 + 1) - ErgEntries("\\S").ValueString = (Vquer * (t1 + 1) / 3600).ToString - ErgEntries("\\V").ValueString = Vquer.ToString + ErgEntries("\\S").ValueString = (Vquer * (t1 + 1) / 3600) + ErgEntries("\\V").ValueString = Vquer 'altitude change sum = 0 @@ -89,7 +95,7 @@ Class cERG sum += MODdata.Vh.V(t) * 1 * MODdata.Vh.Grad(t) / 100 'v[m/s] * t[s] * grad[-] = ∆h[m] Next - ErgEntries("\\G").ValueString = (sum).ToString + ErgEntries("\\G").ValueString = (sum) 'Auxiliary energy consumption If GEN.AuxDef Then @@ -118,7 +124,7 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\PeEM+").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\PeEM+").ValueString = (sum / c) 'Positive effective Battery-Power = internal EM-Power sum = 0 @@ -129,7 +135,7 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\PeBat+").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\PeBat+").ValueString = (sum / c) 'Positive internal Battery-Power sum = 0 @@ -140,7 +146,7 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\PiBat+").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\PiBat+").ValueString = (sum / c) 'Calculate Energy consumed EBatPlus = sum / 3600 @@ -154,7 +160,7 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\PeEM-").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\PeEM-").ValueString = (sum / c) 'Negative effective Battery-Power = internal EM-Power sum = 0 @@ -165,7 +171,7 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\PeBat-").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\PeBat-").ValueString = (sum / c) 'Negative internal Battery-Power sum = 0 @@ -176,14 +182,14 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\PiBat-").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\PiBat-").ValueString = (sum / c) 'Charged-energy calculation EBatMinus = sum / 3600 'Battery in/out Energy - ErgEntries("\\EiBat+").ValueString = EBatPlus.ToString - ErgEntries("\\EiBat-").ValueString = EBatMinus.ToString + ErgEntries("\\EiBat+").ValueString = EBatPlus + ErgEntries("\\EiBat-").ValueString = EBatMinus 'EtaEM sum = 0 @@ -197,7 +203,7 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\EtaEM").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\EtaEM").ValueString = (sum / c) 'EtaBat sum = 0 @@ -211,16 +217,16 @@ Class cERG c += 1 End If Next - If c > 0 Then ErgEntries("\\EtaBat").ValueString = (sum / c).ToString + If c > 0 Then ErgEntries("\\EtaBat").ValueString = (sum / c) 'Delta SOC - ErgEntries("\\∆SOC").ValueString = (MODdata.Px.SOC(t1) - MODdata.Px.SOC(0)).ToString + ErgEntries("\\∆SOC").ValueString = (MODdata.Px.SOC(t1) - MODdata.Px.SOC(0)) 'Only EV: If GEN.VehMode = tVehMode.EV Then 'Energy-consumption - ErgEntries("\\EC").ValueString = ((EBatPlus + EBatMinus) / (Vquer * (t1 + 1) / 3600)).ToString + ErgEntries("\\EC").ValueString = ((EBatPlus + EBatMinus) / (Vquer * (t1 + 1) / 3600)) End If @@ -243,9 +249,9 @@ Class cERG End If Else If Em0.NormID = tEmNorm.x Or GEN.VehMode = tVehMode.EngineOnly Then - ErgEntries(Em0.IDstring).ValueString = Em0.FinalAvg.ToString + ErgEntries(Em0.IDstring).ValueString = Em0.FinalAvg Else - ErgEntries(Em0.IDstring & "_km").ValueString = (Em0.FinalAvg / Vquer).ToString + ErgEntries(Em0.IDstring & "_km").ValueString = (Em0.FinalAvg / Vquer) End If End If @@ -258,27 +264,27 @@ Class cERG 'For t = 0 To t1 ' sum += MODdata.Pe(t) 'Next - 'ErgEntries("\\Pe_norm").ValueString = (sum / (t1 + 1)).ToString + 'ErgEntries("\\Pe_norm").ValueString = (sum / (t1 + 1)) 'sum = 0 'For t = 0 To t1 ' sum += MODdata.nn(t) 'Next - 'ErgEntries("\\n_norm").ValueString = (sum / (t1 + 1)).ToString + 'ErgEntries("\\n_norm").ValueString = (sum / (t1 + 1)) 'Ppos sum = 0 For t = 0 To t1 sum += Math.Max(0, MODdata.Pe(t)) Next - ErgEntries("\\Ppos").ValueString = (sum / (t1 + 1)).ToString + ErgEntries("\\Ppos").ValueString = (sum / (t1 + 1)) 'Pneg sum = 0 For t = 0 To t1 sum += Math.Min(0, MODdata.Pe(t)) Next - ErgEntries("\\Pneg").ValueString = (sum / (t1 + 1)).ToString + ErgEntries("\\Pneg").ValueString = (sum / (t1 + 1)) End If @@ -290,60 +296,60 @@ Class cERG For t = 0 To t1 sum += MODdata.Pbrake(t) / VEH.Pnenn Next - ErgEntries("\\Pbrake").ValueString = (sum / (t1 + 1)).ToString + ErgEntries("\\Pbrake").ValueString = (sum / (t1 + 1)) 'Eair sum = 0 For t = 0 To t1 sum += MODdata.Pluft(t) Next - ErgEntries("\\Eair").ValueString = (-sum / 3600).ToString + ErgEntries("\\Eair").ValueString = (-sum / 3600) 'Eroll sum = 0 For t = 0 To t1 sum += MODdata.Proll(t) Next - ErgEntries("\\Eroll").ValueString = (-sum / 3600).ToString + ErgEntries("\\Eroll").ValueString = (-sum / 3600) 'Egrad sum = 0 For t = 0 To t1 sum += MODdata.Pstg(t) Next - ErgEntries("\\Egrad").ValueString = (-sum / 3600).ToString + ErgEntries("\\Egrad").ValueString = (-sum / 3600) 'Eacc sum = 0 For t = 0 To t1 sum += MODdata.Pa(t) + MODdata.PaGB(t) + MODdata.PaEng(t) Next - ErgEntries("\\Eacc").ValueString = (-sum / 3600).ToString + ErgEntries("\\Eacc").ValueString = (-sum / 3600) 'Eaux sum = 0 For t = 0 To t1 sum += MODdata.PauxSum(t) Next - ErgEntries("\\Eaux").ValueString = (-sum / 3600).ToString + ErgEntries("\\Eaux").ValueString = (-sum / 3600) 'Ebrake sum = 0 For t = 0 To t1 sum += MODdata.Pbrake(t) Next - ErgEntries("\\Ebrake").ValueString = (sum / 3600).ToString + ErgEntries("\\Ebrake").ValueString = (sum / 3600) 'Etransm sum = 0 For t = 0 To t1 sum += MODdata.PlossDiff(t) + MODdata.PlossGB(t) Next - ErgEntries("\\Etransm").ValueString = (-sum / 3600).ToString + ErgEntries("\\Etransm").ValueString = (-sum / 3600) 'Masse, Loading - ErgEntries("\\Mass").ValueString = (VEH.Mass + VEH.MassExtra).ToString - ErgEntries("\\Loading").ValueString = VEH.Loading.ToString + ErgEntries("\\Mass").ValueString = (VEH.Mass + VEH.MassExtra) + ErgEntries("\\Loading").ValueString = VEH.Loading 'CylceKin For Each ErgEntry In MODdata.CylceKin.ErgEntries @@ -356,14 +362,14 @@ Class cERG For t = 0 To t1 sum += Math.Max(0, MODdata.Pe(t)) Next - ErgEntries("\\EposICE").ValueString = (VEH.Pnenn * sum / 3600).ToString + ErgEntries("\\EposICE").ValueString = (VEH.Pnenn * sum / 3600) 'EnegICE sum = 0 For t = 0 To t1 sum += Math.Min(0, MODdata.Pe(t)) Next - ErgEntries("\\EnegICE").ValueString = (VEH.Pnenn * sum / 3600).ToString + ErgEntries("\\EnegICE").ValueString = (VEH.Pnenn * sum / 3600) End If End If @@ -411,6 +417,10 @@ Class cERG Public Function AusgERG(ByVal NrOfRunStr As String, ByVal GenFilename As String, ByVal CycleFilename As String, ByVal AbortedByError As Boolean) As Boolean Dim str As String Dim MsgSrc As String + Dim dic As Dictionary(Of String, Object) + Dim dic0 As Dictionary(Of String, Object) + Dim dic1 As Dictionary(Of String, Object) + Dim key As String MsgSrc = "SUMALL/Output" @@ -418,6 +428,9 @@ Class cERG If Not HeadInit() Then Return False End If + 'JSON + dic = New Dictionary(Of String, Object) + 'Open file Try Ferg = My.Computer.FileSystem.OpenTextFileWriter(ERGpath, True, FileFormat) @@ -428,13 +441,30 @@ Class cERG End Try str = NrOfRunStr & "," & GenFilename & "," & CycleFilename & "," + dic.Add("Job", GenFilename) + dic.Add("Cycle", CycleFilename) If AbortedByError Then Ferg.WriteLine(str & "Aborted due to Error!") + dic.Add("AbortedByError", True) Else Ferg.WriteLine(str & ErgLine()) + dic.Add("AbortedByError", False) + + dic1 = New Dictionary(Of String, Object) + For Each key In ErgEntryList + dic0 = New Dictionary(Of String, Object) + dic0.Add("Value", ErgEntries(key).ValueString) + dic0.Add("Unit", ErgEntries(key).Unit) + dic1.Add(ErgEntries(key).Head, dic0) + Next + dic.Add("Results", dic1) + End If + ResList.Add(dic) + + 'Close file Ferg.Close() Ferg = Nothing @@ -443,6 +473,18 @@ Class cERG End Function + Public Function WriteJSON() As Boolean + + ergJSON.Content("Body").add("Results", ResList) + + Try + Return ergJSON.WriteFile(ERGpath & ".json") + Catch ex As Exception + Return False + End Try + + End Function + Private Sub AddToErg(ByVal IDstring As String, ByVal Head As String, ByVal Unit As String) If Not ErgEntries.ContainsKey(IDstring) Then ErgEntries.Add(IDstring, New cErgEntry(Head, Unit)) @@ -485,6 +527,8 @@ Class cERG Dim i2 As Integer Dim iDim As Integer Dim DRI0 As cDRI + Dim dic As Dictionary(Of String, Object) + Dim MsgSrc As String @@ -520,17 +564,40 @@ Class cERG Return False End Try + 'JSON + ergJSON = New cJSON + + 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) + ergJSON.Content.Add("Header", dic) + ergJSON.Content.Add("Body", New Dictionary(Of String, Object)) + dic = New Dictionary(Of String, Object) + dic.Add("Air Density [kg/m3]", Cfg.AirDensity) + dic.Add("Distance Correction", Cfg.WegKorJa) + ergJSON.Content("Body").add("Settings", dic) + + ResList = New List(Of Dictionary(Of String, Object)) + 'Info Ferg.WriteLine("VECTO results") Ferg.WriteLine("VECTO " & VECTOvers) Ferg.WriteLine(Now.ToString) - Ferg.WriteLine(ERGinfo) + Ferg.WriteLine("air density [kg/m3]: " & Cfg.AirDensity) + If Cfg.WegKorJa Then + Ferg.WriteLine("Distance Correction ON") + Else + Ferg.WriteLine("Distance Correction OFF") + End If 'Close file (will open after each job) Ferg.Close() 'Add file to signing list Lic.FileSigning.AddFile(ERGpath) + Lic.FileSigning.AddFile(ERGpath & ".json") ErgEntries = New Dictionary(Of String, cErgEntry) @@ -785,29 +852,6 @@ Class cERG End Function - Public Function ERGinfo() As String - Dim s As New System.Text.StringBuilder - - s.AppendLine("air density [kg/m3]: " & Cfg.AirDensity) - - If Cfg.WegKorJa Then - s.AppendLine("Distance Correction ON") - Else - s.AppendLine("Distance Correction OFF") - End If - - 'If Cfg.FCcorrection Then - ' s.AppendLine("HDV FC Correction ON") - 'Else - ' s.AppendLine("HDV FC Correction OFF") - 'End If - - 'If DEV.Enabled Then s.AppendLine(DEV.DEVinfo) - - Return s.ToString - - End Function - Public ReadOnly Property ErgFile As String Get Return ERGpath @@ -819,11 +863,27 @@ End Class Public Class cErgEntry Public Head As String Public Unit As String - Public ValueString As String - + Public MyVal As Object Public Sub New(ByVal HeadStr As String, ByVal UnitStr As String) Head = HeadStr Unit = UnitStr + MyVal = Nothing End Sub + + Public Property ValueString As Object + Get + If MyVal Is Nothing Then + Return "-" + Else + Return MyVal + End If + End Get + Set(value As Object) + MyVal = value + End Set + End Property + + + End Class diff --git a/VECTO/cVSUM.vb b/VECTO/cVSUM.vb index 52871a4c9b6fb67c9a1329645f18f8826f50511a..ce20c630dc877680787077ab37f71767e3e68780 100644 --- a/VECTO/cVSUM.vb +++ b/VECTO/cVSUM.vb @@ -32,7 +32,7 @@ Public Class cVSUM MsgSrc = "SUM/SetVals" - VehConfig = fAxleConfName(VEH.AxcleConf) + VehConfig = fAxleConfName(VEH.AxleConf) EffIdx = 0 If Not MODdata.Em.EmDefComp.ContainsKey(tMapComp.FC) Then