Esempio n. 1
0
        public static bool ValidEntry(PortEntry entry)
        {
            if (entry.GetIsComment())
            {
                return(true);
            }
            bool b = true;

            if (!entry.IsValidData_size())
            {
                entry.SetReason("The port " + entry.GetName() + " has invalid data size: " + entry.GetData_size());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidMemorySection())
            {
                entry.SetReason("The port " + entry.GetName() + " has invalid memory section: " + entry.GetMemory_section());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidPriority())
            {
                entry.SetReason("The port " + entry.GetName() + " has Priority out of range [0, 99]");
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidR_W())
            {
                entry.SetReason("The port " + entry.GetName() + " has R_W different from 'R' or 'W': " + entry.GetR_W());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidAnableEmerge())
            {
                entry.SetReason("The port " + entry.GetName() + " has anable emerge different from 'N' or 'Y': " + entry.GetAnable_emerge());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidBank())
            {
                entry.SetReason("The port " + entry.GetName() + " has bank different from 'A' or 'B': " + entry.GetBank());
                entry.SetValid(false);
                b = false;
            }
            return(b);
        }
Esempio n. 2
0
        private void DataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            PortEntry pe = null;

            foreach (DataGridViewRow item in dataGridView1.SelectedRows)
            {
                pe = Ports[(int)item.Cells["Index"].Value];
                //MessageBox.Show(item.Cells["Index"].Value.ToString());
                break;
            }
            if (pe != null)
            {
                PortNameText.Text               = pe.GetName();
                CommentText.Text                = pe.GetComment();
                MemorySizeText.Text             = pe.GetMemorySize();
                ValidCheckBox.Checked           = pe.GetValidField();
                RelativeAddressCheckBox.Checked = pe.GetRelative_address();
                EmergencyCheckBox.Checked       = pe.GetAnable_emerge() == 'Y';
                DebugCheckBox.Checked           = pe.GetRead_bk_address();

                int index = R_WCombo.FindStringExact(pe.GetR_W().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                R_WCombo.SelectedIndex = index;
                index = DataSizeBox.FindStringExact(pe.GetData_size().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                DataSizeBox.SelectedIndex = index;
                index = TypeOpts.FindStringExact(pe.GetPortType().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                TypeOpts.SelectedIndex = index;
                index = BankBox.FindStringExact(pe.GetBank().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                BankBox.SelectedIndex = index;
                index = pe.GetPriority();
                if (index >= 100 || index <= 0)
                {
                    index = 99;
                }
                numericUpDown1.Value = index;
                index = pe.GetMemory_section();
                if (index < 0)
                {
                    index = 1;
                }
                numericUpDown2.Value = index;

                if (pe.GetIsComment())
                {
                    ErrorMessage.Text = "Message: ";
                }
                else if (!pe.GetValid())
                {
                    ErrorMessage.Text = "Message: " + pe.GetReason();
                }
                else
                {
                    ErrorMessage.Text = "Message: ";
                }
            }
        }