robocar-camera/vendor/github.com/cyrilix/robocar-base/mode/mode.go

38 lines
502 B
Go

package mode
import (
"log"
)
type DriveMode int
const (
DriveModeInvalid = -1
DriveModeUser = iota
DriveModePilot
)
func ToString(mode DriveMode) string {
switch mode {
case DriveModeUser:
return "user"
case DriveModePilot:
return "pilot"
default:
return ""
}
}
func ParseString(val string) DriveMode {
switch val {
case "user":
return DriveModeUser
case "pilot":
return DriveModePilot
default:
log.Printf("invalid DriveMode: %v", val)
return DriveModeInvalid
}
}