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.

238 lines
8.1 KiB

using Module.Plc.ModbusTcp.Tool;
using RS.Module.Common;
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.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.AxHost;
namespace MorClient.UserControls
{
public partial class UnitUAFrom : UserControl
{
public UnitUAFrom()
{
InitializeComponent();
}
#region 实时展示状态值
private delegate void PrintCSStateValueCallBack(); //委托事件
private PrintCSStateValueCallBack ShowCSStateValue;
public static bool IsPrintReadValue = false;
/// <summary>
/// 实时展示
/// </summary>
private void UnitUAFrom_Load(object sender, EventArgs e)
{
//委托展示参数实时值
ShowCSStateValue = new PrintCSStateValueCallBack(PrintParamRealValue);
//开始显示实时值线程
System.Threading.Thread printRealValueThread = new System.Threading.Thread(StartPrintParamRealValue);
printRealValueThread.IsBackground = true;
printRealValueThread.Start();
}
/// <summary>
/// 开始显示实时值线程
/// </summary>
private async void StartPrintParamRealValue()
{
await Task.Run(() =>
{
while (true)
{
if (this.IsHandleCreated)
{
this.BeginInvoke(ShowCSStateValue, null);
}
System.Threading.Thread.Sleep(200);
}
});
}
/// <summary>
/// 展示参数实时值
/// </summary>
private void PrintParamRealValue()
{
PubStaticClass.date1 = DateTime.Now;
try
{
if (MorClient.PublicPara.PlcTool != null)
{
uiButton3.FillColor = Common.stationCA.F_VacuumSuction ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100);
uiButton1.FillColor = Common.stationCA.F_BearingPlatformCylinder ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100);
uiButton2.FillColor = Common.stationCA.F_TopSidemCylinder ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100);
uiButton6.FillColor = Common.stationCA.F_StationInitialization ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100);
uiButton4.FillColor = Common.stationCA.F_StationSingleAction ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100);
//uiButton5.FillColor = Common.stationCA.F_StationSingleAction ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100);
}
if (PublicParams.currUserInfo.userGroup == "Operator")
{
this.Enabled = false;
this.Refresh();
}
else
{
this.Enabled = true;
this.Refresh();
}
}
catch (Exception ex)
{
ex.ToString();
}
}
#endregion 实时展示状态值
static UnitUAFrom unitUAFrom_Now;
public void GetUnitUAFrom(UnitUAFrom unitHandactObject)
{
unitUAFrom_Now = unitHandactObject;
unitUAFrom_Now.tableLayoutPanelUserControl1.Refresh();
unitUAFrom_Now.tableLayoutPanelUserControl1.BorderStyle = BorderStyle.FixedSingle;
unitUAFrom_Now.tableLayoutPanel1.Refresh();
unitUAFrom_Now.tableLayoutPanel1.BorderStyle = BorderStyle.FixedSingle;
if (PublicParams.currUserInfo.userGroup == "Operator")
{
this.Enabled = false;
}
else
{
this.Enabled = true;
}
}
#region 工位操作
/// <summary>
/// 承片台
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void uiButton1_Click_1(object sender, EventArgs e)
{
MorClient.PublicPara.PlcTool.CaStage();
}
/// <summary>
/// 对中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void uiButton2_Click(object sender, EventArgs e)
{
MorClient.PublicPara.PlcTool.CaCenteringCylinder();
}
/// <summary>
/// 吸片真空
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void uiButton3_Click(object sender, EventArgs e)
{
MorClient.PublicPara.PlcTool.CaVacuumSuction();
}
private void uiButton6_MouseDown(object sender, MouseEventArgs e)
{
MorClient.PublicPara.PlcTool.ValveControlLowOrder("4410");
}
private void uiButton6_MouseUp(object sender, MouseEventArgs e)
{
//MorClient.PublicPara.PlcTool.CaInitializationUp();
}
private void uiButton4_MouseDown(object sender, MouseEventArgs e)
{
MorClient.PublicPara.PlcTool.ValveControlHighOrder("4410");
}
private void uiButton4_MouseUp(object sender, MouseEventArgs e)
{
//MorClient.PublicPara.PlcTool.CaSingleActionUp();
}
private void uiButton5_MouseDown(object sender, MouseEventArgs e)
{
MorClient.PublicPara.PlcTool.CaRepairDown();
}
private void uiButton5_MouseUp(object sender, MouseEventArgs e)
{
MorClient.PublicPara.PlcTool.CaRepairUp();
}
#endregion 工位操作
private void uiButton3_MouseEnter(object sender, EventArgs e)
{
if (uiButton3.FillColor == Color.FromArgb(146, 208, 80))
{
uiButton3.FillColor = Color.FromArgb(146, 208, 80);
uiButton3.FillHoverColor = Color.FromArgb(146, 208, 80);
}
else if (uiButton3.FillColor == Color.FromArgb(32, 56, 100))
{
uiButton3.FillColor = Color.FromArgb(32, 56, 100);
uiButton3.FillHoverColor = Color.FromArgb(32, 56, 100);
}
}
private void uiButton1_MouseEnter(object sender, EventArgs e)
{
if (uiButton1.FillColor == Color.FromArgb(146, 208, 80))
{
uiButton1.FillColor = Color.FromArgb(146, 208, 80);
uiButton1.FillHoverColor = Color.FromArgb(146, 208, 80);
}
else if (uiButton1.FillColor == Color.FromArgb(32, 56, 100))
{
uiButton1.FillColor = Color.FromArgb(32, 56, 100);
uiButton1.FillHoverColor = Color.FromArgb(32, 56, 100);
}
}
private void uiButton2_MouseEnter(object sender, EventArgs e)
{
if (uiButton2.FillColor == Color.FromArgb(146, 208, 80))
{
uiButton2.FillColor = Color.FromArgb(146, 208, 80);
uiButton2.FillHoverColor = Color.FromArgb(146, 208, 80);
}
else if (uiButton2.FillColor == Color.FromArgb(32, 56, 100))
{
uiButton2.FillColor = Color.FromArgb(32, 56, 100);
uiButton2.FillHoverColor = Color.FromArgb(32, 56, 100);
}
}
private void uiButton4_MouseEnter(object sender, EventArgs e)
{
if (uiButton4.FillColor == Color.FromArgb(146, 208, 80))
{
uiButton4.FillColor = Color.FromArgb(146, 208, 80);
uiButton4.FillHoverColor = Color.FromArgb(146, 208, 80);
}
else if (uiButton4.FillColor == Color.FromArgb(32, 56, 100))
{
uiButton4.FillColor = Color.FromArgb(32, 56, 100);
uiButton4.FillHoverColor = Color.FromArgb(32, 56, 100);
}
}
}
}