]> git.gag.com Git - fw/altos/blob - altoslib/AltosFile.java
doc: Create release notes for version 1.4
[fw/altos] / altoslib / AltosFile.java
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
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.
7  *
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.
12  *
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.
16  */
17
18 package org.altusmetrum.altoslib_4;
19
20 import java.io.File;
21 import java.util.*;
22
23 public class AltosFile extends File {
24
25         static String number(int n) {
26                 if (n == AltosLib.MISSING)
27                         return "unkn";
28                 else
29                         return String.format("%04d", n);
30         }
31
32         static String receiver(int receiver) {
33                 if (receiver == AltosLib.MISSING)
34                         return "";
35                 return String.format("-via-%04d", receiver);
36         }
37
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));
42         }
43
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);
46         }
47
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),
52                      serial,
53                      flight,
54                      receiver,
55                      extension);
56         }
57
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),
62                      serial,
63                      flight,
64                      AltosLib.MISSING,
65                      extension);
66         }
67
68         public AltosFile(AltosState state) {
69                 this(state.serial, state.flight, state.receiver_serial, "telem");
70         }
71 }