use of org.openmuc.framework.dataaccess.WriteValueContainer in project OpenMUC by isc-konstanz.
the class DataManager method write.
@Override
public void write(List<WriteValueContainer> values) {
HashMap<Device, List<WriteValueContainerImpl>> containersByDevice = new LinkedHashMap<>();
for (WriteValueContainer value : values) {
WriteValueContainerImpl valueContainerImpl = (WriteValueContainerImpl) value;
if (valueContainerImpl.getValue() == null) {
valueContainerImpl.setFlag(Flag.CANNOT_WRITE_NULL_VALUE);
continue;
}
Device device = valueContainerImpl.getChannel().config.deviceParent.device;
List<WriteValueContainerImpl> writeValueContainers = containersByDevice.get(device);
if (writeValueContainers == null) {
writeValueContainers = new LinkedList<>();
containersByDevice.put(device, writeValueContainers);
}
writeValueContainers.add(valueContainerImpl);
}
CountDownLatch writeTasksFinishedSignal = new CountDownLatch(containersByDevice.size());
synchronized (newWriteTasks) {
for (Entry<Device, List<WriteValueContainerImpl>> writeValueContainers : containersByDevice.entrySet()) {
WriteTask writeTask = new WriteTask(this, writeValueContainers.getKey(), writeValueContainers.getValue(), writeTasksFinishedSignal);
newWriteTasks.add(writeTask);
}
}
interrupt();
try {
writeTasksFinishedSignal.await();
} catch (InterruptedException e) {
}
}
Aggregations