001package jmri.jmrix.grapevine.serialmon; 002 003import jmri.jmrix.grapevine.SerialListener; 004import jmri.jmrix.grapevine.SerialMessage; 005import jmri.jmrix.grapevine.SerialReply; 006import jmri.jmrix.grapevine.GrapevineSystemConnectionMemo; 007import org.slf4j.Logger; 008import org.slf4j.LoggerFactory; 009 010/** 011 * Frame displaying (and logging) serial command messages. 012 * 013 * @author Bob Jacobsen Copyright (C) 2001, 2006, 2007, 2008 014 */ 015public class SerialMonFrame extends jmri.jmrix.AbstractMonFrame implements SerialListener { 016 017 private GrapevineSystemConnectionMemo memo = null; 018 019 public SerialMonFrame(GrapevineSystemConnectionMemo _memo) { 020 super(); 021 memo = _memo; 022 } 023 024 @Override 025 protected String title() { 026 return Bundle.getMessage("MonitorXTitle", "Grapevine"); 027 } 028 029 @Override 030 protected void init() { 031 // connect to TrafficController 032 memo.getTrafficController().addSerialListener(this); 033 } 034 035 @Override 036 protected void setHelp() { 037 addHelpMenu("package.jmri.jmrix.grapevine.serialmon.SerialMonFrame", true); // NOI18N 038 } 039 040 @Override 041 public void dispose() { 042 memo.getTrafficController().removeSerialListener(this); 043 super.dispose(); 044 } 045 046 @Override 047 public synchronized void message(SerialMessage l) { // receive a message and log it 048 log.debug("Message: {}", l.toString()); 049 nextLine(Bundle.getMessage("CommandLabel") + " " + l.format() + "\n", l.toString()); 050 } 051 052 @Override 053 public synchronized void reply(SerialReply l) { // receive a reply and log it 054 log.debug("Reply: {}", l.toString()); 055 nextLine(Bundle.getMessage("ReplyLabel") + " " + l.format() + "\n", l.toString()); 056 } 057 058 private final static Logger log = LoggerFactory.getLogger(SerialMonFrame.class); 059 060}