entity

package
v0.0.0-...-9bacab5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const EntityColn = "entity"

EntityColn - entity collection name

Variables

This section is empty.

Functions

func AuthenticateEntity

func AuthenticateEntity(entityID, owner, password string) (err error)

AuthenticateEntity - authenticates an entity with given ID and owner using the provided secret

func CreateEntitySecret

func CreateEntitySecret(ent *Entity, owner string) (
	secret string, err error)

CreateEntitySecret - creates a secret that can be used by an entity to communitcate with the server

func GetEndpoints

func GetEndpoints() (endpoints []*vnet.Endpoint)

GetEndpoints - gives REST endpoints for entity APIs

func Init

func Init(app *vapp.App) (err error)

Init - sparrow-entity initialization

func InsertParamValue

func InsertParamValue(owner string, value *ParamValue) (err error)

InsertParamValue - Insert param value given by entity into database

func Reset

func Reset(app *vapp.App) (err error)

Reset - sparrow-entity reset

func SetParam

func SetParam(value ParamValue) (err error)

SetParam - set value for a parameter exposed by an entity

func Setup

func Setup(app *vapp.App) (err error)

Setup - setup function for entity module

Types

type Entity

type Entity struct {
	OID        bson.ObjectId `json:"_id" bson:"_id,omitempty"`
	Name       string        `json:"name" bson:"name"`
	Type       string        `json:"type" bson:"type"`
	Location   string        `json:"location" bson:"location"`
	OwnerID    string        `json:"ownerID" bson:"ownerID"`
	OwnerName  string        `json:"ownerName" bson:"ownerName"`
	Variables  []vcmn.Param  `json:"variables" bson:"variables"`
	Readers    []string      `json:"readers" bson:"readers"`
	Writers    []string      `json:"writers" bson:"writers"`
	Tags       []string      `json:"tags" bson:"tags"`
	CreatedAt  time.Time     `json:"createdAt" bson:"createdAt"`
	ModifiedAt time.Time     `json:"modifiedAt" bson:"modifiedAt"`
	CreatedBy  string        `json:"createdBy" bson:"createdBy"`
	ModifiedBy string        `json:"modifiedBy" bson:"modifiedBy"`
}

Entity - represents a entiry with variables

func (*Entity) ID

func (e *Entity) ID() bson.ObjectId

ID - get ID of the entity

func (*Entity) SetCreationInfo

func (e *Entity) SetCreationInfo(at time.Time, by string)

SetCreationInfo - set the creation time and creator

func (*Entity) SetModInfo

func (e *Entity) SetModInfo(at time.Time, by string)

SetModInfo - set modification time and modifier

type ParamDesc

type ParamDesc struct {
	EntityID  string `json:"entityID" bson:"entityID"`
	ParamID   string `json:"param" bson:"param"`
	ParamName string `json:"paramName" bson:"paramName"`
	Unit      string `json:"unit" bson:"unit"`
}

ParamDesc - describes a parameter

type ParamEntry

type ParamEntry struct {
	ParamDesc `bson:",inline"`
	Day       time.Time               `json:"day" bson:"day"`
	Total     float64                 `json:"total" bson:"total"`
	Values    map[int]map[int]float32 `json:"values" bson:"values"`
}

ParamEntry - data collection entry for a parameter for a day with granularity of 1 minute

func GetValuesForDateRange

func GetValuesForDateRange(
	entityID,
	owner,
	paramID string,
	dayRange vcmn.DateRange) (values []*ParamEntry, err error)

GetValuesForDateRange - get values for all parameters of an entity that is inserted by the entity between given days

func GetValuesForSingleDay

func GetValuesForSingleDay(
	entityID,
	owner,
	paramID string,
	day time.Time) (values []*ParamEntry, err error)

GetValuesForSingleDay - get values for all parameters of an entity that is inserted by the entity in a single day

type ParamValue

type ParamValue struct {
	ParamDesc `bson:",inline"`
	Value     float32 `json:"value" bson:"value"`
}

ParamValue - parameter value along with parameter description

func ReadParamValue

func ReadParamValue(entityID, paramName string) (
	val ParamValue, err error)

ReadParamValue - read value for a parameter that is set by the user.

type VariableAccess

type VariableAccess int

VariableAccess - access level of variable

Jump to

Keyboard shortcuts

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