generator

package
v0.0.0-...-cee4bc5 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRoutesPerTracker = 5
	MaxTracksPerRoute   = 10
	MaxSegmentsPerTrack = 128
	MaxSensorsPerDevice = 10
)

Variables

View Source
var (
	ErrTrackerIsAlreadyRunning = errors.New("gpsgend/generator: tracker is already running")
	ErrTrackerIsAlreadyStopped = errors.New("gpsgend/generator: tracker is already stopped")
	ErrTrackerHasNoRoutes      = errors.New("gpsgend/generator: tracker has no routes")
	ErrNoRoutes                = errors.New("gpsgend/generator: no routes for tracker")
	ErrNoSensor                = errors.New("gpsgend/generator: no sensor for tracker")
	ErrTrackNotFound           = errors.New("gpsgend/generator: track not found")
	ErrMaxNumRoutesExceeded    = errors.New("gpsgend/generator: max number of routes exceeded")
	ErrMaxNumTracksExceeded    = errors.New("gpsgend/generator: max number of tracks exceeded")
	ErrMaxNumSegmentsExceeded  = errors.New("gpsgend/generator: max number of segments exceeded")
	ErrMaxNumSensorsExceeded   = errors.New("gpsgend/generator: max number of sensors exceeded")
	ErrTrackerNotRunning       = errors.New("gpsgend/generator: tracker not running")
	ErrTrackerNotPaused        = errors.New("gpsgend/generator: tracker not paused")
	ErrTrackerOff              = errors.New("gpsgend/generator: tracker is off")
	ErrParamsEmpty             = errors.New("gpsgend/generator: params empty")
	ErrTrackerNotFound         = errors.New("gpsgend/generator: tracker not found")
	ErrRouteNotFound           = errors.New("gpsgend/generator: route not found")
	ErrSensorNotFound          = errors.New("gpsgend/generator: sensor not found")
	ErrLoadingTracker          = errors.New("gpsgend/generator: trackers loading error")
	ErrUnloadingTracker        = errors.New("gpsgend/generator: trackers unloading error")
	ErrSensorAlreadyExists     = errors.New("gpsgned/generator: sensor already exists")
	ErrNoTracker               = errors.New("gpsgend/generator: no tracker")
	ErrInvalidParams           = errors.New("gpsgend/generator: invalid params")

	ErrBrokenTracker         = errors.New("gpsgend/generator: broken tracker data")
	ErrInvalidTrackerVersion = errors.New("gpsgend/generator: invalid tracker version")

	ErrStorageInsert = errors.New("gpsgend/generator: insert into storage")
	ErrStorageUpdate = errors.New("gpsgend/generator: update in storage")
	ErrStorageFind   = errors.New("gpsgned/generator: find in storage")
	ErrStorageDelete = errors.New("gpsgned/generator: delete from storage")
	ErrStorageSearch = errors.New("gpsgned/generator: search in storage")
)

Functions

func Debug_InjectInvalidDatatForTracker

func Debug_InjectInvalidDatatForTracker(trk *Tracker, fieldName string)

Types

type Bootstraper

type Bootstraper interface {
	LoadTrackers(ctx context.Context, p Processes) error
	UnloadTrackers(ctx context.Context, p Processes) error
}

type EventPublisher

type EventPublisher interface {
	PublishTrackerCreated(ctx context.Context, trackerID types.ID)
	PublishTrackerRemoved(ctx context.Context, trackerID types.ID)
	PublishTrackerUpdated(ctx context.Context, trackerUD types.ID)
	PublishTrackerStarted(ctx context.Context, trackerID types.ID)
	PublishTrackerStopped(ctx context.Context, trackerID types.ID)
	PublishTrackerRoutesAdded(ctx context.Context, trackerID types.ID, routes []*gpsgen.Route)
	PublishTrackerRouteRemoved(ctx context.Context, trackerID, routeID types.ID)
	PublishTrackerRoutesReseted(ctx context.Context, trackerID types.ID)
	PublishTrackerNavigatorReseted(ctx context.Context, trackerID types.ID)
	PublishTrackerNavigatorJumped(ctx context.Context, trackerID types.ID)
	PublishTrackerSensorAdded(ctx context.Context, trackerID, sensorID types.ID)
	PublishTrackerSensorRemoved(ctx context.Context, trackerID, sensorID types.ID)
	PublishTrackerShutdowned(ctx context.Context, trackerID types.ID)
	PublishTrackerResumed(ctx context.Context, trackerID types.ID)
}

type Filter

type Filter struct {
	TrackerIDs []string
	Status     int
	Term       string
	Limit      int64
	Offset     int64
}

Filter defines filtering criteria for tracker search.

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator is a service for managing GPS trackers, routes, and related processes.

func New

New creates a new instance of the Generator.

func (*Generator) AddRoutes

func (g *Generator) AddRoutes(ctx context.Context, trackerID types.ID, newRoutes []*gpsgen.Route) error

AddRoutes adds new routes to a tracker and updates related processes.

func (*Generator) AddSensor

func (g *Generator) AddSensor(
	ctx context.Context,
	trackerID types.ID,
	sensorConf *types.Sensor,
) error

AddSensor adds a sensor to a tracker's list of sensors and updates related processes.

func (*Generator) Close

func (g *Generator) Close(ctx context.Context) error

func (*Generator) FindTracker

func (g *Generator) FindTracker(ctx context.Context, trackerID types.ID) (*Tracker, error)

FindTracker retrieves a tracker from storage using its ID.

func (*Generator) MoveToRoute

func (g *Generator) MoveToRoute(ctx context.Context, trackerID types.ID, routeIndex int) (types.Navigator, bool, error)

MoveToRoute moves the tracker's navigation to a specific route index and provides the updated navigation state.

func (*Generator) MoveToRouteByID

func (g *Generator) MoveToRouteByID(ctx context.Context, trackerID types.ID, routeID types.ID) (types.Navigator, bool, error)

MoveToRouteByID moves the tracker's navigation to a specific route ID and provides the updated navigation state.

func (*Generator) MoveToSegment

func (g *Generator) MoveToSegment(ctx context.Context, trackerID types.ID, routeIndex, trackIndex, segmentIndex int) (types.Navigator, bool, error)

MoveToSegment moves the tracker's navigation to a specific segment index within a route and provides the updated navigation state.

func (*Generator) MoveToTrack

func (g *Generator) MoveToTrack(ctx context.Context, trackerID types.ID, routeIndex, trackIndex int) (types.Navigator, bool, error)

MoveToTrack moves the tracker's navigation to a specific track index within a route and provides the updated navigation state.

func (*Generator) MoveToTrackByID

func (g *Generator) MoveToTrackByID(ctx context.Context, trackerID, routeID, trackID types.ID) (types.Navigator, bool, error)

MoveToTrackByID moves the tracker's navigation to a specific track ID within a route and provides the updated navigation state.

func (*Generator) NewTracker

func (g *Generator) NewTracker(ctx context.Context, opts *NewTrackerOptions) (*Tracker, error)

NewTracker creates a new tracker instance with the given options and inserts it into storage.

func (*Generator) RemoveRoute

func (g *Generator) RemoveRoute(ctx context.Context, trackerID types.ID, routeID types.ID) error

RemoveRoute removes a route from a tracker and updates related processes if needed.

func (*Generator) RemoveSensor

func (g *Generator) RemoveSensor(
	ctx context.Context,
	trackerID types.ID,
	sensorID types.ID,
) error

RemoveSensor removes a sensor from a tracker's list of sensors and updates related processes.

func (*Generator) RemoveTracker

func (g *Generator) RemoveTracker(ctx context.Context, trackerID types.ID) error

RemoveTracker removes a tracker from storage and detaches it from any associated processes.

func (*Generator) ResetNavigator

func (g *Generator) ResetNavigator(ctx context.Context, trackerID types.ID) error

ResetNavigator resets the navigation state of a running tracker process.

func (*Generator) ResetRoutes

func (g *Generator) ResetRoutes(ctx context.Context, trackerID types.ID) (bool, error)

ResetRoutes resets all routes for a tracker and updates related processes.

func (*Generator) ResumeTracker

func (g *Generator) ResumeTracker(ctx context.Context, trackerID types.ID) error

ResumeTracker resumes a tracker from a previously taken snapshot and attaches the process// Resume resumes a tracker from a previously taken snapshot and attaches the process.

func (*Generator) RouteAt

func (g *Generator) RouteAt(ctx context.Context, trackerID types.ID, routeIndex int) (*gpsgen.Route, error)

RouteAt retrieves a route at a specific index for a tracker.

func (*Generator) RouteByID

func (g *Generator) RouteByID(ctx context.Context, trackerID, routeID types.ID) (*gpsgen.Route, error)

RouteByID retrieves a route by its ID for a tracker.

func (*Generator) Routes

func (g *Generator) Routes(ctx context.Context, trackerID types.ID) ([]*gpsgen.Route, error)

Routes retrieves the list of routes associated with a tracker.

func (*Generator) Run

func (g *Generator) Run(ctx context.Context) error

func (*Generator) SearchTrackers

func (g *Generator) SearchTrackers(ctx context.Context, f Filter) (SearchResult, error)

SearchTrackers searches for trackers based on the provided filter. It returns a SearchResult and an error if the search operation fails.

func (*Generator) Sensors

func (g *Generator) Sensors(
	ctx context.Context,
	trackerID types.ID,
) ([]*types.Sensor, error)

Sensors retrieves the list of sensors associated with a tracker.

func (*Generator) ShutdownTracker

func (g *Generator) ShutdownTracker(ctx context.Context, trackerID types.ID) error

Shutdown shuts down a tracker, takes snapshots if needed, and detaches processes.

func (*Generator) StartTracker

func (g *Generator) StartTracker(ctx context.Context, trackerID types.ID) error

StartTracker starts a tracker process and attaches it.

func (*Generator) Stats

func (g *Generator) Stats(ctx context.Context) (item []StatsItem, err error)

func (*Generator) StopTracker

func (g *Generator) StopTracker(ctx context.Context, trackerID types.ID) error

StopTracker stops a tracker process and detaches it.

func (*Generator) Sync

func (g *Generator) Sync(ctx context.Context, trackerID types.ID) error

func (*Generator) ToNextRoute

func (g *Generator) ToNextRoute(ctx context.Context, trackerID types.ID) (types.Navigator, bool, error)

ToNextRoute moves the tracker's navigation to the next route and provides the updated navigation state.

func (*Generator) ToPrevRoute

func (g *Generator) ToPrevRoute(ctx context.Context, trackerID types.ID) (types.Navigator, bool, error)

ToPrevRoute moves the tracker's navigation to the previous route and provides the updated navigation state.

func (*Generator) TrackerState

func (g *Generator) TrackerState(ctx context.Context, trackerID types.ID) (*proto.Device, error)

TrackerState retrieves the state of a running tracker process.

func (*Generator) UpdateTracker

func (g *Generator) UpdateTracker(
	ctx context.Context,
	trackerID types.ID,
	opts UpdateTrackerOptions,
) error

UpdateTracker updates the information of a tracker, validates options, and manages related processes.

type NewTrackerOptions

type NewTrackerOptions struct {
	Model  *types.Model       // Model of the device.
	Color  *types.Color       // Color of the device.
	UserID *types.CustomID    // User ID associated with the device.
	Descr  *types.Description // Description of the device.
	Props  *properties.Properties

	SkipOffline bool // Skip offline mode.
	Offline     types.Offline
	Elevation   types.Elevation
	Battery     types.Battery
	Speed       types.Speed
}

type Processes

type Processes interface {
	HasTracker(deviceID string) bool
	Attach(d *gpsgen.Device) error
	Detach(deviceID string) error
	NumDevices() int
	Lookup(deviceID string) (*gpsgen.Device, bool)
	Each(func(n int, p *gpsgen.Device) bool)
}

type Query

type Query interface {
	// SearchTrackers searches for trackers based on the given filter criteria.
	SearchTrackers(ctx context.Context, f Filter) (SearchResult, error)

	// Stats returns generator statistics group by status.
	Stats(ctx context.Context) ([]StatsItem, error)
}

Query defines an interface for querying tracker data.

type SearchResult

type SearchResult struct {
	Trackers []TrackerView `json:"trackers"`
	Next     int64         `json:"next"`
}

SearchResult holds the result of a tracker search operation.

type SensorSnapshot

type SensorSnapshot struct {
	ID        string  `json:"sensorId" bson:"sensor_id"`
	Name      string  `json:"name" bson:"name"`
	Min       float64 `json:"min" bson:"min"`
	Max       float64 `json:"max" bson:"max"`
	Amplitude int     `json:"amplitude" bson:"amplitude"`
	Mode      int     `json:"mode" bson:"mode"`
}

type Service

type Service interface {
	NewTracker(ctx context.Context, opts *NewTrackerOptions) (*Tracker, error)
	SearchTrackers(ctx context.Context, f Filter) (SearchResult, error)
	RemoveTracker(ctx context.Context, trackerID types.ID) error
	UpdateTracker(ctx context.Context, trackerID types.ID, opts UpdateTrackerOptions) error
	FindTracker(ctx context.Context, trackerID types.ID) (*Tracker, error)
	StartTracker(ctx context.Context, trackerID types.ID) error
	StopTracker(ctx context.Context, trackerID types.ID) error
	TrackerState(ctx context.Context, trackerID types.ID) (*proto.Device, error)
	AddRoutes(ctx context.Context, trackerID types.ID, newRoutes []*gpsgen.Route) error
	RemoveRoute(ctx context.Context, trackerID types.ID, routeID types.ID) error
	Routes(ctx context.Context, trackerID types.ID) ([]*gpsgen.Route, error)
	RouteAt(ctx context.Context, trackerID types.ID, routeIndex int) (*gpsgen.Route, error)
	RouteByID(ctx context.Context, trackerID, routeID types.ID) (*gpsgen.Route, error)
	ResetRoutes(ctx context.Context, trackerID types.ID) (bool, error)
	ResetNavigator(ctx context.Context, trackerID types.ID) error
	ToNextRoute(ctx context.Context, trackerID types.ID) (types.Navigator, bool, error)
	ToPrevRoute(ctx context.Context, trackerID types.ID) (types.Navigator, bool, error)
	MoveToRoute(ctx context.Context, trackerID types.ID, routeIndex int) (types.Navigator, bool, error)
	MoveToRouteByID(ctx context.Context, trackerID types.ID, routeID types.ID) (types.Navigator, bool, error)
	MoveToTrack(ctx context.Context, trackerID types.ID, routeIndex, trackIndex int) (types.Navigator, bool, error)
	MoveToTrackByID(ctx context.Context, trackerID, routeID, trackID types.ID) (types.Navigator, bool, error)
	MoveToSegment(ctx context.Context, trackerID types.ID, routeIndex, trackIndex, segmentIndex int) (types.Navigator, bool, error)
	AddSensor(ctx context.Context, trackerID types.ID, sensor *types.Sensor) error
	RemoveSensor(ctx context.Context, trackerID types.ID, sensorID types.ID) error
	Sensors(ctx context.Context, trackerID types.ID) ([]*types.Sensor, error)
	ShutdownTracker(ctx context.Context, trackerID types.ID) error
	ResumeTracker(ctx context.Context, trackerID types.ID) error
	Stats(ctx context.Context) ([]StatsItem, error)
	Sync(ctx context.Context, trackerID types.ID) error
}

type StatsItem

type StatsItem struct {
	Status string `bson:"status" json:"status"`
	Total  int    `bson:"total" json:"total"`
}

type Storage

type Storage interface {
	// Find retrieves a Tracker based on the provided trackerID from the storage.
	// If the Tracker is found, it is returned along with a nil error.
	// If the Tracker is not found, nil is returned along with an error describing the situation.
	Find(ctx context.Context, trackerID types.ID) (*Tracker, error)

	// Insert adds a new Tracker to the storage.
	// Returns an error if the insertion process fails.
	Insert(ctx context.Context, t *Tracker) error

	// Delete removes a Tracker from the storage based on the provided trackerID.
	// Returns an error if the deletion process fails.
	Delete(ctx context.Context, trackerID types.ID) error

	// Update updates the information of an existing Tracker in the storage.
	// Returns an error if the update process fails.
	Update(ctx context.Context, t *Tracker) error
}

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker represents a GPS tracker device with various properties and capabilities.

func (*Tracker) AddRoute

func (t *Tracker) AddRoute(route *gpsgen.Route) ([]*gpsgen.Route, error)

AddRoute adds a new route to the tracker.

func (*Tracker) AddRoutes

func (t *Tracker) AddRoutes(newRoutes []*gpsgen.Route) ([]*gpsgen.Route, error)

AddRoutes adds multiple new routes to the tracker.

func (*Tracker) AddSensor

func (t *Tracker) AddSensor(newSensor *types.Sensor) error

AddSensor adds one sensors to the tracker.

func (*Tracker) Battery

func (t *Tracker) Battery() types.Battery

Battery returns the battery information of the tracker.

func (*Tracker) Color

func (t *Tracker) Color() types.Color

Color returns the color of the tracker.

func (*Tracker) CreatedAt

func (t *Tracker) CreatedAt() time.Time

CreatedAt returns the timestamp indicating when the tracker was created.

func (*Tracker) Description

func (t *Tracker) Description() types.Description

Description returns the description of the tracker.

func (*Tracker) Elevation

func (t *Tracker) Elevation() types.Elevation

Elevation returns the elevation information of the tracker.

func (*Tracker) FromSnapshot

func (t *Tracker) FromSnapshot(snap *TrackerSnapshot) error

func (*Tracker) HasNoRoutes

func (t *Tracker) HasNoRoutes() bool

HasNoRoutes checks if the tracker has no routes.

func (*Tracker) ID

func (t *Tracker) ID() types.ID

ID returns the unique identifier of the tracker.

func (*Tracker) IsRunning

func (t *Tracker) IsRunning() bool

IsRunning checks if the tracker is currently running.

func (*Tracker) IsTrackerOff

func (t *Tracker) IsTrackerOff() bool

IsTrackerOff checks if the tracker is in a paused state.

func (*Tracker) Model

func (t *Tracker) Model() types.Model

Model returns the model of the tracker.

func (*Tracker) NewProcess

func (t *Tracker) NewProcess() (newProc *gpsgen.Device, err error)

NewProcess creates a new GPS device process for the tracker.

func (*Tracker) NumRoutes

func (t *Tracker) NumRoutes() int

NumRoutes returns the number of routes associated with the tracker.

func (*Tracker) NumSensors

func (t *Tracker) NumSensors() int

NumSensors returns the number of sensors associated with the tracker.

func (*Tracker) Offline

func (t *Tracker) Offline() types.Offline

Offline returns the offline configuration of the tracker.

func (*Tracker) Properties

func (t *Tracker) Properties() properties.Properties

Properties returns the custom properties associated with the tracker.

func (*Tracker) RemoveRoute

func (t *Tracker) RemoveRoute(routeID types.ID) error

RemoveRoute removes a route from the tracker by route ID.

func (*Tracker) RemoveSensorByID

func (t *Tracker) RemoveSensorByID(id types.ID) error

RemoveSensorByID removes a sensor from the tracker by sensor ID.

func (*Tracker) ResetRoutes

func (t *Tracker) ResetRoutes() error

ResetRoutes removes all routes from the tracker.

func (*Tracker) ResetSensors

func (t *Tracker) ResetSensors()

func (*Tracker) ResetStatus

func (t *Tracker) ResetStatus()

ResetStatus resets the tracker's status to stopped.

func (*Tracker) ResumeProcess

func (t *Tracker) ResumeProcess() (*gpsgen.Device, error)

ResumeProcess resumes a paused tracker's process with the provided GPS device state.

func (*Tracker) RouteAt

func (t *Tracker) RouteAt(index int) (*gpsgen.Route, error)

RouteAt returns the route at the specified index.

func (*Tracker) RouteByID

func (t *Tracker) RouteByID(routeID types.ID) (route *gpsgen.Route, err error)

RouteByID returns the route with the specified ID.

func (*Tracker) Routes

func (t *Tracker) Routes() ([]*gpsgen.Route, error)

Routes returns a list of all routes associated with the tracker.

func (*Tracker) RunningAt

func (t *Tracker) RunningAt() time.Time

RunningAt returns the timestamp indicating when the tracker's GPS process started running.

func (*Tracker) Sensors

func (t *Tracker) Sensors() []*types.Sensor

Sensors returns a list of all sensors associated with the tracker.

func (*Tracker) ShutdownProcess

func (t *Tracker) ShutdownProcess(tracker *gpsgen.Device) error

ShutdownProcess saves the current GPS device state and pauses the tracker's process.

func (*Tracker) SkipOffline

func (t *Tracker) SkipOffline() bool

SkipOffline returns whether skipping offline data is enabled for the tracker.

func (*Tracker) Speed

func (t *Tracker) Speed() types.Speed

Speed returns the speed information of the tracker.

func (*Tracker) Status

func (t *Tracker) Status() types.DeviceStatus

Status returns the status of the tracker.

func (*Tracker) Stop

func (t *Tracker) Stop() error

Stop stops the tracker's GPS device process.

func (*Tracker) StoppedAt

func (t *Tracker) StoppedAt() time.Time

StoppedAt returns the timestamp indicating when the tracker's GPS process was stopped.

func (*Tracker) TakeSnapshot

func (t *Tracker) TakeSnapshot(snap *TrackerSnapshot)

func (*Tracker) UpdateInfo

func (t *Tracker) UpdateInfo(opts UpdateTrackerOptions) (bool, error)

UpdateInfo updates the tracker's information with the provided options.

func (*Tracker) UpdatedAt

func (t *Tracker) UpdatedAt() time.Time

UpdatedAt returns the timestamp indicating when the tracker was last updated.

func (*Tracker) UserID

func (t *Tracker) UserID() types.CustomID

UserID returns the custom user identifier associated with the tracker.

type TrackerBuilder

type TrackerBuilder struct {
	// contains filtered or unexported fields
}

func NewTrackerBuilder

func NewTrackerBuilder() *TrackerBuilder

func (*TrackerBuilder) Battery

func (b *TrackerBuilder) Battery(battery types.Battery) *TrackerBuilder

func (*TrackerBuilder) Build

func (b *TrackerBuilder) Build() (*Tracker, error)

func (*TrackerBuilder) Color

func (b *TrackerBuilder) Color(color types.Color) *TrackerBuilder

func (*TrackerBuilder) CreatedAt

func (b *TrackerBuilder) CreatedAt(t time.Time) *TrackerBuilder

func (*TrackerBuilder) CustomID

func (b *TrackerBuilder) CustomID(id types.CustomID) *TrackerBuilder

func (*TrackerBuilder) Description

func (b *TrackerBuilder) Description(descr types.Description) *TrackerBuilder

func (*TrackerBuilder) Elevation

func (b *TrackerBuilder) Elevation(elevation types.Elevation) *TrackerBuilder

func (*TrackerBuilder) ID

func (*TrackerBuilder) Model

func (b *TrackerBuilder) Model(model types.Model) *TrackerBuilder

func (*TrackerBuilder) Offline

func (b *TrackerBuilder) Offline(offline types.Offline) *TrackerBuilder

func (*TrackerBuilder) Props

func (*TrackerBuilder) RunningAt

func (b *TrackerBuilder) RunningAt(t time.Time) *TrackerBuilder

func (*TrackerBuilder) SkipOffline

func (b *TrackerBuilder) SkipOffline(flag bool) *TrackerBuilder

func (*TrackerBuilder) Speed

func (b *TrackerBuilder) Speed(speed types.Speed) *TrackerBuilder

func (*TrackerBuilder) Status

func (b *TrackerBuilder) Status(status types.DeviceStatus) *TrackerBuilder

func (*TrackerBuilder) StoppedAt

func (b *TrackerBuilder) StoppedAt(t time.Time) *TrackerBuilder

func (*TrackerBuilder) UpdatedAt

func (b *TrackerBuilder) UpdatedAt(t time.Time) *TrackerBuilder

type TrackerSnapshot

type TrackerSnapshot struct {
	ID       string `json:"trackerId" bson:"tracker_id,omitempty"`
	CustomID string `json:"customId" bson:"custom_id"`
	Status   struct {
		ID   int    `json:"id" bson:"id"`
		Name string `json:"name" bson:"name"`
	} `json:"status" bson:"status"`
	Model   string `json:"model" bson:"model"`
	Color   string `json:"color" bson:"color"`
	Descr   string `json:"descr"  bson:"descr"`
	Offline struct {
		Min int `json:"min" bson:"min"`
		Max int `json:"max" bson:"max"`
	} `json:"offline" bson:"offline"`
	Elevation struct {
		Min       float64 `json:"min" bson:"min"`
		Max       float64 `json:"max" bson:"max"`
		Amplitude int     `json:"amplitude" bson:"amplitude"`
		Mode      int     `json:"mode" bson:"mode"`
	} `json:"elevation" bson:"elevation"`
	Battery struct {
		Min        float64 `json:"min" bson:"min"`
		Max        float64 `json:"max" bson:"max"`
		ChargeTime float64 `json:"chargeTime" bson:"charge_time"`
	} `json:"battery" bson:"battery"`
	Speed struct {
		Min       float64 `json:"min" bson:"min"`
		Max       float64 `json:"max" bson:"max"`
		Amplitude int     `json:"amplitude" bson:"amplitude"`
	} `json:"speed" bson:"speed"`
	Props       properties.Properties `json:"props,omitempty" bson:"props"`
	Sensors     []SensorSnapshot      `json:"sensors" bson:"sensors"`
	NumSensors  int                   `json:"numSensors" bson:"num_sensors"`
	NumRoutes   int                   `json:"numRoutes" bson:"num_routes"`
	SkipOffline bool                  `json:"skipOffline" bson:"skip_offline"`
	Snapshot    []byte                `json:"-" bson:"snapshot"`
	Routes      []byte                `json:"-" bson:"routes"`
	CreatedAt   int64                 `json:"createdAt" bson:"created_at"`
	UpdatedAt   int64                 `json:"updatedAt" bson:"updated_at"`
	RunningAt   int64                 `json:"runningAt" bson:"running_at"`
	StoppedAt   int64                 `json:"stoppedAt" bson:"stopped_at"`
	Version     int                   `json:"version" bson:"version"`
}

type TrackerView

type TrackerView struct {
	ID       string `json:"trackerId" bson:"tracker_id"`
	CustomID string `json:"customId" bson:"custom_id"`
	Status   struct {
		ID   int    `json:"id" bson:"id"`
		Name string `json:"name" bson:"name"`
	} `json:"status" bson:"status"`
	Model   string `json:"model" bson:"model"`
	Color   string `json:"color" bson:"color"`
	Descr   string `json:"descr" bson:"descr"`
	Offline struct {
		Min int `json:"min" bson:"min"`
		Max int `json:"max" bson:"max"`
	} `json:"offline" bson:"offline"`
	Elevation struct {
		Min       float64 `json:"min" bson:"min"`
		Max       float64 `json:"max" bson:"max"`
		Amplitude int     `json:"amplitude" bson:"amplitude"`
		Mode      int     `json:"mode" bson:"mode"`
	} `json:"elevation" bson:"elevation"`
	Battery struct {
		Min        float64 `json:"min" bson:"min"`
		Max        float64 `json:"max" bson:"max"`
		ChargeTime float64 `json:"chargeTime" bson:"charge_time"`
	} `json:"battery" bson:"battery"`
	Speed struct {
		Min       float64 `json:"min" bson:"min"`
		Max       float64 `json:"max" bson:"max"`
		Amplitude int     `json:"amplitude" bson:"amplitude"`
	} `json:"speed" bson:"speed"`
	Props       properties.Properties `json:"props,omitempty" bson:"props,omitempty"`
	NumSensors  int                   `json:"numSensors" bson:"num_sensors"`
	NumRoutes   int                   `json:"numRoutes" bson:"num_routes"`
	SkipOffline bool                  `json:"skipOffline" bson:"skip_offline"`
	CreatedAt   int64                 `json:"createdAt,omitempty" bson:"created_at"`
	UpdatedAt   int64                 `json:"updatedAt,omitempty" bson:"updated_at"`
	RunningAt   int64                 `json:"runningAt,omitempty" bson:"running_at"`
	StoppedAt   int64                 `json:"stoppedAt,omitempty" bson:"stopped_at"`
}

TrackerView provides a structured view of tracker information for display or transmission.

type UpdateTrackerOptions

type UpdateTrackerOptions struct {
	Model  *types.Model       // Model of the device.
	Color  *types.Color       // Color of the device.
	UserID *types.CustomID    // User ID associated with the device.
	Descr  *types.Description // Description of the device.
}

Jump to

Keyboard shortcuts

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