-
Notifications
You must be signed in to change notification settings - Fork 115
Save&Restore comparison of array data #3669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
35093e4
Setup base APIs to show dialog comparing stored array and live array
georgweiss 2f5314b
Add pv name to dialog layout
georgweiss ab385da
Update comparison table when PV is connected
georgweiss c9bacba
Render delta value in comparison dialog
georgweiss 4838f2b
Add styling of diff column
georgweiss 78385ca
Adding comparison dialog title
georgweiss 85b257d
Additional string resources
georgweiss e3a5f09
More styling and fixed sorting on delta column
georgweiss 6c6eef4
Clickable delta cell to launch dialog if arrays are not equal
georgweiss 7141bd3
Using VTypes instead of priminitives for the comparison dialog
georgweiss 0f70bee
Handle update if live data has fewer elements than stored snapshot
georgweiss b97b54d
Proper handling of differences in array length in comparisoon dialog
georgweiss 0024eed
Minor layout and code cleanup changes
georgweiss 9a8d40c
Javadoc and code cleanup
georgweiss 21e8517
Support for setting threshold when comparing array/table elements
georgweiss 357bdd8
Cleanup code when comparison dialog is closed
georgweiss fa7bb3c
Use VTypeHelper to determine array size
georgweiss ba95624
Adding documentation
georgweiss 77aacfb
Return infinite delta if arrays are of different length
georgweiss b764710
Merge branch 'master' into CSSTUDIO-3585
georgweiss fc547ad
Updated ordering and documentation
georgweiss d355c64
Updated ordering and documentation
georgweiss 24f8a08
Add dimensions and non-equal count to comparison dialog
georgweiss d2fba8b
Do not launch comparison dialog if live PV is not connected
georgweiss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+17.5 KB
app/save-and-restore/app/doc/images/compare-arrays-infinite-delta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...rc/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/compare/ColumnEntry.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright (C) 2025 European Spallation Source ERIC. | ||
| */ | ||
|
|
||
| package org.phoebus.applications.saveandrestore.ui.snapshot.compare; | ||
|
|
||
| import javafx.beans.property.ObjectProperty; | ||
| import javafx.beans.property.SimpleObjectProperty; | ||
| import org.epics.vtype.VNumber; | ||
| import org.epics.vtype.VType; | ||
| import org.phoebus.applications.saveandrestore.SafeMultiply; | ||
| import org.phoebus.applications.saveandrestore.ui.VTypePair; | ||
| import org.phoebus.saveandrestore.util.Threshold; | ||
| import org.phoebus.saveandrestore.util.Utilities; | ||
| import org.phoebus.saveandrestore.util.VNoData; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Data class for one column in the comparison table. | ||
| */ | ||
| public class ColumnEntry { | ||
|
|
||
| /** | ||
| * The {@link VType} value as stored in a {@link org.phoebus.applications.saveandrestore.model.Snapshot} | ||
| */ | ||
| private final ObjectProperty<VType> storedValue = new SimpleObjectProperty<>(this, "storedValue", null); | ||
| /** | ||
| * A {@link VTypePair} property holding data for the purpose of calculating and showing a delta. | ||
| */ | ||
| private final ObjectProperty<VTypePair> delta = new SimpleObjectProperty<>(this, "delta", null); | ||
| /** | ||
| * The live {@link VType} value as read from a connected PV. | ||
| */ | ||
| private final ObjectProperty<VType> liveValue = new SimpleObjectProperty<>(this, "liveValue", VNoData.INSTANCE); | ||
|
|
||
| private Optional<Threshold<?>> threshold = Optional.empty(); | ||
|
|
||
| public ColumnEntry(VType storedValue) { | ||
| this.storedValue.set(storedValue); | ||
| } | ||
|
|
||
| public ObjectProperty<VType> storedValueProperty() { | ||
| return storedValue; | ||
| } | ||
|
|
||
| public void setLiveVal(VType liveValue) { | ||
| this.liveValue.set(liveValue); | ||
| VTypePair vTypePair = new VTypePair(liveValue, storedValue.get(), threshold); | ||
| delta.set(vTypePair); | ||
| } | ||
|
|
||
| public ObjectProperty<VType> liveValueProperty() { | ||
| return liveValue; | ||
| } | ||
|
|
||
| public ObjectProperty<VTypePair> getDelta() { | ||
| return delta; | ||
| } | ||
|
|
||
| /** | ||
| * Set the threshold value for this entry. All value comparisons related to this entry are calculated using the | ||
| * threshold (if it exists). | ||
| * | ||
| * @param ratio the threshold | ||
| */ | ||
| public void setThreshold(double ratio) { | ||
| if (storedValue.get() instanceof VNumber) { | ||
| VNumber vNumber = SafeMultiply.multiply((VNumber) storedValue.get(), ratio); | ||
| boolean isNegative = vNumber.getValue().doubleValue() < 0; | ||
| Threshold t = new Threshold<>(isNegative ? SafeMultiply.multiply(vNumber.getValue(), -1.0) : vNumber.getValue()); | ||
| this.delta.set(new VTypePair(liveValue.get(), storedValue.get(), Optional.of(t))); | ||
| } | ||
| } | ||
| } |
55 changes: 55 additions & 0 deletions
55
...main/java/org/phoebus/applications/saveandrestore/ui/snapshot/compare/ComparisonData.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright (C) 2025 European Spallation Source ERIC. | ||
| */ | ||
|
|
||
| package org.phoebus.applications.saveandrestore.ui.snapshot.compare; | ||
|
|
||
| import javafx.beans.property.IntegerProperty; | ||
| import javafx.beans.property.SimpleIntegerProperty; | ||
| import org.epics.vtype.VType; | ||
| import org.phoebus.applications.saveandrestore.ui.VTypePair; | ||
| import org.phoebus.saveandrestore.util.Threshold; | ||
| import org.phoebus.saveandrestore.util.Utilities; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Data class for the {@link javafx.scene.control.TableView} of the comparison dialog. | ||
| */ | ||
| public class ComparisonData { | ||
|
|
||
| /** | ||
| * Index (=row number) for this instance. | ||
| */ | ||
| private final IntegerProperty index = new SimpleIntegerProperty(this, "index"); | ||
| /** | ||
| * {@link List} of {@link ColumnEntry}s, one for each column in the data. For array data this will | ||
| * hold only one element. | ||
| */ | ||
| private final List<ColumnEntry> columnEntries; | ||
|
|
||
| public ComparisonData(int index, List<ColumnEntry> columnEntries) { | ||
| this.index.set(index); | ||
| this.columnEntries = columnEntries; | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public IntegerProperty indexProperty() { | ||
| return index; | ||
| } | ||
|
|
||
| public List<ColumnEntry> getColumnEntries() { | ||
| return columnEntries; | ||
| } | ||
|
|
||
| /** | ||
| * Set the threshold value for this entry. All value comparisons related to this entry are calculated using the | ||
| * threshold (if it exists). | ||
| * | ||
| * @param ratio the threshold | ||
| */ | ||
| public void setThreshold(double ratio) { | ||
| columnEntries.forEach(columnEntry -> columnEntry.setThreshold(ratio)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the type parameter
Sadded toVTypeCellEditor?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to be able to use
VTypeCellEditorfor bothTableEntryandColumnEntry