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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/*
* This file is part of the ISIS IBEX application.
* Copyright (C) 2012-2015 Science & Technology Facilities Council.
* Copyright (C) 2012-2025 Science & Technology Facilities Council.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful.
Expand Down Expand Up @@ -63,6 +63,12 @@ public class Block extends ModelObject implements IRuncontrol, INamedInComponent
private boolean set_block;
private String set_block_val;

// Alarms config information
private boolean alarmenabled;
private boolean alarmlatched;
private double alarmdelay;
private String alarmguidance;

/**
* Creates a new block given input properties.
*
Expand All @@ -71,9 +77,10 @@ public class Block extends ModelObject implements IRuncontrol, INamedInComponent
* @param visible whether the block should be shown
* @param local whether the PV is local to the instrument
*/
public Block(String name, String pv, boolean visible, boolean local) {
this(name, pv, visible, local, null, 0.0f, 0.0f, false, false, true, DEFAULT_SCAN_RATE, 0.0f, false, "");
}
public Block(String name, String pv, boolean visible, boolean local) {
this(name, pv, visible, local, null, 0.0f, 0.0f, false, false, true, DEFAULT_SCAN_RATE, 0.0f, false, "", false,
false, 0.0d, "");
}

/**
* Creates a new block given input properties.
Expand All @@ -93,23 +100,33 @@ public Block(String name, String pv, boolean visible, boolean local) {
* @param logDeadband deadband for the block to be archived
* @param blockSet A boolean value indicating whether or not to set a value on block on config change.
* @param blockSetVal The value to set the block to on config change if the blockSet is true.
*/
public Block(String name, String pv, boolean visible, boolean local, String component, double lowLimit,
double highLimit, boolean suspendOnInvalid, Boolean runcontrol, boolean logPeriodic, int logRate, float logDeadband, boolean blockSet, String blockSetVal) {
* @param alarmEnabled whether alarm are enabled for this block
* @param alarmLatched whether alarm are latched for this block
* @param alarmDelay the delay before the alarm is triggered
* @param alarmGuidance guidance text for alarm
*/
public Block(String name, String pv, boolean visible, boolean local, String component, double lowLimit,
double highLimit, boolean suspendOnInvalid, Boolean runcontrol, boolean logPeriodic, int logRate,
float logDeadband, boolean blockSet, String blockSetVal, boolean alarmEnabled, boolean alarmLatched,
Double alarmDelay, String alarmGuidance) {
this.name = name;
this.pv = pv;
this.visible = visible;
this.local = local;
this.component = component;
this.lowlimit = lowLimit;
this.highlimit = highLimit;
this.runcontrol = runcontrol;
this.log_deadband = logDeadband;
this.log_periodic = logPeriodic;
this.log_rate = logRate;
this.suspend_on_invalid = suspendOnInvalid;
this.set_block = blockSet;
this.set_block_val = blockSetVal;
this.lowlimit = lowLimit;
this.highlimit = highLimit;
this.runcontrol = runcontrol;
this.log_deadband = logDeadband;
this.log_periodic = logPeriodic;
this.log_rate = logRate;
this.suspend_on_invalid = suspendOnInvalid;
this.set_block = blockSet;
this.set_block_val = blockSetVal;
this.alarmenabled = alarmEnabled;
this.alarmlatched = alarmLatched;
this.alarmdelay = alarmDelay;
this.alarmguidance = alarmGuidance;
}

/**
Expand All @@ -118,8 +135,9 @@ public Block(String name, String pv, boolean visible, boolean local, String comp
* @param other the block to be copied
*/
public Block(Block other) {
this(other.name, other.pv, other.visible, other.local, other.component, other.lowlimit, other.highlimit, other.suspend_on_invalid,
other.runcontrol, other.log_periodic, other.log_rate, other.log_deadband, other.set_block, other.set_block_val);
this(other.name, other.pv, other.visible, other.local, other.component, other.lowlimit, other.highlimit,
other.suspend_on_invalid, other.runcontrol, other.log_periodic, other.log_rate, other.log_deadband,
other.set_block, other.set_block_val, other.alarmenabled, other.alarmlatched, other.alarmdelay, other.alarmguidance);
}

/**
Expand Down Expand Up @@ -385,6 +403,62 @@ public String getblockSetVal() {
return set_block_val;
}

/**
* @return the alarmEnabled
*/
public boolean isAlarmEnabled() {
return alarmenabled;
}

/**
* @param alarmEnabled the alarmEnabled to set
*/
public void setAlarmEnabled(boolean alarmEnabled) {
firePropertyChange("alarmEnabled", this.alarmenabled, this.alarmenabled = alarmEnabled);
}

/**
* @return the alarmLatched
*/
public boolean isAlarmLatched() {
return alarmlatched;
}

/**
* @param alarmLatched the alarmLatched to set
*/
public void setAlarmLatched(boolean alarmLatched) {
firePropertyChange("alarmLatched", this.alarmlatched, this.alarmlatched = alarmLatched);
}

/**
* @return the alarmDelay
*/
public double getAlarmDelay() {
return alarmdelay;
}

/**
* @param alarmDelay the alarmDelay to set
*/
public void setAlarmDelay(double alarmDelay) {
firePropertyChange("alarmDelay", this.alarmdelay, this.alarmdelay = alarmDelay);
}

/**
* @return the alarmGuidance
*/
public String getAlarmGuidance() {
return alarmguidance;
}

/**
* @param alarmGuidance the alarmGuidance to set
*/
public void setAlarmGuidance(String alarmGuidance) {
firePropertyChange("alarmGuidance", this.alarmguidance, this.alarmguidance = alarmGuidance);
}

@Override
public String toString() {
return name;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* This file is part of the ISIS IBEX application. Copyright (C) 2012-2025
* Science & Technology Facilities Council. All rights reserved.
*
* This program is distributed in the hope that it will be useful. This program
* and the accompanying materials are made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution. EXCEPT AS
* EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM AND
* ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND. See the Eclipse Public License v1.0 for more
* details.
*
* You should have received a copy of the Eclipse Public License v1.0 along with
* this program; if not, you can obtain a copy from
* https://www.eclipse.org/org/documents/epl-v10.php or
* http://opensource.org/licenses/eclipse-1.0.php
*/

package uk.ac.stfc.isis.ibex.ui.configserver.editing.blocks;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import uk.ac.stfc.isis.ibex.ui.widgets.buttons.IBEXButton;

/**
* A panel in the edit block dialog for the block's alarm configuration settings.
*/
@SuppressWarnings("checkstyle:magicnumber")
public class BlockAlarmConfigPanel extends Composite {
private Text lowLimit;
private Text highLimit;
private Text delay;
private Text guidance;
private Button enabled;
private Button latched;

/**
* Standard constructor.
*
* @param parent The parent composite.
* @param style The SWT style.
* @param viewModel The viewModel for the block alarm configuration.
*/
public BlockAlarmConfigPanel(Composite parent, int style, BlockAlarmConfigViewModel viewModel) {
super(parent, style);
setLayout(new FillLayout(SWT.HORIZONTAL));

Group alarmConfigGroup = new Group(this, SWT.NONE);
alarmConfigGroup.setText("Alarm Configurations");
alarmConfigGroup.setLayout(new GridLayout(6, false));

addLabel(alarmConfigGroup, "Low Limit:");
lowLimit = new Text(alarmConfigGroup, SWT.BORDER);
lowLimit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lowLimit.setToolTipText("Alarm Low limit - not managed at block level");
lowLimit.setEnabled(false); // Low limit is currently not editable.
//lowLimit.setText(viewModel.getLowLimit());

addLabel(alarmConfigGroup, "High Limit:");
highLimit = new Text(alarmConfigGroup, SWT.BORDER);
highLimit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
highLimit.setToolTipText("Alarm High limit - not managed at block level");
highLimit.setEnabled(false); // High limit is currently not editable.
//highLimit.setText(viewModel.getHighLimit());

addLabel(alarmConfigGroup, "Delay:");
delay = new Text(alarmConfigGroup, SWT.BORDER);
delay.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
delay.setToolTipText("Delay before the alarm is triggered");

enabled = new IBEXButton(alarmConfigGroup, SWT.CHECK)
.layoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1))
.text("Enabled").tooltip("Enable or disable the alarm")
.get();

latched = new IBEXButton(alarmConfigGroup, SWT.CHECK)
.layoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1))
.text("Latched").tooltip("Enable or disable latched alarm behavior")
.get();

addLabel(alarmConfigGroup, "Guidance:");
guidance = new Text(alarmConfigGroup, SWT.BORDER);
GridData grid = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
grid.widthHint = 200;
guidance.setLayoutData(grid);
guidance.setToolTipText("Guidance text for the alarm configuration");
setModel(viewModel);
}

/**
* @param alarmConfigGroup the group to which the label is added
* @param labelText the text for the label
*/
private void addLabel(Group alarmConfigGroup, String labelText) {
Label label = new Label(alarmConfigGroup, SWT.NONE);
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
label.setText(labelText);
}

/**
* Sets the view model and observers for run control settings.
* @param viewModel The view model for run control settings.
*/
private void setModel(BlockAlarmConfigViewModel viewModel) {
DataBindingContext bindingContext = new DataBindingContext();

bindingContext.bindValue(WidgetProperties.buttonSelection().observe(enabled),
BeanProperties.value(BlockAlarmConfigViewModel.ENABLED_BINDING_NAME).observe(viewModel));
bindingContext.bindValue(WidgetProperties.buttonSelection().observe(latched),
BeanProperties.value(BlockAlarmConfigViewModel.LATCHED_BINDING_NAME).observe(viewModel));
bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(delay),
BeanProperties.value(BlockAlarmConfigViewModel.DELAY_BINDING_NAME).observe(viewModel));
bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(guidance),
BeanProperties.value(BlockAlarmConfigViewModel.GUIDANCE_BINDING_NAME).observe(viewModel));
bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(lowLimit),
BeanProperties.value(BlockAlarmConfigViewModel.LOWLIMIT_BINDING_NAME).observe(viewModel));
bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(highLimit),
BeanProperties.value(BlockAlarmConfigViewModel.HIGHLIMIT_BINDING_NAME).observe(viewModel));
}
}
Loading
Loading