1
2
3
4
5
6
7
8
9 package org.epics.pvmanager.jca;
10
11 import gov.aps.jca.Channel;
12 import gov.aps.jca.dbr.DBRType;
13 import org.epics.util.time.Timestamp;
14
15
16
17
18
19
20
21
22 public class JCAConnectionPayload {
23 private final JCADataSource jcaDataSource;
24 private final Channel channel;
25 private final boolean connected;
26 private final boolean longString;
27 private final DBRType fieldType;
28 private final Timestamp eventTime = Timestamp.now();
29
30 public JCAConnectionPayload(JCAChannelHandler channleHandler, Channel channel, JCAConnectionPayload previousPayload) {
31 this.jcaDataSource = channleHandler.getJcaDataSource();
32 this.channel = channel;
33 this.connected = channel != null && channel.getConnectionState() == Channel.ConnectionState.CONNECTED;
34 this.longString = channleHandler.isLongString();
35 if (channel.getFieldType().getClass() == null && previousPayload != null) {
36
37
38 this.fieldType = previousPayload.fieldType;
39 } else {
40 this.fieldType = channel.getFieldType();
41 }
42 }
43
44
45
46
47
48
49 public JCADataSource getJcaDataSource() {
50 return jcaDataSource;
51 }
52
53
54
55
56
57
58 public Channel getChannel() {
59 return channel;
60 }
61
62 public DBRType getFieldType() {
63 return fieldType;
64 }
65
66
67
68
69
70
71 public boolean isChannelConnected() {
72 return connected;
73 }
74
75
76
77
78
79
80 public boolean isWriteConnected() {
81 return isChannelConnected() && channel.getWriteAccess();
82 }
83
84
85
86
87
88
89 public boolean isLongString() {
90 return longString;
91 }
92
93
94
95
96
97
98 public Timestamp getEventTime() {
99 return eventTime;
100 }
101
102 @Override
103 public String toString() {
104 return "JCAConnection [connected: " +isChannelConnected() + " writeConnected: " + isWriteConnected() + " channel: " + channel + "]";
105 }
106
107 }