package org.hwo.pulscounter; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.hwo.csv.CSV; import org.hwo.datetime.TimeOfDay; public class TimeBarrier { ArrayList channels; private TimeOfDay timeOfDay; public TimeBarrier(int timeOfDay) { this.timeOfDay = new TimeOfDay(timeOfDay); this.channels = new ArrayList(); } public TimeBarrier(Integer HourOfDay,Integer MinuteOfDay) { this.timeOfDay = new TimeOfDay(HourOfDay,MinuteOfDay,0); this.channels = new ArrayList(); } public void save() { try { save(new FileOutputStream(String.format("day-%d.csv", timeOfDay))); } catch (FileNotFoundException e) { e.printStackTrace(); } } public void save(OutputStream output) { CSV csv = new CSV(); for (CounterChannel channel: channels) { // csv.getRecords().add(new String[]{channel.getChannel().toString(),channel.getValue().toString(),channel.getCorrect().toString(),channel.correctedValue().toString()}); } csv.saveToStream(output); } @Override public String toString() { return String.format("Werte bis %02d:%02d", timeOfDay.getHours(), timeOfDay.getMinutes()); } public TimeOfDay getTimeOfDay() { return timeOfDay; } public void setTimeOfDay(TimeOfDay timeOfDay) { this.timeOfDay = timeOfDay; } }