1
2
3
4
5 package org.epics.pvmanager.jca;
6
7 import gov.aps.jca.Channel;
8 import gov.aps.jca.dbr.DBR;
9 import gov.aps.jca.dbr.DBR_String;
10 import gov.aps.jca.dbr.DBR_TIME_String;
11 import gov.aps.jca.dbr.Severity;
12 import gov.aps.jca.dbr.Status;
13 import gov.aps.jca.dbr.TimeStamp;
14 import gov.aps.jca.event.MonitorEvent;
15
16
17
18
19
20
21
22 public class JCAMessagePayload {
23 private final DBR metadata;
24 private final MonitorEvent event;
25
26 JCAMessagePayload(DBR metadata, MonitorEvent event) {
27 if (event != null) {
28
29
30 if (event.getDBR() instanceof DBR_String && !(event.getDBR() instanceof DBR_TIME_String)) {
31 DBR_String originalValue = (DBR_String) event.getDBR();
32
33 DBR_TIME_String value = new DBR_TIME_String(originalValue.getStringValue());
34 value.setSeverity(Severity.NO_ALARM);
35 value.setStatus(Status.NO_ALARM);
36 value.setTimeStamp(new TimeStamp());
37
38 event = new MonitorEvent((Channel) event.getSource(), value, event.getStatus());
39 }
40 }
41 this.metadata = metadata;
42 this.event = event;
43 }
44
45
46
47
48
49
50 public MonitorEvent getEvent() {
51 return event;
52 }
53
54
55
56
57
58
59 public DBR getMetadata() {
60 return metadata;
61 }
62
63 @Override
64 public String toString() {
65 DBR value = null;
66 if (event != null) {
67 value = event.getDBR();
68 }
69 return "Metadata " + metadata + " value " + value;
70 }
71
72 }