diff --git a/pom.xml b/pom.xml index a932cfc..d813f8e 100644 --- a/pom.xml +++ b/pom.xml @@ -194,6 +194,29 @@ + org.apache.maven.plugins @@ -256,8 +279,8 @@ en_US protected all,missing - false - true + true + false diff --git a/src/main/java/org/lembeck/fs/simconnect/ResponseReceiver.java b/src/main/java/org/lembeck/fs/simconnect/ResponseReceiver.java index a573544..8fbb1cd 100644 --- a/src/main/java/org/lembeck/fs/simconnect/ResponseReceiver.java +++ b/src/main/java/org/lembeck/fs/simconnect/ResponseReceiver.java @@ -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) { diff --git a/src/main/java/org/lembeck/fs/simconnect/SimConnect.java b/src/main/java/org/lembeck/fs/simconnect/SimConnect.java index 6cd7819..e9c57b4 100644 --- a/src/main/java/org/lembeck/fs/simconnect/SimConnect.java +++ b/src/main/java/org/lembeck/fs/simconnect/SimConnect.java @@ -18,31 +18,52 @@ public class SimConnect { private final ResponseReceiver responseReceiver; - private final ByteBuffer inBuffer; - private final ByteBuffer outBuffer; private final AtomicInteger lastUniqueRequestIdentifier = new AtomicInteger(0); private final static AtomicInteger lastUserRequestIdentifier = new AtomicInteger(0); + private final static AtomicInteger lastUserDefineIdentifier = new AtomicInteger(0); private final static AtomicInteger lastUserEventIdentifier = new AtomicInteger(0); private Thread responseReceiverThread; + /** + * Creates a new instance of the simconnect communication client. Even if it is possible to use multiple client + * instances in an application, it is recommended to only create one instance of this class to avoid confusion + * in communication. + */ public SimConnect() { responseReceiver = new ResponseReceiver(); - this.inBuffer = ByteBuffer.allocateDirect(64 * 1024); this.outBuffer = ByteBuffer.allocateDirect(64 * 1024); - inBuffer.order(LITTLE_ENDIAN); outBuffer.order(LITTLE_ENDIAN); } + /** + * Establishes the socket connection from this client to the simulator. + * + * @param hostname Name of the machine, the simulator is running on. + * @param port Port on wich the simconnect interface of the simulator is listening. This port can be configured + * in the simulators simconnect.xml file. + * @param appName Name of this application. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_XML_Definition.htm + * @see #connect(SocketAddress, String) + */ public void connect(String hostname, int port, String appName) throws IOException { connect(new InetSocketAddress(hostname, port), appName); } + /** + * Establishes the socket connection from this client to the simulator. + * + * @param address Address on wich the simconnect interface of the simulator is listening. This address can be + * configured in the simulators simconnect.xml file. + * @param appName Name of this application. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_XML_Definition.htm + * @see #connect(String, int, String) + */ public void connect(SocketAddress address, String appName) throws IOException { channel = SocketChannel.open(address); responseReceiver.setChannel(channel); @@ -53,20 +74,49 @@ public void connect(SocketAddress address, String appName) throws IOException { responseReceiverThread.start(); } + /** + * Informs the response receiver to stop handling incoming responses and closes the socket connection to the + * simulator. + */ public void close() { try { responseReceiver.stop(); channel.close(); + channel = null; } catch (IOException ioe) { // ignore } } + /** + * Returns the response handler of this client. This is the place you can add listeners to receive the data that + * will be sent by the simulator. + * + * @return The ResponseReceiver object that handles th incoming responses from the simulator. + */ public ResponseReceiver getRequestReceiver() { return responseReceiver; } + /** + * Sends a single request from this client to the simulator. Can be used to send custom requests. Normally this + * method does not need to be called directly. Instead, the specific methods for each method can be used, which + * generate the requests and then send them via this method. + * + * @param request The request object that should be sent to the server. + * @param Type of the request object. + * @return The object that was passed to this method. Each request to the simulator via the simconnect api will be + * done with a unique request identifier. The Identifier will be generated within this method and set to the passed + * request object. Also the size of the request will be calculated during the process of sending an updated in the + * object. In order to be able to read the identifier and the calculated size, the object is returned again at this + * point. + */ public T write(T request) throws IOException { + if (channel == null) { + throw new IllegalStateException(""" + Can not write requests to the interface before the connection is not established. \ + Please call the connect() method before."""); + } request.setIdentifier(lastUniqueRequestIdentifier.incrementAndGet()); synchronized (outBuffer) { outBuffer.clear(); @@ -77,33 +127,122 @@ public T write(T request) throws IOException { return request; } + /** + * The SimConnect_MapClientEventToSimEvent function associates a client defined event ID with a Microsoft Flight + * Simulator event name. + * + * @param eventID Specifies the ID of the client event. + * @param eventName Specifies the Microsoft Flight Simulator event name. Refer to the Event IDs document for a list + * of event names (listed under String Name). If the event name includes one or more periods (such + * as "Custom.Event" in the example below) then they are custom events specified by the client, and + * will only be recognized by another client (and not Microsoft Flight Simulator) that has been + * coded to receive such events. No Microsoft Flight Simulator events include periods. If no entry + * is made for this parameter, the event is private to the client. + * Alternatively enter a decimal number in the format "#nnnn" or a hex number in the format + * "#0xnnnn", where these numbers are in the range THIRD_PARTY_EVENT_ID_MIN and + * THIRD_PARTY_EVENT_ID_MAX, in order to receive events from third-party add-ons to Flight + * Simulator X. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_MapClientEventToSimEvent.htm + * @see https://docs.flightsimulator.com/html/Programming_Tools/Event_IDs/Event_IDs.htm + */ public MapClientEventToSimEventRequest mapClientEventToSimEvent(int eventID, String eventName) throws IOException { return write(new MapClientEventToSimEventRequest(eventID, eventName)); } + /** + * The SimConnect_TransmitClientEvent function is used to request that the Microsoft Flight Simulator server + * transmit to all SimConnect clients the specified client event. + * + * @param objectID Specifies the ID of the server defined object. If this parameter is set to + * SIMCONNECT_OBJECT_ID_USER, then the transmitted event will be sent to the other clients in + * priority order. If this parameters contains another object ID, then the event will be sent + * direct to that sim-object, and no other clients will receive it. + * @param clientEventID Specifies the ID of the client event. + * @param data Double word containing any additional number required by the event. This is often zero. If + * the event is a Microsoft Flight Simulator event, then refer to the Event IDs document for + * information on this additional value. If the event is a custom event, then any value put in + * this parameter will be available to the clients that receive the event. + * @param priority This specifies the priority to send the message to all clients with this priority. + * To receive the event notification other SimConnect clients must have subscribed to receive + * the event. See the explanation of SimConnect Priorities. The exception to the default + * behavior is set by the SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY flag, described below. + * @param eventFlag One or more of the flags shown in {@link EventFlag}. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_TransmitClientEvent.htm + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#simconnect-priorities + * @see EventFlag + */ public TransmitClientEventRequest transmitClientEvent(int objectID, int clientEventID, int data, Priority priority, int eventFlag) throws IOException { return write(new TransmitClientEventRequest(objectID, clientEventID, data, priority, eventFlag)); } + /** + * The SimConnect_SetSystemEventState function is used to turn requests for event information from the server on and + * off. + * + * @param clientEventID Specifies the ID of the client event that is to have its state changed. + * @param state Double word containing the state (one member of SIMCONNECT_STATE). + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_SetSystemEventState.htm + */ public SetSystemEventStateRequest setSystemEventState(int clientEventID, State state) throws IOException { return write(new SetSystemEventStateRequest(clientEventID, state)); } + /** + * The SimConnect_AddClientEventToNotificationGroup function is used to add an individual client defined event to a + * notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group. + * @param clientEventID Specifies the ID of the client defined event. + * @param maskable True indicates that the event will be masked by this client and will not be + * transmitted to any more clients, possibly including Microsoft Flight Simulator itself + * (if the priority of the client exceeds that of Flight Simulator). + * False is the default. See the explanation of SimConnect Priorities. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_AddClientEventToNotificationGroup.htm + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#simconnect-priorities + */ public AddClientEventToNotificationGroupRequest addClientEventToNotificationGroup(int notificationGroupID, int clientEventID, boolean maskable) throws IOException { return write(new AddClientEventToNotificationGroupRequest(notificationGroupID, clientEventID, maskable)); } + /** + * The SimConnect_RemoveClientEvent function is used to remove a client defined event from a notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group. + * @param clientEventID Specifies the ID of the client defined event ID that is to be removed from the group. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_RemoveClientEvent.htm + */ public RemoveClientEventRequest removeClientEvent(int notificationGroupID, int clientEventID) throws IOException { return write(new RemoveClientEventRequest(notificationGroupID, clientEventID)); } + /** + * The SimConnect_SetNotificationGroupPriority function is used to set the priority for a notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group. + * @param priority The group's priority. See the explanation of SimConnect Priorities. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/General/SimConnect_SetNotificationGroupPriority.htm + */ public SetNotificationGroupPriorityRequest setNotificationGroupPriority(int notificationGroupID, - int priority) throws IOException { + Priority priority) throws IOException { return write(new SetNotificationGroupPriorityRequest(notificationGroupID, priority)); } + /** + * The SimConnect_ClearNotificationGroup function is used to remove all the client defined events from a + * notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group that is to have all its events removed. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_ClearNotificationGroup.htm + */ public ClearNotificationGroupRequest clearNotificationGroup(int notificationGroupID) throws IOException { return write(new ClearNotificationGroupRequest(notificationGroupID)); } @@ -129,7 +268,8 @@ public ClearDataDefinitionRequest clearDataDefinition(int dataDefinitionID) thro public RequestDataOnSimObjectRequest requestDataOnSimObject(int dataRequestID, int dataDefinitionID, int objectID, SimconnectPeriod period, int dataRequestFlags, int origin, int interval, int limit) throws IOException { - return write(new RequestDataOnSimObjectRequest(dataRequestID, dataDefinitionID, objectID, period, dataRequestFlags, origin, interval, limit)); + return write(new RequestDataOnSimObjectRequest(dataRequestID, dataDefinitionID, objectID, period, + dataRequestFlags, origin, interval, limit)); } public RequestDataOnSimObjectTypeRequest requestDataOnSimObjectType(int requestID, int defineID, int radiusMeters, @@ -172,6 +312,13 @@ public SubscribeToSystemEventRequest subscribeToSystemEvent(int eventID, String return write(new SubscribeToSystemEventRequest(eventID, eventName)); } + /** + * The SimConnect_UnsubscribeFromSystemEvent function is used to request that notifications are no longer received + * for the specified system event. + * + * @param eventID Specifies the ID of the client event. + * @return The Object that represents the message that was sent to the simulator. + */ public UnsubscribeFromSystemEventRequest unsubscribeFromSystemEvent(int eventID) throws IOException { return write(new UnsubscribeFromSystemEventRequest(eventID)); } @@ -184,7 +331,8 @@ public AICreateParkedATCAircraftRequest aiCreateParkedATCAircraft(String contain public AICreateEnrouteATCAircraftRequest aiCreateEnrouteATCAircraft(String containerTitle, String tailNumber, int flightNumber, String flightPlanPath, float flightPlanPosition, boolean touchAndGo, int requestID) throws IOException { - return write(new AICreateEnrouteATCAircraftRequest(containerTitle, tailNumber, flightNumber, flightPlanPath, flightPlanPosition, touchAndGo, requestID)); + return write(new AICreateEnrouteATCAircraftRequest(containerTitle, tailNumber, flightNumber, flightPlanPath, + flightPlanPosition, touchAndGo, requestID)); } public AICreateNonATCAircraftRequest aiCreateNonATCAircraft(String containerTitle, String tailNumber, @@ -268,7 +416,8 @@ public ClearClientDataDefinitionRequest clearClientDataDefinition(int defineID) public RequestClientDataRequest requestClientData(int clientDataID, int requestID, int defineID, SimconnectPeriod period, int flags, int origin, int interval, int limit) throws IOException { - return write(new RequestClientDataRequest(clientDataID, requestID, defineID, period, flags, origin, interval, limit)); + return write(new RequestClientDataRequest(clientDataID, requestID, defineID, period, flags, origin, interval, + limit)); } public SetClientDataDefinitionRequest setClientDataDefinition(int clientDataID, int defineID, boolean tagged, @@ -294,19 +443,78 @@ public SubscribeToFacilitiesRequest subscribeToFacilities(FacilityListType facil return write(new SubscribeToFacilitiesRequest(facilityListType, requestId)); } + /** + * The SimConnect_UnsubscribeToFacilities function is used to request that notifications of additions to the + * facilities cache are no longer sent. + * + * @param facilityListType Specifies one member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_UnsubscribeToFacilities.htm + */ public UnsubscribeToFacilitiesRequest unsubscribeToFacilities( FacilityListType facilityListType) throws IOException { return write(new UnsubscribeToFacilitiesRequest(facilityListType)); } + /** + * The SimConnect_RequestFacilitesList function is used to request a list of all the facilities of a given type + * currently in the world, or within a radius of the aircraft depending on the requested type. + * + * @param facilityListType Specifies one member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + * @param requestId Specifies the client defined request ID. This will be returned along with the data. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_RequestFacilitesList.htm + */ public RequestFacilitesListRequest requestFacilitiesList(FacilityListType facilityListType, int requestId) throws IOException { return write(new RequestFacilitesListRequest(facilityListType, requestId)); } + /** + * The SimConnect_TransmitClientEvent_EX1 function is used to request that the Microsoft Flight Simulator server + * transmit to all SimConnect clients the specified client event. This function is specifically designed to permit + * the sending of multiple parameters for the key event (up to five), unlike the SimConnect_TransmitClientEvent + * which only permits one. + * + * @param objectID Specifies the ID of the server defined object. If this parameter is set to + * SIMCONNECT_OBJECT_ID_USER, then the transmitted event will be sent to the other clients in + * priority order. If this parameters contains another object ID, then the event will be sent + * direct to that sim-object, and no other clients will receive it. + * @param eventID Specifies the ID of the client event. + * @param priority This specifies the priority to send the message to all clients with this priority. To receive + * the event notification other SimConnect clients must have subscribed to receive the event. See + * the explanation of SimConnect Priorities. The exception to the default behavior is set by the + * SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY flag, described below. + * @param eventFlag One or more of the flags shown in {@link EventFlag}. + * @param data0 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data1 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data2 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data3 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data4 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_TransmitClientEvent_EX1.htm + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#simconnect-priorities + * @see https://docs.flightsimulator.com/html/Programming_Tools/Event_IDs/Event_IDs.htm + */ public TransmitClientEventEx1Request transmitClientEventEx1(int objectID, int eventID, Priority priority, int eventFlag, int data0, int data1, int data2, int data3, int data4) throws IOException { - return write(new TransmitClientEventEx1Request(objectID, eventID, priority, eventFlag, data0, data1, data2, data3, data4)); + return write(new TransmitClientEventEx1Request(objectID, eventID, priority, eventFlag, data0, data1, data2, + data3, data4)); } public AddToFacilityDefinitionRequest addToFacilityDefinition(int defineID, String fieldName) throws IOException { @@ -323,9 +531,18 @@ public SubscribeToFacilitiesEx1Request subscribeToFacilitiesEx1(FacilityListType return write(new SubscribeToFacilitiesEx1Request(type, newElemInRangeRequestID, oldElemOutRangeRequestID)); } + /** + * The SimConnect_UnsubscribeToFacilities_EX1 function is used to request that notifications of additions to the + * facilities cache are no longer sent, with the ability to specify which event should be disabled. + * + * @param type Specifies one member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + * @param unsubscribeNewInRange Specifies that the "new element in range" event should be disabled. + * @param unsubscribeOldOutRange Specifies that the "element out of range" event should be disabled. + * @return The Object that represents the message that was sent to the simulator. + */ public UnsubscribeToFacilitiesEx1Request unsubscribeToFacilitiesEx1(FacilityListType type, - boolean unsubscribeNewInRange, boolean unsubscribeOldOutRang) throws IOException { - return write(new UnsubscribeToFacilitiesEx1Request(type, unsubscribeNewInRange, unsubscribeOldOutRang)); + boolean unsubscribeNewInRange, boolean unsubscribeOldOutRange) throws IOException { + return write(new UnsubscribeToFacilitiesEx1Request(type, unsubscribeNewInRange, unsubscribeOldOutRange)); } public RequestFacilitiesListEx1Request requestFacilitiesListEx1(FacilityListType type, @@ -348,7 +565,8 @@ public EnumerateControllersRequest enumerateControllers() throws IOException { public MapInputEventToClientEventEx1Request mapInputEventToClientEventEx1(int groupID, String inputDefinition, int downEventID, int downValue, int upEventID, int upValue, boolean bMaskable) throws IOException { - return write(new MapInputEventToClientEventEx1Request(groupID, inputDefinition, downEventID, downValue, upEventID, upValue, bMaskable)); + return write(new MapInputEventToClientEventEx1Request(groupID, inputDefinition, downEventID, downValue, + upEventID, upValue, bMaskable)); } public EnumerateInputEventsRequest enumerateInputEvents(int requestID) throws IOException { @@ -375,28 +593,80 @@ public SubscribeInputEventRequest subscribeInputEvent(long hash) throws IOExcept return write(new SubscribeInputEventRequest(hash)); } + /** + * The SimConnect_UnsubscribeInputEvent function is used to unsubscribe from an input event that has previously been + * subscribed to. + * + * @param hash Hash ID that will identify the desired input event to unsubscribe from. You can use 0 here to + * unsubscribe from all input events. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/InputEvents/SimConnect_UnsubscribeInputEvent.htm + */ public UnsubscribeInputEventRequest unsubscribeInputEvent(long hash) throws IOException { return write(new UnsubscribeInputEventRequest(hash)); } + /** + * The SimConnect_AddFacilityDataDefinitionFilter function is used add a filter on a node in the + * FacilityDataDefinition to block sending data according to this filter, thus reduce the amount of data received + * and limit it to only that which is required. + * + * @param defineID Specifies the ID of the client defined data definition. + * @param filterPath Defines the node and member that you wish to apply the filter to. + * @param filterData Filter data as bytes (will be cast to the right type later). + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_AddFacilityDataDefinitionFilter.htm + */ public AddFacilityDataDefinitionFilterRequest addFacilityDataDefinitionFilter(int defineID, String filterPath, byte[] filterData) throws IOException { return write(new AddFacilityDataDefinitionFilterRequest(defineID, filterPath, filterData)); } + /** + * The SimConnect_ClearAllFacilityDataDefinitionFilters function is used to clear all applied facility definition + * filters. + * + * @param defineID Specifies the ID of the client defined data definition. + * @return The Object that represents the message that was sent to the simulator. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_ClearAllFacilityDataDefinitionFilters.htm + */ public ClearAllFacilityDataDefinitionFiltersRequest clearAllFacilityDataDefinitionFilters( int defineID) throws IOException { return write(new ClearAllFacilityDataDefinitionFiltersRequest(defineID)); } + /** + * Generates a continuously increasing user request id every time this method is called. Some function calls require + * a unique user request id so that the following responses can be clearly assigned to the respective request. + * Caution: This mechanism only works as long as all user request ids used were created using this method. + * When using self-made IDs, a collision cannot be ruled out. + * + * @return A new user request id for the usage in function calls which need such an id. + */ public static int getNextUserRequestID() { return lastUserRequestIdentifier.incrementAndGet(); } + /** + * Generates a continuously increasing user define id every time this method is called. Some function calls require + * a unique user define id so that all calls that deal with a coherent definition of data can can be recognized. + * Caution: This mechanism only works as long as all user define ids used were created using this method. + * When using self-made IDs, a collision cannot be ruled out. + * + * @return A new user define id for the usage in function calls which need such an id. + */ public static int getNextUserDefineID() { return lastUserDefineIdentifier.incrementAndGet(); } + /** + * Generates a continuously increasing user event id every time this method is called. Some function calls require + * a unique user event id so that the following responses can be clearly assigned to the respective event. + * Caution: This mechanism only works as long as all user event ids used were created using this method. + * When using self-made IDs, a collision cannot be ruled out. + * + * @return A new user event id for the usage in function calls which need such an id. + */ public static int getNextUserEventID() { return lastUserEventIdentifier.incrementAndGet(); } diff --git a/src/main/java/org/lembeck/fs/simconnect/SimUtil.java b/src/main/java/org/lembeck/fs/simconnect/SimUtil.java index e2b0b55..a439d9f 100644 --- a/src/main/java/org/lembeck/fs/simconnect/SimUtil.java +++ b/src/main/java/org/lembeck/fs/simconnect/SimUtil.java @@ -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(); + } } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/DataType.java b/src/main/java/org/lembeck/fs/simconnect/constants/DataType.java index 6fde926..7fbf2ff 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/DataType.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/DataType.java @@ -1,26 +1,108 @@ 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 https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_DATATYPE.htm + */ 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; @@ -28,6 +110,12 @@ public enum DataType { 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; @@ -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; } -} +} \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/ExceptionType.java b/src/main/java/org/lembeck/fs/simconnect/constants/ExceptionType.java index dbfa41d..330a5f0 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/ExceptionType.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/ExceptionType.java @@ -1,53 +1,266 @@ package org.lembeck.fs.simconnect.constants; +/** + * The SIMCONNECT_EXCEPTION enumeration type is used with the SIMCONNECT_RECV_EXCEPTION structure to return information + * on an error that has occurred. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_EXCEPTION.htm + */ public enum ExceptionType { + /** + * Specifies that there has not been an error. This value is not currently used. + */ SIMCONNECT_EXCEPTION_NONE, + + /** + * An unspecific error has occurred. This can be from incorrect flag settings, null or incorrect parameters, the + * need to have at least one up or down event with an input event, failed calls from the SimConnect server to the + * operating system, among other reasons. + */ SIMCONNECT_EXCEPTION_ERROR, + + /** + * Specifies the size of the data provided does not match the size required. This typically occurs when the wrong + * string length, fixed or variable, is involved. + */ SIMCONNECT_EXCEPTION_SIZE_MISMATCH, + + /** + * Specifies that the client event, request ID, data definition ID, or object ID was not recognized. + */ SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID, + + /** + * Specifies that communication with the SimConnect server has not been opened. This error is not currently used. + */ SIMCONNECT_EXCEPTION_UNOPENED, + + /** + * Specifies a versioning error has occurred. Typically this will occur when a client built on a newer version of + * the SimConnect client dll attempts to work with an older version of the SimConnect server. + */ SIMCONNECT_EXCEPTION_VERSION_MISMATCH, + + /** + * Specifies that the maximum number of groups allowed has been reached. The maximum is 20. + */ SIMCONNECT_EXCEPTION_TOO_MANY_GROUPS, + + /** + * Specifies that the simulation event name (such as "brakes") is not recognized. + */ SIMCONNECT_EXCEPTION_NAME_UNRECOGNIZED, + + /** + * Specifies that the maximum number of event names allowed has been reached. The maximum is 1000. + */ SIMCONNECT_EXCEPTION_TOO_MANY_EVENT_NAMES, + + /** + * Specifies that the event ID has been used already. This can occur with calls to + * SimConnect_MapClientEventToSimEvent, or SimConnect_SubscribeToSystemEvent. + */ SIMCONNECT_EXCEPTION_EVENT_ID_DUPLICATE, + + /** + * Specifies that the maximum number of mappings allowed has been reached. The maximum is 20. + */ SIMCONNECT_EXCEPTION_TOO_MANY_MAPS, + + /** + * Specifies that the maximum number of objects allowed has been reached. The maximum is 1000. + */ SIMCONNECT_EXCEPTION_TOO_MANY_OBJECTS, + + /** + * Specifies that the maximum number of requests allowed has been reached. The maximum is 1000. + */ SIMCONNECT_EXCEPTION_TOO_MANY_REQUESTS, + + /** + * Specifies an invalid port number was requested. + */ SIMCONNECT_EXCEPTION_WEATHER_INVALID_PORT, + + /** + * Specifies that the metar data supplied did not match the required format. + */ SIMCONNECT_EXCEPTION_WEATHER_INVALID_METAR, + + /** + * Specifies that the weather observation requested was not available. + */ SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_GET_OBSERVATION, + + /** + * Specifies that the weather station could not be created. + */ SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_CREATE_STATION, + + /** + * Specifies that the weather station could not be removed. + */ SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_REMOVE_STATION, + + /** + * Specifies that the data type requested does not apply to the type of data requested. Typically, this occurs with + * a fixed length string of the wrong length. + */ SIMCONNECT_EXCEPTION_INVALID_DATA_TYPE, + + /** + * Specifies that the size of the data provided is not what is expected. This can occur when the size of a structure + * provided does not match the size given, or a null string entry is made for a menu or sub-menu entry text, or data + * with a size of zero is added to a data definition. It can also occur with an invalid request to + * SimConnect_CreateClientData. + */ SIMCONNECT_EXCEPTION_INVALID_DATA_SIZE, + + /** + * Specifies a generic data error. This error is used by the SimConnect_WeatherCreateThermal function to report + * incorrect parameters, such as negative radii or values greater than the maximum allowed. It is also used by the + * SimConnect_FlightSave and SimConnect_FlightLoad functions to report incorrect file types. It is also used by + * other functions to report that flags or reserved parameters have not been set to zero. + */ SIMCONNECT_EXCEPTION_DATA_ERROR, + + /** + * Specifies an invalid array has been sent to the SimConnect_SetDataOnSimObject function. + */ SIMCONNECT_EXCEPTION_INVALID_ARRAY, + + /** + * Specifies that the attempt to create an AI object failed. + */ SIMCONNECT_EXCEPTION_CREATE_OBJECT_FAILED, + + /** + * Specifies that the specified flight plan could not be found, or did not load correctly. + */ SIMCONNECT_EXCEPTION_LOAD_FLIGHTPLAN_FAILED, + + /** + * Specifies that the operation requested does not apply to the object type, for example trying to set a flight plan + * on an object that is not an aircraft will result in this error. + */ SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE, + + /** + * Specifies that the AI operation requested cannot be completed, such as requesting that an object be removed when + * the client did not create that object. This error also applies to the Weather system. + */ SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION, + + /** + * Specifies that the client has already subscribed to that event. + */ SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED, + + /** + * Specifies that the member of the enumeration provided was not valid. Currently this is only used if an unknown + * type is provided to SimConnect_RequestDataOnSimObjectType. + */ SIMCONNECT_EXCEPTION_INVALID_ENUM, + + /** + * Specifies that there is a problem with a data definition. Currently this is only used if a variable length + * definition is sent with SimConnect_RequestDataOnSimObject. + */ SIMCONNECT_EXCEPTION_DEFINITION_ERROR, + + /** + * Specifies that the ID has already been used. This can occur with menu IDs, or with the IDs provided to + * SimConnect_AddToDataDefinition, SimConnect_AddClientEventToNotificationGroup or SimConnect_MapClientDataNameToID. + */ SIMCONNECT_EXCEPTION_DUPLICATE_ID, + + /** + * Specifies that the datum ID is not recognized. This currently occurs with a call to the + * SimConnect_SetDataOnSimObject function. + */ SIMCONNECT_EXCEPTION_DATUM_ID, + + /** + * Specifies that the radius given in the SimConnect_RequestDataOnSimObjectType was outside the acceptable range, + * or with an invalid request to SimConnect_CreateClientData. + */ SIMCONNECT_EXCEPTION_OUT_OF_BOUNDS, + + /** + * Specifies that a client data area with the name requested by a call to SimConnect_MapClientDataNameToID has + * already been created by another addon. Try again with a different name. + */ SIMCONNECT_EXCEPTION_ALREADY_CREATED, + + /** + * Specifies that an attempt to create an ATC controlled AI object failed because the location of the object is + * outside the reality bubble. + */ SIMCONNECT_EXCEPTION_OBJECT_OUTSIDE_REALITY_BUBBLE, + + /** + * Specifies that an attempt to create an AI object failed because of an error with the container system for the + * object. + */ SIMCONNECT_EXCEPTION_OBJECT_CONTAINER, + + /** + * Specifies that an attempt to create an AI object failed because of an error with the AI system for the object. + */ SIMCONNECT_EXCEPTION_OBJECT_AI, + + /** + * Specifies that an attempt to create an AI object failed because of an error with the ATC system for the object. + */ SIMCONNECT_EXCEPTION_OBJECT_ATC, + + /** + * Specifies that an attempt to create an AI object failed because of a scheduling problem. + */ SIMCONNECT_EXCEPTION_OBJECT_SCHEDULE, + + /** + * Specifies that an attempt to retrieve jetway data using SimConnect_RequestJetwayData has caused an exception. + */ SIMCONNECT_EXCEPTION_JETWAY_DATA, + + /** + * Specifies that the given action cannot be found when using the SimConnect_ExecuteAction function. + */ SIMCONNECT_EXCEPTION_ACTION_NOT_FOUND, + + /** + * Specifies that the given action does not exist when using the SimConnect_ExecuteAction function. + */ SIMCONNECT_EXCEPTION_NOT_AN_ACTION, + + /** + * Specifies that the wrong parameters have been given to the function SimConnect_ExecuteAction. + */ SIMCONNECT_EXCEPTION_INCORRECT_ACTION_PARAMS, + + /** + * This means that the wrong name/hash has been passed to the SimConnect_GetInputEvent function. + */ SIMCONNECT_EXCEPTION_GET_INPUT_EVENT_FAILED, + + /** + * This means that the wrong name/hash has been passed to the SimConnect_SetInputEvent function. + */ SIMCONNECT_EXCEPTION_SET_INPUT_EVENT_FAILED, + + /** + * Specifies an unknown exception type. + */ UNKNOWN; + /** + * Returns the exception type specified by the given identifier. + * + * @param id Identifier of the exception type. + * @return Exception type of the identifier. + */ public static ExceptionType ofId(int id) { return switch (id) { case 0 -> SIMCONNECT_EXCEPTION_NONE; diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/FacilityDataType.java b/src/main/java/org/lembeck/fs/simconnect/constants/FacilityDataType.java index 0aca719..ed647c4 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/FacilityDataType.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/FacilityDataType.java @@ -1,34 +1,154 @@ package org.lembeck.fs.simconnect.constants; +/** + * The SIMCONNECT_FACILITY_DATA_TYPE enumeration type is used within the SIMCONNECT_RECV_FACILITY_DATA return to give + * the type of data that is being received. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_FACILITY_DATA_TYPE.htm + */ public enum FacilityDataType { + + /** + * Contents of the parent struct are for an airport. See AIRPORT for more information. + */ AIRPORT, + + /** + * Contents of the parent struct are for a runway. See RUNWAY for more information. + */ RUNWAY, + + /** + * Contents of the parent struct are for defining an airport start position. See START for more information. + */ START, + + /** + * Contents of the parent struct are for frequencies. See FREQUENCY for more information. + */ FREQUENCY, + + /** + * Contents of the parent struct are for a helipad. See HELIPAD for more information. + */ HELIPAD, + + /** + * Contents of the parent struct are for an approach. See APPROACH for more information. + */ APPROACH, + + /** + * Contents of the parent struct are for an approach transition. See APPROACH_TRANSITION for more information. + */ APPROACH_TRANSITION, + + /** + * Contents of the parent struct are for an approach leg. See APPROACH_LEG for more information. + */ APPROACH_LEG, + + /** + * Contents of the parent struct are for a final approach leg. See FINAL_APPROACH_LEG for more information. + */ FINAL_APPROACH_LEG, + + /** + * Contents of the parent struct are for a missed approach leg. See MISSED_APPROACH_LEG for more information. + */ MISSED_APPROACH_LEG, + + /** + * Contents of the parent struct are for a departure. See DEPARTURE for more information. + */ DEPARTURE, + + /** + * Contents of the parent struct are for an arrival. See ARRIVAL for more information. + */ ARRIVAL, + + /** + * Contents of the parent struct are for a runway transition. See RUNWAY_TRANSITION for more information. + */ RUNWAY_TRANSITION, + + /** + * Contents of the parent struct are for a route transition. See ENROUTE_TRANSITION for more information. + */ ENROUTE_TRANSITION, + + /** + * Contents of the parent struct are for a taxiway point. See TAXI_POINT for more information. + */ TAXI_POINT, + + /** + * Contents of the parent struct are for a taxiway parking spot. See TAXI_PARKING for more information. + */ TAXI_PARKING, + + /** + * Contents of the parent struct are for a taxiway path. See TAXI_PATH for more information. + */ TAXI_PATH, + + /** + * Contents of the parent struct are for a taxi name. See TAXI_NAME for more information. + */ TAXI_NAME, + + /** + * Contents of the parent struct are for a jetway. See JETWAY for more information. + */ JETWAY, + + /** + * Contents of the parent struct are for a VOR station. See VOR for more information. + */ VOR, + + /** + * Contents of the parent struct are for an NDB station. See NDB for more information. + */ NDB, + + /** + * Contents of the parent struct are for a waypoint. See WAYPOINT for more information. + */ WAYPOINT, + + /** + * Contents of the parent struct are for a route. See ROUTE for more information. + */ ROUTE, + + /** + * Contents of the parent struct are for a pavement element. See PAVEMENT for more information. + */ PAVEMENT, + + /** + * Contents of the parent struct are for the runway approach lights. See APPROACHLIGHTS for more information. + */ APPROACH_LIGHTS, + + /** + * Contents of the parent struct are for VASI information. See VASI for more information. + */ VASI, + + /** + * Specifies an unknown facility data type (should not be used). + */ UNKNOWN; + /** + * Returns the facility data type specified by the given identifier. + * + * @param id Identifier of the facility data type. + * @return The facility data type specified by the given identifier. + */ public static FacilityDataType ofId(int id) { return switch (id) { case 0 -> AIRPORT; diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/FacilityListType.java b/src/main/java/org/lembeck/fs/simconnect/constants/FacilityListType.java index 77fe0db..2d65568 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/FacilityListType.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/FacilityListType.java @@ -1,13 +1,49 @@ package org.lembeck.fs.simconnect.constants; +/** + * The SIMCONNECT_FACILITY_LIST_TYPE enumeration type is used to determine which type of facilities data is being + * requested or returned. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_FACILITY_LIST_TYPE.htm + */ public enum FacilityListType { + + /** + * Specifies that the type of information is for an airport, see SIMCONNECT_DATA_FACILITY_AIRPORT. + */ AIRPORT, + + /** + * Specifies that the type of information is for a waypoint, see SIMCONNECT_DATA_FACILITY_WAYPOINT. + */ WAYPOINT, + + /** + * Specifies that the type of information is for an NDB, see SIMCONNECT_DATA_FACILITY_NDB. + */ NDB, + + /** + * Specifies that the type of information is for a VOR, see SIMCONNECT_DATA_FACILITY_VOR. + */ VOR, + + /** + * Not valid as a list type, but simply the number of list types. + */ COUNT, + + /** + * Specifies an unknown facility lit type (should not be used). + */ UNKNOWN; + /** + * Returns the facility list type by its identifier. + * + * @param id Identifier of the facility list type. + * @return Facility list type of the given identifier. + */ public static FacilityListType ofId(int id) { return switch (id) { case 0 -> AIRPORT; diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/InputEventType.java b/src/main/java/org/lembeck/fs/simconnect/constants/InputEventType.java index 252a132..4deef79 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/InputEventType.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/InputEventType.java @@ -1,10 +1,33 @@ package org.lembeck.fs.simconnect.constants; +/** + * Expected data types in the SIMCONNECT_INPUT_EVENT_DESCRIPTOR structure. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_INPUT_EVENT_DESCRIPTOR.htm + */ public enum InputEventType { + + /** + * Type double. + */ DOUBLE, + + /** + * Type String. + */ STRING, + + /** + * Unknown type (should not be used). + */ UNKNOWN; + /** + * Returns the type specified by its identifier. + * + * @param id Identifier of the type. + * @return The type specified by its identifier. + */ public static InputEventType ofId(int id) { return switch (id) { case 0 -> DOUBLE; diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/RunwayDesignator.java b/src/main/java/org/lembeck/fs/simconnect/constants/RunwayDesignator.java index 026a3f4..7a28224 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/RunwayDesignator.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/RunwayDesignator.java @@ -1,9 +1,61 @@ package org.lembeck.fs.simconnect.constants; +/** + * Enumeration of the possible runway designators. + */ public enum RunwayDesignator { - NONE, LEFT, RIGHT, CENTER, WATER, A, B, LAST, UNKNOWN; + /** + * Runway has no specific designator. + */ + NONE, + /** + * Left runway. + */ + LEFT, + + /** + * Right runway. + */ + RIGHT, + + /** + * Center runway. + */ + CENTER, + + /** + * Water runway. + */ + WATER, + + /** + * Runway A. + */ + A, + + /** + * Runway B. + */ + B, + + /** + * Last runway. + */ + LAST, + + /** + * Unknown runway designator. + */ + UNKNOWN; + + /** + * Returns the runway designator specified by the given identifier. + * + * @param id Identifier of the runway designator. + * @return The runway designator specified by the given identifier. + */ public static RunwayDesignator ofId(int id) { return switch (id) { case 0 -> NONE; @@ -18,6 +70,11 @@ public static RunwayDesignator ofId(int id) { }; } + /** + * Returns a short name of the runway designator. + * + * @return Short name of the designator (like 'L' for left...). + */ public String getShortName() { return switch (this) { case A -> "A"; @@ -31,4 +88,4 @@ public String getShortName() { case NONE -> ""; }; } -} +} \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/RunwaySurface.java b/src/main/java/org/lembeck/fs/simconnect/constants/RunwaySurface.java index cdc9146..1dd78f2 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/RunwaySurface.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/RunwaySurface.java @@ -1,42 +1,188 @@ package org.lembeck.fs.simconnect.constants; +/** + * The type of pavement used by the runway. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_AddToFacilityDefinition.htm + */ public enum RunwaySurface { + /** + * Specifies the runways surface to be concrete. + */ CONCRETE, + + /** + * Specifies the runways surface to be grass. + */ GRASS, + + /** + * Specifies the runways surface to be water. + */ WATER_FSX, + + /** + * Specifies the runways surface to be bumpy grass. + */ GRASS_BUMPY, + + /** + * Specifies the runways surface to be asphalt. + */ ASPHALT, + + /** + * Specifies the runways surface to be short grass. + */ SHORT_GRASS, + + /** + * Specifies the runways surface to be long grass. + */ LONG_GRASS, + + /** + * Specifies the runways surface to be hard turf. + */ HARD_TURF, + + /** + * Specifies the runways surface to be snow. + */ SNOW, + + /** + * Specifies the runways surface to be ice. + */ ICE, + + /** + * Specifies the runways surface to be urban. + */ URBAN, + + /** + * Specifies the runways surface to be forest. + */ FOREST, + + /** + * Specifies the runways surface to be dirt. + */ DIRT, + + /** + * Specifies the runways surface to be coral. + */ CORAL, + + /** + * Specifies the runways surface to be gravel. + */ GRAVEL, + + /** + * Specifies the runways surface to be oil treated. + */ OIL_TREATED, + + /** + * Specifies the runways surface to be steel mats. + */ STEEL_MATS, + + /** + * Specifies the runways surface to be bituminous. + */ BITUMINUS, + + /** + * Specifies the runways surface to be brick. + */ BRICK, + + /** + * Specifies the runways surface to be macadam. + */ MACADAM, + + /** + * Specifies the runways surface to be planks. + */ PLANKS, + + /** + * Specifies the runways surface to be sand. + */ SAND, + + /** + * Specifies the runways surface to be shale. + */ SHALE, + + /** + * Specifies the runways surface to be tarmac. + */ TARMAC, + + /** + * Specifies the runways surface to be wright flyer track. + */ WRIGHT_FLYER_TRACK, + + /** + * Specifies the runways surface to be an ocean. + */ OCEAN, + + /** + * Specifies the runways surface to be water. + */ WATER, + + /** + * Specifies the runways surface to be a pond. + */ POND, + + /** + * Specifies the runways surface to be a lake. + */ LAKE, + + /** + * Specifies the runways surface to be a river. + */ RIVER, + + /** + * Specifies the runways surface to be waste water. + */ WASTE_WATER, + + /** + * Specifies the runways surface to be paint. + */ PAINT, + + /** + * Specifies the runways surface to be unknown. + */ UNKNOWN, + + /** + * Specifies the runways surface to be undefined (should not be used). + */ UNDEFINED; + /** + * Returns the runway surface specified by the given identifier. + * + * @param id Identifier of the runway surface. + * @return The runway surface specified by the given identifier. + */ public static RunwaySurface ofId(int id) { return switch (id) { case 0 -> CONCRETE; @@ -76,4 +222,4 @@ public static RunwaySurface ofId(int id) { default -> UNDEFINED; }; } -} +} \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/SimObjectType.java b/src/main/java/org/lembeck/fs/simconnect/constants/SimObjectType.java index c265caa..22b45a3 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/SimObjectType.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/SimObjectType.java @@ -1,13 +1,46 @@ package org.lembeck.fs.simconnect.constants; +/** + * The SIMCONNECT_SIMOBJECT_TYPE enumeration type is used with the SimConnect_RequestDataOnSimObjectType call to request + * information on specific or nearby objects. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_SIMOBJECT_TYPE.htm + */ public enum SimObjectType { + /** + * Specifies the user's aircraft. + */ USER("User"), + + /** + * Specifies all AI controlled objects. + */ ALL("All"), + + /** + * Specifies all aircraft. + */ AIRCRAFT("Airplane"), + + /** + * Specifies all helicopters. + */ HELICOPTER("Helicopter"), + + /** + * Specifies all AI controlled boats. + */ BOAT("Boat"), + + /** + * Specifies all AI controlled ground vehicles. + */ GROUND("GroundVehicle"), + + /** + * Specifies an unknown sim object type (should not be used). + */ UNKNOWN("UNKNOWN"); private final String identifier; @@ -16,15 +49,27 @@ public enum SimObjectType { this.identifier = identifier; } + /** + * Returns the sim object type specified by its string identifier. + * + * @param identifier String identifier of the sim object type. + * @return The sim object type specified by its string identifier. + */ public static SimObjectType fromIdentifier(String identifier) { for (SimObjectType type : values()) { if (type.identifier.equalsIgnoreCase(identifier)) { return type; } } - throw new IllegalArgumentException("unkown simObjectTyp " + identifier); + return UNKNOWN; } + /** + * Returns the sim object type specified by its identifier. + * + * @param id Identifier of the sim object type. + * @return The sim object type specified by its identifier. + */ public static SimObjectType ofId(int id) { return switch (id) { case 0 -> USER; @@ -36,4 +81,4 @@ public static SimObjectType ofId(int id) { default -> UNKNOWN; }; } -} +} \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/SimconnectPeriod.java b/src/main/java/org/lembeck/fs/simconnect/constants/SimconnectPeriod.java index 9ec0d98..b0cba8e 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/SimconnectPeriod.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/SimconnectPeriod.java @@ -1,5 +1,9 @@ package org.lembeck.fs.simconnect.constants; +/** + * The SIMCONNECT_PERIOD enumeration type is used with the SimConnect_RequestDataOnSimObject call to specify how often + * data is to be sent to the client. + */ public enum SimconnectPeriod { @@ -29,8 +33,17 @@ public enum SimconnectPeriod { */ SECOND, + /** + * Specified an unknown period (should not be used). + */ UNKNOWN; + /** + * Returns the simconnect period specified by the given identifier. + * + * @param id The identifier of the period. + * @return Simconnect period specified by the given identifier. + */ public static SimconnectPeriod ofId(int id) { return switch (id) { case 0 -> NEVER; diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/State.java b/src/main/java/org/lembeck/fs/simconnect/constants/State.java index db3683c..820d29b 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/State.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/State.java @@ -1,13 +1,34 @@ package org.lembeck.fs.simconnect.constants; +/** + * The SIMCONNECT_STATE enumeration type is used with the SimConnect_SetSystemEventState call to turn the reporting of + * events on and off. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_STATE.htm + */ public enum State { + /** + * Specifies off. + */ OFF, + /** + * Specifies on. + */ ON, + /** + * Specifies an unknown state (should not be used). + */ UNKNOWN; + /** + * Returns the state specified by the given identifier. + * + * @param id The identifier of the state. + * @return State specified by the given identifier. + */ public static State ofId(int id) { return switch (id) { case 0 -> OFF; diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/SystemEventName.java b/src/main/java/org/lembeck/fs/simconnect/constants/SystemEventName.java index 603a35c..605497f 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/SystemEventName.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/SystemEventName.java @@ -1,37 +1,173 @@ package org.lembeck.fs.simconnect.constants; +/** + * Enumeration of the available system event names used by the SubscribeToSystemEvent request. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_SubscribeToSystemEvent.htm + */ public enum SystemEventName { /** * Request a notification every second. */ ONE_SEC("1sec"), + + /** + * Request a notification every four seconds. + */ FOUR_SEC("4sec"), + + /** + * Request notifications six times per second. This is the same rate that joystick movement events are transmitted. + */ SIX_HZ("6Hz"), + /** + * Request a notification when the aircraft flight dynamics file is changed. These files have a .AIR extension. + * The filename is returned in a SIMCONNECT_RECV_EVENT_FILENAME structure. + */ AIRCRAFR_LOADED("AircraftLoaded"), + + /** + * Request a notification if the user aircraft crashes. + */ CRASHED("Crashed"), + + /** + * Request a notification when the crash cut-scene has completed. + */ CRASH_RESET("CrashReset"), + + /** + * Request a notification when a mission action has been executed. + */ @Deprecated CUSTOM_MISSION_ACTION_EXECUTED("CustomMissionActionExecuted"), + + /** + * Request a notification when a flight is loaded. Note that when a flight is ended, a default flight is typically + * loaded, so these events will occur when flights and missions are started and finished. The filename of the flight + * loaded is returned in a SIMCONNECT_RECV_EVENT_FILENAME structure. + */ FLIGHT_LOADED("FlightLoaded"), + + /** + * Request a notification when a flight is saved correctly. The filename of the flight saved is returned in a + * SIMCONNECT_RECV_EVENT_FILENAME structure. + */ FLIGHT_SAVED("FlightSaved"), + + /** + * Request a notification when a new flight plan is activated. The filename of the activated flight plan is returned + * in a SIMCONNECT_RECV_EVENT_FILENAME structure. + */ FLIGHT_PLAN_ACTIVATED("FlightPlanActivated"), + + /** + * Request a notification when the active flight plan is de-activated. + */ FLIGHT_PLAN_DEACTIVATED("FlightPlanDeactivated"), + + /** + * Request notifications every visual frame. Information is returned in a SIMCONNECT_RECV_EVENT structure. + */ FRAME("Frame"), + + /** + * Request a notification when an AI object is added to the simulation. Refer also to the + * SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE structure. + */ OBJECT_ADDED("ObjectAdded"), + + /** + * Request a notification when an AI object is removed from the simulation. Refer also to the + * SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE structure. + */ OBJECT_REMOVED("ObjectRemoved"), + + /** + * Request notifications when the flight is paused or unpaused, and also immediately returns the current pause + * state (1 = paused or 0 = unpaused). The state is returned in the dwData parameter. + */ PAUSE("Pause"), + + /** + * Request notifications when the flight is paused or unpaused, and also immediately returns the current pause state + * with more detail than the regular Pause system event. The state is returned in the dwData parameter, and will be + * one of the following defines: + *
    + *
  • 0: No Pause
  • + *
  • 1: "full" Pause (sim + traffic + etc...)
  • + *
  • 2: FSX Legacy Pause (not used anymore)
  • + *
  • 4: Pause was activated using the "Active Pause" Button
  • + *
  • 8: Pause the player sim but traffic, multi, etc... will still run
  • + *
+ */ PAUSE_EX1("Pause_EX1"), + + /** + * Request a notification when the flight is paused. + */ PAUSED("Paused"), + + /** + * Request notifications for every visual frame that the simulation is paused. Information is returned in a + * SIMCONNECT_RECV_EVENT structure. + */ PAUSE_FRAME("PauseFrame"), + + /** + * Request a notification when the user changes the position of their aircraft through a dialog. + */ POSITION_CHANGED("PositionChanged"), + + /** + * Request notifications when the flight is running or not, and also immediately returns the current state + * (1 = running or 0 = not running). The state is returned in the dwData parameter. + */ SIM("Sim"), + + /** + * The simulator is running. Typically the user is actively controlling the aircraft on the ground or in the air. + * However, in some cases additional pairs of SimStart/SimStop events are sent. For example, when a flight is reset + * the events that are sent are SimStop, SimStart, SimStop, SimStart. Also when a flight is started with the + * SHOW_OPENING_SCREEN value set to zero, then an additional SimStart/SimStop pair are sent before a second SimStart + * event is sent when the scenery is fully loaded. The opening screen provides the options to change aircraft, + * departure airport, and so on. + */ SIM_START("SimStart"), + + /** + * The simulator is not running. Typically the user is loading a flight, navigating the shell or in a dialog. + */ SIM_STOP("SimStop"), + + /** + * Requests a notification when the master sound switch is changed. This request will also return the current state + * of the master sound switch immediately. A flag is returned in the dwData parameter, 0 if the switch is off, + * SIMCONNECT_SOUND_SYSTEM_EVENT_DATA_MASTER (0x1) if the switch is on. + */ SOUND("Sound"), + + /** + * Request a notification when the flight is un-paused. + */ UNPAUSED("Unpaused"), + + /** + * Requests a notification when the user aircraft view is changed. This request will also return the current view + * immediately. A flag is returned in the dwData parameter, one of: + *
    + *
  • SIMCONNECT_VIEW_SYSTEM_EVENT_DATA_COCKPIT_2D
  • + *
  • SIMCONNECT_VIEW_SYSTEM_EVENT_DATA_COCKPIT_VIRTUAL
  • + *
  • SIMCONNECT_VIEW_SYSTEM_EVENT_DATA_ORTHOGONAL (the map view).
  • + *
+ */ VIEW("View"), + + /** + * Request a notification when the weather mode is changed. + */ @Deprecated WEATHER_MODE_CHANGED("WeatherModeChanged"); @@ -41,7 +177,12 @@ public enum SystemEventName { this.eventName = eventName; } + /** + * Returns the name of the event. + * + * @return Name of the event. + */ public String getEventName() { return eventName; } -} +} \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/constants/VorType.java b/src/main/java/org/lembeck/fs/simconnect/constants/VorType.java index da5b00c..cdcb9df 100644 --- a/src/main/java/org/lembeck/fs/simconnect/constants/VorType.java +++ b/src/main/java/org/lembeck/fs/simconnect/constants/VorType.java @@ -1,16 +1,58 @@ package org.lembeck.fs.simconnect.constants; +/** + * The VOR type as used by the AddToFacilityDefinition method. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_AddToFacilityDefinition.htm + */ public enum VorType { + /** + * Specifies an unknown VOR type. + */ UNKNOWN, + + /** + * Specifies a terminal VOR type. + */ TERMINAL, + + /** + * Specifies a low altitude VOR type. + */ LOW_ALTITUDE, + + /** + * Specifies a low alt VOR type. + */ LOW_ALT, + + /** + * Specifies a high altitude VOR type. + */ HIGH_ALTITUDE, + + /** + * Specifies a high alt VOR type. + */ HIGH_ALT, + + /** + * Specifies an ILS VOR type. + */ ILS, + + /** + * Specifies a VOR test facility station. + */ VOT; + /** + * Returns the VOR type specified by its identifier. + * + * @param id Identifier of the VOR type. + * @return The VOR type specified by its identifier. + */ public static VorType ofId(int id) { return switch (id) { case 0 -> UNKNOWN; diff --git a/src/main/java/org/lembeck/fs/simconnect/examples/ReadAllFacilities.java b/src/main/java/org/lembeck/fs/simconnect/examples/ReadAllFacilities.java index c37bc7c..2424d93 100644 --- a/src/main/java/org/lembeck/fs/simconnect/examples/ReadAllFacilities.java +++ b/src/main/java/org/lembeck/fs/simconnect/examples/ReadAllFacilities.java @@ -11,9 +11,9 @@ public class ReadAllFacilities { - public String hostname = "localhost"; + private final String hostname = "localhost"; - public int port = 26010; + private final int port = 26010; private final SimConnect simConnect = new SimConnect(); @@ -26,7 +26,7 @@ public static void main(String[] args) throws IOException { new ReadAllFacilities().run(); } - public void run() throws IOException { + private void run() throws IOException { simConnect.getRequestReceiver().addAirportListHandler(this::handleAirports); simConnect.getRequestReceiver().addWaypointListHandler(this::handleWaypoints); simConnect.getRequestReceiver().addNdbListHandler(this::handleNDBs); @@ -43,7 +43,7 @@ public void run() throws IOException { simConnect.subscribeToFacilities(FacilityListType.VOR, 7); } - public void handleAirports(RecvAirportListResponse response) { + private void handleAirports(RecvAirportListResponse response) { Arrays.stream(response.getAirportList()).forEach(airports::add); if (response.getEntryNumber() == response.getOutOf() - 1) { System.out.println(airports.stream().map(FacilityAirport::getIcao).sorted().collect(Collectors.joining(", "))); diff --git a/src/main/java/org/lembeck/fs/simconnect/examples/SystemEvents.java b/src/main/java/org/lembeck/fs/simconnect/examples/SystemEvents.java index d178c1b..c25a2ed 100644 --- a/src/main/java/org/lembeck/fs/simconnect/examples/SystemEvents.java +++ b/src/main/java/org/lembeck/fs/simconnect/examples/SystemEvents.java @@ -8,11 +8,11 @@ public class SystemEvents { - public String hostname = "localhost"; + private final String hostname = "localhost"; - public int port = 26010; + private final int port = 26010; - int counter = 0; + private int counter = 0; private SimConnect simConnect; diff --git a/src/main/java/org/lembeck/fs/simconnect/examples/SystemState.java b/src/main/java/org/lembeck/fs/simconnect/examples/SystemState.java index af9ea35..b877367 100644 --- a/src/main/java/org/lembeck/fs/simconnect/examples/SystemState.java +++ b/src/main/java/org/lembeck/fs/simconnect/examples/SystemState.java @@ -6,9 +6,9 @@ public class SystemState { - public String hostname = "localhost"; + private final String hostname = "localhost"; - public int port = 26010; + private final int port = 26010; public static void main(String[] args) throws IOException { new SystemState().run(); diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/AirportListHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/AirportListHandler.java index a502e9c..02460a3 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/AirportListHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/AirportListHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvAirportListResponse; +/** + * Listener interface for RecvAirportListResponse responses. + */ @FunctionalInterface public interface AirportListHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void hanldeAirportList(RecvAirportListResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/AssignedObjectIdHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/AssignedObjectIdHandler.java index 1a275aa..9846043 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/AssignedObjectIdHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/AssignedObjectIdHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvAssignedObjectIdResponse; +/** + * Listener interface for RecvAssignedObjectIdResponse responses. + */ @FunctionalInterface public interface AssignedObjectIdHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param assignedObjectIdResponse The response object the listener ist supposed to handle. + */ void handleAssignedObjectId(RecvAssignedObjectIdResponse assignedObjectIdResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/ClientDataHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/ClientDataHandler.java index 77fe060..f68f6ca 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/ClientDataHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/ClientDataHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvClientDataResponse; +/** + * Listener interface for RecvClientDataResponse responses. + */ @FunctionalInterface public interface ClientDataHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param clientDataResponse The response object the listener ist supposed to handle. + */ void handleClientData(RecvClientDataResponse clientDataResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/ControllersListHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/ControllersListHandler.java index 1d05858..c372973 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/ControllersListHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/ControllersListHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvControllersListResponse; +/** + * Listener interface for RecvControllersListResponse responses. + */ @FunctionalInterface public interface ControllersListHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param controllersListResponse The response object the listener ist supposed to handle. + */ void handleControllersList(RecvControllersListResponse controllersListResponse); } diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EnumerateInputEventsHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EnumerateInputEventsHandler.java index 44578a0..ef433d8 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EnumerateInputEventsHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EnumerateInputEventsHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEnumerateInputEventsResponse; +/** + * Listener interface for RecvEnumerateInputEventsResponse responses. + */ @FunctionalInterface public interface EnumerateInputEventsHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param enumerateInputEventsResponse The response object the listener ist supposed to handle. + */ void handleEnumerateInputEvents(RecvEnumerateInputEventsResponse enumerateInputEventsResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventEx1Handler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventEx1Handler.java index b39426d..c8e5fc7 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventEx1Handler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventEx1Handler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEventEx1Response; +/** + * Listener interface for RecvEventEx1Response responses. + */ @FunctionalInterface public interface EventEx1Handler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param eventEx1Response The response object the listener ist supposed to handle. + */ void handleEventEx1(RecvEventEx1Response eventEx1Response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventFilenameHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventFilenameHandler.java index 90842c8..4329823 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventFilenameHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventFilenameHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEventFilenameResponse; +/** + * Listener interface for RecvEventFilenameResponse responses. + */ @FunctionalInterface public interface EventFilenameHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void handleEventFilename(RecvEventFilenameResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventFrameHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventFrameHandler.java index 283a6c4..c61c943 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventFrameHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventFrameHandler.java @@ -2,7 +2,16 @@ import org.lembeck.fs.simconnect.response.RecvEventFrameResponse; +/** + * Listener interface for RecvEventFrameResponse responses. + */ @FunctionalInterface public interface EventFrameHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param eventFrameResponse The response object the listener ist supposed to handle. + */ void handleEventFrame(RecvEventFrameResponse eventFrameResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventHandler.java index f262bfa..fd96ca8 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEventResponse; +/** + * Listener interface for RecvEventResponse responses. + */ @FunctionalInterface public interface EventHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void handleEvent(RecvEventResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerClientStartedHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerClientStartedHandler.java index bd00a68..2647835 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerClientStartedHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerClientStartedHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEventMultiplayerClientStartedResponse; +/** + * Listener interface for RecvEventMultiplayerClientStartedResponse responses. + */ @FunctionalInterface public interface EventMultiplayerClientStartedHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param multiplayerClientStartedResponse The response object the listener ist supposed to handle. + */ void handleEventMultiplayerClientStarted(RecvEventMultiplayerClientStartedResponse multiplayerClientStartedResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerServerStartedHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerServerStartedHandler.java index bdbc4b0..2b76de8 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerServerStartedHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerServerStartedHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEventMultiplayerServerStartedResponse; +/** + * Listener interface for RecvEventMultiplayerServerStartedResponse responses. + */ @FunctionalInterface public interface EventMultiplayerServerStartedHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param multiplayerServerStartedResponse The response object the listener ist supposed to handle. + */ void handleEventMultiplayerServerStarted(RecvEventMultiplayerServerStartedResponse multiplayerServerStartedResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerSessionEndedHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerSessionEndedHandler.java index a84a5cf..32daaee 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerSessionEndedHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventMultiplayerSessionEndedHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEventMultiplayerSessionEndedResponse; +/** + * Listener interface for RecvEventMultiplayerSessionEndedResponse responses. + */ @FunctionalInterface public interface EventMultiplayerSessionEndedHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param multiplayerSessionEndedResponse The response object the listener ist supposed to handle. + */ void handleEventMultiplayerSessionEnded(RecvEventMultiplayerSessionEndedResponse multiplayerSessionEndedResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/EventObjectAddRemoveHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/EventObjectAddRemoveHandler.java index cdf02d7..e3f4fd4 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/EventObjectAddRemoveHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/EventObjectAddRemoveHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvEventObjectAddRemoveResponse; +/** + * Listener interface for RecvEventObjectAddRemoveResponse responses. + */ @FunctionalInterface public interface EventObjectAddRemoveHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param objectAddRemoveResponse The response object the listener ist supposed to handle. + */ void handleEventObjectAddRemove(RecvEventObjectAddRemoveResponse objectAddRemoveResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/ExceptionHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/ExceptionHandler.java index 46870b1..1b6e6aa 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/ExceptionHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/ExceptionHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvExceptionResponse; +/** + * Listener interface for RecvExceptionResponse responses. + */ @FunctionalInterface public interface ExceptionHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void handleException(RecvExceptionResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataEndHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataEndHandler.java index 2f6ee28..bcd5981 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataEndHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataEndHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvFacilityDataEndResponse; +/** + * Listener interface for RecvFacilityDataEndResponse responses. + */ @FunctionalInterface public interface FacilityDataEndHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param facilityDataEndResponse The response object the listener ist supposed to handle. + */ void handleFacilityDataEnd(RecvFacilityDataEndResponse facilityDataEndResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataHandler.java index fd792ce..c7ac950 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/FacilityDataHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvFacilityDataResponse; +/** + * Listener interface for RecvFacilityDataResponse responses. + */ @FunctionalInterface public interface FacilityDataHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param facilityDataResponse The response object the listener ist supposed to handle. + */ void handleFacilityData(RecvFacilityDataResponse facilityDataResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/JetwayDataHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/JetwayDataHandler.java index cd4468e..6e9beb4 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/JetwayDataHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/JetwayDataHandler.java @@ -2,9 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvJetwayDataResponse; +/** + * Listener interface for RecvJetwayDataResponse responses. + */ @FunctionalInterface - public interface JetwayDataHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param jetwayDataResponse The response object the listener ist supposed to handle. + */ void handleJetwayData(RecvJetwayDataResponse jetwayDataResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/NdbListHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/NdbListHandler.java index bd1c1cc..12057bf 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/NdbListHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/NdbListHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvNdbListResponse; +/** + * Listener interface for RecvNdbListResponse responses. + */ @FunctionalInterface public interface NdbListHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void hanldeNdbList(RecvNdbListResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/OpenHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/OpenHandler.java index 529681f..f06041b 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/OpenHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/OpenHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvOpenResponse; +/** + * Listener interface for RecvOpenResponse responses. + */ @FunctionalInterface public interface OpenHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param openResponse The response object the listener ist supposed to handle. + */ void handleOpen(RecvOpenResponse openResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/QuitHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/QuitHandler.java index 7a2accd..247ba4a 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/QuitHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/QuitHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvQuitResponse; +/** + * Listener interface for RecvQuitResponse responses. + */ @FunctionalInterface public interface QuitHandler { - void handleQuit(RecvQuitResponse quitRsponse); + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param quitResponse The response object the listener ist supposed to handle. + */ + void handleQuit(RecvQuitResponse quitResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/ReservedKeyHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/ReservedKeyHandler.java index bd174b3..5fcbe03 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/ReservedKeyHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/ReservedKeyHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvReservedKeyResponse; +/** + * Listener interface for RecvReservedKeyResponse responses. + */ @FunctionalInterface public interface ReservedKeyHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param reservedKeyResponse The response object the listener ist supposed to handle. + */ void handleReservedKey(RecvReservedKeyResponse reservedKeyResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/ResponseHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/ResponseHandler.java index c0b4089..a939796 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/ResponseHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/ResponseHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.SimResponse; +/** + * Listener interface for SimResponse responses. + */ @FunctionalInterface public interface ResponseHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void handleResponse(SimResponse response); } diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataByTypeHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataByTypeHandler.java index 0e61913..30374c0 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataByTypeHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataByTypeHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvSimobjectDataByTypeResponse; +/** + * Listener interface for RecvSimobjectDataByTypeResponse responses. + */ @FunctionalInterface public interface SimobjectDataByTypeHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param simobjectDataByTypeResponse The response object the listener ist supposed to handle. + */ void handleSimobjectDataByType(RecvSimobjectDataByTypeResponse simobjectDataByTypeResponse); } diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataHandler.java index 6ff0fba..a7d90d0 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/SimobjectDataHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvSimobjectDataResponse; +/** + * Listener interface for RecvSimobjectDataResponse responses. + */ @FunctionalInterface public interface SimobjectDataHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param simobjectDataResponse The response object the listener ist supposed to handle. + */ void handleSimobjectData(RecvSimobjectDataResponse simobjectDataResponse); } diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/SystemStateHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/SystemStateHandler.java index 0ec1dec..002d06a 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/SystemStateHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/SystemStateHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvSystemStateResponse; +/** + * Listener interface for RecvSystemStateResponse responses. + */ @FunctionalInterface public interface SystemStateHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param recvSystemStateResponse The response object the listener ist supposed to handle. + */ void handleSystemState(RecvSystemStateResponse recvSystemStateResponse); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/UnknownResponseHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/UnknownResponseHandler.java index c2840ad..a219e16 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/UnknownResponseHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/UnknownResponseHandler.java @@ -2,6 +2,17 @@ import org.lembeck.fs.simconnect.response.UnknownResponse; +/** + * Listener interface for UnknownResponse responses. + */ +@FunctionalInterface public interface UnknownResponseHandler { + + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void handleUnknonwResponse(UnknownResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/VorListHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/VorListHandler.java index d8c2d13..89f4546 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/VorListHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/VorListHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvVorListResponse; +/** + * Listener interface for RecvVorListResponse responses. + */ @FunctionalInterface public interface VorListHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void hanldeVorList(RecvVorListResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/handler/WaypointListHandler.java b/src/main/java/org/lembeck/fs/simconnect/handler/WaypointListHandler.java index 178768b..9e8727c 100644 --- a/src/main/java/org/lembeck/fs/simconnect/handler/WaypointListHandler.java +++ b/src/main/java/org/lembeck/fs/simconnect/handler/WaypointListHandler.java @@ -2,8 +2,17 @@ import org.lembeck.fs.simconnect.response.RecvWaypointListResponse; +/** + * Listener interface for RecvWaypointListResponse responses. + */ @FunctionalInterface public interface WaypointListHandler { + /** + * Defines the method, wich the response receiver should give the specific response to when the listener will be + * registered to it. + * + * @param response The response object the listener ist supposed to handle. + */ void hanldeWaypointList(RecvWaypointListResponse response); } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/proxy/ChannelConnector.java b/src/main/java/org/lembeck/fs/simconnect/proxy/ChannelConnector.java index c29dcfc..3f93172 100644 --- a/src/main/java/org/lembeck/fs/simconnect/proxy/ChannelConnector.java +++ b/src/main/java/org/lembeck/fs/simconnect/proxy/ChannelConnector.java @@ -2,7 +2,6 @@ import org.lembeck.fs.simconnect.request.SimRequest; import org.lembeck.fs.simconnect.response.SimResponse; - import java.io.IOException; import java.io.PrintStream; import java.nio.ByteBuffer; @@ -40,7 +39,7 @@ public static void create(String name, SocketChannel sourceChannel, SocketChanne @Override public void run() { - ByteBuffer buffer = ByteBuffer.allocate(64 * 1024); + final ByteBuffer buffer = ByteBuffer.allocate(64 * 1024); buffer.order(ByteOrder.LITTLE_ENDIAN); int bytesRead = 0; try { @@ -57,7 +56,7 @@ public void run() { if (bytesRead != 4) { throw new RuntimeException("Die Länge des Pakets konnte nicht gelesen werden: " + bytesRead); } - int size = buffer.getInt(0); + final int size = buffer.getInt(0); buffer.position(4); buffer.limit(size); while (bytesRead < size) { @@ -72,7 +71,7 @@ public void run() { debugStream.println(request); } } else { - SimResponse response = SimResponse.parseResponse(size, buffer); + SimResponse response = SimResponse.parseResponse(buffer); synchronized (debugStream) { debugStream.println(response); } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/AddClientEventToNotificationGroupRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/AddClientEventToNotificationGroupRequest.java index 7095f67..36f12f1 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/AddClientEventToNotificationGroupRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/AddClientEventToNotificationGroupRequest.java @@ -2,6 +2,12 @@ import java.nio.ByteBuffer; +/** + * The SimConnect_AddClientEventToNotificationGroup function is used to add an individual client defined event to a + * notification group. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_AddClientEventToNotificationGroup.htm + */ public class AddClientEventToNotificationGroupRequest extends SimRequest { /** @@ -10,7 +16,9 @@ public class AddClientEventToNotificationGroupRequest extends SimRequest { public static final int TYPE_ID = 0xf0000007; private final int notificationGroupID; + private final int clientEventID; + private final boolean maskable; AddClientEventToNotificationGroupRequest(ByteBuffer buffer) { @@ -20,6 +28,19 @@ public class AddClientEventToNotificationGroupRequest extends SimRequest { maskable = buffer.getInt() != 0; } + /** + * The SimConnect_AddClientEventToNotificationGroup function is used to add an individual client defined event to a + * notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group. + * @param clientEventID Specifies the ID of the client defined event. + * @param maskable True indicates that the event will be masked by this client and will not be + * transmitted to any more clients, possibly including Microsoft Flight Simulator itself + * (if the priority of the client exceeds that of Flight Simulator). + * False is the default. See the explanation of SimConnect Priorities. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#simconnect-priorities + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_AddClientEventToNotificationGroup.htm + */ public AddClientEventToNotificationGroupRequest(int notificationGroupID, int clientEventID, boolean maskable) { super(TYPE_ID); this.notificationGroupID = notificationGroupID; @@ -35,14 +56,31 @@ protected void writeRequest(ByteBuffer outBuffer) { } + /** + * Returns the ID of the client defined group. + * + * @return ID of the client defined group. + */ public int getNotificationGroupID() { return notificationGroupID; } + /** + * Returns the ID of the client defined event. + * + * @return ID of the client defined event. + */ public int getClientEventID() { return clientEventID; } + /** + * Returns whether the event will be masked by this client. + * + * @return True indicates that the event will be masked by this client and will not be transmitted to any more + * clients, possibly including Microsoft Flight Simulator itself (if the priority of the client exceeds that of + * Flight Simulator). False is the default. See the explanation of SimConnect Priorities. + */ public boolean isMaskable() { return maskable; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/AddFacilityDataDefinitionFilterRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/AddFacilityDataDefinitionFilterRequest.java index f11270a..43fbf7d 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/AddFacilityDataDefinitionFilterRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/AddFacilityDataDefinitionFilterRequest.java @@ -4,6 +4,13 @@ import java.nio.ByteBuffer; import java.util.Arrays; +/** + * The SimConnect_AddFacilityDataDefinitionFilter function is used add a filter on a node in the + * FacilityDataDefinition to block sending data according to this filter, thus reduce the amount of data received + * and limit it to only that which is required. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_AddFacilityDataDefinitionFilter.htm + */ public class AddFacilityDataDefinitionFilterRequest extends SimRequest { /** @@ -26,6 +33,16 @@ public class AddFacilityDataDefinitionFilterRequest extends SimRequest { buffer.get(filterData); } + /** + * The SimConnect_AddFacilityDataDefinitionFilter function is used add a filter on a node in the + * FacilityDataDefinition to block sending data according to this filter, thus reduce the amount of data received + * and limit it to only that which is required. + * + * @param defineID Specifies the ID of the client defined data definition. + * @param filterPath Defines the node and member that you wish to apply the filter to. + * @param filterData Filter data as bytes (will be cast to the right type later). + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_AddFacilityDataDefinitionFilter.htm + */ public AddFacilityDataDefinitionFilterRequest(int defineID, String filterPath, byte[] filterData) { super(TYPE_ID); this.defineID = defineID; @@ -41,14 +58,29 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.put(filterData); } + /** + * Returns the ID of the client defined data definition. + * + * @return ID of the client defined data definition. + */ public int getDefineID() { return defineID; } + /** + * Returns the node and member that you wish to apply the filter to. + * + * @return Node and member that you wish to apply the filter to. + */ public String getFilterPath() { return filterPath; } + /** + * Returns the filter data as bytes (will be cast to the right type later). + * + * @return Filter data as bytes (will be cast to the right type later). + */ public byte[] getFilterData() { return filterData; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/ClearAllFacilityDataDefinitionFiltersRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/ClearAllFacilityDataDefinitionFiltersRequest.java index 42d17b9..9c893a9 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/ClearAllFacilityDataDefinitionFiltersRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/ClearAllFacilityDataDefinitionFiltersRequest.java @@ -2,6 +2,11 @@ import java.nio.ByteBuffer; +/** + * The SimConnect_ClearAllFacilityDataDefinitionFilters function is used to clear all applied facility definition filters. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_ClearAllFacilityDataDefinitionFilters.htm + */ public class ClearAllFacilityDataDefinitionFiltersRequest extends SimRequest { /** @@ -16,6 +21,12 @@ public class ClearAllFacilityDataDefinitionFiltersRequest extends SimRequest { defineID = buffer.getInt(); } + /** + * The SimConnect_ClearAllFacilityDataDefinitionFilters function is used to clear all applied facility definition filters. + * + * @param defineID Specifies the ID of the client defined data definition. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_ClearAllFacilityDataDefinitionFilters.htm + */ public ClearAllFacilityDataDefinitionFiltersRequest(int defineID) { super(TYPE_ID); this.defineID = defineID; @@ -26,6 +37,11 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(defineID); } + /** + * Returns the ID of the client defined data definition. + * + * @return ID of the client defined data definition. + */ public int getDefineID() { return defineID; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/ClearNotificationGroupRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/ClearNotificationGroupRequest.java index 76ca0fd..4e3957c 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/ClearNotificationGroupRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/ClearNotificationGroupRequest.java @@ -2,6 +2,11 @@ import java.nio.ByteBuffer; +/** + * The SimConnect_ClearNotificationGroup function is used to remove all the client defined events from a notification group. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_ClearNotificationGroup.htm + */ public class ClearNotificationGroupRequest extends SimRequest { /** @@ -16,6 +21,12 @@ public class ClearNotificationGroupRequest extends SimRequest { notificationGroupID = buffer.getInt(); } + /** + * The SimConnect_ClearNotificationGroup function is used to remove all the client defined events from a notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group that is to have all its events removed. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_ClearNotificationGroup.htm + */ public ClearNotificationGroupRequest(int notificationGroupID) { super(TYPE_ID); this.notificationGroupID = notificationGroupID; @@ -26,6 +37,11 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(notificationGroupID); } + /** + * Returns the ID of the client defined group that is to have all its events removed. + * + * @return ID of the client defined group that is to have all its events removed. + */ public int getNotificationGroupID() { return notificationGroupID; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/MapClientEventToSimEventRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/MapClientEventToSimEventRequest.java index 161d31a..c947e51 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/MapClientEventToSimEventRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/MapClientEventToSimEventRequest.java @@ -3,6 +3,11 @@ import org.lembeck.fs.simconnect.SimUtil; import java.nio.ByteBuffer; +/** + * The SimConnect_MapClientEventToSimEvent function associates a client defined event ID with a Microsoft Flight Simulator event name. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_MapClientEventToSimEvent.htm + */ public class MapClientEventToSimEventRequest extends SimRequest { /** @@ -19,6 +24,22 @@ public class MapClientEventToSimEventRequest extends SimRequest { eventName = SimUtil.readString(buffer, 256); } + /** + * Creates a new request instance. + * + * @param eventID Specifies the ID of the client event. + * @param eventName Specifies the Microsoft Flight Simulator event name. Refer to the Event IDs document for a list + * of event names (listed under String Name). If the event name includes one or more periods (such + * as "Custom.Event" in the example below) then they are custom events specified by the client, and + * will only be recognized by another client (and not Microsoft Flight Simulator) that has been + * coded to receive such events. No Microsoft Flight Simulator events include periods. If no entry + * is made for this parameter, the event is private to the client. + * Alternatively enter a decimal number in the format "#nnnn" or a hex number in the format + * "#0xnnnn", where these numbers are in the range THIRD_PARTY_EVENT_ID_MIN and + * THIRD_PARTY_EVENT_ID_MAX, in order to receive events from third-party add-ons to Flight + * Simulator X. + * @see https://docs.flightsimulator.com/html/Programming_Tools/Event_IDs/Event_IDs.htm + */ public MapClientEventToSimEventRequest(int eventID, String eventName) { super(TYPE_ID); this.eventID = eventID; @@ -31,10 +52,19 @@ protected void writeRequest(ByteBuffer outBuffer) { SimUtil.writeString(outBuffer, eventName, 256); } + /** + * Returns the ID of the client event. + * @return ID of the client event. + */ public int getEventID() { return eventID; } + /** + * Returns the event name. + * @return The event name. + * @see https://docs.flightsimulator.com/html/Programming_Tools/Event_IDs/Event_IDs.htm + */ public String getEventName() { return eventName; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/Priority.java b/src/main/java/org/lembeck/fs/simconnect/request/Priority.java index 50a7bf3..c27dcb3 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/Priority.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/Priority.java @@ -51,4 +51,14 @@ public Priority(int priorityValue) { public int getPriorityValue() { return priorityValue; } + + /** + * Returns a string representation of the object. + * + * @return A string representation of the object. + */ + @Override + public String toString() { + return Integer.toString(priorityValue); + } } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/request/RemoveClientEventRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/RemoveClientEventRequest.java index 8f63b95..0c57f9a 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/RemoveClientEventRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/RemoveClientEventRequest.java @@ -2,6 +2,11 @@ import java.nio.ByteBuffer; +/** + * The SimConnect_RemoveClientEvent function is used to remove a client defined event from a notification group. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_RemoveClientEvent.htm + */ public class RemoveClientEventRequest extends SimRequest { /** @@ -19,6 +24,13 @@ public class RemoveClientEventRequest extends SimRequest { clientEventID = buffer.getInt(); } + /** + * The SimConnect_RemoveClientEvent function is used to remove a client defined event from a notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group. + * @param clientEventID Specifies the ID of the client defined event ID that is to be removed from the group. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_RemoveClientEvent.htm + */ public RemoveClientEventRequest(int notificationGroupID, int clientEventID) { super(TYPE_ID); this.notificationGroupID = notificationGroupID; @@ -31,10 +43,19 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(clientEventID); } + /** + * Returns the ID of the client defined group. + * + * @return ID of the client defined group. + */ public int getNotificationGroupID() { return notificationGroupID; } + /** + * Returns the ID of the client defined event ID that is to be removed from the group. + * @return ID of the client defined event ID that is to be removed from the group. + */ public int getClientEventID() { return clientEventID; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/RequestFacilitesListRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/RequestFacilitesListRequest.java index 68f265b..e55c768 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/RequestFacilitesListRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/RequestFacilitesListRequest.java @@ -3,6 +3,12 @@ import org.lembeck.fs.simconnect.constants.FacilityListType; import java.nio.ByteBuffer; +/** + * The SimConnect_RequestFacilitesList function is used to request a list of all the facilities of a given type + * currently in the world, or within a radius of the aircraft depending on the requested type. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_RequestFacilitesList.htm + */ public class RequestFacilitesListRequest extends SimRequest { /** @@ -19,6 +25,14 @@ public class RequestFacilitesListRequest extends SimRequest { dataRequestId = buffer.getInt(); } + /** + * The SimConnect_RequestFacilitesList function is used to request a list of all the facilities of a given type + * currently in the world, or within a radius of the aircraft depending on the requested type. + * + * @param facilityListType Specifies one member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + * @param requestId Specifies the client defined request ID. This will be returned along with the data. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_RequestFacilitesList.htm + */ public RequestFacilitesListRequest(FacilityListType facilityListType, int requestId) { super(TYPE_ID); this.dataRequestId = requestId; @@ -31,10 +45,19 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(dataRequestId); } + /** + * Returns one member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + * + * @return Member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + */ public FacilityListType getFacilityListType() { return facilityListType; } + /** + * Returns the client defined request ID. + * @return The client defined request ID. + */ public int getDataRequestId() { return dataRequestId; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/SetDataOnSimObjectRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/SetDataOnSimObjectRequest.java index 9097eed..090bde0 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/SetDataOnSimObjectRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/SetDataOnSimObjectRequest.java @@ -1,7 +1,7 @@ package org.lembeck.fs.simconnect.request; +import org.lembeck.fs.simconnect.SimUtil; import org.lembeck.fs.simconnect.constants.DataSetFlag; -import org.lembeck.fs.simconnect.response.SimResponse; import java.nio.ByteBuffer; import static org.lembeck.fs.simconnect.constants.DataSetFlag.NOT_TAGGED; @@ -94,7 +94,7 @@ public String toString() { ", dataSetFlag=" + dataSetFlag + ", arrayCount=" + arrayCount + ", unitSize=" + unitSize + - ", data=" + SimResponse.toString(data) + + ", data=" + SimUtil.byteArrayToString(data) + "}"; } } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/request/SetNotificationGroupPriorityRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/SetNotificationGroupPriorityRequest.java index 77ec94a..ec9585e 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/SetNotificationGroupPriorityRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/SetNotificationGroupPriorityRequest.java @@ -2,6 +2,11 @@ import java.nio.ByteBuffer; +/** + * The SimConnect_SetNotificationGroupPriority function is used to set the priority for a notification group. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/General/SimConnect_SetNotificationGroupPriority.htm + */ public class SetNotificationGroupPriorityRequest extends SimRequest { /** @@ -10,15 +15,22 @@ public class SetNotificationGroupPriorityRequest extends SimRequest { public static int TYPE_ID = 0xf0000009; private final int notificationGroupID; - private final int priority; + private final Priority priority; SetNotificationGroupPriorityRequest(ByteBuffer buffer) { super(buffer); notificationGroupID = buffer.getInt(); - priority = buffer.getInt(); + priority = new Priority(buffer.getInt()); } - public SetNotificationGroupPriorityRequest(int notificationGroupID, int priority) { + /** + * The SimConnect_SetNotificationGroupPriority function is used to set the priority for a notification group. + * + * @param notificationGroupID Specifies the ID of the client defined group. + * @param priority The group's priority. See the explanation of SimConnect Priorities. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/General/SimConnect_SetNotificationGroupPriority.htm + */ + public SetNotificationGroupPriorityRequest(int notificationGroupID, Priority priority) { super(TYPE_ID); this.notificationGroupID = notificationGroupID; this.priority = priority; @@ -27,14 +39,24 @@ public SetNotificationGroupPriorityRequest(int notificationGroupID, int priority @Override protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(notificationGroupID); - outBuffer.putInt(priority); + outBuffer.putInt(priority.getPriorityValue()); } + /** + * Returns the ID of the client defined group. + * + * @return ID of the client defined group. + */ public int getNotificationGroupID() { return notificationGroupID; } - public int getPriority() { + /** + * Returns the group's priority. See the explanation of SimConnect Priorities. + * + * @return Group's priority. See the explanation of SimConnect Priorities. + */ + public Priority getPriority() { return priority; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/SetSystemEventStateRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/SetSystemEventStateRequest.java index b19e546..142e3ab 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/SetSystemEventStateRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/SetSystemEventStateRequest.java @@ -3,6 +3,12 @@ import org.lembeck.fs.simconnect.constants.State; import java.nio.ByteBuffer; +/** + * The SimConnect_SetSystemEventState function is used to turn requests for event information from the server on and + * off. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_SetSystemEventState.htm + */ public class SetSystemEventStateRequest extends SimRequest { /** @@ -18,6 +24,14 @@ public class SetSystemEventStateRequest extends SimRequest { state = State.ofId(buffer.getInt()); } + /** + * The SimConnect_SetSystemEventState function is used to turn requests for event information from the server on and + * off. + * + * @param clientEventID Specifies the ID of the client event that is to have its state changed. + * @param state Double word containing the state (one member of SIMCONNECT_STATE). + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_SetSystemEventState.htm + */ public SetSystemEventStateRequest(int clientEventID, State state) { super(TYPE_ID); this.clientEventID = clientEventID; @@ -30,10 +44,20 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(state.ordinal()); } + /** + * Returns the ID of the client event that is to have its state changed. + * + * @return ID of the client event that is to have its state changed. + */ public int getClientEventID() { return clientEventID; } + /** + * Returns the double word containing the state (one member of SIMCONNECT_STATE). + * + * @return Double word containing the state (one member of SIMCONNECT_STATE). + */ public State getState() { return state; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventEx1Request.java b/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventEx1Request.java index 6eec861..1e72aad 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventEx1Request.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventEx1Request.java @@ -1,7 +1,18 @@ package org.lembeck.fs.simconnect.request; +import org.lembeck.fs.simconnect.constants.EventFlag; import java.nio.ByteBuffer; +/** + * The SimConnect_TransmitClientEvent_EX1 function is used to request that the Microsoft Flight Simulator server + * transmit to all SimConnect clients the specified client event. This function is specifically designed to permit + * the sending of multiple parameters for the key event (up to five), unlike the SimConnect_TransmitClientEvent + * which only permits one. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_TransmitClientEvent_EX1.htm + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#simconnect-priorities + * @see https://docs.flightsimulator.com/html/Programming_Tools/Event_IDs/Event_IDs.htm + */ public class TransmitClientEventEx1Request extends SimRequest { /** @@ -32,7 +43,48 @@ public class TransmitClientEventEx1Request extends SimRequest { data4 = buffer.getInt(); } - public TransmitClientEventEx1Request(int objectID, int eventID, Priority priority, int eventFlag, int data0, int data1, int data2, int data3, int data4) { + /** + * The SimConnect_TransmitClientEvent_EX1 function is used to request that the Microsoft Flight Simulator server + * transmit to all SimConnect clients the specified client event. This function is specifically designed to permit + * the sending of multiple parameters for the key event (up to five), unlike the SimConnect_TransmitClientEvent + * which only permits one. + * + * @param objectID Specifies the ID of the server defined object. If this parameter is set to + * SIMCONNECT_OBJECT_ID_USER, then the transmitted event will be sent to the other clients in + * priority order. If this parameters contains another object ID, then the event will be sent + * direct to that sim-object, and no other clients will receive it. + * @param eventID Specifies the ID of the client event. + * @param priority This specifies the priority to send the message to all clients with this priority. To receive + * the event notification other SimConnect clients must have subscribed to receive the event. See + * the explanation of SimConnect Priorities. The exception to the default behavior is set by the + * SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY flag, described below. + * @param eventFlag One or more of the flags shown in {@link EventFlag}. + * @param data0 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data1 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data2 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data3 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @param data4 Double word containing an additional number required by the event. If the event is a Microsoft + * Flight Simulator event, then refer to the Event IDs document for information on this additional + * value(s). If the event is a custom event, then any values put in these parameters will be + * available to the clients that receive the event. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_TransmitClientEvent_EX1.htm + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#simconnect-priorities + * @see https://docs.flightsimulator.com/html/Programming_Tools/Event_IDs/Event_IDs.htm + */ + public TransmitClientEventEx1Request(int objectID, int eventID, Priority priority, int eventFlag, int data0, + int data1, int data2, int data3, int data4) { super(TYPE_ID); this.objectID = objectID; this.eventID = eventID; @@ -58,38 +110,87 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(data4); } + /** + * Returns the server defined object id of this event. + * + * @return The ID of the server defined object. If this parameter is set to SIMCONNECT_OBJECT_ID_USER, then the + * transmitted event will be sent to the other clients in priority order. If this parameters contains another object + * ID, then the event will be sent direct to that sim-object, and no other clients will receive it. + */ public int getObjectID() { return objectID; } + /** + * Returns the ID of the client event. + * + * @return ID of the client event. + */ public int getEventID() { return eventID; } + /** + * Returns the priority of this event. + * + * @return Priority of this event. + * @see Priority + */ public Priority getPriority() { return priority; } + /** + * Returns the flags that were defined for this event. + * + * @return Flags that were defined for this event. + * @see EventFlag + */ public int getEventFlag() { return eventFlag; } + /** + * Returns the first number required by this event. + * + * @return The first number required by this event. + */ public int getData0() { return data0; } + /** + * Returns the second number required by this event. + * + * @return The second number required by this event. + */ public int getData1() { return data1; } + /** + * Returns the third number required by this event. + * + * @return The third number required by this event. + */ public int getData2() { return data2; } + /** + * Returns the fourth number required by this event. + * + * @return The fourth number required by this event. + */ public int getData3() { return data3; } + /** + * Returns the fifth number required by this event. + * + * @return The fifth number required by this event. + */ public int getData4() { return data4; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventRequest.java index 42c534c..c944844 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/TransmitClientEventRequest.java @@ -1,19 +1,29 @@ package org.lembeck.fs.simconnect.request; +import org.lembeck.fs.simconnect.constants.EventFlag; import java.nio.ByteBuffer; +/** + * The SimConnect_TransmitClientEvent function is used to request that the Microsoft Flight Simulator server transmit to all SimConnect clients the specified client event. + */ public class TransmitClientEventRequest extends SimRequest { /** * Internally used ID of this simconnect request. */ public static final int TYPE_ID = 0xf0000005; + private final int objectID; + private final int clientEventID; + private final int data; + private final Priority priority; + private final int eventFlag; + TransmitClientEventRequest(ByteBuffer buffer) { super(buffer); objectID = buffer.getInt(); @@ -23,6 +33,18 @@ public class TransmitClientEventRequest extends SimRequest { eventFlag = buffer.getInt(); } + /** + * The SimConnect_TransmitClientEvent function is used to request that the Microsoft Flight Simulator server transmit to all SimConnect clients the specified client event. + * + * @param objectID Specifies the ID of the server defined object. If this parameter is set to SIMCONNECT_OBJECT_ID_USER, then the transmitted event will be sent to the other clients in priority order. If this parameters contains another object ID, then the event will be sent direct to that sim-object, and no other clients will receive it. + * @param clientEventID Specifies the ID of the client event. + * @param data Double word containing any additional number required by the event. This is often zero. If the event is a Microsoft Flight Simulator event, then refer to the Event IDs document for information on this additional value. If the event is a custom event, then any value put in this parameter will be available to the clients that receive the event. + * @param priority This specifies the priority to send the message to all clients with this priority. To receive the event notification other SimConnect clients must have subscribed to receive the event. See the explanation of SimConnect Priorities. The exception to the default behavior is set by the SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY flag, described below. + * @param eventFlag One or more of the flags shown in {@link EventFlag}. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_TransmitClientEvent.htm + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#simconnect-priorities + * @see EventFlag + */ public TransmitClientEventRequest(int objectID, int clientEventID, int data, Priority priority, int eventFlag) { super(TYPE_ID); this.objectID = objectID; @@ -42,22 +64,49 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(eventFlag); } + /** + * Returns the ID of the server defined object. + * + * @return ID of the server defined object. + */ public int getObjectID() { return objectID; } + /** + * Returns the ID of the client event. + * + * @return ID of the client event. + */ public int getClientEventID() { return clientEventID; } + /** + * Returns the double word containing any additional number required by the event. + * + * @return double word containing any additional number required by the event. + */ public int getData() { return data; } + /** + * Returns the priority of this event. + * + * @return Priority of this event. + * @see Priority + */ public Priority getPriority() { return priority; } + /** + * Returns the flags that were defined for this event. + * + * @return Flags that were defined for this event. + * @see EventFlag + */ public int getEventFlag() { return eventFlag; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/UnknownRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/UnknownRequest.java index 2dfeb51..26095d1 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/UnknownRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/UnknownRequest.java @@ -1,13 +1,17 @@ package org.lembeck.fs.simconnect.request; -import org.lembeck.fs.simconnect.response.SimResponse; +import org.lembeck.fs.simconnect.SimUtil; import java.nio.ByteBuffer; +/** + * Represents a request that is new and not yet implemented in this framework. Will only be used by proxying + * simconnect interface communication. + */ public class UnknownRequest extends SimRequest { private final byte[] data; - public UnknownRequest(ByteBuffer buffer) { + UnknownRequest(ByteBuffer buffer) { super(buffer); data = new byte[buffer.remaining()]; buffer.get(data); @@ -18,6 +22,11 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.put(data); } + /** + * Returns the data that was contained in the request. + * + * @return The requests contained data. + */ public byte[] getData() { return data; } @@ -34,7 +43,7 @@ public String toString() { ", size=" + getSize() + ", version=" + getVersion() + ", identifier=" + getIdentifier() + - ", data=" + SimResponse.toString(data) + + ", data=" + SimUtil.byteArrayToString(data) + "}"; } } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeFromSystemEventRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeFromSystemEventRequest.java index cc9fec8..7dc4e91 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeFromSystemEventRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeFromSystemEventRequest.java @@ -2,6 +2,12 @@ import java.nio.ByteBuffer; +/** + * The SimConnect_UnsubscribeFromSystemEvent function is used to request that notifications are no longer received for + * the specified system event. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Events_And_Data/SimConnect_UnsubscribeFromSystemEvent.htm + */ public class UnsubscribeFromSystemEventRequest extends SimRequest { /** @@ -16,6 +22,12 @@ public class UnsubscribeFromSystemEventRequest extends SimRequest { this.clientEventID = buffer.getInt(); } + /** + * The SimConnect_UnsubscribeFromSystemEvent function is used to request that notifications are no longer received + * for the specified system event. + * + * @param clientEventID Specifies the ID of the client event. + */ public UnsubscribeFromSystemEventRequest(int clientEventID) { super(TYPE_ID); this.clientEventID = clientEventID; @@ -26,6 +38,11 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putInt(clientEventID); } + /** + * Returns the ID of the client event. + * + * @return ID of the client event. + */ public int getClientEventID() { return clientEventID; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeInputEventRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeInputEventRequest.java index 42ff258..9bd4d07 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeInputEventRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeInputEventRequest.java @@ -2,12 +2,19 @@ import java.nio.ByteBuffer; +/** + * The SimConnect_UnsubscribeInputEvent function is used to unsubscribe from an input event that has previously been + * subscribed to. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/InputEvents/SimConnect_UnsubscribeInputEvent.htm + */ public class UnsubscribeInputEventRequest extends SimRequest { /** * Internally used ID of this simconnect request. */ public static final int TYPE_ID = 0xf0000053; + private final long hash; UnsubscribeInputEventRequest(ByteBuffer buffer) { @@ -15,6 +22,14 @@ public class UnsubscribeInputEventRequest extends SimRequest { hash = buffer.getLong(); } + /** + * The SimConnect_UnsubscribeInputEvent function is used to unsubscribe from an input event that has previously been + * subscribed to. + * + * @param hash Hash ID that will identify the desired input event to unsubscribe from. You can use 0 here to + * unsubscribe from all input events. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/InputEvents/SimConnect_UnsubscribeInputEvent.htm + */ public UnsubscribeInputEventRequest(long hash) { super(TYPE_ID); this.hash = hash; @@ -25,6 +40,12 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.putLong(hash); } + /** + * Returns the hash ID that will identify the desired input event to unsubscribe from. You can use 0 here to + * unsubscribe from all input events. + * + * @return The hash ID that will identify the desired input event to unsubscribe from. + */ public long getHash() { return hash; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesEx1Request.java b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesEx1Request.java index e627198..531d04c 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesEx1Request.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesEx1Request.java @@ -3,6 +3,12 @@ import org.lembeck.fs.simconnect.constants.FacilityListType; import java.nio.ByteBuffer; +/** + * The SimConnect_UnsubscribeToFacilities_EX1 function is used to request that notifications of additions to the + * facilities cache are no longer sent, with the ability to specify which event should be disabled. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_UnsubscribeToFacilities_EX1.htm + */ public class UnsubscribeToFacilitiesEx1Request extends SimRequest { /** @@ -21,7 +27,16 @@ public class UnsubscribeToFacilitiesEx1Request extends SimRequest { unsubscribeOldOutRange = buffer.get() != 0; } - public UnsubscribeToFacilitiesEx1Request(FacilityListType type, boolean unsubscribeNewInRange, boolean unsubscribeOldOutRange) { + /** + * The SimConnect_UnsubscribeToFacilities_EX1 function is used to request that notifications of additions to the + * facilities cache are no longer sent, with the ability to specify which event should be disabled. + * + * @param type Specifies one member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + * @param unsubscribeNewInRange Specifies that the "new element in range" event should be disabled. + * @param unsubscribeOldOutRange Specifies that the "element out of range" event should be disabled. + */ + public UnsubscribeToFacilitiesEx1Request(FacilityListType type, boolean unsubscribeNewInRange, + boolean unsubscribeOldOutRange) { super(TYPE_ID); this.type = type; this.unsubscribeNewInRange = unsubscribeNewInRange; @@ -35,14 +50,29 @@ protected void writeRequest(ByteBuffer outBuffer) { outBuffer.put(unsubscribeOldOutRange ? (byte) 1 : (byte) 0); } + /** + * Returns the type of facilities no further additions to the cache should be sent for. + * + * @return The type of facilities no further additions to the cache should be sent for. + */ public FacilityListType getType() { return type; } + /** + * Returns whether the "new element in range" event should be disabled. + * + * @return Specifies that the "new element in range" event should be disabled. + */ public boolean isUnsubscribeNewInRange() { return unsubscribeNewInRange; } + /** + * Returns whether the "element out of range" event should be disabled. + * + * @return Specifies that the "element out of range" event should be disabled. + */ public boolean isUnsubscribeOldOutRange() { return unsubscribeOldOutRange; } diff --git a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesRequest.java b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesRequest.java index 40cd57a..9ecad93 100644 --- a/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesRequest.java +++ b/src/main/java/org/lembeck/fs/simconnect/request/UnsubscribeToFacilitiesRequest.java @@ -3,6 +3,12 @@ import org.lembeck.fs.simconnect.constants.FacilityListType; import java.nio.ByteBuffer; +/** + * The SimConnect_UnsubscribeToFacilities function is used to request that notifications of additions to the facilities + * cache are no longer sent. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_UnsubscribeToFacilities.htm + */ public class UnsubscribeToFacilitiesRequest extends SimRequest { /** @@ -10,25 +16,37 @@ public class UnsubscribeToFacilitiesRequest extends SimRequest { */ public static final int TYPE_ID = 0xf0000042; - private final FacilityListType facilitiesListType; + private final FacilityListType facilityListType; UnsubscribeToFacilitiesRequest(ByteBuffer buffer) { super(buffer); - facilitiesListType = FacilityListType.ofId(buffer.getInt()); + facilityListType = FacilityListType.ofId(buffer.getInt()); } - public UnsubscribeToFacilitiesRequest(FacilityListType facilitiesListType) { + /** + * The SimConnect_UnsubscribeToFacilities function is used to request that notifications of additions to the + * facilities cache are no longer sent. + * + * @param facilityListType Specifies one member of the SIMCONNECT_FACILITY_LIST_TYPE enumeration type. + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_UnsubscribeToFacilities.htm + */ + public UnsubscribeToFacilitiesRequest(FacilityListType facilityListType) { super(TYPE_ID); - this.facilitiesListType = facilitiesListType; + this.facilityListType = facilityListType; } @Override protected void writeRequest(ByteBuffer outBuffer) { - outBuffer.putInt(facilitiesListType.ordinal()); + outBuffer.putInt(facilityListType.ordinal()); } - public FacilityListType getFacilitiesListType() { - return facilitiesListType; + /** + * Returns the type of facilities no further additions to the cache should be sent for. + * + * @return The type of facilities no further additions to the cache should be sent for. + */ + public FacilityListType getFacilityListType() { + return facilityListType; } /** @@ -43,7 +61,7 @@ public String toString() { ", size=" + getSize() + ", version=" + getVersion() + ", identifier=" + getIdentifier() + - ", facilitiesListType=" + facilitiesListType + + ", facilityListType=" + facilityListType + "}"; } } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/response/FacilityAirport.java b/src/main/java/org/lembeck/fs/simconnect/response/FacilityAirport.java index 9dac6dd..de4af48 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/FacilityAirport.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/FacilityAirport.java @@ -1,17 +1,49 @@ package org.lembeck.fs.simconnect.response; +/** + * The SIMCONNECT_DATA_FACILITY_AIRPORT structure is used to return information on a single airport in the facilities + * cache. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_DATA_FACILITY_AIRPORT.htm + */ public class FacilityAirport { + /** + * The airport ICAO code. + */ protected final String icao; + /** + * The airport region code. + * + * @see https://en.wikipedia.org/wiki/ICAO_airport_code#Prefixes + */ protected final String regionCode; + /** + * Latitude of the airport facility in degrees. + */ protected final double latitude; + /** + * Longitude of the airport facility in degrees. + */ protected final double longitude; + /** + * Altitude of the facility in meters. + */ protected final double altitude; + /** + * Creates a new airport instance. + * + * @param icao The airport ICAO code. + * @param regionCode The airport region code. + * @param latitude Latitude of the airport facility in degrees. + * @param longitude Longitude of the airport facility in degrees. + * @param altitude Altitude of the facility in meters. + */ public FacilityAirport(String icao, String regionCode, double latitude, double longitude, double altitude) { this.icao = icao; this.regionCode = regionCode; @@ -20,22 +52,48 @@ public FacilityAirport(String icao, String regionCode, double latitude, double l this.altitude = altitude; } + /** + * Returns the airport ICAO code. + * + * @return The airport ICAO code. + */ public String getIcao() { return icao; } + /** + * Returns the airport region code. + * + * @return The airport region code. + * @see https://en.wikipedia.org/wiki/ICAO_airport_code#Prefixes + */ public String getRegionCode() { return regionCode; } + /** + * Returns the Latitude of the airport facility. + * + * @return Latitude of the airport facility in degrees. + */ public double getLatitude() { return latitude; } + /** + * Returns the Longitude of the airport facility. + * + * @return Longitude of the airport facility in degrees. + */ public double getLongitude() { return longitude; } + /** + * Returns the Altitude of the facility in meters. + * + * @return Altitude of the facility in meters. + */ public double getAltitude() { return altitude; } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/FacilityNDB.java b/src/main/java/org/lembeck/fs/simconnect/response/FacilityNDB.java index f2599cb..4bdbe1a 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/FacilityNDB.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/FacilityNDB.java @@ -1,14 +1,40 @@ package org.lembeck.fs.simconnect.response; +/** + * The SIMCONNECT_DATA_FACILITY_NDB structure is used to return information on a single NDB station in the facilities + * cache. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_DATA_FACILITY_NDB.htm + */ public class FacilityNDB extends FacilityWaypoint { + /** + * Frequency of the station in Hz. + */ protected final int frequency; - public FacilityNDB(String icao, String regionCode, double latitude, double longitude, double altitude, float magVar, int frequency) { + /** + * Creates a new NDB instance. + * + * @param icao The NDB ICAO code. + * @param regionCode The NDB region code. + * @param latitude Latitude of the NDB facility in degrees. + * @param longitude Longitude of the NDB facility in degrees. + * @param altitude Altitude of the NDB facility in meters. + * @param magVar The magnetic variation of the NDB in degrees. + * @param frequency Frequency of the station in Hz. + */ + public FacilityNDB(String icao, String regionCode, double latitude, double longitude, double altitude, float magVar, + int frequency) { super(icao, regionCode, latitude, longitude, altitude, magVar); this.frequency = frequency; } + /** + * Returns the Frequency of the station in Hz. + * + * @return Frequency of the station in Hz. + */ public int getFrequency() { return frequency; } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/FacilityVOR.java b/src/main/java/org/lembeck/fs/simconnect/response/FacilityVOR.java index 218993b..b465159 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/FacilityVOR.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/FacilityVOR.java @@ -1,20 +1,76 @@ package org.lembeck.fs.simconnect.response; + +/** + * The SIMCONNECT_DATA_FACILITY_VOR structure is used to return information on a single VOR station in the facilities + * cache. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_DATA_FACILITY_VOR.htm + */ public class FacilityVOR extends FacilityNDB { + /** + * Flags indicating whether the other fields are valid or not. + *
    + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_NAV_SIGNAL(0x1): Set if the station has a NAV transmitter, and if so, GlideLat, GlideLon and GlideAlt contain valid data.
  • + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_LOCALIZER(0x2): Set if the station transmits an ILS localizer angle, and if so fLocalizer contains valid data.
  • + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_GLIDE_SLOPE(0x4): Set if the station transmits an ILS approach angle, and if so fGlideSlopeAngle contains valid data.
  • + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_DME(0x8): Set if the station t transmits a DME signal, and if so the inherited DME fFrequency contains valid data.
  • + *
+ */ protected final int flags; + /** + * The ILS localizer angle in degrees. + */ protected final float localizer; + /** + * The latitude of the glide slope transmitter in degrees. + */ protected final double glideLat; + /** + * The longitude of the glide slope transmitter in degrees. + */ protected final double glideLon; + /** + * The altitude of the glide slope transmitter in degrees. + */ protected final double glideAlt; + /** + * The ILS approach angle in degrees. + */ protected final float glideSlopeAngle; - public FacilityVOR(String icao, String regionCode, double latitude, double longitude, double altitude, float magVar, int frequency, int flags, float localizer, double glideLat, double glideLon, double glideAlt, float glideSlopeAngle) { + /** + * Creates a new VOR instance. + * + * @param icao The VOR ICAO code. + * @param regionCode The VOR region code. + * @param latitude Latitude of the VOR facility in degrees. + * @param longitude Longitude of the VOR facility in degrees. + * @param altitude Altitude of the VOR facility in meters. + * @param magVar The magnetic variation of the VOR in degrees. + * @param frequency Frequency of the station in Hz. + * @param flags Flags indicating whether the other fields are valid or not. + *
    + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_NAV_SIGNAL(0x1): Set if the station has a NAV transmitter, and if so, GlideLat, GlideLon and GlideAlt contain valid data.
  • + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_LOCALIZER(0x2): Set if the station transmits an ILS localizer angle, and if so fLocalizer contains valid data.
  • + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_GLIDE_SLOPE(0x4): Set if the station transmits an ILS approach angle, and if so fGlideSlopeAngle contains valid data.
  • + *
  • SIMCONNECT_RECV_ID_VOR_LIST_HAS_DME(0x8): Set if the station t transmits a DME signal, and if so the inherited DME fFrequency contains valid data.
  • + *
+ * @param localizer The ILS localizer angle in degrees. + * @param glideLat The latitude of the glide slope transmitter in degrees. + * @param glideLon The longitude of the glide slope transmitter in degrees. + * @param glideAlt The altitude of the glide slope transmitter in degrees. + * @param glideSlopeAngle The ILS approach angle in degrees. + */ + public FacilityVOR(String icao, String regionCode, double latitude, double longitude, double altitude, float magVar, + int frequency, int flags, float localizer, double glideLat, double glideLon, double glideAlt, + float glideSlopeAngle) { super(icao, regionCode, latitude, longitude, altitude, magVar, frequency); this.flags = flags; this.localizer = localizer; @@ -31,20 +87,6 @@ public FacilityVOR(String icao, String regionCode, double latitude, double longi */ @Override public String toString() { - return getClass().getSimpleName() + "{" + - "icao='" + icao + '\'' + - ", regionCode='" + regionCode + '\'' + - ", latitude=" + latitude + - ", longitude=" + longitude + - ", altitude=" + altitude + - ", magVar=" + magVar + - ", frequency=" + frequency + - ", flags=" + flags + - ", localizer=" + localizer + - ", glideLat=" + glideLat + - ", glideLon=" + glideLon + - ", glideAlt=" + glideAlt + - ", glideSlopeAngle=" + glideSlopeAngle + - '}'; + return getClass().getSimpleName() + "{" + "icao='" + icao + '\'' + ", regionCode='" + regionCode + '\'' + ", latitude=" + latitude + ", longitude=" + longitude + ", altitude=" + altitude + ", magVar=" + magVar + ", frequency=" + frequency + ", flags=" + flags + ", localizer=" + localizer + ", glideLat=" + glideLat + ", glideLon=" + glideLon + ", glideAlt=" + glideAlt + ", glideSlopeAngle=" + glideSlopeAngle + '}'; } } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/response/FacilityWaypoint.java b/src/main/java/org/lembeck/fs/simconnect/response/FacilityWaypoint.java index 0945f37..87e0323 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/FacilityWaypoint.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/FacilityWaypoint.java @@ -1,14 +1,39 @@ package org.lembeck.fs.simconnect.response; +/** + * The SIMCONNECT_DATA_FACILITY_WAYPOINT structure used to return information on a single waypoint in the facilities + * cache. + * + * @see https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Structures_And_Enumerations/SIMCONNECT_DATA_FACILITY_WAYPOINT.htm + */ public class FacilityWaypoint extends FacilityAirport { + /** + * The magnetic variation of the waypoint in degrees. + */ protected final float magVar; - public FacilityWaypoint(String icao, String regionCode, double latitude, double longitude, double altitude, float magVar) { + /** + * Creates a new waypoint instance. + * + * @param icao The waypoint ICAO code. + * @param regionCode The waypoint region code. + * @param latitude Latitude of the waypoint facility in degrees. + * @param longitude Longitude of the waypoint facility in degrees. + * @param altitude Altitude of the waypoint facility in meters. + * @param magVar The magnetic variation of the waypoint in degrees. + */ + public FacilityWaypoint(String icao, String regionCode, double latitude, double longitude, double altitude, + float magVar) { super(icao, regionCode, latitude, longitude, altitude); this.magVar = magVar; } + /** + * Returns the magnetic variation of the waypoint in degrees. + * + * @return The magnetic variation of the waypoint in degrees. + */ public float getMagVar() { return magVar; } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/InputEventDescriptor.java b/src/main/java/org/lembeck/fs/simconnect/response/InputEventDescriptor.java index 7fd5eae..16c8cd9 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/InputEventDescriptor.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/InputEventDescriptor.java @@ -4,26 +4,68 @@ import org.lembeck.fs.simconnect.constants.InputEventType; import java.nio.ByteBuffer; +/** + * The SIMCONNECT_INPUT_EVENT_DESCRIPTOR structure is used to return an item of data for a specific input event. + */ public class InputEventDescriptor { + /** + * The name of the Input Event. + */ private final String name; + + /** + * The hash ID for the event. + */ private final long hash; + + /** + * The expected datatype (from the SIMCONNECT_DATATYPE enum). Usually a FLOAT32 or STRING128. + */ private final InputEventType inputEventType; - public InputEventDescriptor(ByteBuffer buffer) { + InputEventDescriptor(ByteBuffer buffer) { name = SimUtil.readString(buffer, 64); hash = buffer.getLong(); inputEventType = InputEventType.ofId(buffer.getInt()); } + /** + * Creates a new InputEventDescriptor instance. + * + * @param name The name of the Input Event. + * @param hash The hash ID for the event. + * @param inputEventType The expected datatype (from the SIMCONNECT_DATATYPE enum). Usually a FLOAT32 or STRING128. + */ + public InputEventDescriptor(String name, long hash, InputEventType inputEventType) { + this.name = name; + this.hash = hash; + this.inputEventType = inputEventType; + } + + /** + * Returns the name of the Input Event. + * + * @return The name of the Input Event. + */ public String getName() { return name; } + /** + * Returns the hash ID for the event. + * + * @return The hash ID for the event. + */ public long getHash() { return hash; } + /** + * Returns the expected datatype (from the SIMCONNECT_DATATYPE enum). Usually a FLOAT32 or STRING128. + * + * @return The expected datatype (from the SIMCONNECT_DATATYPE enum). Usually a FLOAT32 or STRING128. + */ public InputEventType getInputEventType() { return inputEventType; } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvAirportListResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvAirportListResponse.java index 75c56be..e164aed 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvAirportListResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvAirportListResponse.java @@ -4,23 +4,31 @@ import java.nio.ByteBuffer; import java.util.Arrays; +/** + * The SIMCONNECT_RECV_AIRPORT_LIST structure is used to return a list of SIMCONNECT_DATA_FACILITY_AIRPORT structures. + */ public class RecvAirportListResponse extends RecvFacilitiesListResponse { private final FacilityAirport[] airportList; - RecvAirportListResponse(ByteBuffer buffer) { + RecvAirportListResponse(final ByteBuffer buffer) { super(buffer); airportList = new FacilityAirport[arraySize]; for (int i = 0; i < arraySize; i++) { - String icao = SimUtil.readString(buffer, 6); - String regionCode = SimUtil.readString(buffer, 3); - double latitude = buffer.getDouble(); - double longitude = buffer.getDouble(); - double altitude = buffer.getDouble(); + final String icao = SimUtil.readString(buffer, 6); + final String regionCode = SimUtil.readString(buffer, 3); + final double latitude = buffer.getDouble(); + final double longitude = buffer.getDouble(); + final double altitude = buffer.getDouble(); airportList[i] = new FacilityAirport(icao, regionCode, latitude, longitude, altitude); } } + /** + * Returns the List of airports in this response. + * + * @return List of contained airports- + */ public FacilityAirport[] getAirportList() { return airportList; } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvAssignedObjectIdResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvAssignedObjectIdResponse.java index fc5f5d3..2195270 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvAssignedObjectIdResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvAssignedObjectIdResponse.java @@ -7,7 +7,14 @@ */ public class RecvAssignedObjectIdResponse extends SimResponse { + /** + * Double word containing the client defined request ID. + */ private final int requestId; + + /** + * Double word containing the server defined object ID. + */ private final int objectId; RecvAssignedObjectIdResponse(ByteBuffer buffer) { @@ -16,10 +23,20 @@ public class RecvAssignedObjectIdResponse extends SimResponse { objectId = buffer.getInt(); } + /** + * Returns the Double word containing the client defined request ID. + * + * @return Double word containing the client defined request ID. + */ public int getRequestId() { return requestId; } + /** + * Returns the Double word containing the server defined object ID. + * + * @return Double word containing the server defined object ID. + */ public int getObjectId() { return objectId; } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerClientStartedResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerClientStartedResponse.java index 3b3a27c..3da1acb 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerClientStartedResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerClientStartedResponse.java @@ -4,7 +4,13 @@ import static org.lembeck.fs.simconnect.SimUtil.UNKNOWN_GROUP; + +/** + * The SIMCONNECT_RECV_EVENT_MULTIPLAYER_CLIENT_STARTED structure is sent to a client when they have successfully joined + * a multi-player race. + */ public class RecvEventMultiplayerClientStartedResponse extends RecvEventResponse { + RecvEventMultiplayerClientStartedResponse(ByteBuffer buffer) { super(buffer); } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerServerStartedResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerServerStartedResponse.java index 43e96e5..b0e6fd0 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerServerStartedResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerServerStartedResponse.java @@ -4,7 +4,12 @@ import static org.lembeck.fs.simconnect.SimUtil.UNKNOWN_GROUP; +/** + * The SIMCONNECT_RECV_EVENT_MULTIPLAYER_SERVER_STARTED structure is sent to the host when the session is visible to + * other users in the lobby. + */ public class RecvEventMultiplayerServerStartedResponse extends RecvEventResponse { + RecvEventMultiplayerServerStartedResponse(ByteBuffer buffer) { super(buffer); } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerSessionEndedResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerSessionEndedResponse.java index 2f84195..3ebfbc6 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerSessionEndedResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvEventMultiplayerSessionEndedResponse.java @@ -4,7 +4,12 @@ import static org.lembeck.fs.simconnect.SimUtil.UNKNOWN_GROUP; +/** + * The SIMCONNECT_RECV_EVENT_MULTIPLAYER_SESSION_ENDED structure is sent to a client when they have requested to leave + * a race, or to all players when the session is terminated by the host. + */ public class RecvEventMultiplayerSessionEndedResponse extends RecvEventResponse { + RecvEventMultiplayerSessionEndedResponse(ByteBuffer buffer) { super(buffer); } diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvQuitResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvQuitResponse.java index 1111d93..7d0bf26 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvQuitResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvQuitResponse.java @@ -2,6 +2,9 @@ import java.nio.ByteBuffer; +/** + * The SIMCONNECT_RECV_QUIT is an identical structure to the SIMCONNECT_RECV structure. + */ public class RecvQuitResponse extends SimResponse { RecvQuitResponse(ByteBuffer buffer) { diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataByTypeResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataByTypeResponse.java index a4e2c9c..21b38bb 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataByTypeResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataByTypeResponse.java @@ -2,6 +2,10 @@ import java.nio.ByteBuffer; +/** + * The SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE structure will be received by the client after a successful call to + * SimConnect_RequestDataOnSimObjectType. It is an identical structure to SIMCONNECT_RECV_SIMOBJECT_DATA. + */ public class RecvSimobjectDataByTypeResponse extends RecvSimobjectDataResponse { RecvSimobjectDataByTypeResponse(ByteBuffer buffer) { diff --git a/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataResponse.java index d9f7b5b..e81e065 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/RecvSimobjectDataResponse.java @@ -1,21 +1,50 @@ package org.lembeck.fs.simconnect.response; +import org.lembeck.fs.simconnect.SimUtil; import java.nio.ByteBuffer; import static java.nio.ByteOrder.LITTLE_ENDIAN; +/** + * The SIMCONNECT_RECV_SIMOBJECT_DATA structure will be received by the client after a successful call to + * SimConnect_RequestDataOnSimObject or SimConnect_RequestDataOnSimObjectType. + */ public class RecvSimobjectDataResponse extends SimResponse { + /** + * The default, data will be sent strictly according to the defined period. + */ public static final int DATA_REQUEST_FLAG_DEFAULT = 0; + + /** + * Data will only be sent to the client when one or more values have changed. If this is the only flag set, then all + * the variables in a data definition will be returned if just one of the values changes. + */ public static final int DATA_REQUEST_FLAG_CHANGED = 1; + + /** + * Requested data will be sent in tagged format (datum ID/value pairs). Tagged format requires that a datum + * reference ID is returned along with the data value, in order that the client code is able to identify the + * variable. This flag is usually set in conjunction with the previous flag, but it can be used on its own to return + * all the values in a data definition in datum ID/value pairs. See the SIMCONNECT_RECV_SIMOBJECT_DATA structure for + * more details. + */ public static final int SIMCONNECT_DATA_REQUEST_FLAG_TAGGED = 2; + private final int requestID; + private final int objectID; + private final int defineID; + private final int flags; + private final int entryNumber; + private final int outOf; + private final int defineCount; + private final byte[] data; RecvSimobjectDataResponse(ByteBuffer buffer) { @@ -31,34 +60,84 @@ public class RecvSimobjectDataResponse extends SimResponse { buffer.get(data); } + /** + * Returns the ID of the client defined request. + * + * @return ID of the client defined request. + */ public int getRequestID() { return requestID; } + /** + * returns the ID of the client defined object. + * + * @return ID of the client defined object. + */ public int getObjectID() { return objectID; } + /** + * Returns the ID of the client defined data definition. + * + * @return ID of the client defined data definition. + */ public int getDefineID() { return defineID; } + /** + * Returns the flags that were set for this data request, see SimConnect_RequestDataOnSimObject for a description + * of the flags. This parameter will always be set to zero if the call was SimConnect_RequestDataOnSimObjectType. + * + * @return Flags that were set for this data request. + */ public int getFlags() { return flags; } + /** + * If multiple objects are being returned, this is the index number of this object out of a total of outof. + * This will always be 1 if the call was SimConnect_RequestDataOnSimObject, and can be 0 or more if the call was + * SimConnect_RequestDataOnSimObjectType. + * + * @return Index number of this object. + * @see #getOutOf() + */ public int getEntryNumber() { return entryNumber; } + /** + * The total number of objects being returned. Note that entryNumber and outOf start with 1 not 0, so if two + * objects are being returned entryNumber and outOf pairs will be 1,2 and 2,2 for the two objects. This will + * always be 1 if the call was SimConnect_RequestDataOnSimObject, and can be 0 or more if the call was + * SimConnect_RequestDataOnSimObjectType. + * + * @return The total number of objects being returned. + * @see #getEntryNumber() + */ public int getOutOf() { return outOf; } + /** + * The number of 8-byte elements in the dwData array. + * + * @return Number of 8-byte elements in the dwData array. + */ public int getDefineCount() { return defineCount; } + /** + * A data array containing information on a specified object in 8-byte (double word) elements wrapped as ByteBuffer. + * The length of the array is defineCount. + * + * @return ByteBuffer holding the data of the response. + * @see #getDefineCount() + */ public ByteBuffer getData() { ByteBuffer buffer = ByteBuffer.wrap(data); buffer.order(LITTLE_ENDIAN); @@ -83,7 +162,7 @@ public String toString() { ", entryNumber=" + entryNumber + ", outOf=" + outOf + ", defineCount=" + defineCount + - ", data=" + SimResponse.toString(data) + + ", data=" + SimUtil.byteArrayToString(data) + "}"; } -} +} \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/response/SimResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/SimResponse.java index 377128f..fcc9708 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/SimResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/SimResponse.java @@ -2,15 +2,35 @@ import java.nio.ByteBuffer; +/** + * Superclass of all responses that will be received from the simulator over the simconnect interface. + * Contains the data that is common to all kinds of response types as its size, the current version and its type id. + */ public abstract class SimResponse { + /** + * The total size of the returned structure in bytes (that is, not usually the size of the SIMCONNECT_RECV structure, but of the structure that inherits it). + */ protected final int size; + /** + * The version number of the SimConnect server. + */ protected final int version; + /** + * The ID of the returned structure. One member of SIMCONNECT_RECV_ID. + */ protected final int typeId; - public SimResponse(int size, int version, int typeId) { + /** + * Creates a new response instance. + * + * @param size The total size of the returned structure in bytes (that is, not usually the size of the SIMCONNECT_RECV structure, but of the structure that inherits it). + * @param version The version number of the SimConnect server. + * @param typeId The ID of the returned structure. One member of SIMCONNECT_RECV_ID. + */ + protected SimResponse(int size, int version, int typeId) { this.size = size; this.version = version; this.typeId = typeId; @@ -22,19 +42,40 @@ public SimResponse(int size, int version, int typeId) { buffer.getInt()); // typeId } + /** + * Returns the total size of the returned structure in bytes. + * + * @return The total size of the returned structure in bytes (that is, not usually the size of the SIMCONNECT_RECV structure, but of the structure that inherits it). + */ public int getSize() { return size; } + /** + * returns the version number of the SimConnect server. + * + * @return The version number of the SimConnect server. + */ public int getVersion() { return version; } + /** + * Returns the ID of the returned structure. + * + * @return The ID of the returned structure. One member of SIMCONNECT_RECV_ID. + */ public int getTypeID() { return typeId; } - public static SimResponse parseResponse(int size, ByteBuffer buffer) { + /** + * Reads the next response from the given byte buffer and transforms it into its specific SimResponse implementation. + * + * @param buffer The buffer from which to read the data from. + * @return Object representation of the read simconnect response. If the type is new or not yet implemented, the result will be of type {@link UnknownResponse}. + */ + public static SimResponse parseResponse(ByteBuffer buffer) { int typeId = buffer.getInt(8); return switch (typeId) { case 0x01 -> new RecvExceptionResponse(buffer); @@ -78,17 +119,4 @@ public static SimResponse parseResponse(int size, ByteBuffer buffer) { default -> new UnknownResponse(buffer); }; } - - public static String toString(byte[] data) { - StringBuffer sb = new StringBuffer(); - 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(); - } } \ No newline at end of file diff --git a/src/main/java/org/lembeck/fs/simconnect/response/UnknownResponse.java b/src/main/java/org/lembeck/fs/simconnect/response/UnknownResponse.java index e18eddc..f7bd6aa 100644 --- a/src/main/java/org/lembeck/fs/simconnect/response/UnknownResponse.java +++ b/src/main/java/org/lembeck/fs/simconnect/response/UnknownResponse.java @@ -1,17 +1,27 @@ package org.lembeck.fs.simconnect.response; +import org.lembeck.fs.simconnect.SimUtil; import java.nio.ByteBuffer; +/** + * Class to represent new and currently not yet implemented response types that will be received from the simulators + * simconnect interface. + */ public class UnknownResponse extends SimResponse { private final byte[] data; - public UnknownResponse(ByteBuffer buffer) { + UnknownResponse(ByteBuffer buffer) { super(buffer); data = new byte[buffer.remaining()]; buffer.get(data); } + /** + * Returns the contained data of the unknown response. + * + * @return Data of the unknown response. + */ public byte[] getData() { return data; } @@ -23,6 +33,6 @@ public byte[] getData() { */ @Override public String toString() { - return getClass().getSimpleName() + " {Typ: " + Integer.toHexString(getTypeID()) + ", Länge=" + getSize() + ", Version=" + getVersion() + ", data=" + toString(data) + "}"; + return getClass().getSimpleName() + " {Typ: " + Integer.toHexString(getTypeID()) + ", Länge=" + getSize() + ", Version=" + getVersion() + ", data=" + SimUtil.byteArrayToString(data) + "}"; } } \ No newline at end of file