liurunyu
2023-11-22 429f9d85eddbb07081c149d7156964337ba688aa
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCache.java
File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCach.java
@@ -10,18 +10,18 @@
/**
 * 非线程安全的,只能在单线程中运行
 */
public class TcpDownCommandCach {
public class TcpDownCommandCache {
   
   //TCP下行命令缓存队列
   private static Queue cachQueue = new Queue("tcpDownComandQueue") ;
   private static Queue cacheQueue = new Queue("tcpDownCommandQueue") ;
   
   private static TcpDownCommandCach instance = new TcpDownCommandCach() ;
   private static TcpDownCommandCache instance = new TcpDownCommandCache() ;
   
   private TcpDownCommandCach(){
      cachQueue.setLimit(990000, 1000000);
   private TcpDownCommandCache(){
      cacheQueue.setLimit(ServerProperties.cacheUpDownDataWarnCount, ServerProperties.cacheUpDownDataMaxCount);
   }
   
   public static TcpDownCommandCach getInstance(){
   public static TcpDownCommandCache getInstance(){
      return instance ;
   }
@@ -30,16 +30,16 @@
    * @param result
    * @throws Exception
    */
   public static void cachCommand(MidResultToRtu result) throws Exception{
   public static void cacheCommand(MidResultToRtu result) throws Exception{
      if(result != null){
         if(result.maxSendTimes == null){
            //设置最大发送次数
            result.maxSendTimes = ServerProperties.downComandMaxResendTimes ;
         }
         if(result.isSendFirst){
            cachQueue.pushHead(new TcpDownCommandObj(result));
            cacheQueue.pushHead(new TcpDownCommandObj(result));
         }else{
            cachQueue.pushTail(new TcpDownCommandObj(result));
            cacheQueue.pushTail(new TcpDownCommandObj(result));
         }
      }
   }
@@ -52,7 +52,7 @@
   public static MidResultToRtu matchFromHead(MidResultFromRtu rsFromRtu){
      MidResultToRtu res = null ;
      TcpDownCommandObj obj = null ;
      Node node = cachQueue.getFirstNode() ;
      Node node = cacheQueue.getFirstNode() ;
      while(node != null && node.obj != null){
         obj = (TcpDownCommandObj)node.obj;
         res = obj.result ;
@@ -77,7 +77,7 @@
   public static MidResultToRtu matchFromTail(MidResultFromRtu rsFromRtu){
      MidResultToRtu res = null ;
      TcpDownCommandObj obj = null ;
      Node node = cachQueue.getLastNode() ;
      Node node = cacheQueue.getLastNode() ;
      while(node != null && node.obj != null){
         obj = (TcpDownCommandObj)node.obj;
         res = obj.result ;
@@ -99,7 +99,7 @@
    * @return
    */
   public static Node getFirstQueueNode(){
      return cachQueue.getFirstNode() ;
      return cacheQueue.getFirstNode() ;
   }
   
   /**
@@ -107,7 +107,7 @@
    * @return
    */
   public static Node getLastQueueNode(){
      return cachQueue.getLastNode() ;
      return cacheQueue.getLastNode() ;
   }
   
   /**
@@ -115,15 +115,15 @@
    * @param node
    */
   public static void removeNode(Node node){
      cachQueue.remove(node);
      cacheQueue.remove(node);
   }
   /**
    * 缓存的节点数
    * @param node
    * @Return 缓存节点数
    */
   public static Integer size(){
      return cachQueue.size() ;
      return cacheQueue.size() ;
   }
}