|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 得到所有在线与离线数量统计 | 
|---|
|  |  |  | * @return [0]=在线数量,[2]上线过,但当前离线的数量 | 
|---|
|  |  |  | * @return [0]=在线数量,[1]上线过,但当前离线的数量 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Integer[] allOnLineStateStatistics(){ | 
|---|
|  |  |  | synchronized (map){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设置上行数据时刻 | 
|---|
|  |  |  | * 当有上行数据时 | 
|---|
|  |  |  | * @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() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(tcpSe.ioSession != null && tcpSe.ioSession.isConnected()){ | 
|---|
|  |  |  | if(now - tcpSe.lastUpDataTimeForOnlineCtrl > ServerProperties.disconnectedByNoUpDataMinutes){ | 
|---|
|  |  |  | tcpSe.ioSession.closeNow() ; | 
|---|
|  |  |  | RtuLogDealer.log(entry.getKey(), "因较长时间未收上行数据,认为设备离线"); | 
|---|
|  |  |  | RtuLogDealer.log(entry.getKey(), "因较长时间未收到上行数据,认为设备离线"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|