File size: 2,805 Bytes
e38de99 |
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# Three-Phase DCRM Flask API - Quick Start Guide
## π Quick Start (3 Steps)
### Step 1: Start the Flask API
```bash
python dcrm_flask_api.py
```
**Expected output:**
```
* Running on http://0.0.0.0:5000
* Restarting with stat
* Debugger is active!
```
### Step 2: Open the Test Frontend
Double-click: `test_three_phase_frontend.html`
OR open in browser: `file:///c:/codes/dcrm/pranit/csv_kpi/combined/test_three_phase_frontend.html`
### Step 3: Upload and Test
1. Enter Breaker ID (default: `6926e63d4614721a79b7b24e`)
2. Enter Operator Name (default: `Test Engineer`)
3. Upload 3 CSV files:
- π΄ Red Phase (R): `df3_final (1).csv`
- π‘ Yellow Phase (Y): `df3_final (1).csv`
- π΅ Blue Phase (B): `df3_final (1).csv`
4. Click "Upload & Analyze All Phases"
5. Wait 90-180 seconds for processing
6. View results!
---
## π Alternative: Command Line Test
```bash
# Terminal 1: Start API
python dcrm_flask_api.py
# Terminal 2: Run automated test
python test_three_phase_flask.py
```
---
## π― What You'll See
### Overall Results:
- Overall Health Score (average of 3 phases)
- Breaker ID
- Operator Name
- Creation Timestamp
### Per-Phase Results:
- Red Phase (R): Health Score, CBHI, Findings
- Yellow Phase (Y): Health Score, CBHI, Findings
- Blue Phase (B): Health Score, CBHI, Findings
### Complete JSON:
- Full three-phase analysis
- Enhanced waveform with coil currents
- AI recommendations with performanceGains & riskMitigation
- All fields matching `sample.json` structure
---
## π API Endpoints
### Three-Phase Analysis
```
POST /api/circuit-breakers/{breaker_id}/tests/upload-three-phase
```
**Request:**
- `fileR`: CSV file for Red phase
- `fileY`: CSV file for Yellow phase
- `fileB`: CSV file for Blue phase
- `operator`: (optional) Operator name
**Response:** Combined three-phase JSON
### Health Check
```
GET /api/health
```
---
## π§ Configuration
### Change Port
Edit `dcrm_flask_api.py` line ~400:
```python
app.run(host="0.0.0.0", port=5000, debug=True)
```
### Change API URL in Frontend
Edit `test_three_phase_frontend.html` line ~300:
```javascript
const API_URL = 'http://localhost:5000';
```
---
## β
Features Implemented
β
Flask-based API (instead of FastAPI)
β
Three-phase processing (fileR, fileY, fileB)
β
Enhanced waveform (includes close_coil, trip_coil_1, trip_coil_2)
β
Updated AI recommendations (performanceGains, riskMitigation)
β
Combined JSON structure matching sample.json
β
Beautiful HTML frontend with 3-file upload
β
Automated test script
β
Complete documentation
---
## π You're All Set!
Everything is ready to use. Just start the API and open the HTML frontend!
|