blob: 12f7fd30735c5afeab6ecfdbbef585df5d9130fc [file] [log] [blame]
/*******************************************************************************
* 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:
* Regent L'Archeveque - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.environment.earth.orbit.planner.impl;
import org.eclipse.apogy.common.emf.ApogyCommonEMFFacade;
import org.eclipse.apogy.core.environment.earth.orbit.planner.ObservationAnalysisPlannerNode;
public class ObservationAnalysisPlannerNodeCustomImpl extends ObservationAnalysisPlannerNodeImpl {
@Override
public double getCost() {
return ApogyCoreEnvironmentEarthOrbitPlannerFacadeCustomImpl.INSTANCE.getNodeTotalCost(this);
}
@Override
public double getCumulativeCost() {
return getParent() == null? getCost(): getCost() + getParent().getCumulativeCost();
}
@Override
public int getLevel() {
int level = 0;
ObservationAnalysisPlannerNode currentNode = this;
if (currentNode != null) {
while (currentNode.getParent() != null) {
level++;
currentNode = currentNode.getParent();
}
}
return level;
}
@Override
public ObservationAnalysisPlannerNode getFirstLevelNode() {
ObservationAnalysisPlannerNode currentNode = this;
while (currentNode != null && currentNode.getParent() != null && currentNode.getParent().getParent() != null) {
currentNode = currentNode.getParent();
}
return currentNode;
}
@Override
public ObservationAnalysisPlannerNode basicGetFirstLevelNode() {
return getFirstLevelNode();
}
@Override
public double getSolutionDuration() {
return getFirstLevelNode() != null && getFirstLevelNode().getPass() != null && getPass() != null?
ApogyCommonEMFFacade.INSTANCE.getDuration(getFirstLevelNode().getPass().getFromDate(), getPass().getToDate()): 0.0;
}
@Override
public double getPassDuration() {
return ApogyCommonEMFFacade.INSTANCE.getDuration(getPass());
}
@Override
public double getTotalPassesDuration() {
return getParent() == null? getPassDuration(): getPassDuration() + getParent().getTotalPassesDuration();
}
}