package at.ac.tuwien.lsdc.types;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ScenarioData {
	
	private static final Logger LOG = LoggerFactory.getLogger(ScenarioData.class);

	private String scheduler;
	private String scenario;
	private long totalPMs;
	private long totalVMs;
	private long totalDuration;
	private double totalConsumption;
	private int totalInSourced;
	private int totalOutSourced;
	private int totalResizeCalls;
	private int totalDelayedApps;
	private int totalStarted;
	private int totalStopped;

	public ScenarioData(String scheduler, String scenario, long totalPMs,
			long totalVMs, long totalDuration, double totalConsumption,
 int totalInSourced, int totalOutSourced,
			int totalResizeCalls) {
		this.scheduler = scheduler;
		this.scenario = scenario;
		this.totalPMs = totalPMs;
		this.totalVMs = totalVMs;
		this.totalDuration = totalDuration;
		this.totalConsumption = totalConsumption;
		this.totalInSourced = totalInSourced;
		this.totalOutSourced = totalOutSourced;
		this.totalResizeCalls = totalResizeCalls;
	}
	
	public ScenarioData(String scheduler, String scenario, long totalPMs,
			long totalVMs, long totalDuration, double totalConsumption,
 int totalInSourced, int totalOutSourced,
			int totalResizeCalls, int totalDelayedApps) {
		
		this(scheduler, scenario, totalPMs, totalVMs, totalDuration, totalConsumption, totalInSourced, totalOutSourced, totalResizeCalls);
		this.totalDelayedApps = totalDelayedApps;
	}
	
	public ScenarioData(String scheduler, String scenario, long totalPMs,
					long totalVMs, long totalDuration, double totalConsumption,
					int totalInSourced, int totalOutSourced,
					int totalResizeCalls, int totalDelayedApps, 
					int totalStarted, int totalStopped) {
		
		this(scheduler, scenario, totalPMs, totalVMs, totalDuration, totalConsumption, totalInSourced, 
				totalOutSourced, totalResizeCalls, totalDelayedApps);
		this.totalStarted = totalStarted;
		this.totalStopped = totalStopped;
	}

	public String[] toStringArray() {
//		LOG.info("total Consumption = "+totalConsumption+ ", string: "+String.valueOf(totalConsumption));
		DecimalFormat df = new DecimalFormat("#.##");
		
		return new String[] { scheduler, scenario, String.valueOf(totalPMs), String.valueOf(totalVMs),
				String.valueOf(totalDuration), df.format(totalConsumption), String.valueOf(totalInSourced),
				String.valueOf(totalOutSourced), String.valueOf(totalResizeCalls), String.valueOf(totalDelayedApps) , 
				String.valueOf(totalStarted), String.valueOf(totalStopped) };
	}

	@Override
	public String toString() {
		return "ScenarioData [scheduler=" + scheduler + ", scenario="
				+ scenario + ", totalPMs=" + totalPMs + ", totalVMs="
				+ totalVMs + ", totalDuration=" + totalDuration
				+ ", totalConsumption=" + totalConsumption
				+ ", totalInSourced=" + totalInSourced + ", totalOutSourced="
				+ totalOutSourced + ", totalResizeCalls=" + totalResizeCalls
				+ ", delayedApps=" + totalDelayedApps 
				+ ", totalStarted=" + totalStarted + "totalStopped=" + totalStopped + "]";
	}

}
