Skip to content

Commit

Permalink
Only perform camera actions on plan phase change
Browse files Browse the repository at this point in the history
  • Loading branch information
DougLau committed Dec 12, 2024
1 parent c0328a8 commit 2fbefbe
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/us/mn/state/dot/tms/server/DeviceActionJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package us.mn.state.dot.tms.server;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import us.mn.state.dot.sched.DebugLog;
Expand Down Expand Up @@ -52,6 +53,10 @@ public class DeviceActionJob extends Job {
/** Logger for debugging */
private final DebugLog logger;

/** Set of deployed device actions */
private final HashSet<DeviceAction> dep_actions =
new HashSet<DeviceAction>();

/** Mapping of DMS to action tag messages */
private final HashMap<DMSImpl, ActionTagMsg> dms_actions =
new HashMap<DMSImpl, ActionTagMsg>();
Expand Down Expand Up @@ -97,9 +102,16 @@ private void processAction(ActionPlan ap, DeviceAction da) {
if (deploy)
performDmsAction(da);
performBeaconAction(da, deploy);
performCameraAction(da, deploy);
performLaneMarkingAction(da, deploy);
performRampMeterAction(da, deploy);
if (deploy) {
// Only perform camera actions on change
if (!dep_actions.contains(da)) {
performCameraAction(da);
dep_actions.add(da);
}
} else
dep_actions.remove(da);
}

/** Perform an action for DMS */
Expand Down Expand Up @@ -178,25 +190,22 @@ private void performBeaconAction(DeviceAction da, boolean deploy,
}

/** Perform an action for cameras */
private void performCameraAction(DeviceAction da, boolean deploy) {
// FIXME: only perform this action when phase is first changed
private void performCameraAction(DeviceAction da) {
Iterator<Camera> it = CameraHelper.iterator();
while (it.hasNext()) {
Camera c = it.next();
if (c instanceof CameraImpl)
performCameraAction(da, deploy, (CameraImpl) c);
performCameraAction(da, (CameraImpl) c);
}
}

/** Perform a camera action */
private void performCameraAction(DeviceAction da, boolean deploy,
CameraImpl cam)
{
private void performCameraAction(DeviceAction da, CameraImpl cam) {
Hashtags tags = new Hashtags(cam.getNotes());
if (tags.contains(da.getHashtag())) {
ActionTagMsg amsg = new ActionTagMsg(da, cam,
cam.getGeoLoc(), logger);
if (amsg.isPassing() && deploy) {
if (amsg.isPassing()) {
int preset_num = da.getMsgPriority();
if (preset_num == 0) {
cam.setDeviceReq(DeviceRequest.
Expand Down

0 comments on commit 2fbefbe

Please sign in to comment.