Page 1 of 1

Alarm Info

Posted: Wed Jul 04, 2012 4:09 am
by jmsmoreira
Hi,

I want to display further information on a selected alarm by the user, by displaying a pop-up screen with a text lybrary.

The value of the text to be displayed is read on an internal tag, which is set on the action of each alarm.

The problem is that I have near 200 alarms, which means I have to set the action for all of them.

Is there an easier way of doing this?

Thanks

Re: Alarm Info

Posted: Thu Jul 05, 2012 8:27 am
by Ron L.
From my experience, you will have to at least set an action to show a screen for each one.

You might be able to come up with a more advanced solution using reflection and scripting, but I would not recommend this for everyone. Here's some example script where I use reflection to find out what item is selected in the alarm viewer.

Code: Select all

using Neo.ApplicationFramework.Controls.Alarm;
	using System.Reflection;    
    
    public partial class Screen1
    {
		
		void Button1_Click(System.Object sender, System.EventArgs e)
		{	
			Text1.Text = GetAlarmViewerIndex((Form)this).ToString();		
		}
		
		//search screen for alarm viewer, if found return row index, otherwise -2
		int GetAlarmViewerIndex(Form form)
		{	
			for (int i = 0; i < form.Controls.Count; i++)
			{
				if (form.Controls[i].GetType().Equals(typeof(AlarmViewer))) 
				{
					AlarmViewer av = (AlarmViewer)form.Controls[i];
					UserControl uc = (UserControl)av;
					foreach (Control ctrl in uc.Controls) 
					{
						if (ctrl.GetType().ToString().Equals("Resco.Controls.SmartGrid.SmartGrid")) 
						{
							Type gType = ctrl.GetType();
							PropertyInfo[] props = gType.GetProperties();
							foreach (PropertyInfo prop in props)
							{
								if (prop.Name.Equals("ActiveRowIndex")) 
								{
									int idx = (int)prop.GetValue(ctrl, null);
									return idx;
								}
							}							
						}					
					}
				}
			}
			return -2;
		}
    }

Re: Alarm Info

Posted: Sat Jan 09, 2016 1:38 am
by bigT
This is good script. I am trying to get selected alarm text as well by some additions to this script. But cannot succeed.
From my understanding it should look smth like this.

Messagebox.Show(ctrl.Cells.Item[x,y] );

But I cannot build the project because property 'Item' is not recognized. Can anyone help on this?