// Path: app/src/main/java/com/ubiqlog/utils/IOManager.java
// public class IOManager {
// 	String datenow = new String();
// 	private String currentFileName = new String();
// 	private String strPath;
// 
// 	public IOManager() {
// 		this.strPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Setting.DEFAULT_FOLDER;
// 	}
// 
// 	public IOManager(String filename, String homeFolder) {
// 		this.strPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + homeFolder;
// 		this.currentFileName = filename;
// 	}
// 
// 	public String getPath() {
// 		return strPath;
// 	}
// 
// 	public String getCurrentFilename() {
// 		return  currentFileName + ".txt";
// 	}
// 
// 
// 
// 	public void logData(ArrayList<String> inArr) {
// 		FileWriter writer;
// 		datenow = DateFormat.getDateInstance(DateFormat.SHORT).format(System.currentTimeMillis());
// 		SimpleDateFormat dateformat = new SimpleDateFormat("M-d-yyyy");
// 		//datenow = DateFormat.getDateInstance(DateFormat.SHORT).format(System.currentTimeMillis());
// 		//datenow = datenow.replace("/", "-");
// 		try {
// 			File logFile = new File(Setting.Instance(null).getLogFolder() + "/" + "log_" + dateformat.format(new Date()) + ".txt"); //datenow+ ".txt");
// 			writer = new FileWriter(logFile, true);
// 			if (!logFile.exists()) {
// 				logFile.createNewFile();
// 			}
// 			Iterator<String> it = inArr.iterator();
// 			while (it.hasNext()) {
// 				String aaa = it.next();
// 				writer.append(aaa+ System.getProperty("line.separator"));
// 			}
// 			writer.flush();
// 			writer.close();
// 			writer = null;
// 
// 		} catch (Exception e) {
// 			
// 			 Log.e("DataAggregator", "--------Failed to write in a file-----" + e.getMessage() + "; Stack: " + Log.getStackTraceString(e));
// 			
// 		}
// 	}
// 
// 
// 	// Added by AP
// 	// Uses a file name passed into the IOManager
// 	public boolean logData(DataAcquisitor dataAcq, boolean append) {
// 		if (dataAcq.getDataBuffer().size() <= 0) {
// 			return false;
// 		}
// 		//File dirs = new File(getPath() + dataAcq.getFolderName());
// 		File dirs = new File(getPath());
// 		if (!dirs.exists()) {
// 			dirs.mkdirs();
// 		}
// 
// 		String fileName = Setting.filenameFormat.format(new Date()) + "_" + getCurrentFilename();
// 		File logFile = new File(dirs, fileName);
// 		try {
// 			FileWriter writer = new FileWriter(logFile, append);
// 			for (String s : dataAcq.getDataBuffer()) {
// 				writer.append(s + System.getProperty("line.separator"));
// 			}
// 			writer.flush();
// 			writer.close();
// 			return true;
// 
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 			return false;
// 		}
// 	}
// 
// 	public void logError(String msg) {
// 		PrintWriter printWr;
// 		Date a = new Date (System.currentTimeMillis());
// 		String errorDate = a.getDate()+"-"+a.getMonth()+"-"+a.getYear();
// 		File errorFile = new File(Setting.Instance(null).getLogFolder(), "error_"+errorDate+".txt");
// 		try {
// 			printWr = new PrintWriter(new FileWriter(errorFile, true));
// 			printWr.append(msg + System.getProperty("line.separator"));
// 			printWr.flush();
// 			printWr.close();
// 			printWr = null;
// 		} catch (Exception ex) {
// 			Log.e("IOManager.logError", ex.getMessage(), ex);
// 		}
// 	}
// 
// }


import com.ubiqlog.utils.IOManager;
import java.util.ArrayList;
	public DataAcquisitor(String folderName, String fileName) {
		//this.context = context;
		this.folderName = folderName;
		dataBuffer = new ArrayList<String>();
		this.fileName = fileName;
	}

	public void removeData(Long timeinms) {

	}

	public ArrayList<String> getDataBuffer() {
		return dataBuffer;
	}

	public String getCurrrentFileName() {
		return fileName;
	}


	public void insert(String s, boolean append, int maxBuffSize) {
		//Log.d(LOG_TAG, "Inserting into dBuff");
		dataBuffer.add(s);
		if (dataBuffer.size() >= maxBuffSize) {
			flush(append);
		}
	}

	public void flush(boolean append) {
		//Log.d(LOG_TAG, "Flushing buffer" + this.getFolderName());
// Path: app/src/main/java/com/ubiqlog/utils/IOManager.java
// public class IOManager {
// 	String datenow = new String();
// 	private String currentFileName = new String();
// 	private String strPath;
// 
// 	public IOManager() {
// 		this.strPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Setting.DEFAULT_FOLDER;
// 	}
// 
// 	public IOManager(String filename, String homeFolder) {
// 		this.strPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + homeFolder;
// 		this.currentFileName = filename;
// 	}
// 
// 	public String getPath() {
// 		return strPath;
// 	}
// 
// 	public String getCurrentFilename() {
// 		return  currentFileName + ".txt";
// 	}
// 
// 
// 
// 	public void logData(ArrayList<String> inArr) {
// 		FileWriter writer;
// 		datenow = DateFormat.getDateInstance(DateFormat.SHORT).format(System.currentTimeMillis());
// 		SimpleDateFormat dateformat = new SimpleDateFormat("M-d-yyyy");
// 		//datenow = DateFormat.getDateInstance(DateFormat.SHORT).format(System.currentTimeMillis());
// 		//datenow = datenow.replace("/", "-");
// 		try {
// 			File logFile = new File(Setting.Instance(null).getLogFolder() + "/" + "log_" + dateformat.format(new Date()) + ".txt"); //datenow+ ".txt");
// 			writer = new FileWriter(logFile, true);
// 			if (!logFile.exists()) {
// 				logFile.createNewFile();
// 			}
// 			Iterator<String> it = inArr.iterator();
// 			while (it.hasNext()) {
// 				String aaa = it.next();
// 				writer.append(aaa+ System.getProperty("line.separator"));
// 			}
// 			writer.flush();
// 			writer.close();
// 			writer = null;
// 
// 		} catch (Exception e) {
// 			
// 			 Log.e("DataAggregator", "--------Failed to write in a file-----" + e.getMessage() + "; Stack: " + Log.getStackTraceString(e));
// 			
// 		}
// 	}
// 
// 
// 	// Added by AP
// 	// Uses a file name passed into the IOManager
// 	public boolean logData(DataAcquisitor dataAcq, boolean append) {
// 		if (dataAcq.getDataBuffer().size() <= 0) {
// 			return false;
// 		}
// 		//File dirs = new File(getPath() + dataAcq.getFolderName());
// 		File dirs = new File(getPath());
// 		if (!dirs.exists()) {
// 			dirs.mkdirs();
// 		}
// 
// 		String fileName = Setting.filenameFormat.format(new Date()) + "_" + getCurrentFilename();
// 		File logFile = new File(dirs, fileName);
// 		try {
// 			FileWriter writer = new FileWriter(logFile, append);
// 			for (String s : dataAcq.getDataBuffer()) {
// 				writer.append(s + System.getProperty("line.separator"));
// 			}
// 			writer.flush();
// 			writer.close();
// 			return true;
// 
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 			return false;
// 		}
// 	}
// 
// 	public void logError(String msg) {
// 		PrintWriter printWr;
// 		Date a = new Date (System.currentTimeMillis());
// 		String errorDate = a.getDate()+"-"+a.getMonth()+"-"+a.getYear();
// 		File errorFile = new File(Setting.Instance(null).getLogFolder(), "error_"+errorDate+".txt");
// 		try {
// 			printWr = new PrintWriter(new FileWriter(errorFile, true));
// 			printWr.append(msg + System.getProperty("line.separator"));
// 			printWr.flush();
// 			printWr.close();
// 			printWr = null;
// 		} catch (Exception ex) {
// 			Log.e("IOManager.logError", ex.getMessage(), ex);
// 		}
// 	}
// 
// }


// Path: app/src/main/java/com/ubiqlog/core/DataAcquisitor.java
import com.ubiqlog.utils.IOManager;
import java.util.ArrayList;

	public DataAcquisitor(String folderName, String fileName) {
		//this.context = context;
		this.folderName = folderName;
		dataBuffer = new ArrayList<String>();
		this.fileName = fileName;
	}

	public void removeData(Long timeinms) {

	}

	public ArrayList<String> getDataBuffer() {
		return dataBuffer;
	}

	public String getCurrrentFileName() {
		return fileName;
	}


	public void insert(String s, boolean append, int maxBuffSize) {
		//Log.d(LOG_TAG, "Inserting into dBuff");
		dataBuffer.add(s);
		if (dataBuffer.size() >= maxBuffSize) {
			flush(append);
		}
	}

	public void flush(boolean append) {
		//Log.d(LOG_TAG, "Flushing buffer" + this.getFolderName());
		IOManager dataLogger = new IOManager(getCurrrentFileName(), getFolderName());