package org.bench4q.monitor.file.windows;

import java.io.PrintWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

import org.bench4q.monitor.model.PhysicalDiskModel;
import org.bench4q.monitor.service.windows.PhysicalDiskServiceWindows;
import org.bench4q.monitor.files.Write;

public class WritePhysicalDiskWindows extends Write {

	private PhysicalDiskServiceWindows physicalDiskServiceWindows;

	public WritePhysicalDiskWindows(PrintWriter out, int idleTime) {
		this.out = out;
		this.physicalDiskServiceWindows = new PhysicalDiskServiceWindows();
		this.idleTime = idleTime;
	}

	public void run() {
		try {
			JAXBContext context = JAXBContext
					.newInstance(PhysicalDiskModel.class);
			Marshaller marshaller = context.createMarshaller();
			PhysicalDiskModel physicalDiskModel = physicalDiskServiceWindows
					.getPhysicalDiskInfo(idleTime);
			marshaller.marshal(physicalDiskModel, out);
		} catch (Exception e) {
			System.out.println(e);
		}

	}

}
