Newer
Older
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
*
* 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.Globalization;
using NUnit.Framework;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Tests.Integration;
using TUGraz.VectoCore.Tests.Utils;
namespace TUGraz.VectoCore.ModelbasedTests.DriverStrategy
{
[TestFixture]
public class SimpleCycles
{
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
public void Init()
{
//LogManager.DisableLogging();
#if TRACE
GraphWriter.Enable();
#else
GraphWriter.Disable();
#endif
GraphWriter.Xfields = new[] { ModalResultField.time, ModalResultField.dist };
GraphWriter.Yfields = new[] {
ModalResultField.v_act, ModalResultField.acc, ModalResultField.n_eng_avg, ModalResultField.Gear,
ModalResultField.P_eng_out, ModalResultField.T_eng_fcmap, ModalResultField.FCMap
};
GraphWriter.Series1Label = "Vecto 3";
}
private static string GetSlopeString(double slope)
{
var slopeStr = slope > 0
? Math.Abs(slope).ToString("uphill_#")
: slope < 0
? Math.Abs(slope).ToString("downhill_#")
: "level";
return slopeStr;
}
[Category("LongRunning"),
TestCase(0, 80), TestCase(80, 0), TestCase(80, 80),
TestCase(0, 60), TestCase(60, 0), TestCase(60, 60),
TestCase(0, 40), TestCase(40, 0), TestCase(40, 40),
TestCase(0, 20), TestCase(20, 0), TestCase(20, 20),
]
public void Truck_AllSlopes(double v1, double v2)
{
var slopes = new[] { 25, 20, 15, 10, 5, 3, 1, 0, -1, -3, -5, -10, -15, -20, -25 };
foreach (var slope in slopes) {
try {
var cycle = string.Format(CultureInfo.InvariantCulture, "0, {0}, {1}, {2}\n1000, {3}, {4}, {5}", v1, slope,
v1.IsEqual(0) ? 2 : 0, v2, slope, v2.IsEqual(0) ? 2 : 0);
var modFileName = string.Format(CultureInfo.InvariantCulture, "Truck_{0}_{1}_{2}.vmod", v1, v2,
GetSlopeString(slope));
var cycleData = SimpleDrivingCycles.CreateCycleData(cycle);
var run = Truck40tPowerTrain.CreateEngineeringRun(cycleData, modFileName);
run.Run();
Assert.IsTrue(run.FinishedWithoutErrors, "Truck Run (v1: {0}, v2: {1}, slope: {2}) failed.", v1, v2, slope);
GraphWriter.Write(modFileName);
} catch (Exception ex) {
Assert.Fail("Truck Run (v1: {0}, v2: {1}, slope: {2}) failed: {3}", v1, v2, slope, ex);
}
}
}
[Category("LongRunning"),
TestCase(0, 80), TestCase(80, 0), TestCase(80, 80),
TestCase(0, 60), TestCase(60, 0), TestCase(60, 60),
TestCase(0, 40), TestCase(40, 0), TestCase(40, 40),
TestCase(0, 20), TestCase(20, 0), TestCase(20, 20),
]
public void Coach_AllSlopes(double v1, double v2)
{
var slopes = new[] { 15, 12, 10, 7, 5, 3, 1, 0, -1, -3, -5, -7, -10, -12, -15 };
foreach (var slope in slopes) {
try {
var cycle = string.Format(CultureInfo.InvariantCulture, "0, {0}, {1}, {2}\n1000, {3}, {4}, {5}", v1, slope,
v1.IsEqual(0) ? 2 : 0, v2, slope, v2.IsEqual(0) ? 2 : 0);
var modFileName = string.Format(CultureInfo.InvariantCulture, "Coach_{0}_{1}_{2}.vmod", v1, v2,
GetSlopeString(slope));
var cycleData = SimpleDrivingCycles.CreateCycleData(cycle);
var run = CoachPowerTrain.CreateEngineeringRun(cycleData, modFileName);
run.Run();
Assert.IsTrue(run.FinishedWithoutErrors, "Truck Run (v1: {0}, v2: {1}, slope: {2}) failed.", v1, v2, slope);
GraphWriter.Write(modFileName);
} catch (Exception ex) {
Assert.Fail("Truck Run (v1: {0}, v2: {1}, slope: {2}) failed: {3}", v1, v2, slope, ex);
}
}
}
}