| /******************************************************************************* |
| * 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 |
| *******************************************************************************/ |
| package org.eclipse.apogy.core.programs.controllers.impl; |
| |
| import org.eclipse.apogy.common.io.jinput.impl.EControllerEnvironmentCustomImpl; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class TimeTriggerCustomImpl extends TimeTriggerImpl { |
| |
| private static final Logger Logger = LoggerFactory.getLogger(TimeTriggerImpl.class); |
| |
| @Override |
| public void start() { |
| if (!isStarted()) { |
| setStarted(true); |
| |
| // Start thread for update. |
| new Thread() { |
| @Override |
| public void run() { |
| while (isStarted()) { |
| try { |
| // Update |
| getOperationCallControllerBinding().update(); |
| |
| // Wait |
| if (getRefreshPeriod() >= EControllerEnvironmentCustomImpl.MILLIS_BEFORE_NEXT_POLLING) { |
| Thread.sleep(getRefreshPeriod()); |
| } else { |
| Thread.sleep(EControllerEnvironmentCustomImpl.MILLIS_BEFORE_NEXT_POLLING); |
| } |
| } catch (Throwable t) { |
| Logger.error("Error waiting the specified refresh period for the timeTrigger"); |
| } |
| } |
| } |
| }.start(); |
| } |
| } |
| |
| @Override |
| public void stop() { |
| setStarted(true); |
| } |
| |
| } // TimeTriggerImpl |