You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
7.8 KiB

using Module.Plc.ModbusTcp.Tool;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MorClient.UserControls
{
public partial class Supcontrol_DI : UserControl
{
// 更新状态栏委托
//private delegate void PrintSysTime(); //委托事件
//private PrintSysTime DgRealSysTimeValue;
public Supcontrol_DI()
{
InitializeComponent();
}
/// <summary>
/// 传入参数
/// </summary>
/// <param name="b">颜色</param>
/// <param name="box">控件</param>
public void SetInputSingalColor(bool b, PictureBox box)
{
if (b == true)
{
box.Image = WindowsFormsApp1.Properties.Resources.Status_Green;
//box.Refresh();
}
else
{
box.Image = WindowsFormsApp1.Properties.Resources.Status_Gray;
//box.Refresh();
}
}
private void Supcontrol_DI_Load(object sender, EventArgs e)
{
if (!PubStaticClass.bthreedDI)
{
PubStaticClass.bthreedDI = true;
//DgRealSysTimeValue = new PrintSysTime(DetectionRecipeThread);
Thread printRealTimeThread = new Thread(/*StartPrintRealTime*/DetectionRecipeThread);
printRealTimeThread.IsBackground = true;
printRealTimeThread.Start();
}
}
///// <summary>
///// 开始显示实时系统时间
///// </summary>
//private void StartPrintRealTime()
//{
// while (true)
// {
// if (this.IsHandleCreated)
// {
// this.Invoke(DgRealSysTimeValue, null);
// }
// Thread.Sleep(1000);
// }
//}
/// <summary>
/// 实时检测配方下发
/// </summary>
public /*async*/ void DetectionRecipeThread()
{
/*await Task.Run(() =>
{*/
while (true)
{
try
{
if (PublicPara.twoFunctionButtons == "[监控]" && PublicPara.fristFunctionButtons == "[操作]")
{
SetInputSingalColor(Common.inputSingal.host00, pictureBox28);
SetInputSingalColor(Common.inputSingal.host01, pictureBox29);
SetInputSingalColor(Common.inputSingal.host02, pictureBox30);
SetInputSingalColor(Common.inputSingal.host03, pictureBox31);
SetInputSingalColor(Common.inputSingal.host04, pictureBox32);
SetInputSingalColor(Common.inputSingal.host06, pictureBox34);
SetInputSingalColor(Common.inputSingal.host07, pictureBox35);
SetInputSingalColor(Common.inputSingal.host08, pictureBox36);
SetInputSingalColor(Common.inputSingal.host09, pictureBox37);
SetInputSingalColor(Common.inputSingal.host10, pictureBox38);
SetInputSingalColor(Common.inputSingal.host11, pictureBox39);
SetInputSingalColor(Common.inputSingal.host14, pictureBox42);
SetInputSingalColor(Common.inputSingal.host15, pictureBox43);
SetInputSingalColor(Common.inputSingal.di1_00, pictureBox00);
SetInputSingalColor(Common.inputSingal.di1_01, pictureBox1);
SetInputSingalColor(Common.inputSingal.di1_02, pictureBox2);
SetInputSingalColor(Common.inputSingal.di1_03, pictureBox3);
SetInputSingalColor(Common.inputSingal.di1_04, pictureBox4);
SetInputSingalColor(Common.inputSingal.di1_05, pictureBox5);
SetInputSingalColor(Common.inputSingal.di1_08, pictureBox8);
SetInputSingalColor(Common.inputSingal.di1_09, pictureBox9);
SetInputSingalColor(Common.inputSingal.di1_12, pictureBox12);
SetInputSingalColor(Common.inputSingal.di1_13, pictureBox13);
SetInputSingalColor(Common.inputSingal.di1_14, pictureBox14);
SetInputSingalColor(Common.inputSingal.di1_15, pictureBox15);
SetInputSingalColor(Common.inputSingal.di2_00, picdi2_0);
SetInputSingalColor(Common.inputSingal.di2_01, picdi2_1);
SetInputSingalColor(Common.inputSingal.di2_04, picdi2_4);
SetInputSingalColor(Common.inputSingal.di2_05, picdi2_5);
SetInputSingalColor(Common.inputSingal.di2_08, picdi2_8);
SetInputSingalColor(Common.inputSingal.di2_09, picdi2_9);
SetInputSingalColor(Common.inputSingal.di2_10, picdi2_10);
SetInputSingalColor(Common.inputSingal.di2_11, picdi2_11);
SetInputSingalColor(Common.inputSingal.di2_12, picdi2_12);
SetInputSingalColor(Common.inputSingal.di2_13, picdi2_13);
SetInputSingalColor(Common.inputSingal.di3_00, picdi3_0);
SetInputSingalColor(Common.inputSingal.di3_01, picdi3_1);
SetInputSingalColor(Common.inputSingal.di3_04, picdi3_4);
SetInputSingalColor(Common.inputSingal.di3_05, picdi3_5);
SetInputSingalColor(Common.inputSingal.di3_06, picdi3_6);
SetInputSingalColor(Common.inputSingal.di3_07, picdi3_7);
SetInputSingalColor(Common.inputSingal.di3_08, picdi3_8);
SetInputSingalColor(Common.inputSingal.di3_09, picdi3_9);
SetInputSingalColor(Common.inputSingal.di3_12, picdi3_12);
SetInputSingalColor(Common.inputSingal.di3_13, picdi3_13);
SetInputSingalColor(Common.inputSingal.di4_00, picdi4_0);
SetInputSingalColor(Common.inputSingal.di4_01, picdi4_1);
SetInputSingalColor(Common.inputSingal.di4_02, picdi4_2);
SetInputSingalColor(Common.inputSingal.di4_03, picdi4_3);
SetInputSingalColor(Common.inputSingal.di4_04, picdi4_4);
SetInputSingalColor(Common.inputSingal.di4_05, picdi4_5);
SetInputSingalColor(Common.inputSingal.di4_06, picdi4_6);
SetInputSingalColor(Common.inputSingal.di4_07, picdi4_7);
SetInputSingalColor(Common.inputSingal.di4_08, picdi4_8);
SetInputSingalColor(Common.inputSingal.di4_09, picdi4_9);
SetInputSingalColor(Common.inputSingal.di4_10, picdi4_10);
SetInputSingalColor(Common.inputSingal.di4_11, picdi4_11);
SetInputSingalColor(Common.inputSingal.di4_12, picdi4_12);
SetInputSingalColor(Common.inputSingal.di4_13, picdi4_13);
SetInputSingalColor(Common.inputSingal.di4_14, picdi4_14);
SetInputSingalColor(Common.inputSingal.di4_15, picdi4_15);
}
System.Threading.Thread.Sleep(500);
}
catch (Exception ex)
{
ex.ToString();
}
System.Threading.Thread.Sleep(200);
GC.Collect();
GC.WaitForPendingFinalizers();
}
/*});*/
}
}
}