Search in sources :

Example 6 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class JsonTimeSocketService method onMessage.

@Override
public void onMessage(String type, JsonNode data, Locale locale) throws IOException, JmriException, JsonException {
    if (!this.listening) {
        Timebase manager = InstanceManager.getDefault(Timebase.class);
        manager.addMinuteChangeListener(this);
        manager.addPropertyChangeListener(this);
        this.listening = true;
    }
    this.service.doPost(type, null, data, locale);
}
Also used : Timebase(jmri.Timebase)

Example 7 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class JsonTimeSocketService method onClose.

@Override
public void onClose() {
    if (this.listening) {
        Timebase manager = InstanceManager.getDefault(Timebase.class);
        manager.removeMinuteChangeListener(this);
        manager.removePropertyChangeListener(this);
    }
}
Also used : Timebase(jmri.Timebase)

Example 8 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class SimpleTimebaseXml method store.

/**
     * Default implementation for storing the contents of a SimpleTimebase.
     * <P>
     * @param o Object to start process, but not actually used
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    Timebase clock = InstanceManager.getDefault(jmri.Timebase.class);
    Element elem = new Element("timebase");
    elem.setAttribute("class", this.getClass().getName());
    elem.setAttribute("time", clock.getStartTime().toString());
    elem.setAttribute("rate", "" + clock.userGetRate());
    elem.setAttribute("run", (!clock.getStartStopped() ? "yes" : "no"));
    elem.setAttribute("master", (clock.getInternalMaster() ? "yes" : "no"));
    if (!clock.getInternalMaster()) {
        elem.setAttribute("mastername", clock.getMasterName());
    }
    elem.setAttribute("sync", (clock.getSynchronize() ? "yes" : "no"));
    elem.setAttribute("correct", (clock.getCorrectHardware() ? "yes" : "no"));
    elem.setAttribute("display", (clock.use12HourDisplay() ? "yes" : "no"));
    elem.setAttribute("startstopped", (clock.getStartStopped() ? "yes" : "no"));
    elem.setAttribute("startsettime", (clock.getStartSetTime() ? "yes" : "no"));
    elem.setAttribute("startclockoption", Integer.toString(clock.getStartClockOption()));
    elem.setAttribute("showbutton", (clock.getShowStopButton() ? "yes" : "no"));
    return elem;
}
Also used : Timebase(jmri.Timebase) Element(org.jdom2.Element)

Aggregations

Timebase (jmri.Timebase)8 BoxLayout (javax.swing.BoxLayout)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 NamedBean (jmri.NamedBean)2 Container (java.awt.Container)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ParseException (java.text.ParseException)1 Date (java.util.Date)1 ButtonGroup (javax.swing.ButtonGroup)1 JCheckBox (javax.swing.JCheckBox)1 Border (javax.swing.border.Border)1 JmriException (jmri.JmriException)1 Element (org.jdom2.Element)1