using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; using System.ComponentModel; namespace Mesnac.Controls.Feeding { /// /// 小料称量状态 /// [ToolboxBitmap(typeof(System.Windows.Forms.Label))] public class SmallMaterialStatus : Label { #region 字段定义 private int _firstPloy = 0; private int _sendingPloy = 0; private int _endAndWaitPloy = 0; private int _endWeight = 0; private int _weightAuto = 0; private string _firstPloyName; private string _sendingPloyName; private string _endAndWaitPloyName; private string _endWeightName; private string _weightAutoName; private Dictionary _statusValueList = new Dictionary() { { "FirstPloy", "正在称量小料" }, { "SendingPloy", "正在送小料..." }, { "EndAndWaitPloy", "等待送小料" }, { "WeightAuto", "称量正确" } }; #endregion #region 属性定义 /// /// 正在称第一种小料 /// [Description("正在称第一种小料"), Category("PLC")] public int FirstPloy { get { return _firstPloy; } set { _firstPloy = value; this.RefereshText(); } } /// /// 正在送小料 /// [Description("正在送小料"), Category("PLC")] public int SendingPloy { get { return _sendingPloy; } set { _sendingPloy = value; this.RefereshText(); } } /// /// 称量结束等待送小料 /// [Description("称量结束等待送小料"), Category("PLC")] public int EndAndWaitPloy { get { return _endAndWaitPloy; } set { _endAndWaitPloy = value; this.RefereshText(); } } /// /// 结束称量 /// [Description("结束称量"), Category("PLC")] public int EndWeight { get { return _endWeight; } set { _endWeight = value; this.RefereshText(); } } /// /// 秤自动 /// [Description("秤自动"), Category("PLC")] public int WeightAuto { get { return _weightAuto; } set { _weightAuto = value; this.RefereshText(); } } #endregion #region 动画属性定义 /// /// 正在称第一种小料动画属性 /// public string FirstPloyName { get { return _firstPloyName; } set { _firstPloyName = value; } } /// /// 正在送小料动画属性 /// public string SendingPloyName { get { return _sendingPloyName; } set { _sendingPloyName = value; } } /// /// 称量结束等待送小料动画属性 /// public string EndAndWaitPloyName { get { return _endAndWaitPloyName; } set { _endAndWaitPloyName = value; } } /// /// 结束称量动画属性 /// public string EndWeightName { get { return _endWeightName; } set { _endWeightName = value; } } /// /// 秤自动动画属性 /// public string WeightAutoName { get { return _weightAutoName; } set { _weightAutoName = value; } } #endregion #region 业务逻辑处理,根据各属性值确定小料状态 /// /// 根据各属性值确定小料状态 /// private void RefereshText() { string tmp = String.Empty; if (this._firstPloy == 1) { tmp = this._statusValueList["FirstPloy"]; //"正在称量小料"; } if (this._sendingPloy == 1) { tmp = this._statusValueList["SendingPloy"]; //"正在送小料..."; } if (this._endAndWaitPloy == 1) { tmp = this._statusValueList["EndAndWaitPloy"]; //"等待送小料"; } if (this._endWeight == 0) { if (this._weightAuto == 1) { tmp = this._statusValueList["WeightAuto"]; //"称量正确"; } } this.Text = tmp; } #endregion /// /// 状态值列表,键固定 /// [Description("状态值集合"), Category("状态")] public Dictionary StatusValueList { get { return _statusValueList; } set { _statusValueList = value; } } } }