You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/RfidWeb/Frm/UserAlarmShow.cs

328 lines
9.0 KiB
C#

2 weeks ago
using DB.Entity;
using HZH_Controls.Controls;
using HZH_Controls.Forms;
using NewLife.Caching;
using NewLife.Reflection;
using NewLife.Threading;
using System;
2 weeks ago
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
6 days ago
using System.Diagnostics;
2 weeks ago
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
2 weeks ago
using DB.Service;
1 week ago
using HslControls;
2 weeks ago
using Tool;
using Tool.Model;
6 days ago
using HslCommunication.LogNet;
2 weeks ago
namespace RfidWeb.Frm
{
public partial class UserAlarmShow : UserControl
{
6 days ago
private ICache cache = Cache.Default;
private ILogNet logNet = ILogNetFactory.GetLogNet;
2 weeks ago
private TimerX _timer;
6 days ago
private readonly HimAlarmManager himAlarmManager = new HimAlarmManager();
readonly PromptAlarmManager promptAlarmManager = new PromptAlarmManager();
readonly AlarmLogService alarmLogService = new AlarmLogService();
2 weeks ago
2 weeks ago
public UserAlarmShow()
{
InitializeComponent();
1 week ago
_timer = new TimerX(TimeState, null, 2000, 1000);
_timer.Async = true;
2 weeks ago
}
6 days ago
Stopwatch stopwatc=new Stopwatch();
2 weeks ago
void TimeState(Object state)
{
6 days ago
stopwatc.Restart();
1 week ago
FillAlarmGrid();
FillPromptGrid();
FillAlartLed();
1 week ago
FillhslLabelCombo();
6 days ago
stopwatc.Stop();
logNet.WriteInfo("运行时间:"+stopwatc.Elapsed.TotalMilliseconds);
1 week ago
}
/// <summary>
/// 右下角的gridView
/// </summary>
void FillAlarmGrid()
{
List<GridViewData> lsList = new List<GridViewData>();
2 weeks ago
var list = himAlarmManager.GetList();
1 week ago
alarmLogService.Insert(list,1);
2 weeks ago
foreach (var keyValuePair in list)
{
lsList.Add(new GridViewData()
{
AlartTime = keyValuePair.Value.ToString("MM-dd HH:mm:ss"),
Msg = keyValuePair.Key
});
}
this.Invoke(() =>
{
int currentFirstVisibleRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex;
1 week ago
this.dataGridView1.DataSource = lsList;
if (currentFirstVisibleRowIndex > 0)
{
dataGridView1.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex;
}
2 weeks ago
});
1 week ago
}
2 weeks ago
1 week ago
1 week ago
void FillPromptGrid()
{
List<GridViewData> lsList = new List<GridViewData>();
var list = promptAlarmManager.GetList();
1 week ago
alarmLogService.Insert(list,2);
1 week ago
foreach (var keyValuePair in list)
{
lsList.Add(new GridViewData()
{
AlartTime = keyValuePair.Value.ToString("MM-dd HH:mm:ss"),
Msg = keyValuePair.Key
});
}
this.Invoke(() =>
{
int currentFirstVisibleRowIndex = dataGridView2.FirstDisplayedScrollingRowIndex;
this.dataGridView2.DataSource = lsList;
if (currentFirstVisibleRowIndex > 0)
{
dataGridView2.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex;
}
});
2 weeks ago
}
6 days ago
1 week ago
6 days ago
/// <summary>
/// 异常信息
/// </summary>
1 week ago
void FillAlartLed()
{
var plcCh = cache.Get<PlcBoolModel>(CacheKeyManager.CH_alarm);
var plcCq= cache.Get<PlcBoolModel>(CacheKeyManager.CQ_alarm);
var plcStop = cache.Get<List<bool>>(CacheKeyManager.estop_temporary_storage);
var plcAlarm= cache.Get<List<bool>>(CacheKeyManager.Prompt_alarm);
if (plcStop==null || plcCh ==null || plcCq==null ) return;
//No0
if (plcStop[4] || plcStop[0] || plcStop[1])
{
SetTrueLed(hsl0);
}
else
{
SetFaileLed(hsl0);
1 week ago
}
//No1
if (plcCh.B6 || plcCh.B7)
{
SetTrueLed(hslA1, hslB1);
}
else
{
SetFaileLed(hslA1, hslB1);
}
//No2
if (plcCh.A1 || plcCh.A2 || plcCh.B3 || plcCh.B4 || plcStop[12])
{
SetTrueLed(hslA2,hslB2);
}
else
{
SetFaileLed(hslA2, hslB2);
1 week ago
}
//No3
if (plcCh.A0 || plcCh.B0 || plcCh.B1 || plcStop[10] || plcStop[11])
{
SetTrueLed(hslA3,hslB3);
}
else
{
SetFaileLed(hslA3, hslB3);
}
//No4
if (plcCh.B10 || plcCh.B11 || plcCh.B12 || plcCh.B14 || plcCh.B5 || plcCh.B8 || plcStop[14] || plcStop[25])
{
SetTrueLed(hslA4);
}
else
{
SetFaileLed(hslA4);
}
//No5
SetLed(plcCh.B9,hslA5,hslB5);
//No6
if (plcCh.B13 || plcStop[15])
{
SetTrueLed(hslA6);
}
else
{
SetFaileLed(hslA6);
}
2 weeks ago
1 week ago
//No7
if (plcStop[3] || plcStop[5])
{
SetTrueLed(hslA7,hslB7);
}
else
{
SetFaileLed(hslA7, hslB7);
}
//No8
SetLed(plcStop[6],hslA8,hslB8);
//No9
if (plcCq.B9 || plcStop[16])
{
SetTrueLed(hslA9,hslB9);
}
else
{
SetFaileLed(hslA9, hslB9);
}
//No10
if (plcCq.A0 || plcCq.A1 || plcCq.A2
|| plcCq.B0 || plcCq.B1 || plcCq.B3 || plcCq.B4 || plcStop[13] || plcStop[24] || plcAlarm[0] || plcAlarm[1])
{
SetTrueLed(hslA10,hslB10);
}
else
{
SetFaileLed(hslA10, hslB10);
}
//No11
if (plcCq.B2 || plcCq.B5 || plcCq.B6 ||
plcStop[2] || plcStop[7] || plcStop[17] || plcStop[18])
{
SetTrueLed(hslA11, hslB11);
}
else
{
SetFaileLed(hslA11, hslB11);
}
//No12
if (plcCq.B7 || plcCq.B8)
{
SetTrueLed(hslA12);
}
else
{
SetFaileLed(hslA12);
}
//No13
if (plcStop[8] || plcStop[21] || plcStop[22] || plcStop[23] || plcStop[26])
{
SetTrueLed(hslB13);
}
else
{
SetFaileLed(hslB13);
}
//No14
if (plcStop[9] || plcStop[19] || plcStop[20])
{
SetTrueLed(hslB14);
}
else
{
SetFaileLed(hslB14);
}
}
1 week ago
void FillhslLabelCombo()
{
//HmiPoint
hslLabelCombofeedingMotorSpeed.TextValue = HmiPoint.GetFeedingMotorSpeed.ToString();
hslLabelComboLaminated.TextValue = HmiPoint.GetLaminatedMotorSpeed.ToString();
hslLabelComboFelt.TextValue = HmiPoint.GetFeltBeltMotorSpeed.ToString();
hslLabelComboReceiving.TextValue = HmiPoint.GeReceivingMotorSpeed.ToString();
hslLabelComboProduct_counter2.TextValue = HmiPoint.GetProduct_counter2.ToString();
hslLabelComboCQ_Chip1_counter.TextValue = HmiPoint.GetCQ_Chip1_counter.ToString();
hslLabelComboCQ_Chip2_counter.TextValue = HmiPoint.GetCQ_Chip2_counter.ToString();
1 week ago
1 week ago
hslLabelComboQDWD1SS.TextValue = HmiPoint.GetQDWD1SS.ToString();
hslLabelComboQDWD2SS.TextValue = HmiPoint.GetQDWD2SS.ToString();
double result = HmiPoint.GetSWSS / 10.0;
hslLabelComboSWSS.TextValue = result.ToString();
}
1 week ago
private void SetTrueLed(params HslLanternSimple[] simples)
{
SetLed(true,simples);
}
private void SetFaileLed(params HslLanternSimple[] simples)
{
SetLed(false, simples);
}
private void SetLed( bool b, params HslLanternSimple[] simples)
{
if (b)
{
foreach (var simple in simples)
{
if (simple.LanternBackground != Color.Red)
{
simple.LanternBackground = Color.Red;
}
}
}
else
{
foreach (var simple in simples)
{
if (simple.LanternBackground != Color.Chartreuse)
{
simple.LanternBackground = Color.Chartreuse;
}
}
}
}
1 week ago
2 weeks ago
}
}