Skip to content

Commit

Permalink
Merge master branch into develop (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
codygarver authored May 12, 2023
2 parents 41bb775 + 58c37a0 commit d5cd25c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/cc/rsu/BSMRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ public class BSMRequest {
// BSM includes a list of GeoLocation in the route to indicate its future path
private ArrayList<Position> route;
private Instant last_update_at;
// Identify the v2xhub that this RSU is connected to
public String v2xhub_port;

public String getV2xhub_port() {
return v2xhub_port;
}

public void setV2xhub_port(String v2xhub_port) {
this.v2xhub_port = v2xhub_port;
}

/**
* @return BSM hex
Expand Down Expand Up @@ -76,7 +86,7 @@ public BSMRequest(String id, ArrayList<Position> route) {

@Override
public String toString() {
return "BSMRequest [id=" + id + ", route=" + route + ", last_update_at=" + last_update_at + "]";
return "BSMRequest [v2xhub_port="+ v2xhub_port + ", id=" + id + ", route=" + route + ", last_update_at=" + last_update_at + "]";
}

}
8 changes: 7 additions & 1 deletion src/cc/rsu/BSMRequestParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public void startElement(String sUri, String sLocalName, String sQname, Attribut
switch (sQname.toLowerCase()) {
case "bsmrequest":
break;
case "v2xhubport":
break;
case "id":
break;
case "route":
Expand All @@ -44,6 +46,7 @@ public void startElement(String sUri, String sLocalName, String sQname, Attribut
break;
case "point":
loc = new Position();
break;
default:
break;
}
Expand All @@ -60,6 +63,9 @@ public void endElement(String sUri, String sLocalName, String sQname) throws SAX
case "route":
bsmReq.setRoute(route);
break;
case "v2xhubport":
bsmReq.v2xhub_port = m_sbuf.toString();
break;
case "point":
route.add(loc);
break;
Expand Down Expand Up @@ -97,4 +103,4 @@ public BSMRequest parseRequest(InputStream oIn) {
return null;
}

}
}
2 changes: 1 addition & 1 deletion src/cc/rsu/HTTPClientTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Void call() throws Exception {
oOut.append(bsmReq.getId());
}
oHttpClient.disconnect();
LOGGER.info("Successfully sent BSM Hex: " + bsmReq.getId() + " to V2xHub port: "
LOGGER.info("FER-15: Successfully sent BSM Hex: " + bsmReq.getId() + " to V2xHub port: "
+ identifiedRSU.getCenterLoc().v2xhub_port + "!\n");
} catch (MalformedURLException e) {
LOGGER.error("ERROR sending BSM Hex due to malformated URL!");
Expand Down
6 changes: 4 additions & 2 deletions src/cc/rsu/RSUIdentificationTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ public Void call() throws Exception {
//NOTE: For the carma-cloud registered RSUs, it needs additional consideration for those RSUs (RSUs, geofences, etc.) in a certain requested region.
if (registeredRSUs != null && registeredRSUs.size() > 0) {
ArrayList<RSUBoundingbox> identifiedRSUs = new ArrayList<>();
String identifiedRSUNames = "";
for (RSUBoundingbox rsuBoundingBox : registeredRSUs) {
BoundingBox bBox = rsuBoundingBox.getBoundingBox();
for (BoundingBox bsmBoxOther : boundingBoxes) {
if (bBox.intersects(bsmBoxOther)) {
identifiedRSUs.add(rsuBoundingBox);
identifiedRSUNames += rsuBoundingBox.getCenterLoc().id +",";
LOGGER.debug("Identified RSU location: " + rsuBoundingBox.getCenterLoc().toString());
break;
}
}
}
LOGGER.info("Identified numbers of RSU: " + identifiedRSUs.size());
LOGGER.info("FER-14: Identified numbers of RSU: " + identifiedRSUs.size() + "; RSU Names: " + identifiedRSUNames + "; BSM:" + incomingBSMReq.getId());

// sent BSM hex to the identified RSUs
ExecutorService singleExector = Executors.newSingleThreadExecutor();
Expand All @@ -79,7 +81,7 @@ public Void call() throws Exception {
}

long end_ts = Instant.now().toEpochMilli();
LOGGER.warn("TOTAL BSM PROCESS time (ms): " + (end_ts - start_ts) + "\n");
LOGGER.warn("FER-13-2: TOTAL BSM PROCESS time (ms): " + (end_ts - start_ts) + "; BSM:" + incomingBSMReq.getId());
return null;
}

Expand Down
4 changes: 4 additions & 0 deletions src/cc/ws/RSUServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private int listRSU(HttpServletRequest oReq, JSONObject oResponse) {
* Request for identified RSUs
*/
private int requestRSU(HttpServletRequest oReq, JSONObject oResponse) throws Exception {
long start_ts = Instant.now().toEpochMilli();
ArrayList<RSUBoundingbox> registeredRSUs = (ArrayList<RSUBoundingbox>) getServletContext()
.getAttribute(RSULIST);
if (registeredRSUs == null || registeredRSUs.size() == 0) {
Expand Down Expand Up @@ -262,6 +263,7 @@ private int requestRSU(HttpServletRequest oReq, JSONObject oResponse) throws Exc
getServletContext().setAttribute(BSMREQLIST, updatedBsmReqsList);
return HttpServletResponse.SC_CONFLICT;
}

// Processing new BSM request
ExecutorService singleExector = Executors.newSingleThreadExecutor();
singleExector.submit(new RSUIdentificationTask(newBsmReq, registeredRSUs));
Expand All @@ -270,6 +272,8 @@ private int requestRSU(HttpServletRequest oReq, JSONObject oResponse) throws Exc
// Add newly processed BSM request to tracking list
updatedBsmReqsList.add(newBsmReq);
getServletContext().setAttribute(BSMREQLIST, updatedBsmReqsList);
long end_ts = Instant.now().toEpochMilli();
LOGGER.warn("FER-13-1: TOTAL BSM REQUEST time (ms): " + (end_ts - start_ts) + "; BSM:" + newBsmReq.getId());
return HttpServletResponse.SC_OK;
}

Expand Down

0 comments on commit d5cd25c

Please sign in to comment.