Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 12 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Alarm Banner
PostPosted: Sat Mar 23, 2013 11:55 am 

Joined: Fri Jul 20, 2012 12:28 pm
Posts: 3
Location: Sweden

Offline
Hello, I have just finished a script that writes the alarm text whenever an alarm occurs, to a tag. Then it will go through all the en-queued alarms.



Code:
//--------------------------------------------------------------
// Press F1 to get help about using script.
// To access an object that is not located in the current class, start the call with Globals.
// When using events and timers be cautious not to generate memoryleaks,
// please see the help for more information.
//---------------------------------------------------------------

namespace Neo.ApplicationFramework.Generated
{
    using System.Windows.Forms;
    using System;
    using System.Drawing;
   using System.Collections.Generic;
   using System.Collections;
    using Neo.ApplicationFramework.Tools;
    using Neo.ApplicationFramework.Common.Graphics.Logic;
    using Neo.ApplicationFramework.Controls;
    using Neo.ApplicationFramework.Interfaces;
   
   
    public partial class AlarmBarManager
    {
      private List<string> alarmbar_queue = new List<string>();
      private Timer m_timer = new Timer();
      private bool TimerStarted = false;
      private int counter = 0;

      void AlarmBarManager_Created(System.Object sender, System.EventArgs e)
      {
         m_timer.Interval = 5000;       // This is the TimerTick interval [ms]
         m_timer.Tick += TimerTick;
      }
      
      
      
      public void Start_Alarmbar() {
         if (!TimerStarted)          // If never started before
         {
            m_timer.Enabled = true;
            TimerStarted = true;       // Set flag for singel shot execution
            changeText();
         }   
      }

      public void Stop_Alarmbar() {
         m_timer.Enabled = false;
         TimerStarted = false;
      }

      
      void TimerTick(System.Object sender, System.EventArgs e) {
         changeText();
      }
      
      private void changeText(){
         
         if (counter != (alarmbar_queue.Count)){
            Globals.Tags.AlarmBar_Text.SetString(alarmbar_queue[counter]);   
            counter++;
         }else{
            counter = 0;
            Globals.Tags.AlarmBar_Text.SetString(alarmbar_queue[counter]);
            counter++;
         }
      }
      
      
      public void enQueue(string message){
         if (!alarmbar_queue.Contains(message)){
            
            alarmbar_queue.Add(message);
            counter = 0;
            if (!TimerStarted){
               this.Start_Alarmbar();
            }   
         }   
      }
      
      public void deQueue(string message){
         alarmbar_queue.Remove(message);
         
         counter = 0;
         
         if (alarmbar_queue.Count == 0){
            this.Stop_Alarmbar();
            Globals.Tags.AlarmBar_Text.SetString("");
         }
      }

      public List<string> getQueue(){
         return alarmbar_queue;
      }
      

    }
}



It will write the current alarm text to a Tag named AlarmBar_Text that you can link to a text box or something.

The script will start a timer that will change the alarm bar text through all the active alarms, until there are no alarms active anymore.


From the Alarm Server you en-queue like this.


Code:
      void Default1_AlarmItem0_AlarmActive(System.Object sender, System.EventArgs e)
      {
         Globals.AlarmBarManager.enQueue(Globals.AlarmServer.Default1_AlarmItem0.Text);
      }

      void Default1_AlarmItem0_AlarmAcknowledge(System.Object sender, System.EventArgs e)
      {
      Globals.AlarmBarManager.deQueue(Globals.AlarmServer.Default1_AlarmItem0.Text);
      }
      


I just finished with the script and I haven't stress tested it so i can't guarantee that it's perfect, but it's a start.

If something is unclear i can explain more.

//Monzan


 Profile  
 
 Post subject: Re: Alarm Banner
PostPosted: Fri Jan 08, 2016 9:40 am 

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

Offline
Is there a way to do the same with alarms coming via OPC AE server? They are not specified in Alarm Server, therefor I cannot access their properties.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page Previous  1, 2

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: