blob: 89dd8cc536facec5c416767ea1f972a7f81fc5d2 [file] [log] [blame]
/*******************************************************************************
<<<<<<< HEAD
* Copyright (c) 2018 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
=======
* 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,
* Regent L'Archeveque - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*
>>>>>>> refs/heads/eclipse_pa
*******************************************************************************/
package org.eclipse.apogy.addons.sensors.imaging.camera.impl;
import org.eclipse.apogy.addons.sensors.imaging.camera.ApogyAddonsSensorsImagingCameraPackage;
import org.eclipse.apogy.addons.sensors.imaging.camera.CameraViewConfiguration;
import org.eclipse.apogy.addons.sensors.imaging.camera.internal.WatchDog;
import org.eclipse.apogy.common.emf.transaction.ApogyCommonTransactionFacade;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
public class ImageFrozenOverlayCustomImpl extends ImageFrozenOverlayImpl {
private CameraViewConfiguration cvc = null;
protected Adapter cameraViewConfigurationAdapter = null;
protected WatchDog imageWatchDog = null;
@Override
public void setExpectedImageUpdatePeriod(double newExpectedImageUpdatePeriod) {
super.setExpectedImageUpdatePeriod(newExpectedImageUpdatePeriod);
getImageWatchDog().setTimeout(Math.round(newExpectedImageUpdatePeriod * 1000));
ApogyCommonTransactionFacade.INSTANCE.basicSet(ImageFrozenOverlayCustomImpl.this,
ApogyAddonsSensorsImagingCameraPackage.Literals.IMAGE_FROZEN_OVERLAY__FROZEN, Boolean.FALSE);
}
@Override
public String getDisplayedString() {
if (this.cvc == null && getCameraOverlayList() != null) {
this.cvc = getCameraOverlayList().getCameraViewConfiguration();
if (this.cvc != null) {
this.cvc.eAdapters().add(getCameraViewConfigurationAdapter());
}
}
if (isFrozen()) {
return getFrozenMessage();
} else {
return null;
}
}
@Override
public void dispose() {
getImageWatchDog().dispose();
super.dispose();
}
protected Adapter getCameraViewConfigurationAdapter() {
if (this.cameraViewConfigurationAdapter == null) {
this.cameraViewConfigurationAdapter = new AdapterImpl() {
@Override
public void notifyChanged(Notification msg) {
if (msg.getNotifier() instanceof CameraViewConfiguration) {
int featureId = msg.getFeatureID(CameraViewConfiguration.class);
switch (featureId) {
case ApogyAddonsSensorsImagingCameraPackage.CAMERA_VIEW_CONFIGURATION__IMAGE_COUNT:
getImageWatchDog().kick();
ApogyCommonTransactionFacade.INSTANCE.basicSet(ImageFrozenOverlayCustomImpl.this,
ApogyAddonsSensorsImagingCameraPackage.Literals.IMAGE_FROZEN_OVERLAY__FROZEN,
Boolean.FALSE);
break;
default:
break;
}
}
}
};
}
return this.cameraViewConfigurationAdapter;
}
protected WatchDog getImageWatchDog() {
if (this.imageWatchDog == null) {
this.imageWatchDog = new WatchDog(Math.round(getExpectedImageUpdatePeriod() * 1000)) {
@Override
public void timeoutOccured() {
ApogyCommonTransactionFacade.INSTANCE.basicSet(ImageFrozenOverlayCustomImpl.this,
ApogyAddonsSensorsImagingCameraPackage.Literals.IMAGE_FROZEN_OVERLAY__FROZEN, Boolean.TRUE);
}
};
}
return this.imageWatchDog;
}
} // ImageFrozenOverlayImpl