EcoStruxure Geo SCADA Expert Forum
Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-10-26 02:46 AM . Last Modified: 2023-05-03 12:38 AM
>>Message imported from previous forum - Category:Scripts and Tips<<
User: admin, originally posted: 2018-10-19 19:26:28 Id:158
This is a re-posting from the obsoleted (October 2018) "Schneider Electric Telemetry & SCADA" forum.
-------------------------------
**_NIWTelemetry:
Hello Everyone. I would be very grateful for some help if possible.
I basically am trying to identify key wet well analogue points on the database meeting a criteria and disable the alarms on those points within a loop.
I have SQL embedded within Structured text below. Problem is that although the Structured text program compiles and runs - the points returned within the Resultset do not have the alarm disabled.
Because I am using a JOIN between two tables I need to use a STRUCT / END_STRUCT. I would be grateful for any solutions - do I need to call another ST program with a Method do disable the point alarm? Any examples would be great - I'm not that good with ST/ SQL. Thank you all so much in advance._**
_TYPE Point :
STRUCT
AlarmDisabled : BOOL;
END_STRUCT;
END_TYPE
PROGRAM Disable_Point_Alarms
VAR
Pts AT %S(SELECT DISTINCT "CAdvPointCDRLog"."Id" FROM "CAdvPointCDRLog" CROSS JOIN "CPointDigitalManual"WHERE( "CAdvPointCDRLog"."FacilityCARID" = "CPointDigitalManual"."FacilityCARID" ) AND "CAdvPointCDRLog"."FullName" LIKE '%WwPS%' AND "CAdvPointCDRLog"."FullName" LIKE '%WWA1A%' AND NOT ( "CAdvPointCDRLog"."FullName" LIKE '%BAT%' OR "CAdvPointCDRLog"."FullName" LIKE '%Decomm%' OR "CAdvPointCDRLog"."FullName" LIKE '%IPSM%' OR "CAdvPointCDRLog"."FullName" LIKE '%PRI%' OR "CAdvPointCDRLog"."FullName" LIKE '%Test%' ) AND "CAdvPointCDRLog"."FullName" LIKE '%Wet Well Level%' AND "CAdvPointCDRLog"."AlarmDisabled" = 0 AND "CPointDigitalManual"."AlarmState" = 0 AND "CAdvPointCDRLog"."CurrentQualityDesc" NOT LIKE 'Out of Service' AND "CAdvPointCDRLog"."CurrentValueFormatted" "CAdvPointCDRLog"."PreviousValueFormatted") : RESULTSET OF Point;
END_VAR
WHILE Pts.Valid DO
Pts.Value.AlarmDisabled := TRUE;
Pts.Next();
END_WHILE;
END_PROGRAM_
-------------------------------
hardin4019:
I just went through something similar with trying to disable alarms for a set period of time using a redirection. Use the Disable method to disable the alarms.
PS. Don't forget that if the Disabled Alarms are set to independent in the System Configuration / Alarms, then if the alarm is disabled by logic, then only logic can re-enable the alarm.
_________________________________________________
**_NIWTelemetry:
Thank you for the example.
I have created the following ST with Method based on your suggestion.
Instead of passing the point FullName as a parameter - I want to pass the point ID._**
_Program SetAlarmDisabled
VAR_INPUT
(*Point Id*)
ID : INT;
END_VAR
METHOD
DisableAlarm %M({ID}.Disable):BOOL;
END_METHOD
DisableAlarm(TRUE);
END_PROGRAM_
**_This compiles OK. If you think this works - how can I call this ST program and pass the ID parameter from the Parent ST program running the SQL query to identify the Point IDs?
Once I get this working I can engineer other ST programs to reactivate the Point Alarm. This is the initial tricky part to get the first part working. I appreciate your and anyone else good with ST programming to help me. Thanks._**
_________________________
hardin4019:
I have never used the query for this but I think you were on the right path, just needed to use the Disable alarm method. I would think it would look more like this:
_Program SetAlarmDisabled
VAR
Pts AT %S(SELECT DISTINCT "CAdvPointCDRLog"."Id" FROM "CAdvPointCDRLog" CROSS JOIN "CPointDigitalManual"WHERE( "CAdvPointCDRLog"."FacilityCARID" = "CPointDigitalManual"."FacilityCARID" ) AND "CAdvPointCDRLog"."FullName" LIKE '%WwPS%' AND "CAdvPointCDRLog"."FullName" LIKE '%WWA1A%' AND NOT ( "CAdvPointCDRLog"."FullName" LIKE '%BAT%' OR "CAdvPointCDRLog"."FullName" LIKE '%Decomm%' OR "CAdvPointCDRLog"."FullName" LIKE '%IPSM%' OR "CAdvPointCDRLog"."FullName" LIKE '%PRI%' OR "CAdvPointCDRLog"."FullName" LIKE '%Test%' ) AND "CAdvPointCDRLog"."FullName" LIKE '%Wet Well Level%' AND "CAdvPointCDRLog"."AlarmDisabled" = 0 AND "CPointDigitalManual"."AlarmState" = 0 AND "CAdvPointCDRLog"."CurrentQualityDesc" NOT LIKE 'Out of Service' AND "CAdvPointCDRLog"."CurrentValueFormatted" "CAdvPointCDRLog"."PreviousValueFormatted") : RESULTSET OF Point;
END_VAR
METHOD
DisableAlarm %M({ID}.AnalogueValue1.Disable); (* Need a condition between the ID and Disable Method, possibly replace ID with FullName*)
END_METHOD
WHILE Pts.Valid DO
DisableAlarm(); (* No argument for disable method unless entering time in minutes UDINT*)
Pts.Next();
END_WHILE;
END_PROGRAM_
___________________________
dmercer:
Originally posted by: hardin4019
_METHOD
DisableAlarm %M({ID}.AnalogueValue1.Disable);
END_METHOD_
My understanding is that you can only do this with input variables, as in your linked ST program. So what would need to be done is to have two programs; one runs the SQL query, then calls the other one in a loop to disable alarms for each point.
____________
AWoodland:
{} only works with fullname, so if you only have the Id to start with then you must do a query to match the Id to FullName, then pass that FullName to another program to do the disable.
____________________
**_NIWTelemetry:
Hello. Thank you for taking the time to reply and comment.
Would you mind helping me a little more with my script?
I have now created two ST programs and listed both below.
What I'm trying to do is extract the point full name identified in a SQL query then pass it to a second program to actually disable the alarm on the point via a loop in the first program. If you have time would mind having a look and giving me any further guidance? Please feel free to modify the script to get something that will work. Once again - Thank you in advance._**
_TYPE Point :
STRUCT
Id : INT;
FullName: STRING;
END_STRUCT;
END_TYPE
PROGRAM Disable_Point_Alarms_SQL_Query
VAR
Pts AT %S(SELECT DISTINCT "CAdvPointCDRLog"."Id","CAdvPointCDRLog"."FullName" FROM "CAdvPointCDRLog" CROSS JOIN "CPointDigitalManual"WHERE( "CAdvPointCDRLog"."FacilityCARID" = "CPointDigitalManual"."FacilityCARID" ) AND "CAdvPointCDRLog"."FullName" LIKE '%WwPS%' AND "CAdvPointCDRLog"."FullName" LIKE '%WWA1A%' AND NOT ( "CAdvPointCDRLog"."FullName" LIKE '%BAT%' OR "CAdvPointCDRLog"."FullName" LIKE '%Decomm%' OR "CAdvPointCDRLog"."FullName" LIKE '%IPSM%' OR "CAdvPointCDRLog"."FullName" LIKE '%PRI%' OR "CAdvPointCDRLog"."FullName" LIKE '%Test%' ) AND "CAdvPointCDRLog"."FullName" LIKE '%Wet Well Level%' AND "CAdvPointCDRLog"."AlarmDisabled" = 0 AND "CPointDigitalManual"."AlarmState" = 0 AND "CAdvPointCDRLog"."CurrentQualityDesc" NOT LIKE 'Out of Service' AND "CAdvPointCDRLog"."CurrentValueFormatted" "CAdvPointCDRLog"."PreviousValueFormatted") : RESULTSET OF Point;
END_VAR
METHOD
CallAlarmDisable AT%I(.DisableAlarm_CALL.Execute):STRING;
END_METHOD
WHILE Pts.Valid DO
CallAlarmDisable(FullName);
Pts.Next();
END_WHILE;
END_PROGRAM
PROGRAM DisableAlarm_CALL
VAR_INPUT
FullName : STRING;
END_VAR
METHOD
DisableAlarm AT %M({FullName}.AlarmDisabled):BOOL;
END_METHOD
AlarmDisabled := TRUE;
END_PROGRAM_
___________________
hardin4019:
Assuming your query is good (paste it into the query portion of a table to see the points that would have the alarms disabled), the below is an edit of your second ST that I would expect to help clean up your issues. Note that calling the method requires ({FullName}.{Condition}.Disable) where in my attempts at disabling alarms, I was disabling {Condition} = AnalogueValue1. If you have digital alarms, this may need to change or be sent to the DisableAlarm_CALL from the previous ST with the Query.
_PROGRAM DisableAlarm_CALL
VAR_INPUT
FullName : STRING;
END_VAR
METHOD
DisableAlarm AT %M({FullName}.AnalogueValue1.Disable); (*Needs a condition after {FullName}, and at the end".Disable" is the actual method, no need for units since no argument is needed*)
END_METHOD
DisableAlarm(); (*Calls the above named method, also no units needed unless doing timed disable*)
END_PROGRAM_
____________________________
**_NIWTelemetry:
Thank you for the modified second ST Program script - it compiles OK and looks good. Really fantastic! thank you.
I still have a problem however with the first ST program - I'm getting a compile error within the Do While loop - specifically at 'CallAlarmDisable(FullName)' where Im trying to call the second ST program and pass the FullName parameter. Would you have any suggestions how this could be fixed? Thank you so much for your help. This is stressing me out.
I have the script of my first ST program below. I'm sure the SQL is good - just a problem calling / passisng FullName string to the second ST program.
I'd appreciate any help!_**
_TYPE Point :
STRUCT
Id : INT;
FullName: STRING;
END_STRUCT;
END_TYPE
PROGRAM Disable_Point_Alarms_SQL_Query
VAR
Pts AT %S(SELECT DISTINCT "CAdvPointCDRLog"."Id","CAdvPointCDRLog"."FullName" FROM "CAdvPointCDRLog" CROSS JOIN "CPointDigitalManual"WHERE( "CAdvPointCDRLog"."FacilityCARID" = "CPointDigitalManual"."FacilityCARID" ) AND "CAdvPointCDRLog"."FullName" LIKE '%WwPS%' AND "CAdvPointCDRLog"."FullName" LIKE '%WWA1A%' AND NOT ( "CAdvPointCDRLog"."FullName" LIKE '%BAT%' OR "CAdvPointCDRLog"."FullName" LIKE '%Decomm%' OR "CAdvPointCDRLog"."FullName" LIKE '%IPSM%' OR "CAdvPointCDRLog"."FullName" LIKE '%PRI%' OR "CAdvPointCDRLog"."FullName" LIKE '%Test%' ) AND "CAdvPointCDRLog"."FullName" LIKE '%Wet Well Level%' AND "CAdvPointCDRLog"."AlarmDisabled" = 0 AND "CPointDigitalManual"."AlarmState" = 0 AND "CAdvPointCDRLog"."CurrentQualityDesc" NOT LIKE 'Out of Service' AND "CAdvPointCDRLog"."CurrentValueFormatted" "CAdvPointCDRLog"."PreviousValueFormatted") : RESULTSET OF Point;
END_VAR
METHOD
CallAlarmDisable AT%I(.DisableAlarm_CALL.Execute):STRING;
END_METHOD
WHILE Pts.Valid DO
CallAlarmDisable(FullName);
Pts.Next();
END_WHILE;
END_PROGRAM_**
________
hardin4019:
AT defines whether the indirect variable is read only (%I), write only (%Q), or read and write (%M).
Try replacing yours with this bit of program:
_METHOD
CallAlarmDisable AT %M(.DisableAlarm_CALL.Execute):STRING; (* changed to %M*)
END_METHOD
WHILE Pts.Valid DO
CallAlarmDisable(Pts.Value.FullName); (*Changed to Pts.Value.FullName*)
Pts.Next();
END_WHILE;
END_PROGRAM_
Below is my code example. I used the entire ST DisableAlarm_CALL program as expected.
_TYPE Point :
STRUCT
Id : INT;
FullName: STRING;
END_STRUCT;
END_TYPE
PROGRAM Disable_Point_Alarms_SQL_Query
VAR
Pts AT %S(SELECT DISTINCT ID, FullName FROM CALARMOBJECT WHERE "CALARMOBJECT"."FullName" LIKE 'Test%') : RESULTSET OF Point;
END_VAR
METHOD
CallAlarmDisable AT %M(.DisableAlarm_CALL.Execute):STRING;
END_METHOD
WHILE Pts.Valid DO
CallAlarmDisable(Pts.Value.FullName);
Pts.Next();
END_WHILE;
END_PROGRAM_
____________________
**_NIWTelemetry:
Hi - Amazing!
Getting very close - looks like the first point in the record set was passed to the second ST program to disable the alarm. Only issue is I got an error flag up on the second ST program 'Program is configured to run On Input Processed, but has no suitable inputs'
Should the second ST program's execution method be 'On Input Processed' or by another way? Sorry to hassle you with this - but we are almost there._**
______
hardin4019:
Second ST program set to "On Interval", interval set to "0", no seconds or anything like that.
I do think I just found one issue. I added a digital alarm in the same area as my analog alarm that was successfully being disabled, and I got an error. May need to add some alarm type handling to handle switching between points that are digital.
 04/s6me8xv43x3q.jpg "")
_________
**_NIWTelemetry:
Hi. At this stage its only analogue points I need to disable alarms. I am on leave returning Monday next week. I will try and develop things further. Absolutely amazing you gave your time to assist. I hope you dont mind I contact you if I find any more issues._**
_____________
hardin4019:
No problem Tony. Hope it turns out to work correctly for you!
______________
**_NIWTelemetry:
Thank you. Hopefully it will. I'm sure you are aware we get a lot of rain in Ireland so I'm trying to develop an application for control room staff to use. Basically when heavy rain is due, the control room operator can hit a button to launch some logic to disable the alarm on selected wet well levels returned in an SQL query. After a period of time say 4 hours a timer will launch other logic to reactivate the wet well point alarms. So this is where I am and only have a basic understanding of ST. The idea is to stop the control room receiving a large volume of alarms. I'm very grateful to you for your help. Very decent of you??. I have one thought...what is the significance of the condition Analoguevalue1 following the full name? Seems an odd parameter to include in the ST when passing a variable._**
___________________
hardin4019:
The Condition name identifies the type of point or alarm that you are working with. Since digital alarms are different than analog alarms, are different than DNP3 alarms, are differnent than OPC alarms, and so on.
From the help contents in ViewX:
%ACondName%
The ‘condition' with which the alarm is associated. For example, the state of a particular type of point.
For further information, see Use Trip Sequences to Include Alarm Condition and Subcondition Details.
DNP3AnalogInState1
(indicating that the alarm is associated with the state of a DNP3 analog input point)
___________________
_**NIWTelemetry:
Hi, ok I see now. I'm using CAdvPointCDRLog within the SQL statement as its common to both DNP3 and Proteus analogue input points. We are currently rolling out new Talus T4e outstaions across the country replacing older PX24 outstations and hence have both point types configured on the database. I'm simply trying to replicate the action of identifying key analogue input wet well points from the data tree and selecting ‘Disable Alarms' from the pick list albeit by ST logic. So it's really to stop the point from generating any alarms at all...for a temporary period until ‘Enable Alarms' is activated by other logic. To complicate things..I needed to use a STRUCT instead of DATABASE OBJECT as the SQL record set employs a JOIN statement as I need to reference an internal digital point relating to pump trip alarm and exclude these wet well analogues if an alarm condition is true. Before I had to reference the internal Digital point, I was able to disable point alarms in earlier logic Where a JOIN was not required by simply referencing the point alarm disabled flag within the DATABASE OBJECT and setting it to TRUE within the program. Everything has become more complicated now I have to use a STRUCT and call/pass variables to another ST to execute the disable alarm action. Again many thanks for your help, I thought I would give you a bit of a background. Very grateful to you. you have been excellent!**_
____
hardin4019:
I feel your pain. We get nuisance alarms from sites in winter that run off solar and batteries that don't keep up due to having less daylight during the short winter days. We needed a way to put the alarms out of service for a predefined amount of time, so we chose to do 1 hour. I had to make some adjustments to the server configuration, but the way the ST I had posted works, it puts the alarm out of service for 1 hour, then it automatically comes back on. I was starting to make a second ST that would use a query to find alarms that had been disabled more than 1 hour ago, then enable them automatically when someone brought it to my attention that you can disable(##) the number of minutes for the alarms to be out of service with the correct server configuration. That is where the "EndTime" and UDINT came from in my ST.
______________
**_NIWTelemetry:
I am targeting points within the 'CAdvPointCDRLog'
I want to basically disable the possibility of any alarm being generated - in fact disabling the whole point alarm.
Does the condition still apply?_**
_______________
Yep. The same as right clicking in the database tree and clicking disable alarms.
________
**_NIWTelemetry:
Thank you for your input.
Hello Shawn, Thank you for taking the time and trouble to respond. Unfortunately this did not work. Ive tried to go back to a two program solution. One to run the SQL and identify point names meeting a criteria - then passing the full name within a loop as a parameter to a second St program to actually disable the alarm on the point. The script is below - but unfortunately it is still not working. If you have time, id appreciate if you could take a look and advise me what to do. Please feel free to modify the script to get it working. Thanks very much! Tony._**
_TYPE Point :
STRUCT
Id : INT;
FullName: STRING;
END_STRUCT;
END_TYPE
PROGRAM Disable_Point_Alarms_SQL_Query
VAR
Pts AT %S(SELECT DISTINCT "CAdvPointCDRLog"."Id","CAdvPointCDRLog"."FullName" FROM "CAdvPointCDRLog" CROSS JOIN "CPointDigitalManual"WHERE( "CAdvPointCDRLog"."FacilityCARID" = "CPointDigitalManual"."FacilityCARID" ) AND "CAdvPointCDRLog"."FullName" LIKE '%WwPS%' AND "CAdvPointCDRLog"."FullName" LIKE '%WWA1A%' AND NOT ( "CAdvPointCDRLog"."FullName" LIKE '%BAT%' OR "CAdvPointCDRLog"."FullName" LIKE '%Decomm%' OR "CAdvPointCDRLog"."FullName" LIKE '%IPSM%' OR "CAdvPointCDRLog"."FullName" LIKE '%PRI%' OR "CAdvPointCDRLog"."FullName" LIKE '%Test%' ) AND "CAdvPointCDRLog"."FullName" LIKE '%Wet Well Level%' AND "CAdvPointCDRLog"."AlarmDisabled" = 0 AND "CPointDigitalManual"."AlarmState" = 0 AND "CAdvPointCDRLog"."CurrentQualityDesc" NOT LIKE 'Out of Service' AND "CAdvPointCDRLog"."CurrentValueFormatted" "CAdvPointCDRLog"."PreviousValueFormatted") : RESULTSET OF Point;
END_VAR
METHOD
CallAlarmDisable AT%I(.DisableAlarm_CALL.Execute):STRING;
END_METHOD
WHILE Pts.Valid DO
CallAlarmDisable(FullName);
Pts.Next();
END_WHILE;
END_PROGRAM
PROGRAM DisableAlarm_CALL
VAR_INPUT
FullName : STRING;
END_VAR
METHOD
DisableAlarm AT %M({FullName}.AlarmDisabled):BOOL;
END_METHOD
AlarmDisabled := TRUE;
END_PROGRAM_**
Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.
With achievable small steps, users progress and continually feel satisfaction in task accomplishment.
Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.
of