From 2fbefbe310bd4c854fc102e743ed70b9dd218336 Mon Sep 17 00:00:00 2001 From: Doug Lau Date: Thu, 12 Dec 2024 14:44:03 -0600 Subject: [PATCH] Only perform camera actions on plan phase change --- .../state/dot/tms/server/DeviceActionJob.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/us/mn/state/dot/tms/server/DeviceActionJob.java b/src/us/mn/state/dot/tms/server/DeviceActionJob.java index 4ee112380..b3b974487 100644 --- a/src/us/mn/state/dot/tms/server/DeviceActionJob.java +++ b/src/us/mn/state/dot/tms/server/DeviceActionJob.java @@ -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; @@ -52,6 +53,10 @@ public class DeviceActionJob extends Job { /** Logger for debugging */ private final DebugLog logger; + /** Set of deployed device actions */ + private final HashSet dep_actions = + new HashSet(); + /** Mapping of DMS to action tag messages */ private final HashMap dms_actions = new HashMap(); @@ -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 */ @@ -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 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.