001package jmri.jmrix.jmriclient;
002
003
004/**
005 * Encodes a message to an JMRIClient server. The JMRIClientReply class handles
006 * the response from the server.
007 * <p>
008 * The {@link JMRIClientReply} class handles the response from the server.
009 *
010 * @author Bob Jacobsen Copyright (C) 2001, 2004, 2008
011 * @author Paul Bender Copyright (C) 2010
012 */
013public class JMRIClientMessage extends jmri.jmrix.AbstractMRMessage {
014
015    public JMRIClientMessage() {
016        super();
017    }
018
019    // create a new one
020    public JMRIClientMessage(int i) {
021        super(i);
022    }
023
024    // copy one
025    public JMRIClientMessage(JMRIClientMessage m) {
026        super(m);
027    }
028
029    // from String
030    public JMRIClientMessage(String m) {
031        super(m);
032    }
033
034    // diagnose format
035    public boolean isKillMain() {
036        String s = toString();
037        return s.contains("POWER OFF");
038    }
039
040    public boolean isEnableMain() {
041        String s = toString();
042        return s.contains("POWER ON");
043    }
044
045    // static methods to return a formatted message
046    static public JMRIClientMessage getEnableMain() {
047        JMRIClientMessage m = new JMRIClientMessage("POWER ON\n");
048        m.setBinary(false);
049        return m;
050    }
051
052    static public JMRIClientMessage getKillMain() {
053        JMRIClientMessage m = new JMRIClientMessage("POWER OFF\n");
054        m.setBinary(false);
055        return m;
056    }
057
058    static public JMRIClientMessage getProgMode() {
059        return null;
060    }
061
062    static public JMRIClientMessage getExitProgMode() {
063        return null;
064    }
065
066    final static protected int LONG_TIMEOUT = 180000;  // e.g. for programming options
067
068}