diff --git a/SCADA_PERSPECTIVE_PARENT_PROJECT/com.inductiveautomation.perspective/views/Alarm-Views/RealTime/view.json b/SCADA_PERSPECTIVE_PARENT_PROJECT/com.inductiveautomation.perspective/views/Alarm-Views/RealTime/view.json index b034559..35d528a 100644 --- a/SCADA_PERSPECTIVE_PARENT_PROJECT/com.inductiveautomation.perspective/views/Alarm-Views/RealTime/view.json +++ b/SCADA_PERSPECTIVE_PARENT_PROJECT/com.inductiveautomation.perspective/views/Alarm-Views/RealTime/view.json @@ -656,187 +656,6 @@ "basis": "10px" }, "type": "ia.display.label" - }, - { - "custom": { - "alarms_to_shelve": [ - { - "style": { - "classes": "Alarms-Styles/Medium" - }, - "value": { - "Alarm_id": { - "value": 13 - }, - "Duration": { - "value": 10495 - }, - "Expiration": { - "value": { - "$": [ - "ts", - 0, - 1704730823344 - ], - "$ts": 0 - } - }, - "Message": { - "value": "Photo eye blocked" - }, - "Priority": { - "value": "3. Medium" - }, - "Shelve": { - "value": false - }, - "SourceId": { - "value": "PLC09/1210_07_44/B830_3" - }, - "State": { - "value": "Active" - }, - "Timestamp": { - "value": { - "$": [ - "ts", - 0, - 1704730823344 - ], - "$ts": 1704720394486 - } - }, - "Unshelve": { - "value": false - } - } - } - ] - }, - "events": { - "component": { - "onActionPerformed": { - "config": { - "script": "\t\n\tselected_alarms \u003d self.parent.parent.parent.getChild(\"FlexContainer_0\").getChild(\"Table\").props.selection.data\n\t\n\tif len(selected_alarms) \u003d\u003d 0:\n\t\tself.props.value \u003d None\n\t\treturn\n\t\n\tduration \u003d self.props.value \n\t\n\tif(duration):\n\t\tfor alarm in selected_alarms:\n\t\t\tsystem.alarm.shelve(alarm.value[\"Device\"], duration * 60) #60 - seconds.\n\t\t\n\t\tself.props.value \u003d None" - }, - "scope": "G", - "type": "script" - } - } - }, - "meta": { - "name": "Dropdown" - }, - "position": { - "basis": "120px" - }, - "propConfig": { - "props.enabled": { - "binding": { - "config": { - "path": "session.custom.fc" - }, - "enabled": false, - "transforms": [ - { - "code": "\twhid \u003d value.lower()\n\tWHID \u003d value.upper()\n\tsiterole \u003d \u0027Authenticated/Roles/rme-ignition-\u0027+whid+\u0027-alarm-shelving\u0027\n\tSITErole \u003d \u0027Authenticated/Roles/rme-ignition-\u0027+WHID+\u0027-alarm-shelving\u0027\n# Example: rme-ignition-BRS1-alarm-shelving\n\troles \u003d [\u0027Authenticated/Roles/eurme-ignition-admins\u0027, siterole, SITErole]\n\tauth \u003d system.perspective.isAuthorized(False, securityLevels\u003droles)\n\treturn auth", - "type": "script" - } - ], - "type": "property" - } - } - }, - "props": { - "options": [ - { - "label": "15 mins", - "value": 15 - }, - { - "label": "30 min", - "value": 30 - }, - { - "label": "45 min", - "value": 45 - }, - { - "label": "1 hr", - "value": 60 - }, - { - "label": "2 hr", - "value": 120 - }, - { - "label": "4 hr", - "value": 240 - }, - { - "label": "8 hr", - "value": 480 - }, - { - "label": "1 Day", - "value": 1440 - }, - { - "label": "2 Days", - "value": 2880 - }, - { - "label": "1 week", - "value": 10080 - }, - { - "label": "2 weeks", - "value": 20160 - }, - { - "label": "Out of Service", - "value": 263000 - } - ], - "placeholder": { - "color": "#000000", - "icon": { - "color": "#000000", - "path": "material/archive", - "style": { - "classes": "" - } - }, - "text": "Shelve" - }, - "search": { - "enabled": false - }, - "showClearIcon": true, - "style": { - "borderBottomLeftRadius": "5px", - "borderBottomRightRadius": "5px", - "borderTopLeftRadius": "5px", - "borderTopRightRadius": "5px", - "classes": "Dropdown/DropDownBox", - "margin": 15 - }, - "value": null - }, - "scripts": { - "customMethods": [], - "extensionFunctions": null, - "messageHandlers": [ - { - "messageType": "alarms-to-shelve", - "pageScope": true, - "script": "\t# implement your handler here\n\tself.custom.alarms_to_shelve \u003d payload", - "sessionScope": false, - "viewScope": true - } - ] - }, - "type": "ia.input.dropdown" } ], "meta": { @@ -880,11 +699,10 @@ }, "value": { "Description": "MCM01 Hello world", - "Device": "prov:MTN6_SIMULATION_SCADA_TAG_PROVIDER:/tag:System/MCM/MCM01/Beacon_Light:/alm:Hello world", - "Duration": "00:30:34", - "EventTimestamp": "2025-06-19 21:38:34", + "Duration": "00:50:24", + "EventTimestamp": "2025-06-20 15:07:03", "Location": "MCM01", - "NumberID": 57, + "NumberID": 35, "Priority": "Low", "Tag": "MCM01.HMI.Beacon_Light" } @@ -929,7 +747,7 @@ }, "onChange": { "enabled": null, - "script": "\tfrom system import date\n\t\n\ttag_provider \u003d \"[\" + self.session.custom.fc + \"_SCADA_TAG_PROVIDER]\"\n\n\t# Helper: format row for table\n\tdef testRow(eventTimeStamp, duration, location, priority, description, tag, color, numberId, device):\n\t\treturn {\n\t\t \"value\": {\n\t\t \"NumberID\": numberId,\n\t\t \"EventTimestamp\": eventTimeStamp,\n\t\t \"Duration\": duration,\n\t\t \"Priority\": priority,\n\t\t \"Location\": location,\n\t\t \"Description\": description,\n\t\t \"Tag\": tag,\n\t\t \"Device\": device\n\t\t },\n\t\t \"style\": {\n\t\t \"backgroundColor\": color,\n\t\t }\n\t\t}\n\t\n\t# Query active alarms\n\tresults \u003d system.alarm.queryStatus(state\u003d[\"ActiveUnacked\", \"ActiveAcked\"])\n\t\n\t# Build rows\n\tdata \u003d []\n\tcolor \u003d \"\"\n\tnumberID \u003d \"\"\n\t\n\tif(results \u003d\u003d0):\n\t\treturn\n\t\n\tfor i, alarm in enumerate(results):\n\t\tactiveTime \u003d alarm.eventTime\n\t\tOPCItemTag \u003d system.tag.read(tag_provider + alarm.myTag + \".OpcItemPath\").value\n\t\tparts \u003d OPCItemTag.split(\".\")\n\t\ttag \u003d str(alarm.displayPath) +\".\" + parts[1] + \".\" + parts[2]\n\t\t\n\t\t\n\n\ttry:\n\t query \u003d system.db.runQuery(\"SELECT id, eventtime FROM alarm_events WHERE eventid \u003d \" + \"\u0027\" + str(alarm.id) + \"\u0027\",\"MariaDB\")\n\t if(query):\n\t \tnumberID \u003d query[0][0]\n\t durationSeconds \u003d date.secondsBetween(activeTime, date.now())\n\t durationStr \u003d date.format(date.addSeconds(date.midnight(date.now()), durationSeconds), \"HH:mm:ss\")\n\t \n\t priority \u003d alarm.priority.toString()\n\t if priority \u003d\u003d \"High\":\n\t color \u003d \"#f45d56\"\n\t elif priority \u003d\u003d \"Medium\":\n\t color \u003d \"#d32f2f\"\n\t elif priority \u003d\u003d \"Low\":\n\t color \u003d \"#ffeb3b\"\n\t elif priority \u003d\u003d \"Diagnostic\":\n\t color \u003d \"#2196f3\"\n\t elif priority \u003d\u003d \"Critical\":\n\t color \u003d \"#b71c1c\"\n\t else:\n\t color \u003d \"#ffffff\"\n\t \n\t\tsystem.perspective.print(alarm.myTag)\n\t\tsystem.perspective.print(\"tag is printed\")\n\t \n#\t\tOPCItemTag \u003d system.tag.read(tag_provider + alarm.myTag).OpcItemPath\n\t\tself.session.custom.fc\n\t data.append(testRow(\n\t eventTimeStamp \u003d date.format(activeTime, \"yyyy-MM-dd HH:mm:ss\"),\n\t duration \u003d durationStr,\n\t location \u003d alarm.displayPath,\n\t numberId \u003d numberID,\n\t priority \u003d priority,\n\t description \u003d alarm.myLocation + \" \" + alarm.name,\n\t tag \u003d tag,\n\t color \u003d color,\n\t device \u003d alarm.source,\n\t ))\n\texcept:\n\t system.perspective.print(\"Something went wrong\")\n\t\n\tself.custom.rawData \u003d data" + "script": "\tfrom system import date\n\t\n\ttag_provider \u003d \"[\" + self.session.custom.fc + \"_SCADA_TAG_PROVIDER]\"\n\n\t# Helper: format row for table\n\tdef testRow(eventTimeStamp, duration, location, priority, description, tag, color, numberId):\n\t\treturn {\n\t\t \"value\": {\n\t\t \"NumberID\": numberId,\n\t\t \"EventTimestamp\": eventTimeStamp,\n\t\t \"Duration\": duration,\n\t\t \"Priority\": priority,\n\t\t \"Location\": location,\n\t\t \"Description\": description,\n\t\t \"Tag\": tag,\n\t\t },\n\t\t \"style\": {\n\t\t \"backgroundColor\": color,\n\t\t }\n\t\t}\n\t\n\t# Query active alarms\n\tresults \u003d system.alarm.queryStatus(state\u003d[\"ActiveUnacked\", \"ActiveAcked\"])\n\t\n\t# Build rows\n\tdata \u003d []\n\tcolor \u003d \"\"\n\tnumberID \u003d \"\"\n\tlcoation \u003d \"\"\n\t\n\tif(results \u003d\u003d0):\n\t\treturn\n\t\n\tfor i, alarm in enumerate(results):\n\t\tactiveTime \u003d alarm.eventTime\n\t\tmyTag \u003d alarm.myTag\n\t\tOPCItemTag \u003d system.tag.read(tag_provider + myTag + \".OpcItemPath\").value\n\t\tif(OPCItemTag):\t\t\n\t\t\tparts \u003d OPCItemTag.split(\".\")\n\t\t\ttag \u003d str(alarm.displayPath) +\".\" + parts[1] + \".\" + parts[2]\n\t\telse:\n\t\t\ttag \u003d \"Unknown tag\"\n\t\t\n\t\ttag_parts \u003d myTag.split(\"/\")\n\t\tif(tag_parts):\n\t\t\tlocation \u003d tag_parts[1] \n\t\telse:\n\t\t\tlocation \u003d \"Unknown Location\"\n\t\t\n\t\t\n\t\ttry:\n\t\t query \u003d system.db.runQuery(\"SELECT id, eventtime FROM alarm_events WHERE eventid \u003d \" + \"\u0027\" + str(alarm.id) + \"\u0027\",\"MariaDB\")\n\t\t if(query):\n\t\t \tnumberID \u003d query[0][0]\n\t\t durationSeconds \u003d date.secondsBetween(activeTime, date.now())\n\t\t durationStr \u003d date.format(date.addSeconds(date.midnight(date.now()), durationSeconds), \"HH:mm:ss\")\n\t\t \n\t\t priority \u003d alarm.priority.toString()\n\t\t if priority \u003d\u003d \"High\":\n\t\t color \u003d \"#f45d56\"\n\t\t elif priority \u003d\u003d \"Medium\":\n\t\t color \u003d \"#d32f2f\"\n\t\t elif priority \u003d\u003d \"Low\":\n\t\t color \u003d \"#ffeb3b\"\n\t\t elif priority \u003d\u003d \"Diagnostic\":\n\t\t color \u003d \"#2196f3\"\n\t\t elif priority \u003d\u003d \"Critical\":\n\t\t color \u003d \"#b71c1c\"\n\t\t else:\n\t\t color \u003d \"#ffffff\"\n\t\t \n\t\n\t\t data.append(testRow(\n\t\t eventTimeStamp \u003d date.format(activeTime, \"yyyy-MM-dd HH:mm:ss\"),\n\t\t duration \u003d durationStr,\n\t\t location \u003d location,\n\t\t numberId \u003d numberID,\n\t\t priority \u003d priority,\n\t\t description \u003d alarm.myLocation + \" \" + alarm.name,\n\t\t tag \u003d tag,\n\t\t color \u003d color,\n\t\t ))\n\t\texcept:\n\t\t\tpass\n\t\n\tself.custom.rawData \u003d data" } } }, @@ -1485,7 +1303,7 @@ "viewParams": {}, "viewPath": "", "visible": true, - "width": 100 + "width": 150 }, { "align": "center", @@ -1577,7 +1395,7 @@ "viewParams": {}, "viewPath": "", "visible": true, - "width": 150 + "width": 80 } ], "emptyMessage": { @@ -1622,75 +1440,56 @@ { "children": [ { - "children": [ - { - "events": { - "component": { - "onActionPerformed": { - "config": { - "script": "\n\tselected_alarms \u003d self.parent.parent.parent.getChild(\"FlexContainer_0\").getChild(\"AlarmsTable\").props.selection.data\n\tif len(selected_alarms) \u003d\u003d 0:\n\t\treturn\n\t\n\t# Unshelve selected alarms\n\tfor alarm in selected_alarms:\n\t\tsystem.alarm.unshelve(alarm[\u0027path\u0027])\n\t\t\n\tpaths_to_remove \u003d {alarm[\u0027path\u0027] for alarm in selected_alarms}\n\t\n\tshelved_alarms \u003d self.parent.parent.parent.parent.parent.getChild(\"TabContainer\").custom.shelvedAlarms\n\t\t\n\tif shelved_alarms is not None:\n\t\tremaining_data \u003d [a for a in shelved_alarms if a[\u0027path\u0027] not in paths_to_remove]\n\t\t\n\tself.parent.parent.parent.parent.parent.getChild(\"TabContainer\").custom.shelvedAlarms \u003d remaining_data" - }, - "scope": "G", - "type": "script" - } - } - }, - "meta": { - "name": "Button" - }, - "position": { - "basis": "153px" - }, - "props": { - "image": { - "icon": { - "color": "#000000", - "path": "material/archive" - } + "events": { + "component": { + "onActionPerformed": { + "config": { + "script": "\ttry:\n\t # Get dataset from table\n\t data \u003d self.parent.parent.getChild(\"FlexContainer_0\").getChild(\"AlarmsTable\").props.data\n\t\n\t # CSV header\n\t csv_content \u003d \"First Timestamp,Last Timestamp,Count,Duration,Priority,Location,Description,Tag\\n\"\n\t\n\t if data and data.getRowCount() \u003e 0:\n\t for i in range(data.getRowCount()):\n\t duration_raw \u003d data.getValueAt(i, \"Duration\")\n\t duration_str \u003d str(duration_raw) if duration_raw is not None else \"\"\n\t row_data \u003d [\n\t str(data.getValueAt(i, \"FirstTimestamp\") or \"\"),\n\t str(data.getValueAt(i, \"LastTimestamp\") or \"\"),\n\t str(data.getValueAt(i, \"Count\") or \"\"),\n\t duration_str,\n\t str(data.getValueAt(i, \"Priority\") or \"\"),\n\t str(data.getValueAt(i, \"Location\") or \"\"),\n\t str(data.getValueAt(i, \"Description\") or \"\"),\n\t str(data.getValueAt(i, \"Tag\") or \"\")\n\t ]\n\t\n\t # Escape commas for CSV safety\n\t row_data \u003d [field.replace(\",\", \";\") for field in row_data]\n\t csv_content +\u003d \",\".join(row_data) + \"\\n\"\n\t else:\n\t csv_content +\u003d \"No alarms in current view\\n\"\n\t\n\texcept Exception as e:\n\t system.perspective.print(\"Error during CSV export: \" + str(e))\n\t csv_content \u003d \"Error exporting alarm data\\n\"\n\t\n\t# Convert to bytes and trigger download\n\tcsv_bytes \u003d csv_content.encode(\u0027utf-8\u0027)\n\tsystem.perspective.download(\"active_alarms.csv\", csv_bytes)\n " }, - "style": { - "classes": "Dropdown/DropDownBox" - }, - "text": "Unshelve", - "value": "" - }, - "scripts": { - "customMethods": [], - "extensionFunctions": null, - "messageHandlers": [ - { - "messageType": "alarms-to-shelve", - "pageScope": true, - "script": "\t# implement your handler here\n\tself.props.enabled \u003d True\n\tself.custom.alarms_to_shelve \u003d payload", - "sessionScope": false, - "viewScope": true - } - ] - }, - "type": "ia.input.button" + "scope": "G", + "type": "script" + } } - ], + }, "meta": { - "name": "FlexContainer_0" + "name": "Button_1" }, "position": { - "basis": "450px", - "shrink": 0 + "basis": "120px" }, "props": { + "image": { + "icon": { + "path": "material/import_export" + } + }, + "primary": false, "style": { - "padding": 5 - } + "margin": 15 + }, + "text": "Export" }, - "type": "ia.container.flex" + "scripts": { + "customMethods": [], + "extensionFunctions": null, + "messageHandlers": [ + { + "messageType": "button-severity-indicator", + "pageScope": true, + "script": "\tbackground \u003d \"false\"\n\tseverity \u003d payload[\"severity\"]\n\tbutton_severity \u003d self.custom.Severity\n\tif severity \u003d\u003d button_severity:\n\t\tbackground \u003d \"true\"\n\telse:\n\t\tbackground \u003d \"false\"\n\t\n\tself.custom.background_on \u003d background", + "sessionScope": false, + "viewScope": false + } + ] + }, + "type": "ia.input.button" } ], "meta": { "name": "FlexContainer" }, "position": { - "basis": "40px", - "shrink": 0 + "basis": "70px" }, "props": { "alignContent": "flex-start", @@ -1714,15 +1513,13 @@ "props.data": { "binding": { "config": { - "path": "...../TabContainer.custom.shelvedAlarms" + "polling": { + "enabled": true, + "rate": "5" + }, + "queryPath": "GetAlarmsWithCount" }, - "transforms": [ - { - "code": " data \u003d []\n for row in value: \n keys \u003d row.keys() \n if row[\"priority\"] \u003d\u003d \"High\": \n style \u003d {\"backgroundColor\": \"#fd6059\"} \n elif row[\"priority\"] \u003d\u003d \"Low\": \n style \u003d {\"backgroundColor\": \"#fafa6c\"} \n elif row[\"priority\"] \u003d\u003d \"Diagnostic\": \n style \u003d {\"backgroundColor\": \"#5da0f9\"} \n elif row[\"priority\"] \u003d\u003d \"Medium\": \n style \u003d {\"backgroundColor\": \"#fca25f\"} \n elif row[\"priority\"] \u003d\u003d \"Critical\": \n style \u003d {\"backgroundColor\": \"#c86462\"} \n else:\n style \u003d {\"backgroundColor\": \"\"}\n \n formatted_rows \u003d [{\"value\": v, \"style\": style} for v in row.values()]\n \n row_dict \u003d dict(zip(keys, formatted_rows))\n data.append(row_dict)\n return data ", - "type": "script" - } - ], - "type": "property" + "type": "query" } }, "props.editingCell": { @@ -1740,9 +1537,9 @@ { "align": "center", "boolean": "checkbox", - "dateFormat": "none", + "dateFormat": "MM/DD/YYYY HH:mm:ss", "editable": false, - "field": "Description", + "field": "FirstTimestamp", "filter": { "boolean": { "condition": "" @@ -1777,9 +1574,9 @@ "backgroundColor": "#FFFEFE", "classes": "" }, - "title": "" + "title": "First Timestamp" }, - "justify": "auto", + "justify": "left", "nullFormat": { "includeNullStrings": false, "nullFormatValue": "", @@ -1835,7 +1632,7 @@ "boolean": "value", "dateFormat": "MM-DD-YYYY HH:mm:ss", "editable": false, - "field": "path", + "field": "LastTimestamp", "filter": { "boolean": { "condition": "" @@ -1865,11 +1662,11 @@ }, "header": { "align": "center", - "justify": "left", + "justify": "center", "style": { "classes": "" }, - "title": "Start Timestamp" + "title": "Last Timestamp" }, "justify": "center", "nullFormat": { @@ -1927,7 +1724,7 @@ "boolean": "checkbox", "dateFormat": "MM-DD-YYYY HH:mm:ss", "editable": false, - "field": "activeTime", + "field": "Count", "filter": { "boolean": { "condition": "" @@ -1961,7 +1758,7 @@ "style": { "classes": "" }, - "title": "Active Time" + "title": "" }, "justify": "center", "nullFormat": { @@ -2019,7 +1816,7 @@ "boolean": "checkbox", "dateFormat": "none", "editable": false, - "field": "expirationTime", + "field": "Duration", "filter": { "boolean": { "condition": "" @@ -2053,7 +1850,7 @@ "style": { "classes": "" }, - "title": "Expiration Time" + "title": "" }, "justify": "center", "nullFormat": { @@ -2109,9 +1906,9 @@ { "align": "center", "boolean": "checkbox", - "dateFormat": "none", + "dateFormat": "MM/DD/YYYY", "editable": false, - "field": "priority", + "field": "Priority", "filter": { "boolean": { "condition": "" @@ -2151,7 +1948,283 @@ "nullFormat": { "includeNullStrings": false, "nullFormatValue": "", - "strict": true + "strict": false + }, + "number": "value", + "numberFormat": "0,0.##", + "progressBar": { + "bar": { + "color": "", + "style": { + "classes": "" + } + }, + "max": 100, + "min": 0, + "track": { + "color": "", + "style": { + "classes": "" + } + }, + "value": { + "enabled": true, + "format": "0,0.##", + "justify": "center", + "style": { + "classes": "" + } + } + }, + "render": "auto", + "resizable": true, + "sort": "none", + "sortable": true, + "strictWidth": false, + "style": { + "classes": "" + }, + "toggleSwitch": { + "color": { + "selected": "", + "unselected": "" + } + }, + "viewParams": {}, + "viewPath": "", + "visible": true, + "width": "" + }, + { + "align": "center", + "boolean": "checkbox", + "dateFormat": "MM/DD/YYYY", + "editable": false, + "field": "Location", + "filter": { + "boolean": { + "condition": "" + }, + "date": { + "condition": "", + "value": "" + }, + "enabled": false, + "number": { + "condition": "", + "value": "" + }, + "string": { + "condition": "", + "value": "" + }, + "visible": "on-hover" + }, + "footer": { + "align": "center", + "justify": "left", + "style": { + "classes": "" + }, + "title": "" + }, + "header": { + "align": "center", + "justify": "center", + "style": { + "classes": "" + }, + "title": "" + }, + "justify": "center", + "nullFormat": { + "includeNullStrings": false, + "nullFormatValue": "", + "strict": false + }, + "number": "value", + "numberFormat": "0,0.##", + "progressBar": { + "bar": { + "color": "", + "style": { + "classes": "" + } + }, + "max": 100, + "min": 0, + "track": { + "color": "", + "style": { + "classes": "" + } + }, + "value": { + "enabled": true, + "format": "0,0.##", + "justify": "center", + "style": { + "classes": "" + } + } + }, + "render": "auto", + "resizable": true, + "sort": "none", + "sortable": true, + "strictWidth": false, + "style": { + "classes": "" + }, + "toggleSwitch": { + "color": { + "selected": "", + "unselected": "" + } + }, + "viewParams": {}, + "viewPath": "", + "visible": true, + "width": "" + }, + { + "align": "center", + "boolean": "checkbox", + "dateFormat": "MM/DD/YYYY", + "editable": false, + "field": "Description", + "filter": { + "boolean": { + "condition": "" + }, + "date": { + "condition": "", + "value": "" + }, + "enabled": false, + "number": { + "condition": "", + "value": "" + }, + "string": { + "condition": "", + "value": "" + }, + "visible": "on-hover" + }, + "footer": { + "align": "center", + "justify": "left", + "style": { + "classes": "" + }, + "title": "" + }, + "header": { + "align": "center", + "justify": "center", + "style": { + "classes": "" + }, + "title": "" + }, + "justify": "center", + "nullFormat": { + "includeNullStrings": false, + "nullFormatValue": "", + "strict": false + }, + "number": "value", + "numberFormat": "0,0.##", + "progressBar": { + "bar": { + "color": "", + "style": { + "classes": "" + } + }, + "max": 100, + "min": 0, + "track": { + "color": "", + "style": { + "classes": "" + } + }, + "value": { + "enabled": true, + "format": "0,0.##", + "justify": "center", + "style": { + "classes": "" + } + } + }, + "render": "auto", + "resizable": true, + "sort": "none", + "sortable": true, + "strictWidth": false, + "style": { + "classes": "" + }, + "toggleSwitch": { + "color": { + "selected": "", + "unselected": "" + } + }, + "viewParams": {}, + "viewPath": "", + "visible": true, + "width": 150 + }, + { + "align": "center", + "boolean": "checkbox", + "dateFormat": "MM/DD/YYYY", + "editable": false, + "field": "Tag", + "filter": { + "boolean": { + "condition": "" + }, + "date": { + "condition": "", + "value": "" + }, + "enabled": false, + "number": { + "condition": "", + "value": "" + }, + "string": { + "condition": "", + "value": "" + }, + "visible": "on-hover" + }, + "footer": { + "align": "center", + "justify": "left", + "style": { + "classes": "" + }, + "title": "" + }, + "header": { + "align": "center", + "justify": "center", + "style": { + "classes": "" + }, + "title": "" + }, + "justify": "center", + "nullFormat": { + "includeNullStrings": false, + "nullFormatValue": "", + "strict": false }, "number": "value", "numberFormat": "0,0.##", @@ -2204,8 +2277,25 @@ "text": "No Shelved Alarms" } }, + "filter": { + "enabled": true + }, "selection": { - "mode": "multiple interval" + "data": [ + { + "Count": 8, + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:02:08", + "FirstTimestamp": 1750417519000, + "LastTimestamp": 1750417548000, + "Location": "MCM01", + "Priority": "High", + "Tag": "FL2078_2_VFD1.HMI.Voltage" + } + ], + "mode": "multiple interval", + "selectedColumn": "Duration", + "selectedRow": 1 } }, "type": "ia.display.table" @@ -2222,7 +2312,7 @@ } ], "meta": { - "name": "Shelved tab" + "name": "Hit_List" }, "position": { "tabIndex": 1 @@ -2344,17 +2434,17 @@ "$": [ "ts", 192, - 1750354615331 + 1750417660924 ], - "$ts": 1750354615331 + "$ts": 1750417660924 }, "startDate": { "$": [ "ts", 192, - 1750354615331 + 1750417660924 ], - "$ts": 1750352815331 + "$ts": 1750414060924 } }, "meta": { @@ -2527,7 +2617,7 @@ } }, "props": { - "formattedValue": "Jun 19, 2025 9:06 PM", + "formattedValue": "Jun 20, 2025 2:07 PM", "style": { "margin": 15 } @@ -2612,7 +2702,7 @@ } }, "props": { - "formattedValue": "Jun 19, 2025 9:36 PM", + "formattedValue": "Jun 20, 2025 3:07 PM", "maxDate": { "$": [ "ts", @@ -2627,10 +2717,10 @@ "value": { "$": [ "ts", - 201, - 1750354615331 + 192, + 1750417660924 ], - "$ts": 1750354615331 + "$ts": 1750417660924 } }, "scripts": { @@ -2820,17 +2910,17 @@ "$": [ "ts", 192, - 1750356548213 + 1750417660924 ], - "$ts": 1750352815331 + "$ts": 1750414060924 }, "time_to_filter": { "$": [ "ts", 192, - 1750356548213 + 1750417660924 ], - "$ts": 1750354615331 + "$ts": 1750417660924 } }, "meta": { @@ -3633,83 +3723,483 @@ "data": [ { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 35, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 29, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" }, { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 36, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 30, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" }, { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 35, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 29, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" }, { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 36, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 30, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" }, { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 35, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 29, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" }, { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 36, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 30, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" }, { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 35, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 29, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" }, { "Description": "MCM01 - Hello world", - "Duration": "00:00:42", - "EndTimestamp": 1750354587000, - "ID": 36, + "Duration": "00:00:06", + "EndTimestamp": 1750417622000, + "ID": 30, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354545000, + "StartTimestamp": 1750417616000, "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 25, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 26, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 25, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 26, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 25, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 26, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 25, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:16", + "EndTimestamp": 1750417611000, + "ID": 26, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417595000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 21, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 22, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 21, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 22, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 21, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 22, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 21, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:07", + "EndTimestamp": 1750417592000, + "ID": 22, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417585000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 17, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 18, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 17, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 18, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 17, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 18, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 17, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "MCM01 - Hello world", + "Duration": "00:00:05", + "EndTimestamp": 1750417582000, + "ID": 18, + "MCM": "MCM01", + "Priority": "Low", + "StartTimestamp": 1750417577000, + "Tag": "MCM01.HMI.Beacon_Light" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 11, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 12, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 11, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 12, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 11, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 12, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 11, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:07", + "EndTimestamp": 1750417555000, + "ID": 12, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417548000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 5, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 6, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 5, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 6, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 5, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 6, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 5, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" + }, + { + "Description": "FL2078_2_VFD1 - Alarm", + "Duration": "00:00:25", + "EndTimestamp": 1750417544000, + "ID": 6, + "MCM": "FL2078_2_VFD1", + "Priority": "High", + "StartTimestamp": 1750417519000, + "Tag": "FL2078_2_VFD1.HMI.Voltage" } ], "enabled": true @@ -3722,12 +4212,12 @@ "data": [ { "Description": "MCM01 - Hello world", - "Duration": "00:00:02", - "EndTimestamp": 1750354703000, - "ID": 47, + "Duration": "00:24:34", + "EndTimestamp": null, + "ID": 35, "MCM": "MCM01", "Priority": "Low", - "StartTimestamp": 1750354701000, + "StartTimestamp": 1750417623000, "Tag": "MCM01.HMI.Beacon_Light" } ], @@ -3857,17 +4347,17 @@ "$": [ "ts", 192, - 1750356548213 + 1750417660924 ], - "$ts": 1750352815331 + "$ts": 1750414060924 }, "time_to_filter": { "$": [ "ts", 192, - 1750356548213 + 1750417660924 ], - "$ts": 1750354615331 + "$ts": 1750417660924 }, "type_filters": null }, @@ -4124,6 +4614,7 @@ "contentStyle": { "classes": "Background-Styles/Grey-Background" }, + "currentTabIndex": 1, "menuType": "modern", "style": { "classes": "Background-Styles/Grey-Background" @@ -4156,7 +4647,7 @@ }, "tabs": [ "Active Alarms", - "Shelved Alarms", + "ALarm Hit List", "Historical" ] }, diff --git a/SCADA_PERSPECTIVE_PARENT_PROJECT/ignition/named-query/GetAlarmsWithCount/query.sql b/SCADA_PERSPECTIVE_PARENT_PROJECT/ignition/named-query/GetAlarmsWithCount/query.sql new file mode 100644 index 0000000..28a2e21 --- /dev/null +++ b/SCADA_PERSPECTIVE_PARENT_PROJECT/ignition/named-query/GetAlarmsWithCount/query.sql @@ -0,0 +1,58 @@ +SELECT + CONCAT(Active.displaypath, ' - ', SUBSTRING_INDEX(Active.source, ':/alm:', -1)) AS Description, + + SUBSTRING_INDEX(SUBSTRING_INDEX(aed.strValue, '/', 2), '/', -1) AS Location, + + -- Formatted OPC-style tag + CONCAT( + Active.displaypath, + '.HMI.', + SUBSTRING_INDEX(aed.strValue, '/', -1) + ) AS Tag, + + CASE Active.priority + WHEN 0 THEN 'Diagnostic' + WHEN 1 THEN 'Low' + WHEN 2 THEN 'Medium' + WHEN 3 THEN 'High' + WHEN 4 THEN 'Critical' + ELSE 'Unknown' + END AS Priority, + + -- First and last seen times for this alarm + MIN(Active.eventtime) AS FirstTimestamp, + MAX(Active.eventtime) AS LastTimestamp, + + -- Total duration summed from each active-clear pair + CONCAT( + LPAD(FLOOR(SUM(Active.duration_seconds) / 3600), 2, '0'), ':', + LPAD(FLOOR((SUM(Active.duration_seconds) % 3600) / 60), 2, '0'), ':', + LPAD(SUM(Active.duration_seconds) % 60, 2, '0') + ) AS Duration, + + -- Total number of activations + COUNT(*) AS Count + +FROM ( + SELECT + ae.id, + ae.source, + ae.eventid, + ae.eventtime, + ae.priority, + ae.displaypath, + TIMESTAMPDIFF(SECOND, ae.eventtime, COALESCE(ae_clear.eventtime, NOW())) AS duration_seconds + FROM alarm_events ae + LEFT JOIN alarm_events ae_clear + ON ae.eventid = ae_clear.eventid AND ae_clear.eventtype = 1 + WHERE ae.eventtype = 0 +) AS Active + +-- OPC tag path for building .hmi.Tag output +LEFT JOIN alarm_event_data aed + ON aed.id = Active.id AND aed.propname = 'myTag' + +-- 🔹 Group by the full unique alarm key (tag + alarm name) +GROUP BY Active.source, Active.displaypath, aed.strValue + +ORDER BY FirstTimestamp DESC;