Esempio n. 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>
        /// 获取参数表数据转换成ListParaData
        /// </summary>
        /// <returns></returns>
        public static List <ParaData> GetListParaData()
        {
            List <ParaData> lstPara = null;

            if (PubSyswareCom.IsRuntimeServerStarted())
            {
                //获取参数的值
                object obj = null;

                PubSyswareCom.GetParameterNames(string.Empty, ref obj);

                //转换为字符串数组
                if (obj is Object[])
                {
                    lstPara = new List <ParaData>();

                    object[] objName = obj as Object[];
                    for (int i = 0; i < objName.Count(); i++)
                    {
                        Object objValue = null;
                        PubSyswareCom.mGetParameter(string.Empty, objName[i].ToString(), ref objValue);

                        if (objValue != null)
                        {
                            //参数
                            if (objName[i].ToString() != "weightData" && objName[i].ToString() != "coreEnvelopeData")
                            {
                                ParaData data = new ParaData();
                                data.paraName = objName[i].ToString();
                                try
                                {
                                    data.paraValue = Convert.ToDouble(objValue.ToString());
                                }
                                catch (Exception e)
                                {
                                    data.paraValue = 0;
                                    XLog.Write(e.Message);
                                }


                                lstPara.Add(data);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("TDE/IDE 没有启动成功");
            }

            return(lstPara);
        }
        /// <summary>
        /// 同步参数表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPuslishToTde_Click(object sender, EventArgs e)
        {
            if (PubSyswareCom.IsRuntimeServerStarted())
            {
                DialogResult result = MessageBox.Show("是否参数同步?", "同步提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    SynchronizationWeightPara();

                    MessageBox.Show("同步参数完成");
                }
            }
            else
            {
                MessageBox.Show("TDE/IDE 没有启动成功");
            }
        }
 /// <summary>
 /// 结构参数对象转xml文件公共方法
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="result"></param>
 /// <param name="title"></param>
 /// <param name="dataObjectMethod"></param>
 /// <returns></returns>
 public static string DataObjectToXml <T>(T result, string title, DataObjectToXmlDelegate <T> dataObjectMethod)
 {
     if (PubSyswareCom.IsRuntimeServerStarted())
     {
         if (result != null)
         {
             object obj  = null;
             string path = null;
             PubSyswareCom.GetParameterNames(null, ref obj);
             if (obj == null)
             {
                 return("TDE/IDE 参数表没打开");
             }
             object[] objs = obj as object[];
             bool     bl   = false;
             foreach (object o in objs)
             {
                 if (o.ToString() == title)
                 {
                     bl = true;
                     break;
                 }
             }
             path = dataObjectMethod(result, bl);
             if (path == null)
             {
                 return("SyswareDataObject.xml 生成失败");
             }
             bl = bl ? (PubSyswareCom.AddChildDataObject(title, path)) : (PubSyswareCom.AddDataObject(path));
             if (!bl)
             {
                 return("结构化参数表同步失败");
             }
             return("");
         }
         else
         {
             return("评估软件数据集为空");
         }
     }
     else
     {
         return("TDE/IDE 没有启动成功");
     }
 }
        /// <summary>
        /// 获取参数表数据转换成ListParaData
        /// </summary>
        /// <returns></returns>
        public static List <ParaData> GetListParaData()
        {
            List <ParaData> lstPara = null;

            if (PubSyswareCom.IsRuntimeServerStarted())
            {
                //获取参数的值
                object obj = null;
                PubSyswareCom.GetParameterNames(string.Empty, ref obj);

                //转换为字符串数组
                if (obj is Object[])
                {
                    lstPara = new List <ParaData>();

                    object[] objName = obj as Object[];
                    for (int i = 0; i < objName.Count(); i++)
                    {
                        Object objValue = null;
                        PubSyswareCom.mGetParameter(string.Empty, objName[i].ToString(), ref objValue);

                        if (objValue != null)
                        {
                            //参数
                            if (objName[i].ToString() != "weightData" && objName[i].ToString() != "coreEnvelopeData")
                            {
                                ParaData data = new ParaData();
                                data.paraName  = objName[i].ToString();
                                data.paraValue = Convert.ToDouble(objValue.ToString());

                                lstPara.Add(data);
                            }
                        }
                    }
                }
            }

            return(lstPara);
        }