Пример #1
0
        /// <summary>
        /// Gets the PIC processor model corresponding to the given processor name.
        /// </summary>
        /// <param name="procName">Name of the PIC processor.</param>
        /// <returns>
        /// The processor model.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="procName"/> is null.</exception>
        /// <exception cref="InvalidOperationException">Thrown the PIC database is not accessible.</exception>
        public static IPICProcessorModel GetModel(string procName)
        {
            if (string.IsNullOrEmpty(procName))
            {
                procName = DefaultPICName;
            }
            var db = PICCrownking.GetDB();

            if (db is null)
            {
                throw new InvalidOperationException("Can't get the PIC database.");
            }
            var pic = db.GetPIC(procName);

            if (pic is null)
            {
                return(null);
            }
            if (modes.TryGetValue(pic.GetInstructionSetID, out PICProcessorModel mode))
            {
                mode.PICDescriptor = pic;
                return(mode);
            }
            return(null);
        }
Пример #2
0
        private void InitValues()
        {
            string family;

            if (result.PICName.Length < 5)
            {
                result.PICName       = String.Empty;
                result.AllowExtended = false;
                family = "PIC18";
            }
            else
            {
                family = result.PICName.Substring(0, 5);
            }

            switch (family)
            {
            case "PIC16":
                form.PIC16RadioButton.Checked     = true;
                form.PIC18RadioButton.Checked     = false;
                form.ExtendedModeCheckBox.Checked = false;
                form.ExtendedModeCheckBox.Enabled = false;
                break;

            case "PIC18":
                form.PIC16RadioButton.Checked     = false;
                form.PIC18RadioButton.Checked     = true;
                form.ExtendedModeCheckBox.Checked = result.AllowExtended;
                form.ExtendedModeCheckBox.Enabled = true;
                break;
            }
            form.ModelComboBox.BeginUpdate();
            form.ModelComboBox.Items.AddRange(PICCrownking.GetDB().EnumPICList(s => s.StartsWith(family)).ToArray());
            int picindex = -1;

            try
            {
                picindex = form.ModelComboBox.FindStringExact(result.PICName);
            }
            catch
            {
            }
            if (picindex != -1)
            {
                form.ModelComboBox.Text          = result.PICName;
                form.ModelComboBox.SelectedIndex = picindex;
            }
            else
            {
                form.ModelComboBox.Text = string.Empty;
            }
            form.ModelComboBox.EndUpdate();
        }
Пример #3
0
 private void PICRadioButtons_CheckedChanged(object sender, EventArgs e)
 {
     string family;
     if (form.PIC16RadioButton.Checked)
     {
         form.ExtendedModeCheckBox.Enabled = false;
         result.AllowExtended = false;
         family = "PIC16";
     }
     else
     {
         form.ExtendedModeCheckBox.Enabled = true;
         result.AllowExtended = form.ExtendedModeCheckBox.Checked;
         family = "PIC18";
     }
     form.ExtendedModeCheckBox.Checked = result.AllowExtended;
     form.ModelComboBox.BeginUpdate();
     form.ModelComboBox.Items.Clear();
     form.ModelComboBox.Items.AddRange(PICCrownking.GetDB().EnumPICList(s => s.StartsWith(family)).ToArray());
     form.ModelComboBox.Text = null;
     form.ModelComboBox.EndUpdate();
     result.PICName = String.Empty;
 }
Пример #4
0
 public void LoadDB()
 {
     db = PICCrownking.GetDB();
     Assert.That(db, Is.Not.Null, $"No accessible PIC XML database - {PICCrownking.LastErrMsg}.");
 }