diff --git a/Documentation/User Manual/5-input-and-output-files/VDRI.md b/Documentation/User Manual/5-input-and-output-files/VDRI.md index a243e8afd508925915d1ac96a41799ef5b712c45..15fa4504a37c970ded077afad67f24c8795da7e4 100644 --- a/Documentation/User Manual/5-input-and-output-files/VDRI.md +++ b/Documentation/User Manual/5-input-and-output-files/VDRI.md @@ -41,6 +41,10 @@ This driving cycle defines the target speed over distance. Vecto tries to achiev Header: **\<s>, \<v>, \<stop>***\[, \<Padd>]\[, \<grad>]\[, \<vair\_res>, \<vair\_beta>]\[, \<Aux\_ID>]* +**Bold columns** are mandatory. *Italic columns* are optional. Only the listed columns are allowed (no other columns!).<br /> +The order is not important when the headers are annotated with \<angle-brackets\> (less-than-sign "<" and greater-than-sign ">").<br /> +Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign "#". + | Identifier | Unit | Description | | ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **s** | [m] | Traveled distance. Must always be increasing. | @@ -67,6 +71,10 @@ Due to differences in the real and simulated shift strategies a short difference Header: **\<t>, \<v>***\[, \<grad>]\[, \<Padd>]\[, \<vair\_res>, \<vair\_beta>\]\[, \<Aux\_ID>]* +**Bold columns** are mandatory. *Italic columns* are optional. Only the listed columns are allowed (no other columns!).<br /> +The order is not important when the headers are annotated with \<angle-brackets\> (less-than-sign "<" and greater-than-sign ">").<br /> +Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign "#". + | Identifier | Unit | Description | | ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | **t** | [s] | The absolute time. Must always be increasing. | @@ -99,6 +107,10 @@ It is necessary to set the option 'Use gears/rpm\'s from driving cycle in the ** Header: **\<t>, \<v>, \<n>, \<gear>***\[, \<grad>]\[, \<Padd>]\[, \<vair\_res>, \<vair\_beta>]\[, \<Aux\_ID>\]* +**Bold columns** are mandatory. *Italic columns* are optional. Only the listed columns are allowed (no other columns!).<br /> +The order is not important when the headers are annotated with \<angle-brackets\> (less-than-sign "<" and greater-than-sign ">").<br /> +Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign "#". + | Identifier | Unit | Description | | ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | **t** | [s] | The absolute time. Must always be increasing. | @@ -125,6 +137,10 @@ This driving cycle defines the power measured at the wheels over time. Vecto tri Header: **\<t>, \<Pwheel>, \<gear>, \<n>***\[, \<Padd>]* +**Bold columns** are mandatory. *Italic columns* are optional. Only the listed columns are allowed (no other columns!).<br /> +The order is not important when the headers are annotated with \<angle-brackets\> (less-than-sign "<" and greater-than-sign ">").<br /> +Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign "#". + | Identifier | Unit | Quantity Description | | ---------- | ----- | ----------------------------------------------------------------------------------------------------------------- | | **t** | [s] | The absolute time. Must always be increasing. | @@ -148,6 +164,10 @@ This driving cycle directly defines the power or torque at the output shaft of t Header: **\<t>, \<n>, (\<Pe>|\<Me>)***\[, \<Padd>]* +**Bold columns** are mandatory. *Italic columns* are optional. Only the listed columns are allowed (no other columns!).<br /> +The order is not important when the headers are annotated with \<angle-brackets\> (less-than-sign "<" and greater-than-sign ">").<br /> +Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign "#". + | Identifier | Unit | Description | | ---------- | ----- | ----------------------------------------------------------------------------------------------------------------- | | **t** | [s] | The absolute time. Must always be increasing. | diff --git a/Documentation/User Manual/help.html b/Documentation/User Manual/help.html index 6de5236ab4610432082a6b5a0a29abfd85137a31..b5b8ae565b520f934f8db9eec6542eb692c0b4d1 100644 --- a/Documentation/User Manual/help.html +++ b/Documentation/User Manual/help.html @@ -4561,6 +4561,7 @@ Kneeling, UnknownCycleName, 0,</code></pre> <h3>Engineering Mode: Target-Speed, Distance-Based Cycle</h3> <p>This driving cycle defines the target speed over distance. Vecto tries to achieve and maintain this target speed.</p> <p>Header: <strong><s>, <v>, <stop></strong><em>[, <Padd>][, <grad>][, <vair_res>, <vair_beta>][, <Aux_ID>]</em></p> +<p><strong>Bold columns</strong> are mandatory. <em>Italic columns</em> are optional. Only the listed columns are allowed (no other columns!).<br /> The order is not important when the headers are annotated with <angle-brackets> (less-than-sign “<†and greater-than-sign “>â€).<br /> Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign “#â€.</p> <table> <colgroup> <col width="4%"></col> @@ -4664,6 +4665,7 @@ Kneeling, UnknownCycleName, 0,</code></pre> <h3>Engineering Mode: Measured-Speed, Time-Based Cycle</h3> <p>This driving cycle defines the actual measured speed over time. Vecto tries to simulate the vehicle model using this speed as the actual vehicle speed. Due to differences in the real and simulated shift strategies a short difference in speed could occur, but Vecto immediately tries to catch up after the gear is engaged again.</p> <p>Header: <strong><t>, <v></strong><em>[, <grad>][, <Padd>][, <vair_res>, <vair_beta>][, <Aux_ID>]</em></p> +<p><strong>Bold columns</strong> are mandatory. <em>Italic columns</em> are optional. Only the listed columns are allowed (no other columns!).<br /> The order is not important when the headers are annotated with <angle-brackets> (less-than-sign “<†and greater-than-sign “>â€).<br /> Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign “#â€.</p> <table style="width:100%;"> <colgroup> <col width="3%"></col> @@ -4764,6 +4766,7 @@ Kneeling, UnknownCycleName, 0,</code></pre> </div> </div> <p>Header: <strong><t>, <v>, <n>, <gear></strong><em>[, <grad>][, <Padd>][, <vair_res>, <vair_beta>][, <Aux_ID>]</em></p> +<p><strong>Bold columns</strong> are mandatory. <em>Italic columns</em> are optional. Only the listed columns are allowed (no other columns!).<br /> The order is not important when the headers are annotated with <angle-brackets> (less-than-sign “<†and greater-than-sign “>â€).<br /> Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign “#â€.</p> <table style="width:100%;"> <colgroup> <col width="3%"></col> @@ -4877,6 +4880,7 @@ Kneeling, UnknownCycleName, 0,</code></pre> <h3>Engineering Mode: Pwheel (SiCo), Time-Based</h3> <p>This driving cycle defines the power measured at the wheels over time. Vecto tries to simulate the vehicle with this power requirement.</p> <p>Header: <strong><t>, <Pwheel>, <gear>, <n></strong><em>[, <Padd>]</em></p> +<p><strong>Bold columns</strong> are mandatory. <em>Italic columns</em> are optional. Only the listed columns are allowed (no other columns!).<br /> The order is not important when the headers are annotated with <angle-brackets> (less-than-sign “<†and greater-than-sign “>â€).<br /> Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign “#â€.</p> <table> <colgroup> <col width="8%"></col> @@ -4965,6 +4969,7 @@ Kneeling, UnknownCycleName, 0,</code></pre> <h3>Engine Only Mode: Engine Only Driving Cycle</h3> <p>This driving cycle directly defines the power or torque at the output shaft of the engine over time. Vecto add the engine’s inertia to the given power demand and simulates the engine.</p> <p>Header: <strong><t>, <n>, (<Pe>|<Me>)</strong><em>[, <Padd>]</em></p> +<p><strong>Bold columns</strong> are mandatory. <em>Italic columns</em> are optional. Only the listed columns are allowed (no other columns!).<br /> The order is not important when the headers are annotated with <angle-brackets> (less-than-sign “<†and greater-than-sign “>â€).<br /> Units are optional and are enclosed in [square-brackets] after the header-column. Comments may be written with a preceding hash-sign “#â€.</p> <table> <colgroup> <col width="8%"></col> @@ -5432,12 +5437,32 @@ Kneeling, UnknownCycleName, 0,</code></pre> <tr class="even"> <td align="left">P_axle_in</td> <td align="left">[kW]</td> -<td align="left">Power at the axle-gear input shaft. P_axle_in = P_ret_in - P_ret_loss ( - P_angle_loss if an Angulargear is used)</td> +<td align="left">Power at the axle-gear input shaft. P_axle_in = P_ret_in - P_ret_loss ( - P_angle_loss if an Angulargear is used).</td> </tr> <tr class="odd"> <td align="left">P_axle_loss</td> <td align="left">[kW]</td> -<td align="left">Power loss at the axle gear, interpolated from the loss-map</td> +<td align="left">Power loss at the axle gear, interpolated from the loss-map.</td> +</tr> +<tr class="even"> +<td align="left">P_angle_in</td> +<td align="left">[kW]</td> +<td align="left">Power at the angle-gear input shaft.</td> +</tr> +<tr class="odd"> +<td align="left">P_angle_loss</td> +<td align="left">[kW]</td> +<td align="left">Power loss at the angle gear, interpolated from the loss-map.</td> +</tr> +<tr class="even"> +<td align="left">P_tc_in</td> +<td align="left">[kW]</td> +<td align="left">Power at the torque-converter input shaft.</td> +</tr> +<tr class="odd"> +<td align="left">P_tc_loss</td> +<td align="left">[kW]</td> +<td align="left">Power loss at the torque-converter.</td> </tr> <tr class="even"> <td align="left">P_brake_in</td> @@ -5447,7 +5472,7 @@ Kneeling, UnknownCycleName, 0,</code></pre> <tr class="odd"> <td align="left">P_brake_loss</td> <td align="left">[kW]</td> -<td align="left">Power loss due to braking</td> +<td align="left">Power loss due to braking.</td> </tr> <tr class="even"> <td align="left">P_wheel_in</td> @@ -5472,12 +5497,12 @@ Kneeling, UnknownCycleName, 0,</code></pre> <tr class="even"> <td align="left">P_air</td> <td align="left">[kW]</td> -<td align="left">Power loss due to air drag</td> +<td align="left">Power loss due to air drag.</td> </tr> <tr class="odd"> <td align="left">P_roll</td> <td align="left">[kW]</td> -<td align="left">Rolling resistance power loss</td> +<td align="left">Rolling resistance power loss.</td> </tr> <tr class="even"> <td align="left">P_veh_inertia</td> @@ -5669,7 +5694,7 @@ Kneeling, UnknownCycleName, 0,</code></pre> <tr class="odd"> <td align="left">FC-Final</td> <td align="left">[g/h], [g/km], [l/100km], [l/100tkm]</td> -<td align="left">Final average fuel consumption after ALL corrections. Value for calculation of CO<sub>2</sub> value. Output for [l/100tkm] is empty when Loading = 0[kg].</td> +<td align="left">Final average fuel consumption after ALL corrections. Value for calculation of CO<sub>2</sub> value. If Loading = 0[kg] the column [l/100tkm] is left empty.</td> </tr> <tr class="even"> <td align="left">CO2</td> @@ -5687,14 +5712,14 @@ Kneeling, UnknownCycleName, 0,</code></pre> <td align="left">Average brake power losses (not including engine drag)</td> </tr> <tr class="odd"> -<td align="left">P_eng_out_pos</td> +<td align="left">P_clutch_pos</td> <td align="left">[kW]</td> -<td align="left">Average positive engine power (all non-negative values averaged over the whole cycle duration)</td> +<td align="left">Average positive power at clutch (coming from engine) (all non-negative values averaged over the whole cycle duration)</td> </tr> <tr class="even"> -<td align="left">P_eng_out_neg</td> +<td align="left">P_clutch_neg</td> <td align="left">[kW]</td> -<td align="left">Average negative engine power (all non-positive values averaged over the whole cycle duration)</td> +<td align="left">Average negative power at clutch (coming from engine) (all non-positive values averaged over the whole cycle duration)</td> </tr> <tr class="odd"> <td align="left">E_aux_xxx</td> @@ -5747,46 +5772,51 @@ Kneeling, UnknownCycleName, 0,</code></pre> <td align="left">Total torque converter energy loss</td> </tr> <tr class="odd"> -<td align="left">E_eng_out_pos</td> +<td align="left">E_angle_loss</td> <td align="left">[kWh]</td> -<td align="left">Total positive engine work</td> +<td align="left">Total torque converter energy loss</td> </tr> <tr class="even"> -<td align="left">E_eng_out_neg</td> +<td align="left">E_clutch_pos</td> <td align="left">[kWh]</td> -<td align="left">Total negative engine work (engine drag)</td> +<td align="left">Total positive work at clutch input (produced by engine) (all non-negative values averaged over the whole cycle duration)</td> </tr> <tr class="odd"> +<td align="left">E_clutch_neg</td> +<td align="left">[kWh]</td> +<td align="left">Total negative work at clutch input (produced by engine drag) (all non-positive values averaged over the whole cycle duration)</td> +</tr> +<tr class="even"> <td align="left">a</td> <td align="left">[m/s<sup>2</sup>]</td> <td align="left">Average acceleration</td> </tr> -<tr class="even"> +<tr class="odd"> <td align="left">a_pos</td> <td align="left">[m/s<sup>2</sup>]</td> <td align="left">Average acceleration in acceleration phases (a<sub>3s</sub> > 0.125 [m/s<sup>2</sup>], a<sub>3s</sub> = 3-seconds-averaged acceleration)</td> </tr> -<tr class="odd"> +<tr class="even"> <td align="left">a_neg</td> <td align="left">[m/s<sup>2</sup>]</td> <td align="left">Average deceleration in deceleration phases (a<sub>3s</sub> < 0.125 [m/s<sup>2</sup>], a<sub>3s</sub> = 3-seconds-averaged acceleration)</td> </tr> -<tr class="even"> +<tr class="odd"> <td align="left">AccelerationTimeShare</td> <td align="left">[%]</td> <td align="left">Time share of acceleration phases (a<sub>3s</sub> > 0.125 [m/s<sup>2</sup>], a<sub>3s</sub> = 3-seconds-averaged acceleration)</td> </tr> -<tr class="odd"> +<tr class="even"> <td align="left">DecelerationTimeShare</td> <td align="left">[%]</td> <td align="left">Time share of deceleration phases (a<sub>3s</sub> < 0.125 [m/s<sup>2</sup>], a<sub>3s</sub> = 3-seconds-averaged acceleration)</td> </tr> -<tr class="even"> +<tr class="odd"> <td align="left">CruiseTimeShare</td> <td align="left">[%]</td> <td align="left">Time share of cruise phases (-0.125 ≤ a<sub>3s</sub> ≤ 0.125 [m/s<sup>2</sup>])</td> </tr> -<tr class="odd"> +<tr class="even"> <td align="left">StopTimeShare</td> <td align="left">[%]</td> <td align="left">Time share of stop phases (v < 0.1 [m/s])</td> diff --git a/VECTO/File Browser/FB_Dialog.vb b/VECTO/File Browser/FB_Dialog.vb index 2c047cd2f6beacba3c7f42de3f7707f603cc9c6c..a9e7deecdcb779cc65ebcf7600aacd6a38502210 100644 --- a/VECTO/File Browser/FB_Dialog.vb +++ b/VECTO/File Browser/FB_Dialog.vb @@ -50,7 +50,7 @@ Public Class FB_Dialog _myId = "Default" _updateLock = False _initialized = False - _myFolder = "" + _myFolder = "." _myDrive = "" _lastFile = "" _bOverwriteCheck = False diff --git a/VECTO/GUI/F_GBX.Designer.vb b/VECTO/GUI/F_GBX.Designer.vb index 897c3179f8dbf5957e3be193cf2370d85c05b0b4..54e7839d598fe4615bfbecdf9ef2b217b1fb0bce 100644 --- a/VECTO/GUI/F_GBX.Designer.vb +++ b/VECTO/GUI/F_GBX.Designer.vb @@ -50,7 +50,7 @@ Partial Class F_GBX Me.TbTracInt = New System.Windows.Forms.TextBox() Me.LvGears = New System.Windows.Forms.ListView() Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) - Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + 'Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) 'TC Column Me.ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader5 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) @@ -257,7 +257,7 @@ Partial Class F_GBX ' 'LvGears ' - Me.LvGears.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader4, Me.ColumnHeader2, Me.ColumnHeader3, Me.ColumnHeader5, Me.ColumnHeader6}) + Me.LvGears.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2, Me.ColumnHeader3, Me.ColumnHeader5, Me.ColumnHeader6}) Me.LvGears.FullRowSelect = True Me.LvGears.GridLines = True Me.LvGears.HideSelection = False @@ -273,32 +273,32 @@ Partial Class F_GBX 'ColumnHeader1 ' Me.ColumnHeader1.Text = "Gear" - Me.ColumnHeader1.Width = 40 + Me.ColumnHeader1.Width = 46 ' - 'ColumnHeader4 - ' - Me.ColumnHeader4.Text = "TC" - Me.ColumnHeader4.Width = 31 + ''ColumnHeader4 + '' + 'Me.ColumnHeader4.Text = "TC" + 'Me.ColumnHeader4.Width = 31 ' 'ColumnHeader2 ' Me.ColumnHeader2.Text = "Ratio" - Me.ColumnHeader2.Width = 43 + Me.ColumnHeader2.Width = 50 ' 'ColumnHeader3 ' Me.ColumnHeader3.Text = "Loss Map or Efficiency" - Me.ColumnHeader3.Width = 122 + Me.ColumnHeader3.Width = 128 ' 'ColumnHeader5 ' Me.ColumnHeader5.Text = "Shift Polygons" - Me.ColumnHeader5.Width = 88 + Me.ColumnHeader5.Width = 94 ' 'ColumnHeader6 ' Me.ColumnHeader6.Text = "Full Load Curve" - Me.ColumnHeader6.Width = 89 + Me.ColumnHeader6.Width = 95 ' 'TBI_getr ' diff --git a/VECTO/GUI/F_GBX.vb b/VECTO/GUI/F_GBX.vb index 8a56a6fa456fd438df6d652220a49b443eb2b508..c034e2940ac1e14180ac1d2cabb4d1373a4e3069 100644 --- a/VECTO/GUI/F_GBX.vb +++ b/VECTO/GUI/F_GBX.vb @@ -25,6 +25,15 @@ Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ''' </summary> ''' <remarks></remarks> Public Class F_GBX + Private Enum GearboxTbl + GearNr = 0 + 'TorqueConverter = 1 + Ratio = 1 + LossMapEfficiency = 2 + ShiftPolygons = 3 + FullLoadCurve = 4 + End Enum + Private GbxFile As String = "" Public AutoSendTo As Boolean = False Public JobDir As String = "" @@ -92,7 +101,7 @@ Public Class F_GBX tbUpshiftAfterDownshift.Text = cDeclaration.UpshiftAfterDownshiftDelay For Each lv0 In Me.LvGears.Items - lv0.SubItems(4).Text = "-" + lv0.SubItems(GearboxTbl.ShiftPolygons).Text = "-" Next End Sub @@ -155,7 +164,7 @@ Public Class F_GBX 'New file Private Sub newGBX() - Dim lvi As ListViewItem + 'Dim lvi As ListViewItem If ChangeCheckCancel() Then Exit Sub @@ -167,13 +176,7 @@ Public Class F_GBX Me.LvGears.Items.Clear() - lvi = New ListViewItem("Axle") - lvi.SubItems.Add("-") - lvi.SubItems.Add("0") - lvi.SubItems.Add("0") - lvi.SubItems.Add("") - lvi.SubItems.Add("") - Me.LvGears.Items.Add(lvi) + Me.LvGears.Items.Add(CreateListviewItem("Axle", "-", 0, 0, "", "")) 'Me.ChSkipGears.Checked = False 'set by CbGStype.SelectedIndexChanged 'Me.ChShiftInside.Checked = False 'set by CbGStype.SelectedIndexChanged @@ -202,7 +205,7 @@ Public Class F_GBX Public Sub openGBX(ByVal file As String) Dim GBX0 As cGBX Dim i As Integer - Dim lv0 As ListViewItem + 'Dim lv0 As ListViewItem If ChangeCheckCancel() Then Exit Sub @@ -239,26 +242,15 @@ Public Class F_GBX For i = 0 To GBX0.Igetr.Count - 1 If i = 0 Then - lv0 = New ListViewItem("Axle") + 'lv0 = New ListViewItem("Axle") + Me.LvGears.Items.Add(CreateListviewItem("Axle", "-", GBX0.Igetr(i), GBX0.GetrMap(i, True), GBX0.gsFile(i, True), + GBX0.FldFile(i, True))) Else - lv0 = New ListViewItem(i.ToString("00")) + 'lv0 = New ListViewItem(i.ToString("00")) + Me.LvGears.Items.Add(CreateListviewItem(i.ToString("00"), "-", GBX0.Igetr(i), GBX0.GetrMap(i, True), GBX0.gsFile(i, True), + GBX0.FldFile(i, True))) End If - 'If Me.ChTCon.Checked And i > 0 Then - ' If False Then ' GBX0.IsTCgear(i) Then - ' lv0.SubItems.Add("on") - ' Else - ' lv0.SubItems.Add("off") - ' End If - 'Else - lv0.SubItems.Add("-") - 'End If - lv0.SubItems.Add(GBX0.Igetr(i)) - lv0.SubItems.Add(GBX0.GetrMap(i, True)) - lv0.SubItems.Add(GBX0.gsFile(i, True)) - lv0.SubItems.Add(GBX0.FldFile(i, True)) - - Me.LvGears.Items.Add(lv0) Next Me.ChSkipGears.Checked = GBX0.gs_SkipGears @@ -296,6 +288,17 @@ Public Class F_GBX UpdatePic() End Sub + Private Function CreateListviewItem(gear As String, tc As String, ratio As Single, getrMap As String, + shiftPolygon As String, fldFile As String) As ListViewItem + Dim retVal As ListViewItem = New ListViewItem(gear) + 'retVal.SubItems.Add(tc) + retVal.SubItems.Add(ratio) + retVal.SubItems.Add(getrMap) + retVal.SubItems.Add(shiftPolygon) + retVal.SubItems.Add(fldFile) + Return retVal + End Function + 'Save or Save As function = true if file is saved Private Function SaveOrSaveAs(ByVal SaveAs As Boolean) As Boolean If GbxFile = "" Or SaveAs Then @@ -323,14 +326,14 @@ Public Class F_GBX GBX0.GbxInertia = fTextboxToNumString(Me.TBI_getr.Text) For i = 0 To Me.LvGears.Items.Count - 1 - 'GBX0.IsTCgear.Add(Me.LvGears.Items(i).SubItems(1).Text = "on" And i > 0) - GBX0.Igetr.Add(CSng(Me.LvGears.Items(i).SubItems(2).Text)) + 'GBX0.IsTCgear.Add(Me.LvGears.Items(i).SubItems(GearboxTbl.TorqueConverter).Text = "on" And i > 0) + GBX0.Igetr.Add(CSng(Me.LvGears.Items(i).SubItems(GearboxTbl.Ratio).Text)) GBX0.GetrMaps.Add(New cSubPath) - GBX0.GetrMap(i) = Me.LvGears.Items(i).SubItems(3).Text + GBX0.GetrMap(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.LossMapEfficiency).Text GBX0.gs_files.Add(New cSubPath) - GBX0.gsFile(i) = Me.LvGears.Items(i).SubItems(4).Text + GBX0.gsFile(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.ShiftPolygons).Text GBX0.FldFiles.Add(New cSubPath) - GBX0.FldFile(i) = Me.LvGears.Items(i).SubItems(5).Text + GBX0.FldFile(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.FullLoadCurve).Text Next GBX0.gs_TorqueResv = fTextboxToNumString(Me.TbTqResv.Text) @@ -547,15 +550,13 @@ Public Class F_GBX GearDia.PnShiftPoly.Enabled = (Not Cfg.DeclMode And Me.LvGears.SelectedIndices(0) > 0) GearDia.PnFld.Enabled = (Me.LvGears.SelectedIndices(0) > 0) GearDia.GbxPath = fPATH(GbxFile) - GearDia.TbGear.Text = Me.LvGears.SelectedItems(0).SubItems(0).Text - GearDia.TbRatio.Text = Me.LvGears.SelectedItems(0).SubItems(2).Text - GearDia.TbMapPath.Text = Me.LvGears.SelectedItems(0).SubItems(3).Text + GearDia.TbGear.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.GearNr).Text + GearDia.TbRatio.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text + GearDia.TbMapPath.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text If Me.LvGears.SelectedIndices(0) > 0 Then - GearDia.ChIsTCgear.Checked = (Me.ChTCon.Checked And Me.LvGears.SelectedItems(0).SubItems(1).Text = "on") - GearDia.TbShiftPolyFile.Text = Me.LvGears.SelectedItems(0).SubItems(4).Text - GearDia.TbFld.Text = Me.LvGears.SelectedItems(0).SubItems(5).Text + GearDia.TbShiftPolyFile.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text + GearDia.TbFld.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.FullLoadCurve).Text Else - GearDia.ChIsTCgear.Checked = False GearDia.TbShiftPolyFile.Text = "" GearDia.TbFld.Text = "" End If @@ -568,27 +569,20 @@ Public Class F_GBX If GearDia.ShowDialog = Windows.Forms.DialogResult.OK Then - 'If GearDia.ChIsTCgear.Checked Then - ' Me.LvGears.SelectedItems(0).SubItems(1).Text = "on" - 'Else - ' If Me.ChTCon.Checked Then - ' Me.LvGears.SelectedItems(0).SubItems(1).Text = "off" - ' Else - Me.LvGears.SelectedItems(0).SubItems(1).Text = "-" - ' End If - 'End If - - Me.LvGears.SelectedItems(0).SubItems(2).Text = GearDia.TbRatio.Text - Me.LvGears.SelectedItems(0).SubItems(3).Text = GearDia.TbMapPath.Text - Me.LvGears.SelectedItems(0).SubItems(4).Text = GearDia.TbShiftPolyFile.Text - Me.LvGears.SelectedItems(0).SubItems(5).Text = GearDia.TbFld.Text + 'Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.TorqueConverter).Text = "-" + + + Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text = GearDia.TbRatio.Text + Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text = GearDia.TbMapPath.Text + Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text = GearDia.TbShiftPolyFile.Text + Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.FullLoadCurve).Text = GearDia.TbFld.Text UpdatePic() Change() Else - If LvGears.SelectedItems(0).SubItems(2).Text = "" Then RemoveGear(True) + If LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text = "" Then RemoveGear(True) End If @@ -609,16 +603,8 @@ Public Class F_GBX Private Sub AddGear() Dim lvi As ListViewItem - lvi = New ListViewItem(Me.LvGears.Items.Count.ToString("00")) - 'If Me.ChTCon.Checked Then - ' lvi.SubItems.Add("off") - 'Else - lvi.SubItems.Add("-") - 'End If - lvi.SubItems.Add("") - lvi.SubItems.Add("") - lvi.SubItems.Add("") - lvi.SubItems.Add("") + lvi = CreateListviewItem(Me.LvGears.Items.Count.ToString("00"), "-", 1, "", "", "") + Me.LvGears.Items.Add(lvi) lvi.EnsureVisible() @@ -646,9 +632,9 @@ Public Class F_GBX i = 0 For Each lv0 In Me.LvGears.Items - If lv0.SubItems(0).Text = "Axle" Then Continue For + If lv0.SubItems(GearboxTbl.GearNr).Text = "Axle" Then Continue For i += 1 - lv0.SubItems(0).Text = i.ToString("00") + lv0.SubItems(GearboxTbl.GearNr).Text = i.ToString("00") Next If i0 < Me.LvGears.Items.Count Then @@ -729,12 +715,12 @@ Public Class F_GBX If Me.LvGears.Items.Count > 1 Then If Me.LvGears.SelectedItems.Count > 0 AndAlso Me.LvGears.SelectedIndices(0) > 0 Then - path = fFileRepl(Me.LvGears.SelectedItems(0).SubItems(4).Text, fPATH(GbxFile)) - fldpath = fFileRepl(Me.LvGears.SelectedItems(0).SubItems(5).Text, fPATH(GbxFile)) + path = fFileRepl(Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text, fPATH(GbxFile)) + fldpath = fFileRepl(Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.FullLoadCurve).Text, fPATH(GbxFile)) Gear = Me.LvGears.SelectedIndices(0) Else - path = fFileRepl(Me.LvGears.Items(1).SubItems(4).Text, fPATH(GbxFile)) - fldpath = fFileRepl(Me.LvGears.Items(1).SubItems(5).Text, fPATH(GbxFile)) + path = fFileRepl(Me.LvGears.Items(1).SubItems(GearboxTbl.ShiftPolygons).Text, fPATH(GbxFile)) + fldpath = fFileRepl(Me.LvGears.Items(1).SubItems(GearboxTbl.FullLoadCurve).Text, fPATH(GbxFile)) Gear = 1 End If @@ -824,7 +810,7 @@ Public Class F_GBX Dim vectoJob As cVECTO = New cVECTO() With {.FilePath = F_VECTO.VECTOfile} Dim vectoOk As Boolean = vectoJob.ReadFile() - Dim vehicle As cVEH = New cVEH() With {.FilePath = vectoJob.PathVEH(False)} + Dim vehicle As cVEH = New cVEH() With {.FilePath = vectoJob.PathVeh(False)} Dim vehicleOk As Boolean = vehicle.ReadFile(False) 'Fld @@ -845,37 +831,38 @@ Public Class F_GBX Shiftpoly.SetGenericShiftPoly(FLD0, F_VECTO.n_idle) 'Dim fullLoadCurve As FullLoadCurve = ConvertToFullLoadCurve(FLD0.LnU, FLD0.LTq) Dim gears As IList(Of ITransmissionInputData) = ConvertToGears(LvGears.Items) - Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle) - Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, engine.FullLoadCurve, gears, - engine, - Double.Parse(LvGears.Items(0).SubItems(2).Text, CultureInfo.InvariantCulture), - (vehicle.rdyn / 1000.0).SI(Of Meter)) - - s = New System.Windows.Forms.DataVisualization.Charting.Series - - 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) - s.Points.DataBindXY( - shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.BorderDashStyle = DataVisualization.Charting.ChartDashStyle.Dash - s.Name = "Upshift curve (generic)" - MyChart.Series.Add(s) - - s = New System.Windows.Forms.DataVisualization.Charting.Series - 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) - s.Points.DataBindXY( - shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) - s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.BorderDashStyle = DataVisualization.Charting.ChartDashStyle.Dash - s.Name = "Downshift curve (generic)" - MyChart.Series.Add(s) - + If (gears.Count > 1) Then + Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle) + Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, engine.FullLoadCurve, gears, + engine, + Double.Parse(LvGears.Items(0).SubItems(GearboxTbl.Ratio).Text, CultureInfo.InvariantCulture), + (vehicle.rdyn / 1000.0).SI(Of Meter)) + + s = New System.Windows.Forms.DataVisualization.Charting.Series + + 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) + s.Points.DataBindXY( + shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) + s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkRed + s.BorderDashStyle = DataVisualization.Charting.ChartDashStyle.Dash + s.Name = "Upshift curve (generic)" + MyChart.Series.Add(s) + + s = New System.Windows.Forms.DataVisualization.Charting.Series + 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) + s.Points.DataBindXY( + shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) + s.ChartType = DataVisualization.Charting.SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkRed + s.BorderDashStyle = DataVisualization.Charting.ChartDashStyle.Dash + s.Name = "Downshift curve (generic)" + MyChart.Series.Add(s) + End If End If End If @@ -937,7 +924,9 @@ Public Class F_GBX Dim value As Double For i As Integer = 1 To gbx.Count - 1 - If gbx(i).SubItems(2).Text <> "" AndAlso Double.TryParse(gbx(i).SubItems(2).Text, value) Then + If _ + gbx(i).SubItems(GearboxTbl.Ratio).Text <> "" AndAlso Double.TryParse(gbx(i).SubItems(GearboxTbl.Ratio).Text, value) _ + Then retVal.Add( New TransmissionInputData() _ With {.Ratio = Double.Parse(value, CultureInfo.InvariantCulture)}) @@ -976,17 +965,9 @@ Public Class F_GBX For Each lv0 In Me.LvGears.Items - If lv0.SubItems(0).Text = "Axle" Then Continue For - - 'If Me.ChTCon.Checked Then - ' If lv0.Index = 1 Then - ' lv0.SubItems(1).Text = "on" - ' Else - ' lv0.SubItems(1).Text = "off" - ' End If - 'Else - lv0.SubItems(1).Text = "-" - 'End If + If lv0.SubItems(GearboxTbl.GearNr).Text = "Axle" Then Continue For + + 'lv0.SubItems(GearboxTbl.TorqueConverter).Text = "-" Next End Sub diff --git a/VECTO/GUI/F_MAINForm.Designer.vb b/VECTO/GUI/F_MAINForm.Designer.vb index b08a2f58b2f69cbce35d2caba24d13d17d537d2a..0ff00e8a52c21fe7c749defc41a90f84ea062fe2 100644 --- a/VECTO/GUI/F_MAINForm.Designer.vb +++ b/VECTO/GUI/F_MAINForm.Designer.vb @@ -252,7 +252,7 @@ Partial Class F_MAINForm ' Me.LbDecl.AutoSize = True Me.LbDecl.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.LbDecl.Location = New System.Drawing.Point(3, 118) + Me.LbDecl.Location = New System.Drawing.Point(5, 109) Me.LbDecl.Name = "LbDecl" Me.LbDecl.Size = New System.Drawing.Size(107, 13) Me.LbDecl.TabIndex = 19 diff --git a/VECTO/GUI/GearboxGearDialog.Designer.vb b/VECTO/GUI/GearboxGearDialog.Designer.vb index ae070b253468a2bbe5dd7b4e814ea467701f8c24..33be827cdf75b836065eb446074aa4b10b625b64 100644 --- a/VECTO/GUI/GearboxGearDialog.Designer.vb +++ b/VECTO/GUI/GearboxGearDialog.Designer.vb @@ -34,7 +34,6 @@ Partial Class GearboxGearDialog Me.Label3 = New System.Windows.Forms.Label() Me.BtBrowse = New System.Windows.Forms.Button() Me.BtNext = New System.Windows.Forms.Button() - Me.ChIsTCgear = New System.Windows.Forms.CheckBox() Me.TbShiftPolyFile = New System.Windows.Forms.TextBox() Me.BtShiftPolyBrowse = New System.Windows.Forms.Button() Me.Label4 = New System.Windows.Forms.Label() @@ -155,16 +154,6 @@ Partial Class GearboxGearDialog Me.BtNext.Text = "&Next >" Me.BtNext.UseVisualStyleBackColor = True ' - 'ChIsTCgear - ' - Me.ChIsTCgear.AutoSize = True - Me.ChIsTCgear.Location = New System.Drawing.Point(236, 8) - Me.ChIsTCgear.Name = "ChIsTCgear" - Me.ChIsTCgear.Size = New System.Drawing.Size(241, 17) - Me.ChIsTCgear.TabIndex = 4 - Me.ChIsTCgear.Text = "Torque Conveter active (lock-up clutch open)" - Me.ChIsTCgear.UseVisualStyleBackColor = True - ' 'TbShiftPolyFile ' Me.TbShiftPolyFile.Location = New System.Drawing.Point(2, 17) @@ -267,7 +256,6 @@ Partial Class GearboxGearDialog Me.Controls.Add(Me.BtPrevious) Me.Controls.Add(Me.PnFld) Me.Controls.Add(Me.PnShiftPoly) - Me.Controls.Add(Me.ChIsTCgear) Me.Controls.Add(Me.BtNext) Me.Controls.Add(Me.BtBrowse) Me.Controls.Add(Me.Label3) @@ -304,7 +292,6 @@ Partial Class GearboxGearDialog Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents BtBrowse As System.Windows.Forms.Button Friend WithEvents BtNext As System.Windows.Forms.Button - Friend WithEvents ChIsTCgear As System.Windows.Forms.CheckBox Friend WithEvents TbShiftPolyFile As System.Windows.Forms.TextBox Friend WithEvents BtShiftPolyBrowse As System.Windows.Forms.Button Friend WithEvents Label4 As System.Windows.Forms.Label diff --git a/VECTO/GUI/GearboxGearDialog.resx b/VECTO/GUI/GearboxGearDialog.resx index 598ef8b7aa8909d4d36c9bde49528edd90c8ae6c..8547a1a13733e7be98a611d6e03f887a46cb2616 100644 --- a/VECTO/GUI/GearboxGearDialog.resx +++ b/VECTO/GUI/GearboxGearDialog.resx @@ -121,7 +121,7 @@ <data name="BtBrowse.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 @@ -139,7 +139,7 @@ <data name="BtShiftPolyBrowse.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 @@ -157,7 +157,7 @@ <data name="BtBrowseFld.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index 150b39398b0faec56f498fb2f9edc78f43c99893..d8b0f2f0aacfbbd861ec2d399228573b117f09c3 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -43,6 +43,8 @@ namespace TUGraz.VectoCore.Configuration public static class Auxiliaries { + public const string Prefix = "AUX_"; + public static class IDs { public const string Fan = "FAN"; diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 4beadb4e3832b92c5d3ff465544e5c1ea5a48b67..7cf371289223d3220949c55caac80a09bad39a0a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -476,10 +476,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { var retVal = new List<AuxiliaryDataInputData>(); foreach (var aux in Body["Aux"] ?? Enumerable.Empty<JToken>()) { - var type = (AuxiliaryType)0; - try { - type = AuxiliaryTypeHelper.Parse(aux.GetEx<string>("Type")); - } catch (ArgumentOutOfRangeException) {} + var type = AuxiliaryTypeHelper.Parse(aux.GetEx<string>("Type")); var auxData = new AuxiliaryDataInputData { ID = aux.GetEx<string>("ID"), @@ -581,10 +578,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON aux.GetEx<string>("ID")); } - var type = (AuxiliaryType)0; - try { - type = AuxiliaryTypeHelper.Parse(aux.GetEx<string>("Type")); - } catch (ArgumentOutOfRangeException) {} + var type = AuxiliaryTypeHelper.Parse(aux.GetEx<string>("Type")); var auxData = new AuxiliaryDataInputData { ID = aux.GetEx<string>("ID"), diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs index 47ba95d989897ddc8ed9804e754225ddcb23a88a..3237bc773b1a9ed346e2c5cf97478d88eb2c5ac6 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs @@ -10,7 +10,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader.ComponentData { - public sealed class AuxiliaryDataReader + public static class AuxiliaryDataReader { public static AuxiliaryData Create(IAuxiliaryEngineeringInputData data) { @@ -34,7 +34,6 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var map = ReadAuxMap(id, table); return new AuxiliaryData(transmissionRatio, efficiencyToEngine, efficiencyToSupply, map); - } catch (FileNotFoundException e) { throw new VectoException("Auxiliary file not found: " + fileName, e); } @@ -85,19 +84,13 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData public static class Fields { - /// <summary> - /// [1/min] - /// </summary> + /// <summary>[1/min]</summary> public const string AuxSpeed = "Auxiliary speed"; - /// <summary> - /// [kW] - /// </summary> + /// <summary>[kW]</summary> public const string MechPower = "Mechanical power"; - /// <summary> - /// [kW] - /// </summary> + /// <summary>[kW]</summary> public const string SupplyPower = "Supply power"; } } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs index e6304bf963b02bd9349bc0aada9a9f1233c5308a..cfd08c4c2e6f933add7b332836a2b71430c84f35 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs @@ -69,10 +69,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox new TransmissionLossMap.GearLossMapEntry(0.RPMtoRad(), -1e5.SI<NewtonMeter>(), (1 - efficiency) * 1e5.SI<NewtonMeter>()), new TransmissionLossMap.GearLossMapEntry(0.RPMtoRad(), 0.SI<NewtonMeter>(), 0.SI<NewtonMeter>()), - new TransmissionLossMap.GearLossMapEntry(5000.RPMtoRad(), 0.SI<NewtonMeter>(), 0.SI<NewtonMeter>()), - new TransmissionLossMap.GearLossMapEntry(5000.RPMtoRad(), -1e5.SI<NewtonMeter>(), + new TransmissionLossMap.GearLossMapEntry(10000.RPMtoRad(), 0.SI<NewtonMeter>(), 0.SI<NewtonMeter>()), + new TransmissionLossMap.GearLossMapEntry(10000.RPMtoRad(), -1e5.SI<NewtonMeter>(), (1 - efficiency) * 1e5.SI<NewtonMeter>()), - new TransmissionLossMap.GearLossMapEntry(5000.RPMtoRad(), 1e5.SI<NewtonMeter>(), + new TransmissionLossMap.GearLossMapEntry(10000.RPMtoRad(), 1e5.SI<NewtonMeter>(), (1 - efficiency) * 1e5.SI<NewtonMeter>()), }; return new TransmissionLossMap(entries, gearRatio, gearName); diff --git a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs index 8d16fbe2651f5ae3c04b3f828860381851b1fa02..f4fc790a2153fe369f75c6baad86caae12f4cf3b 100644 --- a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs @@ -43,7 +43,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader { - public class DrivingCycleDataReader : LoggingObject + public static class DrivingCycleDataReader { /// <summary> /// Detects the appropriate cycle type for a cycle in a DataTable. @@ -136,7 +136,8 @@ namespace TUGraz.VectoCore.InputData.Reader public static DrivingCycleData ReadFromDataTable(DataTable data, string name, bool crossWindRequired) { if (data == null) { - Logger<DistanceBasedCycleDataParser>().Warn("Invalid data for DrivingCycle -- dataTable is null"); + LogManager.GetLogger(typeof(DrivingCycleDataReader).FullName) + .Warn("Invalid data for DrivingCycle -- dataTable is null"); throw new VectoException("Invalid data for DrivingCycle -- dataTable is null"); } return ReadFromDataTable(data, DetectCycleType(data), name, crossWindRequired); @@ -153,7 +154,8 @@ namespace TUGraz.VectoCore.InputData.Reader public static DrivingCycleData ReadFromDataTable(DataTable data, CycleType type, string name, bool crossWindRequired) { if (data == null) { - Logger<DistanceBasedCycleDataParser>().Warn("Invalid data for DrivingCycle -- dataTable is null"); + LogManager.GetLogger(typeof(DrivingCycleDataReader).FullName) + .Warn("Invalid data for DrivingCycle -- dataTable is null"); throw new VectoException("Invalid data for DrivingCycle -- dataTable is null"); } var entries = GetDataParser(type).Parse(data, crossWindRequired).ToList(); @@ -232,7 +234,7 @@ namespace TUGraz.VectoCore.InputData.Reader distance = entry.Distance; } - Logger<DrivingCycleDataReader>() + LogManager.GetLogger(typeof(DrivingCycleDataReader).FullName) .Info("Data loaded. Number of Entries: {0}, filtered Entries: {1}", entries.Count, filtered.Count); entries = filtered; @@ -243,13 +245,14 @@ namespace TUGraz.VectoCore.InputData.Reader private static void AdjustDistanceAfterStop(List<DrivingCycleData.DrivingCycleEntry> entries) { - var currentIt = entries.GetEnumerator(); - var nextIt = entries.GetEnumerator(); - nextIt.MoveNext(); - while (currentIt.MoveNext() && nextIt.MoveNext()) { - if (currentIt.Current != null && !currentIt.Current.StoppingTime.IsEqual(0)) { - if (nextIt.Current != null) { - nextIt.Current.Distance = currentIt.Current.Distance; + using (var currentIt = entries.GetEnumerator()) + using (var nextIt = entries.GetEnumerator()) { + nextIt.MoveNext(); + while (currentIt.MoveNext() && nextIt.MoveNext()) { + if (currentIt.Current != null && !currentIt.Current.StoppingTime.IsEqual(0)) { + if (nextIt.Current != null) { + nextIt.Current.Distance = currentIt.Current.Distance; + } } } } @@ -297,7 +300,6 @@ namespace TUGraz.VectoCore.InputData.Reader public const string VehicleSpeed = "v"; public const string RoadGradient = "grad"; public const string StoppingTime = "stop"; - public const string AuxiliarySupplyPower = "Aux_"; public const string EngineSpeed = "n"; public const string Gear = "gear"; public const string AdditionalAuxPowerDemand = "Padd"; @@ -320,7 +322,7 @@ namespace TUGraz.VectoCore.InputData.Reader IEnumerable<DrivingCycleData.DrivingCycleEntry> Parse(DataTable table, bool crossWindRequired); } - private abstract class AbstractCycleDataParser : ICycleDataParser + private abstract class AbstractCycleDataParser : LoggingObject, ICycleDataParser { protected static bool CheckColumns(string[] header, IEnumerable<string> allowedCols, IEnumerable<string> requiredCols, bool throwExceptions, bool allowAux) @@ -334,7 +336,7 @@ namespace TUGraz.VectoCore.InputData.Reader } if (allowAux) { - header = header.Where(c => !c.StartsWith(Fields.AuxiliarySupplyPower)).ToArray(); + header = header.Where(c => !c.ToUpper().StartsWith(Constants.Auxiliaries.Prefix)).ToArray(); } diff = header.Except(allowedCols).ToList(); @@ -395,28 +397,32 @@ namespace TUGraz.VectoCore.InputData.Reader public static bool ValidateHeader(string[] header, bool throwExceptions = true) { var requiredCols = new[] { - Fields.VehicleSpeed, Fields.Distance, + Fields.VehicleSpeed, Fields.StoppingTime }; var allowedCols = new[] { Fields.Distance, Fields.VehicleSpeed, - Fields.RoadGradient, Fields.StoppingTime, - Fields.EngineSpeed, - Fields.Gear, Fields.AdditionalAuxPowerDemand, + Fields.RoadGradient, Fields.AirSpeedRelativeToVehicle, Fields.WindYawAngle }; - return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux: true) && + var allowAux = true; + + return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux) && CheckComboColumns(header, new[] { Fields.AirSpeedRelativeToVehicle, Fields.WindYawAngle }, throwExceptions); } } + /// <summary> + /// Parser for EngineOnly Cycles. + /// </summary> + // <t>, <n>, (<Pe>|<Me>)[, <Padd>] private class EngineOnlyCycleDataParser : AbstractCycleDataParser { public override IEnumerable<DrivingCycleData.DrivingCycleEntry> Parse(DataTable table, bool crossWindRequired) @@ -454,6 +460,11 @@ namespace TUGraz.VectoCore.InputData.Reader public static bool ValidateHeader(string[] header, bool throwExceptions = true) { + var requiredCols = new[] { + //Fields.Time not needed --> if missing 1 second resolution is assumed + Fields.EngineSpeed + }; + var allowedCols = new[] { Fields.Time, Fields.EngineSpeed, @@ -462,11 +473,9 @@ namespace TUGraz.VectoCore.InputData.Reader Fields.AdditionalAuxPowerDemand }; - var requiredCols = new[] { - Fields.EngineSpeed - }; + var allowAux = false; - if (!CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux: false)) { + if (!CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux)) { return false; } @@ -481,8 +490,9 @@ namespace TUGraz.VectoCore.InputData.Reader var containsBoth = header.Contains(Fields.EngineTorque) && header.Contains(Fields.EnginePower); if (containsBoth) { - Logger<DrivingCycleDataReader>().Warn("Found column '{0}' and column '{1}': Only column '{0}' will be used.", - Fields.EngineTorque, Fields.EnginePower); + LogManager.GetLogger(typeof(EngineOnlyCycleDataParser).FullName) + .Warn("Found column '{0}' and column '{1}': Only column '{0}' will be used.", + Fields.EngineTorque, Fields.EnginePower); } return true; } @@ -511,28 +521,30 @@ namespace TUGraz.VectoCore.InputData.Reader public static bool ValidateHeader(string[] header, bool throwExceptions = true) { - var allowedCols = new[] { + var requiredCols = new[] { Fields.Time, Fields.PWheel, Fields.Gear, - Fields.EngineSpeed, - Fields.AdditionalAuxPowerDemand + Fields.EngineSpeed }; - var requiredCols = new[] { + var allowedCols = new[] { Fields.Time, Fields.PWheel, Fields.Gear, - Fields.EngineSpeed + Fields.EngineSpeed, + Fields.AdditionalAuxPowerDemand }; - return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux: false); + var allowAux = false; + + return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux); } } /// <summary> /// Parser for Measured Speed Mode Option 1. /// </summary> - // <t>, <v>, <grad>, <Padd>[, <vair_res>, <vair_beta>][, Aux_...] + // <t>, <v>[, <grad>, <Padd>, <vair_res>, <vair_beta>, Aux_...] private class MeasuredSpeedDataParser : AbstractCycleDataParser { public override IEnumerable<DrivingCycleData.DrivingCycleEntry> Parse(DataTable table, bool crossWindRequired) @@ -555,21 +567,23 @@ namespace TUGraz.VectoCore.InputData.Reader public static bool ValidateHeader(string[] header, bool throwExceptions = true) { + var requiredCols = new[] { + Fields.Time, + Fields.VehicleSpeed + }; + var allowedCols = new[] { Fields.Time, Fields.VehicleSpeed, - Fields.RoadGradient, Fields.AdditionalAuxPowerDemand, + Fields.RoadGradient, Fields.AirSpeedRelativeToVehicle, Fields.WindYawAngle }; - var requiredCols = new[] { - Fields.Time, - Fields.VehicleSpeed, - Fields.RoadGradient, - }; - return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux: true) && + var allowAux = true; + + return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux) && CheckComboColumns(header, new[] { Fields.AirSpeedRelativeToVehicle, Fields.WindYawAngle }, throwExceptions); } } @@ -577,7 +591,7 @@ namespace TUGraz.VectoCore.InputData.Reader /// <summary> /// Parser for Measured Speed Mode Option 2. /// </summary> - // <t>, <v>, <grad>, <Padd>, <n>, <gear>[, <vair_res>, <vair_beta>][, Aux_...] + // <t>, <v>, <n>, <gear>[, <grad>, <Padd>, <vair_res>, <vair_beta>, Aux_...] private class MeasuredSpeedGearDataParser : AbstractCycleDataParser { public override IEnumerable<DrivingCycleData.DrivingCycleEntry> Parse(DataTable table, bool crossWindRequired) @@ -602,26 +616,26 @@ namespace TUGraz.VectoCore.InputData.Reader public static bool ValidateHeader(string[] header, bool throwExceptions = true) { + var requiredCols = new[] { + Fields.Time, + Fields.VehicleSpeed, + Fields.EngineSpeed, + Fields.Gear + }; var allowedCols = new[] { Fields.Time, Fields.VehicleSpeed, - Fields.RoadGradient, - Fields.AdditionalAuxPowerDemand, Fields.EngineSpeed, Fields.Gear, + Fields.AdditionalAuxPowerDemand, + Fields.RoadGradient, Fields.AirSpeedRelativeToVehicle, Fields.WindYawAngle }; - var requiredCols = new[] { - Fields.Time, - Fields.VehicleSpeed, - Fields.RoadGradient, - Fields.EngineSpeed, - Fields.Gear - }; + var allowAux = true; - return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux: true) && + return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux) && CheckComboColumns(header, new[] { Fields.AirSpeedRelativeToVehicle, Fields.WindYawAngle }, throwExceptions); } } diff --git a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs index 31a73f78d5bcd38017592d788635af74350649ee..3dc38204ca63f0b23e93b9893343ac66fb3abdf4 100644 --- a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs +++ b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs @@ -22,10 +22,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static AuxiliaryType Parse(string s) { AuxiliaryType aux; - if (StrToAux.TryGetValue(s, out aux)) - return aux; - - throw new ArgumentOutOfRangeException("s", s, "Could not parse auxiliary type string."); + return StrToAux.TryGetValue(s, out aux) ? aux : AuxiliaryType.Fan; } public static string ToString(AuxiliaryType t) diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index a1a3c65ec84c1e01c0b106639571c0bc0ad90bc3..6478446e6f529e3849c5e781ac7a140aeb7a8609 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; using System.Linq; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -248,6 +249,9 @@ namespace TUGraz.VectoCore.Models.Declaration public static ShiftPolygon ComputeShiftPolygon(int gear, FullLoadCurve fullLoadCurve, IList<ITransmissionInputData> gears, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius) { + if (gears.Count < 2) + throw new VectoException("ComputeShiftPolygon needs at least 2 gears. {0} gears given.", gears.Count); + // ReSharper disable once InconsistentNaming var engineSpeed85kmhLastGear = ComputeEngineSpeed85kmh(gears[gears.Count - 1], axlegearRatio, dynamicTyreRadius); diff --git a/VectoCore/VectoCore/Models/Declaration/PT1.cs b/VectoCore/VectoCore/Models/Declaration/PT1.cs index db88c2e9e115983ea4af701a8d1a4c5cd20c27fb..e45f553866865c091d41cd5254bcf3f5d1d355be 100644 --- a/VectoCore/VectoCore/Models/Declaration/PT1.cs +++ b/VectoCore/VectoCore/Models/Declaration/PT1.cs @@ -69,13 +69,13 @@ namespace TUGraz.VectoCore.Models.Declaration public override Second Lookup(PerSecond key) { var index = 1; - if (key < _entries[0].Key) { + if (key.IsSmaller(_entries[0].Key)) { Log.Error("requested rpm below minimum rpm in pt1 - extrapolating. n_eng_avg: {0}, rpm_min: {1}", key.ConvertTo().Rounds.Per.Minute, _entries[0].Key.ConvertTo().Rounds.Per.Minute); } else { - index = _entries.FindIndex(x => x.Key > key); + index = _entries.FindIndex(x => x.Key.IsGreater(key)); if (index <= 0) { - index = (key > _entries[0].Key) ? _entries.Count - 1 : 1; + index = key.IsGreater(_entries[0].Key) ? _entries.Count - 1 : 1; } } diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs index 429ba2493a139399f279ac0c7da8a37cb23677b8..3aa7a3e484860fbc335842d2793eddde7dca546b 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs @@ -329,6 +329,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Data [ModalResultField(typeof(double), name: "TCmu")] TorqueConverterTorqueRatio, [ModalResultField(typeof(SI), "P_TC_out [kW]", outputFactor: 1e-3)] P_TC_out, + + /// <summary> + /// [kW] Power loss at the torque converter. + /// </summary> [ModalResultField(typeof(SI), "P_TC_loss [kW]", outputFactor: 1e-3)] P_TC_loss, /// <summary> @@ -351,11 +355,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Data /// </summary> [ModalResultField(typeof(SI), "n_TC_in")] TC_angularSpeedIn, - /// <summary> - /// [kW] Power loss at the torque converter. - /// </summary> - [ModalResultField(typeof(SI), caption: "P_tc_loss [kW]", outputFactor: 1e-3)] P_tc_loss, - /// <summary> /// [m] Altitude /// </summary> diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxSupplyPowerReader.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxSupplyPowerReader.cs index ad1dc7fa068d2183578f1baf8d0cee15bee61268..d5eb87ca328db6894fce02ff07e0b2fb22170559 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxSupplyPowerReader.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxSupplyPowerReader.cs @@ -31,10 +31,9 @@ using System.Collections.Generic; using System.Data; -using System.Globalization; -using System.Linq; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { @@ -48,13 +47,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// </summary> public static Dictionary<string, Watt> GetAuxiliaries(this DataRow row) { - return row.Table.Columns.Cast<DataColumn>() - .Where(col => { - var s = col.ColumnName; - return s[0] == 'A' && s[1] == 'u' && s[2] == 'x' && s[3] == '_'; - }) - .ToDictionary(col => "Aux_" + col.ColumnName.Substring(4).ToUpper(), - col => SIBase<Watt>.Create(double.Parse(row.Field<string>(col), CultureInfo.InvariantCulture) * Constants.Kilo)); + var aux = new Dictionary<string, Watt>(); + var cols = row.Table.Columns; + var auxLen = Constants.Auxiliaries.Prefix.Length; + for (var i = 0; i < cols.Count; i++) { + var c = cols[i].ColumnName.ToUpper(); + if (c.Length >= auxLen && c.Substring(0, auxLen) == Constants.Auxiliaries.Prefix) { + aux[c.Substring(auxLen)] = (row.ParseDouble(i) * Constants.Kilo).SI<Watt>(); + } + } + return aux; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs index 4056d61288a3efc3d51f731fef9a14ed6b943c26..82e5d44bb4f97ecece54c980879e1bc9bd399750 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs @@ -29,15 +29,9 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Data; -using System.IO; -using System.Linq; -using System.Text; using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader.ComponentData; @@ -49,13 +43,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public sealed class AuxiliaryData { [Required, Range(double.Epsilon, 1)] - public double EfficiencyToSupply { get; set; } + public double EfficiencyToSupply { get; private set; } [Required, Range(double.Epsilon, double.MaxValue)] - public double TransmissionRatio { get; set; } + public double TransmissionRatio { get; private set; } [Required, Range(double.Epsilon, 1)] - public double EfficiencyToEngine { get; set; } + public double EfficiencyToEngine { get; private set; } [Required] private readonly DelaunayMap _map; @@ -84,6 +78,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// <param name="data">The data.</param> /// <param name="context">The validation context.</param> /// <returns></returns> + // ReSharper disable once UnusedMember.Global public static ValidationResult ValidateAuxMap(AuxiliaryData data, ValidationContext context) { var xValidationRules = new[] { new RangeAttribute(0, double.MaxValue) }; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs index 817e5ef2d842c5dccd318c33f82ee6e9d76d8140..72ef57f5c86a5a5407d14abd79f327cb955ad28c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs @@ -109,13 +109,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine public override Second Lookup(PerSecond key) { var index = 1; - if (key < _entries[0].Key) { + if (key.IsSmaller(_entries[0].Key)) { Log.Error("requested rpm below minimum rpm in pt1 - extrapolating. n_eng_avg: {0}, rpm_min: {1}", key.ConvertTo().Rounds.Per.Minute, _entries[0].Key.ConvertTo().Rounds.Per.Minute); } else { - index = _entries.FindIndex(x => x.Key > key); + index = _entries.FindIndex(x => x.Key.IsGreater(key)); if (index <= 0) { - index = (key > _entries[0].Key) ? _entries.Count - 1 : 1; + index = key.IsGreater(_entries[0].Key) ? _entries.Count - 1 : 1; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index f797e4f1e5ea964319cecda2263beaa2ea65fb9d..a189d40f3e48c9945b021a9460013ac14b9e78c9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -46,10 +46,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public new void Connect(ITnOutPort other) + public override void Connect(ITnOutPort other) { - NextComponent = other; - TorqueConverter.NextComponent = NextComponent; + base.Connect(other); + TorqueConverter.NextComponent = other; } public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs index c74ac61420d8f77b4eeac0e51b2c0bb9e9e35870..72c73ccfee12940335d806669ad1f13b3a4c1fd5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs @@ -5,18 +5,15 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public class ATShiftStrategy : LoggingObject, IShiftStrategy { - protected GearboxData Data; - - protected IDataBus DataBus; + protected readonly GearboxData Data; + protected readonly IDataBus DataBus; private ATGearbox _gearbox; - - protected NextGearState NextGear; + protected readonly NextGearState NextGear; public ATShiftStrategy(GearboxData data, IDataBus dataBus) { @@ -68,7 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } if (DataBus.DriverBehavior == DrivingBehavior.Braking && DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ATGearboxDisengageWhenHaltingSpeed) && - outTorque.IsSmaller(0.SI<NewtonMeter>())) { + outTorque.IsSmaller(0)) { // disengage before halting NextGear.SetState(absTime, true, 1, false); return true; @@ -106,7 +103,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("engine speed would fall below idle speed - shift down"); return true; } - if (inAngularVelocity.IsGreater(DataBus.EngineRatedSpeed)) { + if (inAngularVelocity.IsGreater(DataBus.EngineRatedSpeed) && Data.Gears.ContainsKey(gear + 1)) { NextGear.SetState(absTime, false, gear + 1, Data.Gears[gear + 1].HasLockedGear); Log.Debug("engine speed would be above rated speed - shift up"); return true; @@ -227,10 +224,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns><c>true</c> if the operating point is below the down-shift curv; otherwise, <c>false</c>.</returns> protected virtual bool IsBelowDownShiftCurve(uint gear, NewtonMeter inTorque, PerSecond inEngineSpeed) { - if (gear <= 1) { - return false; - } - return Data.Gears[gear].ShiftPolygon.IsBelowDownshiftCurve(inTorque, inEngineSpeed); + return gear > 1 && Data.Gears[gear].ShiftPolygon.IsBelowDownshiftCurve(inTorque, inEngineSpeed); } /// <summary> @@ -242,10 +236,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns><c>true</c> if the operating point is above the up-shift curve; otherwise, <c>false</c>.</returns> protected virtual bool IsAboveUpShiftCurve(uint gear, NewtonMeter inTorque, PerSecond inEngineSpeed) { - if (gear >= Data.Gears.Count) { - return false; - } - return Data.Gears[gear].ShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); + return gear < Data.Gears.Keys.Max() && Data.Gears[gear].ShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); } protected class NextGearState diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index aa7381653a2292e5a923f604bcbcb274a7f8666e..aa68b99fe679bd638aa8b6e2f9acff0daa427523 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -242,8 +242,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.EngineTorque = VectoMath.Limit(totalTorqueDemand, minTorque, maxTorque); CurrentState.EnginePower = CurrentState.EngineTorque * avgEngineSpeed; - if (totalTorqueDemand.IsGreater(0.SI<NewtonMeter>()) && - (deltaFull * avgEngineSpeed).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { + if (totalTorqueDemand.IsGreater(0) && + (deltaFull * avgEngineSpeed).IsGreater(0, Constants.SimulationSettings.LineSearchTolerance)) { Log.Debug("requested engine power exceeds fullload power: delta: {0}", deltaFull); return new ResponseOverload { AbsTime = absTime, @@ -255,8 +255,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - if (totalTorqueDemand.IsSmaller(0.SI<NewtonMeter>()) && - (deltaDrag * avgEngineSpeed).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { + if (totalTorqueDemand.IsSmaller(0) && + (deltaDrag * avgEngineSpeed).IsSmaller(0, Constants.SimulationSettings.LineSearchTolerance)) { Log.Debug("requested engine power is below drag power: delta: {0}", deltaDrag); return new ResponseUnderload { AbsTime = absTime, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs index 1a674c3138b9ee0a4f26d9b45ff03baa5913d5ac..85051e2bddda30ee0aa642db37374926a837d19b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs @@ -31,7 +31,10 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { @@ -59,6 +62,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } else { // disengaged -> clutch open var retVal = NextComponent.Request(absTime, dt, outTorque, angularVelocityIn, dryRun); + if (dryRun) { + return retVal; + } + + var r = retVal as ResponseUnderload; + if (r != null) { + var angularSpeed = SearchAlgorithm.Search(angularVelocityIn, r.Delta, + Constants.SimulationSettings.EngineIdlingSearchInterval, + getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, + evaluateFunction: n => NextComponent.Request(absTime, dt, outTorque, n, true), + criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value()); + Log.Debug( + "Found operating point for idling in cycle clutch. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", + absTime, dt, outTorque, angularSpeed); + retVal = NextComponent.Request(absTime, dt, outTorque, angularSpeed); + } return retVal; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index d4c3268ce9be4196fc76e7a67be2450a41b5a643..6e4aa9e3963aae3f575bec506208d16c7f99a0e2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -200,6 +200,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.TorqueLossResult = inTorqueLossResult; var inAngularVelocity = outAngularVelocity * ModelData.Gears[Gear].Ratio; + if (!inAngularVelocity.IsEqual(0)) { + // MQ 19.2.2016: check! inertia is related to output side, torque loss accounts to input side + CurrentState.InertiaTorqueLossOut = + Formulas.InertiaPower(outAngularVelocity, PreviousState.OutAngularVelocity, ModelData.Inertia, dt) / + avgOutAngularVelocity; + inTorque += CurrentState.InertiaTorqueLossOut / ModelData.Gears[Gear].Ratio; + } else { + CurrentState.InertiaTorqueLossOut = 0.SI<NewtonMeter>(); + } + //todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox? if (Auxiliary != null) inTorque += Auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun); @@ -213,15 +223,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // this code has to be _after_ the check for a potential gear-shift! // (the above block issues dry-run requests and thus may update the CurrentState!) CurrentState.TransmissionTorqueLoss = inTorque - (outTorque / ModelData.Gears[Gear].Ratio); - if (!inAngularVelocity.IsEqual(0)) { - // MQ 19.2.2016: check! inertia is related to output side, torque loss accounts to input side - CurrentState.InertiaTorqueLossOut = - Formulas.InertiaPower(outAngularVelocity, PreviousState.OutAngularVelocity, ModelData.Inertia, dt) / - avgOutAngularVelocity; - inTorque += CurrentState.InertiaTorqueLossOut / ModelData.Gears[Gear].Ratio; - } else { - CurrentState.InertiaTorqueLossOut = 0.SI<NewtonMeter>(); - } + CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); CurrentState.Gear = Gear; // end critical section diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index b9e04b3fa791e2cbd348769cf50b361756c23a54..b2b3f14f309ff09b2cd5858ce334fcd656c4267e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -411,6 +411,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } else { if (DataBus.VehicleSpeed.IsSmallerOrEqual(0.SI<MeterPerSecond>())) { // the clutch is disengaged, and the vehicle stopped - we can't perform a roll action. wait for the clutch to be engaged + // todo mk 2016-08-23: is this still needed? var remainingShiftTime = Constants.SimulationSettings.TargetTimeInterval; while (!DataBus.ClutchClosed(absTime + remainingShiftTime)) { remainingShiftTime += Constants.SimulationSettings.TargetTimeInterval; @@ -491,7 +492,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse response = null; if (DataBus.VehicleSpeed <= DriverStrategy.BrakeTrigger.NextTargetSpeed) { if (DataBus.ClutchClosed(absTime)) { - if (DataBus.VehicleSpeed.IsGreater(0.SI<MeterPerSecond>())) { + if (DataBus.VehicleSpeed.IsGreater(0)) { response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } else { if (RetryDistanceExceeded) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index a27a5eb60453556dbf14444ff18d6e12f95a167f..e1cb4c676688a37c6c46e9174ea40ec693c1e4ef 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -309,7 +309,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // compute speed at the end of the simulation interval. if it exceeds the limit -> return var v2 = DataBus.VehicleSpeed + limitedOperatingPoint.Acceleration * limitedOperatingPoint.SimulationInterval; - if (v2 > maxVelocity && limitedOperatingPoint.Acceleration.IsGreaterOrEqual(0.SI<MeterPerSquareSecond>())) { + if (v2 > maxVelocity && limitedOperatingPoint.Acceleration.IsGreaterOrEqual(0)) { Log.Debug("vehicle's velocity would exceed given max speed. v2: {0}, max speed: {1}", v2, maxVelocity); return new ResponseSpeedLimitExceeded() { Source = this }; } @@ -527,7 +527,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl deltaPower = nextResp.GearboxPowerRequest; }). Case<ResponseUnderload>(r => - deltaPower = DataBus.ClutchClosed(absTime) ? r.Delta : r.GearboxPowerRequest). + deltaPower = DataBus.ClutchClosed(absTime) ? r.Delta : r.GearboxPowerRequest). Default(r => { throw new UnexpectedResponseException("cannot use response for searching braking power!", r); }); try { @@ -588,39 +588,39 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return actionRoll ? r.GearboxPowerRequest : (coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad); }, evaluateFunction: - acc => { - // calculate new time interval only when vehiclespeed and acceleration are != 0 - // else: use same timeinterval as before. - if (!(acc.IsEqual(0) && DataBus.VehicleSpeed.IsEqual(0))) { - var tmp = ComputeTimeInterval(acc, ds); - if (tmp.SimulationInterval.IsEqual(0.SI<Second>(), 1e-9.SI<Second>())) { - throw new VectoSearchAbortedException("next TimeInterval is 0. a: {0}, v: {1}, dt: {2}", acc, - DataBus.VehicleSpeed, tmp.SimulationInterval); - } - retVal.Acceleration = tmp.Acceleration; - retVal.SimulationInterval = tmp.SimulationInterval; - retVal.SimulationDistance = tmp.SimulationDistance; + acc => { + // calculate new time interval only when vehiclespeed and acceleration are != 0 + // else: use same timeinterval as before. + if (!(acc.IsEqual(0) && DataBus.VehicleSpeed.IsEqual(0))) { + var tmp = ComputeTimeInterval(acc, ds); + if (tmp.SimulationInterval.IsEqual(0.SI<Second>(), 1e-9.SI<Second>())) { + throw new VectoSearchAbortedException("next TimeInterval is 0. a: {0}, v: {1}, dt: {2}", acc, + DataBus.VehicleSpeed, tmp.SimulationInterval); } - IterationStatistics.Increment(this, "SearchOperatingPoint"); - DriverAcceleration = acc; - var response = NextComponent.Request(absTime, retVal.SimulationInterval, acc, gradient, true); - response.OperatingPoint = retVal; - return response; - }, + retVal.Acceleration = tmp.Acceleration; + retVal.SimulationInterval = tmp.SimulationInterval; + retVal.SimulationDistance = tmp.SimulationDistance; + } + IterationStatistics.Increment(this, "SearchOperatingPoint"); + DriverAcceleration = acc; + var response = NextComponent.Request(absTime, retVal.SimulationInterval, acc, gradient, true); + response.OperatingPoint = retVal; + return response; + }, criterion: response => { var r = (ResponseDryRun)response; delta = actionRoll ? r.GearboxPowerRequest : (coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad); return delta.Value(); }, abortCriterion: - (response, cnt) => { - var r = (ResponseDryRun)response; - if (r == null) { - return false; - } + (response, cnt) => { + var r = (ResponseDryRun)response; + if (r == null) { + return false; + } - return !actionRoll && !ds.IsEqual(r.OperatingPoint.SimulationDistance); - }); + return !actionRoll && !ds.IsEqual(r.OperatingPoint.SimulationDistance); + }); } catch (VectoSearchAbortedException) { // search aborted, try to go ahead with the last acceleration } catch (Exception) { @@ -650,9 +650,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var currentSpeed = DataBus.VehicleSpeed; var retVal = new OperatingPoint() { SimulationDistance = ds }; - var requiredAverageSpeed = (targetVelocity + currentSpeed) / 2.0; - var requiredAcceleration = - (((targetVelocity - currentSpeed) * requiredAverageSpeed) / ds).Cast<MeterPerSquareSecond>(); + // Δx = (v0+v1)/2 * Δt + // => Δt = 2*Δx/(v0+v1) + var dt = 2 * ds / (currentSpeed + targetVelocity); + + // a = Δv / Δt + var requiredAcceleration = (targetVelocity - currentSpeed) / dt; if (!limitByDriverModel) { return ComputeTimeInterval(requiredAcceleration, ds); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs index a7e20c3a8b9bd36ce0ff622871288a99dc59adb3..bed32b35e867d349934e51c91c8a803b17524ae1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs @@ -34,6 +34,7 @@ using System.Collections.Generic; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data; @@ -68,14 +69,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void AddMapping(string auxId, AuxiliaryData data) { - if (!DataBus.CycleData.LeftSample.AuxiliarySupplyPower.ContainsKey("Aux_" + auxId)) { - var error = string.Format("driving cycle does not contain column for auxiliary: {0}", auxId); + if (!DataBus.CycleData.LeftSample.AuxiliarySupplyPower.ContainsKey(auxId)) { + var error = string.Format("driving cycle does not contain column for auxiliary: {0}", + Constants.Auxiliaries.Prefix + auxId); Log.Error(error); throw new VectoException(error); } Add(auxId, speed => { - var powerSupply = DataBus.CycleData.LeftSample.AuxiliarySupplyPower["Aux_" + auxId]; + var powerSupply = DataBus.CycleData.LeftSample.AuxiliarySupplyPower[auxId]; var nAuxiliary = speed * data.TransmissionRatio; var powerAuxOut = powerSupply / data.EfficiencyToSupply; var powerAuxIn = data.GetPowerDemand(nAuxiliary, powerAuxOut); @@ -83,9 +85,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }); } - public void Add(string auxId, Func<PerSecond, Watt> powerLoss) + public void Add(string auxId, Func<PerSecond, Watt> powerLossFunction) { - _auxiliaries[auxId] = powerLoss; + _auxiliaries[auxId] = powerLossFunction; } public NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index f0b7a8418181c8f5e13e9791d24a2cfb49059434..85ded3f31a7d4ad91e0c1bab401a898d7ef58a19 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -180,7 +180,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var engineSpeedNorm = (outAngularVelocity - DataBus.EngineIdleSpeed) / (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed); - if (DataBus.DriverBehavior == DrivingBehavior.Braking && DataBus.BrakePower.IsGreater(0.SI<Watt>()) && + if (DataBus.DriverBehavior == DrivingBehavior.Braking && DataBus.BrakePower.IsGreater(0) && engineSpeedNorm < Constants.SimulationSettings.ClutchClosingSpeedNorm && DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ClutchDisengageWhenHaltingSpeed)) { _engageTime = absTime + dt; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs b/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs index 1a414f120d6985901cbe3a645b07ed0e0b3be7a3..311bed045e6e889a4c59e6f65699afd10b282d3d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs @@ -93,7 +93,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent } public abstract class StatefulProviderComponent<TStateType, TProviderOutPort, TProviderInPort, TOutPort> : - StatefulVectoSimulationComponent<TStateType> + StatefulVectoSimulationComponent<TStateType> where TStateType : new() where TProviderOutPort : class where TProviderInPort : class @@ -112,7 +112,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent return this as TProviderInPort; } - public void Connect(TOutPort other) + public virtual void Connect(TOutPort other) { NextComponent = other; } diff --git a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs index a057334de64faec0046d3868cd9146947b5efd03..0ff2b1891a239133175e7e09e2e4fc8c00bc6a7b 100644 --- a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs @@ -98,6 +98,7 @@ namespace TUGraz.VectoCore.OutputData IEnumerable<T> GetValues<T>(DataColumn col); Dictionary<string, DataColumn> Auxiliaries { get; set; } + T TimeIntegral<T>(ModalResultField field, Func<SI, bool> filter = null) where T : SIBase<T>; void SetDataValue(string fieldName, object value); @@ -147,49 +148,44 @@ namespace TUGraz.VectoCore.OutputData return self ?? defaultValue; } - public static MeterPerSquareSecond AccelerationsPositive(this IModalDataContainer data) + public static MeterPerSquareSecond AccelerationsPositive(this MeterPerSquareSecond[] acceleration3SecondAverage) { try { - var acceleration3SecondAverage = AccelerationPer3Seconds(data); return acceleration3SecondAverage.Where(x => x > 0.125).Average(); } catch (NullReferenceException) { return null; } } - public static MeterPerSquareSecond AccelerationsNegative(this IModalDataContainer data) + public static MeterPerSquareSecond AccelerationsNegative(this MeterPerSquareSecond[] acceleration3SecondAverage) { - var acceleration3SecondAverage = AccelerationPer3Seconds(data).ToList(); - if (acceleration3SecondAverage.Any()) { + if (acceleration3SecondAverage.Length > 0) { return acceleration3SecondAverage.Where(x => x < -0.125).Average(); } return null; } - public static Scalar AccelerationTimeShare(this IModalDataContainer data) + public static Scalar AccelerationTimeShare(this MeterPerSquareSecond[] acceleration3SecondAverage) { - var acceleration3SecondAverage = AccelerationPer3Seconds(data).ToList(); - if (acceleration3SecondAverage.Any()) { - return 100.SI<Scalar>() * acceleration3SecondAverage.Count(x => x > 0.125) / acceleration3SecondAverage.Count; + if (acceleration3SecondAverage.Length > 0) { + return 100.SI<Scalar>() * acceleration3SecondAverage.Count(x => x > 0.125) / acceleration3SecondAverage.Length; } return null; } - public static Scalar DecelerationTimeShare(this IModalDataContainer data) + public static Scalar DecelerationTimeShare(this MeterPerSquareSecond[] acceleration3SecondAverage) { - var acceleration3SecondAverage = AccelerationPer3Seconds(data).ToList(); - if (acceleration3SecondAverage.Any()) { - return 100.SI<Scalar>() * acceleration3SecondAverage.Count(x => x < -0.125) / acceleration3SecondAverage.Count; + if (acceleration3SecondAverage.Length > 0) { + return 100.SI<Scalar>() * acceleration3SecondAverage.Count(x => x < -0.125) / acceleration3SecondAverage.Length; } return null; } - public static Scalar CruiseTimeShare(this IModalDataContainer data) + public static Scalar CruiseTimeShare(this MeterPerSquareSecond[] acceleration3SecondAverage) { - var acceleration3SecondAverage = AccelerationPer3Seconds(data).ToList(); - if (acceleration3SecondAverage.Any()) { + if (acceleration3SecondAverage.Length > 0) { return 100.SI<Scalar>() * acceleration3SecondAverage.Count(x => x.IsBetween(-0.125, -0.125)) / - acceleration3SecondAverage.Count; + acceleration3SecondAverage.Length; } return null; } @@ -197,8 +193,8 @@ namespace TUGraz.VectoCore.OutputData public static Scalar StopTimeShare(this IModalDataContainer data) { var stopTime = data.GetValues<MeterPerSecond>(ModalResultField.v_act) - .Zip(data.SimulationIntervals(), (v, dt) => new { v, dt }) - .Where(x => x.v < 0.1).Sum(x => x.dt) ?? 0.SI<Second>(); + .Zip(data.SimulationIntervals(), (v, dt) => new { v, dt }) + .Where(x => x.v < 0.1).Sum(x => x.dt) ?? 0.SI<Second>(); return 100 * (stopTime / data.Duration()).Cast<Scalar>(); } @@ -246,7 +242,7 @@ namespace TUGraz.VectoCore.OutputData public static WattSecond WorkTorqueConverter(this IModalDataContainer data) { - return data.TimeIntegral<WattSecond>(ModalResultField.P_tc_loss); + return data.TimeIntegral<WattSecond>(ModalResultField.P_TC_loss); } public static Second Duration(this IModalDataContainer data) @@ -317,7 +313,7 @@ namespace TUGraz.VectoCore.OutputData public static Watt PowerTorqueConverter(this IModalDataContainer data) { - return data.TimeIntegral<WattSecond>(ModalResultField.P_tc_loss) / data.Duration(); + return data.TimeIntegral<WattSecond>(ModalResultField.P_TC_loss) / data.Duration(); } public static Watt PowerWheelPositive(this IModalDataContainer data) @@ -467,33 +463,23 @@ namespace TUGraz.VectoCore.OutputData return data.GetValues<Watt>(auxCol).Zip(simulationIntervals, (value, dt) => value * dt).Sum().Cast<WattSecond>(); } - private static T TimeIntegral<T>(this IModalDataContainer data, ModalResultField field, Func<SI, bool> filter = null) - where T : SIBase<T> - { - var simulationIntervals = data.GetValues<Second>(ModalResultField.simulationInterval); - var filteredList = data.GetValues<SI>(field) - .Zip(simulationIntervals, (value, dt) => new { value, dt }) - .Where(x => filter == null || filter(x.value)).ToList(); - - return filteredList.Any() - ? filteredList.Select(x => (x.value == null ? SIBase<T>.Create(0) : x.value * x.dt)).Sum().Cast<T>() - : SIBase<T>.Create(0); - } - - private static IEnumerable<MeterPerSquareSecond> AccelerationPer3Seconds(IModalDataContainer data) + public static MeterPerSquareSecond[] AccelerationPer3Seconds(this IModalDataContainer data) { + var accs = new List<MeterPerSquareSecond>(1000); var accelerationAverages = AccelerationPerSecond(data).ToList(); if (accelerationAverages.Count >= 3) { var runningAverage = (accelerationAverages[0] + accelerationAverages[1] + accelerationAverages[2]) / 3.0; - yield return runningAverage; + accs.Add(runningAverage); for (var i = 2; i < accelerationAverages.Count - 1; i++) { runningAverage -= accelerationAverages[i - 2] / 3.0; runningAverage += accelerationAverages[i + 1] / 3.0; - yield return runningAverage; + accs.Add(runningAverage); } } + + return accs.ToArray(); } /// <summary> diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index b7fc496636c002614ae8481fab4c151ad2b26b2b..39cf24c121e3aabd53a57eccc8c522c73f36c7fc 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -204,7 +204,6 @@ namespace TUGraz.VectoCore.OutputData }); } - var strCols = dataColumns.Select(x => x.GetName()) .Concat(Auxiliaries.Values.Select(c => c.ColumnName)) .Concat( @@ -232,6 +231,23 @@ namespace TUGraz.VectoCore.OutputData return Data.Rows.Cast<DataRow>().Select(x => x.Field<T>(col)); } + public T TimeIntegral<T>(ModalResultField field, Func<SI, bool> filter = null) + where T : SIBase<T> + { + var result = 0.0; + for (var i = 0; i < Data.Rows.Count; i++) { + var value = Data.Rows[i][(int)field]; + if (value != null && value != DBNull.Value) { + var siValue = (SI)value; + if (filter == null || filter(siValue)) { + result += siValue.Value() * ((Second)Data.Rows[i][(int)ModalResultField.simulationInterval]).Value(); + } + } + } + + return result.SI<T>(); + } + public IEnumerable<T> GetValues<T>(ModalResultField key) { return GetValues<T>(Data.Columns[(int)key]); diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs index 9b5ac0d7b591698cb0026150946180753ef0c76c..a86a4665b998b690488bc057d0e2c86235c4acbb 100644 --- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs @@ -132,9 +132,7 @@ namespace TUGraz.VectoCore.OutputData FCAAUX_H, FCAAUX_KM, FCFINAL_H, FCFINAL_KM, FCFINAL_LITERPER100KM, FCFINAL_LITERPER100TKM, CO2_KM, CO2_TKM, P_WHEEL_POS, P_BRAKE_LOSS, P_ANGLE_LOSS, P_TC_LOSS, P_CLUTCH_POS, P_CLUTCH_NEG, P_FCMAP_POS, E_AUX, E_AIR, E_ROLL, E_GRAD, E_INERTIA, E_BRAKE, E_GBX_AXL_LOSS, E_RET_LOSS, E_TC_LOSS, E_ANGLE_LOSS, E_CLUTCH_POS, E_CLUTCH_NEG, - E_FCMAP_POS, ACC, - ACC_POS, - ACC_NEG, ACC_TIMESHARE, DEC_TIMESHARE, CRUISE_TIMESHARE, STOP_TIMESHARE + E_FCMAP_POS, ACC, ACC_POS, ACC_NEG, ACC_TIMESHARE, DEC_TIMESHARE, CRUISE_TIMESHARE, STOP_TIMESHARE }.Select(x => new DataColumn(x, typeof(SI))).ToArray()); } @@ -227,6 +225,7 @@ namespace TUGraz.VectoCore.OutputData row[P_BRAKE_LOSS] = modData.PowerBrake().ConvertTo().Kilo.Watt; row[P_ANGLE_LOSS] = modData.PowerAngle().ConvertTo().Kilo.Watt; + row[P_TC_LOSS] = modData.PowerTorqueConverter().ConvertTo().Kilo.Watt; row[P_CLUTCH_POS] = modData.EnginePowerPositiveAverage().ConvertTo().Kilo.Watt; @@ -258,12 +257,14 @@ namespace TUGraz.VectoCore.OutputData row[E_CLUTCH_NEG] = modData.EngineWorkNegative().ConvertTo().Kilo.Watt.Hour; row[E_FCMAP_POS] = modData.TotalEngineWorkPositive().ConvertTo().Kilo.Watt.Hour; + var acc = modData.AccelerationPer3Seconds(); + row[ACC] = modData.AccelerationAverage(); - row[ACC_POS] = modData.AccelerationsPositive(); - row[ACC_NEG] = modData.AccelerationsNegative(); - row[ACC_TIMESHARE] = modData.AccelerationTimeShare(); - row[DEC_TIMESHARE] = modData.DecelerationTimeShare(); - row[CRUISE_TIMESHARE] = modData.CruiseTimeShare(); + row[ACC_POS] = acc.AccelerationsPositive(); + row[ACC_NEG] = acc.AccelerationsNegative(); + row[ACC_TIMESHARE] = acc.AccelerationTimeShare(); + row[DEC_TIMESHARE] = acc.DecelerationTimeShare(); + row[CRUISE_TIMESHARE] = acc.CruiseTimeShare(); row[STOP_TIMESHARE] = modData.StopTimeShare(); } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs index 43d3d91a0a90041583478109266ce3b58fa03193..6fb6a1c2cde1a52ce2e4ed51b8a2ffb8dab0c506 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -296,7 +296,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var aux = new EngineAuxiliary(container); AssertHelper.Exception<VectoException>(() => aux.AddMapping("NONEXISTING_AUX", null), - "driving cycle does not contain column for auxiliary: NONEXISTING_AUX"); + "driving cycle does not contain column for auxiliary: AUX_NONEXISTING_AUX"); } [TestMethod] diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/AuxiliaryTypeHelperTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/AuxiliaryTypeHelperTest.cs index 3643a4570a5db4ba3584c66200308ee42c7122dc..a4ddb31543411a64d7eb8da5ff525ee3f2f80108 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/AuxiliaryTypeHelperTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/AuxiliaryTypeHelperTest.cs @@ -49,7 +49,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData Assert.AreEqual(AuxiliaryType.ElectricSystem, AuxiliaryTypeHelper.Parse("Electric System")); Assert.AreEqual(AuxiliaryType.HVAC, AuxiliaryTypeHelper.Parse("HVAC")); Assert.AreEqual(AuxiliaryType.PneumaticSystem, AuxiliaryTypeHelper.Parse("Pneumatic System")); - AssertHelper.Exception<ArgumentOutOfRangeException>(() => { AuxiliaryTypeHelper.Parse("Foo Bar Blupp"); }); } [TestMethod] diff --git a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs index 1ff028aaed45e694a81395c9438da5677c6c84b3..c8d04b557624fd3a695f562168a57242ac2ad00c 100644 --- a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.Data; using System.Linq; @@ -92,6 +93,11 @@ namespace TUGraz.VectoCore.Tests.Utils return Data.Rows.Cast<DataRow>().Select(x => x.Field<T>(col)); } + public T TimeIntegral<T>(ModalResultField field, Func<SI, bool> filter = null) where T : SIBase<T> + { + throw new NotImplementedException(); + } + public Dictionary<string, DataColumn> Auxiliaries { get; set; } public void SetDataValue(string fieldName, object value)