The battery sizing team has developed a body cam usage procedure and tested it on a camera hooked to a power supply. Sensor data gives a list of time intervals (seconds) and the average current draw in milli-amps over each interval. Describe an object model that lets you find the total energy in milli-amp hours from time 0 to T. The list of intervals can be arbitrarily long and you may want to repeatedly query the power used at different times. Example: 0-300 125mA, 300-400 50mA, 400-550 500mA, 550-1000 20mA; total from T=0 to T=700s is 33.47mAh.
Asked in the CoderPad coding stage. Reported follow-ups: support repeated queries at different T efficiently.
target_seconds, total_energy_mah.target_seconds ascending, then query_id ascending.| Column | Type | Description |
|---|---|---|
| interval_idPK | INT | Unique usage interval identifier |
| start_seconds | INT | Inclusive interval start measured from time 0 |
| end_seconds | INT | Exclusive interval end measured from time 0 |
| average_current_ma | NUMERIC(10,2) | Average current draw during the interval in milliamps |
| Column | Type | Description |
|---|---|---|
| query_idPK | INT | Unique requested-energy query identifier |
| target_seconds | INT | Time through which energy should be calculated |
| query_label | VARCHAR(50) | Optional label for the requested time |