From 552c247ecef6bc834ae4185bf86d9668f1a0d16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Coelho?= Date: Fri, 4 Nov 2022 16:29:11 +0100 Subject: [PATCH] Adds support to non-fixed camera resolutions --- .../provider/gen/CameraAdapterInterface.java | 6 ++++ .../gen/CameraProviderServiceImpl.java | 29 ++++++++++--------- .../softsim/CameraSoftSimAdapter.java | 5 ++++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraAdapterInterface.java b/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraAdapterInterface.java index 8cd56a8b2..c1e625513 100644 --- a/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraAdapterInterface.java +++ b/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraAdapterInterface.java @@ -41,6 +41,12 @@ public interface CameraAdapterInterface { */ boolean isUnitAvailable(); + /** + * @return true if the camera has only a fixed set of resolutions. They can + * then be retrieved with the getAvailableResolutions() method. + */ + boolean hasFixedResolutions(); + /** * @return The resolutions supported by the Camera Adapter */ diff --git a/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraProviderServiceImpl.java b/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraProviderServiceImpl.java index ffe7a353b..6b6d6da73 100644 --- a/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraProviderServiceImpl.java +++ b/core/mo-services-impl/nmf-platform-generic-impl/src/main/java/esa/mo/platform/impl/provider/gen/CameraProviderServiceImpl.java @@ -100,7 +100,7 @@ public class CameraProviderServiceImpl extends CameraInheritanceSkeleton { public synchronized void init(COMServicesProvider comServices, CameraAdapterInterface adapter) throws MALException { long timestamp = System.currentTimeMillis(); - + if (!initialiased) { if (MALContextFactory.lookupArea(MALHelper.MAL_AREA_NAME, MALHelper.MAL_AREA_VERSION) == null) { MALHelper.init(MALContextFactory.getElementFactoryRegistry()); @@ -216,20 +216,23 @@ private void isCapturePossible(final CameraSettings settings) throws MALInteract PlatformHelper.DEVICE_IN_USE_ERROR_NUMBER, null)); } final PixelResolutionList availableResolutions = adapter.getAvailableResolutions(); - boolean isResolutionAvailable = false; - // Do we have the resolution requested? - for (PixelResolution availableResolution : availableResolutions) { - if (settings.getResolution().equals(availableResolution)) { - isResolutionAvailable = true; - break; + if (adapter.hasFixedResolutions()) { + boolean isResolutionAvailable = false; + + // Do we have the resolution requested? + for (PixelResolution availableResolution : availableResolutions) { + if (settings.getResolution().equals(availableResolution)) { + isResolutionAvailable = true; + break; + } } - } - // If not, then send the available resolutions to the consumer so they can pick... - if (!isResolutionAvailable) { - throw new MALInteractionException(new MALStandardError( - COMHelper.INVALID_ERROR_NUMBER, availableResolutions)); + // If not, then send the available resolutions to the consumer so they can pick... + if (!isResolutionAvailable) { + throw new MALInteractionException(new MALStandardError( + COMHelper.INVALID_ERROR_NUMBER, availableResolutions)); + } } boolean isFormatsAvailable = false; @@ -360,7 +363,7 @@ public GetPropertiesResponse getProperties(MALInteraction interaction) throws } @Override - public void preprocessPicture(Picture inputPicture, CameraSettings settings, + public void preprocessPicture(Picture inputPicture, CameraSettings settings, PreprocessPictureInteraction interaction) throws MALInteractionException, MALException { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/mission/simulator/platform-services-impl/src/main/java/esa/mo/platform/impl/provider/softsim/CameraSoftSimAdapter.java b/mission/simulator/platform-services-impl/src/main/java/esa/mo/platform/impl/provider/softsim/CameraSoftSimAdapter.java index 97d12e2b5..29a11279d 100644 --- a/mission/simulator/platform-services-impl/src/main/java/esa/mo/platform/impl/provider/softsim/CameraSoftSimAdapter.java +++ b/mission/simulator/platform-services-impl/src/main/java/esa/mo/platform/impl/provider/softsim/CameraSoftSimAdapter.java @@ -191,4 +191,9 @@ public boolean isUnitAvailable() return pcAdapter.isDeviceEnabled(DeviceType.CAMERA); } + @Override + public boolean hasFixedResolutions() + { + return true; + } }