public BaseResultCommunication DealCommWritePLC(ParCommWritePLC par, Hashtable htResult) { BaseResultCommunication result = new BaseResultCommunication(); try { for (int i = 0; i < par.ResultforWritePLC_L.Count; i++) { string nameCell = par.ResultforWritePLC_L[i].NameCell; string nameResult = par.ResultforWritePLC_L[i].NameResult; GetReusltValueFromResultcs fun = new GetReusltValueFromResultcs(); double value = fun.GetResultValue(nameCell, nameResult, htResult); par.ResultforWritePLC_L[i].Result = value; } //写入PLC bool blResult = LogicPLC.L_I.WriteData(par.ResultforWritePLC_L); if (!blResult) { result.LevelError_e = LevelError_enum.Error; result.Annotation = ""; } return(result); } catch (Exception ex) { result.LevelError_e = LevelError_enum.Error; result.Annotation = par.NameCell.ToString() + "写入PLC:" + ex.Message; LogError(NameClass, par, ex); return(result); } }
//引用结果 private void btnGetResult_Click(object sender, RoutedEventArgs e) { try { base.IndexP = this.dgDataAndReg.SelectedIndex; string nameCell = g_CellReference.NameCell; string nameResult = g_ResultReference.NameResult; if (nameResult.Contains("_L"))//如果是数组 { WinSetIndex win = new WinSetIndex(); bool result = (bool)win.ShowDialog(); if (result) { } } GetReusltValueFromResultcs fun = new GetReusltValueFromResultcs(); double value = fun.GetResultValue(nameCell, nameResult, g_HtResult); g_ParCommWritePLC[base.IndexP].NameCell = nameCell; g_ParCommWritePLC[base.IndexP].NameResult = nameResult; g_ParCommWritePLC[base.IndexP].Result = value; g_ParCommWritePLC[base.IndexP].BlSelect = true; //刷新显示 RefreshDgDataAndReg(); } catch (Exception ex) { } }