RGVInfo.xaml.cs 3.6 KB
using HHECS.Application.Enums;
using HHECS.BLL.EquipmentExcute;
using HHECS.Executor.EquipmentHandler;
using HHECS.Model.Entities;
using HHHECS.Model.Enums;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using HHECS.Infrastructure.CommonHelper;
using System.Linq;

namespace HHECS.WinCommon.Controls
{
    /// <summary>
    /// MarkingMonitor.xaml 的交互逻辑
    /// </summary>
    public partial class RGVInfo : UserControl
    {
        public Equipment Self { get; set; }
        public string ControlName
        {
            get { return (string)GetValue(ControlNameProperty); }
            set { SetValue(ControlNameProperty, value); }
        }

        public static readonly DependencyProperty ControlNameProperty =
            DependencyProperty.Register("ControlName", typeof(string), typeof(RGVInfo), new PropertyMetadata(""));
        public RGVInfo()
        {
            InitializeComponent();
            this.txt_RGVName.SetBinding(TextBlock.TextProperty, new Binding("ControlName") { Source = this });
        }

      

        /// <summary>
        /// key :线体code ,value:ip 地址
        /// </summary>
        /// <param name="dicMarking"></param>
        public void SetRGVProps(Equipment RGV,List<Equipment> allEquipments)
        {
            Self = RGV;

         

            var Status = Self[StationProps.RGVStatus.ToString()];
            if (Status != null)
            {
                if (int.TryParse(Status.Value, out int status))
                {
                    txt_RGVStatus.Text = typeof(EquipmentStatus).GetDescriptionString(status);
                }
                else
                {
                    txt_RGVStatus.Text = "未识别";
                }
            }

            var RGVNow = Self[StationProps.RGVNow.ToString()];
            if (RGVNow != null)
            {
                if (!string.IsNullOrEmpty(RGVNow.Value))
                {
                    if (RGVNow.Value == "0")
                    {
                        txt_RGVNow.Text = "未获取";
                    }
                    else
                    {
                        txt_RGVNow.Text = allEquipments.Find(t => t.SelfAddress == RGVNow.Value).Name;
                    }
                    
                }
            }

            var RGVStart = Self[StationProps.RGVStart.ToString()];
            if (RGVStart != null)
            {
                if (!string.IsNullOrEmpty(RGVStart.Value))
                {
                    if (RGVStart.Value=="0")
                    {
                        txt_RGVStart.Text = "未获取";                    }
                    else
                    {
                        txt_RGVStart.Text = allEquipments.Find(t => t.SelfAddress == RGVStart.Value).Name;
                    }
                    
                }
            }

            var RGVEnd = Self[StationProps.RGVEnd.ToString()];
            if (RGVEnd != null)
            {
                if (!string.IsNullOrEmpty(RGVEnd.Value))
                {
                    if (RGVEnd.Value == "0")
                    {
                        txt_RGVEnd.Text = "未获取";
                    }
                    else if (RGVEnd.Value == "2010")
                    {
                        txt_RGVEnd.Text = "下线工位";
                    }
                    else
                    {
                        txt_RGVEnd.Text = allEquipments.Find(t => t.SelfAddress == RGVEnd.Value).Name;
                    }
                    
                }
            }
        }

    }
}