Skip to content

Commit c973c5a

Browse files
committed
Backup commit
1 parent 55b181d commit c973c5a

File tree

16 files changed

+432
-122
lines changed

16 files changed

+432
-122
lines changed

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/configuration/ComparisonDataEditorController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
import javafx.fxml.FXML;
1313
import javafx.scene.control.ComboBox;
1414
import javafx.scene.control.TextField;
15-
import org.phoebus.applications.saveandrestore.model.CompareMode;
15+
import org.phoebus.applications.saveandrestore.model.ComparisonMode;
1616

1717
import java.util.regex.Pattern;
1818

1919
public class ComparisonDataEditorController {
2020

2121
@FXML
22-
private ComboBox<CompareMode> comparisonModeComboBox;
22+
private ComboBox<ComparisonMode> comparisonModeComboBox;
2323

2424
@FXML
2525
private TextField toleranceTextField;
2626

27-
private ObjectProperty<CompareMode> comparisonModeProperty = new SimpleObjectProperty<>();
27+
private ObjectProperty<ComparisonMode> comparisonModeProperty = new SimpleObjectProperty<>();
2828
private StringProperty toleranceProperty = new SimpleStringProperty();
2929
private Pattern pattern = Pattern.compile("\\d*(\\.?\\d*)?");
3030

@@ -35,7 +35,7 @@ public ComparisonDataEditorController(){
3535

3636
@FXML
3737
public void initialize(){
38-
comparisonModeComboBox.itemsProperty().set(FXCollections.observableArrayList(CompareMode.values()));
38+
comparisonModeComboBox.itemsProperty().set(FXCollections.observableArrayList(ComparisonMode.values()));
3939
comparisonModeComboBox.valueProperty().bind(comparisonModeProperty);
4040
toleranceTextField.textProperty().bindBidirectional(toleranceProperty);
4141

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/configuration/ConfigPvEntry.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import javafx.beans.property.SimpleObjectProperty;
1111
import javafx.beans.property.SimpleStringProperty;
1212
import javafx.beans.property.StringProperty;
13+
import org.phoebus.applications.saveandrestore.model.Comparison;
1314
import org.phoebus.applications.saveandrestore.model.ConfigPv;
14-
import org.phoebus.applications.saveandrestore.model.CompareMode;
15+
import org.phoebus.applications.saveandrestore.model.ComparisonMode;
1516

1617
import java.util.Objects;
1718

@@ -24,16 +25,15 @@ public class ConfigPvEntry implements Comparable<ConfigPvEntry> {
2425
private final StringProperty pvNameProperty;
2526
private final StringProperty readBackPvNameProperty;
2627
private final BooleanProperty readOnlyProperty;
27-
private final ObjectProperty<CompareMode> compareModeProperty;
28+
private final ObjectProperty<Comparison> comparisonProperty;
29+
private final ObjectProperty<ComparisonMode> compareModeProperty;
2830
private final ObjectProperty<Double> toleranceProperty;
2931

3032
public ConfigPvEntry(ConfigPv configPv) {
3133
this.pvNameProperty = new SimpleStringProperty(this, "pvNameProperty", configPv.getPvName());
3234
this.readBackPvNameProperty = new SimpleStringProperty(configPv.getReadbackPvName());
3335
this.readOnlyProperty = new SimpleBooleanProperty(configPv.isReadOnly());
34-
this.compareModeProperty = new SimpleObjectProperty(configPv.getCompareMode());
35-
this.toleranceProperty = configPv.getTolerance() != null ?
36-
new SimpleObjectProperty<>(configPv.getTolerance()) : new SimpleObjectProperty<>(null);
36+
this.comparisonProperty = new SimpleObjectProperty<>(configPv.getComparison());
3737
}
3838

3939
public StringProperty getPvNameProperty() {
@@ -48,7 +48,7 @@ public BooleanProperty getReadOnlyProperty() {
4848
return readOnlyProperty;
4949
}
5050

51-
public ObjectProperty<CompareMode> getCompareModeProperty() {
51+
public ObjectProperty<ComparisonMode> getCompareModeProperty() {
5252
return compareModeProperty;
5353
}
5454

@@ -64,7 +64,7 @@ public void setReadBackPvNameProperty(String readBackPvNameProperty) {
6464
this.readBackPvNameProperty.set(readBackPvNameProperty);
6565
}
6666

67-
public void setCompareModeProperty(CompareMode compareModeProperty) {
67+
public void setCompareModeProperty(ComparisonMode compareModeProperty) {
6868
this.compareModeProperty.set(compareModeProperty);
6969
}
7070

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/configuration/ConfigurationController.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
import org.phoebus.applications.saveandrestore.model.ConfigurationData;
5959
import org.phoebus.applications.saveandrestore.model.Node;
6060
import org.phoebus.applications.saveandrestore.model.NodeType;
61-
import org.phoebus.applications.saveandrestore.model.CompareMode;
61+
import org.phoebus.applications.saveandrestore.model.ComparisonMode;
6262
import org.phoebus.applications.saveandrestore.ui.NodeChangedListener;
6363
import org.phoebus.applications.saveandrestore.ui.SaveAndRestoreBaseController;
6464
import org.phoebus.applications.saveandrestore.ui.SaveAndRestoreService;
@@ -100,7 +100,7 @@ public class ConfigurationController extends SaveAndRestoreBaseController implem
100100

101101
@FXML
102102
@SuppressWarnings("unused")
103-
private TableColumn<ConfigPvEntry, CompareMode> comparisonModeColumn;
103+
private TableColumn<ConfigPvEntry, ComparisonMode> comparisonModeColumn;
104104

105105
@FXML
106106
@SuppressWarnings("unused")
@@ -256,12 +256,12 @@ public void initialize() {
256256

257257
comparisonModeColumn.setCellValueFactory(cell -> cell.getValue().getCompareModeProperty());
258258
comparisonModeColumn.setCellFactory(callback -> {
259-
ObservableList<CompareMode> values = FXCollections.observableArrayList(Arrays.stream(CompareMode.values()).toList());
259+
ObservableList<ComparisonMode> values = FXCollections.observableArrayList(Arrays.stream(ComparisonMode.values()).toList());
260260
values.add(0, null);
261-
ComboBoxTableCell<ConfigPvEntry, CompareMode> tableCell = new ComboBoxTableCell<>(values) {
261+
ComboBoxTableCell<ConfigPvEntry, ComparisonMode> tableCell = new ComboBoxTableCell<>(values) {
262262

263263
@Override
264-
public void commitEdit(CompareMode pvCompareMode) {
264+
public void commitEdit(ComparisonMode pvCompareMode) {
265265
getTableView().getItems().get(getIndex()).setCompareModeProperty(pvCompareMode);
266266
if (pvCompareMode == null) {
267267
getTableView().getItems().get(getIndex()).setToleranceProperty(null);
@@ -271,21 +271,21 @@ public void commitEdit(CompareMode pvCompareMode) {
271271
}
272272
};
273273

274-
StringConverter<CompareMode> converter = new StringConverter<>() {
274+
StringConverter<ComparisonMode> converter = new StringConverter<>() {
275275
@Override
276-
public String toString(CompareMode object) {
276+
public String toString(ComparisonMode object) {
277277
if (object == null) {
278278
return "";
279279
}
280280
return object.toString();
281281
}
282282

283283
@Override
284-
public CompareMode fromString(String string) {
284+
public ComparisonMode fromString(String string) {
285285
if (string == null) {
286286
return null;
287287
}
288-
return CompareMode.valueOf(string);
288+
return ComparisonMode.valueOf(string);
289289
}
290290
};
291291
tableCell.setConverter(converter);
@@ -545,7 +545,7 @@ private void launchComparisonEditor(){
545545
}
546546
}
547547

548-
public record ComparisonData(CompareMode pvCompareMode, Double tolerance){
548+
public record ComparisonData(ComparisonMode pvCompareMode, Double tolerance){
549549

550550
}
551551
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright (C) 2025 European Spallation Source ERIC.
3+
*/
4+
5+
package org.phoebus.applications.saveandrestore.model;
6+
7+
public record Comparison(ComparisonMode comparisonMode, double tolerance){
8+
9+
}

app/save-and-restore/model/src/main/java/org/phoebus/applications/saveandrestore/model/CompareMode.java renamed to app/save-and-restore/model/src/main/java/org/phoebus/applications/saveandrestore/model/ComparisonMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Specifies how comparison between PV values should be performed.
99
*/
10-
public enum CompareMode {
10+
public enum ComparisonMode {
1111
RELATIVE,
1212
ABSOLUTE;
1313
}

app/save-and-restore/model/src/main/java/org/phoebus/applications/saveandrestore/model/CompareResult.java renamed to app/save-and-restore/model/src/main/java/org/phoebus/applications/saveandrestore/model/ComparisonResult.java

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
* For the live {@link VType} value, <code>null</code> indicates failure to connect to the PV.
1919
*/
2020
@SuppressWarnings("unused")
21-
public class CompareResult{
21+
public class ComparisonResult {
2222

2323
private String pvName;
2424
private boolean equal;
25-
private CompareMode pvCompareMode;
26-
private double tolerance;
25+
private Comparison comparison;
2726
@JsonSerialize(using = VTypeSerializer.class)
2827
@JsonDeserialize(using = VTypeDeserializer.class)
2928
private VType storedValue;
@@ -35,20 +34,18 @@ public class CompareResult{
3534
/**
3635
* Needed by unit tests. Do not remove.
3736
*/
38-
public CompareResult(){}
37+
public ComparisonResult(){}
3938

40-
public CompareResult(String pvName,
41-
boolean equal,
42-
CompareMode pvCompareMode,
43-
double tolerance,
44-
VType storedValue,
45-
VType liveValue,
46-
String delta){
39+
public ComparisonResult(String pvName,
40+
boolean equal,
41+
Comparison comparison,
42+
VType storedValue,
43+
VType liveValue,
44+
String delta){
4745

4846
this.pvName = pvName;
4947
this.equal = equal;
50-
this.pvCompareMode = pvCompareMode;
51-
this.tolerance = tolerance;
48+
this.comparison = comparison;
5249
this.storedValue = storedValue;
5350
this.liveValue = liveValue;
5451
this.delta = delta;
@@ -58,16 +55,12 @@ public boolean isEqual() {
5855
return equal;
5956
}
6057

61-
public CompareMode getPvCompareMode() {
62-
return pvCompareMode;
58+
public Comparison getComparison() {
59+
return comparison;
6360
}
6461

65-
public double getTolerance() {
66-
return tolerance;
67-
}
68-
69-
public void setTolerance(double tolerance) {
70-
this.tolerance = tolerance;
62+
public void setComparison(Comparison comparison) {
63+
this.comparison = comparison;
7164
}
7265

7366
/**

app/save-and-restore/model/src/main/java/org/phoebus/applications/saveandrestore/model/ConfigPv.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
* is optionally associated with the PV name. A PV record is uniquely identified by both the PV name
2828
* and the read-back PV name (if it has been specified).
2929
* <p>
30-
* A {@link CompareMode} can optionally be specified to
30+
* A {@link ComparisonMode} can optionally be specified to
3131
* indicate how the stored value (as defined by the {@link #pvName} field) is compared to a live value
32-
* if a client requests it. A non-null {@link CompareMode} must be paired non-null and a
32+
* if a client requests it. A non-null {@link ComparisonMode} must be paired non-null and a
3333
* {@link #tolerance} value &ge;0.
3434
* </p>
3535
* @author georgweiss
@@ -52,7 +52,7 @@ public class ConfigPv implements Comparable<ConfigPv> {
5252
*/
5353
private boolean readOnly = false;
5454

55-
private CompareMode compareMode;
55+
private Comparison comparison;
5656

5757
@JsonInclude(JsonInclude.Include.NON_NULL)
5858
private Double tolerance = null;
@@ -81,13 +81,12 @@ public void setReadOnly(boolean readOnly) {
8181
this.readOnly = readOnly;
8282
}
8383

84-
85-
public CompareMode getCompareMode() {
86-
return compareMode;
84+
public Comparison getComparison() {
85+
return comparison;
8786
}
8887

89-
public void setCompareMode(CompareMode compareMode) {
90-
this.compareMode = compareMode;
88+
public void setComparison(Comparison comparison) {
89+
this.comparison = comparison;
9190
}
9291

9392
public Double getTolerance() {
@@ -100,8 +99,7 @@ public void setTolerance(Double tolerance) {
10099

101100
@Override
102101
public boolean equals(Object other) {
103-
if (other instanceof ConfigPv) {
104-
ConfigPv otherConfigPv = (ConfigPv) other;
102+
if (other instanceof ConfigPv otherConfigPv) {
105103
return Objects.equals(pvName, otherConfigPv.getPvName()) && Objects.equals(readbackPvName, otherConfigPv.getReadbackPvName()) && Objects.equals(readOnly, otherConfigPv.isReadOnly());
106104
}
107105
return false;
@@ -115,13 +113,16 @@ public int hashCode() {
115113
@Override
116114
public String toString() {
117115

118-
return new StringBuffer()
116+
StringBuilder stringBuffer = new StringBuilder()
119117
.append("PV name=").append(pvName)
120118
.append(", readback PV name=").append(readbackPvName)
121119
.append(", readOnly=").append(readOnly)
122-
.append(", compareMode=").append(compareMode)
123-
.append(", tolerance=").append(tolerance)
124-
.toString();
120+
.append(", tolerance=").append(tolerance);
121+
if(comparison != null){
122+
stringBuffer.append(", comparison mode=").append(comparison.comparisonMode());
123+
stringBuffer.append(", tolerance=").append(comparison.tolerance());
124+
}
125+
return stringBuffer.toString();
125126
}
126127

127128
/**
@@ -161,8 +162,8 @@ public Builder readOnly(boolean readOnly) {
161162
return this;
162163
}
163164

164-
public Builder compareMode(CompareMode compareMode) {
165-
configPv.setCompareMode(compareMode);
165+
public Builder comparison(Comparison comparison) {
166+
configPv.setComparison(comparison);
166167
return this;
167168
}
168169

app/save-and-restore/model/src/test/java/org/phoebus/applications/saveandrestore/model/ConfigPvTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public void testConfigPv() {
4545
assertNull(configPV.getCompareMode());
4646
assertNull(configPV.getTolerance());
4747

48-
configPV = ConfigPv.builder().pvName("a").readbackPvName("b").readOnly(true).compareMode(CompareMode.ABSOLUTE).tolerance(1.0).build();
49-
assertEquals(CompareMode.ABSOLUTE, configPV.getCompareMode());
48+
configPV = ConfigPv.builder().pvName("a").readbackPvName("b").readOnly(true).compareMode(ComparisonMode.ABSOLUTE).tolerance(1.0).build();
49+
assertEquals(ComparisonMode.ABSOLUTE, configPV.getCompareMode());
5050
assertEquals(1.0, configPV.getTolerance());
5151
}
5252

0 commit comments

Comments
 (0)