diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb index 8d1c05b909f8319505b8893b8b49365b372e8fc5..b13735b81809f00eeb011746b0f7eff556b2d0b4 100644 --- a/VECTO/GUI/GearboxForm.vb +++ b/VECTO/GUI/GearboxForm.vb @@ -755,67 +755,66 @@ Public Class GearboxForm chart.Series.Add(s) End If - Dim vectoJob As VectoJob = New VectoJob() With {.FilePath = VectoJobForm.VECTOfile} - Dim vectoOk As Boolean = vectoJob.ReadFile() + 'Dim vectoJob As VectoJob = New VectoJob() With {.FilePath = VectoJobForm.VECTOfile} + 'Dim vectoOk As Boolean = vectoJob.ReadFile() - Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(vectoJob.PathVeh(False)), + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadJsonJob(VectoJobForm.VECTOfile), IEngineeringInputDataProvider) + If (inputData Is Nothing) Then + Exit Sub + End If Dim vehicle As IVehicleEngineeringInputData = inputData.VehicleInputData - inputData = TryCast(JSONInputDataFactory.ReadComponentData(vectoJob.PathEng(False)), IEngineeringInputDataProvider) + 'inputData = TryCast(JSONInputDataFactory.ReadComponentData(vectoJob.PathEng(False)), IEngineeringInputDataProvider) Dim engine As IEngineEngineeringInputData = inputData.EngineInputData Dim engineFld As EngineFullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve) - 'Fld - If vectoOk AndAlso Not vehicle Is Nothing Then - s = New Series - s.Points.DataBindXY(engineFld.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), - engineFld.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkBlue - s.Name = "Full load" - chart.Series.Add(s) - - If VectoJobForm.Visible AndAlso engine.IdleSpeed > 0 Then - 'If FLD0.Init(VectoJobForm.n_idle) Then - - 'Dim fullLoadCurve As FullLoadCurve = ConvertToFullLoadCurve(FLD0.LnU, FLD0.LTq) - Dim gears As IList(Of ITransmissionInputData) = ConvertToGears(LvGears.Items) - Dim shiftLines As ShiftPolygon = GetShiftLines(engine.IdleSpeed, engineFld, vehicle, gears, gear) - If (CType(CbGStype.SelectedValue, GearboxType).ManualTransmission() AndAlso Not IsNothing(shiftLines)) Then - - - s = New Series - - 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) - s.Points.DataBindXY( - shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.AsRPM). - ToArray(), - shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToArray()) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.BorderDashStyle = ChartDashStyle.Dash - s.Name = "Upshift curve (generic)" - chart.Series.Add(s) - - s = New Series - 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) - s.Points.DataBindXY( - shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.AsRPM) _ - .ToArray(), - shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToArray()) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.BorderDashStyle = ChartDashStyle.Dash - s.Name = "Downshift curve (generic)" - chart.Series.Add(s) - End If - 'End If + s = New Series + s.Points.DataBindXY(engineFld.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + engineFld.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkBlue + s.Name = "Full load" + chart.Series.Add(s) + + If VectoJobForm.Visible AndAlso engine.IdleSpeed > 0 Then + 'If FLD0.Init(VectoJobForm.n_idle) Then + + 'Dim fullLoadCurve As FullLoadCurve = ConvertToFullLoadCurve(FLD0.LnU, FLD0.LTq) + Dim gears As IList(Of ITransmissionInputData) = ConvertToGears(LvGears.Items) + Dim shiftLines As ShiftPolygon = GetShiftLines(engine.IdleSpeed, engineFld, vehicle, gears, gear) + If (CType(CbGStype.SelectedValue, GearboxType).ManualTransmission() AndAlso Not IsNothing(shiftLines)) Then + + + s = New Series + + 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) + s.Points.DataBindXY( + shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.AsRPM). + ToArray(), + shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToArray()) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkRed + s.BorderDashStyle = ChartDashStyle.Dash + s.Name = "Upshift curve (generic)" + chart.Series.Add(s) + + s = New Series + 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) + s.Points.DataBindXY( + shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.AsRPM) _ + .ToArray(), + shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToArray()) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkRed + s.BorderDashStyle = ChartDashStyle.Dash + s.Name = "Downshift curve (generic)" + chart.Series.Add(s) End If - + 'End If End If @@ -853,7 +852,9 @@ Public Class GearboxForm End Sub - Private Function GetShiftLines(ByVal idleSpeed As PerSecond, engineFullLoadCurve As EngineFullLoadCurve, vehicle As IVehicleEngineeringInputData, gears As IList(Of ITransmissionInputData), ByVal gear As Integer) As ShiftPolygon + Private Function GetShiftLines(ByVal idleSpeed As PerSecond, engineFullLoadCurve As EngineFullLoadCurve, + vehicle As IVehicleEngineeringInputData, gears As IList(Of ITransmissionInputData), ByVal gear As Integer) _ + As ShiftPolygon Dim engine As CombustionEngineData = ConvertToEngineData(engineFullLoadCurve, idleSpeed) If gears.Count <= 1 Then Return Nothing diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index 52f85878a590af1b8f65dcaeb1771f253a42929c..cfaa32e9598a275659b9109841682b58623f26e6 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -1194,7 +1194,7 @@ lbFound: If Not LoadedDefault Then Exit Sub Path = FilePath End If - Dim file As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(Path, True, Encoding.UTF8) + Dim file As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(Path, False, Encoding.UTF8) For x = 1 To LVbox.Items.Count file.WriteLine(String.Join("?", LVbox.Items(x - 1).SubItems(0).Text, Math.Abs(CInt(LVbox.Items(x - 1).Checked)))) Next diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index aa7f7a3ec8d7098898055e78659658358f34b0bc..1327b7cff2bed89060aa9d3ccacee3fe1ac29b94 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -128,33 +128,33 @@ Public Class VectoJobForm If _ LvAux.Items.Count <> 5 OrElse - (LvAux.Items(0).Text <> Constants.AuxiliaryKey.Fan OrElse LvAux.Items(1).Text <> Constants.AuxiliaryKey.SteerPump OrElse - LvAux.Items(2).Text <> Constants.AuxiliaryKey.HVAC OrElse LvAux.Items(3).Text <> Constants.AuxiliaryKey.ElecSys OrElse - LvAux.Items(4).Text <> Constants.AuxiliaryKey.PneumSys) Then + (LvAux.Items(0).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.Fan OrElse + LvAux.Items(1).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.SteeringPump OrElse + LvAux.Items(2).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.HeatingVentilationAirCondition OrElse + LvAux.Items(3).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.ElectricSystem OrElse + LvAux.Items(4).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.PneumaticSystem) Then LvAux.Items.Clear() - LvAux.Items.Add(GetTechListForAux(Constants.AuxiliaryKey.Fan, "Fan", DeclarationData.Fan)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.Fan, DeclarationData.Fan)) - LvAux.Items.Add(GetTechListForAux(Constants.AuxiliaryKey.SteerPump, "Steering pump", DeclarationData.SteeringPump)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.SteeringPump, DeclarationData.SteeringPump)) - LvAux.Items.Add(GetTechListForAux(Constants.AuxiliaryKey.HVAC, "HVAC", - DeclarationData.HeatingVentilationAirConditioning)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.HVAC, DeclarationData.HeatingVentilationAirConditioning)) - LvAux.Items.Add(GetTechListForAux(Constants.AuxiliaryKey.ElecSys, "Electric System", DeclarationData.ElectricSystem)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.ElectricSystem, DeclarationData.ElectricSystem)) - LvAux.Items.Add(GetTechListForAux(Constants.AuxiliaryKey.PneumSys, "Pneumatic System", - DeclarationData.PneumaticSystem)) + LvAux.Items.Add(GetTechListForAux(AuxiliaryType.PneumaticSystem, DeclarationData.PneumaticSystem)) End If End Sub - Protected Function GetTechListForAux(key As String, nameStr As String, aux As IDeclarationAuxiliaryTable) _ + Protected Function GetTechListForAux(type As AuxiliaryType, aux As IDeclarationAuxiliaryTable) _ As ListViewItem Dim LV0 As ListViewItem - LV0 = New ListViewItem(key) - LV0.SubItems.Add(nameStr) + LV0 = New ListViewItem(type.Key()) + LV0.SubItems.Add(type.Name()) Dim auxtech As String() = aux.GetTechnologies() If auxtech.Count > 1 Then LV0.SubItems.Add("") @@ -364,24 +364,17 @@ Public Class VectoJobForm 'Open file Public Sub VECTOload2Form(file As String) + If ChangeCheckCancel() Then Exit Sub VECTOnew() 'Read GEN - Dim VEC0 As VectoJob = New VectoJob - VEC0.FilePath = file - Try - If Not VEC0.ReadFile() Then - MsgBox("Failed to load " & GetFilenameWithoutPath(file, True) & "!") - Exit Sub - End If - Catch ex As Exception - MsgBox("Failed to load " & GetFilenameWithoutPath(file, True) & "!") - Exit Sub - End Try + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), + IEngineeringInputDataProvider) + Dim vectoJob As IEngineeringJobInputData = inputData.JobInputData() - If Cfg.DeclMode <> VEC0.SavedInDeclMode Then + If Cfg.DeclMode <> vectoJob.SavedInDeclarationMode Then Select Case WrongMode() Case 1 Close() @@ -394,79 +387,102 @@ Public Class VectoJobForm End Select End If - + VECTOfile = file + _basePath = Path.GetDirectoryName(file) 'Update Form 'Files ----------------------------- - TbVEH.Text = VEC0.PathVeh(True) - TbENG.Text = VEC0.PathEng(True) - TbGBX.Text = VEC0.PathGbx(True) + TbVEH.Text = GetRelativePath(inputData.VehicleInputData.Source, _basePath) + TbENG.Text = GetRelativePath(inputData.EngineInputData.Source, _basePath) + TbGBX.Text = GetRelativePath(inputData.GearboxInputData.Source, _basePath) 'Start/Stop - ChBStartStop.Checked = VEC0.StartStop - TbSSspeed.Text = VEC0.StStV.ToString() - TbSStime.Text = VEC0.StStT.ToString() - TbSSdelay.Text = VEC0.StartStopDelay.ToString() + Dim driver As IDriverEngineeringInputData = inputData.DriverInputData + ChBStartStop.Checked = driver.StartStop.Enabled + TbSSspeed.Text = driver.StartStop.MaxSpeed.ToGUIFormat() + TbSStime.Text = driver.StartStop.MinTime.ToGUIFormat() + TbSSdelay.Text = driver.StartStop.Delay.ToGUIFormat() - 'VACC - TbDesMaxFile.Text = VEC0.DesMaxFile(True) + If (Cfg.DeclMode) Then + TbDesMaxFile.Text = "" + 'AA-TB + 'Try and Select any previously selected Auxiliary Type + Dim declarationInput As IDeclarationInputDataProvider = CType(inputData, IDeclarationInputDataProvider) + Dim auxInput As IAuxiliariesDeclarationInputData = declarationInput.AuxiliaryInputData() + cboAdvancedAuxiliaries.SelectedIndex = 0 - 'AA-TB - 'Try and Select any previously selected Auxiliary Type - For Each item As AdvancedAuxiliary In cboAdvancedAuxiliaries.Items - If item.AssemblyName = VEC0.AuxiliaryAssembly AndAlso VEC0.AuxiliaryVersion = item.AuxiliaryVersion Then - cboAdvancedAuxiliaries.SelectedItem = item - Exit For - End If - Next - 'AA-TB - 'Assign any previously saved Axiliary FilePath - txtAdvancedAuxiliaryFile.Text = VEC0.AdvancedAuxiliaryFilePath + LvAux.Items.Clear() + Dim entry As IAuxiliaryDeclarationInputData + For Each entry In auxInput.Auxiliaries + Dim lv0 As ListViewItem = New ListViewItem + lv0.SubItems(0).Text = AuxiliaryTypeHelper.GetAuxKey(entry.Type) + lv0.SubItems.Add(AuxiliaryTypeHelper.ToString(entry.Type)) + lv0.SubItems.Add(String.Join(", ", entry.Technology)) + LvAux.Items.Add(lv0) + Next + Else + 'VACC + Try + TbDesMaxFile.Text = GetRelativePath(driver.AccelerationCurve.Source, _basePath) + Catch + TbDesMaxFile.Text = "" + End Try + Dim auxInput As IAuxiliariesEngineeringInputData = inputData.AuxiliaryInputData() + For Each item As AdvancedAuxiliary In cboAdvancedAuxiliaries.Items + If _ + item.AssemblyName = auxInput.AuxiliaryAssembly.ToString() AndAlso auxInput.AuxiliaryVersion = item.AuxiliaryVersion _ + Then + cboAdvancedAuxiliaries.SelectedItem = item + Exit For + End If + Next + 'AA-TB + 'Assign any previously saved Axiliary FilePath + txtAdvancedAuxiliaryFile.Text = auxInput.AdvancedAuxiliaryFilePath - LvAux.Items.Clear() - Dim AuxEntryKV As KeyValuePair(Of String, VectoJob.AuxEntry) - For Each AuxEntryKV In VEC0.AuxPaths - Dim lv0 As ListViewItem = New ListViewItem - lv0.SubItems(0).Text = AuxEntryKV.Key - lv0.SubItems.Add(AuxEntryKV.Value.Type) - If Cfg.DeclMode Then - lv0.SubItems.Add(String.Join(", ", AuxEntryKV.Value.TechnologyList)) - Else - lv0.SubItems.Add(AuxEntryKV.Value.Path.OriginalPath) - End If - LvAux.Items.Add(lv0) - Next + LvAux.Items.Clear() + For Each entry As IAuxiliaryEngineeringInputData In auxInput.Auxiliaries + Dim lv0 As ListViewItem = New ListViewItem + lv0.SubItems(0).Text = entry.ID + lv0.SubItems.Add(entry.AuxiliaryType.ToString()) + lv0.SubItems.Add(If(entry.DemandMap Is Nothing, "", entry.DemandMap.Source)) + LvAux.Items.Add(lv0) + Next - Dim sb As SubPath - For Each sb In VEC0.CycleFiles + End If + + Dim sb As ICycleData + For Each sb In vectoJob.Cycles Dim lv0 As ListViewItem = New ListViewItem - lv0.Text = sb.OriginalPath + lv0.Text = sb.Name LvCycles.Items.Add(lv0) Next - CbEngOnly.Checked = VEC0.EngineOnly + CbEngOnly.Checked = vectoJob.EngineOnlyMode - If VEC0.EcoRollOn Then + If driver.OverSpeedEcoRoll.Mode = DriverMode.EcoRoll Then RdEcoRoll.Checked = True - ElseIf VEC0.OverSpeedOn Then + ElseIf driver.OverSpeedEcoRoll.Mode = DriverMode.Overspeed Then RdOverspeed.Checked = True Else RdOff.Checked = True End If - TbOverspeed.Text = CStr(VEC0.OverSpeed) - TbUnderSpeed.Text = CStr(VEC0.UnderSpeed) - TbVmin.Text = CStr(VEC0.VMin) - CbLookAhead.Checked = VEC0.LookAheadOn + TbOverspeed.Text = driver.OverSpeedEcoRoll.MinSpeed.ToGUIFormat() + TbUnderSpeed.Text = driver.OverSpeedEcoRoll.UnderSpeed.ToGUIFormat() + TbVmin.Text = driver.OverSpeedEcoRoll.MinSpeed.ToGUIFormat() + CbLookAhead.Checked = driver.Lookahead.Enabled 'TbAlookahead.Text = CStr(VEC0.ALookahead) 'TbVminLA.Text = CStr(VEC0.VMinLa) - tbLacPreviewFactor.Text = CStr(VEC0.LacPreviewFactor) - tbDfCoastingOffset.Text = CStr(VEC0.LacDfOffset) - tbDfCoastingScale.Text = CStr(VEC0.LacDfScale) + tbLacPreviewFactor.Text = driver.Lookahead.LookaheadDistanceFactor.ToGUIFormat() + tbDfCoastingOffset.Text = driver.Lookahead.CoastingDecisionFactorOffset.ToGUIFormat() + tbDfCoastingScale.Text = driver.Lookahead.CoastingDecisionFactorScaling.ToGUIFormat() - tbLacDfTargetSpeedFile.Text = VEC0.LacDfTargetSpeedFile - tbLacDfVelocityDropFile.Text = VEC0.LacDfVelocityDropFile + tbLacDfTargetSpeedFile.Text = GetRelativePath(driver.Lookahead.CoastingDecisionFactorTargetSpeedLookup.Source, + _basePath) + tbLacDfVelocityDropFile.Text = GetRelativePath(driver.Lookahead.CoastingDecisionFactorVelocityDropLookup.Source, + _basePath) '------------------------------------------------------------- @@ -478,8 +494,6 @@ Public Class VectoJobForm VehicleForm.AutoSendTo = False - VECTOfile = file - Dim x As Integer = Len(file) While Mid(file, x, 1) <> "\" And x > 0 x = x - 1 @@ -538,8 +552,8 @@ Public Class VectoJobForm 'Start/Stop vec0.StartStop = ChBStartStop.Checked - vec0.StStV = TbSSspeed.Text.ToDouble() - vec0.StStT = TbSStime.Text.ToDouble() + vec0.StartStopMaxSpeed = TbSSspeed.Text.ToDouble() + vec0.StartStopTime = TbSStime.Text.ToDouble() vec0.StartStopDelay = TbSSdelay.Text.ToDouble() 'a_DesMax @@ -1014,7 +1028,7 @@ lbDlog: PicVehicle.Image = Nothing PicBox.Image = Nothing - Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(TbVEH.Text), + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(VECTOfile), IEngineeringInputDataProvider) Dim vehicle As IVehicleEngineeringInputData = inputData.VehicleInputData @@ -1071,11 +1085,11 @@ lbDlog: EngineIdleSpeed = engine.IdleSpeed.Value() - Dim fullLoadCurve As FullLoadCurve = FullLoadCurveReader.Create(engine.FullLoadCurve) + Dim fullLoadCurve As FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve) s = New Series - s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM), - fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value())) + s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkBlue @@ -1083,8 +1097,8 @@ lbDlog: MyChart.Series.Add(s) s = New Series - s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM), - fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value())) + s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.Blue @@ -1093,10 +1107,10 @@ lbDlog: OkCount += 1 - pmax = fullLoadCurve.RatedSpeed.Value() / 1000 'FLD0.Pfull(FLD0.EngineRatedSpeed) + pmax = fullLoadCurve.MaxPower.Value() / 1000 'FLD0.Pfull(FLD0.EngineRatedSpeed) - TbEngTxt.Text = (engine.Displacement.Value() / 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " & + TbEngTxt.Text = (engine.Displacement.Value() * 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " & engine.ModelName Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.FuelConsumptionMap) @@ -1172,6 +1186,7 @@ lbDlog: Else For Each gear As ITransmissionInputData In gearbox.Gears + If gear.ShiftPolygon.Rows.Count = 0 Then Continue For Dim shiftPolygon As ShiftPolygon = ShiftPolygonReader.Create(gear.ShiftPolygon) s = New Series s.Points.DataBindXY(shiftPolygon.Upshift.Select(Function(x) x.AngularSpeed), @@ -1237,6 +1252,7 @@ lbDlog: #Region "Open File Context Menu" Private CmFiles As String() + Private _basePath As String = "" Private Sub OpenFiles(ParamArray files() As String) If files.Length = 0 Then Exit Sub diff --git a/VECTO/GUI/VehicleAuxiliariesDialog.vb b/VECTO/GUI/VehicleAuxiliariesDialog.vb index aaa378ed3008004638bb86155b2c74c893f03142..d59afdd681359b491d43727ec8a78b94973551b2 100644 --- a/VECTO/GUI/VehicleAuxiliariesDialog.vb +++ b/VECTO/GUI/VehicleAuxiliariesDialog.vb @@ -11,6 +11,7 @@ Option Infer On Imports System.Windows.Forms +Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCore.Models.Declaration @@ -40,15 +41,15 @@ Public Class VehicleAuxiliariesDialog Private Sub DeclInit() CbTech.Items.Clear() Select Case TbID.Text - Case Constants.AuxiliaryKey.Fan + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.Fan CbTech.Items.AddRange(DeclarationData.Fan.GetTechnologies()) - Case Constants.AuxiliaryKey.SteerPump + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.SteeringPump CbTech.Items.AddRange(DeclarationData.SteeringPump.GetTechnologies()) - Case Constants.AuxiliaryKey.HVAC + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.HeatingVentilationAirCondition CbTech.Items.AddRange(DeclarationData.HeatingVentilationAirConditioning.GetTechnologies()) - Case Constants.AuxiliaryKey.ElecSys + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.ElectricSystem CbTech.Items.AddRange(DeclarationData.ElectricSystem.GetTechnologies()) - Case Constants.AuxiliaryKey.PneumSys + Case VectoCore.Configuration.Constants.Auxiliaries.IDs.PneumaticSystem CbTech.Items.AddRange(DeclarationData.PneumaticSystem.GetTechnologies()) End Select If CbTech.Items.Count > 0 Then @@ -107,12 +108,12 @@ Public Class VehicleAuxiliariesDialog If Cfg.DeclMode Then Select Case CbType.SelectedIndex Case 0 - TbID.Text = Constants.AuxiliaryKey.Fan + TbID.Text = VectoCore.Configuration.Constants.Auxiliaries.IDs.Fan Case 1 - TbID.Text = Constants.AuxiliaryKey.SteerPump + TbID.Text = VectoCore.Configuration.Constants.Auxiliaries.IDs.SteeringPump Case Else '2 - TbID.Text = Constants.AuxiliaryKey.HVAC + TbID.Text = VectoCore.Configuration.Constants.Auxiliaries.IDs.HeatingVentilationAirCondition End Select Else diff --git a/VECTO/Input Files/Engine.vb b/VECTO/Input Files/Engine.vb index b101bb10615fe167b424cccd28738dc5ddbdd7f5..9d124027983f405cfd0e17d02103185d8e873547 100644 --- a/VECTO/Input Files/Engine.vb +++ b/VECTO/Input Files/Engine.vb @@ -285,6 +285,17 @@ Public Class Engine #Region "IInputData" + Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Get + Return DataSourceType.JSONFile + End Get + End Property + Public ReadOnly Property Source As String Implements IComponentInputData.Source + Get + Return FilePath + End Get + End Property + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IComponentInputData.SavedInDeclarationMode Get Return Cfg.DeclMode diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index a90115f9a9da76f5e67192312aaf43bf9d819aca..874728be5bd9d15063bdec382e7e5284e7997ded 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -283,7 +283,7 @@ Public Class Gearbox result = axlegearData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) If result.Any() Then Return _ - New ValidationResult("Gearbox Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + New ValidationResult("Axlegear Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) End If Return ValidationResult.Success @@ -294,6 +294,17 @@ Public Class Gearbox End Function + Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Get + Return DataSourceType.JSONFile + End Get + End Property + Public ReadOnly Property Source As String Implements IComponentInputData.Source + Get + Return FilePath + End Get + End Property + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IComponentInputData.SavedInDeclarationMode Get Return Cfg.DeclMode diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index d2b414b0e327495137a7d3f240fb00f93f693c9c..95d8e2c00bc71d8cb88c45fd52772fece3e80adb 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -8,17 +8,31 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. -Option Infer On -Option Explicit On +'Option Infer On +'Option Explicit On Imports System.Collections.Generic +Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq Imports Newtonsoft.Json.Linq Imports TUGraz.VECTO.Input_Files +Imports TUGraz.VectoCommon.InputData +Imports TUGraz.VectoCommon.Models +Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON - +Imports TUGraz.VectoCore.InputData.Impl +Imports TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +Imports TUGraz.VectoCore.InputData.Reader.Impl +Imports TUGraz.VectoCore.Models.Simulation.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Utils + +<CustomValidation(GetType(VectoJob), "ValidateJob")> Public Class VectoJob + Implements IEngineeringInputDataProvider, IDeclarationInputDataProvider, IEngineeringJobInputData, + IDeclarationJobInputData, IDriverEngineeringInputData, IDriverDeclarationInputData + Private Const FormatVersion As Short = 3 'AA-TB @@ -36,8 +50,6 @@ Public Class VectoJob Private ReadOnly _gearboxFile As SubPath Private _startStop As Boolean - Private _startStopMaxSpeed As Double - Private _startStopMinTime As Double Public StartStopDelay As Double Private ReadOnly _driverAccelerationFile As SubPath @@ -57,6 +69,13 @@ Public Class VectoJob Public EcoRollOn As Boolean Public SavedInDeclMode As Boolean + Private _vehicleInputData As JSONComponentInputData + Private _engineInputData As JSONComponentInputData + Private _gearboxInputData As JSONComponentInputData + + Public Property StartStopMaxSpeed As Double + + Public Property StartStopTime As Double Public Class AuxEntry Public Type As String @@ -88,6 +107,17 @@ Public Class VectoJob Public Function SaveFile() As Boolean Dim json As New JSONParser + Dim validationResults As IList(Of ValidationResult) = + Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + + If validationResults.Count > 0 Then + Dim messages As IEnumerable(Of String) = + validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + MsgBox("Invalid input." + Environment.NewLine + String.Join("; ", messages), MsgBoxStyle.OkOnly, + "Failed to save Vecto Job") + Return False + End If + 'Header Dim header As Dictionary(Of String, Object) = New Dictionary(Of String, Object) From { {"CreatedBy", Lic.LicString & " (" & Lic.GUID & ")"}, @@ -96,7 +126,7 @@ Public Class VectoJob {"FileVersion", FormatVersion}} 'Body - Dim body = New Dictionary(Of String, Object) + Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) body.Add("SavedInDeclMode", Cfg.DeclMode) SavedInDeclMode = Cfg.DeclMode @@ -130,8 +160,8 @@ Public Class VectoJob body.Add("EngineOnlyMode", EngineOnly) body.Add("StartStop", New Dictionary(Of String, Object) From { {"Enabled", _startStop}, - {"MaxSpeed", _startStopMaxSpeed}, - {"MinTime", _startStopMinTime}, + {"MaxSpeed", StartStopMaxSpeed}, + {"MinTime", StartStopTime}, {"Delay", StartStopDelay}}) body.Add("LAC", New Dictionary(Of String, Object) From { {"Enabled", LookAheadOn}, @@ -142,7 +172,7 @@ Public Class VectoJob {"Df_velocityDropLookup", LacDfVelocityDropFile}}) 'Overspeed / EcoRoll - Dim overspeedDic = New Dictionary(Of String, Object) + Dim overspeedDic As Dictionary(Of String, Object) = New Dictionary(Of String, Object) If EcoRollOn Then overspeedDic.Add("Mode", "EcoRoll") ElseIf OverSpeedOn Then @@ -159,215 +189,215 @@ Public Class VectoJob Return json.WriteFile(_sFilePath) End Function - Public Function ReadFile() As Boolean - Const msgSrc = "Main/ReadInp/GEN" - - SetDefault() - - Dim json As New JSONParser - If Not json.ReadFile(_sFilePath) Then Return False - - Try - - Dim fileVersion As Integer = json.Content.GetEx("Header").GetEx(Of Integer)("FileVersion") - - Dim body As JToken = json.Content.GetEx("Body") - - If fileVersion > 1 Then - SavedInDeclMode = body.GetEx(Of Boolean)("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If - - If Not body("VehicleFile") Is Nothing Then _ - _vehicleFile.Init(_myPath, body.GetEx(Of String)("VehicleFile")) - - _engineFile.Init(_myPath, body.GetEx(Of String)("EngineFile")) - - If Not body("GearboxFile") Is Nothing Then _ - _gearboxFile.Init(_myPath, body.GetEx(Of String)("GearboxFile")) - - If Not body("Cycles") Is Nothing Then - For Each entry As JToken In body.GetEx("Cycles") - Dim subPath = New SubPath - subPath.Init(_myPath, entry.Value(Of String)) - CycleFiles.Add(subPath) - Next - End If - - 'AA-TB - 'ADVANCED AUXILIARIES - If Not body("AuxiliaryAssembly") Is Nothing AndAlso - Not body("AuxiliaryVersion") Is Nothing Then - - AuxiliaryAssembly = body("AuxiliaryAssembly").ToString() - AuxiliaryVersion = body("AuxiliaryVersion").ToString() - - End If - If Not body("AdvancedAuxiliaryFilePath") Is Nothing Then - AdvancedAuxiliaryFilePath = body("AdvancedAuxiliaryFilePath").ToString() - End If - - - If Not body("Aux") Is Nothing Then - For Each dic As JToken In body.GetEx("Aux") - - Dim auxId As String = UCase(Trim(dic.GetEx(Of String)("ID"))) - - If AuxPaths.ContainsKey(auxId) Then - WorkerMsg(MessageType.Err, "Multiple definitions of the same auxiliary type (" & auxId & ")!", msgSrc) - Return False - End If - - Dim auxEntry = New AuxEntry - - auxEntry.Type = dic.GetEx(Of String)("Type") - auxEntry.Path.Init(_myPath, dic.GetEx(Of String)("Path")) - - If Not dic("Technology") Is Nothing Then - If fileVersion = 2 Then - auxEntry.TechnologyList.Add(dic.GetEx(Of String)("Technology")) - End If - If fileVersion = 3 Then - auxEntry.TechnologyList = dic.GetEx("Technology").ToObject(Of List(Of String))() '.FirstOrDefault() - End If - End If - - If (auxId = Constants.AuxiliaryKey.HVAC) Then - If auxEntry.TechnologyList.Count > 0 Then ' Not String.IsNullOrWhiteSpace(auxEntry.TechStr) Then - auxEntry.TechnologyList.Clear() - WorkerMsg(MessageType.Normal, "Aux: Automatically Upgraded HVAC to new format.", msgSrc) - End If - End If - - If auxId = Constants.AuxiliaryKey.ElecSys Then - If auxEntry.TechnologyList.Contains("Custom Technology List") OrElse auxEntry.TechnologyList.Count > 0 Then - Dim hasTech = False - - If Not dic("TechList") Is Nothing Then - For Each t In dic("TechList") - hasTech = True - Next - End If - - auxEntry.TechnologyList.Clear() - If Not hasTech Then - auxEntry.TechnologyList.Add("Standard technology") - Else - auxEntry.TechnologyList.Add("Standard technology - LED headlights, all") - End If - WorkerMsg(MessageType.Normal, - "Aux: Automatically Upgraded Electric System to new format: '" + auxEntry.TechnologyList.FirstOrDefault() + "'", - msgSrc) - End If - End If - - If auxId = Constants.AuxiliaryKey.SteerPump Then - If _ - auxEntry.TechnologyList.Contains("Variable displacement") OrElse - auxEntry.TechnologyList.Contains("Hydraulic supported by electric") Then - auxEntry.TechnologyList.Clear() - WorkerMsg(MessageType.Warn, "Aux: Steering Pump Technology not automatically convertible. Please set new value.", - msgSrc) - End If - End If - - If auxId = Constants.AuxiliaryKey.Fan Then - If auxEntry.TechnologyList.Contains("Crankshaft mounted - Electronically controlled visco clutch (Default)") Then - auxEntry.TechnologyList.Clear() - auxEntry.TechnologyList.Add("Crankshaft mounted - Electronically controlled visco clutch") - End If - If auxEntry.TechnologyList.Contains("Crankshaft mounted - On/Off clutch") Then - auxEntry.TechnologyList.Clear() - auxEntry.TechnologyList.Add("Crankshaft mounted - On/off clutch") - End If - If auxEntry.TechnologyList.Contains("Belt driven or driven via transm. - On/Off clutch") Then - auxEntry.TechnologyList.Clear() - auxEntry.TechnologyList.Add("Belt driven or driven via transm. - On/off clutch") - End If - End If - - If fileVersion = 2 AndAlso auxId = Constants.AuxiliaryKey.PneumSys Then - auxEntry.TechnologyList.Clear() - WorkerMsg(MessageType.Warn, "Aux: Pneumatic System must be updated. Please set new value.", - msgSrc) - End If - - AuxPaths.Add(auxId, auxEntry) - - Next - End If - - If Not body("VACC") Is Nothing Then - _driverAccelerationFile.Init(_myPath, body.GetEx(Of String)("VACC")) - End If - - EngineOnly = body.GetEx(Of Boolean)("EngineOnlyMode") - - If Not body("StartStop") Is Nothing Then - Dim startStop As JToken = body.GetEx("StartStop") - _startStop = startStop.GetEx(Of Boolean)("Enabled") - _startStopMaxSpeed = startStop.GetEx(Of Double)("MaxSpeed") - _startStopMinTime = startStop.GetEx(Of Double)("MinTime") - StartStopDelay = startStop.GetEx(Of Double)("Delay") - Else - _startStop = False - End If - - If Not body("LAC") Is Nothing Then - Dim lac = body.GetEx("LAC") - LookAheadOn = lac.GetEx(Of Boolean)("Enabled") - LacPreviewFactor = If(lac("PreviewDistanceFactor") Is Nothing, 10, lac.GetEx(Of Double)("PreviewDistanceFactor")) - LacDfOffset = If(lac("DF_offset") Is Nothing, 2.5, lac.GetEx(Of Double)("DF_offset")) - LacDfScale = If(lac("DF_scaling") Is Nothing, 1.5, lac.GetEx(Of Double)("DF_scaling")) - LacDfTargetSpeedFile = - If(Not lac("DF_targetSpeedLookup") Is Nothing, lac.GetEx(Of String)("DF_targetSpeedLookup"), "") - LacDfVelocityDropFile = - If(Not lac("Df_velocityDropLookup") Is Nothing, lac.GetEx(Of String)("Df_velocityDropLookup"), "") - Else - LookAheadOn = False - End If - - If Not body("OverSpeedEcoRoll") Is Nothing Then - Dim dic = body("OverSpeedEcoRoll") - - Select Case UCase(dic("Mode").ToString).Trim - Case "ECOROLL" - OverSpeedOn = False - EcoRollOn = True - - Case "OVERSPEED" - OverSpeedOn = True - EcoRollOn = False - - Case "OFF" - OverSpeedOn = False - EcoRollOn = False - - Case Else - WorkerMsg(MessageType.Err, "Value '" & dic("Mode").ToString() & "' is not valid for OverSpeedEcoRoll/Mode!", - msgSrc) - Return False - End Select - - VMin = dic.GetEx(Of Double)("MinSpeed") - OverSpeed = dic.GetEx(Of Double)("OverSpeed") - If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic.GetEx(Of Double)("UnderSpeed") - - Else - OverSpeedOn = False - EcoRollOn = False - End If - + 'Public Function ReadFile() As Boolean + ' Const msgSrc = "Main/ReadInp/GEN" - Catch ex As Exception - WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, msgSrc) - Return False - End Try + ' SetDefault() - - Return True - End Function + ' Dim json As New JSONParser + ' If Not json.ReadFile(_sFilePath) Then Return False + + ' Try + + ' Dim fileVersion As Integer = json.Content.GetEx("Header").GetEx(Of Integer)("FileVersion") + + ' Dim body As JToken = json.Content.GetEx("Body") + + ' If fileVersion > 1 Then + ' SavedInDeclMode = body.GetEx(Of Boolean)("SavedInDeclMode") + ' Else + ' SavedInDeclMode = Cfg.DeclMode + ' End If + + ' If Not body("VehicleFile") Is Nothing Then _ + ' _vehicleFile.Init(_myPath, body.GetEx(Of String)("VehicleFile")) + + ' _engineFile.Init(_myPath, body.GetEx(Of String)("EngineFile")) + + ' If Not body("GearboxFile") Is Nothing Then _ + ' _gearboxFile.Init(_myPath, body.GetEx(Of String)("GearboxFile")) + + ' If Not body("Cycles") Is Nothing Then + ' For Each entry As JToken In body.GetEx("Cycles") + ' Dim subPath = New SubPath + ' subPath.Init(_myPath, entry.Value(Of String)) + ' CycleFiles.Add(subPath) + ' Next + ' End If + + ' 'AA-TB + ' 'ADVANCED AUXILIARIES + ' If Not body("AuxiliaryAssembly") Is Nothing AndAlso + ' Not body("AuxiliaryVersion") Is Nothing Then + + ' AuxiliaryAssembly = body("AuxiliaryAssembly").ToString() + ' AuxiliaryVersion = body("AuxiliaryVersion").ToString() + + ' End If + ' If Not body("AdvancedAuxiliaryFilePath") Is Nothing Then + ' AdvancedAuxiliaryFilePath = body("AdvancedAuxiliaryFilePath").ToString() + ' End If + + + ' If Not body("Aux") Is Nothing Then + ' For Each dic As JToken In body.GetEx("Aux") + + ' Dim auxId As String = UCase(Trim(dic.GetEx(Of String)("ID"))) + + ' If AuxPaths.ContainsKey(auxId) Then + ' WorkerMsg(MessageType.Err, "Multiple definitions of the same auxiliary type (" & auxId & ")!", msgSrc) + ' Return False + ' End If + + ' Dim auxEntry = New AuxEntry + + ' auxEntry.Type = dic.GetEx(Of String)("Type") + ' auxEntry.Path.Init(_myPath, dic.GetEx(Of String)("Path")) + + ' If Not dic("Technology") Is Nothing Then + ' If fileVersion = 2 Then + ' auxEntry.TechnologyList.Add(dic.GetEx(Of String)("Technology")) + ' End If + ' If fileVersion = 3 Then + ' auxEntry.TechnologyList = dic.GetEx("Technology").ToObject(Of List(Of String))() '.FirstOrDefault() + ' End If + ' End If + + ' If (auxId = Constants.AuxiliaryKey.HVAC) Then + ' If auxEntry.TechnologyList.Count > 0 Then ' Not String.IsNullOrWhiteSpace(auxEntry.TechStr) Then + ' auxEntry.TechnologyList.Clear() + ' WorkerMsg(MessageType.Normal, "Aux: Automatically Upgraded HVAC to new format.", msgSrc) + ' End If + ' End If + + ' If auxId = Constants.AuxiliaryKey.ElecSys Then + ' If auxEntry.TechnologyList.Contains("Custom Technology List") OrElse auxEntry.TechnologyList.Count > 0 Then + ' Dim hasTech = False + + ' If Not dic("TechList") Is Nothing Then + ' For Each t In dic("TechList") + ' hasTech = True + ' Next + ' End If + + ' auxEntry.TechnologyList.Clear() + ' If Not hasTech Then + ' auxEntry.TechnologyList.Add("Standard technology") + ' Else + ' auxEntry.TechnologyList.Add("Standard technology - LED headlights, all") + ' End If + ' WorkerMsg(MessageType.Normal, + ' "Aux: Automatically Upgraded Electric System to new format: '" + auxEntry.TechnologyList.FirstOrDefault() + "'", + ' msgSrc) + ' End If + ' End If + + ' If auxId = Constants.AuxiliaryKey.SteerPump Then + ' If _ + ' auxEntry.TechnologyList.Contains("Variable displacement") OrElse + ' auxEntry.TechnologyList.Contains("Hydraulic supported by electric") Then + ' auxEntry.TechnologyList.Clear() + ' WorkerMsg(MessageType.Warn, "Aux: Steering Pump Technology not automatically convertible. Please set new value.", + ' msgSrc) + ' End If + ' End If + + ' If auxId = Constants.AuxiliaryKey.Fan Then + ' If auxEntry.TechnologyList.Contains("Crankshaft mounted - Electronically controlled visco clutch (Default)") Then + ' auxEntry.TechnologyList.Clear() + ' auxEntry.TechnologyList.Add("Crankshaft mounted - Electronically controlled visco clutch") + ' End If + ' If auxEntry.TechnologyList.Contains("Crankshaft mounted - On/Off clutch") Then + ' auxEntry.TechnologyList.Clear() + ' auxEntry.TechnologyList.Add("Crankshaft mounted - On/off clutch") + ' End If + ' If auxEntry.TechnologyList.Contains("Belt driven or driven via transm. - On/Off clutch") Then + ' auxEntry.TechnologyList.Clear() + ' auxEntry.TechnologyList.Add("Belt driven or driven via transm. - On/off clutch") + ' End If + ' End If + + ' If fileVersion = 2 AndAlso auxId = Constants.AuxiliaryKey.PneumSys Then + ' auxEntry.TechnologyList.Clear() + ' WorkerMsg(MessageType.Warn, "Aux: Pneumatic System must be updated. Please set new value.", + ' msgSrc) + ' End If + + ' AuxPaths.Add(auxId, auxEntry) + + ' Next + ' End If + + ' If Not body("VACC") Is Nothing Then + ' _driverAccelerationFile.Init(_myPath, body.GetEx(Of String)("VACC")) + ' End If + + ' EngineOnly = body.GetEx(Of Boolean)("EngineOnlyMode") + + ' If Not body("StartStop") Is Nothing Then + ' Dim startStop As JToken = body.GetEx("StartStop") + ' _startStop = startStop.GetEx(Of Boolean)("Enabled") + ' _startStopMaxSpeed = startStop.GetEx(Of Double)("MaxSpeed") + ' _startStopMinTime = startStop.GetEx(Of Double)("MinTime") + ' StartStopDelay = startStop.GetEx(Of Double)("Delay") + ' Else + ' _startStop = False + ' End If + + ' If Not body("LAC") Is Nothing Then + ' Dim lac = body.GetEx("LAC") + ' LookAheadOn = lac.GetEx(Of Boolean)("Enabled") + ' LacPreviewFactor = If(lac("PreviewDistanceFactor") Is Nothing, 10, lac.GetEx(Of Double)("PreviewDistanceFactor")) + ' LacDfOffset = If(lac("DF_offset") Is Nothing, 2.5, lac.GetEx(Of Double)("DF_offset")) + ' LacDfScale = If(lac("DF_scaling") Is Nothing, 1.5, lac.GetEx(Of Double)("DF_scaling")) + ' LacDfTargetSpeedFile = + ' If(Not lac("DF_targetSpeedLookup") Is Nothing, lac.GetEx(Of String)("DF_targetSpeedLookup"), "") + ' LacDfVelocityDropFile = + ' If(Not lac("Df_velocityDropLookup") Is Nothing, lac.GetEx(Of String)("Df_velocityDropLookup"), "") + ' Else + ' LookAheadOn = False + ' End If + + ' If Not body("OverSpeedEcoRoll") Is Nothing Then + ' Dim dic = body("OverSpeedEcoRoll") + + ' Select Case UCase(dic("Mode").ToString).Trim + ' Case "ECOROLL" + ' OverSpeedOn = False + ' EcoRollOn = True + + ' Case "OVERSPEED" + ' OverSpeedOn = True + ' EcoRollOn = False + + ' Case "OFF" + ' OverSpeedOn = False + ' EcoRollOn = False + + ' Case Else + ' WorkerMsg(MessageType.Err, "Value '" & dic("Mode").ToString() & "' is not valid for OverSpeedEcoRoll/Mode!", + ' msgSrc) + ' Return False + ' End Select + + ' VMin = dic.GetEx(Of Double)("MinSpeed") + ' OverSpeed = dic.GetEx(Of Double)("OverSpeed") + ' If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic.GetEx(Of Double)("UnderSpeed") + + ' Else + ' OverSpeedOn = False + ' EcoRollOn = False + ' End If + + + ' Catch ex As Exception + ' WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, msgSrc) + ' Return False + ' End Try + + + ' Return True + 'End Function Private Sub SetDefault() @@ -377,8 +407,8 @@ Public Class VectoJob _startStop = False - _startStopMaxSpeed = 5 - _startStopMinTime = 5 + StartStopMaxSpeed = 5 + StartStopTime = 5 StartStopDelay = 0 _vehicleFile.Clear() @@ -462,6 +492,12 @@ Public Class VectoJob End Property + Public ReadOnly Property IDriverDeclarationInputData_SavedInDeclarationMode As Boolean _ + Implements IDriverDeclarationInputData.SavedInDeclarationMode + Get + End Get + End Property + Public Property StartStop As Boolean Get Return _startStop @@ -471,24 +507,64 @@ Public Class VectoJob End Set End Property - Public Property StStV As Double + Public ReadOnly Property IDriverEngineeringInputData_OverSpeedEcoRoll As IOverSpeedEcoRollEngineeringInputData _ + Implements IDriverEngineeringInputData.OverSpeedEcoRoll Get - Return _startStopMaxSpeed + Dim mode As DriverMode = DriverMode.Off + If EcoRollOn Then + mode = DriverMode.EcoRoll + ElseIf OverSpeedOn Then + mode = DriverMode.Overspeed + End If + + Return New OverSpeedEcoRollInputData() With { + .Mode = mode, + .MinSpeed = VMin.KMPHtoMeterPerSecond(), + .OverSpeed = OverSpeed.KMPHtoMeterPerSecond(), + .UnderSpeed = UnderSpeed.KMPHtoMeterPerSecond() + } End Get - Set(value As Double) - _startStopMaxSpeed = value - End Set End Property - Public Property StStT As Double + Public ReadOnly Property IDriverEngineeringInputData_StartStop As IStartStopEngineeringInputData _ + Implements IDriverEngineeringInputData.StartStop Get - Return _startStopMinTime + Return New StartStopInputData With { + .Enabled = _startStop, + .MaxSpeed = StartStopMaxSpeed.KMPHtoMeterPerSecond(), + .MinTime = StartStopTime.SI(Of Second)(), + .Delay = StartStopDelay.SI(Of Second)() + } + End Get + End Property + + Public ReadOnly Property OverSpeedEcoRoll As IOverSpeedEcoRollDeclarationInputData _ + Implements IDriverDeclarationInputData.OverSpeedEcoRoll + Get + Return IDriverEngineeringInputData_OverSpeedEcoRoll + End Get + End Property + + Public ReadOnly Property AccelerationCurve As TableData Implements IDriverEngineeringInputData.AccelerationCurve + Get + Return VectoCSVFile.Read(_driverAccelerationFile.FullPath) + End Get + End Property + + Public ReadOnly Property Lookahead As ILookaheadCoastingInputData Implements IDriverEngineeringInputData.Lookahead + Get + Return New LookAheadCoastingInputData With { + .CoastingDecisionFactorScaling = LacDfScale, + .CoastingDecisionFactorOffset = LacDfOffset, + .Enabled = LookAheadOn, + .LookaheadDistanceFactor = LacPreviewFactor, + .CoastingDecisionFactorTargetSpeedLookup = VectoCSVFile.Read(LacDfTargetSpeedFile), + .CoastingDecisionFactorVelocityDropLookup = VectoCSVFile.Read(LacDfVelocityDropFile) + } End Get - Set(value As Double) - _startStopMinTime = value - End Set End Property + Public Property DesMaxFile(Optional ByVal original As Boolean = False) As String Get If original Then @@ -509,6 +585,243 @@ Public Class VectoJob Public Property LacDfVelocityDropFile As String +#End Region + + ' ReSharper disable once UnusedMember.Global -- used by Validation + Public Shared Function ValidateJob(vectoJob As VectoJob, validationContext As ValidationContext) As ValidationResult + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + ExecutionModeServiceContainer) + Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) + + Dim jobData As IEnumerable(Of VectoRunData) + + vectoJob._vehicleInputData = New JSONComponentInputData(vectoJob._vehicleFile.FullPath) + vectoJob._engineInputData = New JSONComponentInputData(vectoJob._engineFile.FullPath) + vectoJob._gearboxInputData = New JSONComponentInputData(vectoJob._gearboxFile.FullPath) + + Try + If mode = ExecutionMode.Declaration Then + Dim dataFactory As DeclarationModeVectoRunDataFactory = New DeclarationModeVectoRunDataFactory(vectoJob, Nothing) + jobData = dataFactory.NextRun() + Else + Dim dataFactory As EngineeringModeVectoRunDataFactory = New EngineeringModeVectoRunDataFactory(vectoJob) + jobData = dataFactory.NextRun() + End If + + Dim result As IList(Of ValidationResult) = + jobData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + + Return ValidationResult.Success + + Catch ex As Exception + Return New ValidationResult(ex.Message) + Finally + vectoJob._vehicleInputData = Nothing + vectoJob._engineInputData = Nothing + vectoJob._gearboxInputData = Nothing + End Try + End Function + +#Region "IInputData" + + Public Function JobInputData() As IEngineeringJobInputData Implements IEngineeringInputDataProvider.JobInputData + Return Me + End Function + + Public ReadOnly Property IDeclarationInputDataProvider_VehicleInputData As IVehicleDeclarationInputData _ + Implements IDeclarationInputDataProvider.VehicleInputData + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public Function IDeclarationInputDataProvider_JobInputData() As IDeclarationJobInputData _ + Implements IDeclarationInputDataProvider.JobInputData + Throw New NotImplementedException + End Function + + Public ReadOnly Property VehicleInputData As IVehicleEngineeringInputData _ + Implements IEngineeringInputDataProvider.VehicleInputData + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_GearboxInputData As IGearboxDeclarationInputData _ + Implements IDeclarationInputDataProvider.GearboxInputData + Get + Return _gearboxInputData.GearboxInputData + End Get + End Property + + Public ReadOnly Property GearboxInputData As IGearboxEngineeringInputData _ + Implements IEngineeringInputDataProvider.GearboxInputData + Get + Return _gearboxInputData.GearboxInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_TorqueConverterInputData As ITorqueConverterDeclarationInputData _ + Implements IDeclarationInputDataProvider.TorqueConverterInputData + Get + Return _gearboxInputData.TorqueConverterInputData + End Get + End Property + + Public ReadOnly Property TorqueConverterInputData As ITorqueConverterEngineeringInputData _ + Implements IEngineeringInputDataProvider.TorqueConverterInputData + Get + Return _gearboxInputData.TorqueConverterInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_AxleGearInputData As IAxleGearInputData _ + Implements IDeclarationInputDataProvider.AxleGearInputData + Get + Return _gearboxInputData.AxleGearInputData + End Get + End Property + + Public ReadOnly Property AxleGearInputData As IAxleGearInputData _ + Implements IEngineeringInputDataProvider.AxleGearInputData + Get + Return _gearboxInputData.AxleGearInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_AngularGearInputData As IAngularGearInputData _ + Implements IDeclarationInputDataProvider.AngularGearInputData + Get + Return _vehicleInputData.AngularGearInputData + End Get + End Property + + Public ReadOnly Property AngularGearInputData As IAngularGearInputData _ + Implements IEngineeringInputDataProvider.AngularGearInputData + Get + Return _vehicleInputData.AngularGearInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_EngineInputData As IEngineDeclarationInputData _ + Implements IDeclarationInputDataProvider.EngineInputData + Get + Return _engineInputData.EngineInputData + End Get + End Property + + Public ReadOnly Property EngineInputData As IEngineEngineeringInputData _ + Implements IEngineeringInputDataProvider.EngineInputData + Get + Return _engineInputData.EngineInputData + End Get + End Property + + Public Function AuxiliaryInputData() As IAuxiliariesEngineeringInputData _ + Implements IEngineeringInputDataProvider.AuxiliaryInputData + + Throw New NotImplementedException + End Function + + Public ReadOnly Property IDeclarationInputDataProvider_RetarderInputData As IRetarderInputData _ + Implements IDeclarationInputDataProvider.RetarderInputData + Get + Return _vehicleInputData.RetarderInputData + End Get + End Property + + Public Function IDeclarationInputDataProvider_AuxiliaryInputData() As IAuxiliariesDeclarationInputData _ + Implements IDeclarationInputDataProvider.AuxiliaryInputData + Throw New NotImplementedException + End Function + + Public ReadOnly Property RetarderInputData As IRetarderInputData _ + Implements IEngineeringInputDataProvider.RetarderInputData + Get + Return _vehicleInputData.RetarderInputData + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_DriverInputData As IDriverDeclarationInputData _ + Implements IDeclarationInputDataProvider.DriverInputData + Get + Return Me + End Get + End Property + + Public ReadOnly Property DriverInputData As IDriverEngineeringInputData _ + Implements IEngineeringInputDataProvider.DriverInputData + Get + Return Me + End Get + End Property + + Public ReadOnly Property PTOTransmissionInputData As IPTOTransmissionInputData _ + Implements IEngineeringInputDataProvider.PTOTransmissionInputData + Get + Return _vehicleInputData.PTOTransmissionInputData + End Get + End Property + + + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IDeclarationJobInputData.SavedInDeclarationMode + Get + Return SavedInDeclMode + End Get + End Property + + Public ReadOnly Property IDriverDeclarationInputData_StartStop As IStartStopDeclarationInputData _ + Implements IDriverDeclarationInputData.StartStop + Get + Return IDriverEngineeringInputData_StartStop + End Get + End Property + + Public ReadOnly Property IEngineeringJobInputData_Vehicle As IVehicleEngineeringInputData _ + Implements IEngineeringJobInputData.Vehicle + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public ReadOnly Property Vehicle As IVehicleDeclarationInputData Implements IDeclarationJobInputData.Vehicle + Get + Return _vehicleInputData.VehicleInputData + End Get + End Property + + Public ReadOnly Property Cycles As IList(Of ICycleData) Implements IEngineeringJobInputData.Cycles + Get + Dim retVal As ICycleData() = New ICycleData(CycleFiles.Count) {} + Dim i As Integer = 0 + For Each cycleFile As SubPath In CycleFiles + retVal(i) = New CycleInputData With { + .Name = Path.GetFileNameWithoutExtension(cycleFile.FullPath), + .CycleData = VectoCSVFile.Read(cycleFile.FullPath) + } + i += 1 + Next + Return retVal + End Get + End Property + + Public ReadOnly Property EngineOnlyMode As Boolean Implements IEngineeringJobInputData.EngineOnlyMode + Get + Return EngineOnly + End Get + End Property + + Public ReadOnly Property JobName As String Implements IDeclarationJobInputData.JobName + Get + Return Path.GetFileNameWithoutExtension(FilePath) + End Get + End Property + #End Region End Class diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index eb8af084c94d53ac025b57b795bfb5f6439c83f7..7d88a89fc5a4f9ea05be98c5aa99576c507ed24b 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -28,7 +28,8 @@ Imports TUGraz.VectoCore.Utils <CustomValidation(GetType(Vehicle), "ValidateVehicle")> Public Class Vehicle - Implements IVehicleEngineeringInputData, IVehicleDeclarationInputData + Implements IVehicleEngineeringInputData, IVehicleDeclarationInputData, IRetarderInputData, IPTOTransmissionInputData, + IAngularGearInputData 'V2 MassMax is now saved in [t] instead of [kg] Private Const FormatVersion As Short = 7 Private _fileVersion As Integer @@ -95,6 +96,9 @@ Public Class Vehicle Public Shared Function ValidateVehicle(vehicle As Vehicle, validationContext As ValidationContext) As ValidationResult Dim vehicleData As VehicleData + Dim retarderData As RetarderData + Dim ptoData As PTOData = Nothing + Dim angledriveData As AngularGearData Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), ExecutionModeServiceContainer) @@ -107,17 +111,45 @@ Public Class Vehicle vehicle.GrossVehicleMassRating, vehicle.CurbWeightChassis) vehicleData = doa.CreateVehicleData(vehicle, segment.Missions.First(), segment.Missions.First().Loadings.First().Value) + retarderData = doa.CreateRetarderData(vehicle) + angledriveData = doa.CreateAngularGearData(vehicle, False) Else Dim doa As EngineeringDataAdapter = New EngineeringDataAdapter() vehicleData = doa.CreateVehicleData(vehicle) + retarderData = doa.CreateRetarderData(vehicle) + angledriveData = doa.CreateAngularGearData(vehicle, True) + ptoData = doa.CreatePTOTransmissionData(vehicle) End If Dim result As IList(Of ValidationResult) = vehicleData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Vehicle Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + result = retarderData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("Retarder Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + result = angledriveData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("AngleDrive Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + If Not ptoData Is Nothing Then + result = ptoData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) + If result.Any() Then + Return _ + New ValidationResult("PTO Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + End If - If Not result.Any() Then Return ValidationResult.Success + Return ValidationResult.Success - Return New ValidationResult("Vehicle Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) Catch ex As Exception Return New ValidationResult(ex.Message) End Try @@ -164,7 +196,8 @@ Public Class Vehicle Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering)) If validationResults.Count > 0 Then - Dim messages As IEnumerable(Of String) = validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + Dim messages As IEnumerable(Of String) = + validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) MsgBox("Invalid input." + Environment.NewLine + String.Join("; ", messages), MsgBoxStyle.OkOnly, "Failed to save vehicle") Return False @@ -243,6 +276,18 @@ Public Class Vehicle #Region "IInputData" + Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Get + Return DataSourceType.JSONFile + End Get + End Property + + Public ReadOnly Property Source As String Implements IComponentInputData.Source + Get + Return FilePath + End Get + End Property + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IComponentInputData.SavedInDeclarationMode Get Return Cfg.DeclMode @@ -340,6 +385,8 @@ Public Class Vehicle Private Function AxleWheels() As IEnumerable(Of AxleInputData) Return Axles.Select(Function(axle) New AxleInputData With { + .SourceType = DataSourceType.JSONFile, + .Source = FilePath, .Inertia = axle.Inertia.SI(Of KilogramSquareMeter)(), .Wheels = axle.Wheels, .AxleWeightShare = axle.Share, @@ -383,5 +430,67 @@ Public Class Vehicle End Get End Property + + Public ReadOnly Property Type As RetarderType Implements IRetarderInputData.Type + Get + Return RetarderType + End Get + End Property + + Public ReadOnly Property IAngularGearInputData_Ratio As Double Implements IAngularGearInputData.Ratio + Get + Return AngularGearRatio + End Get + End Property + + Public ReadOnly Property IAngularGearInputData_Type As AngularGearType Implements IAngularGearInputData.Type + Get + Return AngularGearType + End Get + End Property + + Public ReadOnly Property Ratio As Double Implements IRetarderInputData.Ratio + Get + Return RetarderRatio + End Get + End Property + + Public ReadOnly Property IAngularGearInputData_LossMap As TableData Implements IAngularGearInputData.LossMap + Get + Return VectoCSVFile.Read(AngularGearLossMapFile.FullPath) + End Get + End Property + + Public ReadOnly Property LossMap As TableData Implements IRetarderInputData.LossMap + Get + Return VectoCSVFile.Read(RetarderLossMapFile.FullPath) + End Get + End Property + + Public ReadOnly Property Efficiency As Double Implements IAngularGearInputData.Efficiency + Get + Return If(IsNumeric(AngularGearLossMapFile.OriginalPath), AngularGearLossMapFile.OriginalPath.ToDouble(), -1.0) + End Get + End Property + #End Region + + Public ReadOnly Property PTOTransmissionType As String Implements IPTOTransmissionInputData.PTOTransmissionType + Get + Return PTOType + End Get + End Property + + Public ReadOnly Property IPTOTransmissionInputData_PTOCycle As TableData Implements IPTOTransmissionInputData.PTOCycle + Get + Return VectoCSVFile.Read(PTOCycle.FullPath) + End Get + End Property + + Public ReadOnly Property IPTOTransmissionInputData_PTOLossMap As TableData _ + Implements IPTOTransmissionInputData.PTOLossMap + Get + Return VectoCSVFile.Read(PTOLossMap.FullPath) + End Get + End Property End Class \ No newline at end of file diff --git a/VECTO/VECTO_Global.vb b/VECTO/VECTO_Global.vb index 9fd843c88bbe785d2c375731a7a5b989f5deeb5b..5abd3463505a99eefa0661e8d519309f0c62a1fe 100644 --- a/VECTO/VECTO_Global.vb +++ b/VECTO/VECTO_Global.vb @@ -267,13 +267,7 @@ Module Constants ' ReSharper disable once ClassNeverInstantiated.Global - Public Class AuxiliaryKey - Public Const Fan As String = "FAN" - Public Const SteerPump As String = "STP" - Public Const HVAC As String = "AC" - Public Const ElecSys As String = "ES" - Public Const PneumSys As String = "PS" - End Class + End Module diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index 3b79def2f7d7072f73ad87109880792f1ce344fc..913b3cb088c5c21254f82703d852b7d88fbb5859 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -47,6 +47,10 @@ namespace TUGraz.VectoCommon.InputData public interface IComponentInputData { + DataSourceType SourceType { get; } + + string Source { get; } + bool SavedInDeclarationMode { get; } string Vendor { get; } diff --git a/VectoCommon/VectoCommon/InputData/TableData.cs b/VectoCommon/VectoCommon/InputData/TableData.cs index 783e06acaa4a5c8fc85d89fcca902583ef2f37ef..218a4f67a3f2047322a64e879e65d585113c9022 100644 --- a/VectoCommon/VectoCommon/InputData/TableData.cs +++ b/VectoCommon/VectoCommon/InputData/TableData.cs @@ -4,12 +4,6 @@ namespace TUGraz.VectoCommon.InputData { public class TableData : DataTable { - public enum DataSourceType - { - Embedded, - CSVFile, - } - public TableData(string fileName) { SourceType = DataSourceType.CSVFile; diff --git a/VectoCommon/VectoCommon/VectoCommon.csproj b/VectoCommon/VectoCommon/VectoCommon.csproj index c29e1da6e8df24ea5db74bc89e1446c1aaf85e69..767d0d4874514eb826aa59d86499fc953d7e02dc 100644 --- a/VectoCommon/VectoCommon/VectoCommon.csproj +++ b/VectoCommon/VectoCommon/VectoCommon.csproj @@ -44,6 +44,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="InputData\DataSourceType.cs" /> <Compile Include="InputData\TableData.cs"> <SubType>Component</SubType> </Compile> diff --git a/VectoConsole/Properties/Version.cs b/VectoConsole/Properties/Version.cs index 70953ae2e91733e7f7fb770f74c2d05a3dbebffe..ae81b564be17dd880d4bd19c5e27250f8e6f369a 100644 --- a/VectoConsole/Properties/Version.cs +++ b/VectoConsole/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.0.3.613")] -[assembly: AssemblyFileVersion("3.0.3.613")] +[assembly: AssemblyVersion("3.0.3.622")] +[assembly: AssemblyFileVersion("3.0.3.622")] diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 58acc3f13069b4f4576fe03bce1086c7cce0f304..e78c720a5d212b1f31059092f4b6c13f183afa1d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { public abstract class JSONFile : LoggingObject { - private string _basePath; + private readonly string _sourceFile; protected readonly JObject Header; protected readonly JObject Body; @@ -59,7 +59,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { Header = (JObject)data.GetEx(JsonKeys.JsonHeader); Body = (JObject)data.GetEx(JsonKeys.JsonBody); - BasePath = filename; + _sourceFile = Path.GetFullPath(filename); + } + + public DataSourceType SourceType + { + get { return DataSourceType.JSONFile; } + } + + public string Source + { + get { return _sourceFile; } } public bool SavedInDeclarationMode @@ -69,8 +79,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON internal string BasePath { - get { return _basePath; } - set { _basePath = Path.GetDirectoryName(Path.GetFullPath(value)); } + get { return Path.GetDirectoryName(_sourceFile); } } protected TableData ReadTableData(string filename, string tableType, bool required = true) diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index da8c9daa9954deea0d12fb89ae4e74cd9b563737..45c648a28899dbef63415149d2a08323f67fad88 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -117,6 +117,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON return Body.GetEx(JsonKeys.Vehicle_AxleConfiguration).GetEx(JsonKeys.Vehicle_AxleConfiguration_Axles).Select( axle => new AxleInputData { + SourceType = DataSourceType.JSONFile, + Source = Source, Inertia = axle.GetEx<double>(JsonKeys.Vehicle_Axles_Inertia).SI<KilogramSquareMeter>(), Wheels = axle.GetEx<string>(JsonKeys.Vehicle_Axles_Wheels), TwinTyres = axle.GetEx<bool>(JsonKeys.Vehicle_Axles_TwinTyres), diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs index 22c6fbf007a36c743d82237d1f90e0d50e5c56fd..442266ea11cbdb7daeb4abc364833446b20f15b1 100644 --- a/VectoCore/VectoCore/InputData/Impl/InputData.cs +++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs @@ -98,6 +98,7 @@ namespace TUGraz.VectoCore.InputData.Impl public class AxleInputData : IAxleEngineeringInputData { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] public bool SavedInDeclarationMode @@ -105,6 +106,10 @@ namespace TUGraz.VectoCore.InputData.Impl get { throw new System.NotImplementedException(); } } + public DataSourceType SourceType { get; internal set; } + + public string Source { get; internal set; } + public string Vendor { get; internal set; } public string ModelName { get; internal set; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 908289bf36e81080fe2abd95bdcaf2f2b2ade568..dd1d50c27d51170b469c7ff4356fc47a6d094adf 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -302,7 +302,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter } //================================= - public RetarderData CreateRetarderData(IRetarderInputData retarder, IVehicleEngineeringInputData vehicle) + public RetarderData CreateRetarderData(IRetarderInputData retarder) { return SetCommonRetarderData(retarder); } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs index 4ea718fb179e8097c4742b151d5d3277f43d2f4a..d83f066d71cde95be6910d9cce1ca67bfc1f07c9 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs @@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = driver, Aux = dao.CreateAuxiliaryData(InputDataProvider.AuxiliaryInputData()), AdvancedAux = dao.CreateAdvancedAuxData(InputDataProvider.AuxiliaryInputData()), - Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData, InputDataProvider.VehicleInputData), + Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData), PTO = ptoTransmissionData, Cycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, crossWindRequired), ExecutionMode = ExecutionMode.Engineering diff --git a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs index c1f94c0cc4b27a410811a728acddbaec2c9ab632..e037090a0d476dfedeee82a0403a209eb63cedda 100644 --- a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs +++ b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs @@ -15,6 +15,14 @@ namespace TUGraz.VectoCore.Models.Declaration { AuxiliaryType.ElectricSystem, Constants.Auxiliaries.Names.ElectricSystem }, }; + private static readonly Dictionary<AuxiliaryType, string> AuxToKey = new Dictionary<AuxiliaryType, string> { + { AuxiliaryType.Fan, Constants.Auxiliaries.IDs.Fan }, + { AuxiliaryType.SteeringPump, Constants.Auxiliaries.IDs.SteeringPump }, + { AuxiliaryType.HVAC, Constants.Auxiliaries.IDs.HeatingVentilationAirCondition }, + { AuxiliaryType.PneumaticSystem, Constants.Auxiliaries.IDs.PneumaticSystem }, + { AuxiliaryType.ElectricSystem, Constants.Auxiliaries.IDs.ElectricSystem }, + }; + private static readonly Dictionary<string, AuxiliaryType> StrToAux = AuxToStr.ToDictionary(kv => kv.Value, kv => kv.Key); @@ -28,5 +36,20 @@ namespace TUGraz.VectoCore.Models.Declaration { return AuxToStr[t]; } + + public static string GetAuxKey(AuxiliaryType t) + { + return AuxToKey[t]; + } + + public static string Key(this AuxiliaryType t) + { + return AuxToKey[t]; + } + + public static string Name(this AuxiliaryType t) + { + return AuxToStr[t]; + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Properties/Version.cs b/VectoCore/VectoCore/Properties/Version.cs index dddd78a9157bf98224fa80dd8405c5b870d56b07..8ec84a2ba2384b704fcc7ecfff7c1048b3a966e7 100644 --- a/VectoCore/VectoCore/Properties/Version.cs +++ b/VectoCore/VectoCore/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.0.90.613")] -[assembly: AssemblyFileVersion("3.0.90.613")] +[assembly: AssemblyVersion("3.0.90.623")] +[assembly: AssemblyFileVersion("3.0.90.623")] diff --git a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs index 8df9a84d060c6754c2456000e9ae7a8d80e4bb01..c99795d2e784712d64da7fb9526d95995ff13899 100644 --- a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs +++ b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs @@ -37,6 +37,8 @@ namespace TUGraz.VectoCore.Tests.Utils { public class MockEngineDataProvider : IEngineEngineeringInputData { + public DataSourceType SourceType { get; set; } + public string Source { get; set; } public bool SavedInDeclarationMode { get; set; } public string Vendor { get; set; } public string ModelName { get; set; } @@ -50,7 +52,7 @@ namespace TUGraz.VectoCore.Tests.Utils public double WHTCMotorway { get; set; } public double WHTCRural { get; set; } public double WHTCUrban { get; set; } - public double ColdHotBalancingFactor { get; set; } + public double ColdHotBalancingFactor { get; set; } public TableData FuelConsumptionMap { get; set; } public TableData FullLoadCurve { get; set; } public KilogramSquareMeter Inertia { get; set; }