forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dynoview.cpp
106 lines (75 loc) · 2.47 KB
/
test_dynoview.cpp
1
2
3
4
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
45
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
#include "pch.h"
#include "dynoview.h"
void printResults(DynoView *dut) {
#ifdef DBG_TESTS
std::cerr.precision(32);
std::cerr << "Acceleration m/s " << dut->getAcceleration() << std::endl;
std::cerr << "Car force in N " << dut->getEngineForce() << std::endl;
std::cerr << "Car power in KW "<< dut->getEnginePower() << std::endl;
std::cerr << "Car HP " << dut->getEngineHP() << std::endl;
std::cerr << "Car Torque at wheel Nm " << dut->getEngineTorque() << std::endl;
#else
(void)dut;
#endif
}
TEST(DynoView, VSS_T1) {
EngineTestHelper eth(TEST_ENGINE);
DynoView dut;
// Test Speed threshold
engineConfiguration->vehicleWeight = 900;
eth.moveTimeForwardMs(50);
Sensor::setMockValue(SensorType::VehicleSpeed, 18.0);
dut.update(ICU);
eth.moveTimeForwardAndInvokeEventsSec(20);
Sensor::setMockValue(SensorType::VehicleSpeed, 126.0);
dut.update(ICU);
ASSERT_EQ(1.5, dut.getAcceleration());
}
TEST(DynoView, algo) {
EngineTestHelper eth(TEST_ENGINE);
DynoView dut;
// Test Speed threshold
engineConfiguration->vehicleWeight = 900;
//to capture vss
Sensor::setMockValue(SensorType::VehicleSpeed, 35*3.6);
dut.update(ICU);
dut.setAcceleration(1.5);
dut.updateHP();
ASSERT_EQ(1.5, dut.getAcceleration());
ASSERT_EQ(1350, dut.getEngineForce());
ASSERT_EQ(47, dut.getEnginePower());
ASSERT_EQ(63, dut.getEngineHP());
printResults(&dut);
}
TEST(DynoView, VSS_fast) {
EngineTestHelper eth(TEST_ENGINE);
DynoView dut;
// Test Speed threshold
engineConfiguration->vehicleWeight = 900; //kg
Sensor::setMockValue(SensorType::Rpm, 2200);
eth.moveTimeForwardMs(50);
Sensor::setMockValue(SensorType::VehicleSpeed, 50.0);
dut.update(CAN);
//delay 50ms
eth.moveTimeForwardMs(50);
Sensor::setMockValue(SensorType::VehicleSpeed, 50.252);
dut.update(CAN);
ASSERT_EQ(1259, dut.getEngineForce());
printResults(&dut);
}
TEST(DynoView, VSS_Torque) {
EngineTestHelper eth(TEST_ENGINE);
DynoView dut;
// Test Speed threshold
engineConfiguration->vehicleWeight = 900; //kg
Sensor::setMockValue(SensorType::Rpm, 2200);
eth.moveTimeForwardMs(50);
Sensor::setMockValue(SensorType::VehicleSpeed, 80.0);
dut.update(CAN);
//delay 50ms
eth.moveTimeForwardMs(50);
Sensor::setMockValue(SensorType::VehicleSpeed, 80.504);
dut.update(CAN);
ASSERT_EQ(242, dut.getEngineTorque());
printResults(&dut);
}