Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 48 additions & 28 deletions app/alarm/ui/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,9 @@ Alarm Configuration Options

Alarm configurations are imported into the Alarm Server in an XML
format, the schema for which may be found `here <https://github.com/ControlSystemStudio/phoebus/app/alarm/examples/alarm_configuration.xsd>`_.
The options for an entry in the hierarchical alarm configuration
always include guidance, display links etc. as described further below.
In addition, alarm PV entries have the following settings.

Description
^^^^^^^^^^^
This text is displayed in the alarm table when the alarm triggers.

The description is also used by the alarm annunciator.
By default, the annunciator will start the actual message with
the alarm severity. For example, a description of "Vacuum Problem"
will be annunciated as for example "Minor Alarm: Vacuum Problem".
The addition of the alarm severity can be disabled by starting
the description with a "\*" as in "\* Vacuum Problem".

When there is a flurry of alarms, the annunciator will summarize
them to "There are 10 more alarms". To assert that certain alarms
are always annunciated, even if they occur within a burst of other alarms,
start the message with "!" (or "\*!").


Behavior
^^^^^^^^
Behavior - PV entries
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Enabled:
De-select to disable an alarm, i.e. to ignore the value of this alarm trigger PV.
Expand All @@ -171,10 +151,14 @@ Behavior
Should the alarm be annunciated (if the annunciator is running), or should it only
be displayed silently?

* Disable until:
Disables an alarm and sets a date and time when the alarm
would be enabled automatically. User may select absolute or relative date/time.

* Alarm Delay:
Only alarm if the trigger PV remains in alarm for at least this time,
see examples below.

* Alarm Count:
Used in combination with the alarm delay.
If the trigger PVs exhibits a not-OK alarm severity more than 'count' times
Expand All @@ -188,9 +172,8 @@ Behavior

* Enabling Filter:
An optional expression that can enable the alarm based on other PVs.

Example: `'abc' > 10` will only enable this alarm if the PV 'abc' has a value above 10.

Example: `'abc' > 10` will only enable this alarm if the PV 'abc' has a value above 10.

The Alarm Delay and Count work in combination.
By default, with both the alarm delay and count at zero, a non-OK PV severity is right away recognized.
Expand Down Expand Up @@ -230,8 +213,45 @@ guidance and display links which allow the user to figure out:
* What does this alarm mean? What should I do about it?
* What displays allow me to see more, where can I do something about the alarm?

Behavior - component entries
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Enabled:
Enable or disable all PV items in the subtree.

* Disable until:
Disables an all PV items in the subtree and set a date and time when the alarms
would be enabled automatically. User may select absolute or relative date/time.

Note:

* An enable date will be set even if a PV item is already disabled.

* Ticking the Enable check box will enable all PVs in the subtree when saving the changes,
including those that have an enable date set.

* If an enable date is set on any PV in the subtree, it is not possible to set an enable
date.

Description - PV entries only
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This text is displayed in the alarm table when the alarm triggers.

The description is also used by the alarm annunciator.
By default, the annunciator will start the actual message with
the alarm severity. For example, a description of "Vacuum Problem"
will be annunciated as for example "Minor Alarm: Vacuum Problem".
The addition of the alarm severity can be disabled by starting
the description with a "\*" as in "\* Vacuum Problem".

When there is a flurry of alarms, the annunciator will summarize
them to "There are 10 more alarms". To assert that certain alarms
are always annunciated, even if they occur within a burst of other alarms,
start the message with "!" (or "\*!").

Guidance
--------
^^^^^^^^

Each alarm should have at least one guidance message to explain the meaning
of an alarm to the user, to list for example contact information for subsystem experts.
Expand All @@ -249,7 +269,7 @@ parent components of the alarm hierarchy.


Displays
--------
^^^^^^^^

As with Guidance, each alarm should have at least one link to a control
system display that shows the actual alarm PV and the surrounding subsystem.
Expand All @@ -275,7 +295,7 @@ Examples::
file:///path/to/display.bob?MACRO=Value&OTHER=42$NAME=Text+with+spaces

Automated Actions
-----------------
^^^^^^^^^^^^^^^^

Automated actions are performed when the node in the alarm hierarchy enters and remains in
an active alarm state for some time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@

public static String acknowledgeFailed;
public static String addComponentFailed;
public static String configure;

Check warning on line 18 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make configure a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2m&open=AZ5pWHlQoTWlItriCU2m&pullRequest=3809

Check warning on line 18 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static configure" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2z&open=AZ5pWHlQoTWlItriCU2z&pullRequest=3809
public static String delayTooltip0;

Check warning on line 19 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make delayTooltip0 a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2n&open=AZ5pWHlQoTWlItriCU2n&pullRequest=3809

Check warning on line 19 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static delayTooltip0" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU20&open=AZ5pWHlQoTWlItriCU20&pullRequest=3809
public static String delayTooltip1;

Check warning on line 20 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make delayTooltip1 a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2o&open=AZ5pWHlQoTWlItriCU2o&pullRequest=3809

Check warning on line 20 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static delayTooltip1" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU21&open=AZ5pWHlQoTWlItriCU21&pullRequest=3809
public static String delayTooltip2;

Check warning on line 21 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make delayTooltip2 a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2p&open=AZ5pWHlQoTWlItriCU2p&pullRequest=3809

Check warning on line 21 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static delayTooltip2" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU22&open=AZ5pWHlQoTWlItriCU22&pullRequest=3809
public static String disableAlarmFailed;
public static String disableAlarms;

Check warning on line 23 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make disableAlarms a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2q&open=AZ5pWHlQoTWlItriCU2q&pullRequest=3809

Check warning on line 23 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static disableAlarms" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU23&open=AZ5pWHlQoTWlItriCU23&pullRequest=3809
public static String disabled;
public static String disabledUntil;
public static String enableAlarmFailed;
public static String enableAlarms;

Check warning on line 27 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static enableAlarms" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU24&open=AZ5pWHlQoTWlItriCU24&pullRequest=3809

Check warning on line 27 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make enableAlarms a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2r&open=AZ5pWHlQoTWlItriCU2r&pullRequest=3809
public static String headerAlreadyDisabled;

Check warning on line 28 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make headerAlreadyDisabled a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2s&open=AZ5pWHlQoTWlItriCU2s&pullRequest=3809

Check warning on line 28 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static headerAlreadyDisabled" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU25&open=AZ5pWHlQoTWlItriCU25&pullRequest=3809
public static String headerAlreadyEnabled;

Check warning on line 29 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static headerAlreadyEnabled" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU26&open=AZ5pWHlQoTWlItriCU26&pullRequest=3809

Check warning on line 29 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make headerAlreadyEnabled a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2t&open=AZ5pWHlQoTWlItriCU2t&pullRequest=3809
public static String headerConfirmDisable;

Check warning on line 30 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static headerConfirmDisable" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU27&open=AZ5pWHlQoTWlItriCU27&pullRequest=3809

Check warning on line 30 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make headerConfirmDisable a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2u&open=AZ5pWHlQoTWlItriCU2u&pullRequest=3809
public static String headerConfirmDisableWithEnableDate;

Check warning on line 31 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make headerConfirmDisableWithEnableDate a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2v&open=AZ5pWHlQoTWlItriCU2v&pullRequest=3809

Check warning on line 31 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static headerConfirmDisableWithEnableDate" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU28&open=AZ5pWHlQoTWlItriCU28&pullRequest=3809
public static String headerConfirmEnable;

Check warning on line 32 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make headerConfirmEnable a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2w&open=AZ5pWHlQoTWlItriCU2w&pullRequest=3809

Check warning on line 32 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static headerConfirmEnable" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU29&open=AZ5pWHlQoTWlItriCU29&pullRequest=3809
public static String moveItemFailed;
public static String partlyDisabled;
public static String promptTitle;

Check warning on line 35 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static promptTitle" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2-&open=AZ5pWHlQoTWlItriCU2-&pullRequest=3809

Check warning on line 35 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make promptTitle a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2x&open=AZ5pWHlQoTWlItriCU2x&pullRequest=3809
public static String promptContent;

Check warning on line 36 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make promptContent a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2y&open=AZ5pWHlQoTWlItriCU2y&pullRequest=3809

Check warning on line 36 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static promptContent" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHlQoTWlItriCU2_&open=AZ5pWHlQoTWlItriCU2_&pullRequest=3809
public static String removeComponentFailed;
public static String renameItemFailed;
public static String timer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
/*
* Copyright (C) 2025 European Spallation Source ERIC.
*/
package org.phoebus.applications.alarm.ui.config;

import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import org.phoebus.applications.alarm.client.AlarmClient;
import org.phoebus.applications.alarm.client.AlarmClientLeaf;
import org.phoebus.applications.alarm.model.AlarmTreeItem;
import org.phoebus.applications.alarm.ui.Messages;
import org.phoebus.applications.alarm.ui.tree.ComponentActionHelper;
import org.phoebus.framework.jobs.JobManager;
import org.phoebus.ui.dialog.DialogHelper;
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;

import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* FXML controller for LeafConfigDialog.fxml.
*/
@SuppressWarnings("nls")
public class ComponentConfigDialogController extends ConfigDialogController {


// ── FXML-injected fields ──────────────────────────────────────────────────

@SuppressWarnings("unused")
@FXML
private ScrollPane scroll;
@SuppressWarnings("unused")
@FXML
private javafx.scene.layout.GridPane layout;

// Path row (always visible)
@SuppressWarnings("unused")
@FXML
private TextField path;

// Leaf-only rows
@SuppressWarnings("unused")
@FXML
private Label descriptionLabel;
@SuppressWarnings("unused")
@FXML
private TextField description;

@SuppressWarnings("unused")
@FXML
private Label behaviorLabel;
@SuppressWarnings("unused")
@FXML
private HBox behaviorBox;
@SuppressWarnings("unused")
@FXML
private CheckBox enabled;

Check failure on line 69 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/config/ComponentConfigDialogController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"enabled" is the name of a field in "ConfigDialogController".

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHgyoTWlItriCU2a&open=AZ5pWHgyoTWlItriCU2a&pullRequest=3809

@SuppressWarnings("unused")
@FXML
private Label disableUntilLabel;
@SuppressWarnings("unused")
@FXML
private ComboBox<String> relativeDate;

Check failure on line 76 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/config/ComponentConfigDialogController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"relativeDate" is the name of a field in "ConfigDialogController".

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHgyoTWlItriCU2b&open=AZ5pWHgyoTWlItriCU2b&pullRequest=3809

@SuppressWarnings("unused")
@FXML
private DateTimePicker enabledDatePicker;

Check failure on line 80 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/config/ComponentConfigDialogController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"enabledDatePicker" is the name of a field in "ConfigDialogController".

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHgyoTWlItriCU2c&open=AZ5pWHgyoTWlItriCU2c&pullRequest=3809

@SuppressWarnings("unused")
@FXML
private Label partlyDisabledLabel;

private List<AlarmClientLeaf> alarmClientLeaves;

public ComponentConfigDialogController(AlarmClient alarmClient, AlarmTreeItem<?> alarmTreeItem) {
super(alarmClient, alarmTreeItem);
}

@SuppressWarnings("unused")
@FXML
public void initialize() {

Check warning on line 94 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/config/ComponentConfigDialogController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add the "@Override" annotation above this method signature

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHgyoTWlItriCU2d&open=AZ5pWHgyoTWlItriCU2d&pullRequest=3809

super.initialize();

alarmClientLeaves = new ArrayList<>();
List<AlarmClientLeaf> disabled = new ArrayList<>();
List<AlarmClientLeaf> withEnableDate = new ArrayList<>();
// Check subtree for disabled PVs and PVs with non-null enable date
findAffectedPVs(alarmTreeItem, alarmClientLeaves, disabled, withEnableDate);

if(disabled.isEmpty()) {
enabled.setSelected(true);
}
else if (alarmClientLeaves.size() != disabled.size()) {
partlyDisabledLabel.setVisible(true);
enabled.setSelected(false);
}

if (!withEnableDate.isEmpty()) {
relativeDate.setDisable(true);
enabledDatePicker.setDisable(true);
}
}

/**
* Validates input and sends the configuration off to the message broker.
*
*/
public void validateAndStore() {

// First check if user has specified a valid enable date
LocalDateTime enableDate;
try {
enableDate = determineEnableDate();
} catch (Exception e) {
Logger.getLogger(LeafConfigDialogController.class.getName())
.log(Level.WARNING, "Invalid enable date specified", e);
return;
}

// Next store guidance, displays...
alarmTreeItem.setGuidance(guidance.getItems());
alarmTreeItem.setDisplays(displays.getItems());
alarmTreeItem.setCommands(commands.getItems());
alarmTreeItem.setActions(actions.getItems());

try {
alarmClient.sendItemConfigurationUpdate(alarmTreeItem.getPathName(), alarmTreeItem);
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError("Error", "Cannot update item", ex);
return;
}

// Lastly update enable or - if non-null - set enable date.
if (enableDate != null) {
updateEnablement(enableDate);
} else {
ComponentActionHelper.updateEnablement(scroll, alarmClient, List.of(alarmTreeItem), itemEnabledProperty.get());
}
}

/**
* Updates a component to disable a hierarchy of PVs with an enable date.
*
* @param enableDate The {@link LocalDateTime} to set on all leaf nodes specified in <code>items</code> .
*/
private void updateEnablement(LocalDateTime enableDate) {
if (alarmClientLeaves.isEmpty()) {
return;
}
if (alarmClientLeaves.size() > 1) {
final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);
dialog.setTitle(Messages.disableAlarms);
dialog.setHeaderText(MessageFormat.format(Messages.headerConfirmDisableWithEnableDate, enableDate, alarmClientLeaves.size()));

DialogHelper.positionDialog(dialog, scroll, -50, -25);
if (dialog.showAndWait().get() != ButtonType.OK) {
return;
}
}

JobManager.schedule(Messages.disableAlarms, monitor ->
{
for (AlarmClientLeaf pv : alarmClientLeaves) {
final AlarmClientLeaf copy = pv.createDetachedCopy();
if (copy.setEnabledDate(enableDate)) {
try {
alarmClient.sendItemConfigurationUpdate(pv.getPathName(), copy);
} catch (Exception e) {
ExceptionDetailsErrorDialog.openError(Messages.error,
Messages.disableAlarmFailed,
e);
throw e;
}
}
}
});
}

/**
* Recursively counts alarm tree items in a subtree to find total number, number of disabled, and
* number of disabled with enable date.
*
* @param item Root item
* @param total {@link AtomicInteger} that will hold the total number of leaf nodes
* @param disabled {@link AtomicInteger} that will hold the number of disabled leaf nodes (with or without enable date)
* @param withEnableDate {@link AtomicInteger} that will hold the number of leaf nodes with non-null enable date
*
*/
public static void findAffectedPVs(final AlarmTreeItem<?> item, final List<AlarmClientLeaf> total, final List<AlarmClientLeaf> disabled, final List<AlarmClientLeaf> withEnableDate) {
if (item instanceof AlarmClientLeaf) {

Check warning on line 204 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/config/ComponentConfigDialogController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this instanceof check and cast with 'instanceof AlarmClientLeaf pv'

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ5pWHgyoTWlItriCU2e&open=AZ5pWHgyoTWlItriCU2e&pullRequest=3809
final AlarmClientLeaf pv = (AlarmClientLeaf) item;
total.add(pv);
if (!pv.isEnabled()) {
disabled.add(pv);
if (pv.getEnabledDate() != null) {
withEnableDate.add(pv);
}
}
} else {
for (AlarmTreeItem<?> sub : item.getChildren()) {
findAffectedPVs(sub, total, disabled, withEnableDate);
}
}
}
}
Loading
Loading