parser

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2023 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatteryState

type BatteryState int

BatteryState indicates the ISS battery status.

const (
	// BatteryNominal means ISS battery does not require replacement
	BatteryNominal BatteryState = 0
	// BatteryWarning means ISS battery requires replacement
	BatteryWarning BatteryState = 1
)

type BroadcastResponse

type BroadcastResponse struct {
	ConnInfo *ConnInfo `json:"data"`  // ConnInfo contains the UDP broadcast parameters
	Error    *Error    `json:"error"` // Error is a general error message
}

BroadcastResponse is for parsing the response of enabling UDP broadcasts.

func ParseBroadcastResponse

func ParseBroadcastResponse(payload []byte) (*BroadcastResponse, error)

ParseBroadcastResponse parses the response after requesting UDP weather broadcasts. It returns an error if the payload format is not valid.

type ConditionsHTTP

type ConditionsHTTP struct {
	Data  *WeatherHTTP `json:"data"`  // Data is weather conditions from HTTP
	Error *Error       `json:"error"` // Error is a general error message
}

ConditionsHTTP is for parsing weather conditions retrieved over HTTP.

func ParseHTTP

func ParseHTTP(data []byte) (*ConditionsHTTP, error)

ParseHTTP parses weather conditions retrieved over HTTP. It returns an error if the payload format is not valid.

type ConditionsUDP

type ConditionsUDP struct {
	DeviceID   string     `json:"did"`        // DeviceID is unique device ID
	Timestamp  *Time      `json:"ts"`         // Timestamp is device timestamp (epoch seconds)
	Conditions []EntryUDP `json:"conditions"` // Conditions is a list of conditions
}

ConditionsUDP is for parsing weather conditions received over UDP.

func ParseUDP

func ParseUDP(payload []byte) (*ConditionsUDP, error)

ParseUDP parses weather conditions received over UDP. It returns an error if the payload format is not valid.

type ConnInfo

type ConnInfo struct {
	Port     int `json:"broadcast_port"` // Port is the UDP port of weather broadcasts
	Duration int `json:"duration"`       // Duration is how long UDP broadcast is enabled for
}

ConnInfo are the UDP broadcast parameters.

type EntryHTTP

type EntryHTTP struct {
	LogicalSensorID   *int        `json:"lsid"`                // LogicalSensorID is logical sensor ID
	DataStructureType *RecordType `json:"data_structure_type"` // DataStructureType indicates data structure
	Values            interface{} // Values are the weather condition values (generated)
}

EntryHTTP is a union type for containing multiple types of weather conditions.

func (*EntryHTTP) UnmarshalJSON

func (e *EntryHTTP) UnmarshalJSON(payload []byte) error

UnmarshalJSON unmarshals the weather condition entry retrieved over HTTP. It returns an error if the payload format is not valid.

type EntryUDP

type EntryUDP struct {
	LogicalSensorID        *int        `json:"lsid"`                             // LogicalSensorID is logical sensor ID
	DataStructureType      *RecordType `json:"data_structure_type"`              // DataStructureType indicates data structure
	TransmitterID          *int        `json:"txid"`                             // TransmitterID is ID of transmitter
	WindSpeedLast          *float64    `json:"wind_speed_last"`                  // WindSpeedLast is most recent wind speed (mph)
	WindDirLast            *float64    `json:"wind_dir_last"`                    // WindDirLast is most recent wind direction (°)
	RainSize               *float64    `json:"rain_size"`                        // RainSize is size of rain collector (1: 0.01", 2: 0.2mm)
	RainRateLast           *float64    `json:"rain_rate_last"`                   // RainRateLast is most recent rain rate (count/hour)
	RainLast15Min          *float64    `json:"rain_15_min"`                      // RainLast15Min is rain count over last 15 minutes (count)
	RainLast60Min          *float64    `json:"rain_60_min"`                      // RainLast60Min is rain count over last 60 minutes (count)
	RainLast24Hour         *float64    `json:"rain_24_hr"`                       // RainLast24Hour is rain count over last 24 hours (count)
	RainStorm              *float64    `json:"rain_storm"`                       // RainStorm is rain since last 24 hour break in rain (count)
	RainStormStartAt       *Time       `json:"rain_storm_start_at"`              // RainStormStartAt is time of rainstorm start
	RainfallDaily          *float64    `json:"rainfall_daily"`                   // RainfallDaily is total rain since midnight (count)
	RainfallMonthly        *float64    `json:"rainfall_monthly"`                 // RainfallMonthly is total rain since first of month (count)
	RainfallYear           *float64    `json:"rainfall_year"`                    // RainfallYear is total rain since first of year (count)
	WindSpeedHighLast10Min *float64    `json:"wind_speed_hi_last_10_min"`        // WindSpeedHighLast10Min is max gust over last 10 minutes (mph)
	WindDirAtHighLast10Min *float64    `json:"wind_dir_at_hi_speed_last_10_min"` // WindDirAtHighLast10Min is max gust direction over last 10 minutes (°)
}

EntryUDP is for parsing UDP weather data.

type Error

type Error struct {
	Code    int    `json:"code"`    // Code is the error code
	Message string `json:"message"` // Message is an error message
}

Error is a generic error message provided by WLL unit.

type RecordType

type RecordType int

RecordType indicates the weather condition type returned from HTTP.

const (
	// RecordISS is weather conditions from integrated sensor suite
	RecordISS RecordType = 1
	// RecordLSSBarometer is weather conditions from LSS barometer
	RecordLSSBarometer RecordType = 3
	// RecordLSSTempRh is weather condition from LSS temperature + humidity
	RecordLSSTempRh RecordType = 4
)

type SignalState

type SignalState int

SignalState indicates the WLL receiver status.

const (
	// SignalSynced means WLL unit is locked onto ISS signal
	SignalSynced SignalState = 0
	// SignalRescan means WLL unit is scanning for ISS signal
	SignalRescan SignalState = 1
	// SignalLost means WLL unit failed to locate ISS signal
	SignalLost SignalState = 2
)

type Time

type Time time.Time

Time is an alias for parsing epoch timestamps.

func (Time) Time

func (t Time) Time() time.Time

Time returns the underlining time.Time instance.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(payload []byte) error

UnmarshalJSON is to unmarshal epoch timestamp into time.Time. It returns an error if the provided timestamp is invalid.

type UpdateMethod

type UpdateMethod string

UpdateMethod indicates how the Report state is updated

const (
	// UpdateHTTP is updating Report state with data retrieved from HTTP
	UpdateHTTP UpdateMethod = "http"
	// UpdateUDP is updating Report state with data received from UDP
	UpdateUDP UpdateMethod = "udp"
	// UpdateJSON is updating Report state with a JSON payload
	UpdateJSON UpdateMethod = "json"
)

type WeatherHTTP

type WeatherHTTP struct {
	DeviceID   string      `json:"did"`        // DeviceID is unique device ID
	Timestamp  *Time       `json:"ts"`         // Timestamp is device timestamp (epoch seconds)
	Conditions []EntryHTTP `json:"conditions"` // Conditions is a list of weather conditions
}

WeatherHTTP is for parsing HTTP weather data.

type WeatherISS

type WeatherISS struct {
	TransmitterID *int `json:"txid"` // TransmitterID is ID of transmitter

	Temperature *float64 `json:"temp"`       // Temperature (°F)
	Humidity    *float64 `json:"hum"`        // Humidity (%RH)
	Dewpoint    *float64 `json:"dew_point"`  // Dewpoint (°F)
	Wetbulb     *float64 `json:"wet_bulb"`   // Wetbulb (°F)
	HeatIndex   *float64 `json:"heat_index"` // HeatIndex (°F)
	WindChill   *float64 `json:"wind_chill"` // WindChill (°F)
	THWIndex    *float64 `json:"thw_index"`  // THWIndex is "feels like" (°F)
	THSWIndex   *float64 `json:"thsw_index"` // THWSIndex is "feels like" including solar (°F)

	WindSpeedLast          *float64 `json:"wind_speed_last"`                  // WindSpeedLast is most recent wind speed (mph)
	WindDirLast            *float64 `json:"wind_dir_last"`                    // WindDirLast is most recent wind direction (°)
	WindSpeedAvgLast1Min   *float64 `json:"wind_speed_avg_last_1_min"`        // WindSpeedAvgLast1Min is average wind over last minute (mph)
	WindDirAvgLast1Min     *float64 `json:"wind_dir_scalar_avg_last_1_min"`   // WindDirAvgLast1Min is average wind direction over last minute (°)
	WindSpeedAvgLast2Min   *float64 `json:"wind_speed_avg_last_2_min"`        // WindSpeedAvgLast2Min is average wind over last 2 minutes (mph)
	WindDirAvgLast2Min     *float64 `json:"wind_dir_scalar_avg_last_2_min"`   // WindDirAvgLast2Min is average wind direction over last 2 minutes (°)
	WindSpeedHighLast2Min  *float64 `json:"wind_speed_hi_last_2_min"`         // WindSpeedHighLast2Min is max gust over last 2 minutes (mph)
	WindDirAtHighLast2Min  *float64 `json:"wind_dir_at_hi_speed_last_2_min"`  // WindDirAtHighLast2Min is max gust direction over last 2 minutes (°)
	WindSpeedAvgLast10Min  *float64 `json:"wind_speed_avg_last_10_min"`       // WindSpeedAvgLast10Min is average wind over last 10 minutes (mph)
	WindDirAvgLast10Min    *float64 `json:"wind_dir_scalar_avg_last_10_min"`  // WindDirAvgLast10Min is average wind dir over last 10 minutes (°)
	WindSpeedHighLast10Min *float64 `json:"wind_speed_hi_last_10_min"`        // WindSpeedHighLast10Min is max gust over last 10 minutes (mph)
	WindDirAtHighLast10Min *float64 `json:"wind_dir_at_hi_speed_last_10_min"` // WindDirAtHighLast10Min is max gust direction over last 10 minutes (°)

	RainSize              *float64 `json:"rain_size"`                // RainSize is size of rain collector (1: 0.01", 2: 0.2mm)
	RainRateLast          *float64 `json:"rain_rate_last"`           // RainRateLast is most recent rain rate (count/hour)
	RainRateHigh          *float64 `json:"rain_rate_hi"`             // RainRateHigh is highest rain rate over last minute (count/hour)
	RainLast15Min         *float64 `json:"rainfall_last_15_min"`     // RainLast15Min is rain count in last 15 minutes (count)
	RainRateHighLast15Min *float64 `json:"rain_rate_hi_last_15_min"` // RainRateHighLast15Min is highest rain count rate over last 15 minutes (count/hour)
	RainLast60Min         *float64 `json:"rainfall_last_60_min"`     // RainLast60Min is rain count over last 60 minutes (count)
	RainLast24Hour        *float64 `json:"rainfall_last_24_hr"`      // RainLast24Hour is rain count over last 24 hours (count)
	RainStorm             *float64 `json:"rain_storm"`               // RainStorm is rain since last 24 hour break in rain (count)
	RainStormStartAt      *Time    `json:"rain_storm_start_at"`      // RainStormStartAt is time of rain storm start

	SolarRad *float64 `json:"solar_rad"` // SolarRad is solar radiation (W/m²)
	UVIndex  *float64 `json:"uv_index"`  // UVIndex is solar UV index

	RXState          *SignalState  `json:"rx_state"`           // RXState is ISS receiver status
	TransBatteryFlag *BatteryState `json:"trans_battery_flag"` // TransBatteryFlag is ISS battery status

	RainfallDaily        *float64 `json:"rainfall_daily"`           // RainfallDaily is total rain since midnight (count)
	RainfallMonthly      *float64 `json:"rainfall_monthly"`         // RainfallMonthly is total rain since first of month (count)
	RainfallYear         *float64 `json:"rainfall_year"`            // RainfallYear is total rain since first of year (count)
	RainStormLast        *float64 `json:"rain_storm_last"`          // RainStormLast is rain since last 24 hour break in rain (count)
	RainStormLastStartAt *Time    `json:"rain_storm_last_start_at"` // RainStormLastStartAt is time of last rain storm start
	RainStormLastEndAt   *Time    `json:"rain_storm_last_end_at"`   // rainStormLastEndAt is time of last rain storm end
}

WeatherISS is weather conditions from ISS.

type WeatherLSSBarometer

type WeatherLSSBarometer struct {
	BarometerSeaLevel *float64 `json:"bar_sea_level"` // BarometerSeaLevel is barometer reading with elevation adjustment (inches)
	BarometerTrend    *float64 `json:"bar_trend"`     // BarometerTrend is 3 hour barometric trend (inches)
	BarometerAbsolute *float64 `json:"bar_absolute"`  // BarometerAbsolute is barometer reading at current elevation (inches)
}

WeatherLSSBarometer is weather conditions from LSS barometer sensor.

type WeatherLSSTempRh

type WeatherLSSTempRh struct {
	TemperatureIndoor *float64 `json:"temp_in"`       // TemperatureIndoor is indoor temp (°F)
	HumidityIndoor    *float64 `json:"hum_in"`        // HumidityIndoor is indoor humidity (%)
	DewPointIndoor    *float64 `json:"dew_point_in"`  // DewPointIndoor is indoor dewpoint (°F)
	HeatIndexIndoor   *float64 `json:"heat_index_in"` // HeatIndexIndoor is indoor heat index (°F)
}

WeatherLSSTempRh is weather conditions from LSS temperature and humidity sensors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL