Merge pull request 'Fixed: alarms weren't showing in the command control view' (#153) from guga into main

Reviewed-on: #153
This commit is contained in:
gigi.mamaladze 2025-07-02 11:52:46 +00:00
commit fef771d42f

View File

@ -7,6 +7,45 @@
"Low": 0,
"Medium": 0,
"Total": 0
},
"totalAlarms": {
"$": [
"ds",
192,
1751448128142
],
"$columns": [
{
"data": [
"MCM01",
"MCM01",
"MCM01",
"MCM02"
],
"name": "Location",
"type": "String"
},
{
"data": [
"Diagnostic",
"High",
"Medium",
"Diagnostic"
],
"name": "Priority",
"type": "String"
},
{
"data": [
1,
2,
1,
1
],
"name": "Count",
"type": "Long"
}
]
}
},
"params": {
@ -30,14 +69,13 @@
"binding": {
"config": {
"struct": {
"PLC": "{view.params.value.tagProps[0]}",
"device_count": "tag(\u0027[\u0027+ {session.custom.fc} +\u0027_SCADA_TAG_PROVIDER]System/device_count\u0027)"
"PLC": "{view.params.value.tagProps[0]}"
},
"waitOnAll": true
},
"transforms": [
{
"code": "\tcount_dict \u003d system.util.jsonDecode(value.device_count)\n\tvalues \u003d count_dict.get(value.PLC)\n\tif values !\u003d None:\n\t\tvalues[\u0027Total\u0027] \u003d values[\u0027Critical\u0027] + values[\u0027High\u0027] + values[\u0027Medium\u0027] + values[\u0027Low\u0027] + values[\u0027Diagnostic\u0027]\n\t\treturn values\n\telse:\n\t\treturn {\"Critical\":0,\"High\":0,\"Medium\":0,\"Low\":0,\"Diagnostic\":0, \"Total\":0}",
"code": " MCM \u003d value.PLC\n queryData \u003d self.custom.totalAlarms\n\n # Initialize counts\n counts \u003d {\n \"Critical\": 0,\n \"High\": 0,\n \"Medium\": 0,\n \"Low\": 0,\n \"Diagnostic\": 0,\n \"Total\": 0\n }\n\n # Loop through dataset and aggregate\n for row in range(queryData.rowCount):\n mcm_val \u003d queryData.getValueAt(row, 0)\n severity \u003d queryData.getValueAt(row, 1)\n count \u003d queryData.getValueAt(row, 2)\n\n if mcm_val \u003d\u003d MCM:\n \n key \u003d severity.capitalize()\n if key in counts:\n counts[key] +\u003d count\n counts[\"Total\"] +\u003d count\n\n return counts",
"type": "script"
}
],
@ -45,6 +83,15 @@
},
"persistent": true
},
"custom.totalAlarms": {
"binding": {
"config": {
"queryPath": "GetActiveAlarmsByLocationAndPriority"
},
"type": "query"
},
"persistent": true
},
"params.value": {
"paramDirection": "input",
"persistent": true