probe/service/SensorService.go
2018-07-02 21:22:45 +09:00

87 lines
1.7 KiB
Go

package service
import (
"reflect"
cda "git.loafle.net/commons/di-go/annotation"
cdr "git.loafle.net/commons/di-go/registry"
// For annotation
_ "git.loafle.net/overflow/commons-go/core/annotation"
"encoding/base64"
)
var SensorServiceType = reflect.TypeOf((*SensorService)(nil))
func init() {
cdr.RegisterType(SensorServiceType)
}
type SensorService struct {
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
ContainerService *ContainerService `annotation:"@Inject()"`
SensorConfigService *SensorConfigService `annotation:"@Inject()"`
}
func (s *SensorService) InitService() error {
return nil
}
func (s *SensorService) StartService() error {
return nil
}
func (s *SensorService) StopService() {
}
func (s *SensorService) DestroyService() {
}
func (s *SensorService) StartSensor(id int64) error {
return nil
}
func (s *SensorService) StopSensor(id int64) error {
return nil
}
func (s *SensorService) AddSensor(sensorConfigBase64 string) error {
// base64 decode
//ddd := []byte(sensorConfigBase64)
//ff := make([]byte,len(ddd))
//fmt.Println(ddd)
bufByte, err := base64.StdEncoding.DecodeString(sensorConfigBase64)
//bufByte := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(sensorConfigBase64))
//bufByte, err := b64.RawStdEncoding.DecodeString(sensorConfigBase64)
//n, err := b64.StdEncoding.Decode(ff, ddd)
//fmt.Println(n)
if nil == bufByte || nil != err {
return err
}
//b, _ := ioutil.ReadAll(bufByte)
s.SensorConfigService.AddConfig(string(bufByte))
return nil
}
func (s *SensorService) RemoveSensor(sensorConfigID string) error {
return nil
}
func (s *SensorService) UpdateSensor(id int64) error {
return nil
}