|
1 | | -# Rubrion CLI Template |
| 1 | +# ENEMETER Data Processing Tool |
2 | 2 |
|
3 | | -This repository is a template for building Go CLI tools for Rubrion. |
| 3 | +A powerful command-line tool for efficiently processing and analyzing ENEMETER energy measurement data. |
4 | 4 |
|
5 | | -## Getting Started |
| 5 | +## Overview |
6 | 6 |
|
7 | | -To run the CLI locally: |
8 | | -\`\`\` |
9 | | -go run ./cmd/rubrion-cli/main.go |
10 | | -\`\`\` |
| 7 | +This tool processes data from ENEMETER devices, which measure various electrical parameters such as voltage, current, and temperature. The tool is designed to handle large CSV files efficiently and provide meaningful energy metrics for analysis. |
11 | 8 |
|
12 | | -## Build |
| 9 | +## Features |
13 | 10 |
|
14 | | -You can build the CLI using: |
15 | | -\`\`\` |
16 | | -make build |
17 | | -\`\`\` |
| 11 | +- Process large CSV files efficiently with streaming mode |
| 12 | +- Filter data by time range, temperature, voltage, or current |
| 13 | +- Sample data to reduce processing requirements |
| 14 | +- Extract specific metrics for targeted analysis |
| 15 | +- Export results in multiple formats (text, JSON, CSV) |
| 16 | +- Calculate energy consumption metrics and statistics |
| 17 | +- Analyze battery charging/discharging patterns |
| 18 | +- Evaluate solar panel contribution |
18 | 19 |
|
19 | | -## Release Process |
| 20 | +## Installation |
20 | 21 |
|
21 | | -This template includes GitHub Actions workflows for QA checks and production releases. |
22 | | -Refer to the files under \`.github/workflows/\` for details. |
| 22 | +### Prerequisites |
| 23 | + |
| 24 | +- Go 1.23 or later |
| 25 | + |
| 26 | +### Building from source |
| 27 | + |
| 28 | +```bash |
| 29 | +git clone https://github.com/yourusername/enemeter-data-processing.git |
| 30 | +cd enemeter-data-processing |
| 31 | +go build |
| 32 | +``` |
| 33 | + |
| 34 | +## Data Format |
| 35 | + |
| 36 | +ENEMETER data is provided in CSV format with four columns: |
| 37 | + |
| 38 | +1. **Time Delta (milliseconds)** - Time elapsed since the last measurement |
| 39 | +2. **Temperature (millicelsius)** - System temperature |
| 40 | +3. **Voltage (microvolts)** - Battery voltage |
| 41 | +4. **Current (nanoamperes)** - System current (positive when charging, negative when discharging) |
| 42 | + |
| 43 | +Example: |
| 44 | +``` |
| 45 | +0000052051,0004815430,-1275169536,0000023192 |
| 46 | +0000000047,0004815430,-1275169536,0000023192 |
| 47 | +0000000047,0004815790,-1276443264,0000023192 |
| 48 | +``` |
| 49 | + |
| 50 | +## Basic Usage |
| 51 | + |
| 52 | +Process a CSV file with default settings: |
| 53 | + |
| 54 | +```bash |
| 55 | +./enemeter-data-processing --input=data/data.csv |
| 56 | +``` |
| 57 | + |
| 58 | +Save results to a text file: |
| 59 | + |
| 60 | +```bash |
| 61 | +./enemeter-data-processing --input=data/data.csv --output=report.txt |
| 62 | +``` |
| 63 | + |
| 64 | +## Command-line Options |
| 65 | + |
| 66 | +### Input/Output Options |
| 67 | + |
| 68 | +- `--input=<path>`: Path to the input CSV file (required) |
| 69 | +- `--output=<path>`: Path to save the output report (optional) |
| 70 | +- `--format=<text|json|csv>`: Output format (default: text) |
| 71 | + |
| 72 | +### Processing Options |
| 73 | + |
| 74 | +- `--stream`: Use memory-efficient streaming mode for large files |
| 75 | +- `--sample=<N>`: Process every Nth record (default: 1, process all records) |
| 76 | +- `--max=<N>`: Maximum number of records to process (default: 0, no limit) |
| 77 | + |
| 78 | +### Time Filtering Options |
| 79 | + |
| 80 | +- `--start=<time>`: Start time for filtering (format: YYYY-MM-DD[THH:MM:SS]) |
| 81 | +- `--end=<time>`: End time for filtering (format: YYYY-MM-DD[THH:MM:SS]) |
| 82 | +- `--window=<duration>`: Time window to process (e.g., 1h, 30m, 24h) |
| 83 | + |
| 84 | +### Data Filtering Options |
| 85 | + |
| 86 | +- `--min-temp=<value>`: Minimum temperature threshold in millicelsius |
| 87 | +- `--volt-min=<value>`: Minimum voltage threshold in microvolts |
| 88 | +- `--volt-max=<value>`: Maximum voltage threshold in microvolts |
| 89 | +- `--curr-min=<value>`: Minimum current threshold in nanoamperes |
| 90 | +- `--curr-max=<value>`: Maximum current threshold in nanoamperes |
| 91 | + |
| 92 | +### Metric Extraction |
| 93 | + |
| 94 | +- `--metric=<name>`: Extract a specific metric (see below) |
| 95 | + |
| 96 | +## Available Metrics |
| 97 | + |
| 98 | +- `total_energy`: Total energy consumption in joules |
| 99 | +- `average_power`: Average power in watts |
| 100 | +- `peak_power`: Peak power in watts |
| 101 | +- `temperature`: Temperature statistics |
| 102 | +- `energy_by_hour`: Energy consumption by hour |
| 103 | +- `voltage_stats`: Voltage statistics |
| 104 | +- `current_stats`: Current statistics |
| 105 | +- `battery_discharge`: Battery discharge statistics |
| 106 | +- `solar_contribution`: Solar panel contribution |
| 107 | + |
| 108 | +## Examples |
| 109 | + |
| 110 | +### Basic Processing |
| 111 | + |
| 112 | +Process a CSV file and display all metrics: |
| 113 | + |
| 114 | +```bash |
| 115 | +./enemeter-data-processing --input=data/data.csv |
| 116 | +``` |
| 117 | + |
| 118 | +### Memory-Efficient Processing for Large Files |
| 119 | + |
| 120 | +Use streaming mode with sampling for very large files: |
| 121 | + |
| 122 | +```bash |
| 123 | +./enemeter-data-processing --input=big-data.csv --stream --sample=10 |
| 124 | +``` |
| 125 | + |
| 126 | +This processes only every 10th record, reducing memory requirements. |
| 127 | + |
| 128 | +### Filtering by Time |
| 129 | + |
| 130 | +Process data from a specific time range: |
| 131 | + |
| 132 | +```bash |
| 133 | +./enemeter-data-processing --input=data.csv --start="2025-04-01" --end="2025-04-02" |
| 134 | +``` |
| 135 | + |
| 136 | +Process the last 24 hours of data: |
| 137 | + |
| 138 | +```bash |
| 139 | +./enemeter-data-processing --input=data.csv --window=24h |
| 140 | +``` |
| 141 | + |
| 142 | +### Extracting Specific Metrics |
| 143 | + |
| 144 | +Get only temperature statistics in JSON format: |
| 145 | + |
| 146 | +```bash |
| 147 | +./enemeter-data-processing --input=data.csv --metric=temperature --format=json |
| 148 | +``` |
| 149 | + |
| 150 | +Extract hourly energy consumption in CSV format: |
| 151 | + |
| 152 | +```bash |
| 153 | +./enemeter-data-processing --input=data.csv --metric=energy_by_hour --format=csv |
| 154 | +``` |
| 155 | + |
| 156 | +### Filtering by Data Values |
| 157 | + |
| 158 | +Process only records with voltage between specified values: |
| 159 | + |
| 160 | +```bash |
| 161 | +./enemeter-data-processing --input=data.csv --volt-min=3500000 --volt-max=4200000 |
| 162 | +``` |
| 163 | + |
| 164 | +Process only records where temperature is above a certain threshold: |
| 165 | + |
| 166 | +```bash |
| 167 | +./enemeter-data-processing --input=data.csv --min-temp=25000 |
| 168 | +``` |
| 169 | + |
| 170 | +## Output Examples |
| 171 | + |
| 172 | +### Text Output (Default) |
| 173 | + |
| 174 | +``` |
| 175 | +========== ENEMETER DATA PROCESSING REPORT ========== |
| 176 | +Input File: data.csv |
| 177 | +Date: 2025-04-09 10:15:32 |
| 178 | +Data Points: 1253 |
| 179 | +Time Range: 2025-04-08 08:30:15 to 2025-04-09 08:30:10 |
| 180 | +
|
| 181 | +ENERGY METRICS |
| 182 | +------------- |
| 183 | +Total Energy Consumed: 156.4578 joules |
| 184 | +Average Power: 0.0548 watts |
| 185 | +Peak Power: 0.1245 watts |
| 186 | +Estimated Energy per Day: 157.9825 joules |
| 187 | +Measurement Duration: 86395.00 seconds |
| 188 | +
|
| 189 | +TEMPERATURE STATISTICS |
| 190 | +--------------------- |
| 191 | +Minimum Temperature: 22.45 °C |
| 192 | +Maximum Temperature: 28.95 °C |
| 193 | +Average Temperature: 24.75 °C |
| 194 | +
|
| 195 | +... additional sections ... |
| 196 | +``` |
| 197 | + |
| 198 | +### JSON Output |
| 199 | + |
| 200 | +```json |
| 201 | +{ |
| 202 | + "TotalJoules": 156.4578, |
| 203 | + "AveragePowerWatts": 0.0548, |
| 204 | + "PeakPowerWatts": 0.1245, |
| 205 | + "JoulesPerDay": 157.9825, |
| 206 | + "DurationSeconds": 86395.0, |
| 207 | + "TemperatureStats": { |
| 208 | + "MinTempCelsius": 22.45, |
| 209 | + "MaxTempCelsius": 28.95, |
| 210 | + "AvgTempCelsius": 24.75 |
| 211 | + }, |
| 212 | + ... |
| 213 | +} |
| 214 | +``` |
| 215 | + |
| 216 | +### CSV Output |
| 217 | + |
| 218 | +``` |
| 219 | +Metric,Value |
| 220 | +TotalJoules,156.457800 |
| 221 | +AveragePowerWatts,0.054800 |
| 222 | +PeakPowerWatts,0.124500 |
| 223 | +JoulesPerDay,157.982500 |
| 224 | +DurationSeconds,86395.00 |
| 225 | +... |
| 226 | +``` |
| 227 | + |
| 228 | +## Contributing |
| 229 | + |
| 230 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 231 | + |
| 232 | +## License |
| 233 | + |
| 234 | +This project is licensed under the MIT License - see the LICENSE file for details. |
0 commit comments