Skip to content

Commit

Permalink
Merge branch 'master' into CSSTUDIO-2371
Browse files Browse the repository at this point in the history
  • Loading branch information
abrahamwolk committed Aug 27, 2024
2 parents 370d497 + 8b7da49 commit 536f705
Show file tree
Hide file tree
Showing 22 changed files with 279 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public class Messages
FormulaTabTT,
Grid,
GridLbl,
HideAll,
HideTraceWarning,
HideTraceWarningDetail,
ImportActionLabelFmt,
Expand Down Expand Up @@ -269,6 +270,7 @@ public class Messages
SelectTrace,
SeverityColumn,
SeverityStatusFmt,
ShowAll,
StartEndDialogBtn,
StartEndDialogTT,
StartTimeLbl,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Oak Ridge National Laboratory.
* Copyright (c) 2018-2024 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -10,14 +10,15 @@
import org.phoebus.framework.workbench.ApplicationService;
import org.phoebus.ui.javafx.ImageCache;
import org.phoebus.ui.spi.MenuEntry;
import org.phoebus.ui.spi.ToolbarEntry;

import javafx.scene.image.Image;

/** Menu entry for opening data browser
/** Menu and toolbar entry for opening data browser
* @author Kay Kasemir
*/
@SuppressWarnings("nls")
public class OpenDataBrowser implements MenuEntry
public class OpenDataBrowser implements MenuEntry, ToolbarEntry
{
@Override
public String getName()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2024 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************/
package org.csstudio.trends.databrowser3.ui.properties;

import org.csstudio.trends.databrowser3.Activator;
import org.csstudio.trends.databrowser3.Messages;
import org.csstudio.trends.databrowser3.model.AxisConfig;
import org.csstudio.trends.databrowser3.model.Model;
import org.csstudio.trends.databrowser3.model.ModelItem;
import org.phoebus.ui.undo.UndoableAction;
import org.phoebus.ui.undo.UndoableActionManager;

import javafx.scene.control.MenuItem;

/** MenuItem to show or hide all items
* @author Kay Kasemir
*/
@SuppressWarnings("nls")
public class ShowHideAllAction extends MenuItem
{
private class ShowHideAll extends UndoableAction
{
final private Model model;
final private boolean show;

ShowHideAll(final UndoableActionManager operations_manager,
final Model model, final boolean show)
{
super(show ? Messages.ShowAll : Messages.HideAll);
this.model = model;
this.show = show;
operations_manager.execute(this);
}

@Override
public void run()
{
for (ModelItem item : model.getItems())
item.setVisible(show);
for (AxisConfig axis : model.getAxes())
axis.setVisible(model.hasAxisActiveItems(axis));
}

@Override
public void undo()
{
for (ModelItem item : model.getItems())
item.setVisible(!show);
for (AxisConfig axis : model.getAxes())
axis.setVisible(model.hasAxisActiveItems(axis));
}
}

/** @param model Model
* @param undo Undo manager
* @param show Show all, or hide all?
*/
public ShowHideAllAction(final Model model, final UndoableActionManager undo, final boolean show)
{
super(show ? Messages.ShowAll : Messages.HideAll,
Activator.getIcon(show ? "checkbox" : "checkbox_unchecked"));
setOnAction(event -> new ShowHideAll(undo, model, show));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018-2020 Oak Ridge National Laboratory.
* Copyright (c) 2018-2024 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -733,6 +733,12 @@ private void createContextMenu()
items.add(new EditMultipleItemsAction(trace_table, model, undo, selection));

items.add(new SeparatorMenuItem());


items.add(new ShowHideAllAction(model, undo, true));
items.add(new ShowHideAllAction(model, undo, false));

items.add(new SeparatorMenuItem());

// Add PV-based entries
final List<ProcessVariable> pvs = selection.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.csstudio.trends.databrowser3.OpenDataBrowser
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ FormulaTabVariable=Variable
FormulaTabTT=Double-click input to add to formula, or edit variable name
Grid=Grid
GridLbl=Grid:
HideAll=Hide All
HideTraceWarning=Hide Trace?
HideTraceWarningDetail=Hiding a trace can be useful to...\na) temporarily reduce the number of traces on the plot\nb) hide formula input PVs where you are interested in the formula,\n but not the individual inputs\n\nNote however that the Databrowser will still sample data for the hidden trace and request archived data for it so that it's 'ready' when you want to show it again.\n\nIf you don't need this item at all, you should delete it instead of hiding it.\n\nHide trace?
ImportActionLabelFmt=Import {0}
Expand Down Expand Up @@ -249,6 +250,7 @@ SearchTT=Start the channel name search
SelectTrace=Select trace to see data sources
SeverityColumn=Severity
SeverityStatusFmt={0} / {1}
ShowAll=Show All
StartEndDialogBtn=...
StartEndDialogTT=Open start/end time dialog box
StartTimeLbl=Start Time:
Expand Down
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.
16 changes: 16 additions & 0 deletions app/save-and-restore/app/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,22 @@ the :math:`{\Delta}` Base Snapshot column will show the difference to the refere
.. image:: images/compare-snapshots-view.png
:width: 80%

Compare to archiver data
------------------------

In the context menu of a tab showing a snapshot user can chose to compare the snapshot to data retrieved from an
archiver, if one is configured:

.. image:: images/compare_to_archiver.png

Selecting this item will trigger a date/time picker where user can specify the point in time for which to get
archiver data:

.. image:: images/date_time_picker.png

Once data has been returned from the archiver service, it will be rendered as a snapshot in the comparison view.

**NOTE:** If the archiver does not contain a PV, it will be rendered as DISCONNECTED in the view.

Search And Filters
------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Messages {
public static String actionOpenNodeDescription;
public static String alertContinue;
public static String alertAddingPVsToConfiguration;
public static String archiver;
public static String authenticationFailed;
public static String baseSetpoint;
public static String buttonSearch;
Expand All @@ -38,6 +39,7 @@ public class Messages {
public static String contextMenuAddTagWithComment;
public static String contextMenuCreateSnapshot;
public static String contextMenuCompareSnapshots;
public static String contextMenuCompareSnapshotWithArchiverData;
public static String contextMenuDelete;
public static String copy;

Expand Down Expand Up @@ -65,6 +67,7 @@ public class Messages {
public static String currentPVValue;
public static String currentReadbackValue;
public static String currentSetpointValue;
public static String dateTimePickerTitle;
public static String deleteFilter;
public static String deleteFilterFailed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Dialog;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.Menu;
Expand Down Expand Up @@ -85,6 +86,7 @@
import org.phoebus.ui.dialog.DialogHelper;
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;
import org.phoebus.ui.javafx.ImageCache;
import org.phoebus.ui.time.DateTimePane;

import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
Expand All @@ -95,6 +97,7 @@
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -385,6 +388,7 @@ protected void compareSnapshot() {
compareSnapshot(browserSelectionModel.getSelectedItems().get(0).getValue());
}


/**
* Action when user requests comparison between an opened snapshot and the specifies snapshot {@link Node}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.phoebus.applications.saveandrestore.ui;

import org.epics.vtype.VType;
import org.phoebus.applications.saveandrestore.model.*;
import org.phoebus.applications.saveandrestore.model.CompositeSnapshot;
import org.phoebus.applications.saveandrestore.model.Configuration;
Expand All @@ -35,8 +36,12 @@
import org.phoebus.applications.saveandrestore.client.SaveAndRestoreJerseyClient;

import org.phoebus.core.vtypes.VDisconnectedData;
import org.phoebus.pv.PV;
import org.phoebus.pv.PVPool;
import org.phoebus.util.time.TimestampFormats;

import javax.ws.rs.core.MultivaluedMap;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -419,6 +424,7 @@ public List<RestoreResult> restore(String snapshotNodeId) throws Exception{

/**
* Requests service to take a snapshot, i.e. to read PVs as defined in a {@link Configuration}.
* This should be called off the UI thread.
* @param configurationNodeId The unique id of the {@link Configuration} for which to take the snapshot
* @return A {@link List} of {@link SnapshotItem}s carrying snapshot values read by the service.
*/
Expand All @@ -427,4 +433,58 @@ public List<SnapshotItem> takeSnapshot(String configurationNodeId) throws Except
executor.submit(() -> saveAndRestoreClient.takeSnapshot(configurationNodeId));
return future.get();
}

/**
* Requests service to take a snapshot, i.e. to read PVs as defined in a {@link Configuration}.
* This should be called off the UI thread.
* @param configurationNodeId The unique id of the {@link Configuration} for which to take the snapshot
* @param time If non-null, the snapshot is created from archived values.
* @return A {@link List} of {@link SnapshotItem}s carrying snapshot values read by the service or read
* from an archiver.
*/
public List<SnapshotItem> takeSnapshot(String configurationNodeId, Instant time) throws Exception{
if(time == null){
return takeSnapshot(configurationNodeId);
}
else{
ConfigurationData configNode = getConfiguration(configurationNodeId);
List<ConfigPv> configPvList = configNode.getPvList();
List<SnapshotItem> snapshotItems = new ArrayList<>();
configPvList.forEach(configPv -> {
SnapshotItem snapshotItem = new SnapshotItem();
snapshotItem.setConfigPv(configPv);
snapshotItem.setValue(readFromArchiver(configPv.getPvName(), time));
if(configPv.getReadbackPvName() != null){
snapshotItem.setValue(readFromArchiver(configPv.getReadbackPvName(), time));
}
snapshotItems.add(snapshotItem);
});
return snapshotItems;
}
}

/**
* Reads the PV value from archiver.
* @param pvName Name of PV, scheme like for instance pva:// will be removed.
* @param time The point in time supplied in the archiver request
* @return A {@link VType} value if archiver contains the wanted data, otherwise {@link VDisconnectedData}.
*/
private VType readFromArchiver(String pvName, Instant time){
// Check if pv name is prefixed with a scheme, e.g. pva://, ca://...
int indexSchemeSeparator = pvName.indexOf("://");
if(indexSchemeSeparator > 0 && pvName.length() > indexSchemeSeparator){
pvName = pvName.substring(indexSchemeSeparator + 1);
}
// Prepend "alarm://"
pvName = "archive://" + pvName + "(" + TimestampFormats.SECONDS_FORMAT.format(time) + ")";
try {
PV pv = PVPool.getPV(pvName);
VType pvValue = pv.read();
PVPool.releasePV(pv);
return pvValue;
} catch (Exception e) {
// Not found in archiver
return VDisconnectedData.INSTANCE;
}
}
}

This file was deleted.

Loading

0 comments on commit 536f705

Please sign in to comment.