Code development platform for open source projects from the European Union institutions

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

renamed ModalResult-enum to ModalResultFields, removed VS-designer attribute from ModalResults

parent 73c28693
No related branches found
No related tags found
No related merge requests found
......@@ -4,19 +4,25 @@ using System.Reflection;
namespace TUGraz.VectoCore.Models.SimulationComponent.Data
{
[System.ComponentModel.DesignerCategory("")] // to disable design view in VisualStudio
public class ModalResults : DataTable
{
public ModalResults()
{
foreach (ModalResult value in Enum.GetValues(typeof(ModalResult)))
foreach (ModalResultField value in Enum.GetValues(typeof(ModalResultField)))
Columns.Add(value.ToString(), value.GetDataType());
}
public DataTable ReadFromFile(string fileName)
{
throw new NotImplementedException();
}
}
/// <summary>
/// Enum with field definitions of the Modal Results File (.vmod).
/// </summary>
public enum ModalResult
public enum ModalResultField
{
[ModalResultFieldAttr(typeof(double))] time, // [s] Time step.
[ModalResultFieldAttr(typeof(double))] dist, // [km] Travelled distance.
......@@ -56,6 +62,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
[ModalResultFieldAttr(typeof(double))] TC_n_Out, // [1/min] Torque converter output speed
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
class ModalResultFieldAttr : Attribute
{
......@@ -68,19 +79,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public static class ModalResultFieldExtensions
{
public static Type GetDataType(this ModalResult field)
public static Type GetDataType(this ModalResultField field)
{
return GetAttr(field).FieldType;
}
private static ModalResultFieldAttr GetAttr(ModalResult field)
private static ModalResultFieldAttr GetAttr(ModalResultField field)
{
return (ModalResultFieldAttr)Attribute.GetCustomAttribute(ForValue(field), typeof (ModalResultFieldAttr));
}
private static MemberInfo ForValue(ModalResult field)
private static MemberInfo ForValue(ModalResultField field)
{
return typeof (ModalResult).GetField(Enum.GetName(typeof (ModalResult), field));
return typeof (ModalResultField).GetField(Enum.GetName(typeof (ModalResultField), field));
}
}
}
......@@ -9,7 +9,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
object this[ModalResult key] { get; set; }
object this[ModalResultField key] { get; set; }
/// <summary>
/// Commits the data of the current simulation step.
......
......@@ -19,9 +19,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public override void CommitSimulationStep(IModalDataWriter writer)
{
writer[ModalResult.FC] = 1;
writer[ModalResult.FC_AUXc] = 2;
writer[ModalResult.FC_WHTCc] = 3;
writer[ModalResultField.FC] = 1;
writer[ModalResultField.FC_AUXc] = 2;
writer[ModalResultField.FC_WHTCc] = 3;
}
public void Request(TimeSpan absTime, TimeSpan dt, double torque, double engineSpeed)
......
......@@ -68,7 +68,7 @@
<Compile Include="Models\Connector\Ports\IOutShaft.cs" />
<Compile Include="Models\Connector\Ports\ITnPort.cs" />
<Compile Include="Models\SimulationComponent\Data\EngineOnlyDrivingCycle.cs" />
<Compile Include="Models\SimulationComponent\Data\ModalResult.cs">
<Compile Include="Models\SimulationComponent\Data\ModalResultField.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Models\SimulationComponent\Data\CombustionEngineData.cs" />
......
......@@ -76,9 +76,9 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
engine.CommitSimulationStep(dataWriter);
//todo: test with correct output values, add other fields to test
Assert.AreEqual(dataWriter[ModalResult.FC], 13000);
Assert.AreEqual(dataWriter[ModalResult.FC_AUXc], 14000);
Assert.AreEqual(dataWriter[ModalResult.FC_WHTCc], 15000);
Assert.AreEqual(dataWriter[ModalResultField.FC], 13000);
Assert.AreEqual(dataWriter[ModalResultField.FC_AUXc], 14000);
Assert.AreEqual(dataWriter[ModalResultField.FC_WHTCc], 15000);
}
[TestMethod]
......@@ -102,15 +102,15 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
absTime += dt;
//todo: test with correct output values, add other fields to test
Assert.AreEqual(dataWriter[ModalResult.FC], 13000);
Assert.AreEqual(dataWriter[ModalResult.FC_AUXc], 14000);
Assert.AreEqual(dataWriter[ModalResult.FC_WHTCc], 15000);
Assert.AreEqual(dataWriter[ModalResultField.FC], 13000);
Assert.AreEqual(dataWriter[ModalResultField.FC_AUXc], 14000);
Assert.AreEqual(dataWriter[ModalResultField.FC_WHTCc], 15000);
}
//todo: test with correct output values, add other fields to test
Assert.AreEqual(dataWriter[ModalResult.FC], 13000);
Assert.AreEqual(dataWriter[ModalResult.FC_AUXc], 14000);
Assert.AreEqual(dataWriter[ModalResult.FC_WHTCc], 15000);
Assert.AreEqual(dataWriter[ModalResultField.FC], 13000);
Assert.AreEqual(dataWriter[ModalResultField.FC_AUXc], 14000);
Assert.AreEqual(dataWriter[ModalResultField.FC_WHTCc], 15000);
}
public TestContext TestContext { get; set; }
......
......@@ -25,7 +25,7 @@ namespace TUGraz.VectoCore.Tests.Utils
CurrentRow = Data.NewRow();
}
public object this[ModalResult key]
public object this[ModalResultField key]
{
get { return CurrentRow[key.ToString()]; }
set { CurrentRow[key.ToString()] = value; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment