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

added test files, added missing ValidateObject Attributes

parent 3e915e5e
No related branches found
No related tags found
No related merge requests found
...@@ -30,11 +30,12 @@ ...@@ -30,11 +30,12 @@
*/ */
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Data namespace TUGraz.VectoCore.Models.SimulationComponent.Data
{ {
public class AxleGearData : SimulationComponentData public class AxleGearData : SimulationComponentData
{ {
public GearData AxleGear; [ValidateObject] public GearData AxleGear;
} }
} }
\ No newline at end of file
...@@ -37,6 +37,7 @@ using TUGraz.VectoCore.Models.Simulation; ...@@ -37,6 +37,7 @@ using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
...@@ -45,7 +46,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -45,7 +46,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
protected ITnOutPort NextComponent; protected ITnOutPort NextComponent;
internal readonly AxleGearData ModelData; [ValidateObject] internal readonly AxleGearData ModelData;
public AxleGear(IVehicleContainer container, AxleGearData modelData) : base(container) public AxleGear(IVehicleContainer container, AxleGearData modelData) : base(container)
{ {
......
...@@ -68,7 +68,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -68,7 +68,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs";
public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld";
public TestContext TestContext { get; set; } public const string AxleGearValidRangeDataFile = @"TestData\Components\AxleGearValidRange.vgbx";
public const string AxleGearInvalidRangeDataFile = @"TestData\Components\AxleGearInvalidRange.vgbx";
private static GearboxData CreateGearboxData() private static GearboxData CreateGearboxData()
{ {
...@@ -124,6 +125,24 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -124,6 +125,24 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
"AngularVelocity Engine Side"); "AngularVelocity Engine Side");
} }
[TestCase]
public void AxleGearValidRangeTest()
{
var vehicle = new VehicleContainer(ExecutionMode.Engineering);
var axleGearData = MockSimulationDataFactory.CreateAxleGearDataFromFile(AxleGearValidRangeDataFile);
var axleGear = new AxleGear(vehicle, axleGearData);
Assert.AreEqual(0, axleGear.Validate().Count);
}
[TestCase]
public void AxleGearInvalidRangeTest()
{
var vehicle = new VehicleContainer(ExecutionMode.Engineering);
var axleGearData = MockSimulationDataFactory.CreateAxleGearDataFromFile(AxleGearInvalidRangeDataFile);
var axleGear = new AxleGear(vehicle, axleGearData);
var errors = axleGear.Validate();
Assert.AreEqual(1, errors.Count);
}
[Test, [Test,
TestCase(@"TestData\Components\24t Coach LessThanTwoGears.vgbx")] TestCase(@"TestData\Components\24t Coach LessThanTwoGears.vgbx")]
...@@ -359,7 +378,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -359,7 +378,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var ratios = new[] { 0.0, 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 }; var ratios = new[] { 0.0, 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 };
// the first element 0.0 is just a placeholder for axlegear, not used in this test // the first element 0.0 is just a placeholder for axlegear, not used in this test
var absTime = 0.SI<Second>(); var absTime = 0.SI<Second>();
var dt = 2.SI<Second>(); var dt = 2.SI<Second>();
...@@ -370,7 +388,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -370,7 +388,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var torque = (expectedT - expectedLoss) * ratios[gear]; var torque = (expectedT - expectedLoss) * ratios[gear];
var angularVelocity = expectedN / ratios[gear]; var angularVelocity = expectedN / ratios[gear];
gearbox.OutPort().Initialize(torque, angularVelocity); gearbox.OutPort().Initialize(torque, angularVelocity);
gearbox.Gear = (uint)gear; gearbox.Gear = (uint)gear;
var response = gearbox.OutPort().Request(absTime, dt, torque, angularVelocity); var response = gearbox.OutPort().Request(absTime, dt, torque, angularVelocity);
...@@ -384,7 +401,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -384,7 +401,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
} }
} }
[Test, [Test,
TestCase(8, 7, 1500, 750, typeof(ResponseGearShift)), TestCase(8, 7, 1500, 750, typeof(ResponseGearShift)),
TestCase(7, 6, 1500, 750, typeof(ResponseGearShift)), TestCase(7, 6, 1500, 750, typeof(ResponseGearShift)),
...@@ -410,13 +426,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -410,13 +426,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var ratios = new[] { 0.0, 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 }; var ratios = new[] { 0.0, 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 };
// the first element 0.0 is just a placeholder for axlegear, not used in this test // the first element 0.0 is just a placeholder for axlegear, not used in this test
var absTime = 0.SI<Second>(); var absTime = 0.SI<Second>();
var dt = 2.SI<Second>(); var dt = 2.SI<Second>();
gearbox.OutPort().Initialize(1.SI<NewtonMeter>(), 1.SI<PerSecond>()); gearbox.OutPort().Initialize(1.SI<NewtonMeter>(), 1.SI<PerSecond>());
var expectedT = t.SI<NewtonMeter>(); var expectedT = t.SI<NewtonMeter>();
var expectedN = n.RPMtoRad(); var expectedN = n.RPMtoRad();
......
{
"Header": {
"CreatedBy": " ()",
"Date": "8/21/2015 10:16:31 AM",
"AppVersion": "2.2 beta-2",
"FileVersion": 5
},
"Body": {
"SavedInDeclMode": false,
"ModelName": "Generic 24t Coach",
"Inertia": 0.0,
"TracInt": 1.0,
"Gears": [
{
"Ratio": 3.240355,
"LossMap": "AxleInvalid.vtlm"
},
{
"Ratio": 6.38,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 4.63,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 3.44,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 2.59,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 1.86,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 1.35,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 1.0,
"LossMap": "Direct Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 0.76,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
}
],
"TqReserve": 20.0,
"SkipGears": true,
"ShiftTime": 2,
"EaryShiftUp": true,
"StartTqReserve": 20.0,
"StartSpeed": 2.0,
"StartAcc": 0.6,
"GearboxType": "AMT",
"TorqueConverter": {
"Enabled": false,
"File": "<NOFILE>",
"RefRPM": 0.0,
"Inertia": 0.0
}
}
}
\ No newline at end of file
{
"Header": {
"CreatedBy": " ()",
"Date": "8/21/2015 10:16:31 AM",
"AppVersion": "2.2 beta-2",
"FileVersion": 5
},
"Body": {
"SavedInDeclMode": false,
"ModelName": "Generic 24t Coach",
"Inertia": 0.0,
"TracInt": 1.0,
"Gears": [
{
"Ratio": 3.240355,
"LossMap": "AxleValid.vtlm"
},
{
"Ratio": 6.38,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 4.63,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 3.44,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 2.59,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 1.86,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 1.35,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 1.0,
"LossMap": "Direct Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
},
{
"Ratio": 0.76,
"LossMap": "Indirect Gear.vtlm",
"TCactive": false,
"ShiftPolygon": "ShiftPolygons.vgbs",
"FullLoadCurve": "<NOFILE>"
}
],
"TqReserve": 20.0,
"SkipGears": true,
"ShiftTime": 2,
"EaryShiftUp": true,
"StartTqReserve": 20.0,
"StartSpeed": 2.0,
"StartAcc": 0.6,
"GearboxType": "AMT",
"TorqueConverter": {
"Enabled": false,
"File": "<NOFILE>",
"RefRPM": 0.0,
"Inertia": 0.0
}
}
}
\ No newline at end of file
Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm],Eff [-]
0,0,0
-1,-100000,100
-1,100000,100
0,-100001,100
0,100001,100
5001,-100000,100
5001,100000,100
\ No newline at end of file
Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm],Eff [-]
0,0,0
0,-100000,100
0,100000,100
5000,-100000,100
5000,100000,100
\ No newline at end of file
...@@ -189,6 +189,18 @@ ...@@ -189,6 +189,18 @@
<None Include="TestData\Components\12t Delivery Truck.vveh"> <None Include="TestData\Components\12t Delivery Truck.vveh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="TestData\Components\AxleInvalid.vtlm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Components\AxleValid.vtlm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Components\AxleGearInvalidRange.vgbx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Components\AxleGearValidRange.vgbx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Components\24t Coach_IncPT1.vfld"> <None Include="TestData\Components\24t Coach_IncPT1.vfld">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment