a81eb0d357dba3f34e28daf3f54e8655f1bcb968
[fw/altos] / micropeak / MicroDataPoint.java
1 /*
2  * Copyright © 2012 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.micropeak;
19
20 import org.altusmetrum.altosuilib_1.*;
21
22 public class MicroDataPoint implements AltosUIDataPoint {
23         public double   time;
24         public double   pressure;
25         public double   height;
26         public double   speed;
27         public double   accel;
28
29         public static final int data_height = 0;
30         public static final int data_speed = 1;
31         public static final int data_accel = 2;
32
33         public double x() {
34                 return time;
35         }
36
37         public double y(int index) {
38                 switch (index) {
39                 case data_height:
40                         return height;
41                 case data_speed:
42                         return speed;
43                 case data_accel:
44                         return accel;
45                 default:
46                         return 0;
47                 }
48         }
49
50         public MicroDataPoint (double pressure, double height, double speed, double accel, double time) {
51                 this.pressure = pressure;
52                 this.height = height;
53                 this.speed = speed;
54                 this.accel = accel;
55                 this.time = time;
56         }
57
58         public MicroDataPoint(MicroData data, int i) {
59                 this(data.pressure(i),
60                      data.height(i),
61                      data.speed(i),
62                      data.acceleration(i),
63                      data.time(i));
64         }
65 }