Beispiel #1
0
 public void SetParmObj(ParamModel paramModel)
 {
     paramObj           = paramModel;
     this.label1.Text   = paramObj.ParamName;
     this.textBox1.Text = paramObj.ParamVal;
     this.textBox1.Left = this.label1.Right + 5;
 }
Beispiel #2
0
        public static bool LoadCfg(string xmlCfgFile, ref string reStr)
        {
            try
            {
                //  string xmlCfgFile = System.AppDomain.CurrentDomain.BaseDirectory + @"data/DevConfigFTYJ.xml";
                if (!File.Exists(xmlCfgFile))
                {
                    reStr = "系统配置文件:" + xmlCfgFile + " 不存在!";
                    return(false);
                }
                cfgFilePath = xmlCfgFile;
                XElement root = XElement.Load(xmlCfgFile);

                XElement sysSetXE              = root.Element("sysSet");
                XElement sysParamXE            = sysSetXE.Element("SysParam");
                XElement qrCodewReqXe          = sysSetXE.Element("QRCodeRequire");
                XElement requireRepairProcssXe = sysSetXE.Element("RepairProcess");
                StartWorkStationID      = requireRepairProcssXe.Attribute("StartWorkStationID").Value.ToString();
                IsRequireRequireFromMes = bool.Parse(requireRepairProcssXe.Attribute("RequireFromMes").Value.ToString());
                ProcessID = requireRepairProcssXe.Attribute("ProcessID").Value.ToString();
                string strParam = sysParamXE.Value.ToString();
                if (!string.IsNullOrWhiteSpace(strParam))
                {
                    JArray jsonParams = (JArray)JsonConvert.DeserializeObject(strParam);
                    if (jsonParams != null && jsonParams.Count() > 0)
                    {
                        foreach (JObject paramObj in jsonParams)
                        {
                            ParamCfgBase.ParamModel param = new ParamCfgBase.ParamModel(paramObj["ParamName"].ToString(), paramObj["ParamVal"].ToString(), paramObj["ParamType"].ToString());
                            SysParamDic[paramObj["ParamName"].ToString()] = param;
                        }
                    }
                }
                if (sysSetXE.Element("WelderParam") != null)
                {
                    string batNum = sysSetXE.Element("WelderParam").Attribute("batteryNumInMod").Value.ToString();
                    batteryNumInMod = int.Parse(batNum);
                }
                XElement runModeXE = root.Element("sysSet").Element("RunMode");
                string   simStr    = runModeXE.Attribute("sim").Value.ToString().ToUpper();

                if (simStr == "TRUE")
                {
                    SimMode = true;
                }
                else
                {
                    SimMode = false;
                }
                //if(runModeXE.Attribute("debugMode") != null)
                //{
                //    string debugModeStr = runModeXE.Attribute("debugMode").Value.ToString().ToUpper();
                //    if(debugModeStr == "TRUE")
                //    {
                //        DebugMode = true;
                //    }
                //    else
                //    {
                //        DebugMode = false;
                //    }
                //}
                if (runModeXE.Attribute("manualMode1") != null)
                {
                    string manualModeStr = runModeXE.Attribute("manualMode1").Value.ToString().ToUpper();
                    if (manualModeStr == "TRUE")
                    {
                        ManualMode1 = true;
                    }
                    else
                    {
                        ManualMode1 = false;
                    }
                }
                if (runModeXE.Attribute("manualMode3") != null)
                {
                    string manualModeStr = runModeXE.Attribute("manualMode3").Value.ToString().ToUpper();
                    if (manualModeStr == "TRUE")
                    {
                        ManualMode3 = true;
                    }
                    else
                    {
                        ManualMode3 = false;
                    }
                }
                XElement printerXE = root.Element("sysSet").Element("Printer");
                string   str       = printerXE.Attribute("Enable").Value.ToString().ToUpper();
                if (str == "TRUE")
                {
                    PrienterEnable = true;
                }
                else
                {
                    PrienterEnable = false;
                }
                XElement mesXE = root.Element("sysSet").Element("Mes");
                if (mesXE.Attribute("LineID") != null)
                {
                    mesLineID = mesXE.Attribute("LineID").Value.ToString();
                }
                else
                {
                    reStr = "MES产线ID未定义";
                    return(false);
                }
                str = mesXE.Attribute("Enable").Value.ToString().ToUpper();
                if (str == "TRUE")
                {
                    MesCheckEnable = true;
                }
                else
                {
                    MesCheckEnable = false;
                }
                str = mesXE.Attribute("OfflineMode").Value.ToString().ToUpper();
                if (str == "TRUE")
                {
                    MesOfflineMode = true;
                }
                else
                {
                    MesOfflineMode = false;
                }
                str = mesXE.Attribute("MesAutodown").Value.ToString().ToUpper();
                if (str == "TRUE")
                {
                    MesAutodownEnabled = true;
                }
                else
                {
                    MesAutodownEnabled = false;
                }
                XElement mesTimeOutXE = root.Element("sysSet").Element("MesDownTimeout");
                MesTimeout = int.Parse(mesTimeOutXE.Value.ToString());

                XElement rfidTimeOutXE = root.Element("sysSet").Element("RfidTimeout");
                RfidDelayTimeout = int.Parse(rfidTimeOutXE.Value.ToString());

                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }