lbs

package
v0.0.0-...-a5cc226 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	AlarmMessageTopic = "iotx-foundry-alarm"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alarm

type Alarm struct {
	FenceId          string     `json:"fence_id,noempty"`
	FenceName        string     `json:"fence_name,noempty"`
	MonitoredObjects []string   `json:"monitored_objects"`
	Action           string     `json:"action"`
	AlarmPoint       AlarmPoint `json:"alarm_point"`
	PrePoint         AlarmPoint `json:"pre_point"`
}

type AlarmHistory

type AlarmHistory struct {
	FenceId         int               `json:"fence_id"`
	FenceName       string            `json:"fence_name"`
	MonitoredPerson string            `json:"monitored_person"`
	Action          string            `json:"action"`
	AlarmPoint      HistoryAlarmPoint `json:"alarm_point"`
	PrePoint        HistoryPrePoint   `json:"pre_point"`
}

type AlarmInfo

type AlarmInfo struct {
	FenceId          int            `json:"fence_id,noempty"`
	FenceName        string         `json:"fence_name,noempty"`
	MonitoredObjects string         `json:"monitored_person"`
	Action           string         `json:"action"`
	AlarmPoint       AlarmPointInfo `json:"alarm_point"`
	PrePoint         AlarmPointInfo `json:"pre_point"`
	UserId           string
}

type AlarmInfos

type AlarmInfos struct {
	Type      int         `json:"type"`
	ServiceId int         `json:"service_id"`
	Alarms    []AlarmInfo `json:"content"`
}

type AlarmNotification

type AlarmNotification struct {
	Type      int      `json:"type"`
	ServiceId string   `json:"service_id"`
	Alarms    []*Alarm `json:"alarms"`
}

type AlarmPoint

type AlarmPoint struct {
	Longitude  float64    `json:"longitude"`
	Latitude   float64    `json:"latitude"`
	Radius     int        `json:"radius"`
	CoordType  string     `json:"coord_type"`
	LocTime    *time.Time `json:"loc_time"`
	CreateTime *time.Time `json:"create_time"`
}

type AlarmPointInfo

type AlarmPointInfo struct {
	Longitude  float64 `json:"longitude"`
	Latitude   float64 `json:"latitude"`
	Radius     int     `json:"radius"`
	CoordType  string  `json:"coord_type"`
	LocTime    int     `json:"loc_time"`
	CreateTime int     `json:"create_time"`
}

type AlarmTopic

type AlarmTopic struct {
	TopicName string
	Alarm     *AlarmNotification `json:"alarm"`
}

func (*AlarmTopic) Deserialize

func (p *AlarmTopic) Deserialize(buf []byte, opt message.SerializeOption) error

func (*AlarmTopic) Serialize

func (p *AlarmTopic) Serialize(opt message.SerializeOption) ([]byte, error)

func (*AlarmTopic) SetTopic

func (p *AlarmTopic) SetTopic(name string)

func (*AlarmTopic) Topic

func (p *AlarmTopic) Topic() string

type BaiduBatchHistoryAlarmsResp

type BaiduBatchHistoryAlarmsResp struct {
	Status  int            `json:"status"`
	Message string         `json:"message"`
	Size    int            `json:"size"`
	Total   int            `json:"total"`
	Alarms  []AlarmHistory `json:"alarms"`
}

type BaiduGetHistoryAlarmsResponse

type BaiduGetHistoryAlarmsResponse struct {
	Status  int            `json:"status"`
	Message string         `json:"message"`
	Size    int            `json:"size"`
	Alarms  []AlarmHistory `json:"alarms"`
}

type BaiduGetStayPointResp

type BaiduGetStayPointResp struct {
	Status     int     `json:"status"`
	Message    string  `json:"message"`
	Size       int     `json:"size"`
	Total      int     `json:"total"`
	StartPoint Point   `json:"start_point"`
	EndPoint   Point   `json:"end_point"`
	Points     []Point `json:"points"`
}

type BaiduQueryStatusResponse

type BaiduQueryStatusResponse struct {
	Status            int               `json:"status"`
	Message           string            `json:"message"`
	Size              int               `json:"size"`
	MonitoredStatuses []MonitoredStatus `json:"monitored_statuses"`
}

type CircleGeofence

type CircleGeofence struct {
	Name             string
	MonitoredObjects string
	Longitude        float64
	Latitude         float64
	Radius           float64
	CoordType        CoordType
	Denoise          int
	FenceId          string
}

type Collection

type Collection struct {
	UserId        string    `bson:"user_id"`
	CollectionId  string    `bson:"collection_id"`
	CreatedAt     time.Time `bson:"created_at"`
	LastUpdatedAt time.Time `bson:"last_updated_at"`
	Status        string    `bson:"status"`
}

type Config

type Config struct {
	AccessKey string
	ServiceId string
}

type CoordType

type CoordType string
const (
	CoordType_WGS84  CoordType = "wgs84"
	CoordType_GCJ02  CoordType = "gcj02"
	CoordType_BD09LL CoordType = "bd09ll"
)

type Engine

type Engine interface {
	// Add monitored object's track points
	AddTrackPoint(point TrackPoint)
	AddTrackPoints(points []TrackPoint)
	// Create circle geofence and return goefence id if successful
	CreateCircleGeofence(c CircleGeofence) (string, error)
	// Update an existed geofence
	UpdateCircleGeofence(c CircleGeofence) error
	// Delete an existed geofence or monitored objects
	DeleteGeofence(fenceIds []string, objects []string) ([]string, error)
	// List geofences matched with ids or objects
	ListGeofence(fenceIds []string, objects []string) ([]*Geofence, error)
	// Add monitored object for specifed geofence
	AddMonitoredObject(fenceId string, objects []string) error
	// Remove monitored object from specified geofence
	RemoveMonitoredObject(fenceId string, objects []string) error
	// List monitored object in specifed geofence
	ListMonitoredObjects(fenceId string, pageIndex int, pageSize int) (int, []string)
	// Create poly geofence and return goefence id if successful
	CreatePolyGeofence(c PolyGeofence) (string, error)
	// Update an existed poly geofence
	UpdatePolyGeofence(c PolyGeofence) error

	// Alarms
	QueryStatus(monitoredPerson string, fenceIds []string) (BaiduQueryStatusResponse, error)
	GetHistoryAlarms(monitoredPerson string, fenceIds []string) (BaiduGetHistoryAlarmsResponse, error)
	BatchGetHistoryAlarms(input *grpc_pandas_v1.BatchGetHistoryAlarmsRequest) (BaiduBatchHistoryAlarmsResp, error)
	GetStayPoints(input *grpc_pandas_v1.GetStayPointsRequest) (BaiduGetStayPointResp, error)
	UnmarshalAlarmNotification(content []byte) (*AlarmNotification, error)

	//Entity
	AddEntity(EntityName string, EntityDesc string) error
	UpdateEntity(EntityName string, EntityDesc string) error
	DeleteEntity(EntityName string) error
	ListEntity(userId string, collectionId string, CoordTypeOutput string, PageIndex int32, pageSize int32) (int, baiduListEntityStruct)
}

func NewEngine

func NewEngine(r Repository) (Engine, error)

type Entity

type Entity struct {
	EntityName   string             `json:"entity_name"`
	EntityDesc   string             `json:"entity_desc"`
	LastLocation LastLocationStruct `json:"latest_location"`
}

type EntityRecord

type EntityRecord struct {
	UserId        string    `bson:"user_id"`
	CollectionId  string    `bson:"collection_id"`
	EntityName    string    `bson:"entity_name"`
	CreatedAt     time.Time `bson:"created_at"`
	LastUpdatedAt time.Time `bson:"last_updated_at"`
}

type Geofence

type Geofence struct {
	FenceId         int       `json:"fence_id"`
	FenceName       string    `json:"fence_name"`
	MonitoredObject string    `json:"monitored_person"`
	Shape           string    `json:"shape"`
	Longitude       float64   `json:"longitude"`
	Latitude        float64   `json:"latitude"`
	Radius          float64   `json:"radius"`
	CoordType       CoordType `json:"coord_type"`
	Denoise         int       `json:"denoise"`
	CreateTime      string    `json:"create_time"`
	UpdateTime      string    `json:"modify_time"`
	Vertexes        []Vertexe `json:"vertexes"`
}

type HistoryAlarmPoint

type HistoryAlarmPoint struct {
	Longitude  float64 `json:"longitude"`
	Latitude   float64 `json:"latitude"`
	Radius     int     `json:"radius"`
	CoordType  string  `json:"coord_type"`
	LocTime    string  `json:"loc_time"`
	CreateTime string  `json:"create_time"`
}

type HistoryPrePoint

type HistoryPrePoint struct {
	Longitude  float64 `json:"longitude"`
	Latitude   float64 `json:"latitude"`
	Radius     int     `json:"radius"`
	CoordType  string  `json:"coord_type"`
	LocTime    string  `json:"loc_time"`
	CreateTime string  `json:"create_time"`
}

type LastLocationStruct

type LastLocationStruct struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Time      string  `json:"loc_time"`
}

Location is reported by iot terminal to lbs service

type Manager

type Manager interface {
	// Add monitored object's track points
	AddTrackPoint(principal auth.Principal, point TrackPoint)
	AddTrackPoints(principal auth.Principal, points []TrackPoint)
	// Create circle geofence and return goefence id if successful
	CreateCircleGeofence(principal auth.Principal, c CircleGeofence) (string, error)
	// Update an existed geofence
	UpdateCircleGeofence(principal auth.Principal, c CircleGeofence) error
	// Delete an existed geofence or monitored objects
	DeleteGeofence(principal auth.Principal, fenceIds []string, objects []string) ([]string, error)
	// List geofences matched with ids or objects
	ListGeofence(principal auth.Principal, fenceIds []string, objects []string) ([]*Geofence, error)
	// Add monitored object for specifed geofence
	AddMonitoredObject(principal auth.Principal, fenceId string, objects []string) error
	// Remove monitored object from specified geofence
	RemoveMonitoredObject(principal auth.Principal, fenceId string, objects []string) error
	// List monitored object in specifed geofence
	ListMonitoredObjects(principal auth.Principal, fenceId string, pageIndex int, pageSize int) (int, []string)
	// Create poly geofence and return goefence id if successful
	CreatePolyGeofence(principal auth.Principal, c PolyGeofence) (string, error)
	// Update an existed poly geofence
	UpdatePolyGeofence(principal auth.Principal, c PolyGeofence) error

	// Alarms
	QueryStatus(principal auth.Principal, monitoredPerson string, fenceIds []string) (BaiduQueryStatusResponse, error)
	GetHistoryAlarms(principal auth.Principal, monitoredPerson string, fenceIds []string) (BaiduGetHistoryAlarmsResponse, error)
	BatchGetHistoryAlarms(principal auth.Principal, input *grpc_pandas_v1.BatchGetHistoryAlarmsRequest) (BaiduBatchHistoryAlarmsResp, error)
	GetStayPoints(principal auth.Principal, input *grpc_pandas_v1.GetStayPointsRequest) (BaiduGetStayPointResp, error)
	UnmarshalAlarmNotification(principal auth.Principal, content []byte) (*AlarmNotification, error)

	//Entity
	AddEntity(principal auth.Principal, EntityName string, EntityDesc string) error
	UpdateEntity(principal auth.Principal, EntityName string, EntityDesc string) error
	DeleteEntity(principal auth.Principal, EntityName string) error
	ListEntity(principal auth.Principal, collectionId string, CoordTypeOutput string, PageIndex int32, pageSize int32) (int, baiduListEntityStruct)
}

func NewManager

func NewManager(engine string, r Repository) (Manager, error)

type MonitoredStatus

type MonitoredStatus struct {
	FenceId         int    `json:"fence_id"`
	MonitoredStatus string `json:"monitored_status"`
}

type Point

type Point struct {
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
	CoordType string  `json:"coord_type"`
	LocTime   int     `json:"loc_time"`
}

type PolyGeofence

type PolyGeofence struct {
	Name             string
	MonitoredObjects string
	Vertexes         string
	CoordType        CoordType
	Denoise          int
	FenceId          string
}

type Repository

type Repository interface {
	// Helper
	AddCollection(userId string, collectionId string) error
	RemoveCollection(userId string, collectionId string) error
	GetAllCollections() ([]*Collection, error)
	UpdateCollection(userId string, p *Collection) error

	// Geofences
	AddGeofence(userId string, collectionId string, fenceName string, fenceId string) error
	RemoveGeofence(userId string, collectionId string, fenceId string) error
	IsGeofenceExistWithName(userId string, collectionId string, fenceName string) bool
	IsGeofenceExistWithId(userId string, collectionId string, fenceId string) bool
	GetFences(userId, collectionId string) ([]*geofenceRecord, error)
	GetFenceUserId(fenceId string) (string, error)

	//Entity
	AddEntity(userId string, collectionId string, entityName string) error
	DeleteEntity(userId string, collectionId string, entityName string) error
	UpdateEntity(userId string, collectionId string, entityName string, entity EntityRecord) error
	IsEntityExistWithName(userId string, collectionId string, entityName string) bool
	GetEntities(userId string, collectionId string) ([]*EntityRecord, error)

	Close()
}

func NewRepository

func NewRepository() Repository

type TrackPoint

type TrackPoint struct {
	EntityName string    `json:"entity_name"`
	Latitude   float64   `json:"latitude"`
	Longitude  float64   `json:"longitude"`
	CoordType  CoordType `json:"coord_type_input"`
	Time       string    `json:"loc_time"`
}

type UserId

type UserId struct {
	UserId string `bson:"user_id"`
}

type Vertexe

type Vertexe struct {
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
}

Jump to

Keyboard shortcuts

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