package battery.utility;


import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;

import dotplots.ReadCSV;

// public static int MAX_LENGHT = 300000;
// Latest date is "3/5/2100  00:00"
// We have to sort Readings.csv  Z->A according to datetime before running ReadCSV

// ************Battery*********************
// public static int MAX_SENSOR = 100;
// public static int MAX_LENGHT = 10000;



public class Readings {

	public static int MAX_LENGHT = 300000;
	public static String lateDate = "3/5/2100  00:00";
	public static String earlyDate = "3/5/2000  00:00";
	
	public static long[] reading = new long [MAX_LENGHT];
	public static long[] transmission = new long [MAX_LENGHT];
	public static long[] sensor = new long [MAX_LENGHT];
	public static Date[] datetime = new Date [MAX_LENGHT];
	public static long[] datetime2 = new long [MAX_LENGHT];
	
	public static long[] date = new long [MAX_LENGHT];
	public static long[] weekday = new long [MAX_LENGHT];
	public static long[] time = new long [MAX_LENGHT];
	public static Date[] transmissionTime = new Date [MAX_LENGHT];
	public static long[] batteryLevel = new long [MAX_LENGHT];
	public static int row;
	public static int col;
	public static Date minDate;
	public static Date maxDate;
	public static long minDate2;
	public static long maxDate2;

//	public static double[] batteryLevel2 = new double [100000];

	public static void PrintReadings(){
	//	minDate = ReadCSV.parseDate(lateDate);
	//	maxDate = ReadCSV.parseDate(earlyDate);
		for (int i=0; i<row; i++){
			if (minDate.after(datetime[i])) {
				minDate=datetime[i];
			}
			if (maxDate.before(datetime[i])) maxDate=datetime[i];
			//print(i);
		}
		minDate.setSeconds(0);
		minDate.setMinutes(0);
		minDate.setHours(0);
		maxDate.setSeconds(0);
		maxDate.setMinutes(0);
		maxDate.setHours(0);
		
		
//		Date date=new Date(minDate.getTime());
//		for (int i=0; !date.after(maxDate); i++){
		//	System.out.println(" Row:"+i+" ===="+  date);
	//		date.setDate(date.getDate()+1);
	//	}
		
		minDate2 = minDate.getTime();
		maxDate2 = maxDate.getTime();
		for (int i=0; i<row; i++){
			datetime2[i] = (datetime[i].getTime()) - minDate2 ;
		}
	}		
	
	public static void print(int i) {
		System.out.print("Row"+i+"  ");
		System.out.print(reading[i]);
		System.out.print("  ");
		System.out.print(transmission[i]);
		System.out.print("  ");
		System.out.print(sensor[i]);
		System.out.print("  ");
		System.out.print(datetime[i]);
		
		System.out.print("  ");
		System.out.print(date[i]);
		System.out.print("  ");
		System.out.print(weekday[i]);
		System.out.print("  ");
		System.out.print(time[i]);
		System.out.print("  ");
		System.out.print(transmissionTime[i]);
		System.out.print("  ");
		System.out.print(batteryLevel[i]);
		System.out.println("  ");
//		break;
//		if (batteryLevel[i]>2000) break;	
	}	
}
