예제 #1
0
        private void matlabCalc_FormClosing(object sender, EventArgs e)
        {
            byte[] buffer;
            byte[] buffer2;
            if (sender != null)
            {
                switch (this._matlabCalcForm.MatlabResult)
                {
                    case Result.Success:
                        if (this._matlabCalcForm.RegularOutput != null)
                        {
                            if (this._runMode == RunMode.AddConfig)
                            {
                                Pro2Calc.PropertyValuePair[] array = new Pro2Calc.PropertyValuePair[this._matlabCalcForm.RegularOutput.propertyValues.Count];
                                this._matlabCalcForm.RegularOutput.propertyValues.CopyTo(array);
                                this._createdConfig.StoredProperties = new List<Pro2Calc.PropertyValuePair>(array);
                                string strValue = "";
                                int index = this._matlabCalcForm.LogFileContent.IndexOf("BW =");
                                if (index != -1)
                                {
                                    strValue = this._matlabCalcForm.LogFileContent.Substring(index + 4);
                                    int length = strValue.IndexOf("kHz)");
                                    strValue = strValue.Substring(0, length).Trim().Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                                }
                                double doubleValue = 0.0;
                                WDSConverters.ParseDouble(strValue, out doubleValue);
                                if (doubleValue < 40.0)
                                {
                                    this._createdConfig.CrystalTolerance = 0;
                                    this._createdConfig.ChannelBandwith = 40.0 + this._iterationValue;
                                    this._iterationValue++;
                                    this._matlabCalcForm = null;
                                    this.startCalculation();
                                    return;
                                }
                                this._createdConfig.ChannelBandwith = doubleValue;
                                this._createdConfig.ConfigNumber = this._configurationDescriptor.Count + 3;
                                this._configurationDescriptor.Add(this._createdConfig);
                                base.Invoke(new EventHandler(this.cbbXtalTolerance_SelectedIndexChanged), new object[2]);
                                this.loadConfigList(true);
                                base.Enabled = this.dgvEzConfigEnable = true;
                                return;
                            }
                            this._selectedConfig.StoredProperties = this._matlabCalcForm.RegularOutput.propertyValues;
                            goto Label_027B;
                        }
                        _log.Error("Modem calculation did not result any commands!");
                        base.Enabled = this.dgvEzConfigEnable = true;
                        return;

                    case Result.Cancelled:
                        base.Enabled = this.dgvEzConfigEnable = true;
                        return;
                }
                MessageBox.Show("Matlab calculation failed!\n" + this._matlabCalcForm.LogFileContent + "\n" + this._matlabCalcForm.MatlabResult.ToString());
                base.Enabled = this.dgvEzConfigEnable = true;
                return;
            }
            Label_027B:
            foreach (Pro2Calc.PropertyValuePair pair in this._selectedConfig.StoredProperties)
            {
                if ((pair.name == "MODEM_MOD_TYPE") && (this._selectedProject.Name == "Direct TX"))
                {
                    pair.value = (byte) (pair.value & 7);
                    pair.value = (byte) (pair.value | 8);
                }
            }
            if (!this._ezr2Config.createEZConfigCommand(this._selectedConfig.StoredProperties, this.createUserProperties(), this._selectedProject.Name != "Range test demo", out buffer, out buffer2))
            {
                _log.Error("Could not create EZConfig command array!");
            }
            else
            {
                this._selectedConfig.CommandSet = buffer;
                switch (this._runMode)
                {
                    case RunMode.LabEval:
                        if (this.loadFirmwareCode(this._selectedProject.LabEvaluation.Firmware, null))
                        {
                            Thread.Sleep(0x3e8);
                            this.loadProjectSpecificCommands();
                        }
                        break;

                    case RunMode.FirmwareLoad:
                        this.loadFirmwareCode(this._selectedProject.FirmwareLoad.Firmware, this.createFirmwareChanges());
                        break;

                    case RunMode.IDELaunch:
                        this.launchIDE(this.createHeaderFile());
                        break;
                }
                base.Enabled = this.dgvEzConfigEnable = true;
            }
        }
예제 #2
0
        public static List<Config> createConfigDescriptorFromXML(string xmlResourcePath)
        {
            try
            {
                List<Config> list = new List<Config>();
                Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(xmlResourcePath);
                XmlDocument document = new XmlDocument();
                document.Load(manifestResourceStream);
                foreach (XmlNode node in document.GetElementsByTagName("Config"))
                {
                    Config item = new Config();
                    if (node.Attributes.GetNamedItem("ConfNum") != null)
                    {
                        item.ConfigNumber = int.Parse(node.Attributes.GetNamedItem("ConfNum").Value);
                    }
                    foreach (XmlNode node2 in node.ChildNodes)
                    {
                        switch (node2.Name)
                        {
                            case "FreqBand":
                                foreach (XmlNode node3 in node2.ChildNodes)
                                {
                                    string name = node3.Name;
                                    if (name != null)
                                    {
                                        if (!(name == "LowEnd"))
                                        {
                                            if (name == "HighEnd")
                                            {
                                                goto Label_01BF;
                                            }
                                        }
                                        else
                                        {
                                            item.FreqBandLow = int.Parse(node3.InnerText.Trim());
                                        }
                                    }
                                    continue;
                                Label_01BF:
                                    item.FreqBandHigh = int.Parse(node3.InnerText.Trim());
                                }
                                break;

                            case "ModulationMode":
                                item.ModulationMode = (Modulation) Enum.Parse(typeof(Modulation), node2.InnerText.Trim(), true);
                                break;

                            case "CrystalTolerance":
                                item.CrystalTolerance = 30;
                                if (node2.InnerText.Trim() == "hiPPM")
                                {
                                    item.CrystalTolerance = 90;
                                }
                                break;

                            case "DataRate":
                                double num;
                                if (!WDSConverters.ParseDouble(node2.InnerText.Trim(), out num))
                                {
                                    _log.Error("Could not parse dataRate: " + node2.InnerText.Trim());
                                }
                                item.DataRate = num;
                                break;

                            case "ChanelBandwidth":
                                double num2;
                                if (!WDSConverters.ParseDouble(node2.InnerText.Trim(), out num2))
                                {
                                    _log.Error("Could not parse channel bandwidth: " + node2.InnerText.Trim());
                                }
                                item.ChannelBandwith = num2;
                                break;

                            case "FrequencyDeviation":
                                double num3;
                                if (!WDSConverters.ParseDouble(node2.InnerText.Trim(), out num3))
                                {
                                    _log.Error("Could not parse deviation: " + node2.InnerText.Trim());
                                }
                                item.Deviation = num3;
                                break;

                            case "Command":
                                item.StoredProperties = new List<Pro2Calc.PropertyValuePair>();
                                foreach (XmlNode node4 in node2.ChildNodes)
                                {
                                    if (node4.Name == "Property")
                                    {
                                        byte result = 0;
                                        if (!byte.TryParse(node4.Attributes.GetNamedItem("value").Value, NumberStyles.HexNumber, (IFormatProvider) null, out result))
                                        {
                                            Console.WriteLine(node4.Attributes.GetNamedItem("value").Value);
                                        }
                                        Pro2Calc.PropertyValuePair pair = new Pro2Calc.PropertyValuePair(node4.Attributes.GetNamedItem("name").Value, result);
                                        item.StoredProperties.Add(pair);
                                    }
                                }
                                break;
                        }
                    }
                    list.Add(item);
                }
                return list;
            }
            catch (Exception exception)
            {
                _log.Error("Configuration descreptor parsing problem: " + exception.Message);
                return null;
            }
        }