2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.altoslib_4;
23 public class AltosFile extends File {
25 static String number(int n) {
26 if (n == AltosLib.MISSING)
29 return String.format("%04d", n);
32 static String receiver(int receiver) {
33 if (receiver == AltosLib.MISSING)
35 return String.format("-via-%04d", receiver);
38 public AltosFile(int year, int month, int day, int serial, int flight, int receiver, String extension) {
39 super (AltosPreferences.logdir(),
40 String.format("%04d-%02d-%02d-serial-%s-flight-%s%s.%s",
41 year, month, day, number(serial), number(flight), receiver(receiver), extension));
44 public AltosFile(int year, int month, int day, int serial, int flight, String extension) {
45 this(year, month, day, serial, flight, AltosLib.MISSING, extension);
48 public AltosFile(int serial, int flight, int receiver, String extension) {
49 this(Calendar.getInstance().get(Calendar.YEAR),
50 Calendar.getInstance().get(Calendar.MONTH) + 1,
51 Calendar.getInstance().get(Calendar.DAY_OF_MONTH),
58 public AltosFile(int serial, int flight, String extension) {
59 this(Calendar.getInstance().get(Calendar.YEAR),
60 Calendar.getInstance().get(Calendar.MONTH) + 1,
61 Calendar.getInstance().get(Calendar.DAY_OF_MONTH),
68 public AltosFile(AltosState state) {
69 this(state.serial, state.flight, state.receiver_serial, "telem");