221 lines
6.7 KiB
C#
221 lines
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using CRVM.Entity;
|
|
|
|
namespace CRVM
|
|
{
|
|
public partial class AlarmShowForm : Form
|
|
{
|
|
string title = "";
|
|
string msg = "";
|
|
|
|
int count = 0;
|
|
int keepTime = 5;//秒
|
|
int timeCount = 0;
|
|
bool alarming = false;
|
|
|
|
public AlarmShowForm(IClientMainForm fatherForm)
|
|
{
|
|
fatherForm.AlarmDataChangEvent += fatherForm_AlarmDataChangEvent;
|
|
InitializeComponent();
|
|
}
|
|
|
|
void fatherForm_AlarmDataChangEvent(IClientMainForm.Alarmdata data)
|
|
{
|
|
Console.WriteLine(String.Format("|{0}|fatherForm_AlarmDataChangEvent|alarming:{1}", DateTime.Now.ToString(), alarming.ToString()));
|
|
if (data.alarmInfo.Count > 0)
|
|
{
|
|
|
|
alarming = true;
|
|
for (int i = 0; i < data.alarmInfo.Count; i++)
|
|
{
|
|
int index = data.alarmInfo[i].IndexOf("号机架");
|
|
if (index != -1)
|
|
{
|
|
string standno = data.alarmInfo[i].Substring(index - 1, 1);
|
|
if (SysParam.Instance.orderByStandnoR2L)
|
|
{
|
|
if (standno == "1")
|
|
{
|
|
textBox6.Text = "1";
|
|
}
|
|
else if (standno == "2")
|
|
{
|
|
textBox5.Text = "2";
|
|
}
|
|
else if (standno == "3")
|
|
{
|
|
textBox4.Text = "3";
|
|
}
|
|
else if (standno == "4")
|
|
{
|
|
textBox3.Text = "4";
|
|
}
|
|
else if (standno == "5")
|
|
{
|
|
textBox2.Text = "5";
|
|
}
|
|
else if (standno == "6")
|
|
{
|
|
textBox1.Text = "6";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (standno == "1")
|
|
{
|
|
textBox1.Text = "1";
|
|
}
|
|
else if (standno == "2")
|
|
{
|
|
textBox2.Text = "2";
|
|
}
|
|
else if (standno == "3")
|
|
{
|
|
textBox3.Text = "3";
|
|
}
|
|
else if (standno == "4")
|
|
{
|
|
textBox4.Text = "4";
|
|
}
|
|
else if (standno == "5")
|
|
{
|
|
textBox5.Text = "5";
|
|
}
|
|
else if (standno == "6")
|
|
{
|
|
textBox6.Text = "6";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
alarming = false;
|
|
}
|
|
if (SysParam.Instance.alarmingType == 2)
|
|
{
|
|
if (SysParam.Instance.orderByStandnoR2L)
|
|
{
|
|
if (SysParam.Instance.alarming5)
|
|
{
|
|
textBox2.Text = "5";
|
|
}
|
|
if (SysParam.Instance.alarming4)
|
|
{
|
|
textBox3.Text = "4";
|
|
}
|
|
if (SysParam.Instance.alarming3)
|
|
{
|
|
textBox4.Text = "3";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (SysParam.Instance.alarming5)
|
|
{
|
|
textBox5.Text = "5";
|
|
}
|
|
if (SysParam.Instance.alarming4)
|
|
{
|
|
textBox4.Text = "4";
|
|
}
|
|
if (SysParam.Instance.alarming3)
|
|
{
|
|
textBox3.Text = "3";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public AlarmShowForm(string title, string msg)
|
|
{
|
|
this.title = title;
|
|
this.msg = msg;
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void AlarmShowForm_Load(object sender, EventArgs e)
|
|
{
|
|
Initial();
|
|
//SysParam.Instance.isOpenAlarm = true;
|
|
|
|
}
|
|
|
|
private void Initial()
|
|
{
|
|
alarming = false;
|
|
|
|
textBox1.Enabled = false;
|
|
textBox2.Enabled = false;
|
|
textBox3.Enabled = false;
|
|
textBox4.Enabled = false;
|
|
textBox5.Enabled = false;
|
|
textBox6.Enabled = false;
|
|
}
|
|
|
|
//标题闪烁效果
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
if (count == 0)
|
|
{
|
|
label_alarm.BackColor = System.Drawing.Color.Red;
|
|
count = 1;
|
|
}
|
|
else
|
|
{
|
|
label_alarm.BackColor = System.Drawing.Color.Yellow;
|
|
count = 0;
|
|
}
|
|
}
|
|
|
|
//报警画面持续x秒后自动关闭
|
|
private void timer2_Tick(object sender, EventArgs e)
|
|
{
|
|
Console.WriteLine(String.Format("|{0}|timer2_Tick|alarming:{1}", DateTime.Now.ToString(), alarming.ToString()));
|
|
if (alarming == true)
|
|
{
|
|
timeCount = 0;
|
|
}
|
|
else
|
|
{
|
|
timeCount++;
|
|
if (timeCount >= keepTime)
|
|
{
|
|
this.Close();
|
|
SysParam.Instance.isOpenAlarm = false;
|
|
}
|
|
}
|
|
alarming = false;
|
|
if (SysParam.Instance.alarming1 || SysParam.Instance.alarming2
|
|
|| SysParam.Instance.alarming3 || SysParam.Instance.alarming4
|
|
|| SysParam.Instance.alarming5 || SysParam.Instance.alarming6)
|
|
{
|
|
alarming = true;
|
|
}
|
|
|
|
}
|
|
|
|
private void AlarmShowForm_Shown(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void AlarmShowForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
//SysParam.Instance.isOpenAlarm = false;
|
|
}
|
|
|
|
|
|
}
|
|
}
|