ConveyorModel.cs 6.71 KB
using HHECS.Application.Enums;
using HHECS.Model.Entities;
using HHECS.Model.Enums;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace HHECS.WinCommon.ViewModel
{
    /// <summary>
    /// 输送线站台显示
    /// </summary>
    public class ConveyorModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        #region 站台信息 
        public int LineId { get; set; }
        public string LineCode { get; set; }
        public string Code { get; set; }
        public string Name { get; set; }
        public string CanOut { get; set; }
        #endregion

        #region 设备状态 
        public string OperationModel { get; set; }
        public string Status { get; set; }
        public string AllowEntry { get; set; }
        public string TotalError { get; set; }

        #endregion

        #region PLC地址请求 1
        public string RequestMessage { get; set; }
        public string RequestLoadStatus { get; set; }
        public string RequestNumber { get; set; }
        public string RequestBarcode { get; set; }
        public string RequestProductType { get; set; }
        public string RequestBackup { get; set; }
        #endregion

        #region PLC位置到达 1
        public string ArriveMessage { get; set; }
        public string ArriveResult { get; set; }
        public string ArriveRealAddress { get; set; }
        public string ArriveAllcationAddress { get; set; }
        public string ArriveBarcode { get; set; }
        public string ArriveProductType { get; set; }
        public string ArriveBackUp { get; set; }
        #endregion

        #region PLC控制指令 
        public string ControlMessage { get; set; }
        public string ControlType { get; set; }
        public string ControlNumber { get; set; }
        public string ControlBarcode { get; set; }
        public string ControlBackup { get; set; }
        #endregion

        #region PLC应答信号 1
        public string ACKMessage { get; set; }
        public string ACKLoadStatus { get; set; }
        public string ACKNumber { get; set; }
        public string ACKBarcode { get; set; }
        public string ACKBackup { get; set; }
        #endregion

        #region WCS回复请求 1
        public string WCSReplyMessage { get; set; }
        public string WCSReplyLoadStatus { get; set; }
        public string WCSReplyNumber { get; set; }
        public string WCSReplyAddress { get; set; }
        public string WCSReplyBarcode { get; set; }
        public string WCSReplyProductType { get; set; }
        public string WCSReplyMaterial { get; set; }
        public string WCSReplyLength { get; set; }
        public string WCSReplyDiameter { get; set; }
        public string WCSReplyThickness { get; set; }
        public string WCSReplyBackUp { get; set; }
        #endregion

        #region WCS控制指令 1
        public string WCSControlMessage { get; set; }
        public string WCSControlType { get; set; }
        public string WCSControlNumber { get; set; }
        public string WCSControlBarcode { get; set; }
        public string WCSControlMaterial { get; set; }
        public string WCSControlLength { get; set; }
        public string WCSControlDiameter { get; set; }
        public string WCSControlThickness { get; set; }
        public string WCSControlBackup { get; set; }
        #endregion

        #region WCS应答信号 1
        public string WCSACKMessage { get; set; }
        public string WCSACKLoadStatus { get; set; }
        public string WCSACKNumber { get; set; }
        public string WCSACKBarcode { get; set; }
        public string WCSACKProductType { get; set; }
        public string WCSACKMaterial { get; set; }
        public string WCSACKLength { get; set; }
        public string WCSACKDiameter { get; set; }
        public string WCSACKThickness { get; set; }
        public string WCSACKParameter { get; set; }
        public string WCSACKBackup { get; set; }

        #endregion



        public void SetProp(List<EquipmentProp> props, List<Equipment> allEquipments)
        {
            if (props == null)
            {
                return;
            }
            foreach (var item in GetType().GetProperties())
            {
                var temp = props.FirstOrDefault(t => t.EquipmentTypePropTemplateCode == item.Name);
                if (temp != null)
                {
                    item.SetValue(this, temp.Value);
                    if (PropertyChanged != null)
                    {
                        PropertyChanged.Invoke(this, new PropertyChangedEventArgs(item.Name));
                    }
                }
                else
                {
                    if (item.Name == "CanOut")
                    {
                        Equipment station = allEquipments.FirstOrDefault(t => t.Code == Code);
                        if (station == null)
                        {
                            item.SetValue(this, "未获取");
                        }
                        else
                        {
                            //var outMonitor = allEquipments.FirstOrDefault(t => t.EquipmentType.Code == EquipmentTypeConst.StationOutMonitor.ToString() && t.DestinationArea == station.DestinationArea);
                            //if (outMonitor == null)
                            //{
                            //    item.SetValue(this, "未获取");
                            //}
                            //else
                            //{
                            //    var canout = outMonitor.EquipmentProps.FirstOrDefault(t => t.EquipmentTypePropTemplateCode == station.StationIndex.ToString());
                            //    if (canout == null)
                            //    {
                            //        item.SetValue(this, "无");
                            //    }
                            //    else
                            //    {
                            //        //if (canout.Value == StationTaskLimit.Out.GetIndexString())
                            //        //{
                            //        //    item.SetValue(this, "可出");
                            //        //}
                            //        //else
                            //        //{
                            //        //    item.SetValue(this, "不可出");
                            //        //}
                            //    }
                            //}
                        }

                        if (PropertyChanged != null)
                        {
                            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(item.Name));
                        }
                    }
                }
            }
        }
    }
}