Get Alarm text with name of alarm

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
Claus Nielsen
Posts: 18
Joined: Sun May 31, 2015 2:38 am

Get Alarm text with name of alarm

Post by Claus Nielsen »

Hello

Struggling with a problem on how to get the text of an alarm with the name of the alarm.

I got a screen to show info on alarm when pressing request alarm info which works perfectly, but I would like to have the "Text" of the alarm parsed to that screen aswell.

Using a Text Library to handle the alarm info, but would like to have the alarm text handled automaticly when adding new alarms.

Posted my code to show the screen.

Code: Select all

		void AlarmViewer_AlarmEventInfoRequested(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.AlarmEventEventArgs e)
		{
			
			try
			{
				int aNumber = Int32.Parse( e.AlarmEvent.AlarmItemDisplayName.Replace("F", ""));
				
				Globals.Tags.AlarmToShow.Value = aNumber;
				Globals.scn_AlarmInfo.Show();
			}
			
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

Greg M
Posts: 16
Joined: Tue Sep 08, 2015 1:32 pm

Re: Get Alarm text with name of alarm

Post by Greg M »

I've not tested this, but the following function might work:

private string getAlarmTextFromDisplayName(string alarmDisplayName)
{
foreach (IAlarmGroup ag in Globals.AlarmServer.AlarmGroups)
{
foreach (IAlarmItem ai in ag.AlarmItems)
{
if (ai.DisplayName.Equals(alarmDisplayName))
return ai.Text;
}
}

}

Post Reply