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);
}
If something is unclear i can explain more.
//Monzan