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 @@ -20,6 +20,7 @@
import org.epics.vtype.AlarmStatus;
import org.epics.vtype.Display;
import org.epics.vtype.DisplayProvider;
import org.epics.vtype.DescriptionProvider;
import org.epics.vtype.EnumDisplay;
import org.epics.vtype.Time;
import org.epics.vtype.VBoolean;
Expand Down Expand Up @@ -83,9 +84,9 @@ public class PVTableItem

/** Listener to description PV */
private volatile Disposable desc_flow;

private volatile String[] valueOptions = null;

private static final String DESC_FIELD = "DESC";
private static final String DOT = ".";

Expand Down Expand Up @@ -178,7 +179,7 @@ private void createPVs(final String name)
// Determine DESC field include dot in case of variable name such as variableEGUName
desc_name = name.replace(DOT + fieldVal, DOT + DESC_FIELD);
}

try
{
final PV new_desc_pv = PVPool.getPV(desc_name);
Expand All @@ -200,31 +201,15 @@ private void createPVs(final String name)
}
}
}

private void updateDescription() {
if(desc_value == null) {
//update description from value or pv
VType currentValue = getValue();
if(currentValue != null) {
String description = null;
// DisplayProvider is an optional interface for VType values,
// not PVs, but the custum datasource as Muscade happens to implement
// DisplayProvider for enum and bool PVs, so check for that here
Display display = currentValue instanceof DisplayProvider ? ((DisplayProvider) currentValue).getDisplay(): null;
if(display == null && currentValue instanceof VEnum){
EnumDisplay enumdisplay = ((VEnum) currentValue).getDisplay();
if(enumdisplay instanceof DisplayProvider){
display = ((DisplayProvider)enumdisplay).getDisplay();
}
}
if (display != null) {
description = display.getDescription();
}
desc_value = description != null ? description : null;
desc_name = desc_value != null ? "Description of " + name + " PV" : "no description";
desc_flow = value_flow;
}
}
desc_value = switch (getValue()) {
case VEnum vEnum when vEnum.getDisplay() instanceof DescriptionProvider descriptionProvider -> descriptionProvider.getDescription().orElse("");
case DescriptionProvider descriptionProvider -> descriptionProvider.getDescription().orElse("");
default -> "";
};
desc_name = desc_value != null ? "Description of " + name + " PV" : "no description";
desc_flow = value_flow;
}

/** @return <code>true</code> if item is selected to be restored */
Expand Down Expand Up @@ -295,7 +280,7 @@ public String getDescription() {
updateDescription();
return desc_value == null ? "" : desc_value;
}

/** @return description pv name **/
public String getDescriptionName() {
return desc_name;
Expand All @@ -320,7 +305,7 @@ else if(copy instanceof VBoolean) {
}
return valueOptions;
}

/** @return index in case of Enum value */
public int getIndex() {
int index = - 1;
Expand Down
22 changes: 19 additions & 3 deletions core/pv-pva/src/main/java/org/phoebus/pv/pva/Decoders.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.time.Instant;
import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;

import org.epics.pva.data.PVAArray;
Expand All @@ -33,6 +34,7 @@
import org.epics.pva.data.PVAString;
import org.epics.pva.data.PVAStringArray;
import org.epics.pva.data.PVAStructure;
import org.epics.pvdata.pv.PVStructure;
import org.epics.util.array.ArrayByte;
import org.epics.util.array.ArrayDouble;
import org.epics.util.array.ArrayFloat;
Expand Down Expand Up @@ -243,6 +245,20 @@ public Number parse(String source, ParsePosition parsePosition)
}
}

private static Optional<String> decodeDescription(final PVAStructure struct) {
if (struct.get("display") instanceof PVAStructure display) {
if (display.get("description") instanceof PVAString pvaString) {
return Optional.ofNullable(pvaString.get());
}
else {
return Optional.empty();
}
}
else {
return Optional.empty();
}
}

private static Display decodeDisplay(final PVAStructure struct)
{
String units;
Expand Down Expand Up @@ -341,7 +357,7 @@ private static Display decodeDisplay(final PVAStructure struct)
*/
public static VType decodeBool(PVAStructure struct, PVABool field)
{
return VBoolean.of(field.get(), decodeAlarm(struct), decodeTime(struct));
return VBoolean.of(field.get(), decodeAlarm(struct), decodeTime(struct), decodeDescription(struct));
}

/** @param struct Structure
Expand All @@ -350,7 +366,7 @@ public static VType decodeBool(PVAStructure struct, PVABool field)
*/
public static VType decodeString(PVAStructure struct, PVAString field)
{
return VString.of(field.get(), decodeAlarm(struct), decodeTime(struct));
return VString.of(field.get(), decodeAlarm(struct), decodeTime(struct), decodeDescription(struct));
}

/** @param struct Structure for enum
Expand All @@ -366,7 +382,7 @@ public static VEnum decodeEnum(final PVAStructure struct) throws Exception
final int value = ((PVAInt)section.get("index")).get();
final PVAStringArray choices = section.get("choices");

return VEnum.of(value, EnumDisplay.of(choices.get()), alarm, time);
return VEnum.of(value, EnumDisplay.of(choices.get()), alarm, time, decodeDescription(struct));
}

/** @param struct Structure
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<project.build.outputTimestamp>2026-10-06T19:17:33Z</project.build.outputTimestamp>
<epics.version>7.0.11</epics.version>
<epics.util.version>1.0.8</epics.util.version>
<vtype.version>1.0.8</vtype.version>
<vtype.version>1.0.9-SNAPSHOT</vtype.version>
<openjfx.version>25.0.4</openjfx.version>
<!-- netscape.javascript jar for the JDK 26+ profiles; versioned separately
from openjfx as it's only published for 25+. -->
Expand Down
Loading