001package jmri.jmrix.acela.acelamon;
002
003import jmri.jmrix.acela.AcelaListener;
004import jmri.jmrix.acela.AcelaMessage;
005import jmri.jmrix.acela.AcelaReply;
006
007/**
008 * Frame displaying (and logging) Acela command messages
009 *
010 * @author Bob Jacobsen Copyright (C) 2001
011 * @author Bob Coleman, Copyright (C) 2007, 2008 Based on CMRI serial example,
012 * modified to establish Acela support.
013 */
014public class AcelaMonFrame extends jmri.jmrix.AbstractMonFrame implements AcelaListener {
015
016    jmri.jmrix.acela.AcelaSystemConnectionMemo _memo = null;
017
018    public AcelaMonFrame(jmri.jmrix.acela.AcelaSystemConnectionMemo memo) {
019        super();
020        _memo = memo;
021    }
022
023    @Override
024    protected String title() {
025        return Bundle.getMessage("MonitorXTitle", "Acela");
026    }
027
028    @Override
029    protected void init() {
030        // connect to TrafficController
031        _memo.getTrafficController().addAcelaListener(this);
032    }
033
034    /**
035     * Define system-specific help item
036     */
037    @Override
038    protected void setHelp() {
039        addHelpMenu("package.jmri.jmrix.acela.acelamon.AcelaMonFrame", true); // NOI18N
040    }
041
042    @Override
043    public void dispose() {
044        _memo.getTrafficController().removeAcelaListener(this);
045        super.dispose();
046    }
047
048    @Override
049    public synchronized void message(AcelaMessage l) {  // receive a message and log it
050        nextLine("cmd: \"" + l.toString() + "\"\n", "");
051    }
052
053    @Override
054    public synchronized void reply(AcelaReply l) {  // receive a reply message and log it
055        l.setBinary(true);
056        nextLine("rep: \"" + l.toString() + "\"\n", "");
057    }
058
059}