001package jmri.jmrix.rps.rpsmon;
002
003import jmri.jmrix.rps.Distributor;
004import jmri.jmrix.rps.Measurement;
005import jmri.jmrix.rps.MeasurementListener;
006import jmri.jmrix.rps.Reading;
007import jmri.jmrix.rps.ReadingListener;
008import jmri.jmrix.rps.RpsSystemConnectionMemo;
009
010/**
011 * Frame displaying (and logging) RPS messages.
012 *
013 * @author Bob Jacobsen Copyright (C) 2006
014 */
015public class RpsMonFrame extends jmri.jmrix.AbstractMonFrame
016        implements ReadingListener, MeasurementListener {
017
018    // RpsSystemConnectionMemo memo = null;
019
020    public RpsMonFrame(RpsSystemConnectionMemo _memo) {
021        super();
022        // memo = _memo;
023    }
024
025    @Override
026    protected String title() {
027        return "RPS Monitor";
028    }
029
030    @Override
031    public void dispose() {
032        // remove from notification
033        Distributor.instance().removeReadingListener(this);
034        Distributor.instance().removeMeasurementListener(this);
035        // and unwind swing
036        super.dispose();
037    }
038
039    @Override
040    protected void init() {
041        Distributor.instance().addReadingListener(this);
042        Distributor.instance().addMeasurementListener(this);
043    }
044
045    @Override
046    public void notify(Reading r) {
047        String raw = "";
048        if (r.getRawData() != null) {
049            raw = r.getRawData().toString();
050        }
051        nextLine(r.toString() + "\n", raw);
052    }
053
054    @Override
055    public void notify(Measurement m) {
056        String raw = "";
057        if (m.getReading() != null) {
058            raw = m.getReading().toString();
059        }
060        nextLine(m.toString() + "\n", raw);
061    }
062
063}