Add sender queue display and batch timing
This commit is contained in:
@@ -183,6 +183,8 @@ bool meterBatchToJson(const MeterData *samples, size_t count, uint16_t batch_id,
|
||||
doc["sender"] = sender_label;
|
||||
doc["batch_id"] = batch_id;
|
||||
doc["t0"] = samples[0].ts_utc;
|
||||
doc["t_first"] = samples[0].ts_utc;
|
||||
doc["t_last"] = samples[count - 1].ts_utc;
|
||||
uint32_t dt_s = METER_SAMPLE_INTERVAL_MS / 1000;
|
||||
doc["dt_s"] = dt_s > 0 ? dt_s : 1;
|
||||
doc["n"] = static_cast<uint32_t>(count);
|
||||
@@ -247,6 +249,8 @@ bool jsonToMeterBatch(const String &json, MeterData *out_samples, size_t max_cou
|
||||
}
|
||||
|
||||
uint32_t t0 = doc["t0"] | 0;
|
||||
uint32_t t_first = doc["t_first"] | t0;
|
||||
uint32_t t_last = doc["t_last"] | t_first;
|
||||
uint32_t dt_s = doc["dt_s"] | 1;
|
||||
JsonArray energy = doc["energy_wh"].as<JsonArray>();
|
||||
JsonArray p_w = doc["p_w"].as<JsonArray>();
|
||||
@@ -268,7 +272,13 @@ bool jsonToMeterBatch(const String &json, MeterData *out_samples, size_t max_cou
|
||||
snprintf(data.device_id, sizeof(data.device_id), "dd3-0000");
|
||||
}
|
||||
|
||||
data.ts_utc = t0 + static_cast<uint32_t>(idx) * dt_s;
|
||||
if (count > 1 && t_last >= t_first) {
|
||||
uint32_t span = t_last - t_first;
|
||||
uint32_t step = span / static_cast<uint32_t>(count - 1);
|
||||
data.ts_utc = t_first + static_cast<uint32_t>(idx) * step;
|
||||
} else {
|
||||
data.ts_utc = t0 + static_cast<uint32_t>(idx) * dt_s;
|
||||
}
|
||||
data.energy_total_kwh = static_cast<float>((energy[idx] | 0)) / 1000.0f;
|
||||
data.total_power_w = static_cast<float>(p_w[idx] | 0);
|
||||
data.phase_power_w[0] = static_cast<float>(p1_w[idx] | 0);
|
||||
|
||||
Reference in New Issue
Block a user