Added documentation to Payload struct.
All checks were successful
Build Docker image / build (push) Successful in 1m15s

This commit is contained in:
Pieter Hollander 2024-02-18 15:10:37 +01:00
parent 66ad959ada
commit 2844bd89d1
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

48
main.go
View file

@ -13,29 +13,33 @@ import (
_ "github.com/lib/pq" _ "github.com/lib/pq"
) )
// Payload struct
// Dt1, Dt2, Rt1, Rt2 and G are meter readings
// By making them pointers to int, they can be set to 'nil' when the reading has not changed.
// This way, they are logged as NULL in the database when no change has happened, saving storage capacity.
type Payload struct { type Payload struct {
T string `json:"t"` T string `json:"t"` // Timestamp
Dt1 *int `json:"dt1"` Dt1 *int `json:"dt1"` // Delivered / imported meter reading tariff 1 (kWh)
Dt2 *int `json:"dt2"` Dt2 *int `json:"dt2"` // Delivered / imported tariff 2 (kWh)
Rt1 *int `json:"rt1"` Rt1 *int `json:"rt1"` // Returned / exported tariff 1 (kWh)
Rt2 *int `json:"rt2"` Rt2 *int `json:"rt2"` // Returned / exported tariff 2 (kWh)
D int `json:"d"` D int `json:"d"` // Delivering / importing (W)
R int `json:"r"` R int `json:"r"` // Returning / exporting (W)
F int `json:"f"` F int `json:"f"` // Failure (counter)
Fl int `json:"fl"` Fl int `json:"fl"` // Failure long duration (counter)
G *int `json:"g"` G *int `json:"g"` // Gas meter reading (l)
V1 int `json:"v1"` V1 int `json:"v1"` // Voltage L1 (V)
V2 int `json:"v2"` V2 int `json:"v2"` // Voltage L2 (V)
V3 int `json:"v3"` V3 int `json:"v3"` // Voltage L3 (V)
C1 int `json:"c1"` C1 int `json:"c1"` // Current L1 (A)
C2 int `json:"c2"` C2 int `json:"c2"` // Current L2 (A)
C3 int `json:"c3"` C3 int `json:"c3"` // Current L3 (A)
D1 int `json:"d1"` D1 int `json:"d1"` // Delivering / importing L1 (W)
D2 int `json:"d2"` D2 int `json:"d2"` // Delivering / importing L2 (W)
D3 int `json:"d3"` D3 int `json:"d3"` // Delivering / importing L3 (W)
R1 int `json:"r1"` R1 int `json:"r1"` // Returning / exporting L1 (W)
R2 int `json:"r2"` R2 int `json:"r2"` // Returning / exporting L2 (W)
R3 int `json:"r3"` R3 int `json:"r3"` // Returning / exporting L3 (W)
} }
var db *sql.DB var db *sql.DB