Skip to content
SweetnsourcandyPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

BMTree EV Battery Monitoring System (Terminal / CLI Edition)

A high-performance C-based terminal application demonstrating multidimensional sensor indexing, thermal runaway mitigation, and low-latency data structures for Electric Vehicle (EV) battery monitoring.

All HTML/CSS/JavaScript web code and HTTP sockets have been replaced with a native, pure C interactive command-line interface (CLI). Key Data Structures & Algorithms

BMTree (Multidimensional Space-Filling Morton / Z-Order Index)
    Quantization: Quantizes continuous Temperature (-40°C to 150°C into 10 bits), Voltage (0V to 10V into 10 bits), and Zone (1 to 4 into 2 bits).
    Morton Key: Interleaves dimension bits into a 30-bit Morton/Z-order space-filling curve key.
    Compressed Prefix Tree: Builds a bit-prefix binary tree with ASCII hierarchy visualization and spatial locality traversal.

Binary Max-Heap (Thermal Runaway Priority Queue)
    Maintained in C with heap property heap[parent].temp >= heap[child].temp.
    O ( 1 ) Peak Hotspot Extraction: Immediate inspection of the hottest battery cell at the root [0].
    Top-K Priority Queue: Sift-down extraction (Heapsort) of critical overheating cells.
    Memory Array Layout: Complete inspection of parent-child relationships [0..N-1].

Circular Ring Buffer (FIFO Queue)
    Fixed-capacity circular queue (12 samples) with head and tail pointers.
    Tracks rolling thermal velocity ($dT/dt = \text{Temp}t - \text{Temp}{t-1}$) in O ( 1 ) time without memory reallocation.
    Triggers dynamic rate-of-rise alarms before static temperature thresholds are breached.

Hash Table with Separate Chaining
    In-memory hash table using the djb2 hash algorithm across 64 buckets.
    Dynamically allocated linked lists for collision resolution.
    Provides O ( 1 ) instant sensor lookup by Sensor ID (case-insensitive).
    Real-time diagnostic metrics: occupied buckets, collision counts, and load factor ( α ).

Project Structure

bmtree_final/ ├── bmtree.c # Pure C interactive CLI source code ├── bmtree.exe # Compiled Windows executable ├── run.bat # Windows build & launch script └── README.md # Documentation

How to Compile and Run On Windows (using run.bat or Command Prompt / PowerShell)

Double-click run.bat or run:

gcc bmtree.c -o bmtree.exe -Wall -Wextra bmtree.exe

On Linux / macOS

gcc bmtree.c -o bmtree -Wall -Wextra ./bmtree

Interactive Menu Commands Option Description [1] Battery Overview: Pack summary metrics (average temp, cell voltage, peak hotspot) and color-coded sensor table. [2] BMTree ASCII Visualizer: Displays the compressed bit-prefix tree with branch split bits, prefixes, and leaf records. [3] Morton Traversal: Traverses sensors sorted along the 3D space-filling Z-curve. [4] Hash Table Search: Performs instant O ( 1 ) sensor record search by ID (e.g. S-103). [5] Hash Diagnostics: Inspects bucket chains, collision statistics, and load factor. [6] Max-Heap Priority Queue: Views peak hotspot, Top-K severity ranking, and array layout. [7] Circular Ring Buffer: Views rolling thermal velocity ( d T / d t ), rate-of-rise trends, and alarms. [8] Insert Sensor Reading: Interactively inputs a new sensor with full validation and instant index rebuild. [9] Simulate Hotspot: Injects a critical 52.0°C rogue cell to demonstrate immediate heap escalation and velocity alarms. [R] Reset Dataset: Restores default sample sensor readings. [0] Exit: Frees allocated memory and exits cleanly.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages