| package org.eclipse.apogy.addons.sensors.gps.state; |
| /******************************************************************************* |
| * 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, |
| * Sebastien Gemme |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************/ |
| |
| import java.io.IOException; |
| |
| import org.eclipse.apogy.addons.sensors.gps.GPS; |
| import org.eclipse.apogy.addons.sensors.gps.GPSStatus; |
| |
| public class GPSStateRunning extends GPSState { |
| |
| public GPSStateRunning(GPS gps) { |
| super(gps); |
| } |
| |
| @Override |
| public void failure(Exception e) { |
| super.failure(e); |
| getGPS().setStatus(GPSStatus.RECONNECTING); |
| getGPS().reconnect(); |
| } |
| |
| @Override |
| public boolean isRunning() { |
| return true; |
| } |
| |
| @Override |
| public void stop() throws IllegalStateException { |
| getGPS().setStatus(GPSStatus.STOPPED); |
| getGPS().setLastFailure(null); |
| } |
| |
| @Override |
| public void updateGPS() throws IllegalStateException { |
| try { |
| getGPS().getDataInterpreter().updateGPS(); |
| } catch (IOException e) { |
| failure(e); |
| } |
| } |
| |
| } |