|
7 | 7 | ******************************************************************************/ |
8 | 8 | package org.phoebus.pv.pva; |
9 | 9 |
|
| 10 | +import static java.util.stream.Collectors.toList; |
| 11 | +import static java.util.stream.IntStream.range; |
10 | 12 | import static org.phoebus.pv.pva.Decoders.decodeAlarm; |
11 | 13 | import static org.phoebus.pv.pva.Decoders.decodeTime; |
12 | 14 |
|
13 | 15 | import java.util.ArrayList; |
14 | 16 | import java.util.Arrays; |
15 | 17 | import java.util.List; |
16 | 18 | import java.util.Optional; |
| 19 | +import java.util.stream.Collectors; |
| 20 | +import java.util.stream.IntStream; |
17 | 21 |
|
18 | 22 | import org.epics.pva.data.PVAArray; |
19 | 23 | import org.epics.pva.data.PVABool; |
| 24 | +import org.epics.pva.data.PVABoolArray; |
20 | 25 | import org.epics.pva.data.PVAByteArray; |
21 | 26 | import org.epics.pva.data.PVAData; |
22 | 27 | import org.epics.pva.data.PVADoubleArray; |
|
30 | 35 | import org.epics.pva.data.PVAStructure; |
31 | 36 | import org.epics.pva.data.PVAStructureArray; |
32 | 37 | import org.epics.pva.data.PVAUnion; |
| 38 | +import org.epics.util.array.ArrayBoolean; |
| 39 | +import org.epics.util.array.ArrayByte; |
33 | 40 | import org.epics.util.array.ArrayDouble; |
34 | 41 | import org.epics.util.array.ArrayFloat; |
35 | 42 | import org.epics.util.array.ArrayInteger; |
| 43 | +import org.epics.util.array.ArrayLong; |
| 44 | +import org.epics.util.array.ArrayShort; |
| 45 | +import org.epics.util.array.ArrayUByte; |
36 | 46 | import org.epics.util.array.ArrayUInteger; |
| 47 | +import org.epics.util.array.ArrayULong; |
| 48 | +import org.epics.util.array.ArrayUShort; |
37 | 49 | import org.epics.vtype.Alarm; |
38 | 50 | import org.epics.vtype.AlarmSeverity; |
39 | 51 | import org.epics.vtype.AlarmStatus; |
@@ -203,6 +215,45 @@ else if (column instanceof PVAStringArray) |
203 | 215 | types.add(String.class); |
204 | 216 | values.add(Arrays.asList(typed.get())); |
205 | 217 | } |
| 218 | + else if (column instanceof PVAShortArray) |
| 219 | + { |
| 220 | + final PVAShortArray typed = (PVAShortArray)column; |
| 221 | + types.add(Short.TYPE); |
| 222 | + if (typed.isUnsigned()) |
| 223 | + values.add(ArrayUShort.of(typed.get())); |
| 224 | + else |
| 225 | + values.add(ArrayShort.of(typed.get())); |
| 226 | + } |
| 227 | + else if (column instanceof PVALongArray) |
| 228 | + { |
| 229 | + final PVALongArray typed = (PVALongArray)column; |
| 230 | + types.add(Long.TYPE); |
| 231 | + if (typed.isUnsigned()) |
| 232 | + values.add(ArrayULong.of(typed.get())); |
| 233 | + else |
| 234 | + values.add(ArrayLong.of(typed.get())); |
| 235 | + } |
| 236 | + else if (column instanceof PVAByteArray) |
| 237 | + { |
| 238 | + final PVAByteArray typed = (PVAByteArray)column; |
| 239 | + types.add(Byte.TYPE); |
| 240 | + if (typed.isUnsigned()) |
| 241 | + values.add(ArrayUByte.of(typed.get())); |
| 242 | + else |
| 243 | + values.add(ArrayByte.of(typed.get())); |
| 244 | + } |
| 245 | + else if (column instanceof PVABoolArray) |
| 246 | + { |
| 247 | + final PVABoolArray typed = (PVABoolArray)column; |
| 248 | + types.add(Boolean.TYPE); |
| 249 | + boolean[] data = typed.get(); |
| 250 | + // Convert to boxed Integer to add to List |
| 251 | + values.add(range(0, data.length).mapToObj(i -> data[i]).collect(toList())); |
| 252 | + } |
| 253 | + else |
| 254 | + { |
| 255 | + throw new RuntimeException("Could not decode table column of type: " + column.getClass()); |
| 256 | + } |
206 | 257 | } |
207 | 258 |
|
208 | 259 | return VTable.of(types, names, values); |
|
0 commit comments