Skip to content

Commit 6ddaaab

Browse files
authored
Merge pull request #3373 from ControlSystemStudio/CSSTUDIO-2910
Support for per-PV tolerance and compare mode in save&restore
2 parents fa3fa36 + 3c57aaa commit 6ddaaab

File tree

31 files changed

+1777
-341
lines changed

31 files changed

+1777
-341
lines changed
3.85 KB
Loading

app/save-and-restore/app/doc/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Configuration View
157157
------------------
158158

159159
A new configuration is created from the context menu launched when right-clicking on a folder node in the tree view.
160-
This will launch the configuration editor:
160+
This screenshot shows the configuration editor:
161161

162162
.. image:: images/configuration-editor.png
163163
:width: 80%
@@ -170,6 +170,9 @@ with PVs in the order they appear.
170170

171171
PV entries in a configuration marked as read only will be omitted whe performing a restore operation.
172172

173+
Compare Mode and Tolerance data is optional. This is used by the service when a client requests comparison between
174+
stored and live values of a snapshot. More information on this feature is found in the service documentation.
175+
173176
To add a very large number of PVs, user should consider the import feature available via the "Import Configuration file to this folder"
174177
option in the context menu of a folder node in the tree view.
175178

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class Messages {
7979
public static String duplicatePVNamesAdditionalItems;
8080
public static String duplicatePVNamesCheckFailed;
8181
public static String duplicatePVNamesFoundInSelection;
82+
public static String duplicatePVNamesNotSupported;
8283
public static String Edit;
8384
public static String editFilter;
8485
public static String errorActionFailed;
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright (C) 2024 European Spallation Source ERIC.
3+
*/
4+
5+
package org.phoebus.applications.saveandrestore.ui.configuration;
6+
7+
import javafx.beans.property.BooleanProperty;
8+
import javafx.beans.property.ObjectProperty;
9+
import javafx.beans.property.SimpleBooleanProperty;
10+
import javafx.beans.property.SimpleObjectProperty;
11+
import javafx.beans.property.SimpleStringProperty;
12+
import javafx.beans.property.StringProperty;
13+
import org.phoebus.applications.saveandrestore.model.Comparison;
14+
import org.phoebus.applications.saveandrestore.model.ConfigPv;
15+
import org.phoebus.applications.saveandrestore.model.ComparisonMode;
16+
17+
import java.util.Objects;
18+
19+
/**
20+
* Wrapper around a {@link ConfigPv} instance for the purpose of facilitating
21+
* configuration and data binding in (for instance) a {@link javafx.scene.control.TableView}.
22+
*/
23+
public class ConfigPvEntry implements Comparable<ConfigPvEntry> {
24+
25+
private final StringProperty pvNameProperty;
26+
private final StringProperty readBackPvNameProperty;
27+
private final BooleanProperty readOnlyProperty;
28+
private final ObjectProperty<ComparisonMode> comparisonModeProperty;
29+
private final ObjectProperty<Double> toleranceProperty;
30+
31+
public ConfigPvEntry(ConfigPv configPv) {
32+
this.pvNameProperty = new SimpleStringProperty(this, "pvNameProperty", configPv.getPvName());
33+
this.readBackPvNameProperty = new SimpleStringProperty(configPv.getReadbackPvName());
34+
this.readOnlyProperty = new SimpleBooleanProperty(configPv.isReadOnly());
35+
this.comparisonModeProperty = new SimpleObjectProperty<>(configPv.getComparison() == null ? null : configPv.getComparison().getComparisonMode());
36+
this.toleranceProperty = new SimpleObjectProperty<>(configPv.getComparison() == null ? null : configPv.getComparison().getTolerance());
37+
}
38+
39+
public StringProperty getPvNameProperty() {
40+
return pvNameProperty;
41+
}
42+
43+
public StringProperty getReadBackPvNameProperty() {
44+
return readBackPvNameProperty;
45+
}
46+
47+
public BooleanProperty getReadOnlyProperty() {
48+
return readOnlyProperty;
49+
}
50+
51+
public ObjectProperty<ComparisonMode> getComparisonModeProperty() {
52+
return comparisonModeProperty;
53+
}
54+
55+
public ObjectProperty<Double> getToleranceProperty() {
56+
return toleranceProperty;
57+
}
58+
59+
public void setPvNameProperty(String pvNameProperty) {
60+
this.pvNameProperty.set(pvNameProperty);
61+
}
62+
63+
public void setReadBackPvNameProperty(String readBackPvNameProperty) {
64+
this.readBackPvNameProperty.set(readBackPvNameProperty);
65+
}
66+
67+
public void setComparisonModeProperty(ComparisonMode comparisonModeProperty) {
68+
this.comparisonModeProperty.set(comparisonModeProperty);
69+
}
70+
71+
public void setToleranceProperty(Double toleranceProperty) {
72+
this.toleranceProperty.set(toleranceProperty );
73+
}
74+
75+
public ConfigPv toConfigPv() {
76+
ConfigPv configPv = ConfigPv.builder()
77+
.pvName(pvNameProperty.get())
78+
.readbackPvName(readBackPvNameProperty.get())
79+
.readOnly(readOnlyProperty.get())
80+
.build();
81+
if(comparisonModeProperty.isNotNull().get() && toleranceProperty.isNotNull().get()){
82+
configPv.setComparison(new Comparison(comparisonModeProperty.get(), toleranceProperty.get()));
83+
}
84+
return configPv;
85+
}
86+
87+
@Override
88+
public boolean equals(Object other) {
89+
if (other instanceof ConfigPvEntry otherConfigPv) {
90+
return Objects.equals(pvNameProperty, otherConfigPv.getPvNameProperty()) &&
91+
Objects.equals(readBackPvNameProperty, otherConfigPv.getReadBackPvNameProperty()) &&
92+
Objects.equals(readOnlyProperty.get(), otherConfigPv.getReadOnlyProperty().get());
93+
}
94+
return false;
95+
}
96+
97+
@Override
98+
public int hashCode() {
99+
return Objects.hash(pvNameProperty, readBackPvNameProperty, readOnlyProperty);
100+
}
101+
102+
@Override
103+
public int compareTo(ConfigPvEntry other) {
104+
return pvNameProperty.get().compareTo(other.getPvNameProperty().get());
105+
}
106+
}

0 commit comments

Comments
 (0)