2024-11-22 16:41:04 +08:00
|
|
|
package diagram
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
2024-11-27 09:11:48 +08:00
|
|
|
"fmt"
|
2024-11-22 16:41:04 +08:00
|
|
|
"sync"
|
|
|
|
|
|
|
|
|
|
cmap "github.com/orcaman/concurrent-map/v2"
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-27 15:41:22 +08:00
|
|
|
// DiagramsOverview define struct of storage all circuit diagram data
|
2024-11-22 16:41:04 +08:00
|
|
|
var DiagramsOverview sync.Map
|
|
|
|
|
|
2024-11-27 15:41:22 +08:00
|
|
|
// GetComponentMap define func of get circuit diagram data by global uuid
|
|
|
|
|
func GetComponentMap(uuid string) (*cmap.ConcurrentMap[string, any], error) {
|
|
|
|
|
value, ok := DiagramsOverview.Load(uuid)
|
2024-11-22 16:41:04 +08:00
|
|
|
if !ok {
|
2024-11-27 15:41:22 +08:00
|
|
|
return nil, fmt.Errorf("can not find graph by global uuid:%s", uuid)
|
2024-11-22 16:41:04 +08:00
|
|
|
}
|
|
|
|
|
paramsMap, ok := value.(*cmap.ConcurrentMap[string, any])
|
|
|
|
|
if !ok {
|
2024-11-27 09:11:48 +08:00
|
|
|
return nil, errors.New("convert to component map struct failed")
|
2024-11-22 16:41:04 +08:00
|
|
|
}
|
|
|
|
|
return paramsMap, nil
|
|
|
|
|
}
|