Skip to content

Commit

Permalink
Added Javadoc comments to InfrastructureInstanceManager
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Aug 1, 2023
1 parent 0f9e37c commit 8fb2676
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,10 @@ public void onV2XMessageRx(byte[] rxMsg, String rxRsuId) {

/**
* Callback to be invoked when a infrastructure instance receives a simulated
* object detection from
* a registered simulated sensors.
* object detection from a registered simulated sensors. Only send object detection
* to the infrastructure instance that contains the sensor that reported it.
*
* @param detection
* @param sensorId
* @param detection Detected Object.
*/
public void onDetectedObject(DetectedObject detection) {
for (InfrastructureInstance instance : managedInstances.values()) {
Expand All @@ -195,15 +194,34 @@ public void onDetectedObject(DetectedObject detection) {
}
}

/**
* Helper method to serialize time sychronization message to JSON and encode into bytes
* for eventual transmission via a Datagramsocket.
*
* @param message time synchronization message to encode
* @return resulting bytes encoded from JSON string.
*/
private byte[] encodeTimeMessage(InfrastructureTimeMessage message) {
return asJson(message).getBytes();
}

/**
* Helper method to serialize java Object into JSON via the {@link com.google.gson.Gson} object.
*
* @param obj to serialze into JSON string.
* @return resulting JSON string.
*/
private String asJson(Object obj) {
Gson gson = new Gson();
return gson.toJson(obj);
}

/**
* Helper method to serialize object detection message to JSON and encode into bytes
* for eventual transmission via a Datagramsocket.
*
* @param message object detection message to encode
* @return resulting bytes encoded from JSON string.
*/
private byte[] encodeObjectDetection(DetectedObject detection) {
return asJson(detection).getBytes();
}
Expand Down

0 comments on commit 8fb2676

Please sign in to comment.