-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_warmup_test.c
More file actions
80 lines (66 loc) · 2.18 KB
/
simple_warmup_test.c
File metadata and controls
80 lines (66 loc) · 2.18 KB
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "engine-sim-bridge/include/engine_sim_bridge.h"
int main() {
printf("=== Simple Warmup Phase Test ===\n");
// Configuration
EngineSimConfig config = {};
config.sampleRate = 48000;
config.inputBufferSize = 1024;
config.audioBufferSize = 96000;
config.simulationFrequency = 60;
config.volume = 0.5f;
// Create engine
EngineSimHandle handle = NULL;
EngineSimResult result = EngineSimCreate(&config, &handle);
if (result != ESIM_SUCCESS) {
printf("Failed to create engine simulation\n");
return 1;
}
// Load script
result = EngineSimLoadScript(handle, "mock_sine_engine.mr", ".");
if (result != ESIM_SUCCESS) {
printf("Failed to load script\n");
EngineSimDestroy(handle);
return 1;
}
// Start audio thread
result = EngineSimStartAudioThread(handle);
if (result != ESIM_SUCCESS) {
printf("Failed to start audio thread\n");
EngineSimDestroy(handle);
return 1;
}
// Enable starter motor and ignition
EngineSimSetStarterMotor(handle, 1);
EngineSimSetIgnition(handle, 1);
printf("Engine started. Monitoring RPM for 3 seconds...\n");
printf("Time(s) | RPM | Warmup\n");
printf("--------|-----|-------\n");
// Monitor for 3 seconds
for (int i = 0; i < 30; i++) {
// Update engine state
EngineSimUpdate(handle, 0.1);
// Get stats
EngineSimStats stats;
EngineSimGetStats(handle, &stats);
// Check warmup status
int inWarmup = 1; // We'll add a function to check this later
printf("%6.1f | %4.0f | %s\n", (i + 1) * 0.1, stats.currentRPM,
i < 20 ? "YES" : "NO");
// After 2 seconds, disable starter motor
if (i == 20) {
EngineSimSetStarterMotor(handle, 0);
printf("\nStarter motor disabled at t=2.0s\n");
}
usleep(100000); // 100ms
}
printf("\nTest completed successfully!\n");
printf("Engine RPM should be above 600 (minSustainedRPM)\n");
// Cleanup
EngineSimDestroy(handle);
return 0;
}