Community
Question: How to retrieve the latest alarm text as a string when a new alarm occurs?
Hi everyone,
We are working on a customer requirement where we need to retrieve the latest alarm text as a string whenever a new alarm occurs.
Currently, we are stuck at querying the latest alarm. We have written a query to fetch the most recent alarm text, but it is failing in the CTRL script with an error.
main()
{
//SELECT '_alert_hdl.._text' FROM '*' LAST 1
//SELECT ALERT '_alert_hdl.._text' FROM '*' LAST 1
string query = "SELECT ALERT '_alert_hdl.._text' FROM '*' LAST 1";
dpQueryConnectAll("_AlarmCallback", TRUE, 0, query);
}
void _AlarmCallback(anytype userData, dyn_dyn_anytype res)
{
if (dynlen(res) < 2)
{
return;
}
for (int i = 2; i <= dynlen(res); i++)
{
string dpName = res[i][1];
string state = res[i][2];
// if (state != "CAME")
// continue;
string alarmText;
dpGet(dpName + "._alert_hdl._text", alarmText);
if (alarmText != "")
{
DebugN("Alarm Text"+ alarmText);
}
}
}
Error is following
WCCOActrl (2), 2026.01.09 16:14:45.255, PARAM,SEVERE, 81, Syntax error, Query not successful: dpQueryConnectAll(SELECT ALERT...) not allowed
Any help or guidance would be greatly appreciated.
Thanks in advance.
Dhaval Abotiyawala