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 7af566ce authored by Michael KRISPER's avatar Michael KRISPER
Browse files

aux test for mapping auxiliary

parent a5f825e0
Branches
Tags
No related merge requests found
......@@ -280,7 +280,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
var auxCols = row.Table.Columns.Cast<DataColumn>().
Where(col => col.ColumnName.StartsWith(Fields.AuxiliarySupplyPower));
return auxCols.ToDictionary(key => key.ColumnName.Substring(Fields.AuxiliarySupplyPower.Length - 1),
return auxCols.ToDictionary(key => key.ColumnName,
value => row.ParseDouble(value).SI().Kilo.Watt.Cast<Watt>());
}
}
......
......@@ -95,14 +95,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public void AddMapping(string auxId, IDrivingCycleCockpit cycle, MappingAuxiliaryData data)
{
if (!cycle.CycleData().LeftSample.AuxiliarySupplyPower.ContainsKey(auxId)) {
if (!cycle.CycleData().LeftSample.AuxiliarySupplyPower.ContainsKey("Aux_" + auxId)) {
var error = string.Format("driving cycle does not contain column for auxiliary: {0}", auxId);
LogManager.GetLogger(GetType()).ErrorFormat(error);
throw new VectoException(error);
}
_auxDict[auxId] = speed => {
var powerSupply = cycle.CycleData().LeftSample.AuxiliarySupplyPower[auxId];
var powerSupply = cycle.CycleData().LeftSample.AuxiliarySupplyPower["Aux_" + auxId];
var nAuxiliary = speed * data.TransitionRatio;
var powerAuxOut = powerSupply / data.EfficiencyToSupply;
......
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
......@@ -30,7 +31,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
stream.ReadLine(); // skip header "Efficiency auxiliary to supply [-]"
auxData.EfficiencyToSupply = stream.ReadLine().ToDouble();
var table = VectoCSVFile.ReadStream(stream.BaseStream);
var m = new MemoryStream(Encoding.UTF8.GetBytes(stream.ReadToEnd()));
var table = VectoCSVFile.ReadStream(m);
var data = table.Rows.Cast<DataRow>().Select(row => new {
AuxiliarySpeed = row.ParseDouble("Auxiliary speed").RPMtoRad(),
......
......@@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.Utils
{
try {
var lines = new List<string>();
using (StreamReader reader = new StreamReader(stream)) {
using (var reader = new StreamReader(stream)) {
while (!reader.EndOfStream) {
lines.Add(reader.ReadLine());
}
......
......@@ -107,7 +107,11 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
[TestMethod]
public void Test_AuxMapping()
{
const string auxId = "ALT1";
var dataWriter = new TestModalDataWriter();
dataWriter.AddAuxiliary(auxId);
var sumWriter = new TestSumWriter();
var container = new VehicleContainer(dataWriter, sumWriter);
var data = DrivingCycleData.ReadFromFile(@"TestData\Cycles\Coach time based short.vdri",
......@@ -119,7 +123,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
aux.InPort().Connect(port);
var auxData = MappingAuxiliaryData.ReadFromFile(@"TestData\Components\24t_Coach_ALT.vaux");
aux.AddMapping("ALT1", cycle, auxData);
aux.AddMapping(auxId, cycle, auxData);
var speed = 1400.RPMtoRad();
var torque = 500.SI<NewtonMeter>();
......@@ -128,6 +133,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
Assert.AreEqual(speed, port.AngularVelocity);
Assert.IsTrue(port.Torque > torque);
//todo: test different torques and speeds
//todo: test different points in cycle
Assert.Inconclusive();
}
......
......@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Utils;
......@@ -16,15 +17,16 @@ namespace TUGraz.VectoCore.Tests.Utils
{
Data = new ModalResults();
CurrentRow = Data.NewRow();
Auxiliaries = new Dictionary<string, DataColumn>();
}
public ModalResults Data { get; set; }
public DataRow CurrentRow { get; set; }
object IModalDataWriter.this[string auxId]
public object this[string auxId]
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
get { return CurrentRow[Auxiliaries[auxId]]; }
set { CurrentRow[Auxiliaries[auxId]] = value; }
}
public bool HasTorqueConverter { get; set; }
......@@ -47,14 +49,13 @@ namespace TUGraz.VectoCore.Tests.Utils
return Data.Rows.Cast<DataRow>().Select(x => x.Field<T>((int)key));
}
Dictionary<string, DataColumn> IModalDataWriter.Auxiliaries { get; set; }
public Dictionary<string, DataColumn> Auxiliaries { get; set; }
public void AddAuxiliary(string id)
{
throw new NotImplementedException();
Auxiliaries[id] = Data.Columns.Add(ModalResultField.Paux_ + id, typeof(double));
}
public Dictionary<string, IList<Watt>> Auxiliaries { get; set; }
public object this[ModalResultField key]
{
get { return CurrentRow[key.GetName()]; }
......
......@@ -153,7 +153,9 @@
<None Include="TestData\Components\Direct Gear.vtlm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Components\24t_Coach_ALT.vaux" />
<None Include="TestData\Components\24t_Coach_ALT.vaux">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Components\Coach.vacc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment