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