geiger.go 1.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
//
// geiger.go
// Copyright (C) 2017 kevin <kevin@ie.suberic.net>
//
// Distributed under terms of the GPL license.
//

package geiger

Kevin Lyda's avatar
Kevin Lyda committed
10
11
import "time"

12
13
14
15
16
17
18
19
20
21
22
// New creates a new Counter instance
func New(c Config) (Counter, error) {
	switch c.Model {
	case "gqgmc":
		return NewGQGMC(c)
	}
	return nil, nil
}

// Counter is an interface for Geiger Counters
type Counter interface {
Kevin Lyda's avatar
Kevin Lyda committed
23
	Clear() error
Kevin Lyda's avatar
Kevin Lyda committed
24
25
	Model() string
	Version() string
Kevin Lyda's avatar
Kevin Lyda committed
26
	Serial() string
Kevin Lyda's avatar
Kevin Lyda committed
27
28
	GetCPM() (uint16, error)
	GetCPS() (uint16, error)
Kevin Lyda's avatar
Kevin Lyda committed
29
	Volts() (int16, error)
Kevin Lyda's avatar
Kevin Lyda committed
30
31
32
33
34
	GetHistoryData()
	TurnOnCPS() error
	TurnOffCPS() error
	GetAutoCPS() (uint16, error)
	TurnOffPower()
Kevin Lyda's avatar
Kevin Lyda committed
35
	GetConfiguration() error
Kevin Lyda's avatar
Kevin Lyda committed
36
	SetConfiguration()
Kevin Lyda's avatar
Kevin Lyda committed
37
38
	SetTime(time.Time)
	GetTime() (time.Time, error)
Kevin Lyda's avatar
Kevin Lyda committed
39
40
	GetTemp() (float64, error)
	GetGyro() (int16, int16, int16, error)
Kevin Lyda's avatar
Kevin Lyda committed
41
42
	FactoryReset()
	Reboot()
43
44
45
46
47
48
49
50
51
52
53
54
55
}

// Config contain the configuration for a Geiger Counter
type Config struct {
	Model   string
	Device  string
	Options map[string]string
}

// Reading contains a single geiger reading
type Reading struct {
	CPM float64
}