/** * Get the communication status for some driver-managed resource. It is up to the driver to provide * the communication status resource, if it is not available null is returned. * @param target * Some resource that is managed by a driver that provides information on the communication status. * Could be a {@link PhysicalElement} resource representing a device managed by a driver, or a ValueResource. * @return */ public static CommunicationStatus getCommunicationStatus(final Resource target) { return ResourceUtils.getFirstContextResource(target, CommunicationStatus.class); }
/** * Get the first matching context resource of the specified type. See {@link #getContextResources(Resource, Class, boolean)}. * @param target * @param targetType * @return * A matching context resource, or null if none was found. * @throws NullPointerException if targetType is null */ public static <R extends Resource> R getFirstContextResource(final Resource target, final Class<R> targetType) { return getFirstContextResource(target, targetType, null, null); }
/** * Get the device belonging to some communication status resource. * @param status * @param filterCustomTypes * if true, only devices with standard OGEMA device types are reported, custom types are ignored. * @return * the first device found that belongs to the status resource, or null if none was found. */ public static PhysicalElement getDevice(final CommunicationStatus status, final boolean filterCustomTypes) { return ResourceUtils.getFirstContextResource(status, PhysicalElement.class, filterCustomTypes ? Pattern.compile("^org\\.ogema\\.") : null, null); }