Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit d9f28d74 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

[VectoCore] Switched to new project SDK format and deleted files which caused...

[VectoCore] Switched to new project SDK format and deleted files which caused compile errors and were not included in project
parent f9113728
Branches
Tags
No related merge requests found
Showing
with 55 additions and 4565 deletions
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
using Castle.Core.Internal;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
{
public class XMLDeclarationIEPCDataProviderV2101 : AbstractCommonComponentType, IXMLIEPCInputData, IElectricMotorVoltageLevel, IGearEntry
{
public static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V2101_JOBS;
public const string XSD_TYPE = "IEPCMeasuredDataDeclarationType";
public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE);
private IXMLDeclarationVehicleData _vehicle;
private IList<IElectricMotorVoltageLevel> _voltageLevels;
private IList<IGearEntry> _gears;
public XMLDeclarationIEPCDataProviderV2101(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile)
: base(componentNode, sourceFile)
{
_vehicle = vehicle;
SourceType = DataSourceType.XMLEmbedded;
}
#region Overrides of AbstractCommonComponentType
public override CertificationMethod CertificationMethod
{
get
{
var certMethod = GetString(XMLNames.Component_Gearbox_CertificationMethod, required: false) ??
GetString(XMLNames.Component_CertificationMethod, required: false);
if(certMethod != null && certMethod == "Measured for complete component")
return CertificationMethod.Measured;
return certMethod != null
? EnumHelper.ParseEnum<CertificationMethod>(certMethod)
: CertificationMethod.Measured;
}
}
#endregion
#region Implementation of IPowerRatingInputData
public virtual ElectricMachineType ElectricMachineType =>
GetString(XMLNames.ElectricMachine_ElectricMachineType).ParseEnum<ElectricMachineType>();
public virtual Watt R85RatedPower =>
GetDouble(XMLNames.ElectricMachine_R85RatedPower).SI<Watt>();
public virtual KilogramSquareMeter Inertia =>
GetDouble(XMLNames.ElectricMachine_RotationalInertia).SI<KilogramSquareMeter>();
public virtual NewtonMeter ContinuousTorque =>
GetDouble(XMLNames.ElectricMachine_ContinuousTorque).SI<NewtonMeter>();
public virtual PerSecond ContinuousTorqueSpeed =>
GetDouble(XMLNames.ElectricMachine_TestSpeedContinuousTorque).SI<PerSecond>();
public virtual NewtonMeter OverloadTorque =>
GetDouble(XMLNames.ElectricMachine_OverloadTorque).SI<NewtonMeter>();
public virtual PerSecond OverloadTestSpeed =>
GetDouble(XMLNames.ElectricMachine_TestSpeedOverloadTorque).SI<PerSecond>();
public virtual Second OverloadTime =>
GetDouble(XMLNames.ElectricMachine_OverloadDuration).SI<Second>();
#endregion
#region Implementation of IIEPCDeclarationInputData
public virtual Volt TestVoltageOverload =>
GetDouble(XMLNames.ElectricMachine_TestVoltageOverload).SI<Volt>();
public virtual bool DifferentialIncluded => GetBool(XMLNames.IEPC_DifferentialIncluded);
public virtual bool DesignTypeWheelMotor => GetBool(XMLNames.IEPC_DesignTypeWheelMotor);
public virtual int? NrOfDesignTypeWheelMotorMeasured => ElementExists(XMLNames.IEPC_NrOfDesignTypeWheelMotorMeasured) ?
(int?) Convert.ToInt32(GetString(XMLNames.IEPC_NrOfDesignTypeWheelMotorMeasured)) : null;
public IList<IGearEntry> Gears =>
_gears ?? (_gears = GetGearEntries());
public virtual IList<IElectricMotorVoltageLevel> VoltageLevels =>
_voltageLevels ?? (_voltageLevels = GetVoltageLevels());
public TableData DragCurve =>
ReadTableData(XMLNames.DragCurve, XMLNames.DragCurve_Entry, new Dictionary<string, string>
{
{XMLNames.DragCurve_OutShaftSpeed, XMLNames.DragCurve_OutShaftSpeed},
{XMLNames.DragCurve_DragTorque, XMLNames.DragCurve_DragTorque}
});
#endregion
#region Implementation of IElectricMotorVoltageLevel
public Volt VoltageLevel => GetDouble(XMLNames.VoltageLevel_Voltage).SI<Volt>();
public TableData FullLoadCurve => ReadTableData(XMLNames.MaxTorqueCurve, XMLNames.MaxTorqueCurve_Entry, new Dictionary<string, string> {
{XMLNames.MaxTorqueCurve_OutShaftSpeed, XMLNames.MaxTorqueCurve_OutShaftSpeed},
{XMLNames.MaxTorqueCurve_MaxTorque, XMLNames.MaxTorqueCurve_MaxTorque},
{XMLNames.MaxTorqueCurve_MinTorque, XMLNames.MaxTorqueCurve_MinTorque}
});
public TableData EfficiencyMap => ReadTableData(XMLNames.PowerMap, XMLNames.PowerMap_Entry, new Dictionary<string, string> {
{ XMLNames.PowerMap_OutShaftSpeed, XMLNames.PowerMap_OutShaftSpeed },
{ XMLNames.PowerMap_Torque, XMLNames.PowerMap_Torque },
{ XMLNames.PowerMap_ElectricPower, XMLNames.PowerMap_ElectricPower }
});
#endregion
private IList<IElectricMotorVoltageLevel> GetVoltageLevels()
{
var voltageLevelNodes = GetNodes(XMLNames.ElectricMachine_VoltageLevel);
if (voltageLevelNodes.IsNullOrEmpty())
return null;
var voltageLevels = new List<IElectricMotorVoltageLevel>();
foreach (XmlNode voltageLevelNode in voltageLevelNodes)
{
voltageLevels.Add(new XMLDeclarationIEPCDataProviderV2101(null, voltageLevelNode, null));
}
return voltageLevels;
}
#region Implementation of IGearEntry
public int GearNumber => Convert.ToInt32(GetAttribute(BaseNode, XMLNames.Gear_GearNumber_Attr));
public double Ratio => GetDouble(XMLNames.Gear_Ratio);
public NewtonMeter MaxOutputShaftTorque => ElementExists(XMLNames.Gear_MaxOutputShaftTorque)
? GetDouble(XMLNames.Gear_MaxOutputShaftTorque).SI<NewtonMeter>()
: null;
public PerSecond MaxOutputShaftSpeed => ElementExists(XMLNames.Gear_MaxOutputShaftSpeed)
? GetDouble(XMLNames.Gear_MaxOutputShaftSpeed).SI<PerSecond>()
: null;
#endregion
private IList<IGearEntry> GetGearEntries()
{
var gearNodes = GetNodes(XMLNames.Gear_EntryName);
if (gearNodes.IsNullOrEmpty())
return null;
var gears = new List<IGearEntry>();
foreach (XmlNode gearNode in gearNodes) {
gears.Add(new XMLDeclarationIEPCDataProviderV2101(null, gearNode, null));
}
return gears;
}
#region Overrides of AbstractXMLResource
protected override XNamespace SchemaNamespace => NAMESPACE_URI;
protected override DataSourceType SourceType { get; }
#endregion
}
}
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Collections.Generic;
using System.Xml;
using TUGraz.IVT.VectoXML;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.Impl;
namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration
{
public class XMLDeclarationGearboxDataProvider : AbstractDeclarationXMLComponentDataProvider,
IGearboxDeclarationInputData
{
public XMLDeclarationGearboxDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider)
: base(xmlInputDataProvider)
{
XBasePath = Helper.Query(VehiclePath,
XMLNames.Vehicle_Components,
XMLNames.Component_Gearbox,
XMLNames.ComponentDataWrapper);
}
public new CertificationMethod CertificationMethod
{
get { return GetElementValue(XMLNames.Component_Gearbox_CertificationMethod).ParseEnum<CertificationMethod>(); }
}
public GearboxType Type
{
get {
var value = GetElementValue(XMLNames.Gearbox_TransmissionType);
switch (value) {
case "MT":
case "SMT":
return GearboxType.MT;
case "AMT":
return GearboxType.AMT;
case "APT-S":
case "AT - Serial":
return GearboxType.ATSerial;
case "APT-P":
case "AT - PowerSplit":
return GearboxType.ATPowerSplit;
}
throw new ArgumentOutOfRangeException("GearboxType", value);
}
}
public IList<ITransmissionInputData> Gears
{
get {
var retVal = new List<ITransmissionInputData>();
var gears = Navigator.Select(
Helper.Query(XBasePath, XMLNames.Gearbox_Gears, XMLNames.Gearbox_Gears_Gear),
Manager);
while (gears.MoveNext()) {
var gear = gears.Current.GetAttribute(XMLNames.Gearbox_Gear_GearNumber_Attr, "");
retVal.Add(ReadGear(gear));
}
return retVal;
}
}
public ITorqueConverterDeclarationInputData TorqueConverter
{
get {
return new XMLDeclarationTorqueConverterDataProvider(InputData);
}
}
protected ITransmissionInputData ReadGear(string gearNr)
{
var retVal = new TransmissionInputData();
var gearPath = Helper.Query(XMLNames.Gearbox_Gears,
Helper.QueryConstraint(XMLNames.Gearbox_Gears_Gear, XMLNames.Gearbox_Gear_GearNumber_Attr, gearNr));
retVal.Ratio = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gear_Ratio));
retVal.Gear = XmlConvert.ToUInt16(gearNr);
retVal.LossMap = ReadTableData(AttributeMappings.TransmissionLossmapMapping,
Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry));
if (ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque))) {
retVal.MaxTorque = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque)).SI<NewtonMeter>();
}
if (ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gear_MaxSpeed))) {
retVal.MaxInputSpeed = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gear_MaxSpeed)).RPMtoRad();
}
return retVal;
}
}
}
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Resources;
namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration
{
// ReSharper disable once InconsistentNaming
public class XMLDeclarationJobInputDataProvider : AbstractDeclarationXMLComponentDataProvider, IDeclarationJobInputData
{
private readonly XMLDeclarationVehicleDataProvider _vehicle;
public XMLDeclarationJobInputDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider)
: base(xmlInputDataProvider)
{
XBasePath = VehiclePath;
_vehicle = new XMLDeclarationVehicleDataProvider(xmlInputDataProvider);
}
public IVehicleDeclarationInputData Vehicle
{
get { return _vehicle; }
}
public XMLDeclarationVehicleDataProvider XMLVehicle
{
get { return _vehicle; }
}
public string JobName
{
get { return GetAttributeValue("", XMLNames.Component_ID_Attr); }
}
public string ShiftStrategy { get { return ""; } }
}
}
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Xml.XPath;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering
{
public class XMLEngineeringInputDataProvider : IEngineeringInputDataProvider
{
public readonly string FileName;
internal XmlDocument Document;
protected internal XMLEngineeringJobInputDataProvider XMLEngineeringJobData;
protected internal XMLEngineeringVehicleDataProvider VehicleData;
protected internal XMLEngineeringDriverDataProvider XMLEngineeringDriverData;
public bool VerifyXml { get; protected set; }
public XMLEngineeringInputDataProvider(string filename, bool verifyXml)
{
VerifyXml = verifyXml;
FileName = filename;
ReadXMLDocument(File.OpenRead(filename));
InitializeComponentDataProvider();
}
public XMLEngineeringInputDataProvider(Stream inputData, bool verifyXml)
{
FileName = ".";
VerifyXml = verifyXml;
ReadXMLDocument(inputData);
var nav = Document.CreateNavigator();
var manager = new XmlNamespaceManager(nav.NameTable);
var helper = new XPathHelper(ExecutionMode.Engineering);
helper.AddNamespaces(manager);
var refNodes =
nav.Select(
"//" + helper.Query(helper.QueryConstraint(XMLNames.ExternalResource, XMLNames.ExtResource_File_Attr, null)),
manager);
if (refNodes.Count > 0) {
throw new VectoException("XML input data with file references can not be read via stream!");
}
InitializeComponentDataProvider();
}
private void ReadXMLDocument(Stream inputData)
{
var xmldoc = new XmlDocument();
xmldoc.Load(inputData);
if (VerifyXml) {
new XMLValidator(xmldoc, null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType.EngineeringData);
}
Document = xmldoc;
}
private void InitializeComponentDataProvider()
{
var helper = new XPathHelper(ExecutionMode.Engineering);
XMLEngineeringJobData = new XMLEngineeringJobInputDataProvider(this, Document,
helper.QueryAbs(helper.NSPrefix(XMLNames.VectoInputEngineering, Constants.XML.RootNSPrefix)),
Path.GetDirectoryName(Path.GetFullPath(FileName)));
if (XMLEngineeringJobData.EngineOnlyMode) {
EngineOnlyInputData = new XMLEngineeringEngineDataProvider(this, Document,
helper.QueryAbs(helper.NSPrefix(XMLNames.VectoInputEngineering, Constants.XML.RootNSPrefix),
XMLNames.Component_Engine,
XMLNames.ComponentDataWrapper), Path.GetDirectoryName(Path.GetFullPath(FileName)));
return;
}
ReadVehicle();
XMLEngineeringDriverData = XMLEngineeringJobData.GetDriverData();
}
internal static void ValidationCallBack(XmlSeverityType severity, ValidationEvent evt)
{
if (severity == XmlSeverityType.Error) {
throw new VectoException("Validation error: {0}", evt.ValidationEventArgs.Message);
}
}
private void ReadVehicle()
{
var helper = new XPathHelper(ExecutionMode.Engineering);
var nav = Document.CreateNavigator();
var vehiclePath = helper.QueryAbs(helper.NSPrefix(XMLNames.VectoInputEngineering, Constants.XML.RootNSPrefix),
XMLNames.Component_Vehicle);
var manager = new XmlNamespaceManager(nav.NameTable);
helper.AddNamespaces(manager);
var vehicle = nav.SelectSingleNode(vehiclePath, manager);
if (vehicle != null) {
VehicleData = new XMLEngineeringVehicleDataProvider(this, Document, vehiclePath,
Path.GetDirectoryName(Path.GetFullPath(FileName)));
return;
}
var extVehilePath = helper.QueryAbs(
helper.NSPrefix(XMLNames.VectoInputEngineering, Constants.XML.RootNSPrefix),
helper.QueryConstraint(XMLNames.ExternalResource, "@component='Vehicle' and @type='xml'", null, ""));
var extVehicle = nav.SelectSingleNode(extVehilePath, manager);
if (extVehicle != null) {
try {
var vehicleFile = extVehicle.GetAttribute(XMLNames.ExtResource_File_Attr, "");
var vehicleDocument = new XmlDocument();
vehicleDocument.Load(XmlReader.Create(Path.Combine(Path.GetDirectoryName(FileName) ?? "./", vehicleFile)));
if (VerifyXml) {
new XMLValidator(vehicleDocument, null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType
.EngineeringData);
}
var vehicleCompPath =
helper.QueryAbs(
helper.NSPrefix("VectoComponentEngineering", Constants.XML.RootNSPrefix),
XMLNames.Component_Vehicle);
VehicleData = new XMLEngineeringVehicleDataProvider(this, vehicleDocument, vehicleCompPath,
Path.GetDirectoryName(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(FileName) ?? "./", vehicleFile))));
return;
} catch (XmlSchemaValidationException validationException) {
throw new VectoException("Validation of XML-file for Vehicle failed", validationException);
}
}
throw new VectoException("No Vehicle found");
}
private static XmlSchemaSet GetXMLSchema(string version)
{
var resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema,
"VectoEngineeringInput.xsd");
var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() };
var reader = XmlReader.Create(resource, new XmlReaderSettings(), XmlResourceResolver.BaseUri);
xset.Add(XmlSchema.Read(reader, null));
xset.Compile();
return xset;
}
public IEngineeringJobInputData JobInputData
{
get { return XMLEngineeringJobData; }
}
public IVehicleEngineeringInputData VehicleInputData
{
get { return VehicleData; }
}
public IEngineEngineeringInputData EngineOnlyInputData { get; private set; }
public IDriverEngineeringInputData DriverInputData
{
get { return XMLEngineeringDriverData; }
}
public IGearshiftEngineeringInputData GearshiftInputData { get { return null; } }
}
}
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.InputData.Impl;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering
{
// ReSharper disable once InconsistentNaming
public class XMLEngineeringJobInputDataProvider : AbstractEngineeringXMLComponentDataProvider, IEngineeringJobInputData
{
public XMLEngineeringJobInputDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider,
XmlDocument jobDocument, string xmlBasePath, string fsBasePath)
: base(xmlEngineeringJobInputDataProvider, jobDocument, xmlBasePath, fsBasePath) {}
public IVehicleDeclarationInputData Vehicle
{
get { return InputData.VehicleInputData; }
}
IVehicleEngineeringInputData IEngineeringJobInputData.Vehicle
{
get { return InputData.VehicleInputData; }
}
public IList<ICycleData> Cycles
{
get {
var retVal = new List<ICycleData>();
var cycles = Navigator.Select(Helper.Query(XBasePath, XMLNames.VectoJob_MissionCycles,
Helper.QueryConstraint(XMLNames.Missions_Cycle, XMLNames.ExtResource_Type_Attr,
XMLNames.ExtResource_Type_Value_CSV)), Manager);
while (cycles.MoveNext()) {
var file = cycles.Current.GetAttribute(XMLNames.ExtResource_File_Attr, "");
var fileFull = Path.Combine(FSBasePath ?? "", file);
if (File.Exists(fileFull)) {
retVal.Add(new CycleInputData() {
Name = Path.GetFileNameWithoutExtension(fileFull),
CycleData = VectoCSVFile.Read(fileFull)
});
} else {
try {
var resourceName = DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + file +
Constants.FileExtensions.CycleFile;
retVal.Add(new CycleInputData() {
Name = Path.GetFileNameWithoutExtension(file),
CycleData = VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceName), source: resourceName),
});
} catch {
//Log.Debug("Driving Cycle could not be read: " + cycleFile);
throw new VectoException("Driving Cycle could not be read: " + file);
}
}
}
return retVal;
}
}
public bool EngineOnlyMode
{
get {
return ElementExists(XMLNames.VectoJob_EngineOnlyMode) &&
XmlConvert.ToBoolean(GetElementValue(XMLNames.VectoJob_EngineOnlyMode));
}
}
public IEngineEngineeringInputData EngineOnly
{
get { return InputData.EngineOnlyInputData; }
}
protected internal Second DownshiftAfterUpshiftDelay
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"DownshiftAfterUpshiftDelay"))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"DownshiftAfterUpshiftDelay")).SI<Second>()
: DeclarationData.Gearbox.DownshiftAfterUpshiftDelay;
}
}
protected internal Second UpshiftAfterDownshiftDelay
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"UpshiftAfterDownshiftDelay"))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"UpshiftAfterDownshiftDelay")).SI<Second>()
: DeclarationData.Gearbox.UpshiftAfterDownshiftDelay;
}
}
protected internal MeterPerSquareSecond UpshiftMinAcceleration
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"UpshiftMinAcceleration"))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"UpshiftMinAcceleration"))
.SI<MeterPerSquareSecond>()
: DeclarationData.Gearbox.UpshiftMinAcceleration;
}
}
public string JobName
{
get {
return InputData.JobInputData.EngineOnlyMode
? InputData.JobInputData.EngineOnly.Model
: InputData.VehicleData.GetVehicleID;
}
}
public string ShiftStrategy { get { return ""; } }
public double TorqueReserve
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_TorqueReserve))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_TorqueReserve))
: DeclarationData.Gearbox.TorqueReserve;
}
}
public Second MinTimeBetweenGearshift
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_TimeBetweenGearshift))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_TimeBetweenGearshift)).SI<Second>()
: DeclarationData.Gearbox.MinTimeBetweenGearshifts;
}
}
public MeterPerSecond StartSpeed
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_StartSpeed))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_StartSpeed)).SI<MeterPerSecond>()
: DeclarationData.Gearbox.StartSpeed;
}
}
public MeterPerSquareSecond StartAcceleration
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_StartAcceleration))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_StartAcceleration)).SI<MeterPerSquareSecond>()
: DeclarationData.Gearbox.StartAcceleration;
}
}
public double StartTorqueReserve
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_StartTorqueReserve))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
XMLNames.DriverModel_ShiftStrategyParameters_StartTorqueReserve))
: DeclarationData.Gearbox.TorqueReserveStart;
}
}
public Second PowershiftShiftTime
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"PowershiftShiftTime"))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"PowershiftShiftTime")).SI<Second>()
: 0.8.SI<Second>();
}
}
public MeterPerSquareSecond CCUpshiftMinAcceleration
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"CCUpshiftMinAcceleration"))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"CCUpshiftMinAcceleration")).SI<MeterPerSquareSecond>()
: DeclarationData.Gearbox.UpshiftMinAcceleration;
}
}
public MeterPerSquareSecond CLUpshiftMinAcceleration
{
get {
return
ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"CLUpshiftMinAcceleration"))
? GetDoubleElementValue(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_ShiftStrategyParameters,
"CLUpshiftMinAcceleration")).SI<MeterPerSquareSecond>()
: DeclarationData.Gearbox.UpshiftMinAcceleration;
}
}
public XMLEngineeringDriverDataProvider GetDriverData()
{
return new XMLEngineeringDriverDataProvider(InputData, XMLDocument, XBasePath, FSBasePath);
}
}
}
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
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;
using TUGraz.VectoCore.InputData.Reader.ComponentData;
using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.InputData.Reader.Impl
{
public class DeclarationModeVectoRunDataFactory : LoggingObject, IVectoRunDataFactory
{
private static readonly object CyclesCacheLock = new object();
private static readonly Dictionary<MissionType, DrivingCycleData> CyclesCache =
new Dictionary<MissionType, DrivingCycleData>();
protected readonly IDeclarationInputDataProvider InputDataProvider;
protected IDeclarationReport Report;
private DeclarationDataAdapter _dao;
private Segment _segment;
private bool allowVocational;
private DriverData _driverdata;
private AirdragData _airdragData;
private CombustionEngineData _engineData;
private AxleGearData _axlegearData;
private AngledriveData _angledriveData;
private GearboxData _gearboxData;
private RetarderData _retarderData;
private PTOData _ptoTransmissionData;
private PTOData _municipalPtoTransmissionData;
private Exception InitException;
internal DeclarationModeVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, IDeclarationReport report)
{
InputDataProvider = dataProvider;
Report = report;
allowVocational = true;
try {
Initialize();
if (Report != null) {
InitializeReport();
}
} catch (Exception e) {
InitException = e;
}
}
private void Initialize()
{
_dao = new DeclarationDataAdapter();
var vehicle = InputDataProvider.JobInputData.Vehicle;
if (vehicle.ExemptedVehicle) {
if (vehicle.AxleConfiguration != AxleConfiguration.AxleConfig_Undefined) {
_segment = GetVehicleClassification(vehicle.VehicleCategory,
vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, vehicle.CurbMassChassis, false);
}
return;
}
try {
_segment = GetVehicleClassification(
vehicle.VehicleCategory,
vehicle.AxleConfiguration,
vehicle.GrossVehicleMassRating,
vehicle.CurbMassChassis,
vehicle.VocationalVehicle);
} catch (VectoException) {
allowVocational = false;
_segment = GetVehicleClassification(
vehicle.VehicleCategory,
vehicle.AxleConfiguration,
vehicle.GrossVehicleMassRating,
vehicle.CurbMassChassis,
false);
}
if (!_segment.Found) {
throw new VectoException(
"no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, GVMR: {2}",
vehicle.VehicleCategory, vehicle.AxleConfiguration,
vehicle.GrossVehicleMassRating);
}
_driverdata = _dao.CreateDriverData();
_driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile);
var tempVehicle = _dao.CreateVehicleData(vehicle, _segment.Missions.First(),
_segment.Missions.First().Loadings.First().Value, allowVocational);
_airdragData = _dao.CreateAirdragData(vehicle.Components.AirdragInputData,
_segment.Missions.First(), _segment);
_engineData = _dao.CreateEngineData(vehicle.Components.EngineInputData,
vehicle.EngineIdleSpeed,
vehicle.Components.GearboxInputData, vehicle.TorqueLimits, vehicle.TankSystem);
_axlegearData = _dao.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData);
_angledriveData = _dao.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData);
_gearboxData = _dao.CreateGearboxData(vehicle.Components.GearboxInputData, _engineData,
_axlegearData.AxleGear.Ratio,
tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory, vehicle.Components.TorqueConverterInputData);
_retarderData = _dao.CreateRetarderData(vehicle.Components.RetarderInputData);
_ptoTransmissionData = _dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData);
_municipalPtoTransmissionData = CreateDefaultPTOData();
}
private void InitializeReport()
{
VectoRunData powertrainConfig;
if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) {
powertrainConfig = new VectoRunData() {
Exempted = true,
VehicleData = _dao.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, null, null, allowVocational),
InputDataHash = InputDataProvider.XMLHash
};
powertrainConfig.VehicleData.VehicleClass = _segment.Found ? _segment.VehicleClass : VehicleClass.Class0;
} else {
powertrainConfig = new VectoRunData() {
VehicleData =
_dao.CreateVehicleData(
InputDataProvider.JobInputData.Vehicle, _segment.Missions.First(),
_segment.Missions.First().Loadings.First().Value, allowVocational),
AirdragData = _airdragData,
EngineData = _engineData,
GearboxData = _gearboxData,
AxleGearData = _axlegearData,
Retarder = _retarderData,
Aux =
_dao.CreateAuxiliaryData(
InputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData,
_segment.Missions.First().MissionType,
_segment.VehicleClass),
PTO = _ptoTransmissionData,
InputDataHash = InputDataProvider.XMLHash
};
powertrainConfig.VehicleData.VehicleClass = _segment.VehicleClass;
}
Report.InitializeReport(powertrainConfig);
}
public IEnumerable<VectoRunData> NextRun()
{
if (InitException != null) {
throw InitException;
}
if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) {
yield return new VectoRunData {
Exempted = true,
Report = Report,
Mission = new Mission() { MissionType = MissionType.ExemptedMission},
VehicleData = _dao.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, null, null, allowVocational),
InputDataHash = InputDataProvider.XMLHash
};
} else {
foreach (var vectoRunData in VectoRunDataNonExempted())
yield return vectoRunData;
}
}
private IEnumerable<VectoRunData> VectoRunDataNonExempted()
{
var vehicle = InputDataProvider.JobInputData.Vehicle;
var adasCombination = DeclarationData.ADASCombinations.Lookup(vehicle.ADAS);
foreach (var mission in _segment.Missions) {
if (mission.MissionType.IsEMS() &&
_engineData.RatedPowerDeclared.IsSmaller(DeclarationData.MinEnginePowerForEMS)) {
continue;
}
DrivingCycleData cycle;
lock (CyclesCacheLock) {
if (CyclesCache.ContainsKey(mission.MissionType)) {
cycle = CyclesCache[mission.MissionType];
} else {
cycle = DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false);
CyclesCache.Add(mission.MissionType, cycle);
}
}
foreach (var loading in mission.Loadings) {
var simulationRunData = new VectoRunData {
Loading = loading.Key,
VehicleDesignSpeed = _segment.DesignSpeed,
VehicleData = _dao.CreateVehicleData(vehicle, mission, loading.Value, allowVocational),
AirdragData = _dao.CreateAirdragData(vehicle.Components.AirdragInputData, mission, _segment),
EngineData = _engineData.Copy(), // a copy is necessary because every run has a different correction factor!
GearboxData = _gearboxData,
AxleGearData = _axlegearData,
AngledriveData = _angledriveData,
Aux = _dao.CreateAuxiliaryData(vehicle.Components.AuxiliaryInputData, mission.MissionType,
_segment.VehicleClass),
Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()),
Retarder = _retarderData,
DriverData = _driverdata,
ExecutionMode = ExecutionMode.Declaration,
JobName = InputDataProvider.JobInputData.JobName,
ModFileSuffix = loading.Key.ToString(),
Report = Report,
Mission = mission,
PTO = mission.MissionType == MissionType.MunicipalUtility
? _municipalPtoTransmissionData
: _ptoTransmissionData,
InputDataHash = InputDataProvider.XMLHash,
SimulationType = SimulationType.DistanceCycle
};
simulationRunData.EngineData.FuelConsumptionCorrectionFactor = DeclarationData.WHTCCorrection.Lookup(
mission.MissionType.GetNonEMSMissionType(), _engineData.WHTCRural, _engineData.WHTCUrban,
_engineData.WHTCMotorway) *
_engineData.ColdHotCorrectionFactor * _engineData.CorrectionFactorRegPer;
simulationRunData.EngineData.ADASCorrectionFactor = DeclarationData.ADASBenefits.Lookup(
_segment.VehicleClass, adasCombination, mission.MissionType, loading.Key);
simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass;
yield return simulationRunData;
}
}
}
private PTOData CreateDefaultPTOData()
{
return new PTOData() {
TransmissionType = DeclarationData.PTO.DefaultPTOTechnology,
LossMap = PTOIdleLossMapReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)),
PTOCycle =
DrivingCycleDataReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle),
CycleType.PTO, "PTO", false)
};
}
internal Segment GetVehicleClassification(VehicleCategory category, AxleConfiguration axles, Kilogram grossMassRating,
Kilogram curbWeight, bool vocational)
{
return DeclarationData.Segments.Lookup(category, axles, grossMassRating, curbWeight, vocational);
}
}
}
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
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;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.InputData.Reader.ComponentData;
using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData;
namespace TUGraz.VectoCore.InputData.Reader.Impl
{
internal class DeclarationVTPModeVectoRunDataFactory : IVectoRunDataFactory
{
protected IVTPDeclarationJobInputData JobInputData;
protected DriverData Driverdata;
protected AirdragData AirdragData;
protected CombustionEngineData EngineData;
protected AxleGearData AxlegearData;
protected AngledriveData AngledriveData;
protected GearboxData GearboxData;
protected RetarderData RetarderData;
protected PTOData PTOTransmissionData;
protected List<VectoRunData.AuxData> AuxVTP;
protected Segment Segment;
protected bool allowVocational;
protected DeclarationDataAdapter Dao;
protected Exception InitException;
public IVTPReport Report;
public DeclarationVTPModeVectoRunDataFactory(IVTPDeclarationInputDataProvider ivtpProvider, IVTPReport report) : this(
ivtpProvider.JobInputData, report) { }
protected DeclarationVTPModeVectoRunDataFactory(IVTPDeclarationJobInputData job, IVTPReport report)
{
JobInputData = job;
Report = report;
allowVocational = true;
try {
Initialize();
if (Report != null) {
InitializeReport();
}
} catch (Exception e) {
InitException = e;
}
}
private void InitializeReport()
{
var powertrainConfig = new VectoRunData() {
VehicleData =
Dao.CreateVehicleData(
JobInputData.Vehicle, Segment.Missions.First(),
Segment.Missions.First().Loadings.First().Value, allowVocational),
AirdragData = AirdragData,
EngineData = EngineData,
GearboxData = GearboxData,
AxleGearData = AxlegearData,
Retarder = RetarderData,
Aux =
Dao.CreateAuxiliaryData(
JobInputData.Vehicle.Components.AuxiliaryInputData,
Segment.Missions.First().MissionType,
Segment.VehicleClass),
};
powertrainConfig.VehicleData.VehicleClass = Segment.VehicleClass;
Report.InputDataHash = JobInputData.VectoJobHash;
Report.ManufacturerRecord = JobInputData.ManufacturerReportInputData;
Report.ManufacturerRecordHash = JobInputData.VectoManufacturerReportHash;
Report.InitializeReport(powertrainConfig);
}
protected void Initialize()
{
Dao = new DeclarationDataAdapter();
var vehicle = JobInputData.Vehicle;
try {
Segment = DeclarationData.Segments.Lookup(
vehicle.VehicleCategory,
vehicle.AxleConfiguration,
vehicle.GrossVehicleMassRating,
vehicle.CurbMassChassis,
vehicle.VocationalVehicle);
} catch (VectoException) {
allowVocational = false;
Segment = DeclarationData.Segments.Lookup(
vehicle.VehicleCategory,
vehicle.AxleConfiguration,
vehicle.GrossVehicleMassRating,
vehicle.CurbMassChassis,
false);
}
Driverdata = Dao.CreateDriverData();
Driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(Segment.AccelerationFile);
var tempVehicle = Dao.CreateVehicleData(
vehicle, Segment.Missions.First(),
Segment.Missions.First().Loadings.First().Value, allowVocational);
AirdragData = Dao.CreateAirdragData(
vehicle.Components.AirdragInputData,
Segment.Missions.First(), Segment);
EngineData = Dao.CreateEngineData(
vehicle.Components.EngineInputData,
vehicle.EngineIdleSpeed,
vehicle.Components.GearboxInputData, vehicle.TorqueLimits, vehicle.TankSystem);
AxlegearData = Dao.CreateAxleGearData(vehicle.Components.AxleGearInputData);
AngledriveData = Dao.CreateAngledriveData(vehicle.Components.AngledriveInputData);
GearboxData = Dao.CreateGearboxData(
vehicle.Components.GearboxInputData, EngineData,
AxlegearData.AxleGear.Ratio,
tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory, vehicle.Components.TorqueConverterInputData);
RetarderData = Dao.CreateRetarderData(vehicle.Components.RetarderInputData);
PTOTransmissionData =
Dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData);
AuxVTP = CreateVTPAuxData(vehicle);
}
#region Implementation of IVectoRunDataFactory
public virtual IEnumerable<VectoRunData> NextRun()
{
if (InitException != null) {
throw InitException;
}
// simulate the LongHaul cycle with RefLoad
var mission = Segment.Missions.FirstOrDefault();
if (mission == null) {
throw new VectoException("No Mission found in segmentation matrix");
}
var loading = mission.Loadings.FirstOrDefault(l => l.Key == DeclarationData.VTPMode.SelectedLoading);
var runData = CreateVectoRunData(Segment, mission, loading.Value);
runData.EngineData.FuelConsumptionCorrectionFactor = DeclarationData.WHTCCorrection.Lookup(
mission.MissionType.GetNonEMSMissionType(), runData.EngineData.WHTCRural, runData.EngineData.WHTCUrban,
runData.EngineData.WHTCMotorway) *
runData.EngineData.ColdHotCorrectionFactor * runData.EngineData.CorrectionFactorRegPer;
var adasCombination = DeclarationData.ADASCombinations.Lookup(JobInputData.Vehicle.ADAS);
runData.EngineData.ADASCorrectionFactor = DeclarationData.ADASBenefits.Lookup(
Segment.VehicleClass, adasCombination, mission.MissionType, loading.Key);
runData.ModFileSuffix = loading.Key.ToString();
var cycle = DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false);
runData.Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString());
runData.DriverData = Driverdata;
runData.Aux = Dao.CreateAuxiliaryData(
JobInputData.Vehicle.Components.AuxiliaryInputData, mission.MissionType, Segment.VehicleClass);
runData.ExecutionMode = ExecutionMode.Declaration;
runData.SimulationType = SimulationType.DistanceCycle;
runData.Mission = mission;
runData.Loading = loading.Key;
yield return runData;
// simulate the Measured cycle
var vtpCycle = JobInputData.Cycles.FirstOrDefault();
if (vtpCycle == null) {
throw new VectoException("no VTP-Cycle provided!");
}
var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(vtpCycle.CycleData, vtpCycle.Name, false);
// Loading is not relevant as we use P_wheel
var vtpRunData = CreateVectoRunData(Segment, Segment.Missions.First(), 0.SI<Kilogram>());
vtpRunData.Cycle = new DrivingCycleProxy(drivingCycle, vtpCycle.Name);
vtpRunData.Aux = AuxVTP;
vtpRunData.FanData = GetFanData();
vtpRunData.ExecutionMode = ExecutionMode.Declaration;
vtpRunData.SimulationType = SimulationType.VerificationTest;
vtpRunData.Mission = new Mission() {
MissionType = MissionType.VerificationTest
};
//var ncvStd = DeclarationData.FuelData.Lookup(JobInputData.Vehicle.Components.EngineInputData.FuelType).LowerHeatingValueVecto;
//var ncvCorrection = ncvStd / JobInputData.NetCalorificValueTestFuel;
var mileageCorrection = GetMileagecorrectionFactor(JobInputData.Mileage);
vtpRunData.VTPData = new VTPData() {
CorrectionFactor = mileageCorrection,
};
yield return vtpRunData;
}
protected virtual AuxFanData GetFanData()
{
return new AuxFanData() {
FanCoefficients = DeclarationData.VTPMode.FanParameters,
FanDiameter = JobInputData.FanDiameter,
};
}
private double GetMileagecorrectionFactor(Meter mileage)
{
if (mileage > DeclarationData.VTPMode.RunInThreshold) {
return 1;
}
return DeclarationData.VTPMode.EvolutionCoefficient + (1 - DeclarationData.VTPMode.EvolutionCoefficient) * mileage /
DeclarationData.VTPMode.RunInThreshold;
}
protected VectoRunData CreateVectoRunData(Segment segment, Mission mission, Kilogram loading)
{
return new VectoRunData {
JobName = JobInputData.Vehicle.VIN,
EngineData = EngineData,
GearboxData = GearboxData,
AxleGearData = AxlegearData,
AngledriveData = AngledriveData,
VehicleData = Dao.CreateVehicleData(
JobInputData.Vehicle, mission,
loading, allowVocational),
AirdragData = AirdragData,
DriverData = null,
AdvancedAux = null,
Retarder = RetarderData,
PTO = PTOTransmissionData,
Report = Report,
};
}
protected virtual List<VectoRunData.AuxData> CreateVTPAuxData(IVehicleDeclarationInputData vehicle)
{
var auxRD = Dao.CreateAuxiliaryData(
vehicle.Components.AuxiliaryInputData, MissionType.RegionalDelivery, Segment.VehicleClass)
.ToList();
foreach (var entry in auxRD) {
entry.MissionType = MissionType.RegionalDelivery;
}
var auxLH = Dao.CreateAuxiliaryData(
vehicle.Components.AuxiliaryInputData, MissionType.LongHaul, Segment.VehicleClass)
.ToList();
foreach (var entry in auxLH) {
entry.MissionType = MissionType.LongHaul;
}
var auxUD = Dao.CreateAuxiliaryData(
vehicle.Components.AuxiliaryInputData, MissionType.UrbanDelivery, Segment.VehicleClass)
.ToList();
foreach (var entry in auxUD) {
entry.MissionType = MissionType.UrbanDelivery;
}
var aux = new List<VectoRunData.AuxData>();
aux.AddRange(auxRD);
aux.AddRange(auxLH);
aux.AddRange(auxUD);
aux.RemoveAll(x => x.ID == Constants.Auxiliaries.IDs.Fan);
aux.Add(
new VectoRunData.AuxData {
DemandType = AuxiliaryDemandType.Direct,
ID = DrivingCycleDataReader.Fields.AdditionalAuxPowerDemand
});
return aux;
}
#endregion
}
}
using System.Collections.Generic;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl {
public class EngineSpeedDriveOffPreprocessor : ISimulationPreprocessor
{
protected VectoRunData Data;
protected SimplePowertrainContainer Container;
protected Dictionary<uint, PerSecond> engineSpeeds;
public EngineSpeedDriveOffPreprocessor(Dictionary<uint, PerSecond> engineSpeedAtDriveOff, VectoRunData runData, SimplePowertrainContainer testContainer)
{
Data = runData;
Container = testContainer;
engineSpeeds = engineSpeedAtDriveOff;
}
#region Implementation of ISimulationPreprocessor
public void RunPreprocessing()
{
var vehicle = Container.VehicleInfo as Vehicle;
if (vehicle == null) {
throw new VectoException("no vehicle found...");
}
var gearbox = Container.GearboxInfo as Gearbox;
if (gearbox == null) {
throw new VectoException("no gearbox found...");
}
// issue a initialize and request call in order to avoid a slipping clutch when looping over all gears
gearbox.Disengaged = false;
gearbox.Gear = 1;
vehicle.Initialize(Data.GearshiftParameters.StartVelocity, VectoMath.InclinationToAngle(0));
vehicle.Request(0.SI<Second>(), 0.5.SI<Second>(), 0.SI<MeterPerSquareSecond>(), 0.SI<Radian>());
foreach (var gearData in Data.GearboxData.Gears) {
gearbox.Gear = gearData.Key;
gearbox.Disengaged = false;
var response = vehicle.Initialize(Data.GearshiftParameters.StartVelocity, VectoMath.InclinationToAngle(0));
engineSpeeds[gearData.Key] = response.Engine.EngineSpeed;
}
}
#endregion
}
}
\ No newline at end of file
using System.Collections.Generic;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl {
public class MaxCardanTorquePreprocessor : ISimulationPreprocessor
{
protected readonly MaxCardanTorqueLookup MaxCardanTorqueLookup;
protected readonly VectoRunData Data;
protected readonly SimplePowertrainContainer TestContainer;
public MaxCardanTorquePreprocessor(MaxCardanTorqueLookup maxCardanTorqueLookup, VectoRunData data, SimplePowertrainContainer testContainer)
{
MaxCardanTorqueLookup = maxCardanTorqueLookup;
Data = data;
TestContainer = testContainer;
}
#region Implementation of ISimulationPreprocessor
public void RunPreprocessing()
{
var retVal = new Dictionary<uint, List<KeyValuePair<PerSecond, NewtonMeter>>>(Data.GearboxData.Gears.Count);
var testContainerGbx = TestContainer.GearboxCtl as Gearbox;
if (testContainerGbx == null) {
throw new VectoException("Unknown gearboxtype: {0}", TestContainer.GearboxCtl.GetType().FullName);
}
testContainerGbx.Gear = 1;
var init = TestContainer.VehiclePort.Initialize(Data.GearshiftParameters.StartVelocity, 0.SI<Radian>());
var powertrainRatioWOGearbox = (Data.GearshiftParameters.StartVelocity / init.Engine.EngineSpeed * Data.GearboxData.Gears[1].Ratio).Cast<Meter>();
var engineSpeedSteps = (Data.EngineData.FullLoadCurves[0].N95hSpeed - Data.EngineData.IdleSpeed) / 100;
foreach (var gearData in Data.GearboxData.Gears) {
retVal[gearData.Key] = new List<KeyValuePair<PerSecond, NewtonMeter>>();
testContainerGbx.Gear = gearData.Key;
for (var engineSpeed = Data.EngineData.IdleSpeed;
engineSpeed < Data.EngineData.FullLoadCurves[0].N95hSpeed;
engineSpeed += engineSpeedSteps) {
var maxTorque = Data.EngineData.FullLoadCurves[gearData.Key].FullLoadStationaryTorque(engineSpeed);
var vehicleSpeed = engineSpeed * powertrainRatioWOGearbox / gearData.Value.Ratio;
var grad = VectoMath.InclinationToAngle(1);
var max = TestContainer.VehiclePort.Initialize(vehicleSpeed, grad);
if ((max.Engine.TotalTorqueDemand - maxTorque).IsGreater(0)) {
var first = TestContainer.VehiclePort.Initialize(vehicleSpeed, 0.SI<Radian>());
var delta = first.Engine.TotalTorqueDemand - maxTorque;
grad = SearchAlgorithm.Search(
0.SI<Radian>(), delta, 0.1.SI<Radian>(),
getYValue: r => {
return ((r as AbstractResponse).Engine.TotalTorqueDemand - maxTorque);
},
evaluateFunction: g => {
return TestContainer.VehiclePort.Initialize(vehicleSpeed, g);
},
criterion: r => {
return ((r as AbstractResponse).Engine.TotalTorqueDemand - maxTorque).Value() / 1e5;
}
);
max = TestContainer.VehiclePort.Initialize(vehicleSpeed, grad);
}
retVal[gearData.Key].Add(new KeyValuePair<PerSecond, NewtonMeter>(max.Engine.EngineSpeed, max.Axlegear.CardanTorque));
}
}
MaxCardanTorqueLookup.Data = retVal;
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl {
public class MaxGradabilityPreprocessor : ISimulationPreprocessor
{
protected readonly MaxGradabilityLookup GradabilityLookup;
protected readonly VectoRunData ModelData;
protected SimplePowertrainContainer Container;
public MaxGradabilityPreprocessor(MaxGradabilityLookup maxGradability, VectoRunData modelData, SimplePowertrainContainer simpleContainer)
{
GradabilityLookup = maxGradability;
ModelData = modelData;
Container = simpleContainer;
}
#region Implementation of ISimulationPreprocessor
public void RunPreprocessing()
{
GradabilityLookup.Data = SearchMaxRoadGradient();
}
private Dictionary<uint, Tuple<Radian, Radian>> SearchMaxRoadGradient()
{
var vehicle = Container?.VehicleInfo as Vehicle;
if (vehicle == null) {
throw new VectoException("no vehicle found...");
}
var gearbox = Container.GearboxInfo as Gearbox;
if (gearbox == null) {
throw new VectoException("no gearbox found...");
}
//var driver = container.Driver as Driver;
//if (driver == null) {
// throw new VectoException("no driver found...");
//}
//driver.DriverBehavior = DrivingBehavior.Driving;
gearbox.Disengaged = false;
var retVal = new Dictionary<uint, Tuple<Radian, Radian>>();
foreach (var gearData in ModelData.GearboxData.Gears) {
var engineSpeed = ModelData.EngineData.FullLoadCurves[0].NTq99lSpeed;
var vehicleSpeed = CalcVehicleSpeed(engineSpeed, gearData);
gearbox.Gear = gearData.Key;
var gradMaxTorque = SearchGradient(vehicle, vehicleSpeed, ModelData.EngineData.FullLoadCurves[0].MaxTorque * 0.99);
engineSpeed = (ModelData.EngineData.FullLoadCurves[0].NTq99lSpeed +
ModelData.EngineData.FullLoadCurves[0].NTq99hSpeed) / 2.0;
vehicleSpeed = CalcVehicleSpeed(engineSpeed, gearData);
var torqueFactor = ModelData.GearshiftParameters.ShareTorque99L.Lookup(vehicleSpeed);
var gradRedTorque = SearchGradient(vehicle, vehicleSpeed, ModelData.EngineData.FullLoadCurves[0].FullLoadStationaryTorque(engineSpeed) * torqueFactor);
retVal.Add(gearData.Key, Tuple.Create(gradMaxTorque, gradRedTorque));
}
return retVal;
}
private Radian SearchGradient(Vehicle vehicle, MeterPerSecond vehicleSpeed, NewtonMeter maxTorque)
{
var gradientMax = VectoMath.InclinationToAngle(1);
var responseMax = vehicle.Initialize(vehicleSpeed, gradientMax);
var deltaMax = responseMax.Engine.PowerRequest / responseMax.Engine.EngineSpeed - maxTorque;
if (deltaMax.IsSmaller(0)) {
return gradientMax;
}
var gradient = VectoMath.InclinationToAngle(0);
var response = vehicle.Initialize(vehicleSpeed, gradient);
var delta = response.Engine.PowerRequest / response.Engine.EngineSpeed - maxTorque;
gradient = SearchAlgorithm.Search(
gradient, delta, VectoMath.InclinationToAngle(1),
getYValue: r => {
var rs = r as ResponseSuccess;
if (rs != null) {
return rs.Engine.PowerRequest / rs.Engine.EngineSpeed - maxTorque;
}
return 0.SI<NewtonMeter>();
},
evaluateFunction: g => {
return vehicle.Initialize(vehicleSpeed, g);
},
criterion: r => {
var rs = r as ResponseSuccess;
if (rs != null) {
return (rs.Engine.PowerRequest / rs.Engine.EngineSpeed - maxTorque).Value();
}
return 0;
}
);
return gradient;
}
private MeterPerSecond CalcVehicleSpeed(PerSecond engineSpeed, KeyValuePair<uint, GearData> gearData)
{
return engineSpeed / gearData.Value.Ratio / ModelData.AxleGearData.AxleGear.Ratio /
(ModelData.AngledriveData?.Angledrive.Ratio ?? 1.0) * ModelData.VehicleData.DynamicTyreRadius;
}
#endregion
}
}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment