liurunyu
2025-02-25 5e31f7c1f3eaf5cfd3be0e5fc942aa78f3a4133c
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java
@@ -113,19 +113,6 @@
    * 得到Tcp通信协议名称
    * @param rtuAddr
    * @return
   public static String getTcpProtocolName(String rtuAddr){
      TcpSession tcpSe = sessionTable.get(rtuAddr) ;
      if(tcpSe != null){
         return tcpSe.protocolName ;
      }else{
         return null ;
      }
   }
    */
   /**
    * 得到Tcp通信协议名称
    * @param rtuAddr
    * @return
    * */
   public static Object[] getTcpProtocolNameVersion(String rtuAddr){
      TcpSession tcpSe = map.get(rtuAddr) ;
@@ -141,7 +128,7 @@
   /**
    * 得到所有在线与离线数量统计
    * @return [0]=在线数量,[2]上线过,但当前离线的数量
    * @return [0]=在线数量,[1]上线过,但当前离线的数量
    */
   public static Integer[] allOnLineStateStatistics(){
      synchronized (map){
@@ -194,50 +181,7 @@
         return map ;
      }
   }
//
//   /**
//    * 得到所有RTU连接状态情况
//    * @return
//    */
//   public static List<RtuSessionStatus> allConnectStatus(){
//      synchronized (sessionTable){
//         List<RtuSessionStatus> list = new ArrayList<RtuSessionStatus>();
//         Iterator<Entry<String, TcpSession>> it = sessionTable.entrySet().iterator() ;
//         Entry<String, TcpSession> entry = null ;
//         while(it.hasNext()){
//            entry = it.next() ;
//            RtuSessionStatus vo = new RtuSessionStatus() ;
//            vo.rtuAddr = entry.getKey() ;
//            IoSession se = entry.getValue().ioSession ;
//            vo.onTrueOffLine = se.isConnected() ;
//            InetSocketAddress sa = (InetSocketAddress)se.getRemoteAddress() ;
//            if(sa != null){
//               InetAddress inetAddr = sa.getAddress() ;
//               if(inetAddr != null){
//                  vo.ip = inetAddr.getHostAddress() ;
//                  vo.port = sa.getPort() ;
//               }
//            }
//            list.add(vo) ;
//         }
//         return list ;
//      }
//   }
//
   /**
    * 得到IoSession
    * @param rtuAddr
    * @return
    */
//   public IoSession getIoSession(String rtuAddr){
//      TcpSession tcpSe = sessionMap.get(rtuAddr) ;
//      if(tcpSe != null){
//         return tcpSe.ioSession ;
//      }
//      return null ;
//   }
   /**
    * 网络是否连接
    * @param rtuAddr
@@ -271,12 +215,13 @@
   }
   
   /**
    * 设置上行数据时刻
    * 当有上行数据时
    * @param rtuAddr
    */
   public static void cacheUpDataTime(String rtuAddr){
   public static void whenUpData(String rtuAddr){
      TcpSession tcpSe = map.get(rtuAddr) ;
      if(tcpSe != null){
         tcpSe.lastDownComTime = 0L ;//置0,使等待lastUpDataTimeLive(见config.xml配置文件)时长后,即刻下发缓存中的命令
         tcpSe.lastUpDataTime = System.currentTimeMillis() ;
         tcpSe.lastUpDataTimeForOnlineCtrl = System.currentTimeMillis() ;
      }
@@ -312,21 +257,5 @@
         }
      }
   }
//   public static void updateRtuStatus(Long now){
//      synchronized (sessionTable){
//         Iterator<TcpSession> it = sessionTable.values().iterator() ;
//         TcpSession tcpSe ;
//         while(it.hasNext()){
//            tcpSe = it.next() ;
//            if(tcpSe.lastUpDataTime != null){
//               if(now - tcpSe.lastUpDataTime > ServerProperties.lastUpDataTimeLive){
//                  tcpSe.lastUpDataTime = null ;
//               }
//            }
//         }
//      }
//   }
}