Skip to content

Commit

Permalink
Merge pull request #25 from wanglin86769/add-vtype-to-metadata-of-string
Browse files Browse the repository at this point in the history
Add vtype to metadata of string PVs
  • Loading branch information
kasemir authored Jun 17, 2024
2 parents 4271154 + a179ed8 commit b995613
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 b995613

Please sign in to comment.