From 70d7f5ac8c22feae1ad94ca299384b923274c2b3 Mon Sep 17 00:00:00 2001 From: "harald.martini@student.tugraz.at" <harald.martini@student.tugraz.at> Date: Fri, 7 May 2021 17:07:51 +0200 Subject: [PATCH] Changed usage of GetLabel() in XMLBusAuxiliariesWriter Added XmlNode to IAirdragViewModel Implemented LegislativeCategory in VehicleViewModel Added CompressorDrive to MultistageAuxiliariesViewModel Implemented VIF Writing (WIP) Added GuiLabels to CompressorDriveEnum --- .../XMLBusAuxiliariesWriter.cs | 6 +-- VECTO3GUI2020/VECTO3GUI2020.csproj | 4 ++ .../Vehicle/Components/AirDragViewModel.cs | 5 +++ .../JobEdit/Vehicle/VehicleViewModel.cs | 2 + .../Vehicle/Components/IAirDragViewModel.cs | 6 ++- .../InterimStageBusVehicleViewModel_v2_8.cs | 4 ++ .../MultistageAuxiliariesViewModel.cs | 27 ++++++++---- .../MultistageJobViewModel_v0_1.cs | 42 +++++++++++++++++-- .../Views/Multistage/AirDragView_v2_8.xaml | 2 +- Vecto3GUI2020Test/ViewModelTests.cs | 14 ++++++- .../InputData/DeclarationInputData.cs | 2 + 11 files changed, 96 insertions(+), 18 deletions(-) diff --git a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs index 750b364be5..c54b57651b 100644 --- a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs +++ b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs @@ -85,9 +85,9 @@ namespace VECTO3GUI2020.Util.XML.Implementation.ComponentWriter var hvacElement = new XElement(_defaultNamespace + "HVAC"); hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_SystemConfiguration, _inputData.HVACAux.SystemConfiguration.GetXmlFormat())); hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_HeatPumpTypeDriver, _inputData.HVACAux.HeatPumpTypeDriverCompartment.GetLabel())); - hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_HeatPumpModeDriver, _inputData.HVACAux.HeatPumpModeDriverCompartment?.GetLabel())); - hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_HeatPumpTypePassenger, _inputData.HVACAux.HeatPumpTypePassengerCompartment?.GetLabel())); - hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_HeatPumpModePassenger, _inputData.HVACAux.HeatPumpModePassengerCompartment?.GetLabel())); + hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_HeatPumpModeDriver, _inputData.HVACAux.HeatPumpModeDriverCompartment.GetLabel())); + hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_HeatPumpTypePassenger, _inputData.HVACAux.HeatPumpTypePassengerCompartment.GetLabel())); + hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_HeatPumpModePassenger, _inputData.HVACAux.HeatPumpModePassengerCompartment.GetLabel())); hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_AuxiliaryHeaterPower, _inputData.HVACAux.AuxHeaterPower?.ToXMLFormat(0))); hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_DoubleGlazing, _inputData.HVACAux.DoubleGlazing)); hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_AdjustableAuxiliaryHeater, _inputData.HVACAux.AdjustableAuxiliaryHeater)); diff --git a/VECTO3GUI2020/VECTO3GUI2020.csproj b/VECTO3GUI2020/VECTO3GUI2020.csproj index 0d0aa7158b..47c51e6a50 100644 --- a/VECTO3GUI2020/VECTO3GUI2020.csproj +++ b/VECTO3GUI2020/VECTO3GUI2020.csproj @@ -684,6 +684,10 @@ <Project>{B673E12F-D323-4C4C-8805-9915B2C72D3D}</Project> <Name>VectoHashing</Name> </ProjectReference> + <ProjectReference Include="..\VectoCore\VectoCoreTest\VectoCoreTest.csproj"> + <Project>{6A27F93E-4A58-48F6-B00B-3908C5D3D5A2}</Project> + <Name>VectoCoreTest</Name> + </ProjectReference> <ProjectReference Include="..\VectoCore\VectoCore\VectoCore.csproj"> <Project>{cd36938a-add9-4c65-96da-b397cdeea90a}</Project> <Name>VectoCore</Name> diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/Components/AirDragViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/Components/AirDragViewModel.cs index c8f07cabca..f4314ec98e 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/Components/AirDragViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/Components/AirDragViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.Reflection.Emit; +using System.Xml; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -17,6 +18,8 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components protected IAirdragDeclarationInputData _inputData; + public XmlNode XMLSource { get; } + private ICommonComponentViewModel _commonComponentViewModel; public ICommonComponentViewModel CommonComponentViewModel { @@ -39,6 +42,8 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components Debug.Assert(_inputData != null); _isPresent = (_inputData?.DataSource?.SourceFile != null); + XMLSource = (inputData as AbstractCommonComponentType)?.XMLSource; + _commonComponentViewModel = vmFactory.CreateCommonComponentViewModel(_inputData); SetProperties(); } diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/VehicleViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/VehicleViewModel.cs index 2a3c6c6d99..acb4986d54 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/VehicleViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobEdit/Vehicle/VehicleViewModel.cs @@ -179,6 +179,8 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle set => throw new NotImplementedException(); } + public virtual string LegislativeCategory => throw new NotImplementedException(); + LegislativeClass? IVehicleDeclarationInputData.LegislativeClass { get; } public virtual LegislativeClass LegislativeClass diff --git a/VECTO3GUI2020/ViewModel/Interfaces/JobEdit/Vehicle/Components/IAirDragViewModel.cs b/VECTO3GUI2020/ViewModel/Interfaces/JobEdit/Vehicle/Components/IAirDragViewModel.cs index a78893acfa..9f49b555da 100644 --- a/VECTO3GUI2020/ViewModel/Interfaces/JobEdit/Vehicle/Components/IAirDragViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Interfaces/JobEdit/Vehicle/Components/IAirDragViewModel.cs @@ -1,4 +1,5 @@ -using TUGraz.VectoCommon.InputData; +using System.Xml; +using TUGraz.VectoCommon.InputData; namespace VECTO3GUI2020.ViewModel.Interfaces.JobEdit.Vehicle.Components { @@ -6,5 +7,6 @@ namespace VECTO3GUI2020.ViewModel.Interfaces.JobEdit.Vehicle.Components { bool LabelVisible { get; set; } bool IsReadOnly { get; set; } - } + XmlNode XMLSource { get; } + } } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs index 94c35be2a1..9f04dfd2d2 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs @@ -485,6 +485,10 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #region not implemented + public string LegislativeCategory + { + get => throw new NotImplementedException(); + } public IGearboxDeclarationInputData GearboxInputData => throw new NotImplementedException(); public ITorqueConverterDeclarationInputData TorqueConverterInputData => throw new NotImplementedException(); diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs index 786d9af768..f41ebb6fab 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs @@ -185,6 +185,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation private bool? _positionlightsLed; private bool? _headlightsLed; private bool? _brakelightsLed; + public bool? InteriorLightsLED { @@ -219,7 +220,22 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #endregion + #region IPneumaticSuppyDeclarationData + public IPneumaticSupplyDeclarationData PneumaticSupply + { + get => this; + set => throw new NotImplementedException(); + } + + private CompressorDrive _compressorDrive; + public CompressorDrive CompressorDrive + { + get => _compressorDrive; + set => SetProperty(ref _compressorDrive, value); + } + + #endregion #region Implementation of interfaces (unused Properties); @@ -242,11 +258,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => throw new NotImplementedException(); } - public IPneumaticSupplyDeclarationData PneumaticSupply - { - get => this; - set => throw new NotImplementedException(); - } + public IPneumaticConsumersDeclarationData PneumaticConsumers { @@ -254,8 +266,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => throw new NotImplementedException(); } - - + @@ -331,6 +342,8 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #region Implementation of IPneumaticSupplyDeclarationData + + public string Clutch => throw new NotImplementedException(); public double Ratio => throw new NotImplementedException(); diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs index 095048ec5b..473d10565e 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs @@ -2,14 +2,19 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Input; using System.Windows.Navigation; using System.Xml; using System.Xml.Linq; using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; +using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.OutputData.FileIO; +using TUGraz.VectoCore.Tests.Models.Simulation; using TUGraz.VectoCore.Utils; using VECTO3GUI2020.Helper; using VECTO3GUI2020.Ninject; @@ -54,16 +59,44 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation get { return _saveVifCommand ?? new RelayCommand(() => { - - SaveVIF(this); + var outPutFile = _multistageDependencies.DialogHelperLazy.Value.SaveToXMLDialog(Settings.Default.DefaultFilePath); + if (outPutFile == null) { + return; + } + SaveVIF(this, outPutFile); }, () => true); } } - private static void SaveVIF(IMultistageVIFInputData inputData) + private static void SaveVIF(IMultistageVIFInputData vifData, string outputFile) { + + + + var numberOfManufacturingStages = + vifData.MultistageJobInputData.JobInputData.ManufacturingStages?.Count ?? 1; + + + + var writer = new FileOutputVIFWriter(outputFile, numberOfManufacturingStages); + var inputData = new XMLDeclarationVIFInputData(vifData.MultistageJobInputData, vifData.VehicleInputData); + + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer); + + var jobContainer = new JobContainer(new MockSumWriter()); //TODO: Replace with real sumwriter + + var runs = factory.SimulationRuns().ToList(); + foreach (var run in runs) + { + jobContainer.AddRun(run); + } + + jobContainer.Execute(); + jobContainer.WaitFinished(); + var progress = jobContainer.GetProgress(); + var validator = new XMLValidator(XmlReader.Create(writer.XMLMultistageReportFileName)); var vifInputData = inputData; } @@ -202,7 +235,8 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public IVehicleDeclarationInputData VehicleInputData => _manufacturingStageViewModel.Vehicle; - public IMultistageBusInputDataProvider MultistageInputData => this; + public IMultistageBusInputDataProvider MultistageJobInputData => this; + #endregion diff --git a/VECTO3GUI2020/Views/Multistage/AirDragView_v2_8.xaml b/VECTO3GUI2020/Views/Multistage/AirDragView_v2_8.xaml index f09fcfaecd..c42665b938 100644 --- a/VECTO3GUI2020/Views/Multistage/AirDragView_v2_8.xaml +++ b/VECTO3GUI2020/Views/Multistage/AirDragView_v2_8.xaml @@ -7,7 +7,7 @@ xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls" xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components" d:DataContext="{d:DesignInstance Type=implementation:AirDragViewModel_v2_8}" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="450" d:DesignWidth="800" Background="BlueViolet"> <Grid> <StackPanel> <Label diff --git a/Vecto3GUI2020Test/ViewModelTests.cs b/Vecto3GUI2020Test/ViewModelTests.cs index 1eb98c29b0..1ba6933f93 100644 --- a/Vecto3GUI2020Test/ViewModelTests.cs +++ b/Vecto3GUI2020Test/ViewModelTests.cs @@ -1,6 +1,8 @@ using System; using System.IO; +using System.Linq; using System.Runtime.CompilerServices; +using System.Xml; using Moq; using Ninject; using NUnit.Framework; @@ -9,7 +11,11 @@ using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore; using TUGraz.VectoCore.InputData.FileIO.XML; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; +using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Strategies; +using TUGraz.VectoCore.OutputData.FileIO; +using TUGraz.VectoCore.Utils; using VECTO3GUI2020.Helper; using VECTO3GUI2020.Ninject; using VECTO3GUI2020.Ninject.Vehicle; @@ -204,6 +210,11 @@ namespace Vecto3GUI2020Test Assert.AreEqual(VehicleDeclarationType.interim, vehicle.VehicleDeclarationType); + var airdrag = vehicle.MultistageAirdragViewModel; + Assert.NotNull(airdrag.AirDragViewModel.XMLSource); + + + } @@ -215,6 +226,7 @@ namespace Vecto3GUI2020Test } + #region Helper @@ -224,7 +236,7 @@ namespace Vecto3GUI2020Test var exists = File.Exists(filePath); if (!exists) { - Console.WriteLine(filePath + " not existing"); + Console.WriteLine(filePath + @" not existing"); } Assert.IsTrue(exists); diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index 75a92a9e8f..d359617fb7 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -990,7 +990,9 @@ namespace TUGraz.VectoCommon.InputData public enum CompressorDrive { + [GuiLabel("Electrically")] electrically, + [GuiLabel("Mechanically")] mechanically } -- GitLab