Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jflight/vario/Vario.java


1   
2   /*
3   Project name:   JFlight
4   Hosted at:      www.sourceforge.net
5   Homepage:       jflight.sourceforge.net
6   Licence:        GNU public licence (GPL)
7   Filename:       Gps.java
8   Package:        jflight
9   */
10  package jflight.vario;
11  
12  
13  
14  import java.util.*;
15  import java.text.*;
16  import java.io.*;
17  import jflight.gps.*;
18  import jflight.model.*;
19  
20  /**
21  Basic class for Vario-access;
22  Implements only the basic, device-independent methods. The other
23  functions are declared abstract and have to be defined in the derived
24  class for a specific Vario. All these functions define the interface
25  that is/can be used by the main class.<br>
26  
27  Interface for the Vario-class(es).<br>
28  The data supplied by any Vario are expected to be at least these:<br>
29  A series of height-data and (optionally) windspeed-data.<br>
30  The data are collected at regular intervalls. The intervall is also
31  supplied.<br>
32  Start-and endtime are optional.<br>
33  There may be marks (defining a certain time) which also may have a
34  coordinate. These coordinate values don't make sense in this
35  application (supplied by the GPS).<br>
36  <br>
37  Notes:<br>
38  - If no speeddata are available the first speedvalue is set to -1.<br>
39  - Datavalues that were taken on the ground are marked with an
40  offset of -1000 in the speedvalue (except the first one).
41  This is done in the data used internally only, not in the stored values.<br>
42  <br>
43  Tbd:<br>
44  - How does mark-setting affect the regular intervalls?
45  - What about US-style settings: feet / feet per minute?<br>
46  <br>
47  Multiple sets of flightdata in the vario may be joined to a single
48  flight. This is because there may be problems when switching to the
49  backup battery. The missing height-data shall be interpolated assuming
50  the time difference information is valid. The speed-data are set to the
51  glider-default.<br>
52  If windspeed data are available the Vario-flight-data may be shortened
53  by the data before launch and after landing by setting a windspeed
54  threshhold. This can be done alternativly / in addition using constant
55  height (threshhold) too. Should be confirmed by the user. Note that such
56  an operation has to be done anyhow to map the vario-and GPS-data later.
57  The values removed are not really removed but marked by a windspeed of -1.<br>
58  <br>
59  Device-independence: All Classes shall be designed in such a way that the main
60  program using them can rely on a basic set of methods that are
61  implemented by all implementations regardless of the real Vario-device
62  used.<br>
63  
64  @since          JDK1.1.x
65  @author         Rüdiger Bien
66  
67  @CVS-section:
68  @file_version   $Revision: 1.15 $
69  
70  */
71  public abstract class Vario {
72  
73  
74      /** mode for list-management */
75      public final static int     REPLACE           = 1;
76      /** mode for list-management */
77      public final static int     APPEND            = 2;
78  
79  
80      protected final static int SUCCESS             = 0;
81      protected final static int BAD_CRC             = -1;  // error-codes < 0 !
82      protected final static int IO_NOT_INITIALIZED  = -6;
83    protected boolean ioInit;
84    protected OutputStream os;
85    protected InputStream is;
86  
87    private int pid;
88    private int bufSize;
89    private VarioData curVarioData;
90      protected BaroContainer baroCont = null;
91  
92      /**
93       * Initializes the datastructures.
94       **/
95      public Vario() {
96  
97      ioInit = false;
98          baroCont = BaroContainer.getInstance();
99      }
100 
101   /**
102     Get a single barogram. The flight may be specified by a number, if the
103     Vario supports this. Otherwise it is ignored. Bufer 0 is used.
104   <br>
105     tbd: add mode-flag for append-mode
106     <br>
107     @return status-info     SUCCESS or other ;-)
108   @exception  IOException
109   */
110     public abstract int getBarogram(int flightNumber) throws IOException;
111     /** Get the flightbook from the vario
112     @return status-info     SUCCESS, NOT_AVAILABLE or other ;-)
113     @exception              IOException
114     */
115     public abstract int getFlightBook();
116 
117 
118     /**
119     Stores the stream to use for Vario access.
120 
121     @param   is  serial input stream
122     @param   os  serial output stream
123 
124     */
125   public void initIOStreams(InputStream is, OutputStream os) {
126 
127     ioInit = true;
128     this.is = is;
129     this.os = os;
130   }
131 
132     /**
133     Clears the stream-infos.
134 
135     */
136   public void deinitIOStreams() {
137     ioInit = false;
138   }
139 
140 
141 
142     /**
143      * delays some milliseconds
144      *                                                         *
145      * @param milli                                            *
146      */
147     protected void delay(int milli) {
148 
149         try {
150             Thread.sleep(milli);
151         } catch (InterruptedException e) {
152 
153             // the VM doesn't want us to sleep anymore,
154             // so get back to work
155         }
156     }
157 
158 
159 }
160 
161 
162