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.

638 lines
22 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using System.Data;
namespace Mesnac.Controls.Feeding
{
/// <summary>
/// 物料(胶料、小料)称量状态
/// </summary>
[ToolboxBitmap(typeof(System.Windows.Forms.Label))]
public class MaterialStatus : Label
{
#region 字段定义
private int _firstPloy = 0;
private int _secondPloy = 0;
private int _thirdPloy = 0;
private int _fourthPloy = 0;
private int _fifthPloy = 0;
private int _sixthPloy = 0;
private int _seventhPloy = 0;
private int _eighthPloy = 0;
private int _ninethPloy = 0;
private int _tenthPloy = 0;
private int _eleventhPloy = 0;
private int _twelvethPloy = 0;
private int _thirteenthPloy = 0;
private int _fourteenthPloy = 0;
private int _fifteenthPloy = 0;
private int _sendingPloy = 0;
private int _endAndWaitPloy = 0;
private int _endWeight = 0;
private int _weightAuto = 0;
private string _materialType=string.Empty;
private string _firstPloyName;
private string _secondPloyName;
private string _thirdPloyName;
private string _fourthPloyName;
private string _fifthPloyName;
private string _sixthPloyName;
private string _seventhPloyName;
private string _eightPloyName;
private string _ninethPloyName;
private string _tenthPloyName;
private string _eleventhPloyName;
private string _twelvethPloyName;
private string _thirteenthPloyName;
private string _fourteenthPloyName;
private string _fifteenthPloyName;
private string _sendingPloyName;
private string _endAndWaitPloyName;
private string _endWeightName;
private string _weightAutoName;
private Dictionary<string, string> _plyStatusValueList = new Dictionary<string, string>() { { "FirstPloy", "正在称量第一种胶料" }, { "SecondPloy", "正在称量第二种胶料" }, { "ThirdPloy", "正在称量第三种胶料" }, { "FourthPloy", "正在称量第四种胶料" }, { "FifthPloy", "正在称量第五种胶料" }, { "SixthPloy", "正在称量第六种胶料" }, { "SeventhPloy", "正在称量第七种胶料" }, { "EighthPloy", "正在称量第八种胶料" }, { "NinethPloy", "正在称量第九种胶料" }, { "TenthPloy", "正在称量第十种胶料" }, { "EleventhPloy", "正在称量第十一种胶料" }, { "TwelvethPloy", "正在称量第十二种胶料" }, { "ThirteenthPloy", "正在称量第十三种胶料" }, { "FourteenthPloy", "正在称量第十四种胶料" }, { "FifteenthPloy", "正在称量第十五种胶料" }, { "SendingPloy", "正在送胶料..." }, { "EndAndWaitPloy", "等待送胶料" }, { "WeightAuto0", "手动" }, { "WeightAuto1", "自动" } };
private Dictionary<string, string> _smallStatusValueList = new Dictionary<string, string>() { { "FirstPloy", "正在称量第一种小料" }, { "SecondPloy", "正在称量第二种小料" }, { "ThirdPloy", "正在称量第三种小料" }, { "FourthPloy", "正在称量第四种小料" }, { "FifthPloy", "正在称量第五种小料" }, { "SixthPloy", "正在称量第六种小料" }, { "SendingPloy", "正在送小料..." }, { "EndAndWaitPloy", "等待送小料" }, { "WeightAuto0", "手动" }, { "WeightAuto1", "自动" } };
#endregion
#region 属性定义
[TypeConverter(typeof(MaterialTypeConverter)), Category("Design")]
public string MaterialType
{
get { return _materialType; }
set
{
_materialType = value;
}
}
/// <summary>
/// 正在称第01种物料
/// </summary>
[Description("正在称第01种物料"), Category("PLC")]
public int FirstPloy
{
get { return _firstPloy; }
set
{
_firstPloy = value;
this.RefereshText();
}
}
/// <summary>
/// 正在称第02种物料
/// </summary>
[Description("正在称第02种物料"), Category("PLC")]
public int SecondPloy
{
get { return _secondPloy; }
set
{
_secondPloy = value;
this.RefereshText();
}
}
/// <summary>
/// 正在称第03种物料
/// </summary>
[Description("正在称第03种物料"), Category("PLC")]
public int ThirdPloy
{
get { return _thirdPloy; }
set
{
_thirdPloy = value;
this.RefereshText();
}
}
/// <summary>
/// 正在称第04种物料
/// </summary>
[Description("正在称第04种物料"), Category("PLC")]
public int FourthPloy
{
get { return _fourthPloy; }
set
{
_fourthPloy = value;
this.RefereshText();
}
}
/// <summary>
/// 正在称第05种物料
/// </summary>
[Description("正在称第05种物料"), Category("PLC")]
public int FifthPloy
{
get { return _fifthPloy; }
set
{
_fifthPloy = value;
this.RefereshText();
}
}
/// <summary>
/// 正在称第06种物料
/// </summary>
[Description("正在称第06种物料"), Category("PLC")]
public int SixthPloy
{
get { return _sixthPloy; }
set
{
_sixthPloy = value;
this.RefereshText();
}
}
/// <summary>
/// 正在称第07种物料
/// </summary>
[Description("正在称第07种物料"), Category("PLC")]
public int SeventhPloy
{
get { return _seventhPloy; }
set
{
_seventhPloy = value;
this.RefereshText();
}
}
/// <summary>
/// 正在称第08种物料
/// </summary>
[Description("正在称第08种物料"), Category("PLC")]
public int EighthPloy
{
get { return _eighthPloy; }
set { _eighthPloy = value; }
}
/// <summary>
/// 正在称第09种物料
/// </summary>
[Description("正在称第09种物料"), Category("PLC")]
public int NinethPloy
{
get { return _ninethPloy; }
set { _ninethPloy = value; }
}
/// <summary>
/// 正在称第10种物料
/// </summary>
[Description("正在称第10种物料"), Category("PLC")]
public int TenthPloy
{
get { return _tenthPloy; }
set { _tenthPloy = value; }
}
/// <summary>
/// 正在称第11种物料
/// </summary>
[Description("正在称第11种物料"), Category("PLC")]
public int EleventhPloy
{
get { return _eleventhPloy; }
set { _eleventhPloy = value; }
}
/// <summary>
/// 正在称第12种物料
/// </summary>
[Description("正在称第12种物料"), Category("PLC")]
public int TwelvethPloy
{
get { return _twelvethPloy; }
set { _twelvethPloy = value; }
}
/// <summary>
/// 正在称第13种物料
/// </summary>
[Description("正在称第13种物料"), Category("PLC")]
public int ThirteenthPloy
{
get { return _thirteenthPloy; }
set { _thirteenthPloy = value; }
}
/// <summary>
/// 正在称第14种物料
/// </summary>
[Description("正在称第14种物料"), Category("PLC")]
public int FourteenthPloy
{
get { return _fourteenthPloy; }
set { _fourteenthPloy = value; }
}
/// <summary>
/// 正在称第15种物料
/// </summary>
[Description("正在称第15种物料"), Category("PLC")]
public int FifteenthPloy
{
get { return _fifteenthPloy; }
set { _fifteenthPloy = value; }
}
/// <summary>
/// 正在送物料
/// </summary>
[Description("正在送物料"), Category("PLC")]
public int SendingPloy
{
get { return _sendingPloy; }
set { _sendingPloy = value; this.RefereshText(); }
}
/// <summary>
/// 称量结束等待送物料
/// </summary>
[Description("称量结束等待送物料"), Category("PLC")]
public int EndAndWaitPloy
{
get { return _endAndWaitPloy; }
set { _endAndWaitPloy = value; this.RefereshText(); }
}
/// <summary>
/// 结束称量
/// </summary>
[Description("结束称量"), Category("PLC")]
public int EndWeight
{
get { return _endWeight; }
set { _endWeight = value; this.RefereshText(); }
}
/// <summary>
/// 秤自动
/// </summary>
[Description("秤自动"), Category("PLC")]
public int WeightAuto
{
get { return _weightAuto; }
set { _weightAuto = value; this.RefereshText(); }
}
#endregion
#region 动画属性定义
/// <summary>
/// 正在称第01种物料动画属性
/// </summary>
public string FirstPloyName
{
get { return _firstPloyName; }
set { _firstPloyName = value; }
}
/// <summary>
/// 正在称第02种物料动画属性
/// </summary>
public string SecondPloyName
{
get { return _secondPloyName; }
set { _secondPloyName = value; }
}
/// <summary>
/// 正在称第03种物料动画属性
/// </summary>
public string ThirdPloyName
{
get { return _thirdPloyName; }
set { _thirdPloyName = value; }
}
/// <summary>
/// 正在称第04种物料动画属性
/// </summary>
public string FourthPloyName
{
get { return _fourthPloyName; }
set { _fourthPloyName = value; }
}
/// <summary>
/// 正在称第05种物料动画属性
/// </summary>
public string FifthPloyName
{
get { return _fifthPloyName; }
set { _fifthPloyName = value; }
}
/// <summary>
/// 正在称第06种物料动画属性
/// </summary>
public string SixthPloyName
{
get { return _sixthPloyName; }
set { _sixthPloyName = value; }
}
/// <summary>
/// 正在称第07种物料动画属性
/// </summary>
public string SeventhPloyName
{
get { return _seventhPloyName; }
set { _seventhPloyName = value; }
}
/// <summary>
/// 正在称第08种物料动画属性
/// </summary>
public string EightPloyName
{
get { return _eightPloyName; }
set { _eightPloyName = value; }
}
/// <summary>
/// 正在称第09种物料动画属性
/// </summary>
public string NinethPloyName
{
get { return _ninethPloyName; }
set { _ninethPloyName = value; }
}
/// <summary>
/// 正在称第10种物料动画属性
/// </summary>
public string TenthPloyName
{
get { return _tenthPloyName; }
set { _tenthPloyName = value; }
}
/// <summary>
/// 正在称第11种物料动画属性
/// </summary>
public string EleventhPloyName
{
get { return _eleventhPloyName; }
set { _eleventhPloyName = value; }
}
/// <summary>
/// 正在称第12种物料动画属性
/// </summary>
public string TwelvethPloyName
{
get { return _twelvethPloyName; }
set { _twelvethPloyName = value; }
}
/// <summary>
/// 正在称第13种物料动画属性
/// </summary>
public string ThirteenthPloyName
{
get { return _thirteenthPloyName; }
set { _thirteenthPloyName = value; }
}
/// <summary>
/// 正在称第14种物料动画属性
/// </summary>
public string FourteenthPloyName
{
get { return _fourteenthPloyName; }
set { _fourteenthPloyName = value; }
}
/// <summary>
/// 正在称第15种物料动画属性
/// </summary>
public string FifteenthPloyName
{
get { return _fifteenthPloyName; }
set { _fifteenthPloyName = value; }
}
/// <summary>
/// 正在送物料动画属性
/// </summary>
public string SendingPloyName
{
get { return _sendingPloyName; }
set { _sendingPloyName = value; }
}
/// <summary>
/// 称量结束等待送物料动画属性
/// </summary>
public string EndAndWaitPloyName
{
get { return _endAndWaitPloyName; }
set { _endAndWaitPloyName = value; }
}
/// <summary>
/// 结束称量动画属性
/// </summary>
public string EndWeightName
{
get { return _endWeightName; }
set { _endWeightName = value; }
}
/// <summary>
/// 秤自动动画属性
/// </summary>
public string WeightAutoName
{
get { return _weightAutoName; }
set { _weightAutoName = value; }
}
#endregion
#region 业务逻辑处理,根据各属性值确定小料状态
/// <summary>
/// 根据各属性值确定小料状态
/// </summary>
private void RefereshText()
{
string tmp = String.Empty;
if (this._firstPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["FirstPloy"]; //"正在称量第01种物料";
}
else
{
tmp=this._smallStatusValueList["FirstPloy"];
}
}
if (this._secondPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["SecondPloy"]; //"正在称量第02种物料";
}
else
{
tmp = this._smallStatusValueList["SecondPloy"];
}
}
if (this._thirdPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["ThirdPloy"]; //"正在称量第03种物料";
}
else
{
tmp = this._smallStatusValueList["ThirdPloy"];
}
}
if (this._fourthPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["FourthPloy"]; //"正在称量第04种物料";
}
else
{
tmp = this._smallStatusValueList["FourthPloy"];
}
}
if (this._fifthPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["FifthPloy"]; //"正在称量第05种物料";
}
else
{
tmp = this._smallStatusValueList["FifthPloy"];
}
}
if (this._sixthPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["SixthPloy"]; //"正在称量第06种物料";
}
else
{
tmp = this._smallStatusValueList["SixthPloy"];
}
}
if (this._seventhPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["SeventhPloy"]; //"正在称量第07种物料";
}
}
if (this._eighthPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["EighthPloy"]; //"正在称量第08种物料";
}
}
if (this._ninethPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["NinethPloy"]; //"正在称量第09种物料";
}
}
if (this._tenthPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["TenthPloy"]; //"正在称量第10种物料";
}
}
if (this._eleventhPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["EleventhPloy"]; //"正在称量第11种物料";
}
}
if (this._twelvethPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["TwelvethPloy"]; //"正在称量第12种物料";
}
}
if (this._thirteenthPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["ThirteenthPloy"]; //"正在称量第13种物料";
}
}
if (this._fourteenthPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["FourteenthPloy"]; //"正在称量第14种物料";
}
}
if (this.FifteenthPloy == 1 && !String.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["FifteenthPloy"]; //"正在称量第15种物料";
}
}
if (this._sendingPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["SendingPloy"]; //"正在送料...";
}
else
{
tmp = this._smallStatusValueList["SendingPloy"];
}
}
if (this._endAndWaitPloy == 1 && !string.IsNullOrWhiteSpace(_materialType))
{
if (_materialType == "胶料")
{
tmp = this._plyStatusValueList["EndAndWaitPloy"]; //"等待送小料";
}
else
{
tmp = this._smallStatusValueList["EndAndWaitPloy"];
}
}
//if (this._endWeight == 0 && !string.IsNullOrWhiteSpace(_materialType))
//{
// if (this._weightAuto == 0)
// {
// if (_materialType == "胶料")
// {
// tmp = this._plyStatusValueList["WeightAuto0"]; //"手动";
// }
// else
// {
// tmp = this._smallStatusValueList["WeightAuto0"];
// }
// }
//}
//else
//{
// if (this._weightAuto == 1)
// {
// if (_materialType == "胶料")
// {
// tmp = this._plyStatusValueList["WeightAuto1"]; //"手动";
// }
// else
// {
// tmp = this._smallStatusValueList["WeightAuto1"];
// }
// }
//}
this.Text = tmp;
}
#endregion
///// <summary>
///// 状态值列表,键固定
///// </summary>
//[Description("状态值集合"), Category("状态")]
//public Dictionary<string, string> StatusValueList
//{
// get { return _statusValueList; }
// set { _statusValueList = value; }
//}
}
}