use of org.openmuc.framework.dataaccess.ReadRecordContainer in project OpenMUC by isc-konstanz.
the class DataManager method read.
@Override
public void read(List<ReadRecordContainer> readContainers) {
Map<Device, List<ChannelRecordContainerImpl>> containersByDevice = new HashMap<>();
for (ReadRecordContainer container : readContainers) {
if (container instanceof ChannelRecordContainerImpl == false) {
throw new IllegalArgumentException("Only use ReadRecordContainer created by Channel.getReadContainer()");
}
ChannelImpl channel = (ChannelImpl) container.getChannel();
List<ChannelRecordContainerImpl> containersOfDevice = containersByDevice.get(channel.config.deviceParent.device);
if (containersOfDevice == null) {
containersOfDevice = new LinkedList<>();
containersByDevice.put(channel.config.deviceParent.device, containersOfDevice);
}
containersOfDevice.add((ChannelRecordContainerImpl) container);
}
CountDownLatch readTasksFinishedSignal = new CountDownLatch(containersByDevice.size());
synchronized (newReadTasks) {
for (Entry<Device, List<ChannelRecordContainerImpl>> channelRecordContainers : containersByDevice.entrySet()) {
ReadTask readTask = new ReadTask(this, channelRecordContainers.getKey(), channelRecordContainers.getValue(), readTasksFinishedSignal);
newReadTasks.add(readTask);
}
}
interrupt();
try {
readTasksFinishedSignal.await();
} catch (InterruptedException e) {
}
}
Aggregations