package com.zy.core.cache; import com.core.common.Cools; import com.zy.core.model.protocol.RgvRunProtocol; import com.zy.core.model.protocol.RgvTaskProtocol; import java.util.concurrent.ConcurrentHashMap; /** * Created by IX on 2025/02/21 */ public class RgvRunCache { // 本地缓存,键为 currentPosition,值为 DeviceStatus private static final ConcurrentHashMap cache = new ConcurrentHashMap<>(); /** * 更新设备状态 */ public static void updateRgvStatus(RgvRunProtocol status) { try { cache.put(status.getDev(), status); } finally { } } /** * 获取设备状态 */ public static RgvRunProtocol getRgvRun() { try { RgvRunProtocol rgv = cache.get("RGV"); if (Cools.isEmpty(rgv)){ rgv = new RgvRunProtocol(); } return rgv; } finally { } } /** * 获取设备状态 */ public static RgvRunProtocol getRgvStatus(String dev) { try { return cache.get(dev); } finally { } } /** * 获取所有设备状态 */ public static ConcurrentHashMap getAllRgvStatus() { try { return new ConcurrentHashMap<>(cache); // 返回副本 } finally { } } }