private bool CopyTag() { jobTaskModel.Tags = DeviceMonitor.GetTagSettings(""); jobTaskModel.CopyTags = new List <FmsAssetTagSetting>(); foreach (var tag in jobTaskModel.Tags) { FmsAssetTagSetting copyTag = new FmsAssetTagSetting(); copyTag.CopyDataItem(tag); jobTaskModel.CopyTags.Add(copyTag); } return(true); }
private void btnTestCopy_Click(object sender, RoutedEventArgs e) { copyTags.Clear(); #region 制当前Tag值,保证数据一致性,作为判断条件用 List <FmsAssetTagSetting> tags = DeviceMonitor.GetTagSettings(""); foreach (var tag in tags) { FmsAssetTagSetting copyTag = new FmsAssetTagSetting(); copyTag.CopyDataItem(tag); copyTags.Add(copyTag); } #endregion }
public bool Init() { if ((RunState != 1) && (!CBaseData.AppClosing)) //正在运行才执行 { return(false); } #region 整线报警 FmsAssetTagSetting alertTag = DeviceMonitor.GetTagSettings("TAG_CODE = '整线报警'").FirstOrDefault(); string alertValue = alertTag?.CUR_VALUE; if (alertValue == "1") //有整线报警,系统退出 { //break; } #endregion FMSControlService.iConditionStartAddPause = 10; //条件启动启动后附加的延时 正常10ms,按条件启动后500ms FMSControlService.bStart = false; //已经启动了,只要启动了就重新获取订单信息 return(true); }
/// <summary> /// 获取动态文本的值 /// </summary> /// <param name="text">文本</param> /// <returns>转换后的值</returns> private string GetDynamicValue(string text) { if (string.IsNullOrEmpty(text)) { return(""); } string result = text; if (text.Length > 4) //"{[TagCode]}形式" { if ((text.Substring(0, 2) == "{[") && (text.Substring(text.Length - 2) == "]}")) //按照TagCode获取Tag点的当前 { string tagCode = text.Substring(2, text.Length - 4); // FmsAssetTagSetting tag = DeviceMonitor.GetTagSettings($"TAG_CODE = '{tagCode}'").FirstOrDefault(); if (tag != null) { result = tag.CUR_VALUE; // } } } return(result); }
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("刀补值下发成功!", "下发刀补"); } }