Documentation ¶
Index ¶
- Variables
- func GetUniqueHash(deviceId, integration string) string
- type Database
- func (d *Database) DeleteGraphValue(graphToDelete DeviceGraph) (updated bool, err error)
- func (d *Database) GetAllAutomatedGraphs() (automatedGraphs []DeviceGraph)
- func (d *Database) GetAllAutomatedTimeTables() []TimeTable
- func (d *Database) GetAllDeviceGraphs() (graphs []DeviceGraph)
- func (d *Database) GetAllDevices() (devices []Device)
- func (d *Database) GetAllGraphs() (graphs []UniqueHashGraphs)
- func (d *Database) GetAllTimeTables() []TimeTable
- func (d *Database) GetAutomatedGraphs(uniqueId, integration, status string) (graphResults []DeviceGraph)
- func (d *Database) GetAutomatedTimeTableEntry(timeBlock string) []Device
- func (d *Database) GetDevice(uniqueId, integration string) (device Device)
- func (d *Database) GetDeviceByHash(uniqueHash string) (device Device)
- func (d *Database) GetDeviceGraphValues(fromUniqueHash string) (deviceGraphs UniqueHashGraphs, err error)
- func (d *Database) GetDeviceValues(uniqueHash string) (device Device, err error)
- func (d *Database) GetGraphByRelationship(...) (graph DeviceGraph, err error)
- func (d *Database) GetGraphs(uniqueId, integration string) (graphResults []DeviceGraph)
- func (d *Database) GetMemoryData() (bool, []byte)
- func (d *Database) GetTimeTableValues(timeBlock string) (times TimeTable, err error)
- func (d *Database) ImproveEnergyEfficiency(amount int) bool
- func (d *Database) PutDeviceGraphValues(graphs UniqueHashGraphs) (err error)
- func (d *Database) PutDeviceValues(device Device) (err error)
- func (d *Database) PutTimeTableValues(timeTable string, timeEntries TimeTable) (err error)
- func (d *Database) RecreateGraphBucket() error
- func (d *Database) RecreateTimeBucket() error
- func (d *Database) ResetDeviceGraph() bool
- func (d *Database) RetrieveDataFromDeviceGraphByWeight(weightAmount int) (graphResults []DeviceGraph)
- func (d *Database) SetDevice(data Device) (inserted bool)
- func (d *Database) SetGraph(graphData DeviceGraph) bool
- func (d *Database) StoreMemoryData(jsonBrain interface{}) bool
- func (d *Database) UpdateEfficiencyTime(uniquehash string, updateBy int) bool
- func (d *Database) UpdateGraphTableWithAutomated(graphData DeviceGraph) bool
- func (d *Database) UpdateGraphWeight(graphData DeviceGraph, amount int) bool
- func (d *Database) UpdateWeightsForTimeTable(timeTable string, timeDevices []Device) bool
- type Device
- type DeviceGraph
- type TimeBlocks
- type TimeTable
- type UniqueHashGraphs
Constants ¶
This section is empty.
Variables ¶
var ( MemoryBucket = []byte("memory") DeviceBucket = []byte("device") DeviceGraphBucket = []byte("deviceGraph") TimeTableBucket = []byte("timeChain") )
Functions ¶
func GetUniqueHash ¶
GetUniqueHash will return the unique hash created from the deviceid and integration
Types ¶
type Database ¶
var MartianData Database
func (*Database) DeleteGraphValue ¶
func (d *Database) DeleteGraphValue(graphToDelete DeviceGraph) (updated bool, err error)
DeleteGraphValue will remove the graph provided
func (*Database) GetAllAutomatedGraphs ¶
func (d *Database) GetAllAutomatedGraphs() (automatedGraphs []DeviceGraph)
GetAllAutomatedGraphs will return all of the automated graphs
func (*Database) GetAllAutomatedTimeTables ¶
GetAllTimeTables will return all of the timetables
func (*Database) GetAllDeviceGraphs ¶
func (d *Database) GetAllDeviceGraphs() (graphs []DeviceGraph)
GetAllDeviceGraphss
func (*Database) GetAllDevices ¶
GetAllDevices
func (*Database) GetAllGraphs ¶
func (d *Database) GetAllGraphs() (graphs []UniqueHashGraphs)
GetAllDeviceGraphss
func (*Database) GetAllTimeTables ¶
GetAllTimeTables will return all of the timetables
func (*Database) GetAutomatedGraphs ¶
func (d *Database) GetAutomatedGraphs(uniqueId, integration, status string) (graphResults []DeviceGraph)
GetAutomatedGraphs will return all of the graphs that are automated for the provided uniqueid and integration
func (*Database) GetAutomatedTimeTableEntry ¶
GetTimeTableEntry will return the devices that are available for that time
func (*Database) GetDevice ¶
GetDevice will return the device row for the provided uniqueId and integration
func (*Database) GetDeviceByHash ¶
GetDeviceByHash will return the device row for the provided uniqueId and integration
func (*Database) GetDeviceGraphValues ¶
func (d *Database) GetDeviceGraphValues(fromUniqueHash string) (deviceGraphs UniqueHashGraphs, err error)
GetDeviceGraphValues
func (*Database) GetDeviceValues ¶
GetDeviceValues
func (*Database) GetGraphByRelationship ¶
func (d *Database) GetGraphByRelationship(firstId, firstIntegration, firstStatus, lastId, lastIntegration, lastStatus string) (graph DeviceGraph, err error)
GetGraphByRelationship gets the graph by the first and last pieces provided
func (*Database) GetGraphs ¶
func (d *Database) GetGraphs(uniqueId, integration string) (graphResults []DeviceGraph)
GetGraphs will return all of the graphs for the provided uniqueid and integration
func (*Database) GetMemoryData ¶
GetMemoryData will grab the memory data from the database
returns a boolean on if the value exists along with the value
func (*Database) GetTimeTableValues ¶
GetTimeTableValues
func (*Database) ImproveEnergyEfficiency ¶
ImproveEnergyEfficiencyDaily will decrease the time that devices are on by a minute per day
func (*Database) PutDeviceGraphValues ¶
func (d *Database) PutDeviceGraphValues(graphs UniqueHashGraphs) (err error)
PutDeviceGraphValues
func (*Database) PutDeviceValues ¶
PutDeviceValues
func (*Database) PutTimeTableValues ¶
PutTimeTableValues
func (*Database) RecreateGraphBucket ¶
func (*Database) RecreateTimeBucket ¶
func (*Database) ResetDeviceGraph ¶
ResetDeviceGraph will delete all unautomated entries
func (*Database) RetrieveDataFromDeviceGraphByWeight ¶
func (d *Database) RetrieveDataFromDeviceGraphByWeight(weightAmount int) (graphResults []DeviceGraph)
RetrieveDataFromDeviceGraph grabs data from the device graph above the specified weight amount
func (*Database) SetDevice ¶
SetDevice will set the device in the database, will return a false if it was unable to insert or device already exists
func (*Database) SetGraph ¶
func (d *Database) SetGraph(graphData DeviceGraph) bool
SetGraph Will set the graph for the first time
func (*Database) StoreMemoryData ¶
StoreMemoryData will store the memory data in the bolt database
returns a boolean on storage success
func (*Database) UpdateEfficiencyTime ¶
UpdateEfficiencyTime will update the efficiency time in the device table for the provided hash by provided amount
func (*Database) UpdateGraphTableWithAutomated ¶
func (d *Database) UpdateGraphTableWithAutomated(graphData DeviceGraph) bool
UpdateGraphTableWithAutomated will set entries as automated
func (*Database) UpdateGraphWeight ¶
func (d *Database) UpdateGraphWeight(graphData DeviceGraph, amount int) bool
UpdateGraphWeight will update the weight on the graph entry
type Device ¶
type Device struct { DeviceId string `json:"deviceId"` UniqueHash string `json:"uniqueHash"` Name string `json:"name,omitempty"` Label string `json:"label,omitempty"` Type string `json:"type,omitempty"` Integration string `json:"integration,omitempty"` EnergyEfficiencyMinutes int `json:"energyEfficiencyMinutes,omitempty"` }
type DeviceGraph ¶
type DeviceGraph struct { FromUniqueHash string `json:"fromUniqueHash"` FromStatus string `json:"fromStatus"` ToUniqueHash string `json:"toUniqueHash"` ToStatus string `json:"toStatus"` Weight int `json:"weight"` Automated bool `json:"automated"` TimeAutomated bool `json:"timeAutomated"` }
func AssembleDeviceGraph ¶
func AssembleDeviceGraph(fromId, fromIntegration, fromStatus, toId, toIntegration, toStatus string) (deviceGraph DeviceGraph, sameDevice bool)
AssembleDeviceGraph will create the graph sructure required to insert into table, will return a boolean on if the device_graph has the same device in the from->to positions
type TimeBlocks ¶
type TimeTable ¶
type TimeTable struct {
Times []TimeBlocks `json:"timeBlocks"`
}
type UniqueHashGraphs ¶
type UniqueHashGraphs struct {
Graphs []DeviceGraph `json:"graphs"`
}