Documentation ¶
Index ¶
- type Building
- type Datapoint
- type Hub
- func (h *Hub) Find() (hubs []Hub, err error)
- func (h *Hub) FindByID(ID string) (hub Hub, err error)
- func (h *Hub) GetRoom() (room Room, err error)
- func (h *Hub) GetSensors() (sensors []Sensor, err error)
- func (h *Hub) MarshalJSON() ([]byte, error)
- func (h *Hub) Remove(ID string) error
- func (h *Hub) Save() (info *mgo.ChangeInfo, err error)
- func (h *Hub) Status() string
- type Model
- type OccupationSensor
- type Room
- type RoomLog
- type RoomRoster
- type Sensor
- type SensorJSON
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Building ¶
type Building struct { ID bson.ObjectId `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Location string `json:"location"` Rooms []Room `json:"rooms,omitempty" bson:"-"` RoomIDs []bson.ObjectId `json:"-" bson:"rooms"` // contains filtered or unexported fields }
func NewBuildingModel ¶
func NewBuildingModel(db *mgo.Database) *Building
type Datapoint ¶
type Datapoint struct { ID bson.ObjectId `json:"id" bson:"_id"` SensorID bson.ObjectId `json:"sensor_id" bson:"sensor"` Key string `json:"key" bson:"key"` Value float64 `json:"value" bson:"value"` Timestamp int64 `json:"timestamp" bson:"timestamp"` DB *mgo.Database `json:"-" bson:"-"` }
func BulkSaveDatapoints ¶
func DatapointModel ¶
HubModel creates a Hub which can be used to query the db
type Hub ¶
type Hub struct { ID bson.ObjectId `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Serial string `json:"serialNumber" bson:"serial"` SensorIDS []bson.ObjectId `json:"-" bson:"sensors"` Sensors []Sensor `json:"sensors,omitempty" bson:"-"` // do not store directly in db Room Room `json:"room,omitempty" bson:"-"` // contains filtered or unexported fields }
func (*Hub) GetSensors ¶
Sensors retrieves the associated sensors from this h
func (*Hub) MarshalJSON ¶
type OccupationSensor ¶
type OccupationSensor struct { InSensorDatapoints []*Datapoint OutSensorDatapoints []*Datapoint TotalEntrances int TotalExits int CurrentOccupants int }
func (*OccupationSensor) CalculateCurrentOccupants ¶
func (o *OccupationSensor) CalculateCurrentOccupants()
func (*OccupationSensor) CalculateEntrances ¶
func (o *OccupationSensor) CalculateEntrances() int
func (*OccupationSensor) CalculateExits ¶
func (o *OccupationSensor) CalculateExits() int
type Room ¶
type Room struct { ID bson.ObjectId `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Size float32 `json:"size" bson:"size"` MaxCapacity int `json:"maxCapacity" bson:"maxCapacity"` Occupation int `json:"occupation" bson:"occupation"` // Hubs []Hub `json:"hubs" bson:"-"` HubIDs []bson.ObjectId `json:"-" bson:"hubs,omitempty"` BuildingID bson.ObjectId `json:"building" bson:"building,omitempty"` RoomLogs []RoomLog `json:"logs" bson:"-"` RoomRosters []RoomRoster `json:"roster" bson:"-"` // contains filtered or unexported fields }
func NewRoomModel ¶
func NewRoomModel(db *mgo.Database) *Room
type RoomRoster ¶ added in v0.2.0
type Sensor ¶
type Sensor struct { ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"` Name string `json:"name,omitempty" bson:"name"` SensorType string `json:"sensorType,omitempty" bson:"sensorType"` Status bool `json:"status,omitempty" bson:"status"` UUID int `json:"UUID,omitempty" bson:"UUID"` Gpio_trigger int `json:"gpio_trigger,omitempty" bson:"gpio_trigger"` Gpio_echo int `json:"gpio_echo,omitempty" bson:"gpio_echo"` Datapoints []Datapoint `json:"datapoints,omitempty" bson:"datapoints"` HubID bson.ObjectId `json:"-" bson:"hub"` // contains filtered or unexported fields }
type SensorJSON ¶
SensorJSON is a wrapper to expose the relation with hub
Click to show internal directories.
Click to hide internal directories.