/// <summary> /// 删除任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_CommandDelete_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show($"是否确认删除任务?", "注意", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Button button = (Button)sender; if (Self != null) { //var carStatus = Self.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "carStatus"); //if (carStatus.Value != CarStatus.idle.GetIndexString()) //{ // MessageBox.Show("小车状态不是空闲,不能设置!"); // return; //} var props = Self.EquipmentProps; var wcsDeleteCommand = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsDeleteCommand.ToString()); wcsDeleteCommand.Value = "1"; var wcsConfirmTaskFinish = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsConfirmTaskFinish.ToString()); wcsConfirmTaskFinish.Value = "0"; var wcsActionType = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsActionType.ToString()); wcsActionType.Value = CarActionType.Init.GetIndexString(); var wcsRow = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.row.ToString()); wcsRow.Value = "0"; var wcsTaskHeaderId = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsTaskHeaderId.ToString()); wcsTaskHeaderId.Value = "0"; var wcsTaskCarId = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsTaskCarId.ToString()); wcsTaskCarId.Value = "0"; var wcsSwitch = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.wcsSwitch.ToString()); wcsSwitch.Value = "0"; var hasPallet = props.Find(t => t.EquipmentTypeTemplateCode == CarMonitorProps.hasPallet.ToString()); hasPallet.Value = "2"; var temp = CommandDelete?.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("操作失败,通信中断,请重试!"); } } }
/// <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); } }