105 lines
2.6 KiB
Go
105 lines
2.6 KiB
Go
package zaptec
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
type ChargersResponse struct {
|
|
Pages int
|
|
Data []Charger
|
|
}
|
|
|
|
type Charger struct {
|
|
OperatingMode int
|
|
IsOnline bool
|
|
Id string
|
|
MID string
|
|
DeviceId string
|
|
SerialNo string
|
|
Name string
|
|
CreatedOnDate string
|
|
CircuitId string
|
|
Active bool
|
|
CurrentUserRoles int
|
|
DeviceType int
|
|
InstallationName string
|
|
InstallationId string
|
|
AuthenticationType int
|
|
IsAuthorizationRequired bool
|
|
}
|
|
|
|
type StateResponse []Observation
|
|
|
|
func (s *StateResponse) ObservationByID(id ObservationID) *Observation {
|
|
if s == nil {
|
|
return nil
|
|
}
|
|
|
|
for _, o := range *s {
|
|
if o.StateId == id {
|
|
return &o
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type Observation struct {
|
|
ChargerId string
|
|
StateId ObservationID
|
|
Timestamp string
|
|
ValueAsString string
|
|
}
|
|
|
|
func (o *Observation) Bool() bool {
|
|
return o != nil && (o.ValueAsString == "true" || o.ValueAsString == "1")
|
|
}
|
|
|
|
func (o *Observation) Int() (int, error) {
|
|
if o == nil || o.ValueAsString == "" {
|
|
return 0, nil
|
|
}
|
|
|
|
return strconv.Atoi(o.ValueAsString)
|
|
}
|
|
|
|
func (o *Observation) Float64() (float64, error) {
|
|
if o == nil || o.ValueAsString == "" {
|
|
return 0, nil
|
|
}
|
|
|
|
return strconv.ParseFloat(o.ValueAsString, 64)
|
|
}
|
|
|
|
type Update struct {
|
|
MaxChargeCurrent *float64 `json:"maxChargeCurrent,omitempty"`
|
|
MaxChargePhases *int `json:"maxChargePhases,omitempty"`
|
|
MinChargeCurrent *float64 `json:"minChargeCurrent,omitempty"`
|
|
OfflineChargeCurrent *float64 `json:"offlineChargeCurrent,omitempty"`
|
|
OfflineChargePhase *int `json:"offlineChargePhase,omitempty"`
|
|
MeterValueInterval *int `json:"meterValueInterval,omitempty"`
|
|
}
|
|
|
|
type SessionPriority struct {
|
|
PrioritizedPhases *int `json:"prioritizedPhases,omitempty"`
|
|
}
|
|
|
|
type Installation struct {
|
|
Id string `json:"id"`
|
|
MaxCurrent float64 `json:"maxCurrent"`
|
|
}
|
|
|
|
type UpdateInstallation struct {
|
|
AvailableCurrentPhase1 *float64 `json:"availableCurrentPhase1,omitempty"`
|
|
AvailableCurrentPhase2 *float64 `json:"availableCurrentPhase2,omitempty"`
|
|
AvailableCurrentPhase3 *float64 `json:"availableCurrentPhase3,omitempty"`
|
|
}
|
|
|
|
type CapabilitiesResponse struct {
|
|
CommunicationModes []string `json:"communicationModes"`
|
|
DeviceType string `json:"deviceType"`
|
|
MeterCalibrated bool `json:"meterCalibrated"`
|
|
PhaseBalancing []string `json:"phaseBalancing"`
|
|
ProductVariant string `json:"productVariant"`
|
|
SchemaVersion string `json:"schemaVersion"`
|
|
}
|