|
| 1 | +/* |
| 2 | + * Copyright 2019 Tango Controls |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
1 | 17 | package org.tango.rest.rc4;
|
2 | 18 |
|
3 | 19 | import fr.esrf.Tango.DevFailed;
|
@@ -68,40 +84,40 @@ public static fr.esrf.TangoApi.DeviceAttribute[] getDeviceAttributesValue(TangoD
|
68 | 84 | //TODO split into good and bad attributes: write good ones; report bad ones (if present)
|
69 | 85 | fr.esrf.TangoApi.DeviceAttribute[] attrs =
|
70 | 86 | queryParams.stream()
|
71 |
| - .map(stringListEntry -> { |
72 |
| - String attrName = stringListEntry.getKey(); |
73 |
| - String[] value = stringListEntry.getValue().toArray(new String[stringListEntry.getValue().size()]); |
74 |
| - DeviceAttribute result; |
| 87 | + .map(stringListEntry -> { |
| 88 | + String attrName = stringListEntry.getKey(); |
| 89 | + String[] value = stringListEntry.getValue().toArray(new String[stringListEntry.getValue().size()]); |
| 90 | + DeviceAttribute result; |
75 | 91 |
|
76 |
| - try { |
77 |
| - result = new DeviceAttribute(attrName); |
78 |
| - TangoDataType<Object> dataType = (TangoDataType<Object>) deviceProxy.getProxy().getAttributeInfo(attrName).getType(); |
79 |
| - Class<?> type = dataType.getDataTypeClass(); |
80 |
| - Object converted = ConvertUtils.convert(value.length == 1 ? value[0] : value, type); |
| 92 | + try { |
| 93 | + result = new DeviceAttribute(attrName); |
| 94 | + TangoDataType<Object> dataType = (TangoDataType<Object>) deviceProxy.getProxy().getAttributeInfo(attrName).getType(); |
| 95 | + Class<?> type = dataType.getDataTypeClass(); |
| 96 | + Object converted = ConvertUtils.convert(value.length == 1 ? value[0] : value, type); |
81 | 97 |
|
82 |
| - dataType.insert(TangoDataWrapper.create(result, null), converted); |
| 98 | + dataType.insert(TangoDataWrapper.create(result, null), converted); |
83 | 99 |
|
84 |
| - return result; |
85 |
| - } catch (TangoProxyException | NoSuchAttributeException | ValueInsertionException e) { |
86 |
| - return null; |
87 |
| - } |
88 |
| - }) |
89 |
| - .filter(Objects::nonNull) |
90 |
| - .toArray(fr.esrf.TangoApi.DeviceAttribute[]::new); |
| 100 | + return result; |
| 101 | + } catch (TangoProxyException | NoSuchAttributeException | ValueInsertionException e) { |
| 102 | + return null; |
| 103 | + } |
| 104 | + }) |
| 105 | + .filter(Objects::nonNull) |
| 106 | + .toArray(fr.esrf.TangoApi.DeviceAttribute[]::new); |
91 | 107 | if(async) {
|
92 | 108 | deviceProxy.getProxy().toDeviceProxy().write_attribute_asynch(attrs);
|
93 | 109 | return null;
|
94 | 110 | } else {
|
95 | 111 | String[] readNames =
|
96 | 112 | Arrays.stream(attrs)
|
97 |
| - .map(deviceAttribute -> { |
98 |
| - try { |
99 |
| - return deviceAttribute.getName(); |
100 |
| - } catch (DevFailed devFailed) { |
101 |
| - throw new AssertionError("Must not happen!", TangoUtils.convertDevFailedToException(devFailed)); |
102 |
| - } |
103 |
| - }) |
104 |
| - .toArray(String[]::new); |
| 113 | + .map(deviceAttribute -> { |
| 114 | + try { |
| 115 | + return deviceAttribute.getName(); |
| 116 | + } catch (DevFailed devFailed) { |
| 117 | + throw new AssertionError("Must not happen!", TangoUtils.convertDevFailedToException(devFailed)); |
| 118 | + } |
| 119 | + }) |
| 120 | + .toArray(String[]::new); |
105 | 121 | deviceProxy.getProxy().toDeviceProxy().write_attribute(attrs);
|
106 | 122 | return deviceProxy.getProxy().toDeviceProxy().read_attribute(readNames);
|
107 | 123 | }
|
|
0 commit comments