001package jmri.jmrix.can;
002
003/**
004 * Traffic controller for CAN access.
005 *
006 * @author Bob Jacobsen Copyright (C) 2008
007 */
008abstract public class TrafficController extends AbstractCanTrafficController {
009
010    /**
011     * Create a new CAN TrafficController instance.
012     */
013    public TrafficController() {
014        super();
015    }
016
017    protected int _canid = 120;
018
019    /**
020     * Get the Connection CAN ID.
021     * @return Connection CAN ID, defaults to 120
022     */
023    public int getCanid() {
024        return _canid;
025    }
026    
027    /**
028     * Set the Connection CAN ID.
029     * @param canid CAN ID to use
030     */
031    public void setCanId(int canid) {
032        _canid = canid;
033    }
034
035    /**
036     * Set the CAN ID by numerical String value.
037     * @param canId String value of CAN ID.
038     */
039    public void setCanId( @javax.annotation.CheckForNull String canId) {
040        try {
041            setCanId(Integer.parseInt(canId));
042        } catch (NumberFormatException e) {
043            log.error("Cannot parse CAN ID \"{}\" - check your preference settings", canId, e);
044            log.error("Now using CAN ID {}",getCanid());
045        }
046    }
047
048    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TrafficController.class);
049
050}