Documentation ¶
Index ¶
- Variables
- func Debug(debugMode bool)
- func Exists(name string) (err error)
- func GetFamilies() (families []string)
- type Database
- func (d *Database) AddName(table string, name string) (deviceID string, err error)
- func (d *Database) AddPrediction(timestamp int64, aidata []models.LocationPrediction) (err error)
- func (d *Database) AddSensor(s models.SensorData) (err error)
- func (d *Database) Close() (err error)
- func (d *Database) Columns() (columns []string, err error)
- func (d *Database) Debug(debugMode bool)
- func (d *Database) Dump() (err error)
- func (d *Database) Get(key string, v interface{}) (err error)
- func (d *Database) GetAllForClassification() (s []models.SensorData, err error)
- func (d *Database) GetAllFromPreparedQuery(query string, args ...interface{}) (s []models.SensorData, err error)
- func (d *Database) GetAllFromQuery(query string) (s []models.SensorData, err error)
- func (d *Database) GetAllNotForClassification() (s []models.SensorData, err error)
- func (d *Database) GetDeviceCounts() (counts map[string]int, err error)
- func (d *Database) GetDeviceFirstTime() (firstTime map[string]time.Time, err error)
- func (d *Database) GetDevices() (devices []string, err error)
- func (d *Database) GetID(table string, name string) (id string, err error)
- func (d *Database) GetIDToName(table string) (idToName map[string]string, err error)
- func (d *Database) GetKeys(keylike string) (keys []string, err error)
- func (d *Database) GetLastSensorTimestamp() (timestamp int64, err error)
- func (d *Database) GetLatest(device string) (s models.SensorData, err error)
- func (d *Database) GetLocationCounts() (counts map[string]int, err error)
- func (d *Database) GetLocations() (locations []string, err error)
- func (d *Database) GetPrediction(timestamp int64) (aidata []models.LocationPrediction, err error)
- func (d *Database) GetSensorFromGreaterTime(timeBlockInMilliseconds int64) (sensors []models.SensorData, err error)
- func (d *Database) GetSensorFromTime(timestamp interface{}) (s models.SensorData, err error)
- func (d *Database) MakeTables() (err error)
- func (d *Database) NumDevices() (num int, err error)
- func (d *Database) Set(key string, value interface{}) (err error)
- func (d *Database) SetGPS(p models.SensorData) (err error)
- func (d *Database) TotalLearnedCount() (count int64, err error)
Constants ¶
This section is empty.
Variables ¶
var DataFolder = "."
DataFolder is set to where you want each Sqlite3 database to be stored
var DebugMode bool
Functions ¶
func GetFamilies ¶
func GetFamilies() (families []string)
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is the main structure for holding the information pertaining to the name of the database.
func (*Database) AddName ¶
AddName will add a name to a table (devices/locations) and return the ID. If the device already exists it will just return it.
func (*Database) AddPrediction ¶
func (d *Database) AddPrediction(timestamp int64, aidata []models.LocationPrediction) (err error)
AddPrediction will insert or update a prediction in the database
func (*Database) AddSensor ¶
func (d *Database) AddSensor(s models.SensorData) (err error)
AddSensor will insert a sensor data into the database TODO: AddSensor should be special case of AddSensors
func (*Database) GetAllForClassification ¶
func (d *Database) GetAllForClassification() (s []models.SensorData, err error)
GetAllForClassification will return a sensor data for classifying
func (*Database) GetAllFromPreparedQuery ¶
func (d *Database) GetAllFromPreparedQuery(query string, args ...interface{}) (s []models.SensorData, err error)
GetAllFromPreparedQuery
func (*Database) GetAllFromQuery ¶
func (d *Database) GetAllFromQuery(query string) (s []models.SensorData, err error)
func (*Database) GetAllNotForClassification ¶
func (d *Database) GetAllNotForClassification() (s []models.SensorData, err error)
GetAllForClassification will return a sensor data for classifying
func (*Database) GetDeviceCounts ¶
func (*Database) GetDeviceFirstTime ¶
func (*Database) GetDevices ¶
func (*Database) GetID ¶
GetID will get the ID of an element in a table (devices/locations) and return an error if it doesn't exist
func (*Database) GetIDToName ¶
func (*Database) GetLastSensorTimestamp ¶
Get will retrieve the value associated with a key.
func (*Database) GetLatest ¶
func (d *Database) GetLatest(device string) (s models.SensorData, err error)
GetLatest will return a sensor data for classifying
func (*Database) GetLocationCounts ¶
func (*Database) GetLocations ¶
func (*Database) GetPrediction ¶
func (d *Database) GetPrediction(timestamp int64) (aidata []models.LocationPrediction, err error)
GetPrediction will retrieve models.LocationAnalysis associated with that timestamp
func (*Database) GetSensorFromGreaterTime ¶
func (d *Database) GetSensorFromGreaterTime(timeBlockInMilliseconds int64) (sensors []models.SensorData, err error)
GetSensorFromGreaterTime will return a sensor data for a given timeframe
func (*Database) GetSensorFromTime ¶
func (d *Database) GetSensorFromTime(timestamp interface{}) (s models.SensorData, err error)
GetSensorFromTime will return a sensor data for a given timestamp
func (*Database) MakeTables ¶
MakeTables creates two tables, a `keystore` table:
KEY (TEXT) VALUE (TEXT)
and also a `sensors` table for the sensor data:
TIMESTAMP (INTEGER) DEVICE(TEXT) LOCATION(TEXT)
the sensor table will dynamically create more columns as new types of sensor data are inserted. The LOCATION column is optional and only used for learning/classification.
func (*Database) NumDevices ¶
func (*Database) SetGPS ¶
func (d *Database) SetGPS(p models.SensorData) (err error)
SetGPS will set a GPS value in the GPS database
func (*Database) TotalLearnedCount ¶
Get will retrieve the value associated with a key.