diff --git a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vecto b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vecto index 58446147ddd3975d9e6346d28f52809015f7b664..72969c4dc9d99efeaae341111c35f94f4eaa1e5f 100644 --- a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vecto +++ b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vecto @@ -1,7 +1,7 @@ { "Header": { "CreatedBy": " ()", - "Date": "15.06.2016 14:59:16", + "Date": "17.06.2016 08:12:45", "AppVersion": "2.2", "FileVersion": 2 }, @@ -18,7 +18,6 @@ "AuxiliaryAssembly": "CLASSIC", "AuxiliaryVersion": "CLASSIC", "AdvancedAuxiliaryFilePath": "", - "Aux": [], "VACC": "Truck.vacc", "EngineOnlyMode": false, "StartStop": { diff --git a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.veng b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.veng index a044e5c860446864e86de98092b3061d683f0bd6..9e3015efdd65dd6ce5e881088f9b073e6506f0e6 100644 --- a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.veng +++ b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.veng @@ -1,7 +1,7 @@ { "Header": { "CreatedBy": " ()", - "Date": "15.06.2016 14:57:57", + "Date": "17.06.2016 07:48:12", "AppVersion": "2.2", "FileVersion": 3 }, diff --git a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vgbx b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vgbx index f2799dbaf0083cf94150284321ebe423bd06351b..19b10889a85b6f2ac68bacc0b96d5578ba427c9c 100644 --- a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vgbx +++ b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vgbx @@ -1,7 +1,7 @@ { "Header": { "CreatedBy": " ()", - "Date": "15.06.2016 14:57:40", + "Date": "17.06.2016 08:12:24", "AppVersion": "2.2", "FileVersion": 5 }, @@ -19,42 +19,42 @@ "Ratio": 6.75, "LossMap": "Indirect Gear.vtlm", "TCactive": false, - "ShiftPolygon": "-", + "ShiftPolygon": "ShiftPolygons.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 3.6, "LossMap": "Indirect Gear.vtlm", "TCactive": false, - "ShiftPolygon": "-", + "ShiftPolygon": "ShiftPolygons.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 2.13, "LossMap": "Indirect Gear.vtlm", "TCactive": false, - "ShiftPolygon": "-", + "ShiftPolygon": "ShiftPolygons.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 1.39, "LossMap": "Indirect Gear.vtlm", "TCactive": false, - "ShiftPolygon": "-", + "ShiftPolygon": "ShiftPolygons.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 1.0, "LossMap": "Direct Gear.vtlm", "TCactive": false, - "ShiftPolygon": "-", + "ShiftPolygon": "ShiftPolygons.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 0.78, "LossMap": "Indirect Gear.vtlm", "TCactive": false, - "ShiftPolygon": "-", + "ShiftPolygon": "ShiftPolygons.vgbs", "FullLoadCurve": "<NOFILE>" } ], diff --git a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vveh b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vveh index 3d86f1fd1268592b9762def9f6e679064e66e17b..f7d8fe842b220a23478297a34810c54ca378c82d 100644 --- a/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vveh +++ b/Generic Vehicles/Engineering Mode/12t Delivery Truck/12t Delivery Truck.vveh @@ -1,7 +1,7 @@ { "Header": { "CreatedBy": " ()", - "Date": "15.06.2016 14:59:16", + "Date": "17.06.2016 07:50:47", "AppVersion": "2.2", "FileVersion": 7 }, @@ -28,7 +28,7 @@ { "Inertia": 6.0, "Wheels": "245/70 R19.5", - "AxleWeightShare": 0.5, + "AxleWeightShare": 0.4, "TwinTyres": false, "RRCISO": 0.008343465, "FzISO": 20800.0 @@ -36,7 +36,7 @@ { "Inertia": 6.0, "Wheels": "245/70 R19.5", - "AxleWeightShare": 0.5, + "AxleWeightShare": 0.6, "TwinTyres": true, "RRCISO": 0.00943769, "FzISO": 20800.0 diff --git a/Tools/DeclarationCycleZip/Program.cs b/Tools/DeclarationCycleZip/Program.cs index f9f3216132ddbb38b7e596cf7309e92c69b30a20..4ffa9847a296f27ef6e648ea45b763aec404f83c 100644 --- a/Tools/DeclarationCycleZip/Program.cs +++ b/Tools/DeclarationCycleZip/Program.cs @@ -65,7 +65,7 @@ namespace DeclarationCycleZip var row = table.NewRow(); row["<s>"] = x.Distance.Value().ToString(CultureInfo.InvariantCulture); row["<v>"] = x.VehicleTargetSpeed.ConvertTo().Kilo.Meter.Per.Hour.Value().ToString(CultureInfo.InvariantCulture); - row["<grad>"] = x.RoadGradientPercent.ToString(CultureInfo.InvariantCulture); + row["<grad>"] = x.RoadGradientPercent.Value().ToString(CultureInfo.InvariantCulture); row["<stop>"] = x.StoppingTime.Value().ToString(CultureInfo.InvariantCulture); table.Rows.Add(row); lastDistance = x.Distance; diff --git a/VECTO/GUI/F_Graph.vb b/VECTO/GUI/F_Graph.vb index f386389d2d8c91506e0b5a84977161ca1886ef3d..c2c7eb2fce07848f0cf4bb5a91242df204e035f9 100644 --- a/VECTO/GUI/F_Graph.vb +++ b/VECTO/GUI/F_Graph.vb @@ -10,6 +10,7 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.Linq Public Class F_Graph Private Filepath As String @@ -52,7 +53,7 @@ Public Class F_Graph Public Sub LoadNewFile(ByVal Path As String) Dim lv0 As ListViewItem - Dim i As Integer + Dim i As Integer = 0 Clear() @@ -60,13 +61,16 @@ Public Class F_Graph LoadFile() - For i = 2 To 3 - lv0 = New ListViewItem - lv0.Text = Channels(i).Name - lv0.SubItems.Add("Left") - lv0.Tag = i - lv0.Checked = True - Me.ListView1.Items.Add(lv0) + For Each channel As cChannel In Channels + If (channel.Name = "v_act [km/h]" OrElse channel.Name = "v_targ [km/h]") Then + lv0 = New ListViewItem + lv0.Text = channel.Name + lv0.SubItems.Add("Left") + lv0.Tag = i + lv0.Checked = True + Me.ListView1.Items.Add(lv0) + End If + i += 1 Next End Sub @@ -110,15 +114,16 @@ Public Class F_Graph file.Close() l0 = Channels(0).Values - TimeList = New List(Of Single) - For i = 0 To l0.Count - 1 - TimeList.Add(CSng(l0(i))) - Next - - l0 = Channels(1).Values - DistList = New List(Of Single) - For i = 0 To l0.Count - 1 - DistList.Add(CSng(l0(i))) + TimeList = Nothing + DistList = Nothing + + For Each channel As cChannel In Channels + If (channel.Name = "time [s]" AndAlso TimeList Is Nothing) Then + TimeList = channel.Values.Select(Function(x) CSng(x)).ToList() + End If + If (channel.Name = "dist [m]" AndAlso DistList Is Nothing) Then + DistList = channel.Values.Select(Function(x) CSng(x)).ToList() + End If Next SetxMax0() @@ -301,17 +306,17 @@ Public Class F_Graph Dim xya(3) As Single Dim i As Int16 - Interv0 = (xMax - xMin)/10 + Interv0 = (xMax - xMin) / 10 Grx = 20 - Do While 10^Grx > Interv0 + Do While 10 ^ Grx > Interv0 Grx = Grx - 1 Loop - xyd(0) = 1*10^Grx - xyd(1) = 2.5*10^Grx - xyd(2) = 5*10^Grx - xyd(3) = 10*10^Grx + xyd(0) = 1 * 10 ^ Grx + xyd(1) = 2.5 * 10 ^ Grx + xyd(2) = 5 * 10 ^ Grx + xyd(3) = 10 * 10 ^ Grx For i = 0 To 3 xya(i) = Math.Abs(Interv0 - xyd(i)) Next @@ -498,13 +503,13 @@ Public Class F_Graph Private Sub BtZoomIn_Click(sender As System.Object, e As System.EventArgs) Handles BtZoomIn.Click Dim d As Single - d = (xMax - xMin)/10 + d = (xMax - xMin) / 10 - xMin += 2*0.5*d - xMax -= 2*(1 - 0.5)*d + xMin += 2 * 0.5 * d + xMax -= 2 * (1 - 0.5) * d If xMin > 1000 Then - xMin = Math.Round(xMin/100, 0)*100 + xMin = Math.Round(xMin / 100, 0) * 100 Else xMin = Math.Round(xMin, 0) End If @@ -516,13 +521,13 @@ Public Class F_Graph Private Sub BtZoomOut_Click(sender As System.Object, e As System.EventArgs) Handles BtZoomOut.Click Dim d As Single - d = (xMax - xMin)/10 + d = (xMax - xMin) / 10 - xMin -= 2*0.5*d - xMax += 2*(1 - 0.5)*d + xMin -= 2 * 0.5 * d + xMax += 2 * (1 - 0.5) * d If xMin > 1000 Then - xMin = Math.Round(xMin/100, 0)*100 + xMin = Math.Round(xMin / 100, 0) * 100 Else xMin = Math.Round(xMin, 0) End If @@ -536,12 +541,12 @@ Public Class F_Graph If xMin <= 0 Then Exit Sub - d = (xMax - xMin)/3 + d = (xMax - xMin) / 3 xMin -= d xMax -= d If xMin > 1000 Then - xMin = Math.Round(xMin/100, 0)*100 + xMin = Math.Round(xMin / 100, 0) * 100 Else xMin = Math.Round(xMin, 0) End If @@ -555,12 +560,12 @@ Public Class F_Graph If xMax >= xMax0 Then Exit Sub - d = (xMax - xMin)/3 + d = (xMax - xMin) / 3 xMin += d xMax += d If xMin > 1000 Then - xMin = Math.Round(xMin/100, 0)*100 + xMin = Math.Round(xMin / 100, 0) * 100 Else xMin = Math.Round(xMin, 0) End If diff --git a/VECTO/GUI/F_VECTO.Designer.vb b/VECTO/GUI/F_VECTO.Designer.vb index 251f0d3e1054a2ec17124172c0251ea3980ec23f..8335327b0d520ff8483f1a035fb7b2f2e7a28488 100644 --- a/VECTO/GUI/F_VECTO.Designer.vb +++ b/VECTO/GUI/F_VECTO.Designer.vb @@ -32,12 +32,13 @@ Partial Class F_VECTO Me.BtDRIrem = New System.Windows.Forms.Button() Me.BtDRIadd = New System.Windows.Forms.Button() Me.GrAux = New System.Windows.Forms.GroupBox() - Me.Label1 = New System.Windows.Forms.Label() - Me.btnBrowseAAUXFile = New System.Windows.Forms.Button() - Me.txtAdvancedAuxiliaryFile = New System.Windows.Forms.TextBox() - Me.picAuxInfo = New System.Windows.Forms.PictureBox() - Me.cboAdvancedAuxiliaries = New System.Windows.Forms.ComboBox() - Me.lbAdvancedAuxiliaries = New System.Windows.Forms.Label() + Me.btnAAUXOpen = New System.Windows.Forms.Button() + Me.Label1 = New System.Windows.Forms.Label() + Me.btnBrowseAAUXFile = New System.Windows.Forms.Button() + Me.txtAdvancedAuxiliaryFile = New System.Windows.Forms.TextBox() + Me.picAuxInfo = New System.Windows.Forms.PictureBox() + Me.cboAdvancedAuxiliaries = New System.Windows.Forms.ComboBox() + Me.lbAdvancedAuxiliaries = New System.Windows.Forms.Label() Me.Label32 = New System.Windows.Forms.Label() Me.LvAux = New System.Windows.Forms.ListView() Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) @@ -121,28 +122,27 @@ Partial Class F_VECTO Me.TbHVCclass = New System.Windows.Forms.TextBox() Me.TbGbxTxt = New System.Windows.Forms.TextBox() Me.TbMass = New System.Windows.Forms.TextBox() - Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) - Me.btnAAUXOpen = New System.Windows.Forms.Button() - Me.TabPgGen.SuspendLayout - Me.GrCycles.SuspendLayout - Me.GrAux.SuspendLayout - CType(Me.picAuxInfo,System.ComponentModel.ISupportInitialize).BeginInit - Me.TabControl1.SuspendLayout - Me.TabPgDriver.SuspendLayout - Me.GrVACC.SuspendLayout - Me.GrLAC.SuspendLayout - Me.PnLookAhead.SuspendLayout - Me.GroupBox1.SuspendLayout - Me.PnEcoRoll.SuspendLayout - Me.GrStartStop.SuspendLayout - Me.PnStartStop.SuspendLayout - Me.StatusStrip1.SuspendLayout - Me.ToolStrip1.SuspendLayout - CType(Me.PictureBox1,System.ComponentModel.ISupportInitialize).BeginInit - Me.CmOpenFile.SuspendLayout - CType(Me.PicVehicle,System.ComponentModel.ISupportInitialize).BeginInit - CType(Me.PicBox,System.ComponentModel.ISupportInitialize).BeginInit - Me.SuspendLayout + Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) + Me.TabPgGen.SuspendLayout() + Me.GrCycles.SuspendLayout() + Me.GrAux.SuspendLayout() + CType(Me.picAuxInfo, System.ComponentModel.ISupportInitialize).BeginInit() + Me.TabControl1.SuspendLayout() + Me.TabPgDriver.SuspendLayout() + Me.GrVACC.SuspendLayout() + Me.GrLAC.SuspendLayout() + Me.PnLookAhead.SuspendLayout() + Me.GroupBox1.SuspendLayout() + Me.PnEcoRoll.SuspendLayout() + Me.GrStartStop.SuspendLayout() + Me.PnStartStop.SuspendLayout() + Me.StatusStrip1.SuspendLayout() + Me.ToolStrip1.SuspendLayout() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.CmOpenFile.SuspendLayout() + CType(Me.PicVehicle, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.PicBox, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() ' 'TabPgGen ' @@ -160,7 +160,7 @@ Partial Class F_VECTO Me.TabPgGen.Location = New System.Drawing.Point(4, 22) Me.TabPgGen.Name = "TabPgGen" Me.TabPgGen.Padding = New System.Windows.Forms.Padding(3) - Me.TabPgGen.Size = New System.Drawing.Size(527, 491) + Me.TabPgGen.Size = New System.Drawing.Size(527, 542) Me.TabPgGen.TabIndex = 0 Me.TabPgGen.Text = "General" Me.TabPgGen.UseVisualStyleBackColor = True @@ -174,9 +174,9 @@ Partial Class F_VECTO Me.GrCycles.Controls.Add(Me.LvCycles) Me.GrCycles.Controls.Add(Me.BtDRIrem) Me.GrCycles.Controls.Add(Me.BtDRIadd) - Me.GrCycles.Location = New System.Drawing.Point(7, 271) + Me.GrCycles.Location = New System.Drawing.Point(6, 322) Me.GrCycles.Name = "GrCycles" - Me.GrCycles.Size = New System.Drawing.Size(515, 208) + Me.GrCycles.Size = New System.Drawing.Size(515, 186) Me.GrCycles.TabIndex = 10 Me.GrCycles.TabStop = False Me.GrCycles.Text = "Cycles" @@ -184,8 +184,8 @@ Partial Class F_VECTO 'Label2 ' Me.Label2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.Label2.AutoSize = true - Me.Label2.Location = New System.Drawing.Point(387, 188) + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(386, 162) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(122, 13) Me.Label2.TabIndex = 3 @@ -199,10 +199,10 @@ Partial Class F_VECTO Me.LvCycles.FullRowSelect = True Me.LvCycles.GridLines = True Me.LvCycles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None - Me.LvCycles.HideSelection = false - Me.LvCycles.LabelEdit = true - Me.LvCycles.Location = New System.Drawing.Point(6, 25) - Me.LvCycles.MultiSelect = false + Me.LvCycles.HideSelection = False + Me.LvCycles.LabelEdit = True + Me.LvCycles.Location = New System.Drawing.Point(6, 25) + Me.LvCycles.MultiSelect = False Me.LvCycles.Name = "LvCycles" Me.LvCycles.Size = New System.Drawing.Size(503, 123) Me.LvCycles.TabIndex = 0 @@ -219,7 +219,7 @@ Partial Class F_VECTO ' Me.BtDRIrem.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) Me.BtDRIrem.Image = Global.VECTO.My.Resources.Resources.minus_circle_icon - Me.BtDRIrem.Location = New System.Drawing.Point(41, 156) + Me.BtDRIrem.Location = New System.Drawing.Point(41, 157) Me.BtDRIrem.Name = "BtDRIrem" Me.BtDRIrem.Size = New System.Drawing.Size(29, 23) Me.BtDRIrem.TabIndex = 2 @@ -229,7 +229,7 @@ Partial Class F_VECTO ' Me.BtDRIadd.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) Me.BtDRIadd.Image = Global.VECTO.My.Resources.Resources.plus_circle_icon - Me.BtDRIadd.Location = New System.Drawing.Point(6, 156) + Me.BtDRIadd.Location = New System.Drawing.Point(6, 157) Me.BtDRIadd.Name = "BtDRIadd" Me.BtDRIadd.Size = New System.Drawing.Size(29, 23) Me.BtDRIadd.TabIndex = 1 @@ -240,83 +240,92 @@ Partial Class F_VECTO Me.GrAux.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.GrAux.Controls.Add(Me.btnAAUXOpen) - Me.GrAux.Controls.Add(Me.Label1) - Me.GrAux.Controls.Add(Me.btnBrowseAAUXFile) - Me.GrAux.Controls.Add(Me.txtAdvancedAuxiliaryFile) - Me.GrAux.Controls.Add(Me.picAuxInfo) - Me.GrAux.Controls.Add(Me.cboAdvancedAuxiliaries) - Me.GrAux.Controls.Add(Me.lbAdvancedAuxiliaries) + Me.GrAux.Controls.Add(Me.btnAAUXOpen) + Me.GrAux.Controls.Add(Me.Label1) + Me.GrAux.Controls.Add(Me.btnBrowseAAUXFile) + Me.GrAux.Controls.Add(Me.txtAdvancedAuxiliaryFile) + Me.GrAux.Controls.Add(Me.picAuxInfo) + Me.GrAux.Controls.Add(Me.cboAdvancedAuxiliaries) + Me.GrAux.Controls.Add(Me.lbAdvancedAuxiliaries) Me.GrAux.Controls.Add(Me.Label32) Me.GrAux.Controls.Add(Me.LvAux) Me.GrAux.Controls.Add(Me.ButAuxRem) Me.GrAux.Controls.Add(Me.ButAuxAdd) Me.GrAux.Location = New System.Drawing.Point(6, 87) Me.GrAux.Name = "GrAux" - Me.GrAux.Size = New System.Drawing.Size(515, 260) + Me.GrAux.Size = New System.Drawing.Size(515, 229) Me.GrAux.TabIndex = 9 Me.GrAux.TabStop = False Me.GrAux.Text = "Auxiliaries" ' - 'Label1 - ' - Me.Label1.AutoSize = true - Me.Label1.Location = New System.Drawing.Point(7, 52) - Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(96, 13) - Me.Label1.TabIndex = 40 - Me.Label1.Text = "Advanced Aux File" - ' - 'btnBrowseAAUXFile - ' - Me.btnBrowseAAUXFile.Location = New System.Drawing.Point(447, 45) - Me.btnBrowseAAUXFile.Name = "btnBrowseAAUXFile" - Me.btnBrowseAAUXFile.Size = New System.Drawing.Size(36, 23) - Me.btnBrowseAAUXFile.TabIndex = 39 - Me.btnBrowseAAUXFile.Text = ". . ." - Me.ToolTip1.SetToolTip(Me.btnBrowseAAUXFile, "Configure/Browser Advanced Auxiliary Files") - Me.btnBrowseAAUXFile.UseVisualStyleBackColor = true - ' - 'txtAdvancedAuxiliaryFile - ' - Me.txtAdvancedAuxiliaryFile.Location = New System.Drawing.Point(119, 47) - Me.txtAdvancedAuxiliaryFile.Name = "txtAdvancedAuxiliaryFile" - Me.txtAdvancedAuxiliaryFile.Size = New System.Drawing.Size(321, 20) - Me.txtAdvancedAuxiliaryFile.TabIndex = 38 - ' - 'picAuxInfo - ' - Me.picAuxInfo.Image = Global.VECTO.My.Resources.Resources.Information_icon - Me.picAuxInfo.InitialImage = Global.VECTO.My.Resources.Resources.Information_icon - Me.picAuxInfo.Location = New System.Drawing.Point(451, 19) - Me.picAuxInfo.Name = "picAuxInfo" - Me.picAuxInfo.Size = New System.Drawing.Size(16, 16) - Me.picAuxInfo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize - Me.picAuxInfo.TabIndex = 37 - Me.picAuxInfo.TabStop = false - ' - 'cboAdvancedAuxiliaries - ' - Me.cboAdvancedAuxiliaries.FormattingEnabled = true - Me.cboAdvancedAuxiliaries.Location = New System.Drawing.Point(119, 18) - Me.cboAdvancedAuxiliaries.Name = "cboAdvancedAuxiliaries" - Me.cboAdvancedAuxiliaries.Size = New System.Drawing.Size(321, 21) - Me.cboAdvancedAuxiliaries.TabIndex = 36 - ' - 'lbAdvancedAuxiliaries - ' - Me.lbAdvancedAuxiliaries.AutoSize = true - Me.lbAdvancedAuxiliaries.Location = New System.Drawing.Point(7, 21) - Me.lbAdvancedAuxiliaries.Name = "lbAdvancedAuxiliaries" - Me.lbAdvancedAuxiliaries.Size = New System.Drawing.Size(72, 13) - Me.lbAdvancedAuxiliaries.TabIndex = 35 - Me.lbAdvancedAuxiliaries.Text = "Auxiliary Type" - ' + 'btnAAUXOpen + ' + Me.btnAAUXOpen.Image = Global.VECTO.My.Resources.Resources.application_export_icon_small + Me.btnAAUXOpen.Location = New System.Drawing.Point(486, 45) + Me.btnAAUXOpen.Name = "btnAAUXOpen" + Me.btnAAUXOpen.Size = New System.Drawing.Size(26, 23) + Me.btnAAUXOpen.TabIndex = 41 + Me.btnAAUXOpen.UseVisualStyleBackColor = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(7, 52) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(96, 13) + Me.Label1.TabIndex = 40 + Me.Label1.Text = "Advanced Aux File" + ' + 'btnBrowseAAUXFile + ' + Me.btnBrowseAAUXFile.Location = New System.Drawing.Point(447, 45) + Me.btnBrowseAAUXFile.Name = "btnBrowseAAUXFile" + Me.btnBrowseAAUXFile.Size = New System.Drawing.Size(36, 23) + Me.btnBrowseAAUXFile.TabIndex = 39 + Me.btnBrowseAAUXFile.Text = ". . ." + Me.ToolTip1.SetToolTip(Me.btnBrowseAAUXFile, "Configure/Browser Advanced Auxiliary Files") + Me.btnBrowseAAUXFile.UseVisualStyleBackColor = True + ' + 'txtAdvancedAuxiliaryFile + ' + Me.txtAdvancedAuxiliaryFile.Location = New System.Drawing.Point(119, 47) + Me.txtAdvancedAuxiliaryFile.Name = "txtAdvancedAuxiliaryFile" + Me.txtAdvancedAuxiliaryFile.Size = New System.Drawing.Size(321, 20) + Me.txtAdvancedAuxiliaryFile.TabIndex = 38 + ' + 'picAuxInfo + ' + Me.picAuxInfo.Image = Global.VECTO.My.Resources.Resources.Information_icon + Me.picAuxInfo.InitialImage = Global.VECTO.My.Resources.Resources.Information_icon + Me.picAuxInfo.Location = New System.Drawing.Point(451, 19) + Me.picAuxInfo.Name = "picAuxInfo" + Me.picAuxInfo.Size = New System.Drawing.Size(16, 16) + Me.picAuxInfo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize + Me.picAuxInfo.TabIndex = 37 + Me.picAuxInfo.TabStop = False + ' + 'cboAdvancedAuxiliaries + ' + Me.cboAdvancedAuxiliaries.FormattingEnabled = True + Me.cboAdvancedAuxiliaries.Location = New System.Drawing.Point(119, 18) + Me.cboAdvancedAuxiliaries.Name = "cboAdvancedAuxiliaries" + Me.cboAdvancedAuxiliaries.Size = New System.Drawing.Size(321, 21) + Me.cboAdvancedAuxiliaries.TabIndex = 36 + ' + 'lbAdvancedAuxiliaries + ' + Me.lbAdvancedAuxiliaries.AutoSize = True + Me.lbAdvancedAuxiliaries.Location = New System.Drawing.Point(7, 21) + Me.lbAdvancedAuxiliaries.Name = "lbAdvancedAuxiliaries" + Me.lbAdvancedAuxiliaries.Size = New System.Drawing.Size(72, 13) + Me.lbAdvancedAuxiliaries.TabIndex = 35 + Me.lbAdvancedAuxiliaries.Text = "Auxiliary Type" + ' 'Label32 ' Me.Label32.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.Label32.AutoSize = true - Me.Label32.Location = New System.Drawing.Point(369, 200) + Me.Label32.AutoSize = True + Me.Label32.Location = New System.Drawing.Point(369, 205) Me.Label32.Name = "Label32" Me.Label32.Size = New System.Drawing.Size(139, 13) Me.Label32.TabIndex = 3 @@ -327,11 +336,11 @@ Partial Class F_VECTO Me.LvAux.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.LvAux.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader4, Me.ColumnHeader5, Me.ColumnHeader6}) - Me.LvAux.FullRowSelect = true - Me.LvAux.GridLines = true - Me.LvAux.HideSelection = false - Me.LvAux.Location = New System.Drawing.Point(6, 72) - Me.LvAux.MultiSelect = false + Me.LvAux.FullRowSelect = True + Me.LvAux.GridLines = True + Me.LvAux.HideSelection = False + Me.LvAux.Location = New System.Drawing.Point(6, 72) + Me.LvAux.MultiSelect = False Me.LvAux.Name = "LvAux" Me.LvAux.Size = New System.Drawing.Size(503, 117) Me.LvAux.TabIndex = 0 @@ -357,7 +366,7 @@ Partial Class F_VECTO 'ButAuxRem ' Me.ButAuxRem.Image = Global.VECTO.My.Resources.Resources.minus_circle_icon - Me.ButAuxRem.Location = New System.Drawing.Point(42, 195) + Me.ButAuxRem.Location = New System.Drawing.Point(42, 195) Me.ButAuxRem.Name = "ButAuxRem" Me.ButAuxRem.Size = New System.Drawing.Size(29, 23) Me.ButAuxRem.TabIndex = 2 @@ -366,7 +375,7 @@ Partial Class F_VECTO 'ButAuxAdd ' Me.ButAuxAdd.Image = Global.VECTO.My.Resources.Resources.plus_circle_icon - Me.ButAuxAdd.Location = New System.Drawing.Point(7, 195) + Me.ButAuxAdd.Location = New System.Drawing.Point(7, 195) Me.ButAuxAdd.Name = "ButAuxAdd" Me.ButAuxAdd.Size = New System.Drawing.Size(29, 23) Me.ButAuxAdd.TabIndex = 1 @@ -471,7 +480,7 @@ Partial Class F_VECTO Me.TabControl1.Location = New System.Drawing.Point(1, 107) Me.TabControl1.Name = "TabControl1" Me.TabControl1.SelectedIndex = 0 - Me.TabControl1.Size = New System.Drawing.Size(535, 568) + Me.TabControl1.Size = New System.Drawing.Size(535, 568) Me.TabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed Me.TabControl1.TabIndex = 0 ' @@ -484,7 +493,7 @@ Partial Class F_VECTO Me.TabPgDriver.Location = New System.Drawing.Point(4, 22) Me.TabPgDriver.Name = "TabPgDriver" Me.TabPgDriver.Padding = New System.Windows.Forms.Padding(3) - Me.TabPgDriver.Size = New System.Drawing.Size(527, 542) + Me.TabPgDriver.Size = New System.Drawing.Size(527, 542) Me.TabPgDriver.TabIndex = 7 Me.TabPgDriver.Text = "Driver Assist" Me.TabPgDriver.UseVisualStyleBackColor = True @@ -870,7 +879,7 @@ Partial Class F_VECTO 'StatusStrip1 ' Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabelGEN}) - Me.StatusStrip1.Location = New System.Drawing.Point(0, 678) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 678) Me.StatusStrip1.Name = "StatusStrip1" Me.StatusStrip1.Size = New System.Drawing.Size(944, 22) Me.StatusStrip1.SizingGrip = False @@ -886,7 +895,7 @@ Partial Class F_VECTO 'ButOK ' Me.ButOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.ButOK.Location = New System.Drawing.Point(779, 652) + Me.ButOK.Location = New System.Drawing.Point(779, 652) Me.ButOK.Name = "ButOK" Me.ButOK.Size = New System.Drawing.Size(75, 23) Me.ButOK.TabIndex = 0 @@ -897,7 +906,7 @@ Partial Class F_VECTO ' Me.ButCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.ButCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.ButCancel.Location = New System.Drawing.Point(860, 652) + Me.ButCancel.Location = New System.Drawing.Point(860, 652) Me.ButCancel.Name = "ButCancel" Me.ButCancel.Size = New System.Drawing.Size(75, 23) Me.ButCancel.TabIndex = 1 @@ -1007,7 +1016,7 @@ Partial Class F_VECTO ' Me.CmOpenFile.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OpenWithToolStripMenuItem, Me.ShowInFolderToolStripMenuItem}) Me.CmOpenFile.Name = "CmOpenFile" - Me.CmOpenFile.Size = New System.Drawing.Size(153, 70) + Me.CmOpenFile.Size = New System.Drawing.Size(153, 48) ' 'OpenWithToolStripMenuItem ' @@ -1088,22 +1097,13 @@ Partial Class F_VECTO Me.TbMass.Size = New System.Drawing.Size(50, 20) Me.TbMass.TabIndex = 3 ' - 'btnAAUXOpen - ' - Me.btnAAUXOpen.Image = Global.VECTO.My.Resources.Resources.application_export_icon_small - Me.btnAAUXOpen.Location = New System.Drawing.Point(486, 45) - Me.btnAAUXOpen.Name = "btnAAUXOpen" - Me.btnAAUXOpen.Size = New System.Drawing.Size(26, 23) - Me.btnAAUXOpen.TabIndex = 41 - Me.btnAAUXOpen.UseVisualStyleBackColor = true - ' 'F_VECTO ' Me.AcceptButton = Me.ButOK Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ButCancel - Me.ClientSize = New System.Drawing.Size(944, 700) + Me.ClientSize = New System.Drawing.Size(944, 700) Me.Controls.Add(Me.TbHVCclass) Me.Controls.Add(Me.TbMass) Me.Controls.Add(Me.TbAxleConf) @@ -1125,39 +1125,39 @@ Partial Class F_VECTO Me.Name = "F_VECTO" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "Job Editor" - Me.TabPgGen.ResumeLayout(false) - Me.TabPgGen.PerformLayout - Me.GrCycles.ResumeLayout(false) - Me.GrCycles.PerformLayout - Me.GrAux.ResumeLayout(false) - Me.GrAux.PerformLayout - CType(Me.picAuxInfo,System.ComponentModel.ISupportInitialize).EndInit - Me.TabControl1.ResumeLayout(false) - Me.TabPgDriver.ResumeLayout(false) - Me.GrVACC.ResumeLayout(false) - Me.GrVACC.PerformLayout - Me.GrLAC.ResumeLayout(false) - Me.GrLAC.PerformLayout - Me.PnLookAhead.ResumeLayout(false) - Me.PnLookAhead.PerformLayout - Me.GroupBox1.ResumeLayout(false) - Me.GroupBox1.PerformLayout - Me.PnEcoRoll.ResumeLayout(false) - Me.PnEcoRoll.PerformLayout - Me.GrStartStop.ResumeLayout(false) - Me.GrStartStop.PerformLayout - Me.PnStartStop.ResumeLayout(false) - Me.PnStartStop.PerformLayout - Me.StatusStrip1.ResumeLayout(false) - Me.StatusStrip1.PerformLayout - Me.ToolStrip1.ResumeLayout(false) - Me.ToolStrip1.PerformLayout - CType(Me.PictureBox1,System.ComponentModel.ISupportInitialize).EndInit - Me.CmOpenFile.ResumeLayout(false) - CType(Me.PicVehicle,System.ComponentModel.ISupportInitialize).EndInit - CType(Me.PicBox,System.ComponentModel.ISupportInitialize).EndInit - Me.ResumeLayout(false) - Me.PerformLayout + Me.TabPgGen.ResumeLayout(False) + Me.TabPgGen.PerformLayout() + Me.GrCycles.ResumeLayout(False) + Me.GrCycles.PerformLayout() + Me.GrAux.ResumeLayout(False) + Me.GrAux.PerformLayout() + CType(Me.picAuxInfo, System.ComponentModel.ISupportInitialize).EndInit() + Me.TabControl1.ResumeLayout(False) + Me.TabPgDriver.ResumeLayout(False) + Me.GrVACC.ResumeLayout(False) + Me.GrVACC.PerformLayout() + Me.GrLAC.ResumeLayout(False) + Me.GrLAC.PerformLayout() + Me.PnLookAhead.ResumeLayout(False) + Me.PnLookAhead.PerformLayout() + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + Me.PnEcoRoll.ResumeLayout(False) + Me.PnEcoRoll.PerformLayout() + Me.GrStartStop.ResumeLayout(False) + Me.GrStartStop.PerformLayout() + Me.PnStartStop.ResumeLayout(False) + Me.PnStartStop.PerformLayout() + Me.StatusStrip1.ResumeLayout(False) + Me.StatusStrip1.PerformLayout() + Me.ToolStrip1.ResumeLayout(False) + Me.ToolStrip1.PerformLayout() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() + Me.CmOpenFile.ResumeLayout(False) + CType(Me.PicVehicle, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.PicBox, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents TabPgGen As System.Windows.Forms.TabPage diff --git a/VECTO/GUI/F_VECTO.resx b/VECTO/GUI/F_VECTO.resx index dfedf03c9b45e956dddfa245a9b36cea479dd337..e86e2319862af9904048f1c4664865391ed468f6 100644 --- a/VECTO/GUI/F_VECTO.resx +++ b/VECTO/GUI/F_VECTO.resx @@ -129,9 +129,6 @@ <metadata name="CmOpenFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>350, 15</value> </metadata> - <metadata name="ToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>468, 15</value> - </metadata> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>49</value> </metadata> diff --git a/VECTO/Input Files/cVECTO.vb b/VECTO/Input Files/cVECTO.vb index dd22112b39d668404960c5c4de26b663a6b8d822..54ec57cdc8e5a89404647ebcbbf04792a4a35229 100644 --- a/VECTO/Input Files/cVECTO.vb +++ b/VECTO/Input Files/cVECTO.vb @@ -12,868 +12,848 @@ Imports System.Collections.Generic Public Class cVECTO + Private Const FormatVersion As Short = 2 + Private FileVersion As Short - Private Const FormatVersion As Short = 2 - Private FileVersion As Short + 'AA-TB + 'STORES THE Type and version of the chosen or default Auxiliary Type ( Classic/Original or other ) + Public AuxiliaryAssembly As String + Public AuxiliaryVersion As String + Public AdvancedAuxiliaryFilePath As String - 'AA-TB - 'STORES THE Type and version of the chosen or default Auxiliary Type ( Classic/Original or other ) - public AuxiliaryAssembly As String - public AuxiliaryVersion As String - Public AdvancedAuxiliaryFilePath As String - - Private sFilePath As String + Private sFilePath As String - Private MyPath As String + Private MyPath As String - 'Input parameters - Private stPathVEH As cSubPath - Private stPathENG As cSubPath - Private stPathGBX As cSubPath + 'Input parameters + Private stPathVEH As cSubPath + Private stPathENG As cSubPath + Private stPathGBX As cSubPath - Private boStartStop As Boolean - Private siStStV As Single - Private siStStT As Single - Public StStDelay As Integer + Private boStartStop As Boolean + Private siStStV As Single + Private siStStT As Single + Public StStDelay As Integer - Private stDesMaxFile As cSubPath - Private laDesV As List(Of Single) - Private laDesMax As List(Of Single) - Private laDesMin As List(Of Single) - Private DesMaxDim As Integer + Private stDesMaxFile As cSubPath + Private laDesV As List(Of Single) + Private laDesMax As List(Of Single) + Private laDesMin As List(Of Single) + Private DesMaxDim As Integer - Public AuxPaths As Dictionary(Of String, cAuxEntry) - Public AuxRefs As Dictionary(Of String, cAux) 'Alle Nebenverbraucher die in der Veh-Datei UND im Zyklus definiert sind - Public AuxDef As Boolean 'True wenn ein oder mehrere Nebenverbraucher definiert sind - Public EStechs As List(Of String) + Public AuxPaths As Dictionary(Of String, cAuxEntry) + Public AuxRefs As Dictionary(Of String, cAux) _ + 'Alle Nebenverbraucher die in der Veh-Datei UND im Zyklus definiert sind + Public AuxDef As Boolean 'True wenn ein oder mehrere Nebenverbraucher definiert sind + Public EStechs As List(Of String) - Public CycleFiles As List(Of cSubPath) + Public CycleFiles As List(Of cSubPath) - Public EngOnly As Boolean + Public EngOnly As Boolean - Public a_lookahead As Single - Public vMin As Single - Public vMinLA As Single - Public LookAheadOn As Boolean - Public OverSpeedOn As Boolean - Public OverSpeed As Single - Public UnderSpeed As Single - Public EcoRollOn As Boolean + Public a_lookahead As Single + Public vMin As Single + Public vMinLA As Single + Public LookAheadOn As Boolean + Public OverSpeedOn As Boolean + Public OverSpeed As Single + Public UnderSpeed As Single + Public EcoRollOn As Boolean - Private MyFileList As List(Of String) + Private MyFileList As List(Of String) - Public SavedInDeclMode As Boolean + Public SavedInDeclMode As Boolean - Public Class cAuxEntry - Public Type As String - Public Path As cSubPath - Public TechStr As String = "" + Public Class cAuxEntry + Public Type As String + Public Path As cSubPath + Public TechStr As String = "" - Public Sub New() - Path = New cSubPath - End Sub + Public Sub New() + Path = New cSubPath + End Sub + End Class - End Class + Public Function CreateFileList() As Boolean + Dim Aux0 As cAuxEntry + Dim sb As cSubPath + Dim str As String - Public Function CreateFileList() As Boolean - Dim Aux0 As cAuxEntry - Dim sb As cSubPath - Dim str As String + MyFileList = New List(Of String) - MyFileList = New List(Of String) + '.vecto + MyFileList.Add(Me.sFilePath) - '.vecto - MyFileList.Add(Me.sFilePath) + 'Veh + If Not Me.EngOnly Then + MyFileList.Add(Me.PathVEH) - 'Veh - If Not Me.EngOnly Then - MyFileList.Add(Me.PathVEH) + If Not VEH.CreateFileList Then Return False + For Each str In VEH.FileList + MyFileList.Add(str) + Next + End If - If Not VEH.CreateFileList Then Return False - For Each str In VEH.FileList - MyFileList.Add(str) - Next - End If + 'Eng + MyFileList.Add(Me.PathENG) - 'Eng - MyFileList.Add(Me.PathENG) + If Not ENG.CreateFileList Then Return False + For Each str In ENG.FileList + MyFileList.Add(str) + Next - If Not ENG.CreateFileList Then Return False - For Each str In ENG.FileList - MyFileList.Add(str) - Next + If Not Me.EngOnly Then - If Not Me.EngOnly Then + 'Gbx + MyFileList.Add(Me.PathGBX) - 'Gbx - MyFileList.Add(Me.PathGBX) + If Not GBX.CreateFileList Then Return False + For Each str In GBX.FileList + MyFileList.Add(str) + Next - If Not GBX.CreateFileList Then Return False - For Each str In GBX.FileList - MyFileList.Add(str) - Next + 'Aux + If AuxDef And Not Cfg.DeclMode Then + For Each Aux0 In Me.AuxPaths.Values + MyFileList.Add(Aux0.Path.FullPath) + Next + End If - 'Aux - If AuxDef And Not Cfg.DeclMode Then - For Each Aux0 In Me.AuxPaths.Values - MyFileList.Add(Aux0.Path.FullPath) - Next - End If + '.vacc + MyFileList.Add(Me.stDesMaxFile.FullPath) - '.vacc - MyFileList.Add(Me.stDesMaxFile.FullPath) + End If - End If + 'Cycles + For Each sb In Me.CycleFiles + MyFileList.Add(sb.FullPath) + Next - 'Cycles - For Each sb In Me.CycleFiles - MyFileList.Add(sb.FullPath) - Next + Return True + End Function - Return True + Public Sub New() - End Function + MyPath = "" + sFilePath = "" - Public Sub New() + stPathVEH = New cSubPath + stPathENG = New cSubPath + stPathGBX = New cSubPath - MyPath = "" - sFilePath = "" + stDesMaxFile = New cSubPath - stPathVEH = New cSubPath - stPathENG = New cSubPath - stPathGBX = New cSubPath + laDesV = New List(Of Single) + laDesMax = New List(Of Single) + laDesMin = New List(Of Single) - stDesMaxFile = New cSubPath + AuxPaths = New Dictionary(Of String, cAuxEntry) + AuxRefs = New Dictionary(Of String, cAux) + AuxDef = False + EStechs = New List(Of String) - laDesV = New List(Of Single) - laDesMax = New List(Of Single) - laDesMin = New List(Of Single) + CycleFiles = New List(Of cSubPath) + End Sub - AuxPaths = New Dictionary(Of String, cAuxEntry) - AuxRefs = New Dictionary(Of String, cAux) - AuxDef = False - EStechs = New List(Of String) - - CycleFiles = New List(Of cSubPath) - - End Sub - - Public Function SaveFile() As Boolean - Dim AuxEntryKV As KeyValuePair(Of String, cAuxEntry) - 'Dim s As String - Dim sb As cSubPath + Public Function SaveFile() As Boolean + Dim AuxEntryKV As KeyValuePair(Of String, cAuxEntry) + 'Dim s As String + Dim sb As cSubPath 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) - - '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 - dic0 = New Dictionary(Of String, Object) - - dic0.Add("SavedInDeclMode", Cfg.DeclMode) - SavedInDeclMode = Cfg.DeclMode - - 'Main Files - dic0.Add("VehicleFile", stPathVEH.PathOrDummy) - dic0.Add("EngineFile", stPathENG.PathOrDummy) - dic0.Add("GearboxFile", stPathGBX.PathOrDummy) - - 'Cycles - If CycleFiles.Count > 0 Then - ls = New List(Of Object) - For Each sb In CycleFiles - ls.Add(sb.PathOrDummy) - Next - dic0.Add("Cycles", ls) - End If - - 'AA-TB - 'ADVANCED AUXILIARIES - dic0.Add("AuxiliaryAssembly",AuxiliaryAssembly) - dic0.Add("AuxiliaryVersion",AuxiliaryVersion) - dic0.Add("AdvancedAuxiliaryFilePath",AdvancedAuxiliaryFilePath) - - 'Aux - If AuxPaths.Count > 0 Then - ls = New List(Of Object) - For Each AuxEntryKV In AuxPaths - dic = New Dictionary(Of String, Object) - dic.Add("ID", Trim(UCase(AuxEntryKV.Key))) - dic.Add("Type", AuxEntryKV.Value.Type) - dic.Add("Path", AuxEntryKV.Value.Path.PathOrDummy) - dic.Add("Technology", AuxEntryKV.Value.TechStr) - - If AuxEntryKV.Key = sKey.AUX.ElecSys Then - dic.Add("TechList", EStechs) - End If - - ls.Add(dic) - Next - dic0.Add("Aux", ls) - End If - - 'VACC - dic0.Add("VACC", stDesMaxFile.PathOrDummy) - - 'EngineOnlyMode - dic0.Add("EngineOnlyMode", EngOnly) - - 'Start Stop - dic = New Dictionary(Of String, Object) - dic.Add("Enabled", boStartStop) - dic.Add("MaxSpeed", siStStV) - dic.Add("MinTime", siStStT) - dic.Add("Delay", StStDelay) - dic0.Add("StartStop", dic) - - 'LAC - dic = New Dictionary(Of String, Object) - dic.Add("Enabled", LookAheadOn) - dic.Add("Dec", a_lookahead) - dic.Add("MinSpeed", vMinLA) - dic0.Add("LAC", dic) - - 'Overspeed / EcoRoll - dic = New Dictionary(Of String, Object) - If EcoRollOn Then - dic.Add("Mode", "EcoRoll") - ElseIf OverSpeedOn Then - dic.Add("Mode", "OverSpeed") - Else - dic.Add("Mode", "Off") - End If - dic.Add("MinSpeed", vMin) - dic.Add("OverSpeed", OverSpeed) - dic.Add("UnderSpeed", UnderSpeed) - dic0.Add("OverSpeedEcoRoll", dic) - - ' - - - JSON.Content.Add("Body", dic0) - - Return JSON.WriteFile(sFilePath) - - End Function - - Public Function ReadFile() As Boolean - Dim AuxEntry As cAuxEntry - Dim AuxID As String - Dim MsgSrc As String - Dim SubPath As cSubPath + Dim ls As List(Of Object) + Dim dic As Dictionary(Of String, Object) + Dim dic0 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 + dic0 = New Dictionary(Of String, Object) + + dic0.Add("SavedInDeclMode", Cfg.DeclMode) + SavedInDeclMode = Cfg.DeclMode + + 'Main Files + dic0.Add("VehicleFile", stPathVEH.PathOrDummy) + dic0.Add("EngineFile", stPathENG.PathOrDummy) + dic0.Add("GearboxFile", stPathGBX.PathOrDummy) + + 'Cycles + If CycleFiles.Count > 0 Then + ls = New List(Of Object) + For Each sb In CycleFiles + ls.Add(sb.PathOrDummy) + Next + dic0.Add("Cycles", ls) + End If + + 'AA-TB + 'ADVANCED AUXILIARIES + dic0.Add("AuxiliaryAssembly", AuxiliaryAssembly) + dic0.Add("AuxiliaryVersion", AuxiliaryVersion) + dic0.Add("AdvancedAuxiliaryFilePath", AdvancedAuxiliaryFilePath) + + 'Aux + If AuxPaths.Count > 0 Then + ls = New List(Of Object) + For Each AuxEntryKV In AuxPaths + dic = New Dictionary(Of String, Object) + dic.Add("ID", Trim(UCase(AuxEntryKV.Key))) + dic.Add("Type", AuxEntryKV.Value.Type) + dic.Add("Path", AuxEntryKV.Value.Path.PathOrDummy) + dic.Add("Technology", AuxEntryKV.Value.TechStr) + + If AuxEntryKV.Key = sKey.AUX.ElecSys Then + dic.Add("TechList", EStechs) + End If + + ls.Add(dic) + Next + dic0.Add("Aux", ls) + End If + + 'VACC + dic0.Add("VACC", stDesMaxFile.PathOrDummy) + + 'EngineOnlyMode + dic0.Add("EngineOnlyMode", EngOnly) + + 'Start Stop + dic = New Dictionary(Of String, Object) + dic.Add("Enabled", boStartStop) + dic.Add("MaxSpeed", siStStV) + dic.Add("MinTime", siStStT) + dic.Add("Delay", StStDelay) + dic0.Add("StartStop", dic) + + 'LAC + dic = New Dictionary(Of String, Object) + dic.Add("Enabled", LookAheadOn) + dic.Add("Dec", a_lookahead) + dic.Add("MinSpeed", vMinLA) + dic0.Add("LAC", dic) + + 'Overspeed / EcoRoll + dic = New Dictionary(Of String, Object) + If EcoRollOn Then + dic.Add("Mode", "EcoRoll") + ElseIf OverSpeedOn Then + dic.Add("Mode", "OverSpeed") + Else + dic.Add("Mode", "Off") + End If + dic.Add("MinSpeed", vMin) + dic.Add("OverSpeed", OverSpeed) + dic.Add("UnderSpeed", UnderSpeed) + dic0.Add("OverSpeedEcoRoll", dic) + + ' + + + JSON.Content.Add("Body", dic0) + + Return JSON.WriteFile(sFilePath) + End Function + + Public Function ReadFile() As Boolean + Dim AuxEntry As cAuxEntry + Dim AuxID As String + Dim MsgSrc As String + Dim SubPath As cSubPath Dim JSON As New JSON - Dim str As String - Dim dic As Object - - - - - - MsgSrc = "Main/ReadInp/GEN" - - SetDefault() - - If Not JSON.ReadFile(sFilePath) Then Return False - - Try - - FileVersion = JSON.Content("Header")("FileVersion") - - If FileVersion > 1 Then - SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If - - If Not JSON.Content("Body")("VehicleFile") Is Nothing Then stPathVEH.Init(MyPath, JSON.Content("Body")("VehicleFile")) + Dim str As String + Dim dic As Object - stPathENG.Init(MyPath, JSON.Content("Body")("EngineFile")) - If Not JSON.Content("Body")("GearboxFile") Is Nothing Then stPathGBX.Init(MyPath, JSON.Content("Body")("GearboxFile")) + MsgSrc = "Main/ReadInp/GEN" - 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 + SetDefault() - 'AA-TB - 'ADVANCED AUXILIARIES - If Not JSON.Content("Body")("AuxiliaryAssembly") is Nothing AndAlso - NOT JSON.Content("Body")("AuxiliaryVersion") is nothing + If Not JSON.ReadFile(sFilePath) Then Return False - AuxiliaryAssembly = JSON.Content("Body")("AuxiliaryAssembly").ToString() - AuxiliaryVersion = JSON.Content("Body")("AuxiliaryVersion").ToString() + Try - End If - If NOT JSON.Content("Body")("AdvancedAuxiliaryFilePath") is nothing then - AdvancedAuxiliaryFilePath = JSON.Content("Body")("AdvancedAuxiliaryFilePath").ToString() - end if + FileVersion = JSON.Content("Header")("FileVersion") + If FileVersion > 1 Then + SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") + Else + SavedInDeclMode = Cfg.DeclMode + End If + If Not JSON.Content("Body")("VehicleFile") Is Nothing Then _ + stPathVEH.Init(MyPath, JSON.Content("Body")("VehicleFile")) - If Not JSON.Content("Body")("Aux") Is Nothing Then - For Each dic In JSON.Content("Body")("Aux") + stPathENG.Init(MyPath, JSON.Content("Body")("EngineFile")) - AuxID = UCase(Trim(dic("ID").ToString)) + If Not JSON.Content("Body")("GearboxFile") Is Nothing Then _ + stPathGBX.Init(MyPath, JSON.Content("Body")("GearboxFile")) - If AuxPaths.ContainsKey(AuxID) Then - WorkerMsg(tMsgID.Err, "Multiple definitions of the same auxiliary type (" & AuxID & ")!", MsgSrc) - Return False - End If + 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 - AuxEntry = New cAuxEntry + 'AA-TB + 'ADVANCED AUXILIARIES + If Not JSON.Content("Body")("AuxiliaryAssembly") Is Nothing AndAlso + Not JSON.Content("Body")("AuxiliaryVersion") Is Nothing Then - AuxEntry.Type = dic("Type") - AuxEntry.Path.Init(MyPath, dic("Path")) + AuxiliaryAssembly = JSON.Content("Body")("AuxiliaryAssembly").ToString() + AuxiliaryVersion = JSON.Content("Body")("AuxiliaryVersion").ToString() - If Not dic("Technology") Is Nothing Then AuxEntry.TechStr = dic("Technology") + End If + If Not JSON.Content("Body")("AdvancedAuxiliaryFilePath") Is Nothing Then + AdvancedAuxiliaryFilePath = JSON.Content("Body")("AdvancedAuxiliaryFilePath").ToString() + End If - AuxPaths.Add(AuxID, AuxEntry) - AuxDef = True + If Not JSON.Content("Body")("Aux") Is Nothing Then + For Each dic In JSON.Content("Body")("Aux") - If AuxID = sKey.AUX.ElecSys Then - If Not dic("TechList") Is Nothing Then - For Each str In dic("TechList") - EStechs.Add(str) - Next - End If - End If + AuxID = UCase(Trim(dic("ID").ToString)) - Next - End If + If AuxPaths.ContainsKey(AuxID) Then + WorkerMsg(tMsgID.Err, "Multiple definitions of the same auxiliary type (" & AuxID & ")!", MsgSrc) + Return False + End If - If Not JSON.Content("Body")("VACC") Is Nothing Then stDesMaxFile.Init(MyPath, JSON.Content("Body")("VACC")) + AuxEntry = New cAuxEntry - EngOnly = JSON.Content("Body")("EngineOnlyMode") + AuxEntry.Type = dic("Type") + AuxEntry.Path.Init(MyPath, dic("Path")) - If Not JSON.Content("Body")("StartStop") Is Nothing Then - dic = JSON.Content("Body")("StartStop") - boStartStop = dic("Enabled") - siStStV = dic("MaxSpeed") - siStStT = dic("MinTime") - StStDelay = dic("Delay") - Else - boStartStop = False - End If + If Not dic("Technology") Is Nothing Then AuxEntry.TechStr = dic("Technology") - If Not JSON.Content("Body")("LAC") Is Nothing Then - dic = JSON.Content("Body")("LAC") - LookAheadOn = dic("Enabled") - a_lookahead = dic("Dec") - vMinLA = dic("MinSpeed") - Else - LookAheadOn = False - End If + AuxPaths.Add(AuxID, AuxEntry) - If Not JSON.Content("Body")("OverSpeedEcoRoll") Is Nothing Then + AuxDef = True - dic = JSON.Content("Body")("OverSpeedEcoRoll") + If AuxID = sKey.AUX.ElecSys Then + If Not dic("TechList") Is Nothing Then + For Each str In dic("TechList") + EStechs.Add(str) + Next + End If + End If - Select Case UCase(dic("Mode").ToString).Trim - Case "ECOROLL" - OverSpeedOn = False - EcoRollOn = True + Next + End If - Case "OVERSPEED" - OverSpeedOn = True - EcoRollOn = False + If Not JSON.Content("Body")("VACC") Is Nothing Then stDesMaxFile.Init(MyPath, JSON.Content("Body")("VACC")) - Case "OFF" - OverSpeedOn = False - EcoRollOn = False + EngOnly = JSON.Content("Body")("EngineOnlyMode") - Case Else - WorkerMsg(tMsgID.Err, "Value '" & dic("Mode") & "' is not valid for OverSpeedEcoRoll/Mode!", MsgSrc) - Return False - End Select + If Not JSON.Content("Body")("StartStop") Is Nothing Then + dic = JSON.Content("Body")("StartStop") + boStartStop = dic("Enabled") + siStStV = dic("MaxSpeed") + siStStT = dic("MinTime") + StStDelay = dic("Delay") + Else + boStartStop = False + End If - vMin = dic("MinSpeed") - OverSpeed = dic("OverSpeed") - If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic("UnderSpeed") + If Not JSON.Content("Body")("LAC") Is Nothing Then + dic = JSON.Content("Body")("LAC") + LookAheadOn = dic("Enabled") + a_lookahead = dic("Dec") + vMinLA = dic("MinSpeed") + Else + LookAheadOn = False + End If - Else - OverSpeedOn = False - EcoRollOn = False - End If + If Not JSON.Content("Body")("OverSpeedEcoRoll") Is Nothing Then + dic = JSON.Content("Body")("OverSpeedEcoRoll") + Select Case UCase(dic("Mode").ToString).Trim + Case "ECOROLL" + OverSpeedOn = False + EcoRollOn = True + Case "OVERSPEED" + OverSpeedOn = True + EcoRollOn = False + Case "OFF" + OverSpeedOn = False + EcoRollOn = False - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) - Return False - End Try + Case Else + WorkerMsg(tMsgID.Err, "Value '" & dic("Mode") & "' is not valid for OverSpeedEcoRoll/Mode!", MsgSrc) + Return False + End Select + vMin = dic("MinSpeed") + OverSpeed = dic("OverSpeed") + If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic("UnderSpeed") - Return True + Else + OverSpeedOn = False + EcoRollOn = False + End If - End Function + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) + Return False + End Try - Private Sub SetDefault() - AuxiliaryAssembly ="CLASSIC" - AuxiliaryVersion ="CLASSIC" - AdvancedAuxiliaryFilePath=String.Empty + Return True + End Function + Private Sub SetDefault() - boStartStop = False - siStStV = 5 - siStStT = 5 - StStDelay = 0 - FileVersion = 0 + AuxiliaryAssembly = "CLASSIC" + AuxiliaryVersion = "CLASSIC" + AdvancedAuxiliaryFilePath = String.Empty - stPathVEH.Clear() - stPathENG.Clear() - CycleFiles.Clear() - stPathGBX.Clear() - stDesMaxFile.Clear() - laDesV.Clear() - laDesMax.Clear() - laDesMin.Clear() - DesMaxDim = -1 + boStartStop = False + siStStV = 5 + siStStT = 5 + StStDelay = 0 + FileVersion = 0 - AuxPaths.Clear() - AuxRefs.Clear() - AuxDef = False - EStechs.Clear() + stPathVEH.Clear() + stPathENG.Clear() + CycleFiles.Clear() + stPathGBX.Clear() - EngOnly = False + stDesMaxFile.Clear() + laDesV.Clear() + laDesMax.Clear() + laDesMin.Clear() + DesMaxDim = -1 - a_lookahead = 0 - vMin = 0 - LookAheadOn = True - OverSpeedOn = False - EcoRollOn = False - OverSpeed = 0 - UnderSpeed = 0 - vMinLA = 0 + AuxPaths.Clear() + AuxRefs.Clear() + AuxDef = False + EStechs.Clear() - SavedInDeclMode = False + EngOnly = False - End Sub + a_lookahead = 0 + vMin = 0 + LookAheadOn = True + OverSpeedOn = False + EcoRollOn = False + OverSpeed = 0 + UnderSpeed = 0 + vMinLA = 0 - Public Function DeclInit() As Boolean + SavedInDeclMode = False + End Sub - Dim cl As List(Of String) - Dim s As String - Dim SubPath As cSubPath - Dim MsgSrc As String + Public Function DeclInit() As Boolean - MsgSrc = "VECTO/DeclInit" + Dim cl As List(Of String) + Dim s As String + Dim SubPath As cSubPath + Dim MsgSrc As String - EngOnly = False + MsgSrc = "VECTO/DeclInit" - CycleFiles.Clear() + EngOnly = False - cl = Declaration.SegRef.GetCycles + CycleFiles.Clear() - For Each s In cl - SubPath = New cSubPath - SubPath.Init(MyPath, s) - CycleFiles.Add(SubPath) - Next + cl = Declaration.SegRef.GetCycles - stDesMaxFile.Init(MyPath, Declaration.SegRef.VACCfile) + For Each s In cl + SubPath = New cSubPath + SubPath.Init(MyPath, s) + CycleFiles.Add(SubPath) + Next - siStStV = cDeclaration.SSspeed - siStStT = cDeclaration.SStime - StStDelay = cDeclaration.SSdelay + stDesMaxFile.Init(MyPath, Declaration.SegRef.VACCfile) - If Not EcoRollOn Then OverSpeedOn = True + siStStV = cDeclaration.SSspeed + siStStT = cDeclaration.SStime + StStDelay = cDeclaration.SSdelay - OverSpeed = cDeclaration.Overspeed - UnderSpeed = cDeclaration.Underspeed - vMin = cDeclaration.ECvmin + If Not EcoRollOn Then OverSpeedOn = True - LookAheadOn = True - a_lookahead = cDeclaration.LACa - vMinLA = cDeclaration.LACvmin + OverSpeed = cDeclaration.Overspeed + UnderSpeed = cDeclaration.Underspeed + vMin = cDeclaration.ECvmin - 'No need to check Aux (AuxDef). Will be checked in cDeclaration.CalcInitLoad + LookAheadOn = True + a_lookahead = cDeclaration.LACa + vMinLA = cDeclaration.LACvmin - Return True + 'No need to check Aux (AuxDef). Will be checked in cDeclaration.CalcInitLoad - End Function + Return True + End Function - 'This Sub reads those Input-files that do not have their own class, etc. - Public Function Init() As Boolean - Dim file As cFile_V3 - Dim line As String() + 'This Sub reads those Input-files that do not have their own class, etc. + Public Function Init() As Boolean + Dim file As cFile_V3 + Dim line As String() - Dim MsgSrc As String + Dim MsgSrc As String - MsgSrc = "VECTO/Init" + MsgSrc = "VECTO/Init" - If Not EngOnly Then + If Not EngOnly Then - file = New cFile_V3 + file = New cFile_V3 - If Not file.OpenRead(stDesMaxFile.FullPath) Then - WorkerMsg(tMsgID.Err, "Can't read .vacc file (" & stDesMaxFile.FullPath & ")", MsgSrc) - Return False - End If + If Not file.OpenRead(stDesMaxFile.FullPath) Then + WorkerMsg(tMsgID.Err, "Can't read .vacc file (" & stDesMaxFile.FullPath & ")", MsgSrc) + Return False + End If - 'Skip Header - file.ReadLine() + 'Skip Header + file.ReadLine() - laDesV.Clear() - laDesMax.Clear() - laDesMin.Clear() - DesMaxDim = -1 - Try + laDesV.Clear() + laDesMax.Clear() + laDesMin.Clear() + DesMaxDim = -1 + Try - Do While Not file.EndOfFile + Do While Not file.EndOfFile - DesMaxDim += 1 + DesMaxDim += 1 - line = file.ReadLine + line = file.ReadLine - laDesV.Add(CSng(line(0)) / 3.6) 'km/h => m/s !!!! - laDesMax.Add(CSng(line(1))) - laDesMin.Add(CSng(line(2))) + laDesV.Add(CSng(line(0)) / 3.6) 'km/h => m/s !!!! + laDesMax.Add(CSng(line(1))) + laDesMin.Add(CSng(line(2))) - Loop + Loop - Catch ex As Exception + Catch ex As Exception - file.Close() - WorkerMsg(tMsgID.Err, "Error in .vacc file. " & ex.Message & " (" & stDesMaxFile.FullPath & ")", MsgSrc, stDesMaxFile.FullPath) - Return False + file.Close() + WorkerMsg(tMsgID.Err, "Error in .vacc file. " & ex.Message & " (" & stDesMaxFile.FullPath & ")", MsgSrc, + stDesMaxFile.FullPath) + Return False - End Try + End Try - file.Close() + file.Close() - End If + End If - Return True - - End Function + Return True + End Function #Region "Aux" - Public Function AuxInit() As Boolean - - Dim Aux0 As cAux - Dim AuxPathKV As KeyValuePair(Of String, cAuxEntry) - Dim DRIauxcheck As New Dictionary(Of String, Boolean) - Dim AuxID As String + Public Function AuxInit() As Boolean - Dim MsgSrc As String + Dim Aux0 As cAux + Dim AuxPathKV As KeyValuePair(Of String, cAuxEntry) + Dim DRIauxcheck As New Dictionary(Of String, Boolean) + Dim AuxID As String - MsgSrc = "VEH/AuxInit" + Dim MsgSrc As String - AuxRefs = New Dictionary(Of String, cAux) + MsgSrc = "VEH/AuxInit" - If Cfg.DeclMode Then + AuxRefs = New Dictionary(Of String, cAux) - For Each AuxPathKV In AuxPaths - AuxRefs.Add(AuxPathKV.Key, Nothing) - Next + If Cfg.DeclMode Then - Return True + For Each AuxPathKV In AuxPaths + AuxRefs.Add(AuxPathKV.Key, Nothing) + Next - End If + Return True + End If - If DRI.AuxDef Xor AuxDef Then - If AuxDef Then - WorkerMsg(tMsgID.Err, "No auxiliary input defined in driving cycle!", MsgSrc) - Return False - Else - WorkerMsg(tMsgID.Warn, "No auxiliary defined in vehicle file! Psupply input will be ignored!", MsgSrc) - Return True - End If + If DRI.AuxDef Xor AuxDef Then - End If + If AuxDef Then + WorkerMsg(tMsgID.Err, "No auxiliary input defined in driving cycle!", MsgSrc) + Return False + Else + WorkerMsg(tMsgID.Warn, "No auxiliary defined in vehicle file! Psupply input will be ignored!", MsgSrc) + Return True + End If - If Not (DRI.AuxDef Or AuxDef) Then Return True + End If + If Not (DRI.AuxDef Or AuxDef) Then Return True - For Each AuxID In DRI.AuxComponents.Keys - DRIauxcheck.Add(AuxID, False) - Next - For Each AuxPathKV In AuxPaths + For Each AuxID In DRI.AuxComponents.Keys + DRIauxcheck.Add(AuxID, False) + Next - MsgSrc = "VEH/AuxInit/" & AuxPathKV.Key + For Each AuxPathKV In AuxPaths - If Not DRI.AuxComponents.ContainsKey(AuxPathKV.Key) Then - WorkerMsg(tMsgID.Err, "No Psupply input defined in driving cycle for auxiliary '" & AuxPathKV.Key & "'!", MsgSrc) - Return False - End If + MsgSrc = "VEH/AuxInit/" & AuxPathKV.Key - Aux0 = New cAux - Aux0.Filepath = AuxPathKV.Value.Path.FullPath + If Not DRI.AuxComponents.ContainsKey(AuxPathKV.Key) Then + WorkerMsg(tMsgID.Err, "No Psupply input defined in driving cycle for auxiliary '" & AuxPathKV.Key & "'!", MsgSrc) + Return False + End If - If Not Aux0.Readfile Then - 'Notificationin ReadFile() - Return False - End If + Aux0 = New cAux + Aux0.Filepath = AuxPathKV.Value.Path.FullPath - AuxRefs.Add(AuxPathKV.Key, Aux0) + If Not Aux0.Readfile Then + 'Notificationin ReadFile() + Return False + End If - DRIauxcheck(AuxPathKV.Key) = True + AuxRefs.Add(AuxPathKV.Key, Aux0) - Next + DRIauxcheck(AuxPathKV.Key) = True - MsgSrc = "VEH/AuxInit" + Next - For Each AuxID In DRI.AuxComponents.Keys - If Not DRIauxcheck(AuxID) Then WorkerMsg(tMsgID.Warn, "Auxiliary '" & AuxID & "' not found! Psupply input will be ignored!", MsgSrc) - Next + MsgSrc = "VEH/AuxInit" - Return True + For Each AuxID In DRI.AuxComponents.Keys + If Not DRIauxcheck(AuxID) Then _ + WorkerMsg(tMsgID.Warn, "Auxiliary '" & AuxID & "' not found! Psupply input will be ignored!", MsgSrc) + Next - End Function + Return True + End Function - Public Function Paux(ByVal AuxID As String, ByVal t As Integer, ByVal nU As Single) As Single - Dim Psupply As Single - Dim Px As Single - Dim Aux0 As cAux + Public Function Paux(ByVal AuxID As String, ByVal t As Integer, ByVal nU As Single) As Single + Dim Psupply As Single + Dim Px As Single + Dim Aux0 As cAux - Dim MsgSrc As String + Dim MsgSrc As String - MsgSrc = "VEH/Paux" + MsgSrc = "VEH/Paux" - If Cfg.DeclMode Then Return Declaration.AuxPower(AuxID) + If Cfg.DeclMode Then Return Declaration.AuxPower(AuxID) - If AuxDef Then + If AuxDef Then - Aux0 = AuxRefs(AuxID) + Aux0 = AuxRefs(AuxID) - Psupply = DRI.AuxComponents(AuxID)(t) + Psupply = DRI.AuxComponents(AuxID)(t) - If Psupply < 0 Then GoTo lbAuxError + If Psupply < 0 Then GoTo lbAuxError - Px = Aux0.Paux(nU, Psupply) + Px = Aux0.Paux(nU, Psupply) - If Px < 0 Then GoTo lbAuxError + If Px < 0 Then GoTo lbAuxError - Return Px + Return Px - Else + Else - Return 0 + Return 0 - End If + End If lbAuxError: - MODdata.ModErrors.AuxNegative = AuxID - Return 0 - - - End Function + MODdata.ModErrors.AuxNegative = AuxID + Return 0 + End Function - Public Function PauxSum(ByVal t As Integer, ByVal nU As Single) As Single - Dim sum As Single - Dim AuxID As String + Public Function PauxSum(ByVal t As Integer, ByVal nU As Single) As Single + Dim sum As Single + Dim AuxID As String - Dim MsgSrc As String + Dim MsgSrc As String - MsgSrc = "VEH/Paux" + MsgSrc = "VEH/Paux" - If AuxDef Then + If AuxDef Then - sum = 0 + sum = 0 - For Each AuxID In AuxRefs.Keys + For Each AuxID In AuxRefs.Keys - sum += Paux(AuxID, t, nU) + sum += Paux(AuxID, t, nU) - Next + Next - Return sum + Return sum - Else + Else - Return 0 + Return 0 - End If - - End Function + End If + End Function #End Region #Region "Properties" - Public ReadOnly Property FileList As List(Of String) - Get - Return MyFileList - End Get - End Property - - - Public Property FilePath() As String - Get - Return sFilePath - End Get - Set(ByVal value As String) - sFilePath = value - If sFilePath = "" Then - MyPath = "" - Else - MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" - End If - End Set - End Property - - - Public Property PathVEH(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stPathVEH.OriginalPath - Else - Return stPathVEH.FullPath - End If - End Get - Set(ByVal value As String) - stPathVEH.Init(MyPath, value) - End Set - End Property - - Public Property PathENG(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stPathENG.OriginalPath - Else - Return stPathENG.FullPath - End If - End Get - Set(ByVal value As String) - stPathENG.Init(MyPath, value) - End Set - End Property - - Public Property PathGBX(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stPathGBX.OriginalPath - Else - Return stPathGBX.FullPath - End If - End Get - Set(ByVal value As String) - stPathGBX.Init(MyPath, value) - End Set - End Property - - - Public Property StartStop() As Boolean - Get - Return boStartStop - End Get - Set(ByVal value As Boolean) - boStartStop = value - End Set - End Property - - Public Property StStV() As Single - Get - Return siStStV - End Get - Set(ByVal value As Single) - siStStV = value - End Set - End Property - - Public Property StStT() As Single - Get - Return siStStT - End Get - Set(ByVal value As Single) - siStStT = value - End Set - End Property - - Public Property DesMaxFile(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stDesMaxFile.OriginalPath - Else - Return stDesMaxFile.FullPath - End If - End Get - Set(ByVal value As String) - stDesMaxFile.Init(MyPath, value) - End Set - End Property + Public ReadOnly Property FileList As List(Of String) + Get + Return MyFileList + End Get + End Property + + + Public Property FilePath() As String + Get + Return sFilePath + End Get + Set(ByVal value As String) + sFilePath = value + If sFilePath = "" Then + MyPath = "" + Else + MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" + End If + End Set + End Property + + + Public Property PathVEH(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stPathVEH.OriginalPath + Else + Return stPathVEH.FullPath + End If + End Get + Set(ByVal value As String) + stPathVEH.Init(MyPath, value) + End Set + End Property + + Public Property PathENG(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stPathENG.OriginalPath + Else + Return stPathENG.FullPath + End If + End Get + Set(ByVal value As String) + stPathENG.Init(MyPath, value) + End Set + End Property + + Public Property PathGBX(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stPathGBX.OriginalPath + Else + Return stPathGBX.FullPath + End If + End Get + Set(ByVal value As String) + stPathGBX.Init(MyPath, value) + End Set + End Property + + + Public Property StartStop() As Boolean + Get + Return boStartStop + End Get + Set(ByVal value As Boolean) + boStartStop = value + End Set + End Property + + Public Property StStV() As Single + Get + Return siStStV + End Get + Set(ByVal value As Single) + siStStV = value + End Set + End Property + + Public Property StStT() As Single + Get + Return siStStT + End Get + Set(ByVal value As Single) + siStStT = value + End Set + End Property + + Public Property DesMaxFile(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stDesMaxFile.OriginalPath + Else + Return stDesMaxFile.FullPath + End If + End Get + Set(ByVal value As String) + stDesMaxFile.Init(MyPath, value) + End Set + End Property #End Region - Public Function aDesMax(ByVal v As Single) As Single - Dim i As Int32 + Public Function aDesMax(ByVal v As Single) As Single + Dim i As Int32 - 'Extrapolation for x < x(1) - If laDesV(0) >= v Then - If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - i = 1 - GoTo lbInt - End If + 'Extrapolation for x < x(1) + If laDesV(0) >= v Then + If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + i = 1 + GoTo lbInt + End If - i = 0 - Do While laDesV(i) < v And i < DesMaxDim - i += 1 - Loop + i = 0 + Do While laDesV(i) < v And i < DesMaxDim + i += 1 + Loop - 'Extrapolation for x > x(imax) - If laDesV(i) < v Then - MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - End If + 'Extrapolation for x > x(imax) + If laDesV(i) < v Then + MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + End If lbInt: - 'Interpolation - Return (v - laDesV(i - 1)) * (laDesMax(i) - laDesMax(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMax(i - 1) - - End Function - - Public Function aDesMin(ByVal v As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If laDesV(0) >= v Then - If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While laDesV(i) < v And i < DesMaxDim - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If laDesV(i) < v Then - MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - End If + 'Interpolation + Return (v - laDesV(i - 1)) * (laDesMax(i) - laDesMax(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMax(i - 1) + End Function + + Public Function aDesMin(ByVal v As Single) As Single + Dim i As Int32 + + 'Extrapolation for x < x(1) + If laDesV(0) >= v Then + If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + i = 1 + GoTo lbInt + End If + + i = 0 + Do While laDesV(i) < v And i < DesMaxDim + i += 1 + Loop + + 'Extrapolation for x > x(imax) + If laDesV(i) < v Then + MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + End If lbInt: - 'Interpolation - Return (v - laDesV(i - 1)) * (laDesMin(i) - laDesMin(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMin(i - 1) - - End Function - - + 'Interpolation + Return (v - laDesV(i - 1)) * (laDesMin(i) - laDesMin(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMin(i - 1) + End Function End Class diff --git a/VECTO/MODcalc/cPower.vb b/VECTO/MODcalc/cPower.vb index e1c8e498a03a705b8493da6a960fc407eeea5d17..1221aff9a1a9c005787502a3573585609f82a604 100644 --- a/VECTO/MODcalc/cPower.vb +++ b/VECTO/MODcalc/cPower.vb @@ -297,7 +297,7 @@ Public Class cPower 'Total aux power '[kW] - Paux = PreExistingAuxPower + fPaux(t, EngineSpeed) + Paux = fPaux(t, EngineSpeed) 'Internal Engine Power (Pclutch plus Aux plus Inertia) P = Pkup + Paux + PaMot @@ -1095,7 +1095,7 @@ lb_nOK: 'Total aux power '[kW] - Paux = PreExistingAuxPower + fPaux(jz, EngineSpeed) + Paux = fPaux(jz, EngineSpeed) '***************** ADVANCED AUXILIARIES END ******************************************************** 'ICE-inertia @@ -2741,7 +2741,7 @@ lb10: If VECTO_Global.VEC.AuxiliaryAssembly = "CLASSIC" Then - Return CSng(VEC.PauxSum(t, nU)) + Return CSng(MODdata.Vh.Padd(t) + VEC.PauxSum(t, nU)) Else @@ -2760,7 +2760,7 @@ lb10: mAAUX_Global.advancedAuxModel.Signals.InternalEnginePower = (mAAUX_Global.Internal_Engine_Power * 1000).SI(Of Watt)() 'Power coming out of Advanced Model is in Watts. - power = (advancedAuxModel.AuxiliaryPowerAtCrankWatts().Value() / 1000) + power = PreExistingAuxPower + (advancedAuxModel.AuxiliaryPowerAtCrankWatts / 1000) 'Glenn: Comment the previous line and uncomment the next line to include the classic auxilaries power togeher with the advanced auxiliary power. 'power = VEC.PauxSum(t, nU) + (advancedAuxModel.AuxiliaryPowerAtCrankWatts / 1000) diff --git a/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs b/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs index d5551f7a00dcc7a93c7c373f04b27eec3f40dbc2..2fa74371cf429282d52cf85fb08df64808186476 100644 --- a/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs +++ b/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCommon.Exceptions LogManager.Flush(); } - protected VectoException(string message, Exception inner, params object[] args) + public VectoException(string message, Exception inner, params object[] args) : base(string.Format(message, args), inner) { LogManager.Flush(); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index ffbf6bab3609efb177172eb292eee4d0d95d78c2..a780e644173c1d02879c364c919533101fc7dcd1 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -209,31 +209,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON if (!EmptyOrInvalidFileName(gearboxFile)) { Gearbox = JSONInputDataFactory.ReadGearbox(Path.Combine(BasePath, gearboxFile)); } - } catch (Exception e) { - throw new VectoException("Failed to read Gearbox file.", e); - } - try { + var axleGear = Gearbox as IAxleGearInputData; if (axleGear != null) { AxleGear = axleGear; } - } catch (Exception e) { - throw new VectoException("Failed to read AxleGear file.", e); - } - try { + Engine = JSONInputDataFactory.ReadEngine( Path.Combine(BasePath, Body.GetEx(JsonKeys.Vehicle_EngineFile).Value<string>())); - } catch (Exception e) { - throw new VectoException("Failed to read Engine file.", e); - } - try { + var vehicleFile = Body.GetEx(JsonKeys.Vehicle_VehicleFile).Value<string>(); if (!EmptyOrInvalidFileName(vehicleFile)) { VehicleData = JSONInputDataFactory.ReadJsonVehicle( Path.Combine(BasePath, vehicleFile)); } } catch (Exception e) { - throw new VectoException("Failed to read Vehicle file.", e); + throw new VectoException("Failed to read input data: {0}", e, e.Message); } var retarder = VehicleData as IRetarderInputData; if (retarder != null) { @@ -265,7 +256,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IVehicleEngineeringInputData VehicleInputData { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (VehicleData == null) { @@ -277,7 +269,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IGearboxEngineeringInputData GearboxInputData { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Gearbox == null) { @@ -289,7 +282,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IAxleGearInputData AxleGearInputData { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (AxleGear == null) { @@ -306,7 +300,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IEngineEngineeringInputData EngineInputData { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Engine == null) { @@ -333,7 +328,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IRetarderInputData RetarderInputData { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Retarder == null) { @@ -359,7 +355,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IList<ICycleData> Cycles { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { var retVal = new List<ICycleData>(); @@ -467,7 +464,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual DataTable AccelerationCurve { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { var acceleration = Body[JsonKeys.DriverData_AccelerationCurve]; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index fd1ff147dabaa62e5a182b634f5ac34e84803977..4a25ea6044564194c925ef542bd58eb738f660a2 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -176,12 +176,17 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper WarnEngineeringMode("AuxData"); } - return auxInputData.Auxiliaries.Select(a => new VectoRunData.AuxData { - ID = a.ID, - Technology = a.Technology, - TechList = a.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray(), - DemandType = AuxiliaryDemandType.Mapping, - Data = new AuxiliaryData(a, a.ID) //AuxiliaryData.Create(a.DemandMap) + return auxInputData.Auxiliaries.Select(a => { + if (a.DemandMap == null) { + throw new VectoSimulationException("Demand Map for auxiliary {0} {1} required", a.ID, a.Technology); + } + return new VectoRunData.AuxData { + ID = a.ID, + Technology = a.Technology, + TechList = a.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray(), + DemandType = AuxiliaryDemandType.Mapping, + Data = new AuxiliaryData(a, a.ID) //AuxiliaryData.Create(a.DemandMap) + }; }).Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()).ToList(); } diff --git a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs index 7ddcaab7d648dacea8dbbd9960179f7e16b9ac94..59005eaa9003b851f50d55a03bf7cd9fe1ff9a60 100644 --- a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs @@ -205,7 +205,6 @@ namespace TUGraz.VectoCore.InputData.Reader var tmp = new DrivingCycleData.DrivingCycleEntry(entry) { StoppingTime = 0.SI<Second>(), RoadGradient = entry.RoadGradient, - RoadGradientPercent = entry.RoadGradientPercent, VehicleTargetSpeed = i < entries.Count - 1 ? entries[i + 1].VehicleTargetSpeed : 0.SI<MeterPerSecond>() }; filtered.Add(tmp); @@ -362,7 +361,6 @@ namespace TUGraz.VectoCore.InputData.Reader return table.Rows.Cast<DataRow>().Select(row => new DrivingCycleData.DrivingCycleEntry { Distance = row.ParseDouble(Fields.Distance).SI<Meter>(), VehicleTargetSpeed = row.ParseDouble(Fields.VehicleSpeed).KMPHtoMeterPerSecond(), - RoadGradientPercent = row.ParseDoubleOrGetDefault(Fields.RoadGradient), RoadGradient = VectoMath.InclinationToAngle(row.ParseDoubleOrGetDefault(Fields.RoadGradient) / 100.0), StoppingTime = row.ParseDouble(Fields.StoppingTime).SI<Second>(), AdditionalAuxPowerDemand = row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.Cast<Watt>(), diff --git a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs index 94a96663c4c72dba3a9fe8d550261d365995b2eb..fa7e2073d3691837b01b32f479ef72998efe8994 100644 --- a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs +++ b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Models.Declaration NormalizeTable(table); foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) { var values = table.Columns[mission.ToString().ToLower()].Values<string>().ToDouble().ToArray(); - _data[mission] = new WHTCCorrectionEntry { Rural = values[0], Urban = values[1], Motorway = values[2] }; + _data[mission] = new WHTCCorrectionEntry { Urban = values[0], Rural = values[1], Motorway = values[2] }; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index 49f72e7e5d05fa95d492ba3b997d3510e730be4a..28f75402351f764408f95b7c66eab2070941736f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.Diagnostics; using TUGraz.VectoCommon.Utils; @@ -101,7 +102,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// <summary> /// [%] Optional. /// </summary> - public double RoadGradientPercent { get; set; } + public Scalar RoadGradientPercent + { + get { return (Math.Tan(RoadGradient.Value()) * 100).SI<Scalar>(); } + } /// <summary> /// relative altitude of the driving cycle over distance diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index a170bb82787c1d6526bea6173927398c75ff2bce..24545662c6e54e6e2bd6e1ccca690d6f21789b8f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -32,6 +32,7 @@ using System; using System.IO; using System.Windows.Forms.VisualStyles; +using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Simulation; @@ -44,20 +45,25 @@ using VectoAuxiliaries; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class BusAuxiliariesAdapter : StatefulVectoSimulationComponent<BusAuxiliariesAdapter.BusAuxState>, - IEngineAuxInProvider, IEngineAuxPort + public class BusAuxiliariesAdapter : LoggingObject, IEngineAuxInProvider, IEngineAuxPort { + protected IDataBus DataBus; + protected internal BusAuxState CurrentState; + protected internal BusAuxState PreviousState; + protected IAdvancedAuxiliaries Auxiliaries; private readonly FuelConsumptionAdapter _fcMapAdapter; - public BusAuxiliariesAdapter(IVehicleContainer container, string aauxFile, string cycleName, Kilogram vehicleWeight, - FuelConsumptionMap fcMap, - PerSecond engineIdleSpeed) : base(container) + public BusAuxiliariesAdapter(IDataBus container, string aauxFile, string cycleName, Kilogram vehicleWeight, + FuelConsumptionMap fcMap, PerSecond engineIdleSpeed) { // mAAUX_Global.advancedAuxModel.Signals.DeclarationMode = Cfg.DeclMode // mAAUX_Global.advancedAuxModel.Signals.WHTC = Declaration.WHTCcorrFactor + CurrentState = new BusAuxState(); + PreviousState = new BusAuxState(); + DataBus = container; var tmpAux = new AdvancedAuxiliaries(); // 'Set Statics @@ -114,6 +120,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed) { + PreviousState.TotalFuelConsumption = 0.SI<Kilogram>(); PreviousState.AngularSpeed = angularSpeed; PreviousState.PowerDemand = GetBusAuxPowerDemand(0.SI<Second>(), 1.SI<Second>(), torque, torque, angularSpeed); return PreviousState.PowerDemand / angularSpeed; @@ -132,7 +139,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } - protected override void DoWriteModalResults(IModalDataContainer container) + protected internal void DoWriteModalResults(IModalDataContainer container) { _fcMapAdapter.AllowExtrapolation = true; // cycleStep has to be called here and not in DoCommit, write is called before Commit! @@ -140,6 +147,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Auxiliaries.CycleStep(CurrentState.dt, ref message); Log.Warn(message); + CurrentState.TotalFuelConsumption = Auxiliaries.TotalFuelGRAMS.SI().Gramm.Cast<Kilogram>(); container[ModalResultField.P_aux] = CurrentState.PowerDemand; container[ModalResultField.AA_NonSmartAlternatorsEfficiency] = Auxiliaries.AA_NonSmartAlternatorsEfficiency; @@ -193,11 +201,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Auxiliaries.AA_TotalCycleFuelConsumptionCompressorOn; } - protected override void DoCommitSimulationStep() + protected internal void DoCommitSimulationStep() { - AdvanceState(); + PreviousState = CurrentState; + CurrentState = new BusAuxState(); } + protected internal KilogramPerSecond AAuxFuelConsumption + { + get { return (CurrentState.TotalFuelConsumption - PreviousState.TotalFuelConsumption) / CurrentState.dt; } + } private Watt GetBusAuxPowerDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine, PerSecond angularSpeed, bool dryRun = false) @@ -253,6 +266,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Second dt; public PerSecond AngularSpeed; public Watt PowerDemand; + public Kilogram TotalFuelConsumption; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index f2a45a9b8c45083e3b4d6050c025445a38b96df8..bf102a03d719ec35e8847900435f5689ea221267 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -344,6 +344,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var fcWHTC = fcAux * ModelData.WHTCCorrectionFactor; var fcAAUX = fcWHTC; + var advancedAux = EngineAux as BusAuxiliariesAdapter; + if (advancedAux != null) { + advancedAux.DoWriteModalResults(container); + fcAAUX = advancedAux.AAuxFuelConsumption; + } var fcFinal = fcAAUX; container[ModalResultField.FCMap] = fc; @@ -356,6 +361,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override void DoCommitSimulationStep() { AdvanceState(); + var advancedAux = EngineAux as BusAuxiliariesAdapter; + if (advancedAux != null) { + advancedAux.DoCommitSimulationStep(); + } } #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index a56f0fc0e1b1c3e8f3f5ad4a5293e064e399eeb2..6b64c413c7b679700823490c8d0dbf74f1363b9e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -359,7 +359,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : 0.SI<NewtonMeter>(); inTorque += CurrentState.InertiaTorqueLossOut / ModelData.Gears[Gear].Ratio; - var dryRunResponse = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, true); + var inertiaTorqueLossIn = + Formulas.InertiaPower(outAngularVelocity, PreviousState.OutAngularVelocity, ModelData.Inertia, dt) / + avgOutAngularVelocity / ModelData.Gears[Gear].Ratio; + var dryRunResponse = NextComponent.Request(absTime, dt, inTorque + inertiaTorqueLossIn, inAngularVelocity, true); dryRunResponse.GearboxPowerRequest = outTorque * (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; return dryRunResponse; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 444b0e5f671d97ce14f039e39e4f54d9f1bbcb1a..b6fdee3501d24cbfc7226aec422331949374b0d9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.Linq; using TUGraz.VectoCommon.Exceptions; @@ -527,7 +528,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.dist] = CurrentState.Distance; container[ModalResultField.simulationDistance] = CurrentState.SimulationDistance; container[ModalResultField.v_targ] = CurrentState.VehicleSpeed; - container[ModalResultField.grad] = LeftSample.Current.RoadGradientPercent.SI(); + container[ModalResultField.grad] = LeftSample.Current.RoadGradientPercent; container[ModalResultField.altitude] = LeftSample.Current.Altitude; container[ModalResultField.acc] = CurrentState.Acceleration; } diff --git a/VectoCore/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/VectoCore/Utils/VectoCSVFile.cs index 5ab2a8e9050846fa6135dd95cdde57c3600ddf62..657dac3cd1bb125afc08be0e554b42c3ae4d8e5d 100644 --- a/VectoCore/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/VectoCore/Utils/VectoCSVFile.cs @@ -44,7 +44,7 @@ using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Utils { /// <summary> - /// Class for Reading and Writing VECTO CSV Files. + /// Class for Reading and Writing VECTO CSV Files. /// </summary> /// <remarks> /// The following format applies to all CSV (Comma-separated values) Input Files used in VECTO: @@ -56,140 +56,139 @@ namespace TUGraz.VectoCore.Utils /// max: id (name) [unit], id (name) [unit], ... /// min: id,id,... /// </remarks> - public class VectoCSVFile : LoggingObject + public static class VectoCSVFile { private static readonly Regex HeaderFilter = new Regex(@"\[.*?\]|\<|\>", RegexOptions.Compiled); private const char Delimiter = ','; private const char Comment = '#'; /// <summary> - /// Reads a CSV file which is stored in Vecto-CSV-Format. + /// Reads a CSV file which is stored in Vecto-CSV-Format. /// </summary> - /// <param name="fileName"></param> - /// <param name="ignoreEmptyColumns"></param> - /// <param name="fullHeader"></param> - /// <exception cref="FileIOException"></exception> + /// <param name="fileName">the filename</param> + /// <param name="ignoreEmptyColumns">set true, if empty columns should be ignored. default: false.</param> + /// <param name="fullHeader">set true is column names should be preserved. Otherwise units are trimed away. default: false.</param> /// <returns>A DataTable which represents the CSV File.</returns> public static DataTable Read(string fileName, bool ignoreEmptyColumns = false, bool fullHeader = false) { try { - return ReadData(File.ReadAllLines(fileName, Encoding.UTF8), ignoreEmptyColumns, fullHeader); + using (var fs = new FileStream(fileName, FileMode.Open)) { + return ReadStream(fs, ignoreEmptyColumns, fullHeader); + } } catch (Exception e) { - Logger<VectoCSVFile>().Error(e); - throw new VectoException("File {0}: {1}", fileName, e.Message); + LogManager.GetLogger(typeof(VectoCSVFile).FullName).Error(e); + throw new VectoException("Error File {0}: {1}", fileName, e.Message); } } /// <summary> - /// Reads a CSV file which is stored in Vecto-CSV-Format. + /// Reads a CSV file which is stored in Vecto-CSV-Format. /// </summary> - /// <param name="stream"></param> - /// <param name="ignoreEmptyColumns"></param> - /// <exception cref="FileIOException"></exception> + /// <param name="stream">the stream to read</param> + /// <param name="ignoreEmptyColumns">set true, if empty columns should be ignored. default: false.</param> + /// <param name="fullHeader">set true is column names should be preserved. Otherwise units are trimed away. default: false.</param> /// <returns>A DataTable which represents the CSV File.</returns> - public static DataTable ReadStream(Stream stream, bool ignoreEmptyColumns = false) + public static DataTable ReadStream(Stream stream, bool ignoreEmptyColumns = false, bool fullHeader = false) { try { - return ReadData(ReadAllLines(stream), ignoreEmptyColumns); + return ReadData(ReadLines(stream), ignoreEmptyColumns, fullHeader); } catch (Exception e) { - Logger<VectoCSVFile>().Error(e); + LogManager.GetLogger(typeof(VectoCSVFile).FullName).Error(e); throw new VectoException("Failed to read stream: " + e.Message, e); } } - private static IEnumerable<string> ReadAllLines(Stream stream) + private static IEnumerable<string> ReadLines(Stream stream) { - using (var reader = new StreamReader(stream)) { - string line; - while ((line = reader.ReadLine()) != null) { - yield return line; - } + using (var reader = new StreamReader(stream, Encoding.UTF8)) { + while (!reader.EndOfStream) + yield return reader.ReadLine(); } } - private static DataTable ReadData(IEnumerable<string> data, bool ignoreEmptyColumns = false, bool fullHeader = false) + /// <summary> + /// + /// </summary> + /// <param name="allLines"></param> + /// <param name="ignoreEmptyColumns"></param> + /// <param name="fullHeader"></param> + /// <returns></returns> + private static DataTable ReadData(IEnumerable<string> allLines, bool ignoreEmptyColumns = false, + bool fullHeader = false) { - var linesEnumerable = RemoveComments(data); - var lines = linesEnumerable.GetEnumerator(); + // trim, remove comments and filter empty lines + var lines = allLines + .Select(l => l.Trim()) + .Select(l => l.Contains(Comment) ? l.Substring(0, l.IndexOf(Comment)) : l) + .Where(l => !string.IsNullOrWhiteSpace(l)) + .GetEnumerator(); + + // start the enumerable lines.MoveNext(); - var validColumns = GetValidHeaderColumns(lines.Current, fullHeader).ToArray(); + // add columns + var line = lines.Current; + if (!fullHeader) { + line = HeaderFilter.Replace(line, ""); + } + double tmp; + var splittedColumns = line + .Split(Delimiter); + + var columns = splittedColumns + .Select(col => col.Trim()) + .Where(col => !double.TryParse(col, NumberStyles.Any, CultureInfo.InvariantCulture, out tmp)) + .ToList(); - if (validColumns.Length > 0) { - // Valid Columns found => header was valid => skip header line + if (columns.Count > 0) { + // first line was a valid header: advance to first data line lines.MoveNext(); } else { - Logger<VectoCSVFile>().Warn("No valid Data Header found. Interpreting the first line as data line."); + LogManager.GetLogger(typeof(VectoCSVFile).FullName) + .Warn("No valid Data Header found. Interpreting the first line as data line."); // set the validColumns to: {"0", "1", "2", "3", ...} for all columns in first line. - validColumns = GetColumns(lines.Current).Select((_, index) => index.ToString()).ToArray(); + columns = splittedColumns.Select((_, index) => index.ToString()).ToList(); } var table = new DataTable(); - foreach (var col in validColumns) { + foreach (var col in columns) { table.Columns.Add(col); } - var i = 1; + // read data into table + var i = 0; do { - var line = lines.Current; + i++; + line = lines.Current; var cells = line.Split(Delimiter).Select(s => s.Trim()).ToArray(); - if (!ignoreEmptyColumns && cells.Length != table.Columns.Count) { + if (cells.Length != table.Columns.Count && !ignoreEmptyColumns) { throw new CSVReadException( string.Format("Line {0}: The number of values is not correct. Expected {1} Columns, Got {2} Columns", i, table.Columns.Count, cells.Length)); } try { + // ReSharper disable once CoVariantArrayConversion table.Rows.Add(cells); } catch (InvalidCastException e) { throw new CSVReadException( string.Format("Line {0}: The data format of a value is not correct. {1}", i, e.Message), e); } - i++; } while (lines.MoveNext()); - return table; } - private static IEnumerable<string> GetValidHeaderColumns(string line, bool fullHeader = false) - { - double test; - var validColumns = GetColumns(line, fullHeader). - Where(col => !double.TryParse(col, NumberStyles.Any, CultureInfo.InvariantCulture, out test)); - return validColumns.ToArray(); - } - - private static IEnumerable<string> GetColumns(string line, bool fullHeader = false) - { - if (!fullHeader) { - line = HeaderFilter.Replace(line, ""); - } - return line.Split(Delimiter).Select(col => col.Trim()); - } - - private static IEnumerable<string> RemoveComments(IEnumerable<string> lines) - { - foreach (var line in lines) { - var index = line.IndexOf(Comment); - var result = index == -1 ? line : line.Substring(0, index + 1); - if (!string.IsNullOrWhiteSpace(result)) { - yield return result; - } - } - } - /// <summary> - /// Writes the datatable to the csv file. - /// Uses the column caption as header (with fallback to column name) for the csv header. + /// Writes the datatable to the csv file. + /// Uses the column caption as header (with fallback to column name) for the csv header. /// </summary> /// <param name="fileName">Path to the file.</param> /// <param name="table">The Datatable.</param> public static void Write(string fileName, DataTable table) { - var stream = new StreamWriter(new FileStream(fileName, FileMode.Create), Encoding.UTF8); - Write(stream, table); - stream.Close(); + using (var sw = new StreamWriter(new FileStream(fileName, FileMode.Create), Encoding.UTF8)) + Write(sw, table); } /// <summary> @@ -216,9 +215,9 @@ namespace TUGraz.VectoCore.Utils var showUnit = (bool?)col.ExtendedProperties["showUnit"]; var si = item as SI; - return (si != null + return si != null ? si.ToOutputFormat(decimals, outputFactor, showUnit) - : string.Format(CultureInfo.InvariantCulture, "{0}", item)); + : string.Format(CultureInfo.InvariantCulture, "{0}", item); }); writer.WriteLine(Delimiter.ToString().Join(formattedList)); diff --git a/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs b/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs new file mode 100644 index 0000000000000000000000000000000000000000..fcea833170ceba9237976efedfa161e150df0c4b --- /dev/null +++ b/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs @@ -0,0 +1,126 @@ +using System.Data; +using System.IO; +using System.Linq; +using NUnit.Framework; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Tests.FileIO +{ + [TestFixture] + public class VectoCSVFileTest + { + [Test] + public void VectoCSVFile_Read() + { + var table = VectoCSVFile.Read(@"TestData\test.csv"); + Assert.AreEqual(3, table.Columns.Count); + Assert.IsTrue(new[] { "a", "b", "c" }.SequenceEqual(table.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); + Assert.AreEqual(2, table.Rows.Count); + + Assert.IsTrue(new[] { "1", "2", "3" }.SequenceEqual(table.Rows[0].ItemArray)); + Assert.IsTrue(new[] { "4", "5", "6" }.SequenceEqual(table.Rows[1].ItemArray)); + } + + [Test] + public void VectoCSVFile_Read_RealLossMap() + { + var table = VectoCSVFile.Read(@"TestData\Components\Axle.vtlm"); + Assert.AreEqual(3, table.Columns.Count); + Assert.IsTrue( + new[] { "Input Speed", "Input Torque", "Torque Loss" }.SequenceEqual( + table.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); + Assert.AreEqual(285, table.Rows.Count); + } + + [Test] + public void VectoCSVFile_ReadStream_Normal() + { + var stream = "a,b,c\n1,2,3\n4,5,6".GetStream(); + var table = VectoCSVFile.ReadStream(stream); + + Assert.AreEqual(3, table.Columns.Count); + Assert.IsTrue(new[] { "a", "b", "c" }.SequenceEqual(table.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); + Assert.AreEqual(2, table.Rows.Count); + + Assert.IsTrue(new[] { "1", "2", "3" }.SequenceEqual(table.Rows[0].ItemArray)); + Assert.IsTrue(new[] { "4", "5", "6" }.SequenceEqual(table.Rows[1].ItemArray)); + } + + [Test] + public void VectoCSVFile_ReadStream_No_Header() + { + var stream = "1,2,3\n4,5,6".GetStream(); + var table = VectoCSVFile.ReadStream(stream); + + Assert.AreEqual(3, table.Columns.Count); + Assert.IsTrue(new[] { "0", "1", "2" }.SequenceEqual(table.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); + Assert.AreEqual(2, table.Rows.Count); + + Assert.IsTrue(new[] { "1", "2", "3" }.SequenceEqual(table.Rows[0].ItemArray)); + Assert.IsTrue(new[] { "4", "5", "6" }.SequenceEqual(table.Rows[1].ItemArray)); + } + + [Test] + public void VectoCSVFile_ReadStream_Comments() + { + var stream = @"#a,b,c + #21,22,23 + #674,95,96 + a,b,c + #9,8,7 + 1,2,3 + 4,5,6".GetStream(); + var table = VectoCSVFile.ReadStream(stream); + + Assert.AreEqual(3, table.Columns.Count); + Assert.IsTrue(new[] { "a", "b", "c" }.SequenceEqual(table.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); + Assert.AreEqual(2, table.Rows.Count); + + Assert.IsTrue(new[] { "1", "2", "3" }.SequenceEqual(table.Rows[0].ItemArray)); + Assert.IsTrue(new[] { "4", "5", "6" }.SequenceEqual(table.Rows[1].ItemArray)); + } + + [Test] + public void VectoCSVFile_Write_Filename() + { + const string fileName = "out_test.csv"; + + if (File.Exists(fileName)) + File.Delete(fileName); + + var table = new DataTable(); + table.Columns.Add("a"); + table.Columns.Add("b"); + table.Rows.Add("1", "2"); + + VectoCSVFile.Write(fileName, table); + + var text = File.ReadAllText(fileName); + Assert.AreEqual("a,b\r\n1,2\r\n", text); + } + + [Test] + public void VectoCSVFile_Write_StreamWriter() + { + var table = new DataTable(); + table.Columns.Add("a"); + table.Columns.Add("b"); + var row = table.NewRow(); + row.ItemArray = new[] { "1", "2" }; + table.Rows.Add(row); + + using (var stream = new MemoryStream()) { + using (var sw = new StreamWriter(stream)) { + VectoCSVFile.Write(sw, table); + sw.Flush(); + + stream.Position = 0; + + using (var sr = new StreamReader(stream)) + Assert.AreEqual("a,b\r\n1,2\r\n", sr.ReadToEnd()); + } + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs index b3e7ad768ddaf1ee45375ed1c0f212fd4ca11886..c9f2acef12657ca172426d25e76c7be3e16b4200 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs @@ -86,7 +86,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); Assert.AreEqual(6086.9321, (torque * engineSpeed).Value(), 1e-3); - busAux.CommitSimulationStep(modalData); + busAux.DoWriteModalResults(modalData); } Assert.AreEqual(79.303.SI().Gramm.Value(), ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); @@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); Assert.AreEqual(8954.1396, (torque * engineSpeed).Value(), 1e-3); - busAux.CommitSimulationStep(modalData); + busAux.DoWriteModalResults(modalData); } Assert.AreEqual(82.5783.SI().Gramm.Value(), ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); @@ -110,7 +110,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); Assert.AreEqual(6086.9321, (torque * engineSpeed).Value(), 1e-3); - busAux.CommitSimulationStep(modalData); + busAux.DoWriteModalResults(modalData); } Assert.AreEqual(162.4654.SI().Gramm.Value(), ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index ba9cc63546f83edd230c92e4e65d66d565be8e1a..9b4a86ad46a2d3d7e68286e3539351a6deac4e5f 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -128,12 +128,42 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration var urban = r.NextDouble() * 2; var rural = r.NextDouble() * 2; var motorway = r.NextDouble() * 2; - var whtcValue = whtc.Lookup(Missions[i], urban, rural, motorway); + var whtcValue = whtc.Lookup(Missions[i], rural: rural, urban: urban, motorway: motorway); Assert.AreEqual(urban * factors.urban[i] + rural * factors.rural[i] + motorway * factors.motorway[i], whtcValue); } } + [TestMethod] + public void WHTCLookupTestLongHaul() + { + var expected = 1.015501; + + var rural = 1.0265; + var urban = 1.0948; + var motorway = 1.0057; + + var lookup = DeclarationData.WHTCCorrection.Lookup(MissionType.LongHaul, rural: rural, urban: urban, + motorway: motorway); + Assert.AreEqual(expected, lookup, 1e-8); + } + + + [TestMethod] + public void WHTCLookupTestRegionalDelivery() + { + var expected = 1.02708700; + + var rural = 1.0265; + var urban = 1.0948; + var motorway = 1.0057; + + var lookup = DeclarationData.WHTCCorrection.Lookup(MissionType.RegionalDelivery, rural: rural, urban: urban, + motorway: motorway); + Assert.AreEqual(expected, lookup, 1e-8); + } + + [Test] public void AirDragTest() { diff --git a/VectoCore/VectoCoreTest/TestData/Components/Axle.vtlm b/VectoCore/VectoCoreTest/TestData/Components/Axle.vtlm index a2f69201fe0a5444d2b61277178fb1c851b7f55e..813c9769895bfcea728722bc66735bc2fafcfc78 100644 --- a/VectoCore/VectoCoreTest/TestData/Components/Axle.vtlm +++ b/VectoCore/VectoCoreTest/TestData/Components/Axle.vtlm @@ -1,5 +1,7 @@ -Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm],Eff [-] -0,-2500,77.5 +Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm] # this is a comment +# rpm, Nm, Nm +# this is a comment +0,-2500,77.5 # this is a comment 0,-1500,62.5 0,-500,47.5 0,500,47.5 @@ -7,6 +9,7 @@ Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm],Eff [-] 0,2500,77.5 0,3500,92.5 0,4500,107.5 +# this is a comment 0,5500,122.5 0,6500,137.5 0,7500,152.5 diff --git a/VectoCore/VectoCoreTest/TestData/test.csv b/VectoCore/VectoCoreTest/TestData/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..2d26a450a2fe74a9e7df6f9c46ed0ec96f080974 --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/test.csv @@ -0,0 +1,3 @@ +a,b,c +1,2,3 +4,5,6 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index 4d3cffbdc1db8e62484f961c5f3586fa2d9f2722..483a3af3a20772e610a1ca3eceb46c3a15cd1ebc 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -77,6 +77,7 @@ <ItemGroup> <Compile Include="Dummy\EngineFLDTest.cs" /> <Compile Include="Exceptions\ExceptionTests.cs" /> + <Compile Include="FileIO\VectoCSVFileTest.cs" /> <Compile Include="FileIO\JsonTest.cs" /> <Compile Include="FileIO\SimulationDataReaderTest.cs" /> <Compile Include="GraphProgram.cs" /> @@ -1348,6 +1349,9 @@ <None Include="TestData\Results\Integration\job_1-Gear-Test-dist.vmod"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\test.csv"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <None Include="TestData\Cycles\EngineOnly_FullLoad.vdri">