Alarm Info

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
jmsmoreira
Posts: 28
Joined: Mon Apr 23, 2012 7:03 am

Alarm Info

Post 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

User avatar
Ron L.
Posts: 214
Joined: Fri Jul 15, 2011 3:21 pm

Re: Alarm Info

Post 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;
		}
    }
Best Regards,

Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer

bigT
Posts: 3
Joined: Wed Jan 06, 2016 8:42 am

Re: Alarm Info

Post 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?

Post Reply