1
2
3
4
5 package org.epics.pvmanager.jca;
6
7 import gov.aps.jca.dbr.DBR;
8 import gov.aps.jca.dbr.DBRType;
9 import gov.aps.jca.dbr.DBR_CTRL_Double;
10 import gov.aps.jca.dbr.DBR_TIME_Double;
11 import org.epics.vtype.VDouble;
12 import org.epics.vtype.VTypeToString;
13
14
15
16
17
18 class VDoubleFromDbr extends VNumberMetadata<DBR_TIME_Double, DBR_CTRL_Double> implements VDouble {
19
20 public VDoubleFromDbr(DBR_TIME_Double dbrValue, DBR_CTRL_Double metadata, JCAConnectionPayload connPayload) {
21 super(dbrValue, metadata, connPayload);
22 }
23
24 private static DBR_TIME_Double convert(DBR dbrValue) {
25 try {
26 return (DBR_TIME_Double) dbrValue.convert(DBRType.TIME_DOUBLE);
27 } catch (Exception ex) {
28 throw new RuntimeException("Couldn't convert " + dbrValue.getType() + " to DBR_TIME_DOUBLE", ex);
29 }
30 }
31
32 public VDoubleFromDbr(DBR dbrValue, DBR_CTRL_Double metadata, JCAConnectionPayload connPayload) {
33 this(convert(dbrValue), metadata, connPayload);
34 }
35
36 @Override
37 public Double getValue() {
38 return dbrValue.getDoubleValue()[0];
39 }
40
41 @Override
42 public String toString() {
43 return VTypeToString.toString(this);
44 }
45
46 }