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_Int;
11 import org.epics.vtype.VInt;
12 import org.epics.vtype.VTypeToString;
13
14
15
16
17
18 class VIntFromDbr extends VNumberMetadata<DBR_TIME_Int, DBR_CTRL_Double> implements VInt {
19
20 public VIntFromDbr(DBR_TIME_Int dbrValue, DBR_CTRL_Double metadata, JCAConnectionPayload connPayload) {
21 super(dbrValue, metadata, connPayload);
22 }
23
24 private static DBR_TIME_Int convert(DBR dbrValue) {
25 try {
26 return (DBR_TIME_Int) dbrValue.convert(DBRType.TIME_INT);
27 } catch (Exception ex) {
28 throw new RuntimeException("Couldn't convert " + dbrValue.getType() + " to DBR_TIME_DOUBLE", ex);
29 }
30 }
31
32 public VIntFromDbr(DBR dbrValue, DBR_CTRL_Double metadata, JCAConnectionPayload connPayload) {
33 this(convert(dbrValue), metadata, connPayload);
34 }
35
36 @Override
37 public Integer getValue() {
38 return dbrValue.getIntValue()[0];
39 }
40
41 @Override
42 public String toString() {
43 return VTypeToString.toString(this);
44 }
45
46 }