Skip to content

Commit

Permalink
Plaster over clock rate setting bug...
Browse files Browse the repository at this point in the history
...when hardware provides a clock but user selects internal computer
clcok as time source.
  • Loading branch information
newHeiko committed Apr 19, 2019
1 parent b39ba52 commit e15dac8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Expand Up @@ -65,6 +65,7 @@ MinutesError = Error in Fast Time minutes entry:
MinutesRangeError = Minutes entry not within allowed 0 - 59 range.
NegativeRateError = Error in entry - Rate cannot be negative.
NonIntegerError = Error in entry - Your hardware clock requires an integer rate.
NonIntegerErrorCantChangeSource = Your hardware clock requires an integer rate. Cannot change time source to hardware clock with non-integer rate.

#Reminder1 = Please remember to save your changes to disk.
#Reminder2 = ( Select 'Store panels...' in the Panels menu. )
Expand Down
Expand Up @@ -53,7 +53,8 @@ HoursRangeError = Stundeneingabe nicht im erlaubten Bereich 0 - 23.
MinutesError = Fehler bei der Eingabe der Minuten der Startzeit:
MinutesRangeError = Minuteneingabe nicht im erlaubten Bereich 0 - 59.
NegativeRateError = Fehler im Wertebereich - Wert darf nicht negativ sein.
NonIntegerError = Fehler im Wertebereich - Systemuhr ben\u00f6tigt einen Integerwert.
NonIntegerError = Fehler im Wertebereich - Systemuhr ben\u00f6tigt einen ganzzahligen Zeitfaktor.
NonIntegerErrorCantChangeSource = Systemuhr ben\u00f6tigt einen ganzzahligen Zeitfaktor. Kann Zeitquelle nicht auf Systemuhr umstellen, solange Zeitfaktor nicht ganzzahlig ist.

#Reminder1 = Nicht vergessen, die \u00c4nderungen zu speichern.
#Reminder2 = ( W\u00e4hle "Speichere Gleisstellbild" im Menu "Panels")
Expand Down
15 changes: 14 additions & 1 deletion java/src/jmri/jmrit/simpleclock/SimpleClockFrame.java
Expand Up @@ -514,7 +514,7 @@ void updateRunningButton() {
Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
return null;
}
if (InstanceManager.getDefault(jmri.ClockControl.class).requiresIntegerRate()) {
if (InstanceManager.getDefault(jmri.ClockControl.class).requiresIntegerRate() && !clock.getInternalMaster()) {
double frac = rate - (int) rate;
if (frac > 0.001) {
JOptionPane.showMessageDialog(this, Bundle.getMessage("NonIntegerError"),
Expand Down Expand Up @@ -546,6 +546,8 @@ public void setRateButtonActionPerformed() {

/**
* Handle time source change
*
* Only changes the time source if the rate is OK (typically: Integer) for new source
*/
private void setTimeSourceChanged() {
int index = timeSourceBox.getSelectedIndex();
Expand All @@ -561,6 +563,17 @@ private void setTimeSourceChanged() {
if (index == internalSourceIndex) {
clock.setInternalMaster(true, true);
} else {
// only change if new source is okay with current rate
if (InstanceManager.getDefault(jmri.ClockControl.class).requiresIntegerRate()) {
double rate = clock.userGetRate();
double frac = rate - (int) rate;
if (frac > 0.001) {
JOptionPane.showMessageDialog(this, Bundle.getMessage("NonIntegerErrorCantChangeSource"),
Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
timeSourceBox.setSelectedIndex(internalSourceIndex);
return;
}
}
clock.setInternalMaster(false, true);
}
changed = true;
Expand Down
6 changes: 5 additions & 1 deletion java/src/jmri/jmrit/simpleclock/SimpleTimebase.java
Expand Up @@ -288,7 +288,11 @@ public void setInternalMaster(boolean master, boolean update) {
}
}
}

/**
* Get internalMaster field
*
* @returns true if fast clock time is derived from internal computer clock, false if derived from hardware clock
*/
@Override
public boolean getInternalMaster() {
return internalMaster;
Expand Down

0 comments on commit e15dac8

Please sign in to comment.