mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-21 21:25:38 +00:00
re-added com.sap.sailing.nmeaconnector[.test]
Change-Id: Iae27c3b4625afc4542331feb5b4088d56903150c
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.sap.sailing.nmeaconnector</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=false
|
||||
resolve.requirebundle=false
|
||||
@@ -0,0 +1,13 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Nmeaconnector
|
||||
Bundle-SymbolicName: com.sap.sailing.nmeaconnector
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ClassPath: .
|
||||
Export-Package: com.sap.sailing.nmeaconnector
|
||||
Require-Bundle: com.sap.sailing.domain,
|
||||
com.sap.sailing.domain.common,
|
||||
com.sap.sse.common,
|
||||
net.sf.marineapi
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>root</artifactId>
|
||||
<groupId>com.sap.sailing</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.sap.sailing.nmeaconnector</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.sap.sailing.nmeaconnector;
|
||||
|
||||
import com.sap.sailing.nmeaconnector.impl.NmeaFactoryImpl;
|
||||
|
||||
public interface NmeaFactory {
|
||||
static NmeaFactory INSTANCE = new NmeaFactoryImpl();
|
||||
|
||||
NmeaUtil getUtil();
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.sap.sailing.nmeaconnector;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.SpeedWithBearing;
|
||||
import com.sap.sailing.domain.common.Wind;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
import net.sf.marineapi.nmea.sentence.MWVSentence;
|
||||
import net.sf.marineapi.nmea.util.Units;
|
||||
|
||||
public interface NmeaUtil {
|
||||
Wind getWind(TimePoint timePoint, Position position, MWVSentence mwvSentence);
|
||||
|
||||
Speed getSpeed(double magnitude, Units unit);
|
||||
|
||||
SpeedWithBearing getSpeedWithBearing(double speedMagnitude, Units speedUnit, double bearingInDegrees);
|
||||
|
||||
/**
|
||||
* Replaces all occurrences of <code>sequenceToFind</code> by <code>replaceWith</code>, as {@link String#replace(CharSequence, CharSequence)},
|
||||
* but assuming that <code>nmeaSentence</code> has a trailing NMEA checksum, adjusts the checksum accordingly. This will turn a valid
|
||||
* checksum into a valid checksum again, and an invalid checksum into an invalid checksum.
|
||||
*/
|
||||
String replace(String nmeaSentence, String sequenceToFind, String replaceWith);
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
package com.sap.sailing.nmeaconnector.impl;
|
||||
|
||||
import com.sap.sailing.nmeaconnector.NmeaFactory;
|
||||
import com.sap.sailing.nmeaconnector.NmeaUtil;
|
||||
|
||||
public class NmeaFactoryImpl implements NmeaFactory {
|
||||
|
||||
@Override
|
||||
public NmeaUtil getUtil() {
|
||||
return new NmeaUtilImpl();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
package com.sap.sailing.nmeaconnector.impl;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.KilometersPerHourSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.common.Bearing;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.SpeedWithBearing;
|
||||
import com.sap.sailing.domain.common.Wind;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.KilometersPerHourSpeedImpl;
|
||||
import com.sap.sailing.domain.common.impl.KnotSpeedImpl;
|
||||
import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.WindImpl;
|
||||
import com.sap.sailing.nmeaconnector.NmeaUtil;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
import net.sf.marineapi.nmea.sentence.MWVSentence;
|
||||
import net.sf.marineapi.nmea.util.Units;
|
||||
|
||||
public class NmeaUtilImpl implements NmeaUtil {
|
||||
|
||||
@Override
|
||||
public Wind getWind(TimePoint timePoint, Position position, MWVSentence mwvSentence) {
|
||||
return new WindImpl(position, timePoint, new KnotSpeedWithBearingImpl(mwvSentence.getSpeed(),
|
||||
new DegreeBearingImpl(mwvSentence.getAngle())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Speed getSpeed(double magnitude, Units unit) {
|
||||
switch (unit) {
|
||||
case KMH:
|
||||
return new KilometersPerHourSpeedImpl(magnitude);
|
||||
case KNOT:
|
||||
return new KnotSpeedImpl(magnitude);
|
||||
case METER:
|
||||
return new KilometersPerHourSpeedImpl(magnitude * 3.6);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unit "+unit+" not understood for a speed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpeedWithBearing getSpeedWithBearing(double speedMagnitude, Units speedUnit, double bearingInDegrees) {
|
||||
Bearing bearing = new DegreeBearingImpl(bearingInDegrees);
|
||||
switch (speedUnit) {
|
||||
case KMH:
|
||||
return new KilometersPerHourSpeedWithBearingImpl(speedMagnitude, bearing);
|
||||
case KNOT:
|
||||
return new KnotSpeedWithBearingImpl(speedMagnitude, bearing);
|
||||
case METER:
|
||||
return new KilometersPerHourSpeedWithBearingImpl(speedMagnitude * 3.6, bearing);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unit "+speedUnit+" not understood for a speed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String replace(String nmeaSentence, String regexToFind, String replaceWith) {
|
||||
while (nmeaSentence.matches(".*" + regexToFind + ".*")) {
|
||||
final String resultWithOldChecksum = nmeaSentence.replaceFirst(regexToFind, replaceWith);
|
||||
if (resultWithOldChecksum.matches(".*\\*[0-9a-fA-F][0-9a-fA-F]$")) {
|
||||
// found checksum
|
||||
int checksum = Integer.valueOf(resultWithOldChecksum.substring(resultWithOldChecksum.length() - 2), 16);
|
||||
for (char oldChar : regexToFind.toCharArray()) {
|
||||
checksum ^= (byte) oldChar;
|
||||
}
|
||||
for (char newChar : replaceWith.toCharArray()) {
|
||||
checksum ^= (byte) newChar;
|
||||
}
|
||||
String newHexChecksum = Integer.toHexString(checksum).toUpperCase();
|
||||
if (newHexChecksum.length() == 1) {
|
||||
newHexChecksum = "0" + newHexChecksum;
|
||||
}
|
||||
nmeaSentence = resultWithOldChecksum.substring(0, resultWithOldChecksum.length() - 2) + newHexChecksum;
|
||||
} else {
|
||||
nmeaSentence = resultWithOldChecksum;
|
||||
}
|
||||
}
|
||||
return nmeaSentence;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user