| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Pierre Allard - initial API and implementation |
| * Regent L'Archeveque |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************/ |
| package org.eclipse.apogy.addons.sensors.imaging.camera.internal; |
| |
| import java.util.Date; |
| |
| import org.eclipse.apogy.addons.sensors.fov.ApogyAddonsSensorsFOVFacade; |
| import org.eclipse.apogy.addons.sensors.fov.RectangularFrustrumFieldOfView; |
| import org.eclipse.apogy.addons.sensors.imaging.ApogyAddonsSensorsImagingFactory; |
| import org.eclipse.apogy.addons.sensors.imaging.ImageSnapshot; |
| import org.eclipse.apogy.addons.sensors.imaging.impl.AbstractCameraImpl; |
| import org.eclipse.apogy.common.images.ApogyCommonImagesFactory; |
| import org.eclipse.apogy.common.images.URLEImage; |
| |
| public class AbstractCameraStub extends AbstractCameraImpl { |
| private final String imageURL; |
| private final RectangularFrustrumFieldOfView fov; |
| |
| public AbstractCameraStub(String imageURL, double horizontalFieldOfViewAngle, double verticalFieldOfViewAngle) { |
| this.imageURL = imageURL; |
| |
| this.fov = ApogyAddonsSensorsFOVFacade.INSTANCE.createRectangularFrustrumFieldOfView(0, 100, |
| horizontalFieldOfViewAngle, verticalFieldOfViewAngle); |
| } |
| |
| @Override |
| public RectangularFrustrumFieldOfView getFieldOfView() { |
| return this.fov; |
| } |
| |
| @Override |
| public ImageSnapshot takeSnapshot() { |
| ImageSnapshot imageSnapshot = ApogyAddonsSensorsImagingFactory.eINSTANCE.createImageSnapshot(); |
| imageSnapshot |
| .setFieldOfView(ApogyAddonsSensorsFOVFacade.INSTANCE.createRectangularFrustrumFieldOfView(this.fov)); |
| imageSnapshot.setTime(new Date()); |
| |
| // Adds the image. |
| URLEImage urlImage = ApogyCommonImagesFactory.eINSTANCE.createURLEImage(); |
| urlImage.setUrl(this.imageURL); |
| imageSnapshot.setImage(urlImage); |
| |
| setLatestImageSnapshot(imageSnapshot); |
| |
| return imageSnapshot; |
| } |
| } |