Mapowanie rejestrów SUN2K do jednolitego formatu ORNO
This commit is contained in:
63
modb_orno3.c
63
modb_orno3.c
@@ -379,8 +379,64 @@ int influx_send_orno_batch(s_voltage *v, int v_ok, s_current *i, int i_ok,
|
||||
int influx_send_SUN2K(t_mb_reg *reg_to_send, char *_str_buf) {
|
||||
if (!_str_buf || strlen(_str_buf) == 0) return 0;
|
||||
char line[256];
|
||||
/* reg_id used as tag, value as field */
|
||||
snprintf(line, sizeof(line), "sun2k,device=sun2k %s=%s", reg_to_send->reg_id, _str_buf);
|
||||
char pomiar_tag[32] = "";
|
||||
char field_name[32] = "";
|
||||
|
||||
/* Mapowanie rejestrów SUN2K do jednolitego formatu ORNO */
|
||||
if (strcmp(reg_to_send->reg_id, "PV_P") == 0 ||
|
||||
strcmp(reg_to_send->reg_id, "P_active") == 0 ||
|
||||
strcmp(reg_to_send->reg_id, "P_peak") == 0) {
|
||||
/* Moc - mapujemy do pomiar=power, pole=total */
|
||||
strcpy(pomiar_tag, ",pomiar=power");
|
||||
strcpy(field_name, "total");
|
||||
}
|
||||
else if (strcmp(reg_to_send->reg_id, "P_reactive") == 0) {
|
||||
/* Moc bierna - osobny pomiar */
|
||||
strcpy(pomiar_tag, ",pomiar=reactive_power");
|
||||
strcpy(field_name, "total");
|
||||
}
|
||||
else if (strcmp(reg_to_send->reg_id, "Frequency") == 0) {
|
||||
/* Częstotliwość - mapujemy do pomiar=frequency, pole=frequency */
|
||||
strcpy(pomiar_tag, ",pomiar=frequency");
|
||||
strcpy(field_name, "frequency");
|
||||
}
|
||||
else if (strcmp(reg_to_send->reg_id, "Temp") == 0) {
|
||||
/* Temperatura */
|
||||
strcpy(pomiar_tag, ",pomiar=temperature");
|
||||
strcpy(field_name, "value");
|
||||
}
|
||||
else if (strcmp(reg_to_send->reg_id, "P_accum") == 0) {
|
||||
/* Energia zgromadzona */
|
||||
strcpy(pomiar_tag, ",pomiar=energy");
|
||||
strcpy(field_name, "total");
|
||||
}
|
||||
else if (strcmp(reg_to_send->reg_id, "P_daily") == 0) {
|
||||
/* Energia dzienna - osobny pomiar */
|
||||
strcpy(pomiar_tag, ",pomiar=daily_energy");
|
||||
strcpy(field_name, "total");
|
||||
}
|
||||
else if (strcmp(reg_to_send->reg_id, "State1") == 0 ||
|
||||
strcmp(reg_to_send->reg_id, "Alarm1") == 0 ||
|
||||
strcmp(reg_to_send->reg_id, "Status") == 0 ||
|
||||
strcmp(reg_to_send->reg_id, "Fault") == 0) {
|
||||
/* Statusy */
|
||||
strcpy(pomiar_tag, ",pomiar=status");
|
||||
strcpy(field_name, reg_to_send->reg_id);
|
||||
}
|
||||
else if (strcmp(reg_to_send->reg_id, "Start") == 0 ||
|
||||
strcmp(reg_to_send->reg_id, "Shutdown") == 0 ||
|
||||
strcmp(reg_to_send->reg_id, "Time") == 0) {
|
||||
/* Info/czas */
|
||||
strcpy(pomiar_tag, ",pomiar=info");
|
||||
strcpy(field_name, reg_to_send->reg_id);
|
||||
}
|
||||
else {
|
||||
/* Domyślnie - nazwa rejestru jako nazwa pola */
|
||||
strcpy(field_name, reg_to_send->reg_id);
|
||||
}
|
||||
|
||||
snprintf(line, sizeof(line), "sun2k,device=sun2k%s %s=%s",
|
||||
pomiar_tag, field_name, _str_buf);
|
||||
return influx_send_post(line);
|
||||
}
|
||||
|
||||
@@ -388,7 +444,8 @@ int influx_send_SUN2K_U_batch(float U_A, float U_B, float U_C, int valid) {
|
||||
if (DISABLE_INFLUX) return 0;
|
||||
if (!valid) return 0;
|
||||
char batch[256];
|
||||
snprintf(batch, sizeof(batch), "sun2k,device=sun2k,pomiar=voltage U_A=%.2f,U_B=%.2f,U_C=%.2f", U_A, U_B, U_C);
|
||||
/* Ujednolicone z ORNO - L1, L2, L3 zamiast U_A, U_B, U_C */
|
||||
snprintf(batch, sizeof(batch), "sun2k,device=sun2k,pomiar=voltage L1=%.2f,L2=%.2f,L3=%.2f", U_A, U_B, U_C);
|
||||
return influx_send_post(batch);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user