Skip to content

Commit

Permalink
Add vtype to metadata of string PVs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wang Lin committed Jun 17, 2024
1 parent 4271154 commit a179ed8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/pvws/ws/Vtype2Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,20 @@ else if (value != null)
private static void handleString(final JsonGenerator g, final VString value, final VType last_value) throws Exception
{
final AlarmSeverity severity = value.getAlarm().getSeverity();
if (last_value == null ||
(last_value instanceof VString &&
((VString) last_value).getAlarm().getSeverity() != severity))
g.writeStringField("severity", value.getAlarm().getSeverity().name());
if (last_value == null)
{
// Initially, add complete metadata
g.writeStringField("vtype", VType.typeOf(value).getSimpleName());
// Initial severity
g.writeStringField("severity", severity.name());
}
else
{
// Add severity if it changed
if ((last_value instanceof VString) &&
((VString) last_value).getAlarm().getSeverity() != severity)
g.writeStringField("severity", severity.name());
}

g.writeStringField("text", value.getValue());
}
Expand Down

0 comments on commit a179ed8

Please sign in to comment.