| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- from cell import Cell
- from config_loader import ConfigLoader
- class Subsegment:
- def __init__(self, segment_id, subsegment_id):
- self.segment_id = segment_id
- self.subsegment_id = subsegment_id
- config = ConfigLoader()
- cell_ids = config.get_cell_ids_for_subsegment(segment_id, subsegment_id)
-
- if not cell_ids:
- raise ValueError(f"No cell IDs configured for subsegment {subsegment_id}")
-
- # Create cells with explicitly configured IDs
- self.cells = [Cell(cell_id) for cell_id in cell_ids]
- def measure_voltages(self):
- return [cell.measure_voltage() for cell in self.cells]
- def measure_currents(self):
- return [cell.measure_current() for cell in self.cells]
- def measure_temperatures(self):
- return [cell.measure_temperature() for cell in self.cells]
- # def get_power(self):
- # return [cell.measure_voltage() * cell.measure_current() for cell in self.cells]
- # def calculate_saved_power(self):
- # return sum(self.get_power())
- def get_subset_voltage(self):
- voltages = self.measure_voltages()
- return sum(voltages) / len(voltages) if voltages else 0
- def get_subset_current(self):
- currents = self.measure_currents()
- return sum(currents)
- def disconnect(self):
- # Logic to disconnect the subsegment
- pass
- def connect(self):
- # Logic to connect the subsegment
- pass
- def get_total_estimated_capacity_mah(self):
- """For cells in parallel, total estimated capacity is sum of individual estimated capacities"""
- return sum(cell.estimated_capacity_mah for cell in self.cells)
|