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