From 7220d3e7501ce92a8ee223c6e998f8353ae4ade6 Mon Sep 17 00:00:00 2001 From: ms Date: Sun, 15 Feb 2026 22:22:01 +0100 Subject: [PATCH] zmiana w modb_orno3.c i dodanie skryptu usuniecie_pola_highfluct.sh --- modb_orno3.c | 30 +++++++++++++----------------- usuniecie_pola_highfluct.sh | 1 + 2 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 usuniecie_pola_highfluct.sh diff --git a/modb_orno3.c b/modb_orno3.c index 47f105a..36d9242 100644 --- a/modb_orno3.c +++ b/modb_orno3.c @@ -348,25 +348,21 @@ int influx_send_orno_batch(s_voltage *v, int v_ok, s_current *i, int i_ok, char batch[1024]; int offset = 0; - if (v_ok) { - offset += snprintf(batch + offset, sizeof(batch) - offset, - "orno,device=orno,pomiar=voltage L1=%.2f,L2=%.2f,L3=%.2f\n", v->U1, v->U2, v->U3); - } - if (i_ok) { - offset += snprintf(batch + offset, sizeof(batch) - offset, - "orno,device=orno,pomiar=current L1=%.2f,L2=%.2f,L3=%.2f\n", i->I1, i->I2, i->I3); - } - if (p_ok) { - offset += snprintf(batch + offset, sizeof(batch) - offset, - "orno,device=orno,pomiar=power total=%.3f,L1=%.3f,L2=%.3f,L3=%.3f\n", p->P_Tot, p->P1, p->P2, p->P3); - } - if (w_ok) { - offset += snprintf(batch + offset, sizeof(batch) - offset, - "orno,device=orno,pomiar=energy total=%.3f,L1=%.3f,L2=%.3f,L3=%.3f\n", w->W_Tot, w->W1, w->W2, w->W3); - } + /* Line protocol format: measurement,tag=value field=value ... */ + /* New format groups data by phase with U, I, P, W fields */ + offset += snprintf(batch + offset, sizeof(batch) - offset, + "energydb,device=orno,phase=L1 U=%.2f,I=%.2f,P=%.2f,W=%.2f\n" + "energydb,device=orno,phase=L2 U=%.2f,I=%.2f,P=%.2f,W=%.2f\n" + "energydb,device=orno,phase=L3 U=%.2f,I=%.2f,P=%.2f,W=%.2f\n" + "energydb,device=orno,phase=total P=%.2f,W=%.2f\n", + v->U1, i->I1, p->P1, w->W1, + v->U2, i->I2, p->P2, w->W2, + v->U3, i->I3, p->P3, w->W3, + p->P_Tot, w->W_Tot); + if (f_ok) { offset += snprintf(batch + offset, sizeof(batch) - offset, - "orno,device=orno,pomiar=frequency frequency=%.4f\n", f->Freq); + "energydb,device=orno,frequency=Hz value=%.4f\n", f->Freq); } if (offset == 0) return 0; diff --git a/usuniecie_pola_highfluct.sh b/usuniecie_pola_highfluct.sh new file mode 100644 index 0000000..d1deb6e --- /dev/null +++ b/usuniecie_pola_highfluct.sh @@ -0,0 +1 @@ +influx delete --host "http://localhost:5086" --org "sic" --bucket "energydb" --token "BCIZ6kcCAVgpcwSfU0PBS7m0Zb6an93kuOtizbEtlXub-uaoYp4dmIQBQYaJCv8_KE4QYYZ08jxtpaZ3TUWP-Q==" --start 1970-01-01T00:00:00Z --stop $(date -u +"%Y-%m-%dT%H:%M:%SZ") --predicate '_fields="highfluct"'