// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
// 
// 	// Define the constants to get/set values from context
// 	public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// 	public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// 	public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
// 
// 	@Inject
// 	IEclipseContext ctx; // The context where values will be injected
// 
// 	// Physical values
// 	int speed, rpm, tankLevel;
// 	int acceleration = 2;
// 
// 	Timer timer = null;
// 
// 	@Inject
// 	EngineSimulator() {
// 		this(65);
// 	}
// 
// 	EngineSimulator(int tankInit) {
// 		tankLevel = tankInit;
// 
// 	}
// 
// 	public void start() {
// 		if (timer == null) {
// 			timer = new Timer();
// 			timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// 		}
// 	}
// 
// 	public void stop() {
// 		if (timer != null) {
// 			timer.cancel();
// 			ctx.set(ECF2014_SPEED_VALUE, 0);
// 			ctx.set(ECF2014_RPM_VALUE, 0);
// 
// 		}
// 		timer = null;
// 	}
// 
// 	@PostConstruct
// 	void declareInContext() {
// 		ctx.set(EngineSimulator.class, this);
// 
// 	}
// 
// 	private class EngineTimerTask extends TimerTask {
// 		@Override
// 		public void run() {
// 			speed = speed + acceleration;
// 			rpm = speed * 75;
// 
// 			if (speed < 0)
// 				speed = 0;
// 			if (rpm < 0)
// 				rpm = 0;
// 
// 			System.out.println("New value for speed : " + speed + " and rpm : "
// 					+ rpm);
// 			ctx.set(ECF2014_SPEED_VALUE, speed);
// 			ctx.set(ECF2014_RPM_VALUE, rpm);
// 		}
// 	}
// 
// 	/**
// 	 * accelerate or brake
// 	 * 
// 	 * @param a
// 	 *            acceleration in m/s2
// 	 */
// 	public void accelerate(int a) {
// 		acceleration = a;
// 	}
// 
// }
// 
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// 	// Define the sent topics
// 	public static final String ALARM_TOPIC = "Alarm/*";
// 	public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// 	public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
// 
// 	// Get the event broker by injection
// 	@Inject
// 	IEventBroker ebroker;
// 
// 	@Optional
// 	@Inject
// 	public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// 	{
// 		if (value > 5000)
// 		{
// 			// Send an alarm
// 			Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// 			ebroker.send(ALARM_RPM_TOO_HIGH, a);
// 		}
// 	}
// 
// 	@Optional
// 	@Inject
// 	public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// 	{
// 		System.out.println("Check speed value for alarm : " + value);
// 		if (value > 160)
// 		{
// 			// Send an alarm
// 			Alarm a = new Alarm("speed is too high (" + value + ")", value);
// 			ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// 		}
// 	}
// 
// }


import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
package com.opcoach.ecf2014.engine.ui.parts;




public class DashBoard
{
	private GaugeFigure speedCounter;
	private GaugeFigure rpmCounter;
	private XYGraphMediaFactory gmfactory;
	
	private static final int COUNTER_SIZE = 200;
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
// 
// 	// Define the constants to get/set values from context
// 	public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// 	public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// 	public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
// 
// 	@Inject
// 	IEclipseContext ctx; // The context where values will be injected
// 
// 	// Physical values
// 	int speed, rpm, tankLevel;
// 	int acceleration = 2;
// 
// 	Timer timer = null;
// 
// 	@Inject
// 	EngineSimulator() {
// 		this(65);
// 	}
// 
// 	EngineSimulator(int tankInit) {
// 		tankLevel = tankInit;
// 
// 	}
// 
// 	public void start() {
// 		if (timer == null) {
// 			timer = new Timer();
// 			timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// 		}
// 	}
// 
// 	public void stop() {
// 		if (timer != null) {
// 			timer.cancel();
// 			ctx.set(ECF2014_SPEED_VALUE, 0);
// 			ctx.set(ECF2014_RPM_VALUE, 0);
// 
// 		}
// 		timer = null;
// 	}
// 
// 	@PostConstruct
// 	void declareInContext() {
// 		ctx.set(EngineSimulator.class, this);
// 
// 	}
// 
// 	private class EngineTimerTask extends TimerTask {
// 		@Override
// 		public void run() {
// 			speed = speed + acceleration;
// 			rpm = speed * 75;
// 
// 			if (speed < 0)
// 				speed = 0;
// 			if (rpm < 0)
// 				rpm = 0;
// 
// 			System.out.println("New value for speed : " + speed + " and rpm : "
// 					+ rpm);
// 			ctx.set(ECF2014_SPEED_VALUE, speed);
// 			ctx.set(ECF2014_RPM_VALUE, rpm);
// 		}
// 	}
// 
// 	/**
// 	 * accelerate or brake
// 	 * 
// 	 * @param a
// 	 *            acceleration in m/s2
// 	 */
// 	public void accelerate(int a) {
// 		acceleration = a;
// 	}
// 
// }
// 
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// 	// Define the sent topics
// 	public static final String ALARM_TOPIC = "Alarm/*";
// 	public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// 	public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
// 
// 	// Get the event broker by injection
// 	@Inject
// 	IEventBroker ebroker;
// 
// 	@Optional
// 	@Inject
// 	public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// 	{
// 		if (value > 5000)
// 		{
// 			// Send an alarm
// 			Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// 			ebroker.send(ALARM_RPM_TOO_HIGH, a);
// 		}
// 	}
// 
// 	@Optional
// 	@Inject
// 	public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// 	{
// 		System.out.println("Check speed value for alarm : " + value);
// 		if (value > 160)
// 		{
// 			// Send an alarm
// 			Alarm a = new Alarm("speed is too high (" + value + ")", value);
// 			ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// 		}
// 	}
// 
// }


// Path: ECF14/com.opcoach.ecf2014.engine.ui/src/com/opcoach/ecf2014/engine/ui/parts/DashBoard.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
import com.opcoach.ecf2014.engine.core.EngineWatcher;

package com.opcoach.ecf2014.engine.ui.parts;




public class DashBoard
{
	private GaugeFigure speedCounter;
	private GaugeFigure rpmCounter;
	private XYGraphMediaFactory gmfactory;
	
	private static final int COUNTER_SIZE = 200;
	private static final int COUNTER_MARGIN = 15;