예제 #1
0
        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);
                            MainForm.SetParameterUnit(weight.ParaName, 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);
                        MainForm.SetParameterUnit(weight.ParaName, weight.ParaUnit);
                        WeightEstimateForm.SetParaGroup(weight.ParaType, weight.ParaName);
                    }
                }
                MessageBox.Show("参数写入TDE成功!");
            }
        }
        /// <summary>
        /// 同步参数到参数列表
        /// </summary>
        private void SynchronizationWeightPara()
        {
            string          msg     = "";
            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;
                    try
                    {
                        data.paraUnit = dicUnits[para.paraUnit];
                    }
                    catch
                    {
                        //data.paraUnit = para.paraUnit;
                        msg += data.paraName + "单位值'" + para.paraUnit + "'不在IDE已有单位范围中;\n";
                    }

                    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);

                        //设置分组
                        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, "临时参数");
                        }
                    }
                    MainForm.SetParameterUnit(para.paraName, para.paraUnit);
                }
            }

            /*------------------------------------------删除文件中没有的参数-----------------------------*/

            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);
            }

            if (msg != "")
            {
                XLog.Write(msg);
                //MessageBox.Show(msg);
            }
            //----------------------------------------------------------------------------------------------//
            XLog.Write("同步参数表成功");
        }
 private void btnImportFromIde_Click(object sender, EventArgs e)
 {
     //设置页面数据
     SetPageData(WeightEstimateForm.GetListParaData());
 }