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