You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package sensor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Manager struct {
|
|
|
|
Addr int
|
|
|
|
Type string
|
|
|
|
Status bool
|
|
|
|
//I2C I2CMonitor
|
|
|
|
mu sync.Mutex
|
|
|
|
}
|
|
|
|
|
|
|
|
//type I2CMonitor interface {
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
func (m *Manager) GetStatus() bool{
|
|
|
|
m.mu.Lock()
|
|
|
|
defer m.mu.Unlock()
|
|
|
|
return m.Status
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Manager) GetType() string{
|
|
|
|
m.mu.Lock()
|
|
|
|
defer m.mu.Unlock()
|
|
|
|
return m.Type
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSensorManager(addr int) *Manager {
|
|
|
|
return &Manager{Addr:addr}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Manager) Start() {
|
|
|
|
types := map[int]string{97:"DO Sensor",99:"pH Sensor",102:"RTD Sensor"}
|
|
|
|
m.Type = types[m.Addr]
|
|
|
|
m.Status = true
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|