add sensible field names

pull/8/head
Medad Rufus Newman 2022-05-07 23:24:20 +01:00
rodzic 4f21e36754
commit e9a4d8bca8
4 zmienionych plików z 17 dodań i 17 usunięć

Wyświetl plik

@ -87,11 +87,11 @@ public final class PayloadDecoder {
double altitude = sodaq.getAltitude();
Instant instant = Instant.ofEpochSecond(sodaq.getTimeStamp());
Sentence sentence = new Sentence(callSign, counter, instant);
sentence.addField(String.format(Locale.ROOT, "%.6f", latitude));
sentence.addField(String.format(Locale.ROOT, "%.6f", longitude));
sentence.addField(String.format(Locale.ROOT, "%.1f", altitude));
sentence.addField(String.format(Locale.ROOT, "%.0f", sodaq.getBoardTemp()));
sentence.addField(String.format(Locale.ROOT, "%.2f", sodaq.getBattVoltage()));
sentence.addField("lat", String.format(Locale.ROOT, "%.6f", latitude));
sentence.addField("lon", String.format(Locale.ROOT, "%.6f", longitude));
sentence.addField("alt", String.format(Locale.ROOT, "%.1f", altitude));
sentence.addField("temp", String.format(Locale.ROOT, "%.0f", sodaq.getBoardTemp()));
sentence.addField("batt", String.format(Locale.ROOT, "%.2f", sodaq.getBattVoltage()));
return sentence;
} catch (BufferUnderflowException e) {
throw new DecodeException("Error decoding sodaqone", e);
@ -117,15 +117,15 @@ public final class PayloadDecoder {
double longitude = parseDouble(fields.get("lon"));
double altitude = parseDouble(fields.get("gpsalt"));
Sentence sentence = new Sentence(callSign, counter, time);
sentence.addField(String.format(Locale.ROOT, "%.6f", latitude));
sentence.addField(String.format(Locale.ROOT, "%.6f", longitude));
sentence.addField(String.format(Locale.ROOT, "%.1f", altitude));
sentence.addField("lat", String.format(Locale.ROOT, "%.6f", latitude));
sentence.addField("lon", String.format(Locale.ROOT, "%.6f", longitude));
sentence.addField("alt", String.format(Locale.ROOT, "%.1f", altitude));
if (fields.containsKey("temp") && fields.containsKey("vcc")) {
Double temp = parseDouble(fields.get("temp"));
Double vcc = parseDouble(fields.get("vcc"));
sentence.addField(String.format(Locale.ROOT, "%.1f", temp));
sentence.addField(String.format(Locale.ROOT, "%.3f", vcc));
sentence.addField("temp", String.format(Locale.ROOT, "%.1f", temp));
sentence.addField("batt", String.format(Locale.ROOT, "%.3f", vcc));
}
return sentence;
} catch (RuntimeException e) {

Wyświetl plik

@ -17,9 +17,9 @@ public final class SentenceTest {
public void testSentence() {
Instant instant = Instant.ofEpochSecond(0);
Sentence sentence = new Sentence("CALL", 1, instant);
sentence.addField("3.45");
sentence.addField("6.78");
sentence.addField("9.0");
sentence.addField("lon", "3.45");
sentence.addField("lat", "6.78");
sentence.addField("alt", "9.0");
String s = sentence.format();
Assert.assertEquals("$$CALL,1,00:00:00,3.45,6.78,9.0*906C\n", s);
@ -32,7 +32,7 @@ public final class SentenceTest {
@Test
public void testSentenceExtras() {
Sentence sentence = new Sentence("CALL", 1, Instant.now());
sentence.addField("hello");
sentence.addField("extra" ,"hello");
String s = sentence.format();
Assert.assertTrue(s.contains("hello"));

Wyświetl plik

@ -51,7 +51,7 @@ public final class AmateurSondehubTest {
HabReceiver receiver = new HabReceiver("BERTRIK", LOCATION);
Instant instant = Instant.now();
Sentence sentence = new Sentence("NOTAFLIGHT", 1, instant);
sentence.addField("52.0182307,4.695772,1000");
sentence.addField("location", "52.0182307,4.695772,1000");
uploader.schedulePayloadTelemetryUpload(sentence.format(), Arrays.asList(receiver), instant);
Mockito.verify(restClient, Mockito.timeout(3000).times(1)).uploadDocument(Mockito.anyString());

Wyświetl plik

@ -52,7 +52,7 @@ public final class HabitatUploaderTest {
HabReceiver receiver = new HabReceiver("BERTRIK", LOCATION);
Instant instant = Instant.now();
Sentence sentence = new Sentence("NOTAFLIGHT", 1, instant);
sentence.addField("52.0182307,4.695772,1000");
sentence.addField("location", "52.0182307,4.695772,1000");
uploader.schedulePayloadTelemetryUpload(sentence.format(), Arrays.asList(receiver), instant);
Mockito.verify(restClient, Mockito.timeout(3000).times(1)).updateListener(Mockito.anyString(),
@ -105,7 +105,7 @@ public final class HabitatUploaderTest {
try {
Instant instant = Instant.now();
Sentence sentence = new Sentence("NOTAFLIGHT", 1, instant);
sentence.addField("52.0182307,4.695772,1000");
sentence.addField("location", "52.0182307,4.695772,1000");
HabReceiver receiver = new HabReceiver("BERTRIK", null);
uploader.schedulePayloadTelemetryUpload(sentence.format(), Arrays.asList(receiver), instant);
Thread.sleep(3000);