use of org.apache.plc4x.java.s7.readwrite.utils.S7PlcSubscriptionHandle in project plc4x by apache.
the class S7ProtocolEventLogic method register.
@Override
public PlcConsumerRegistration register(Consumer<PlcSubscriptionEvent> consumer, Collection<PlcSubscriptionHandle> handles) {
Map<PlcConsumerRegistration, Consumer> mapConsumers = null;
S7PlcSubscriptionHandle handle = (S7PlcSubscriptionHandle) handles.toArray()[0];
if (!mapIndex.containsKey(handle.getEventType())) {
mapConsumers = new HashMap();
mapIndex.put(handle.getEventType(), mapConsumers);
}
mapConsumers = mapIndex.get(handle.getEventType());
// TODO: Check the implementation of "DefaultPlcConsumerRegistration". List<> vs Collection<>
DefaultPlcConsumerRegistration registro = new DefaultPlcConsumerRegistration(this, consumer, handles.toArray(new PlcSubscriptionHandle[handles.size()]));
mapConsumers.put(registro, consumer);
return registro;
}
use of org.apache.plc4x.java.s7.readwrite.utils.S7PlcSubscriptionHandle in project plc4x by apache.
the class S7ProtocolEventLogic method unregister.
@Override
public void unregister(PlcConsumerRegistration registration) {
S7PlcSubscriptionHandle handle = (S7PlcSubscriptionHandle) registration.getSubscriptionHandles().get(0);
Map<PlcConsumerRegistration, Consumer> mapConsumers = mapIndex.get(handle.getEventType());
mapConsumers.remove(registration);
}
Aggregations