public class SVData {
public int PRN = 0;
public int elevation = 0;
public int azimuth = 0;
public int SNR = 0;
private String SNRMessage;
// private static final String TABLE_BEGIN = "
| ";
// private static final String TABLE_NEXT = " | ";
// private static final String TABLE_END = " |
";
// private static final String TABLE_BEGIN_B = "| ";
// private static final String TABLE_NEXT_B = " | ";
// private static final String TABLE_END_B = " |
";
public SVData(String PRN, String elevation, String azimuth, String SNR) {
try {
this.PRN = Integer.parseInt(PRN);
this.elevation = Integer.parseInt(elevation);
this.azimuth = Integer.parseInt(azimuth);
this.SNR = Integer.parseInt(SNR);
} catch (java.lang.NumberFormatException nfe) {
if (PRN.length() == 0) { PRN = "0";}
if (elevation.length() == 0) { elevation = "0"; }
if (azimuth.length() == 0) { azimuth = "0"; }
if (SNR.length() == 0) { SNR = "-99"; }
this.PRN = Integer.parseInt(PRN);
this.elevation = Integer.parseInt(elevation);
this.azimuth = Integer.parseInt(azimuth);
this.SNR = Integer.parseInt(SNR);
}
}
public String toString(int format) {
SNRMessage = Integer.toString(SNR) + " dB";
if (SNR == -99) {
SNRMessage = "Not Tracking";
}
// StringBuffer sb = new StringBuffer(60);
switch (format) {
case 1:
return Integer.toString(PRN) + "--> elevation: " + Integer.toString(elevation) +
" azimuth: " + Integer.toString(azimuth) + " SNR: " + SNRMessage;
case 2:
// sb.append(TABLE_BEGIN);
// sb.append(Integer.toString(PRN));
// sb.append(TABLE_NEXT);
// sb.append(SNRMessage);
// sb.append(TABLE_NEXT);
// sb.append(elevation);
// sb.append(TABLE_NEXT);
// sb.append(azimuth);
// sb.append(TABLE_END);
// return sb.toString();
return "| " + Integer.toString(PRN) +
" | " + SNRMessage +
" | " + Integer.toString(elevation) +
" | "+ Integer.toString(azimuth) +" |
\r\n";
case 3:
// sb.append(TABLE_BEGIN_B);
// sb.append(Integer.toString(PRN));
// sb.append(TABLE_NEXT_B);
// sb.append(SNRMessage);
// sb.append(TABLE_NEXT_B);
// sb.append(elevation);
// sb.append(TABLE_NEXT_B);
// sb.append(azimuth);
// sb.append(TABLE_END_B);
// return sb.toString();
return "| " + Integer.toString(PRN) +
" | " + SNRMessage +
" | " + Integer.toString(elevation) +
" | " + Integer.toString(azimuth) + " |
\r\n";
default:
return "Unknown format in SVData.toString";
}
}
}