// Path: osgi.enroute.trains.api/src/osgi/enroute/trains/cloud/api/TrackForCommand.java
// public interface TrackForCommand extends TrackInfo {
// 
// 	/**
// 	 * Give a train an assignment. The assignment is to move itself to the given
// 	 * segment.
// 	 * 
// 	 * @param train
// 	 *            the train id
// 	 * @param toSegment
// 	 *            the id of the requested segment
// 	 * @return true if granted,otherwise false. This function can wait up to 1
// 	 *         minute.
// 	 */
// 	void assign(String train, String toSegment);
// 
// 	
// 	/**
// 	 * Notify a train of an emergency
// 	 * 
// 	 * @param train
// 	 * 			the train id
// 	 * @param reason
// 	 * 			cause of the emergency 
// 	 * @param emergency 
// 	 * 			whether the emergency is still applying
// 	 */
// 	void emergency(String train, String reason, boolean emergency);
// 	
// 	
// 	/**
// 	 * External indication that a segment is broken
// 	 * 
// 	 * @param Segment
// 	 *            The segment that is blocked/unblocked
// 	 * @param The
// 	 *            reason the segment is blocked
// 	 * @param blocked
// 	 *            true if blocked, false is free
// 	 */
// 	void blocked(String segment, String reason, boolean blocked);
// 	
// 
// 	/**
// 	 * External indication that a segment is dark
// 	 * 
// 	 * @param Segment
// 	 *            The segment  that is dark/light
// 	 * @param blocked
// 	 *            true if dark, false is light
// 	 */
// 	void dark(String segment, boolean dark);
// 	
// }
// 
// Path: osgi.enroute.trains.util/src/osgi/enroute/trains/event/util/EventConvertor.java
// public class EventConvertor {
// 
// 		public static Observation eventToObservation(Event event, DTOs dtos) throws Exception {
// 			Observation o = new Observation();
// 			for ( Field f : o.getClass().getFields() ) {
// 				if ( Modifier.isStatic(f.getModifiers()))
// 					continue;
// 				
// 				Object rawValue = event.getProperty(f.getName());
// 				Object value = dtos.convert(rawValue).to(f.getGenericType());
// 				f.set(o, value);
// 			}
// 			return o;
// 		}
// 		
// 		
// 		public static SensorEvent eventToSensorEvent(Event event, DTOs dtos) throws Exception {
// 			SensorEvent o = new SensorEvent();
// 			for ( Field f : o.getClass().getFields() ) {
// 				if ( Modifier.isStatic(f.getModifiers()))
// 					continue;
// 				
// 				Object rawValue = event.getProperty(f.getName());
// 				Object value = dtos.convert(rawValue).to(f.getGenericType());
// 				f.set(o, value);
// 			}
// 			return o;
// 		}
// }
// 
// Path: osgi.enroute.trains.api/src/osgi/enroute/trains/sensor/api/SensorEvent.java
// public class SensorEvent extends DTO{
// 
// 	public final static String TOPIC = "osgi/trains/sensor";
// 
// 	public enum Type {
// 		WATER, 
// 		LIGHT,
// 		MOTION,
// 		DOOR,
// 		PASSENGER
// 	}
// 	
// 	public Type type;
// 	public String segment;
// 	public String train;
// 	
// 	public boolean water;
// 	public boolean dark;
// 	public boolean motion;
// 	public boolean open;
// 	public boolean passenger;  // Passenger emergency brake
// }


import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import osgi.enroute.dto.api.DTOs;
import osgi.enroute.trains.cloud.api.TrackForCommand;
import osgi.enroute.trains.event.util.EventConvertor;
import osgi.enroute.trains.sensor.api.SensorEvent;
package osgi.enroute.trains.sensors.provider;



/**
 * 
 */
@Component(name = "osgi.enroute.trains.sensors",
	property={"event.topics="+SensorEvent.TOPIC},
	immediate=true)
public class SensorsImpl implements EventHandler {

	@Reference
	DTOs dtos;
	
	@Reference
// Path: osgi.enroute.trains.api/src/osgi/enroute/trains/cloud/api/TrackForCommand.java
// public interface TrackForCommand extends TrackInfo {
// 
// 	/**
// 	 * Give a train an assignment. The assignment is to move itself to the given
// 	 * segment.
// 	 * 
// 	 * @param train
// 	 *            the train id
// 	 * @param toSegment
// 	 *            the id of the requested segment
// 	 * @return true if granted,otherwise false. This function can wait up to 1
// 	 *         minute.
// 	 */
// 	void assign(String train, String toSegment);
// 
// 	
// 	/**
// 	 * Notify a train of an emergency
// 	 * 
// 	 * @param train
// 	 * 			the train id
// 	 * @param reason
// 	 * 			cause of the emergency 
// 	 * @param emergency 
// 	 * 			whether the emergency is still applying
// 	 */
// 	void emergency(String train, String reason, boolean emergency);
// 	
// 	
// 	/**
// 	 * External indication that a segment is broken
// 	 * 
// 	 * @param Segment
// 	 *            The segment that is blocked/unblocked
// 	 * @param The
// 	 *            reason the segment is blocked
// 	 * @param blocked
// 	 *            true if blocked, false is free
// 	 */
// 	void blocked(String segment, String reason, boolean blocked);
// 	
// 
// 	/**
// 	 * External indication that a segment is dark
// 	 * 
// 	 * @param Segment
// 	 *            The segment  that is dark/light
// 	 * @param blocked
// 	 *            true if dark, false is light
// 	 */
// 	void dark(String segment, boolean dark);
// 	
// }
// 
// Path: osgi.enroute.trains.util/src/osgi/enroute/trains/event/util/EventConvertor.java
// public class EventConvertor {
// 
// 		public static Observation eventToObservation(Event event, DTOs dtos) throws Exception {
// 			Observation o = new Observation();
// 			for ( Field f : o.getClass().getFields() ) {
// 				if ( Modifier.isStatic(f.getModifiers()))
// 					continue;
// 				
// 				Object rawValue = event.getProperty(f.getName());
// 				Object value = dtos.convert(rawValue).to(f.getGenericType());
// 				f.set(o, value);
// 			}
// 			return o;
// 		}
// 		
// 		
// 		public static SensorEvent eventToSensorEvent(Event event, DTOs dtos) throws Exception {
// 			SensorEvent o = new SensorEvent();
// 			for ( Field f : o.getClass().getFields() ) {
// 				if ( Modifier.isStatic(f.getModifiers()))
// 					continue;
// 				
// 				Object rawValue = event.getProperty(f.getName());
// 				Object value = dtos.convert(rawValue).to(f.getGenericType());
// 				f.set(o, value);
// 			}
// 			return o;
// 		}
// }
// 
// Path: osgi.enroute.trains.api/src/osgi/enroute/trains/sensor/api/SensorEvent.java
// public class SensorEvent extends DTO{
// 
// 	public final static String TOPIC = "osgi/trains/sensor";
// 
// 	public enum Type {
// 		WATER, 
// 		LIGHT,
// 		MOTION,
// 		DOOR,
// 		PASSENGER
// 	}
// 	
// 	public Type type;
// 	public String segment;
// 	public String train;
// 	
// 	public boolean water;
// 	public boolean dark;
// 	public boolean motion;
// 	public boolean open;
// 	public boolean passenger;  // Passenger emergency brake
// }


// Path: osgi.enroute.trains.sensors.provider/src/osgi/enroute/trains/sensors/provider/SensorsImpl.java
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import osgi.enroute.dto.api.DTOs;
import osgi.enroute.trains.cloud.api.TrackForCommand;
import osgi.enroute.trains.event.util.EventConvertor;
import osgi.enroute.trains.sensor.api.SensorEvent;

package osgi.enroute.trains.sensors.provider;



/**
 * 
 */
@Component(name = "osgi.enroute.trains.sensors",
	property={"event.topics="+SensorEvent.TOPIC},
	immediate=true)
public class SensorsImpl implements EventHandler {

	@Reference
	DTOs dtos;
	
	@Reference
	TrackForCommand trains;