/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
// Copyright (C) 2017-2018 German Aerospace Center (DLR) and others.
// TraaS module
// Copyright (C) 2016-2017 Dresden University of Technology
// This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v20.html
// SPDX-License-Identifier: EPL-2.0
/****************************************************************************/
/// @file    SumoStopFlags.java
/// @author  Mario Krumnow
/// @author  Evamarie Wiessner
/// @date    2016
/// @version $Id$
///
//
/****************************************************************************/
package de.tudresden.ws.container;

/**
 * 
 * @author Mario Krumnow
 *
 */

public class SumoStopFlags implements SumoObject {

	 public boolean stopped = false;
	 public boolean parking = false;
	 public boolean triggered = false;
	 public boolean containerTriggered = false;
	 public boolean isBusStop = false;
	 public boolean isContainerStop = false;
	
	 public SumoStopFlags(boolean parking, boolean triggered, boolean containerTriggered, boolean isBusStop, boolean isContainerStop){
		 this.parking = parking;
		 this.triggered = triggered;
		 this.containerTriggered = containerTriggered;
		 this.isBusStop = isBusStop;
		 this.isContainerStop = isContainerStop;
	 }
	 
	 public SumoStopFlags(byte id){
		 
		 byte[] m = {1, 2, 4, 8, 16, 32};
		 this.stopped = (id & m[0]) == m[0] ? true : false;
		 this.parking = (id & m[1]) == m[1] ? true : false;
		 this.triggered = (id & m[2]) == m[2] ? true : false;
		 this.containerTriggered = (id & m[3]) == m[3] ? true : false;
		 this.isBusStop = (id & m[4]) == m[4] ? true : false;
		 this.isContainerStop = (id & m[5]) == m[5] ? true : false;
		 
	 }

	 public byte getID(){
		 
		 StringBuilder sb = new StringBuilder();
		 sb.append(isContainerStop ? "1" : "0");
		 sb.append(isBusStop ? "1" : "0");
		 sb.append(containerTriggered ? "1" : "0");
		 sb.append(triggered ? "1" : "0");
		 sb.append(parking ? "1" : "0");
		 return (byte)Integer.parseInt(sb.toString(), 2);
		 
	 }
	 
	
}
