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
Unverified Commit c398eec7 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding testcase for new em overload buffer calculation.

allow reading xml component file (binding for components other than EM still missing)
parent 023f4940
Branches
Tags
No related merge requests found
using Ninject.Modules; using System.Xml;
using Ninject.Modules;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider.v24; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider.v24;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces;
...@@ -302,6 +304,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules ...@@ -302,6 +304,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules
Bind<IXMLElectricMotorDeclarationInputData>().To<XMLElectricMotorDeclarationInputDataProviderV23>() Bind<IXMLElectricMotorDeclarationInputData>().To<XMLElectricMotorDeclarationInputDataProviderV23>()
.Named(XMLElectricMotorDeclarationInputDataProviderV23.QUALIFIED_XSD_TYPE); .Named(XMLElectricMotorDeclarationInputDataProviderV23.QUALIFIED_XSD_TYPE);
Bind<IComponentInputData>().ToConstructor<XMLElectricMotorDeclarationInputDataProviderV23>((syntax) => new XMLElectricMotorDeclarationInputDataProviderV23(syntax.Inject<XmlNode>(), syntax.Inject<string>()))
.Named(XMLElectricMotorDeclarationInputDataProviderV23.QUALIFIED_XSD_TYPE);
Bind<IXMLElectricMotorDeclarationInputData>().To<XMLElectricMotorSystemStandardDeclarationInputDataProviderV23>() Bind<IXMLElectricMotorDeclarationInputData>().To<XMLElectricMotorSystemStandardDeclarationInputDataProviderV23>()
.Named(XMLElectricMotorSystemStandardDeclarationInputDataProviderV23.QUALIFIED_XSD_TYPE); .Named(XMLElectricMotorSystemStandardDeclarationInputDataProviderV23.QUALIFIED_XSD_TYPE);
......
...@@ -62,5 +62,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML ...@@ -62,5 +62,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML
IAirdragDeclarationInputData CreateAirdrag(string filename); IAirdragDeclarationInputData CreateAirdrag(string filename);
IAirdragDeclarationInputData CreateAirdrag(Stream inputData); IAirdragDeclarationInputData CreateAirdrag(Stream inputData);
IAirdragDeclarationInputData CreateAirdrag(XmlReader inputData); IAirdragDeclarationInputData CreateAirdrag(XmlReader inputData);
TOut CreateFromFile<TOut>(string filename) where TOut : class;
TOut CreateFromStream<TOut>(Stream inputData) where TOut : class;
} }
} }
...@@ -220,14 +220,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML ...@@ -220,14 +220,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML
return CreateFromFile<IAirdragDeclarationInputData>(filename); return CreateFromFile<IAirdragDeclarationInputData>(filename);
} }
private TOut CreateFromFile<TOut>(string filename) where TOut : class // when using this method to create component data, make sure to have a binding like this for the component:
// Bind<IComponentInputData>().ToConstructor<XMLElectricMotorDeclarationInputDataProviderV23>((syntax) => new XMLElectricMotorDeclarationInputDataProviderV23(syntax.Inject<XmlNode>(), syntax.Inject<string>()))
// .Named(XMLElectricMotorDeclarationInputDataProviderV23.QUALIFIED_XSD_TYPE);
public TOut CreateFromFile<TOut>(string filename) where TOut : class
{ {
using (var reader = XmlReader.Create(filename)) { using (var reader = XmlReader.Create(filename)) {
return CreateFromXmlReader<TOut>(reader, filename); return CreateFromXmlReader<TOut>(reader, filename);
} }
} }
private TOut CreateFromStream<TOut>(Stream inputData) where TOut : class public TOut CreateFromStream<TOut>(Stream inputData) where TOut : class
{ {
using (var reader = XmlReader.Create(inputData)) { using (var reader = XmlReader.Create(inputData)) {
return CreateFromXmlReader<TOut>(reader, null); return CreateFromXmlReader<TOut>(reader, null);
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Ninject;
using NUnit.Framework; using NUnit.Framework;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.InputData.FileIO.XML;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces;
using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.ComponentData;
using TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData { namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData {
...@@ -149,6 +152,27 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData { ...@@ -149,6 +152,27 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData {
Assert.IsTrue(efficiencies.All(x => x.IsBetween(etaMin, etaMax)), $"{efficiencies.Min()} - {efficiencies.Max()}"); Assert.IsTrue(efficiencies.All(x => x.IsBetween(etaMin, etaMax)), $"{efficiencies.Min()} - {efficiencies.Max()}");
} }
[TestCase(@"TestData/XML/XMLReaderDeclaration/SchemaVersion2.4/Distributed/ComponentData/ElectricMachineSystem_Std_Overload.xml", 600063.423)]
public void TestElectricMotorOverloadBufferTest(string testFile, double expectedOvlBfr)
{
var kernel = new StandardKernel(new VectoNinjectModule());
var componentFactory = kernel.Get<IXMLComponentInputReader>();
var componentData = componentFactory.CreateFromFile<IXMLElectricMotorDeclarationInputData>(testFile);
var em = new XMLElectricMachinesDeclarationData(
new List<ElectricMachineEntry<IElectricMotorDeclarationInputData>> {
new ElectricMachineEntry<IElectricMotorDeclarationInputData>() {
Count = 1,
ElectricMachine = componentData
}
});
var da = new ElectricMachinesDataAdapter();
var modelData = da.CreateElectricMachines(em, null, 500.SI<Volt>());
var emData = modelData.First().Item2;
Assert.AreEqual(expectedOvlBfr, emData.Overload.OverloadBuffer.Value(), 0.1);
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment