Ejemplo n.º 1
0
        /// <summary>
        /// 控制模式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_controlMode_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;

            if (Self != null)
            {
                //var carStatus = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.carStatus.ToString());
                //if (carStatus.Value != CarStatus.idle.GetIndexString())
                //{
                //    MessageBox.Show("小车状态不是空闲,不能设置!");
                //    return;
                //}
                var wcsControlMode = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsControlMode.ToString());
                if (wcsControlMode != null)
                {
                    wcsControlMode.Value = "1";
                    var temp = CommandControlMode?.Invoke(Self);
                    if (temp == null)
                    {
                        MessageBox.Show($"未处理{button.Content}事件");
                    }
                    else
                    {
                        if (temp.Success)
                        {
                            //MessageBox.Show("取货错误处理成功");
                        }
                        else
                        {
                            MessageBox.Show($"{button.Content}操作失败:{temp.Msg}");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("操作失败,通信中断,请重试!");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 赋值属性
        /// </summary>
        /// <param name="deviceEntity"></param>
        /// <param name="props"></param>
        /// <param name="address"></param>
        public void SetProps(IEnumerable <Equipment> equipments)
        {
            Self = equipments.FirstOrDefault(t => t.Code == ControlName);
            if (Self == null)
            {
                //feeder = null;
                return;
            }

            //if (Self.Code == "car1")
            //{
            //    feeder = equipments.FirstOrDefault(x => x.Code == "Feeder2");
            //}
            //else
            //{
            //    feeder = equipments.FirstOrDefault(x => x.Code == "Feeder1");
            //}

            try
            {
                #region 监控文本赋值

                var hasPallet = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.hasPallet.ToString()).Value;
                if (hasPallet != null)
                {
                    lab_hasPallet.Foreground = Brushes.Blue;
                    switch (hasPallet)
                    {
                    case "0":
                        lab_hasPallet.Content = "初始";
                        break;

                    case "1":
                        lab_hasPallet.Content = "无货";
                        break;

                    case "2":
                        lab_hasPallet.Content = "有货";
                        break;

                    default:
                        lab_hasPallet.Content    = "未获取或不识别";
                        lab_hasPallet.Foreground = Brushes.Red;
                        break;
                    }
                }

                var carNo = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.carNo.ToString()).Value;
                if (!string.IsNullOrEmpty(carNo))
                {
                    lab_carNo.Foreground = Brushes.Blue;
                    lab_carNo.Content    = carNo;
                }

                var row = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.row.ToString()).Value;
                if (row != null)
                {
                    lab_Row.Foreground = Brushes.Blue;
                    lab_Row.Content    = row;
                }
                var TaskHeaderID = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.TaskHeaderID.ToString()).Value;
                if (TaskHeaderID != null)
                {
                    lab_taskHeaderId.Foreground = Brushes.Blue;
                    lab_taskHeaderId.Content    = TaskHeaderID;
                }
                var TaskCarId = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.TaskCarId.ToString()).Value;
                if (TaskCarId != null)
                {
                    lab_taskCarId.Foreground = Brushes.Blue;
                    lab_taskCarId.Content    = TaskCarId;
                }



                //显示任务类型
                var actionType = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.actionType.ToString()).Value;
                if (this.carActionTypeList.ContainsKey(actionType))
                {
                    lab_actionType.Content = this.carActionTypeList[actionType];
                }
                //显示设备状态
                var carStatus = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.carStatus.ToString()).Value;
                if (this.carStatusList.ContainsKey(carStatus))
                {
                    lab_carStatus.Content = this.carStatusList[carStatus];
                }
                //显示控制模式
                var controlMode = Self.EquipmentProps.FirstOrDefault(t => t.EquipmentTypeTemplateCode == CarMonitorProps.controlMode.ToString()).Value;
                if (this.controlModeList.ContainsKey(controlMode))
                {
                    lab_controlMode.Content = this.controlModeList[controlMode];
                }

                //错误信息显示
                var tempProps = Self.EquipmentProps.FindAll(t => t.EquipmentTypeTemplate.IsMonitor == true);
                foreach (var item in tempProps)
                {
                    if (item.Value != item.EquipmentTypeTemplate.MonitorCompareValue)
                    {
                        AddAlarm("报警:" + item.EquipmentTypeTemplate.Name + " 信息:" + item.EquipmentTypeTemplate.MonitorFailure, 2);
                    }
                    else
                    {
                        RemoveAlarm("报警:" + item.EquipmentTypeTemplate.Name + " 信息:" + item.EquipmentTypeTemplate.MonitorFailure);
                    }
                }

                #endregion

                #region 清除WCS写入的DB块

                //清除【行列层】设置

                var wcsActionType = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsActionType.ToString());
                if (wcsActionType.Value == CarActionType.ResetLocation.GetIndexString())
                {
                    var wcsRow = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.row.ToString());
                    if (wcsRow.Value != "0")
                    {
                        var wcsSwitch = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsSwitch.ToString());
                        wcsSwitch.Value     = "0";
                        wcsActionType.Value = CarActionType.Init.GetIndexString();
                        wcsRow.Value        = "0";
                        CommandUpdateLocation?.Invoke(Self);
                    }
                }
                //清除【位置】设置
                if (wcsActionType.Value == CarActionType.ResetPosition.GetIndexString())
                {
                    var wcsPosition = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "wcsPosition");
                    if (wcsPosition.Value != "0")
                    {
                        var wcsSwitch = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsSwitch.ToString());
                        wcsSwitch.Value     = "0";
                        wcsActionType.Value = CarActionType.Init.GetIndexString();
                        wcsPosition.Value   = "0";
                        CommandSetPosition?.Invoke(Self);
                    }
                }

                //清除【复位】设置
                var wcsResetCommand = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsResetCommand.ToString());
                if (wcsResetCommand.Value != "0")
                {
                    wcsResetCommand.Value = "0";
                    CommandReset?.Invoke(Self);
                }
                //清除【删除任务】设置
                var wcsDeleteCommand = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsDeleteCommand.ToString());
                if (wcsDeleteCommand.Value != "0")
                {
                    wcsDeleteCommand.Value = "0";
                    CommandDelete?.Invoke(Self);
                }
                //清除【切换模式】设置
                var wcsControlMode = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsControlMode.ToString());
                if (wcsControlMode.Value != "0")
                {
                    wcsControlMode.Value = "0";
                    CommandControlMode?.Invoke(Self);
                }
                #endregion
            }
            catch (Exception ex)
            {
                Logger.Log($"小车监控界面异常:{ex.Message}", LogLevel.Exception);
            }
        }