Alarm Banner

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Monzan
Posts: 3
Joined: Fri Jul 20, 2012 12:28 pm
Location: Sweden

Re: Alarm Banner

Post by Monzan »

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: Select all

//--------------------------------------------------------------
// 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: Select all

		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

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

Re: Alarm Banner

Post by bigT »

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.

Post Reply