Page 1 of 1

Get Alarm text with name of alarm

Posted: Thu Aug 13, 2015 9:36 am
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);
			}
		}

Re: Get Alarm text with name of alarm

Posted: Wed Sep 30, 2015 6:31 am
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;
}
}

}