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.

208 lines
7.1 KiB
C#

using NPOI.SS.Formula.Eval;
using Rs.Framework;
using Rs.MotionPlat.Entitys;
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;
namespace Rs.MotionPlat
{
public partial class UFixture : UserControl
{
public UFixture()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
}
private string fixtureName;
public string FixtureName
{
get { return fixtureName; }
set { fixtureName = value;
lblFixtureName.Text = fixtureName;
}
}
public void RefreshStatus(TestFixture tf)
{
if (lblStatus.Text != tf.Status.ToString())
{
lblStatus.Text = tf.Status.ToString();
}
if (tf.Status== ETestFixtureStatus.Testing)
{
if(lblFixtureName.BackColor != Color.Blue)
{
lblFixtureName.BackColor = Color.Blue;
}
if (lblSN.Text != tf.Product.SN)
{
lblSN.Text = tf.Product.SN;
}
}
else if(tf.Status== ETestFixtureStatus.IDLE)
{
if (tf.Product != null)
{
if (tf.Product.Result == "true" && lblFixtureName.BackColor != Color.Green)
{
lblFixtureName.BackColor = Color.Green;
}
if (tf.Product.Result == "false" && lblFixtureName.BackColor != Color.Red)
{
lblFixtureName.BackColor = Color.Red;
}
if (lblResult.Text != tf.Product.Result)
{
lblResult.Text = tf.Product.Result.ToString();
}
}
else
{
lblSN.Text = "";
lblFixtureName.BackColor = Color.FromArgb(56, 56, 56);
}
}
else if(tf.Status== ETestFixtureStatus.Homing)
{
if(btnReset.Enabled!=false)
{
btnReset.Enabled = false;
}
}
if(lblName.Text!=tf.MachineID)
{
lblName.Text = tf.MachineID;
}
if(lblLotName.Text!= GlobalVar.LotName)
{
lblLotName.Text = GlobalVar.LotName;
}
if(lblEnable.Text!=tf.Enable.ToString())
{
//this.lblFixtureName.Enabled = tf.Enable;
lblEnable.Text = tf.Enable.ToString();
}
this.lblYield.Text = $"{(tf.Yield * 100).ToString("0.00")}%";
if(this.lblLastCT.Text != double.Parse(tf.LastCT.ToString()).ToString("0.000"))
{
this.lblLastCT.Text = double.Parse(tf.LastCT.ToString()).ToString("0.000");
}
if(lblPassCount.Text != tf.PassCount.ToString())
{
lblPassCount.Text = tf.PassCount.ToString();
}
if(lblTotalCount.Text != tf.TotalCount.ToString())
{
lblTotalCount.Text = tf.TotalCount.ToString();
}
if(this.lblFixtureName.Enabled!=tf.Enable)
{
this.lblFixtureName.Enabled= tf.Enable;
}
}
//public void BindEntity(TestFixture tf)
//{
// this.lblIndex.Text = tf.Index.ToString();
// tf.OnProChange += Tf_OnProChange;
// //this.lblStatus.DataBindings.Add("Text", tf, "Status");
// lblPassCount.DataBindings.Add("Text", tf, "PassCount");
// lblTotalCount.DataBindings.Add("Text", tf, "TotalCount");
// //lblIndex.DataBindings.Add("Text",tf, "Index");
// //lblYield.DataBindings.Add("Text", tf, "Yield");
// //lblResult.DataBindings.Add("Text", tf, "Result");
// lblName.DataBindings.Add("Text", tf, "MachineID");
// //lblEnable.DataBindings.Add("Text", tf, "Enable");
// //lblLastCT.DataBindings.Add("Text", tf, "LastCT");
// lblLotName.Text = GlobalVar.LotName;
//}
//private void Tf_OnProChange(string arg1, object arg2)
//{
// this.Invoke(new Action(() => {
// switch (arg1)
// {
// case "Enable":
// if (arg2.ToString() == "False")
// {
// this.lblFixtureName.Enabled = false;
// }
// else
// {
// this.lblFixtureName.Enabled = true;
// }
// this.lblEnable.Text = arg2.ToString();
// break;
// case "Status":
// if (arg2.ToString() == "Testing")
// {
// lblFixtureName.BackColor = Color.Blue;
// }
// else if(arg2.ToString()=="Homing")
// {
// btnReset.Enabled = false;
// }
// else
// {
// btnReset.Enabled = true;
// }
// this.lblStatus.Text = arg2.ToString();
// break;
// case "Yield":
// this.lblYield.Text = $"{(double.Parse(arg2.ToString()) * 100).ToString("0.00")}%";
// break;
// case "Product":
// if (arg2 != null)
// {
// lblSN.Text = ((TestProduct)arg2).SN;
// }
// else
// {
// lblSN.Text = "";
// lblFixtureName.BackColor = Color.FromArgb(56, 56, 56);
// }
// break;
// case "Result":
// if (arg2.ToString() == "true")
// {
// lblFixtureName.BackColor = Color.Green ;
// }
// else
// {
// lblFixtureName.BackColor = Color.Red;
// }
// lblResult.Text = arg2.ToString();
// break;
// case "LastCT":
// this.lblLastCT.Text = double.Parse(arg2.ToString()).ToString("0.000");
// break;
// default:
// break;
// }
// }));
//}
private void btnReset_Click(object sender, EventArgs e)
{
TestFixtureManager.Instance.GetTestFixture(int.Parse(lblIndex.Text)).Home();
}
}
}