|
@@ -28,13 +28,13 @@ type (
|
|
|
|
|
|
var (
|
|
var (
|
|
DeviceIntervalTable = map[string]time.Duration{
|
|
DeviceIntervalTable = map[string]time.Duration{
|
|
- DEVICE_UF: 1 * time.Second,
|
|
|
|
- DEVICE_MF: 1 * time.Second,
|
|
|
|
- DEVICE_NF: 1 * time.Second,
|
|
|
|
- DEVICE_RO: 1 * time.Second,
|
|
|
|
- DEVICE_VALVE: 1 * time.Second,
|
|
|
|
- DEVICE_PUMP: 1 * time.Second,
|
|
|
|
- DEVICE_CHEST: 1 * time.Second,
|
|
|
|
|
|
+ DEVICE_UF: 60 * time.Second,
|
|
|
|
+ DEVICE_MF: 60 * time.Second,
|
|
|
|
+ DEVICE_NF: 60 * time.Second,
|
|
|
|
+ DEVICE_RO: 60 * time.Second,
|
|
|
|
+ DEVICE_VALVE: 60 * time.Second,
|
|
|
|
+ DEVICE_PUMP: 60 * time.Second,
|
|
|
|
+ DEVICE_CHEST: 60 * time.Second,
|
|
}
|
|
}
|
|
|
|
|
|
DeviceHandlerTable = map[string]func(ctx context.Context, task *job.Task, technologyName string) error{
|
|
DeviceHandlerTable = map[string]func(ctx context.Context, task *job.Task, technologyName string) error{
|
|
@@ -59,22 +59,27 @@ var (
|
|
)
|
|
)
|
|
|
|
|
|
func (t DeviceBindCacheMap) GetCache(technologyName string) []model.DcDeviceBind {
|
|
func (t DeviceBindCacheMap) GetCache(technologyName string) []model.DcDeviceBind {
|
|
- return nil
|
|
|
|
- //if cache, ok := t[technologyName]; ok {
|
|
|
|
- // if time.Now().After(cache.Expire) {
|
|
|
|
- // t[technologyName] = DeviceBindCache{}
|
|
|
|
- // return nil
|
|
|
|
- // }
|
|
|
|
- // return cache.Data
|
|
|
|
- //} else {
|
|
|
|
- // return nil
|
|
|
|
- //}
|
|
|
|
|
|
+ if cache, ok := t[technologyName]; ok {
|
|
|
|
+ if time.Now().After(cache.Expire) {
|
|
|
|
+ t[technologyName] = DeviceBindCache{}
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if len(cache.Data) > 0 {
|
|
|
|
+ for _, datum := range cache.Data {
|
|
|
|
+ datum.Items.ClearValues()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return cache.Data
|
|
|
|
+ } else {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
func (t DeviceBindCacheMap) SetCache(technologyName string, data []model.DcDeviceBind, expire time.Time) {
|
|
func (t DeviceBindCacheMap) SetCache(technologyName string, data []model.DcDeviceBind, expire time.Time) {
|
|
- return
|
|
|
|
- //t[technologyName] = DeviceBindCache{
|
|
|
|
- // Expire: expire,
|
|
|
|
- // Data: data,
|
|
|
|
- //}
|
|
|
|
|
|
+ t[technologyName] = DeviceBindCache{
|
|
|
|
+ Expire: expire,
|
|
|
|
+ Data: data,
|
|
|
|
+ }
|
|
}
|
|
}
|