private void BtnSave_Click(object sender, RoutedEventArgs e) { //保存 AmAssetMasterN asset = cmbAssetInfo.SelectedItem as AmAssetMasterN; FmsActionControl actionControl = gbItem.DataContext as FmsActionControl; if (actionControl == null) { return; } #region //TODO: 校验;保存 if (asset == null) { WPFMessageBox.ShowError("请选择设备!", "保存"); return; } if (string.IsNullOrEmpty(actionControl.ACTION_NAME)) { WPFMessageBox.ShowError("请输入指令动作名称!", "保存"); return; } if (actionControl.PKNO == "") { actionControl.PKNO = CBaseData.NewGuid(); _fmsClient.UseService(s => s.AddFmsActionControl(actionControl)); } else { _fmsClient.UseService(s => s.UpdateFmsActionControl(actionControl)); } WPFMessageBox.ShowTips("指令动作配置信息已保存。", "保存"); #endregion GetPage(); //重新刷新数据,根据需求是否进行刷新数据 //保存成功 gbItem.IsCollapsed = true; gbItem.Visibility = Visibility.Collapsed; BindHelper.SetDictDataBindingGridItem(gbItem, gridItem); }
private void BtnDel_Click(object sender, RoutedEventArgs e) { //删除 FmsActionControl actionControl = gridItem.SelectedItem as FmsActionControl; if (actionControl == null) { return; } if ( WPFMessageBox.ShowConfirm($"确定要删除 指令动作【{actionControl.ACTION_NAME}】的配置信息吗?", "删除") != WPFMessageBoxResult.OK) { return; } _fmsClient.UseService(s => s.DelFmsActionControl(actionControl.PKNO)); WPFMessageBox.ShowTips("指令动作配置已删除!", "删除提示"); GetPage(); //重新刷新数据,根据需求是否进行刷新数据 }
private const int ReWriteCount = 3; //数据重写次数 //下发刀补 private void btnWriteToolsSet_Click(object sender, RoutedEventArgs e) { AmAssetMasterN asset = cmbDeviceInfo.SelectedItem as AmAssetMasterN; if (asset == null) { return; } TmsDeviceToolsPos mTmsDeviceToolsPos = gridItem.SelectedItem as TmsDeviceToolsPos; if (mTmsDeviceToolsPos == null) { return; } TmsToolsMaster tools = ws.UseService(s => s.GetTmsToolsMasterById(mTmsDeviceToolsPos.TOOLS_PKNO)); if (tools == null) { return; } if (WPFMessageBox.ShowConfirm($"确定要将机床【{asset.ASSET_NAME}】上刀号【{mTmsDeviceToolsPos.TOOLS_POS_NO}】的补偿值覆盖吗?", "下发刀补") != WPFMessageBoxResult.OK) { return; } Cursor = Cursors.Wait; string tagName = "写入刀补"; FmsAssetTagSetting tag = DeviceMonitor.GetTagSettings($"ASSET_CODE = '{asset.ASSET_CODE}' AND TAG_NAME = '{tagName}'").FirstOrDefault(); if (tag == null) { Cursor = Cursors.Arrow; return; } //0:长度(形状);1:长度(磨损);2:半径(形状);3:半径(磨损) List <string> values = new List <string>(); values.Add(mTmsDeviceToolsPos.TOOLS_POS_NO); //机床刀号 values.Add(tools.COMPENSATION_SHAPE_LENGTH.ToString()); //长度(形状) //values.Add(tools.COMPENSATION_ABRASION_LENGTH.ToString()); //长度(磨损) values.Add(tools.COMPENSATION_SHAPE_DIAMETER.ToString()); //半径(形状) //values.Add(tools.COMPENSATION_ABRASION_DIAMETER.ToString()); //半径(磨损) string offSetValue = string.Join("|", values.ToArray()); #region 发刀补 int iWrite = 0; int ret = 0; string error = ""; while (iWrite < ReWriteCount) { ret = DeviceMonitor.WriteTagToDevice(tag.PKNO, offSetValue, out error); if (ret == 0) { break; } iWrite++; Thread.Sleep(100); } #endregion Cursor = Cursors.Arrow; if (ret == 0) { WPFMessageBox.ShowTips("刀补值下发成功!", "下发刀补"); } }
private void bTestMessageBoxTips_Click(object sender, RoutedEventArgs e) { WPFMessageBox.ShowTips((sender as Button).Content.ToString(), "测试"); }