Documentation ¶
Overview ¶
there are three main commands to the cache module: read, write and command first two are states commands are events, so we need a queue for them instead of a single value
First component needs to be registered so cache will pull its value at the next update cycle Reading is just returns last value of the component Reading affects update frequency: more often reads increase frequency, no reads decrease frequency Writing is just store required value to a cache, it will be written at the next update cycle
Index ¶
Constants ¶
const ( SOffline State = 0 SOnline = 1 SError = 2 // should be treated the same way as offline, but it is when slave firmware behaves incorrectly )
const ( WSUninitialized WriteState = 0 WSPending = 1 WSWritten = 2 WSFailed = 3 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
"object"
func (*Cache) GetCached ¶
func (c *Cache) GetCached(uid RFModel.UID, fno RFModel.FuncNo) (value string, state State, timestamp time.Time)
GetCached return data immediately, no async operations before answer should never panic in case device is offline function will return default value ("")
func (*Cache) RegisterItem ¶
RegisterItem put requested uid/fno pair for read update routine
type DeviceKey ¶
type DeviceKey RFModel.DeviceAddress
type DeviceState ¶
type DeviceState struct {
State State
}
type Key ¶
type Key RFModel.UnitFunctionKey
type Value ¶
type Value struct { ReadValue string LastUpdate time.Time // when it was updated from the unit last time LastRequest time.Time // when it was read from cache last time AccessPeriod time.Duration // update if LastUpdate + AccessPeriod is bigger than time.Now() WriteValue string WriteState WriteState DeviceName string UnitName string FunctionName string Readable bool Writeable bool }
Value — either read value, or write value. One item per function
type WriteState ¶
type WriteState byte