Merge pull request 'Showing alarms on the controller statuses' (#139) from guga into main
Reviewed-on: #139
This commit is contained in:
commit
ce35a82503
@ -1,15 +1,9 @@
|
|||||||
{
|
{
|
||||||
"custom": {},
|
"custom": {},
|
||||||
"params": {
|
"params": {
|
||||||
"Counts": {
|
|
||||||
"Diag": 0,
|
|
||||||
"High": 0,
|
|
||||||
"Low": 0,
|
|
||||||
"Medium": 0
|
|
||||||
},
|
|
||||||
"Status": "",
|
"Status": "",
|
||||||
"tagProps": [
|
"tagProps": [
|
||||||
"PLC03",
|
"MCM01",
|
||||||
"value",
|
"value",
|
||||||
"value",
|
"value",
|
||||||
"value",
|
"value",
|
||||||
@ -22,10 +16,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"propConfig": {
|
"propConfig": {
|
||||||
"params.Counts": {
|
|
||||||
"paramDirection": "input",
|
|
||||||
"persistent": true
|
|
||||||
},
|
|
||||||
"params.Status": {
|
"params.Status": {
|
||||||
"paramDirection": "input",
|
"paramDirection": "input",
|
||||||
"persistent": true
|
"persistent": true
|
||||||
@ -39,8 +29,7 @@
|
|||||||
"defaultSize": {
|
"defaultSize": {
|
||||||
"height": 212,
|
"height": 212,
|
||||||
"width": 336
|
"width": 336
|
||||||
},
|
}
|
||||||
"key": "value"
|
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"children": [
|
"children": [
|
||||||
@ -385,9 +374,26 @@
|
|||||||
"position": {
|
"position": {
|
||||||
"basis": "25px"
|
"basis": "25px"
|
||||||
},
|
},
|
||||||
|
"propConfig": {
|
||||||
|
"props.color": {
|
||||||
|
"binding": {
|
||||||
|
"config": {
|
||||||
|
"path": "/root.custom.counts"
|
||||||
|
},
|
||||||
|
"transforms": [
|
||||||
|
{
|
||||||
|
"code": "\tfor v in value.values():\n\t\tif v \u003e 0:\n\t\t\treturn \"red\"\n\treturn \"\"",
|
||||||
|
"type": "script"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "property"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"props": {
|
"props": {
|
||||||
"path": "material/notifications_active",
|
"path": "material/notifications_active",
|
||||||
"style": {
|
"style": {
|
||||||
|
"classes": "",
|
||||||
"marginLeft": 10
|
"marginLeft": 10
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -524,7 +530,7 @@
|
|||||||
"basis": "32px"
|
"basis": "32px"
|
||||||
},
|
},
|
||||||
"props": {
|
"props": {
|
||||||
"text": 0,
|
"text": 2,
|
||||||
"textStyle": {
|
"textStyle": {
|
||||||
"fontSize": 10,
|
"fontSize": 10,
|
||||||
"textAlign": "center"
|
"textAlign": "center"
|
||||||
@ -582,7 +588,7 @@
|
|||||||
"basis": "32px"
|
"basis": "32px"
|
||||||
},
|
},
|
||||||
"props": {
|
"props": {
|
||||||
"text": 0,
|
"text": 3,
|
||||||
"textStyle": {
|
"textStyle": {
|
||||||
"fontSize": 10,
|
"fontSize": 10,
|
||||||
"textAlign": "center"
|
"textAlign": "center"
|
||||||
@ -611,7 +617,7 @@
|
|||||||
"basis": "32px"
|
"basis": "32px"
|
||||||
},
|
},
|
||||||
"props": {
|
"props": {
|
||||||
"text": 0,
|
"text": 1,
|
||||||
"textStyle": {
|
"textStyle": {
|
||||||
"fontSize": 10,
|
"fontSize": 10,
|
||||||
"textAlign": "center"
|
"textAlign": "center"
|
||||||
@ -640,7 +646,7 @@
|
|||||||
"basis": "32px"
|
"basis": "32px"
|
||||||
},
|
},
|
||||||
"props": {
|
"props": {
|
||||||
"text": 0,
|
"text": 6,
|
||||||
"textStyle": {
|
"textStyle": {
|
||||||
"fontSize": 10,
|
"fontSize": 10,
|
||||||
"textAlign": "center"
|
"textAlign": "center"
|
||||||
@ -704,7 +710,11 @@
|
|||||||
],
|
],
|
||||||
"custom": {
|
"custom": {
|
||||||
"counts": {
|
"counts": {
|
||||||
"Critical": 0
|
"Critical": 0,
|
||||||
|
"Diagnostic": 1,
|
||||||
|
"High": 2,
|
||||||
|
"Low": 3,
|
||||||
|
"Medium": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"events": {
|
"events": {
|
||||||
@ -752,38 +762,6 @@
|
|||||||
"script": "\tsystem.perspective.sendMessage(\"update-alarm-count\", self.custom.counts, \"view\")"
|
"script": "\tsystem.perspective.sendMessage(\"update-alarm-count\", self.custom.counts, \"view\")"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"custom.counts.Diagnostic": {
|
|
||||||
"binding": {
|
|
||||||
"config": {
|
|
||||||
"path": "view.params.Counts.Diag"
|
|
||||||
},
|
|
||||||
"type": "property"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"custom.counts.High": {
|
|
||||||
"binding": {
|
|
||||||
"config": {
|
|
||||||
"path": "view.params.Counts.High"
|
|
||||||
},
|
|
||||||
"type": "property"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"custom.counts.Low": {
|
|
||||||
"binding": {
|
|
||||||
"config": {
|
|
||||||
"path": "view.params.Counts.Low"
|
|
||||||
},
|
|
||||||
"type": "property"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"custom.counts.Medium": {
|
|
||||||
"binding": {
|
|
||||||
"config": {
|
|
||||||
"path": "view.params.Counts.Medium"
|
|
||||||
},
|
|
||||||
"type": "property"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"custom.plc_dict": {
|
"custom.plc_dict": {
|
||||||
"binding": {
|
"binding": {
|
||||||
"config": {
|
"config": {
|
||||||
@ -867,6 +845,22 @@
|
|||||||
"type": "expr"
|
"type": "expr"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"custom.table": {
|
||||||
|
"binding": {
|
||||||
|
"config": {
|
||||||
|
"polling": {
|
||||||
|
"enabled": true,
|
||||||
|
"rate": "3"
|
||||||
|
},
|
||||||
|
"queryPath": "GetActiveAlarmsByLocationAndPriority"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
},
|
||||||
|
"onChange": {
|
||||||
|
"enabled": null,
|
||||||
|
"script": "\ttry:\n\t\tMCM \u003d self.view.params.tagProps[0]\n\t\tdata \u003d currentValue.value\n\t\t\n\t\t# Convert dataset to PyDataSet\n\t\trows \u003d system.dataset.toPyDataSet(data)\n\t\t\n\t\t# Initialize counts dictionary with first-letter uppercase keys\n\t\tcounts \u003d {\n\t\t\t\"Low\": 0,\n\t\t\t\"Medium\": 0,\n\t\t\t\"High\": 0,\n\t\t\t\"Critical\": 0,\n\t\t\t\"Diagnostic\": 0\n\t\t}\n\t\t\n\t\t# Loop through rows and filter for current MCM\n\t\tfor row in rows:\n\t\t\tif row[\"Location\"] \u003d\u003d MCM:\n\n\t\t\t\tpriority \u003d row[\"Priority\"].capitalize()\n\t\t\t\tif priority in counts:\n\t\t\t\t\tcounts[priority] \u003d row[\"Count\"]\n\t\t\n\t\tself.custom.counts \u003d counts\n\t\n\texcept Exception as e:\n\t\tsystem.perspective.print(\"Error gaq dzma: \" + str(e))"
|
||||||
|
}
|
||||||
|
},
|
||||||
"meta.visible": {
|
"meta.visible": {
|
||||||
"binding": {
|
"binding": {
|
||||||
"config": {
|
"config": {
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
WITH Active AS (
|
||||||
|
SELECT
|
||||||
|
ae.id,
|
||||||
|
ae.eventid,
|
||||||
|
ae.priority,
|
||||||
|
aed.strValue
|
||||||
|
FROM alarm_events ae
|
||||||
|
LEFT JOIN alarm_event_data aed ON ae.id = aed.id AND aed.propname = 'myTag'
|
||||||
|
WHERE ae.eventtype = 0
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM alarm_events ae_clear
|
||||||
|
WHERE ae_clear.eventid = ae.eventid
|
||||||
|
AND ae_clear.eventtype = 1
|
||||||
|
)
|
||||||
|
AND ae.displaypath NOT LIKE '%System Startup%'
|
||||||
|
AND ae.source NOT LIKE '%System Startup%'
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
SUBSTRING_INDEX(SUBSTRING_INDEX(strValue, '/', 2), '/', -1) AS Location,
|
||||||
|
CASE 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,
|
||||||
|
COUNT(*) AS Count
|
||||||
|
FROM Active
|
||||||
|
GROUP BY Location, Priority
|
||||||
|
ORDER BY Location, Priority;
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"scope": "DG",
|
||||||
|
"version": 2,
|
||||||
|
"restricted": false,
|
||||||
|
"overridable": true,
|
||||||
|
"files": [
|
||||||
|
"query.sql"
|
||||||
|
],
|
||||||
|
"attributes": {
|
||||||
|
"useMaxReturnSize": false,
|
||||||
|
"autoBatchEnabled": false,
|
||||||
|
"fallbackValue": "",
|
||||||
|
"maxReturnSize": 100,
|
||||||
|
"cacheUnit": "SEC",
|
||||||
|
"type": "Query",
|
||||||
|
"enabled": true,
|
||||||
|
"cacheAmount": 1,
|
||||||
|
"cacheEnabled": false,
|
||||||
|
"database": "MariaDB",
|
||||||
|
"fallbackEnabled": false,
|
||||||
|
"lastModificationSignature": "94fffb6faeb095a088fead98d0743ff496268e71ad69c230d96ceea1d12444a7",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"zone": "default",
|
||||||
|
"role": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"lastModification": {
|
||||||
|
"actor": "admin",
|
||||||
|
"timestamp": "2025-06-24T11:14:20Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user