Cache

package
v0.0.0-...-cdf6177 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

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

View Source
const (
	SOffline State = 0
	SOnline        = 1
	SError         = 2 // should be treated the same way as offline, but it is when slave firmware behaves incorrectly
)
View Source
const (
	WSUninitialized WriteState = 0
	WSPending                  = 1
	WSWritten                  = 2
	WSFailed                   = 3
)

Variables

This section is empty.

Functions

func Init

func Init(self *Cache, rf *RFModel.RFModel, output OutsideInterface.Interface, devicesFile string)

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

func (c *Cache) RegisterItem(uid RFModel.UID, fno RFModel.FuncNo)

RegisterItem put requested uid/fno pair for read update routine

func (*Cache) SetCached

func (c *Cache) SetCached(uid RFModel.UID, fno RFModel.FuncNo, value string)

SetCached return immediately

type DeviceKey

type DeviceKey RFModel.DeviceAddress

type DeviceState

type DeviceState struct {
	State State
}

type Key

type State

type State byte

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

Jump to

Keyboard shortcuts

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