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);
}
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);
}
}
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;
}
Aggregations