Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Alarm Info
PostPosted: Wed Jul 04, 2012 4:09 am 

Joined: Mon Apr 23, 2012 7:03 am
Posts: 28

Offline
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


 Profile  
 
 Post subject: Re: Alarm Info
PostPosted: Thu Jul 05, 2012 8:27 am 
User avatar

Joined: Fri Jul 15, 2011 3:21 pm
Posts: 214

Offline
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:
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


 Profile  
 
 Post subject: Re: Alarm Info
PostPosted: Sat Jan 09, 2016 1:38 am 

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

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


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: