57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type Reading struct {
|
|
Ratio decimal.Decimal `json:"ratio"`
|
|
Overall decimal.Decimal `json:"overall"`
|
|
Critical decimal.Decimal `json:"critical"`
|
|
Peak decimal.Decimal `json:"peak"`
|
|
Flat decimal.Decimal `json:"flat"`
|
|
Valley decimal.Decimal `json:"valley"`
|
|
}
|
|
|
|
func NewPVReading(ratio, overall, critical, peak, flat, valley decimal.Decimal) *Reading {
|
|
return &Reading{
|
|
Ratio: ratio,
|
|
Overall: overall,
|
|
Critical: critical,
|
|
Peak: peak,
|
|
Flat: flat,
|
|
Valley: valley,
|
|
}
|
|
}
|
|
|
|
func NewUnitaryReading(ratio, overall decimal.Decimal) *Reading {
|
|
return &Reading{
|
|
Ratio: ratio,
|
|
Overall: overall,
|
|
Critical: decimal.Zero,
|
|
Peak: decimal.Zero,
|
|
Flat: overall,
|
|
Valley: decimal.Zero,
|
|
}
|
|
}
|
|
|
|
type MeterReading struct {
|
|
ReadAt time.Time `json:"readAt"`
|
|
Park string `json:"parkId" db:"park_id"`
|
|
Meter string `json:"meterId" db:"meter_id"`
|
|
MeterType int16 `json:"meterType"`
|
|
Ratio decimal.Decimal `json:"ratio"`
|
|
Overall decimal.Decimal `json:"overall"`
|
|
Critical decimal.Decimal `json:"critical"`
|
|
Peak decimal.Decimal `json:"peak"`
|
|
Flat decimal.Decimal `json:"flat"`
|
|
Valley decimal.Decimal `json:"valley"`
|
|
}
|
|
|
|
type DetailedMeterReading struct {
|
|
Detail MeterDetail `json:"detail"`
|
|
Reading MeterReading `json:"reading"`
|
|
}
|