From 253e37c3c94a99be2d0e08e5ba31d475f94a43c4 Mon Sep 17 00:00:00 2001 From: "Lee, Jeong Han" Date: Thu, 24 Oct 2024 21:00:07 -0700 Subject: [PATCH 1/2] add latch&&enabled status to command as latched --- .../logging/ui/AlarmLogTableController.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java b/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java index dbdf48e6cc..51d0eef01f 100644 --- a/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java +++ b/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java @@ -1,6 +1,8 @@ package org.phoebus.applications.alarm.logging.ui; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.sun.jersey.api.client.WebResource; @@ -40,6 +42,7 @@ import org.phoebus.applications.alarm.AlarmSystem; import org.phoebus.applications.alarm.logging.ui.AlarmLogTableQueryUtil.Keys; import org.phoebus.applications.alarm.model.SeverityLevel; +import org.phoebus.applications.alarm.model.json.JsonModelReader; import org.phoebus.applications.alarm.ui.AlarmUI; import org.phoebus.framework.jobs.Job; import org.phoebus.framework.selection.SelectionService; @@ -249,7 +252,19 @@ protected void updateItem(String item, boolean empty) { if (!en) { return new SimpleStringProperty("Disabled"); } else { - return new SimpleStringProperty("Enabled"); + try { + final JsonNode jsonNode = (JsonNode) JsonModelReader.parseJsonText(alarmMessage.getValue().getConfig_msg()); + if (jsonNode == null) { + logger.log(Level.WARNING, "There is no JasonNode"); + return null; + } + final boolean latching = jsonNode.get("latching").asBoolean(); + return new SimpleStringProperty(latching ? "Latched" : "Enabled"); + } catch (JsonParseException e) { + logger.log(Level.SEVERE, "Error parsing JSON in alarmMesssage " + e.getMessage()); + } catch (Exception e) { + logger.log(Level.SEVERE, "Unexpected error in alarmMessage" + e.getMessage()); + } } } return null; From e98ae6791922e99ae9344bce918d565f6ecedb66 Mon Sep 17 00:00:00 2001 From: "Lee, Jeong Han" Date: Thu, 31 Oct 2024 23:48:08 -0700 Subject: [PATCH 2/2] simplified the json error handling for alarmLogTable --- .../alarm/logging/ui/AlarmLogTableController.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java b/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java index 51d0eef01f..26e88c1689 100644 --- a/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java +++ b/app/alarm/logging-ui/src/main/java/org/phoebus/applications/alarm/logging/ui/AlarmLogTableController.java @@ -1,7 +1,6 @@ package org.phoebus.applications.alarm.logging.ui; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; @@ -259,11 +258,9 @@ protected void updateItem(String item, boolean empty) { return null; } final boolean latching = jsonNode.get("latching").asBoolean(); - return new SimpleStringProperty(latching ? "Latched" : "Enabled"); - } catch (JsonParseException e) { - logger.log(Level.SEVERE, "Error parsing JSON in alarmMesssage " + e.getMessage()); + return new SimpleStringProperty(latching ? "Enabled:Latched" : "Enabled:Unlatch"); } catch (Exception e) { - logger.log(Level.SEVERE, "Unexpected error in alarmMessage" + e.getMessage()); + logger.log(Level.SEVERE, "Unexpected error in alarmMessage" + e); } } }