@Override public void cleanup(String remoteHost) { LOGGER.info("Cleanup client with address: {}", remoteHost); connectionListener.closed(remoteHost); }
@Override public void opened(String port) { // TODO Auto-generated method stub connectionListener.opened(port); }
@Override public void status(String messageKey) { // TODO Auto-generated method stub connectionListener.status(messageKey); }
@Override public void cleanup(String remoteHost) { LOGGER.info("Cleanup client with address: {}", remoteHost); connectionListener.closed(remoteHost); }
@Override public void open( String portName, ConnectionListener connectionListener, Set<NodeListener> nodeListeners, Set<MessageListener> messageListeners, Set<TransferListener> transferListeners, final Context context) throws PortNotFoundException, PortNotOpenedException { LOGGER.info("Open the serial simulation."); setConnectionListener(connectionListener); registerListeners(nodeListeners, messageListeners, transferListeners); final BidibMessageProcessor messageReceiver = getSimulationMessageReceiver(); if (context != null) { Boolean ignoreWrongMessageNumber = context.get("ignoreWrongReceiveMessageNumber", Boolean.class, Boolean.FALSE); messageReceiver.setIgnoreWrongMessageNumber(ignoreWrongMessageNumber); } startReceiverAndQueues(messageReceiver, context); if (getConnectionListener() != null) { LOGGER.info("Notify that the port was opened: {}", requestedPortName); getConnectionListener().opened(requestedPortName); } LOGGER.info("The port was opened internally, get the magic."); try { int magic = sendResetAndMagic(); LOGGER.info("The root node returned the magic: {}", ByteUtils.magicToHex(magic)); } catch (ProtocolException ex) { LOGGER.error("Send reset and magic to root node failed.", ex); } }
/** * @param messageKey * the message key to notify */ protected void notifyStatusKey(String messageKey) { if (getConnectionListener() != null) { getConnectionListener().status(messageKey); } else { LOGGER.info("No connection listener available."); } }
@Override public void closed(String port) { // TODO Auto-generated method stub // connectionListener.closed(port); if (active) { connectionListener.closed(port); return; } try { active = true; close(); } finally { active = false; } } };
getConnectionListener().opened(requestedPortName);
@Override public void close() { LOGGER.info("Close the port."); if (port != null) { LOGGER.info("Stop the port."); port.stop(); if (portWorker != null) { synchronized (portWorker) { try { portWorker.join(5000L); } catch (InterruptedException ex) { LOGGER.warn("Wait for termination of port worker failed.", ex); } portWorker = null; } } port = null; } stopReceiverAndQueues(null); if (getConnectionListener() != null) { getConnectionListener().closed(connectedPortName); } // clear the connectedPortName connectedPortName = null; cleanupAfterClose(null); LOGGER.info("Close the port finished."); }
getConnectionListener().closed(requestedPortName);
@Override public void close() { LOGGER.info("Close the serial simulation."); isOpened = false; if (getConnectionListener() != null) { getConnectionListener().closed(requestedPortName); } requestedPortName = null; // if (simulationInterface != null) { // simulationInterface.stop(); // } releaseRootNode(); // release the simulation message receiver simulationMessageReceiver = null; cleanupAfterClose(null); // remove all simulators from the simulation registry SimulatorRegistry.getInstance().removeAll(); super.stopReceiverAndQueues(simulationMessageReceiver); }