Skip to content

Commit 68ecad5

Browse files
committed
Update of save&restore config pv data model to include comparison data
1 parent 6f83593 commit 68ecad5

File tree

4 files changed

+59
-0
lines changed

4 files changed

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

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,36 @@
2424
* Class encapsulating data to describe a PV subject to a save operation. A read-back PV name
2525
* is optionally associated with the PV name. A PV record is uniquely identified by both the PV name
2626
* and the read-back PV name (if it has been specified).
27+
* <p>
28+
* If a read-back PV name has been specified, a {@link Comparison} can be specified to
29+
* indicate if and how the stored read-back value is compared to the live read-back value
30+
* if a client requests it.
31+
* </p>
2732
* @author georgweiss
2833
* Created 1 Oct 2018
2934
*/
3035
public class ConfigPv implements Comparable<ConfigPv>{
3136

37+
/**
38+
* Set-point PV name.
39+
*/
3240
private String pvName;
41+
42+
/**
43+
* Optional read-back PV name
44+
*/
3345
private String readbackPvName;
46+
47+
/**
48+
* Flag indicating if set-point PV value should be restored or not.
49+
*/
3450
private boolean readOnly = false;
3551

52+
/**
53+
* Optional comparison data for the read-back PV.
54+
*/
55+
private Comparison comparison;
56+
3657
public String getPvName() {
3758
return pvName;
3859
}
@@ -57,6 +78,14 @@ public void setReadOnly(boolean readOnly) {
5778
this.readOnly = readOnly;
5879
}
5980

81+
public Comparison getComparison() {
82+
return comparison;
83+
}
84+
85+
public void setComparison(Comparison comparison) {
86+
this.comparison = comparison;
87+
}
88+
6089
@Override
6190
public boolean equals(Object other) {
6291
if(other instanceof ConfigPv) {
@@ -118,6 +147,11 @@ public Builder readOnly(boolean readOnly){
118147
return this;
119148
}
120149

150+
public Builder comparison(Comparison comparison){
151+
configPv.setComparison(comparison);
152+
return this;
153+
}
154+
121155
public ConfigPv build(){
122156
return configPv;
123157
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright (C) 2024 European Spallation Source ERIC.
3+
*/
4+
5+
package org.phoebus.applications.saveandrestore.model;
6+
7+
public enum PvCompareMode {
8+
NONE,
9+
RELATIVE,
10+
ABSOLUTE;
11+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public void testConfigPv() {
4242

4343
assertEquals("b", configPV.getReadbackPvName());
4444
assertTrue(configPV.isReadOnly());
45+
assertNull(configPV.getComparison());
46+
47+
configPV = ConfigPv.builder().pvName("a").readbackPvName("b").readOnly(true).comparison(new Comparison(PvCompareMode.ABSOLUTE, 1.0)).build();
48+
assertEquals(PvCompareMode.ABSOLUTE, configPV.getComparison().pvCompareMode());
49+
assertEquals(1.0, configPV.getComparison().tolerance());
4550
}
4651

4752
@Test

0 commit comments

Comments
 (0)