w1

package
v0.0.0-...-5935107 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SENSOR_PATH_SUFFIX = "/w1_slave"
)

Variables

View Source
var (
	SENSOR_PATH_PREFIX = "/sys/bus/w1/devices/" // this needs to be variable in order to enable the main prgramm to set the w1 device path

)

Functions

func IncrementFailLookupCount

func IncrementFailLookupCount()

func IncrementSuccessLookupCount

func IncrementSuccessLookupCount()

func LoopedTemperatureLookupWorker

func LoopedTemperatureLookupWorker(request chan (TemperatureLookupJob), responseChan chan (Temperature), interrupt chan (bool), logDestination *io.Writer, logMutex *sync.Mutex)

implements simple TemperatureLookupWorker

Types

type LookupStat

type LookupStat struct {
	Total   int
	Success int
	Failed  int
}

func GetLookupStats

func GetLookupStats() (stats LookupStat)

type Temperature

type Temperature struct {
	// contains filtered or unexported fields
}

func First

func First(replicas ...TemperatureLookup) *Temperature

*

  • The replicated TemperatureLookup creates a chanel, spawns the replicated TemperatureLookups and
  • returns the first valid Temperature struct that comes in from the chanel.
  • If TemperatureLookups time out, empty Temperature struct is returned.
  • @param replicas slice of TemperaturLookup functions
  • @return pointer to a valid or an empty Temperature

func NewTemperature

func NewTemperature(sensorId, logic string) *Temperature

func SensorTemperaturGenerator

func SensorTemperaturGenerator(sensorId, sensorLogic string, logDestination *io.Writer, logMutex *sync.Mutex) (data Temperature)

implements TemperaturLookup since parses and validates the temperature data for this sensor object

func (*Temperature) AddValue

func (t *Temperature) AddValue(delta int)

func (*Temperature) GetSensorId

func (t *Temperature) GetSensorId() string

func (*Temperature) GetSensorLogic

func (t *Temperature) GetSensorLogic() string

func (*Temperature) GetValue

func (t *Temperature) GetValue() int

func (*Temperature) IsValid

func (t *Temperature) IsValid() bool

func (*Temperature) SetLogic

func (t *Temperature) SetLogic(logic string)

type TemperatureLookup

type TemperatureLookup func() Temperature

*

  • A function that returns a Temperature struct.

func Init_Sensor

func Init_Sensor(sensorId string, logDestination *io.Writer, logMutex *sync.Mutex) TemperatureLookup

*

  • Initializes a temperature sensor by implementing the TemperatureLookup function
  • @return TemperatureLookup function which creates a complete Temperatur object from the sensor

type TemperatureLookupJob

type TemperatureLookupJob struct {
	SensorId, SensorLogic string
}

type TemperatureLookupWorker

type TemperatureLookupWorker func(routine TemperatureLookup, request chan (TemperatureLookupJob), interrupt chan (bool))

Jump to

Keyboard shortcuts

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