Documentation
¶
Index ¶
- Constants
- func Date(t time.Time) int64
- func Device() string
- func Hostname() string
- func JSON(v interface{}) string
- func Trend(entries Entries) string
- func Username() string
- type Battery
- type DeviceStatus
- type Entries
- func (e Entries) Len() int
- func (e Entries) Less(i, j int) bool
- func (e Entries) Print()
- func (e Entries) Reverse()
- func (e Entries) Save(file string) error
- func (e Entries) Sort()
- func (e Entries) Swap(i, j int)
- func (e Entries) TrimAfter(cutoff time.Time) Entries
- func (e Entries) Write(w io.Writer) error
- func (e Entries) X(i int) float64
- func (e Entries) Y(i int) float64
- type Entry
- type EntryTime
- type EntryTimes
- type Gap
- type Glucose
- type IOB
- type Insulin
- type Line
- type Openaps
- type Points
- type Profile
- type ProfileData
- type ProfileID
- type Pump
- type Schedule
- type Status
- type TimeValue
- type Treatment
- type TreatmentTime
- type Uploader
- type Voltage
- type Website
- func (w *Website) APISecret() (string, error)
- func (w Website) DownloadEntries(n int) (Entries, error)
- func (w Website) Gaps(since time.Time, gapDuration time.Duration) ([]Gap, error)
- func (w *Website) Get(api string, result interface{}) error
- func (w *Website) NoUpload() bool
- func (w *Website) Put(api string, data interface{}) error
- func (w *Website) SetNoUpload(flag bool)
- func (w *Website) SetVerbose(flag bool)
- func (w *Website) String() string
- func (w *Website) Upload(api string, data interface{}) error
- func (w *Website) Verbose() bool
- func (w Website) XDripEntries() (Entries, error)
- func (w Website) XDripTime() (time.Time, error)
Constants ¶
const ( SGVType = "sgv" MBGType = "mbg" CalType = "cal" )
Values for the Entry Type field.
const ( // DateStringLayout is a time format accepted by Nightscout. DateStringLayout = time.RFC3339 )
Variables ¶
This section is empty.
Functions ¶
func JSON ¶
func JSON(v interface{}) string
JSON marshals the given data in indented form and returns it as a string.
Types ¶
type Battery ¶
type Battery struct {
Voltage Voltage `json:"voltage"`
}
Battery represents the battery data in a Pump record.
type DeviceStatus ¶
type DeviceStatus struct {
CreatedAt time.Time `json:"created_at"`
Device string `json:"device"`
Openaps Openaps `json:"openaps,omitempty"`
Pump Pump `json:"pump,omitempty"`
Uploader Uploader `json:"uploader,omitempty"`
}
DeviceStatus represents data for the Nightscout devicestatus API.
type Entries ¶
type Entries []Entry
Entries represents a sequence of Entry values.
func MergeEntries ¶
MergeEntries merges entries that are already in reverse chronological order. Duplicates are removed.
func Missing ¶
Missing returns the Entry values that fall within the given gaps. Entries must be in reverse chronological order.
func ReadEntries ¶
ReadEntries reads entries in JSON fromat from an io.Reader.
func ReadEntriesFile ¶
ReadEntriesFile reads entries in JSON format from a file.
func (Entries) Sort ¶
func (e Entries) Sort()
Sort sorts the entries into reverse chronological order, in place.
func (Entries) TrimAfter ¶
TrimAfter returns the entries that are more recent than the specified time. The entries must be in reverse chronological order.
type Entry ¶
type Entry struct {
Type string `json:"type"`
Date int64 `json:"date"` // Unix time in milliseconds
DateString string `json:"dateString"`
Device string `json:"device,omitempty"`
SGV int `json:"sgv,omitempty"`
Direction string `json:"direction,omitempty"`
Filtered int `json:"filtered,omitempty"`
Unfiltered int `json:"unfiltered,omitempty"`
RSSI int `json:"rssi,omitempty"`
Noise int `json:"noise,omitempty"`
Slope float64 `json:"slope,omitempty"`
Intercept float64 `json:"intercept,omitempty"`
Scale float64 `json:"scale,omitempty"`
MBG int `json:"mbg,omitempty"`
}
Entry represents data for the Nightscout entries API.
type EntryTime ¶
type EntryTime struct {
Date int64 `json:"date"` // Unix time in milliseconds
}
EntryTime is used to unmarshal just the Date field of an Entry.
type EntryTimes ¶
type EntryTimes []EntryTime
EntryTimes represents a sequence of entry times.
func (EntryTimes) Len ¶
func (v EntryTimes) Len() int
func (EntryTimes) Less ¶
func (v EntryTimes) Less(i, j int) bool
func (EntryTimes) Swap ¶
func (v EntryTimes) Swap(i, j int)
type IOB ¶
type IOB struct {
IOB Insulin `json:"iob"`
}
IOB represents the insulin-on-board data in an Openaps record.
type Line ¶
Line represents the linear equation y = Slope*x + Intercept.
type Openaps ¶
type Openaps struct {
IOB IOB `json:"iob"`
}
Openaps represents the openaps data in a DeviceStatus record.
type Profile ¶
type Profile struct {
ID string `json:"_id"`
CreatedAt time.Time `json:"created_at"`
StartDate time.Time `json:"startDate"`
DefaultProfile string `json:"defaultProfile"`
Store map[string]ProfileData `json:"store"`
}
Profile represents data for the Nightscout profile API.
type ProfileData ¶
type ProfileData struct {
DIA int `json:"dia"` // hours
Basal Schedule `json:"basal"`
CarbRatio Schedule `json:"carbratio"`
Sens Schedule `json:"sens"`
TargetLow Schedule `json:"target_low"`
TargetHigh Schedule `json:"target_high"`
TimeZone string `json:"timezone"`
Units string `json:"units"`
}
ProfileData represents the information in a Profile record.
type ProfileID ¶
type ProfileID struct {
ID string `json:"_id"`
}
ProfileID is used to unmarshal just the ID field of a Profile.
type Pump ¶
type Pump struct {
Battery Battery `json:"battery"`
Clock time.Time `json:"clock"`
Reservoir Insulin `json:"reservoir"`
Status Status `json:"status"`
}
Pump represents the pump data in a DeviceStatus record.
type Status ¶
type Status struct {
Status string `json:"status"`
Bolusing bool `json:"bolusing"`
Suspended bool `json:"suspended"`
}
Status represents the status data in a Pump record.
type TimeValue ¶
type TimeValue struct {
Time string `json:"time"`
Value interface{} `json:"value"`
}
TimeValue represents a value with an associated time.
type Treatment ¶
type Treatment struct {
CreatedAt time.Time `json:"created_at"`
EventType string `json:"eventType"`
EnteredBy string `json:"enteredBy,omitempty"`
Glucose *Glucose `json:"glucose,omitempty"`
Absolute *Insulin `json:"absolute,omitempty"`
Duration *int `json:"duration,omitempty"` // minutes
Insulin *Insulin `json:"insulin,omitempty"`
Units string `json:"units,omitempty"`
}
Treatment represents data for the Nightscout treatments API.
type TreatmentTime ¶
TreatmentTime is used to unmarshal just the CreatedAt field of a Treatment.
type Uploader ¶
type Uploader struct {
BatteryLevel int `json:"battery"`
BatteryVoltage Voltage `json:"batteryVoltage,omitempty"`
RawBattery int `json:"rawBattery,omitempty"`
}
Uploader represents the uploader data in a DeviceStatus record.
type Website ¶
type Website struct {
URL *url.URL
Client *http.Client
Token string
// contains filtered or unexported fields
}
func DefaultSite ¶
func (Website) DownloadEntries ¶
DownloadEntries downloads the n most recent entries from Nightscout.
func (Website) Gaps ¶
Gaps finds gaps in Nightscout entries since the given time that are longer than the specified duration.
func (*Website) SetNoUpload ¶
SetNoUpload sets the value of the noUpload flag.
func (*Website) SetVerbose ¶
SetVerbose sets the value of the verbose flag.