2018-04-29 09:41:14 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2018-07-02 08:44:53 +00:00
|
|
|
b64 "encoding/base64"
|
2018-04-29 09:41:14 +00:00
|
|
|
"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"
|
2018-07-02 08:44:53 +00:00
|
|
|
|
2018-04-29 09:41:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var SensorServiceType = reflect.TypeOf((*SensorService)(nil))
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cdr.RegisterType(SensorServiceType)
|
|
|
|
}
|
|
|
|
|
|
|
|
type SensorService struct {
|
|
|
|
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
|
|
|
|
|
|
|
|
ContainerService *ContainerService `annotation:"@Inject()"`
|
2018-07-02 08:44:53 +00:00
|
|
|
SensorConfigService *SensorConfigService `annotation:"@Inject()"`
|
2018-04-29 09:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
2018-07-02 08:44:53 +00:00
|
|
|
// base64 decode
|
|
|
|
|
|
|
|
bufByte, err := b64.StdEncoding.DecodeString(sensorConfigBase64)
|
|
|
|
|
|
|
|
if nil == bufByte || nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
s.SensorConfigService.AddConfig(string(bufByte[:]))
|
|
|
|
|
2018-04-29 09:41:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SensorService) RemoveSensor(sensorConfigID string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SensorService) UpdateSensor(id int64) error {
|
|
|
|
return nil
|
|
|
|
}
|