| | |
| | | * 得到所有RTU连接状态情况 |
| | | * @return |
| | | */ |
| | | public static List<RtuSessionStatus> allConnectStatus(){ |
| | | 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 ; |
| | | } |
| | | // public static List<RtuSessionStatus> allConnectStatus(){ |
| | | // 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 ; |
| | | // } |
| | | |
| | | |
| | | /** |