001package jmri.jmrix.sprog.sprogmon;
002
003import jmri.jmrix.sprog.SprogListener;
004import jmri.jmrix.sprog.SprogMessage;
005import jmri.jmrix.sprog.SprogReply;
006import jmri.jmrix.sprog.SprogSystemConnectionMemo;
007import org.slf4j.Logger;
008import org.slf4j.LoggerFactory;
009
010/**
011 * Frame displaying (and logging) Sprog command messages
012 *
013 * @author Bob Jacobsen Copyright (C) 2001
014 */
015public class SprogMonFrame extends jmri.jmrix.AbstractMonFrame implements SprogListener {
016
017    private SprogSystemConnectionMemo _memo = null;
018
019    public SprogMonFrame(SprogSystemConnectionMemo memo) {
020        super();
021        _memo = memo;
022    }
023
024    @Override
025    protected String title() {
026        return Bundle.getMessage("MonitorXTitle", "SPROG");
027    }
028
029    @Override
030    protected void init() {
031        // connect to TrafficController
032        _memo.getSprogTrafficController().addSprogListener(this);
033    }
034
035    @Override
036    public void dispose() {
037        _memo.getSprogTrafficController().removeSprogListener(this);
038        super.dispose();
039    }
040
041    @Override
042    public synchronized void notifyMessage(SprogMessage l) { // receive a message and log it
043        nextLine("cmd: \"" + l.toString(_memo.getSprogTrafficController().isSIIBootMode()) + "\"\n", "");
044
045    }
046
047    @Override
048    public synchronized void notifyReply(SprogReply l) { // receive a reply and log it
049        nextLine("rep: \"" + l.toString() + "\"\n", "");
050        log.debug("reply heard");
051    }
052
053    private final static Logger log = LoggerFactory.getLogger(SprogMonFrame.class);
054
055}