001package jmri.jmrix.bidib; 002 003import java.io.IOException; 004import java.util.Set; 005import org.bidib.jbidibc.core.BidibInterface; 006import org.bidib.jbidibc.core.MessageListener; 007import org.bidib.jbidibc.core.NodeListener; 008import org.bidib.jbidibc.core.node.listener.TransferListener; 009import org.bidib.jbidibc.messages.ConnectionListener; 010import org.bidib.jbidibc.messages.helpers.Context; 011import org.bidib.jbidibc.messages.helpers.DefaultContext; 012 013/** 014 * Abstract base for classes representing a BiDiB communications port 015 * 016 * @author Bob Jacobsen Copyright (C) 2001, 2008 017 * @author Eckart Meyer Copyright (C) 2023 018 */ 019public abstract class BiDiBNetworkPortController extends jmri.jmrix.AbstractNetworkPortController implements BiDiBPortController { 020 021 protected BidibInterface bidib = null; 022 protected Context context = new DefaultContext(); 023 024 public BiDiBNetworkPortController() { 025 super(new BiDiBSystemConnectionMemo()); 026 } 027 028 @Override 029 public abstract void connect(String host, int port) throws IOException; 030 031 /** 032 * {@inheritDoc} 033 */ 034 @Override 035 public BiDiBSystemConnectionMemo getSystemConnectionMemo() { 036 return (BiDiBSystemConnectionMemo) super.getSystemConnectionMemo(); 037 } 038 039 // Implementation of the BiDiBPortController interface 040 041 /** 042 * Get the physical port name used with jbidibc 043 * 044 * @return physical port name 045 */ 046 @Override 047 public String getRealPortName() { 048 return getCurrentPortName(); //default implemention 049 } 050 051 /** 052 * Register all Listeners to the specific BiDiB Object. 053 * We need this here since the BidibInterface does not 054 * provide this method. 055 * 056 * @param connectionListener add to this 057 * @param nodeListeners listeners to add 058 * @param messageListeners listeners to add 059 * @param transferListeners listeners to add 060 */ 061 @Override 062 public abstract void registerAllListeners(ConnectionListener connectionListener, Set<NodeListener> nodeListeners, 063 Set<MessageListener> messageListeners, Set<TransferListener> transferListeners); 064 065 /** 066 * Get the Bidib adapter context 067 * 068 * @return Context 069 */ 070 @Override 071 public Context getContext() { 072 return context; 073 } 074} 075 076 077