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
Expand Up @@ -252,6 +252,7 @@ public class Messages
WidgetProperties_Insets,
WidgetProperties_Interactive,
WidgetProperties_Interpolation,
WidgetProperties_InvertedScale,
WidgetProperties_ItemsFromPV,
WidgetProperties_KnobColor,
WidgetProperties_KnobPosition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
public static final WidgetPropertyDescriptor<Boolean> propOppositeScaleVisible =
newBooleanPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "opposite_scale_visible", Messages.WidgetProperties_OppositeScaleVisible);

/** 'inverted_scale' &mdash; run the scale top-down (right to left
* when horizontal), with the tank filling from the top.
* A log scale always runs bottom-up.
*/
public static final WidgetPropertyDescriptor<Boolean> propInvertedScale =
newBooleanPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "inverted_scale", Messages.WidgetProperties_InvertedScale);

/** Widget configurator to read legacy *.opi files*/
private static class CustomConfigurator extends WidgetConfigurator
{
Expand Down Expand Up @@ -171,6 +178,7 @@
private volatile WidgetProperty<Boolean> perpendicular_tick_labels;
private volatile WidgetProperty<Boolean> opposite_scale_visible;
private volatile WidgetProperty<Boolean> log_scale;
private volatile WidgetProperty<Boolean> invertedScale;
private volatile WidgetProperty<Boolean> horizontal;
private volatile WidgetProperty<Integer> border_width_prop;

Expand All @@ -195,6 +203,7 @@
properties.add(show_minor_ticks = propShowMinorTicks.createProperty(this, true));
properties.add(perpendicular_tick_labels = propPerpendicularTickLabels.createProperty(this, false));
properties.add(log_scale = propLogscale.createProperty(this, false));
properties.add(invertedScale = propInvertedScale.createProperty(this, false));

Check warning on line 206 in app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/TankWidget.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment out of this expression.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AaHMn9zx284JFoRyReHd&open=AaHMn9zx284JFoRyReHd&pullRequest=4016
properties.add(horizontal = propHorizontal.createProperty(this, false));
properties.add(border_width_prop = propTankBorderWidth.createProperty(this, 0));
}
Expand Down Expand Up @@ -268,6 +277,12 @@
return log_scale;
}

/** @return 'inverted_scale' property */
public WidgetProperty<Boolean> propInvertedScale()

Check failure on line 281 in app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/TankWidget.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename method "propInvertedScale" to prevent any misunderstanding/clash with field "propInvertedScale".

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AaHMn9zx284JFoRyReHe&open=AaHMn9zx284JFoRyReHe&pullRequest=4016
{
return invertedScale;
}

/** @return 'horizontal' property */
public WidgetProperty<Boolean> propHorizontal()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<width>50</width>
<height>310</height>
<limits_from_pv>false</limits_from_pv>
<minimum>102.0</minimum>
<maximum>-2.0</maximum>
<minimum>-2.0</minimum>
<maximum>102.0</maximum>
<inverted_scale>true</inverted_scale>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ WidgetProperties_InitialIndex=Initial Index
WidgetProperties_Insets=Insets
WidgetProperties_Interactive=Interactive
WidgetProperties_Interpolation=Interpolation
WidgetProperties_InvertedScale=Inverted Scale
WidgetProperties_ItemsFromPV=Items from PV
WidgetProperties_KnobColor=Knob Color
WidgetProperties_KnobPosition=Knob Position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ WidgetProperties_InitialIndex=Index initial
WidgetProperties_Insets=Marges
WidgetProperties_Interactive=Interactif
WidgetProperties_Interpolation=Interpolation
WidgetProperties_InvertedScale=\u00C9chelle invers\u00E9e
WidgetProperties_ItemsFromPV=\u00C9l\u00E9ments de la PV
WidgetProperties_KnobColor=Couleur du bouton
WidgetProperties_KnobPosition=Position du bouton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void testTankWidgetDefaults()
assertThat(tank.propFormat().getValue(), equalTo(ScaleFormat.DEFAULT));
assertThat(tank.propPrecision().getValue(), equalTo(2));
assertThat(tank.propLogScale().getValue(), equalTo(false));
assertThat(tank.propInvertedScale().getValue(), equalTo(false));
assertThat(tank.propHorizontal().getValue(), equalTo(false));
assertThat(tank.propBorderWidth().getValue(), equalTo(0));
}
Expand Down Expand Up @@ -140,6 +141,7 @@ public void testXmlRoundTrip() throws Exception
original.propPerpendicularTickLabels().setValue(true);
original.propFormat().setValue(ScaleFormat.DECIMAL);
original.propPrecision().setValue(3);
original.propInvertedScale().setValue(true);

// Serialize — disable skip_defaults so ALL properties appear
final DisplayModel model = new DisplayModel();
Expand All @@ -165,6 +167,7 @@ public void testXmlRoundTrip() throws Exception
assertThat(xml, containsString("<opposite_scale_visible>"));
assertThat(xml, containsString("<tank_border_width>"));
assertThat(xml, containsString("<level_lolo>"));
assertThat(xml, containsString("<inverted_scale>"));

// Deserialize
final ModelReader reader = new ModelReader(new ByteArrayInputStream(xml.getBytes()));
Expand All @@ -186,6 +189,7 @@ public void testXmlRoundTrip() throws Exception
assertThat(tank.propPerpendicularTickLabels().getValue(), equalTo(true));
assertThat(tank.propFormat().getValue(), equalTo(ScaleFormat.DECIMAL));
assertThat(tank.propPrecision().getValue(), equalTo(3));
assertThat(tank.propInvertedScale().getValue(), equalTo(true));
}

/** Verify that XML produced by this version can be read by a stock
Expand Down Expand Up @@ -213,5 +217,6 @@ public void testNewPropertiesAreOptional() throws Exception
assertThat(xml, not(containsString("<level_lolo>")));
assertThat(xml, not(containsString("<opposite_scale_visible>")));
assertThat(xml, not(containsString("<tank_border_width>")));
assertThat(xml, not(containsString("<inverted_scale>")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ protected void registerListeners()
model_widget.propLimitsFromPV().addUntypedPropertyListener(valueListener);
model_widget.propMinimum().addUntypedPropertyListener(valueListener);
model_widget.propMaximum().addUntypedPropertyListener(valueListener);
model_widget.propInvertedScale().addUntypedPropertyListener(valueListener);
model_widget.runtimePropValue().addUntypedPropertyListener(valueListener);
// Alarm limits; only need re-evaluation when limit properties change.
// When alarm_limits_from_pv=true, valueChanged() calls applyAlarmLimits() too.
Expand Down Expand Up @@ -114,6 +115,7 @@ protected void unregisterListeners()
model_widget.propLimitsFromPV().removePropertyListener(valueListener);
model_widget.propMinimum().removePropertyListener(valueListener);
model_widget.propMaximum().removePropertyListener(valueListener);
model_widget.propInvertedScale().removePropertyListener(valueListener);
model_widget.runtimePropValue().removePropertyListener(valueListener);
model_widget.propShowAlarmLimits().removePropertyListener(limitsListener);
model_widget.propAlarmLimitsFromPV().removePropertyListener(limitsListener);
Expand Down Expand Up @@ -151,7 +153,9 @@ private void valueChanged(final WidgetProperty<?> property, final Object old_val
max_val = display_info.getDisplayRange().getMaximum();
}
}
tank.setRange(min_val, max_val);
// Displays from before 'inverted_scale' invert the scale with minimum > maximum
tank.setInverted(model_widget.propInvertedScale().getValue() || min_val > max_val);
tank.setRange(Math.min(min_val, max_val), Math.max(min_val, max_val));

// Alarm metadata is embedded in the VType, so re-check it on every update.
// When using widget-configured limits, limitsChanged() handles updates instead.
Expand Down
Loading
Loading