Skip to content

Commit

Permalink
docs and checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
chrlembeck committed Apr 11, 2024
1 parent 52849d6 commit 56f5307
Show file tree
Hide file tree
Showing 81 changed files with 2,451 additions and 102 deletions.
27 changes: 25 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,29 @@
</algorithms>
</configuration>
</plugin>
<!-- <plugin>
<groupId>net.nicoulaj.maven.plugins</groupId>
<artifactId>checksum-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>files</goal>
</goals>
</execution>
</executions>
<configuration>
<algorithms>
<algorithm>MD5</algorithm>
<algorithm>SHA-1</algorithm>
</algorithms>
<fileSets>
<fileSet>
<directory>target</directory>
<include>*.pom</include>
</fileSet>
</fileSets>
</configuration>
</plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -256,8 +279,8 @@
<locale>en_US</locale>
<show>protected</show>
<doclint>all,missing</doclint>
<quiet>false</quiet>
<verbose>true</verbose>
<quiet>true</quiet>
<verbose>false</verbose>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void run() {
}

readBuffer.position(0);
SimResponse response = SimResponse.parseResponse(size, readBuffer);
SimResponse response = SimResponse.parseResponse(readBuffer);
handleResponse(response);
}
} catch (ClosedChannelException cce) {
Expand Down
294 changes: 282 additions & 12 deletions src/main/java/org/lembeck/fs/simconnect/SimConnect.java

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/main/java/org/lembeck/fs/simconnect/SimUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,23 @@ public static double meterToNM(double meter) {
public static double nmToMeter(double nauticalMiles) {
return nauticalMiles * METERS_PER_NAUTICAL_MILE;
}

/**
* Converts the passed byte array to a human-readable form.
*
* @param data Array of bytes to be converted.
* @return Human-readable representation of the byte array to use it in debug messages.
*/
public static String byteArrayToString(byte[] data) {
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < data.length; i++) {
sb.append(data[i] & 0xff);
if (i < data.length - 1) {
sb.append(", ");
}
}
sb.append("]");
return sb.toString();
}
}
97 changes: 95 additions & 2 deletions src/main/java/org/lembeck/fs/simconnect/constants/DataType.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,121 @@
package org.lembeck.fs.simconnect.constants;

/**
* The SIMCONNECT_DATATYPE enumeration type is used with the SimConnect_AddToDataDefinition call to specify the data
* type that the server should use to return the specified data to the client.
*
* @see <a href="https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_DATATYPE.htm">https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_DATATYPE.htm</a>
*/
public enum DataType {

/**
* Specifies an invalid data type marker (should not be used).
*/
INVALID(-1),

/**
* Specifies a 32 bit unsigned integer value.
*/
INT32(4),

/**
* Specifies a 64 bit signed integer value.
*/
INT64(8),

/**
* Specifies a 32 bit floating point number.
*/
FLOAT32(4),

/**
* Specifies a 64 bit floating point number.
*/
FLOAT64(8),

/**
* Specifies strings of the length up to 8 characters.
*/
STRING8(8),

/**
* Specifies strings of the length up to 32 characters.
*/
STRING32(32),

/**
* Specifies strings of the length up to 64 characters.
*/
STRING64(64),

/**
* Specifies strings of the length up to 128 characters.
*/
STRING128(128),

/**
* Specifies strings of the length up to 256 characters.
*/
STRING256(256),

/**
* Specifies strings of the length up to 260 characters.
*/
STRING260(260),

/**
* Specifies a variable length string.
*/
STRINGV(-1),

/**
* Specifies the SIMCONNECT_DATA_INITPOSITION structure.
*
* @see org.lembeck.fs.simconnect.request.InitPosition
*/
INITPOSITION(56),

/**
* Specifies the SIMCONNECT_DATA_MARKERSTATE structure.
*/
MARKERSTATE(68),

/**
* Specifies the SIMCONNECT_DATA_WAYPOINT structure.
*/
WAYPOINT(48),

/**
* Specifies the SIMCONNECT_DATA_LATLONALT structure.
*
* @see org.lembeck.fs.simconnect.response.LatLonAlt
*/
LATLONALT(24),

/**
* Specifies the SIMCONNECT_DATA_XYZ structure.
*
* @see org.lembeck.fs.simconnect.response.DataXYZ
*/
XYZ(24),
UNKNOWN(-1);

/**
* Specifies an unknown data type (should not be used).
*/
UNKNOWN(-1);

private final int size;

DataType(int size) {
this.size = size;
}

/**
* Returns the data type that is specified by the given identifier.
*
* @param id Identifier for the data type.
* @return The data type that is specified by the given identifier.
*/
public static DataType ofId(int id) {
return switch (id) {
case 0 -> INVALID;
Expand All @@ -51,7 +139,12 @@ public static DataType ofId(int id) {
};
}

/**
* Returns the size of one member of the data type in bytes.
*
* @return Size of the data type in bytes.
*/
public int getSize() {
return size;
}
}
}
Loading

0 comments on commit 56f5307

Please sign in to comment.