private void btnWriteParaToTDE_Click(object sender, EventArgs e) { if (PubSyswareCom.IsRuntimeServerStarted()) { List <ParaData> lstTdePara = WeightEstimateForm.GetListParaData(); if (lstTdePara != null && lstTdePara.Count > 0) { foreach (WeightParameter weight in curWaParas) { IEnumerable <ParaData> selection = from para in lstTdePara where weight.ParaName == para.paraName select para; if (selection.Count() == 0) { PubSyswareCom.CreateDoubleParameter(weight.ParaName, weight.ParaValue, true, true, false); PubSyswareCom.SetParameterUnit(string.Empty, weight.ParaName, MainForm.GetUnitName(weight.ParaUnit)); WeightEstimateForm.SetParaGroup(weight.ParaType, weight.ParaName); } else { PubSyswareCom.mSetParameter(string.Empty, weight.ParaName, weight.ParaValue); } } } else { foreach (WeightParameter weight in curWaParas) { PubSyswareCom.CreateDoubleParameter(weight.ParaName, weight.ParaValue, true, true, false); PubSyswareCom.SetParameterUnit(string.Empty, weight.ParaName, MainForm.GetUnitName(weight.ParaUnit)); WeightEstimateForm.SetParaGroup(weight.ParaType, weight.ParaName); } } MessageBox.Show("参数写入TDE成功!"); } }
/// <summary> /// 同步参数到参数列表 /// </summary> private void SynchronizationWeightPara() { List <ParaData> lstPara = new List <ParaData>(); if (lstAllParaData != null && lstAllParaData.Count > 0) { foreach (ParaData para in lstAllParaData) { ParaData data = new ParaData(); data.paraName = para.paraName; data.paraUnit = para.paraUnit; data.paraType = para.paraType; data.paraValue = para.paraValue; data.strRemark = para.strRemark; lstPara.Add(data); } } //参数表中的参数 List <ParaData> lstTdePara = WeightEstimateForm.GetListParaData(); if (lstPara != null && lstPara.Count > 0) { foreach (ParaData para in lstPara) { if (MainForm.IsExitPara(para.paraName, lstTdePara) == false) { PubSyswareCom.CreateDoubleParameter(para.paraName, para.paraValue, true, true, false); // 设置单位 PubSyswareCom.SetParameterUnit(string.Empty, para.paraName, MainForm.GetUnitName(para.paraUnit)); //设置分组 if (para.paraType == 0) { PubSyswareCom.SetParameterGroup(para.paraName, "指标参数"); } if (para.paraType == 1) { PubSyswareCom.SetParameterGroup(para.paraName, "构型和总体参数"); } if (para.paraType == 2) { PubSyswareCom.SetParameterGroup(para.paraName, "旋翼参数"); } if (para.paraType == 3) { PubSyswareCom.SetParameterGroup(para.paraName, "机身翼面参数"); } if (para.paraType == 4) { PubSyswareCom.SetParameterGroup(para.paraName, "着陆装置参数"); } if (para.paraType == 5) { PubSyswareCom.SetParameterGroup(para.paraName, "动力系统参数"); } if (para.paraType == 6) { PubSyswareCom.SetParameterGroup(para.paraName, "传动系统参数"); } if (para.paraType == 7) { PubSyswareCom.SetParameterGroup(para.paraName, "操纵系统参数"); } if (para.paraType == 8) { PubSyswareCom.SetParameterGroup(para.paraName, "人工参数"); } if (para.paraType == 9) { PubSyswareCom.SetParameterGroup(para.paraName, "其他类型参数"); } if (para.paraType == 10) { PubSyswareCom.SetParameterGroup(para.paraName, "临时参数"); } } } } /*------------------------------------------删除文件中没有的参数-----------------------------*/ List <string> lstName = new List <string>(); for (int i = 0; i < lstTdePara.Count; i++) { bool IsExit = false; foreach (ParaData data in lstPara) { if (data.paraName == lstTdePara[i].paraName) { IsExit = true; break; } } if (IsExit == false) { lstName.Add(lstTdePara[i].paraName); } } //删除参数 foreach (string str in lstName) { PubSyswareCom.DeleteParameter(string.Empty, str); } //----------------------------------------------------------------------------------------------// XLog.Write("同步参数表成功"); }