From 49e90e5de2e7166e74e26102dff9064b933fc5fd Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 05 九月 2023 16:00:27 +0800 Subject: [PATCH] 工序的生产进度存表 --- service/plc.go | 39 --------------------------------------- 1 files changed, 0 insertions(+), 39 deletions(-) diff --git a/service/plc.go b/service/plc.go index 74ed5dc..090b4bc 100644 --- a/service/plc.go +++ b/service/plc.go @@ -8,7 +8,6 @@ "encoding/binary" "errors" "fmt" - "sync" ) func PlcRead(plcConfig *model.DevicePlc, fieldType constvar.PlcStartAddressType) (val interface{}, err error) { @@ -85,42 +84,4 @@ } logx.Infof("plc write ok, address: %v, value: %v, result: %v", startAddress, value, result) return -} - -type CacheStore struct { - cache map[string]interface{} - mu sync.Mutex -} - -var defaultCacheStore *CacheStore - -func init() { - defaultCacheStore = newCacheManager() -} -func newCacheManager() *CacheStore { - return &CacheStore{ - cache: make(map[string]interface{}), - } -} - -func (cm *CacheStore) Get(key string) (interface{}, bool) { - cm.mu.Lock() - defer cm.mu.Unlock() - - conn, ok := cm.cache[key] - return conn, ok -} - -func (cm *CacheStore) Add(key string, value interface{}) { - cm.mu.Lock() - defer cm.mu.Unlock() - cm.cache[key] = value -} - -func PlcCacheGet(key string) (interface{}, bool) { - return defaultCacheStore.Get(key) -} - -func PlcCacheSet(key string, value interface{}) { - defaultCacheStore.Add(key, value) } -- Gitblit v1.8.0