@@ -4,7 +4,9 @@ The DataReplayer reads recorded CSV data and replays it by sending UDP packets t
44
55## Features
66
7- - Loads CSV data from ` raw_data/2024-4-7rawdata.csv `
7+ - ** Interactive CSV file selection** with file size and drive duration information
8+ - ** Command-line support** for quick file selection
9+ - ** Drive duration analysis** - automatically calculates drive time from timestamps
810- Parses CSV headers and maps them to the solar car data format
911- ** Generates current timestamps** for live graphing compatibility
1012- Sends data packets via UDP at 31Hz (32ms intervals) to match real-time telemetry
@@ -13,24 +15,57 @@ The DataReplayer reads recorded CSV data and replays it by sending UDP packets t
1315
1416## Usage
1517
16- 1 . Make sure you have the CSV file in ` raw_data/2024-4-7rawdata.csv `
17- 2 . Navigate to the DataReplayer directory and run:
18- ``` bash
19- cd DataReplayer
20- npm start
21- ```
22- 3 . The replayer will:
23- - Load all CSV data into memory
24- - Start sending UDP packets to ` localhost:4003 `
25- - Display progress updates every 100 packets
18+ ### Interactive Mode (with menu)
19+ Navigate to the DataReplayer directory and run:
20+ ``` bash
21+ cd DataReplayer
22+ npm start
23+ ```
24+
25+ This will show an interactive menu with:
26+ - All available CSV files in the ` raw_data ` directory
27+ - File sizes (in MB)
28+ - Drive durations (calculated from timestamps)
29+ - Arrow key navigation for selection
30+
31+ Example menu:
32+ ```
33+ Data Replayer
34+ =====================================
35+ Select a CSV file to replay:
36+
37+ ? Choose CSV file: (Use arrow keys)
38+ ❯ 2024-4-7rawdata.csv (71.28 MB, 4h 15m)
39+ coasts2024-04-141530.csv (21.54 MB, 23m)
40+ ```
41+
42+ ### Command-line Mode (skip menu)
43+ For quick access when you know the filename:
44+ ``` bash
45+ npm start filename.csv
46+ npm start coasts2024-04-141530.csv
47+ ```
48+
49+ This will:
50+ - Skip the interactive menu
51+ - Show file information (size and duration)
52+ - Start replaying immediately
53+
54+ ### Getting Help
55+ ``` bash
56+ npm run help
57+ ```
2658
2759## Installation
2860
29- No additional dependencies are needed since the DataReplayer uses only Node.js built-in modules:
30- - ` fs ` - File system operations
31- - ` readline ` - CSV parsing
32- - ` dgram ` - UDP socket communication
33- - ` buffer ` - Binary data handling
61+ Install dependencies:
62+ ``` bash
63+ npm install
64+ ```
65+
66+ Required dependencies:
67+ - ` inquirer ` - Interactive CLI menus
68+ - Node.js built-in modules: ` fs ` , ` readline ` , ` dgram ` , ` buffer `
3469
3570## Data Flow
3671
@@ -39,12 +74,23 @@ CSV File → Parse → Binary Buffer → UDP Packet → Backend (port 4003)
3974```
4075
4176The replayer:
77+ - ** Analyzes CSV files** to determine drive duration and file size
4278- Reads the CSV headers and maps them to the solar car data format
4379- ** Replaces old timestamps with current time** to enable live graphing
4480- Converts each row to a binary buffer using the same format as DataGenerator
4581- Sends packets at the same rate as live telemetry (31Hz)
4682- Loops through the dataset continuously
4783
84+ ## Drive Duration Analysis
85+
86+ The DataReplayer automatically calculates drive duration by:
87+ 1 . Reading the first timestamp from the ` Var1 ` column (first data row)
88+ 2 . Reading the last timestamp from the ` Var1 ` column (last data row)
89+ 3 . Computing the difference and converting to hours and minutes
90+ 4 . Displaying in format: ` 4h 15m ` or ` 23m ` (if less than 1 hour)
91+
92+ This helps you understand the scope of each dataset before selecting it for replay.
93+
4894## Timestamp Handling
4995
5096The DataReplayer automatically replaces timestamp fields from the CSV with current timestamps:
0 commit comments