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.
38 lines
690 B
Go
38 lines
690 B
Go
package device
|
|
|
|
import (
|
|
"FRMS/internal/pkg/controller"
|
|
pb "FRMS/internal/pkg/grpc"
|
|
"FRMS/internal/pkg/sensor"
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
/*
|
|
Returns the correct manager for sensor/controller
|
|
*/
|
|
|
|
func NewSubManager(device *pb.Device) (SubManager, error) {
|
|
// returns correct device manager by ID
|
|
var m SubManager
|
|
var err error
|
|
addr := device.GetAddr()
|
|
switch addr {
|
|
case 97:
|
|
// DO
|
|
m = sensor.NewDOManager(device)
|
|
case 99:
|
|
// pH
|
|
m = sensor.NewPHManager(device)
|
|
case 102:
|
|
// RTD
|
|
m = sensor.NewRTDManager(device)
|
|
case 256:
|
|
// PWM
|
|
m = controller.NewPWMManager(device)
|
|
default:
|
|
err = errors.New(fmt.Sprintf("Error: device id %d unrecognized!", addr))
|
|
}
|
|
return m, err
|
|
}
|