| New file | 
 |  |  | 
 |  |  | package com.dy.rtuMw.server.forMs; | 
 |  |  |  | 
 |  |  | import com.dy.common.queue.Node; | 
 |  |  | import com.dy.common.queue.Queue; | 
 |  |  | import com.dy.rtuMw.server.ServerProperties; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @Author: liurunyu | 
 |  |  |  * @Date: 2024/7/31 18:47 | 
 |  |  |  * @Description | 
 |  |  |  */ | 
 |  |  | public class SendMsCache { | 
 |  |  |  | 
 |  |  |     //TCP下行命令缓存队列 | 
 |  |  |     private static Queue cacheQueue = new Queue("SendMsCache") ; | 
 |  |  |  | 
 |  |  |     private static SendMsCache instance = new SendMsCache() ; | 
 |  |  |  | 
 |  |  |     private SendMsCache(){ | 
 |  |  |         cacheQueue.setLimit(ServerProperties.cacheUpDownDataWarnCount, ServerProperties.cacheUpDownDataMaxCount); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static SendMsCache getInstance(){ | 
 |  |  |         return instance ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 缓存命令 | 
 |  |  |      * @param ms | 
 |  |  |      * @throws Exception | 
 |  |  |      */ | 
 |  |  |     public static void cacheMs(String ms) throws Exception{ | 
 |  |  |         cacheQueue.pushTail(new MsObj4Ding(ms)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到第一个节点 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public static Node getFirstQueueNode(){ | 
 |  |  |         return cacheQueue.getFirstNode() ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到最后一个节点 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public static Node getLastQueueNode(){ | 
 |  |  |         return cacheQueue.getLastNode() ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 移除节点 | 
 |  |  |      * @param node | 
 |  |  |      */ | 
 |  |  |     public static void removeNode(Node node){ | 
 |  |  |         cacheQueue.remove(node); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 缓存的节点数 | 
 |  |  |      * @Return 缓存节点数 | 
 |  |  |      */ | 
 |  |  |     public static Integer size(){ | 
 |  |  |         return cacheQueue.size() ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |