77import org .epics .vtype .VFloat ;
88import org .epics .vtype .VInt ;
99import org .epics .vtype .VString ;
10+ import org .epics .vtype .VStringArray ;
1011import org .epics .vtype .VShort ;
1112import org .epics .vtype .VEnum ;
1213import org .epics .vtype .VIntArray ;
3536import gov .aps .jca .dbr .*;
3637
3738import java .text .NumberFormat ;
39+ import java .util .Arrays ;
3840import java .util .Collections ;
3941import java .util .HashSet ;
42+ import java .util .List ;
4043import java .util .Set ;
4144import java .util .regex .Pattern ;
4245
@@ -222,7 +225,7 @@ public VString createValue(DBR rawMessage, DBR metadata, CAConnectionPayload con
222225 } else {
223226 timestamp = CADataUtils .timestampOf (message .getTimeStamp ());
224227 }
225- return VString .of (String .valueOf (message .getStringValue ()), alarm , timestamp );
228+ return VString .of (String .valueOf (message .getStringValue ()[ 0 ] ), alarm , timestamp );
226229 }
227230 };
228231
@@ -438,6 +441,28 @@ public VIntArray createValue(DBR value, DBR rawMetadata, CAConnectionPayload con
438441 return VIntArray .of (data , alarm , timestamp , display );
439442 }
440443 };
444+
445+ // DBR_TIME_String -> VString
446+ final static CATypeAdapter DBRStringToVStringArray = new CATypeAdapter (VStringArray .class , DBR_TIME_String .TYPE , null , false ) {
447+
448+ @ Override
449+ public VStringArray createValue (DBR rawMessage , DBR metadata , CAConnectionPayload connPayload ) {
450+ DBR_TIME_String message = (DBR_TIME_String )rawMessage ;
451+ Alarm alarm ;
452+ if (!connPayload .isChannelConnected ()) {
453+ alarm = Alarm .disconnected ();
454+ } else {
455+ alarm = CADataUtils .fromEpics (message .getSeverity ());
456+ }
457+ Time timestamp ;
458+ if (!connPayload .isChannelConnected ()) {
459+ timestamp = Time .of (connPayload .getEventTime ());
460+ } else {
461+ timestamp = CADataUtils .timestampOf (message .getTimeStamp ());
462+ }
463+ return VStringArray .of (Arrays .asList (message .getStringValue ()), alarm , timestamp );
464+ }
465+ };
441466
442467 private static final Set <CATypeAdapter > converters ;
443468
@@ -459,6 +484,7 @@ public VIntArray createValue(DBR value, DBR rawMetadata, CAConnectionPayload con
459484 newFactories .add (DBRByteToVByteArray );
460485 newFactories .add (DBRShortToVShortArray );
461486 newFactories .add (DBRIntToVIntArray );
487+ newFactories .add (DBRStringToVStringArray );
462488 converters = Collections .unmodifiableSet (newFactories );
463489 }
464490
0 commit comments