Beispiel #1
0
        // Turns off the selected busses
        private void BusOff_Click(object sender, EventArgs e)
        {
            // Ensures that something is detected for turning on the interface
            if (InterfaceBox.SelectedIndices.Count > 0)
            {
                ListViewItem item = InterfaceBox.SelectedItems[0];

                // Loops through all of the Items to detect all of the selected itmes
                for (int x = 0; x < InterfaceBox.Items.Count; x++)
                {
                    // If the item is selected then turn on the interface
                    if (InterfaceBox.Items[x].Selected)
                    {
                        if (InterfaceBox.Items[x].SubItems[5].Text == "Bus On")
                        {
                            GenericCanBus.GenericCanBusOff(InterfaceBox.Items[x].SubItems[0].Text + ";" +
                                                           InterfaceBox.Items[x].SubItems[1].Text + ";" +
                                                           InterfaceBox.Items[x].SubItems[2].Text + ";" +
                                                           InterfaceBox.Items[x].SubItems[3].Text);

                            string bitRate = GenericCanBus.GenericCanRateReturn(InterfaceBox.Items[x].SubItems[0].Text + ";" +
                                                                                InterfaceBox.Items[x].SubItems[1].Text + ";" +
                                                                                InterfaceBox.Items[x].SubItems[2].Text + ";" +
                                                                                InterfaceBox.Items[x].SubItems[3].Text);

                            if (bitRate == null || bitRate == "" || bitRate == "0")
                            {
                                InterfaceBox.Items[x].SubItems[4].Text = "NA";
                                InterfaceBox.Items[x].SubItems[5].Text = "Bus Off";
                            }
                            else
                            {
                                InterfaceBox.Items[x].SubItems[4].Text = bitRate;
                                InterfaceBox.Items[x].SubItems[5].Text = "Bus On";
                            }
                        }
                        else
                        {
                            MainWindow.ErrorDisplayString("Bus Not On: " + InterfaceBox.Items[x].SubItems[1].Text);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("One of the items should be selected!");
            }
        }
Beispiel #2
0
        //******************
        // Load Interfaces -- This loads the selected interfaces on the machine into the interfacebox
        //******************
        private void LoadInterfaces()
        {
            string bitRate = null;
            string displayRow;

            // Sets up the multi-column box
            InterfaceBox.Items.Clear();
            InterfaceBox.Columns.Clear();
            InterfaceBox.Columns.Add("Network", 55, HorizontalAlignment.Left);
            InterfaceBox.Columns.Add("Type", 155, HorizontalAlignment.Left);
            InterfaceBox.Columns.Add("Mfg", 85, HorizontalAlignment.Left);
            InterfaceBox.Columns.Add("Channel", 35, HorizontalAlignment.Left);
            InterfaceBox.Columns.Add("BitRate", 55, HorizontalAlignment.Left);
            InterfaceBox.Columns.Add("Status", 75, HorizontalAlignment.Right);

            // Reset Interfaces in Bus Intefaces
            // BusInterface.ResetInterfaces();

            GenericCanBus.DetectCanInterfaces();

            // Find all of the LIN bus interfaces and adds to the list in busInterface
            // GenericLinBus.DetectLinInterfaces();

            // Find all of the FlexRay bus interfaces and adds to the list in busInterface
            // GenericFlexRayBus.DetectFlexRayInterfaces();

            // Returns the interfaces
            string[] interfaces = BusInterface.ReturnInterfaces();

            for (int i = 0; i < interfaces.Length; i++)
            {
                bitRate = GenericCanBus.GenericCanRateReturn(interfaces[i]);

                // Creates the row with the message data and inserts the row in the ListView

                if (bitRate == null || bitRate == "" || bitRate == "0")
                {
                    displayRow = ";NA;Bus Off";
                }
                else
                {
                    displayRow = ";" + bitRate + ";Bus On";
                }

                ListViewItem item = new ListViewItem(CommonUtils.ConvertStringtoStringArray(interfaces[i] + displayRow));
                InterfaceBox.Items.AddRange(new ListViewItem[] { item });
            }
        }
Beispiel #3
0
        //****************************
        // Update Interface Boxes
        //****************************
        private void UpdateInterfaceBox()
        {
            string bitRate = "-1";

            // Populate the availabe interfaces for transmission/receiving
            string[] interfaces = BusInterface.ReturnInterfaces();

            for (int i = 0; i < interfaces.Length; i++)
            {
                bitRate = GenericCanBus.GenericCanRateReturn(interfaces[i]);

                // Creates the row with the message data and inserts the row in the ListView
                if (bitRate != null && bitRate != "" && bitRate != "0" && bitRate != "-1")
                {
                    TransmitInterfaceBox.Items.Add(interfaces[i]);
                }
            }

            if (TransmitInterfaceBox.Items.Count > 0)
            {
                TransmitInterfaceBox.SelectedIndex = 0;
            }
        }
Beispiel #4
0
        // Turns on the selected busses
        private void BusOn_Click(object sender, EventArgs e)
        {
            string bitRateSetting;

            if (standardRate1M.Checked)
            {
                bitRateSetting = "1M";
            }
            else if (standardRate500K.Checked)
            {
                bitRateSetting = "500K";
            }
            else if (standardRate250K.Checked)
            {
                bitRateSetting = "250K";
            }
            else if (standardRate125K.Checked)
            {
                bitRateSetting = "125K";
            }
            else if (standardRate100K.Checked)
            {
                bitRateSetting = "100K";
            }
            else if (standardRate62K.Checked)
            {
                bitRateSetting = "62K";
            }
            else if (standardRate50K.Checked)
            {
                bitRateSetting = "50K";
            }
            else if (standardRate33K.Checked)
            {
                bitRateSetting = "33K";
            }
            else
            {
                bitRateSetting = "NA";
            }

            if (customRate.Checked)
            {
                MainWindow.ErrorDisplayString("Custom Settings Not Yet Implemented");
                return;
            }

            // Ensures that something is detected for turning on the interface
            if (InterfaceBox.SelectedIndices.Count > 0)
            {
                ListViewItem item = InterfaceBox.SelectedItems[0];

                // Loops through all of the Items to detect all of the selected itmes
                for (int x = 0; x < InterfaceBox.Items.Count; x++)
                {
                    // If the item is selected then turn on the interface
                    if (InterfaceBox.Items[x].Selected)
                    {
                        if (InterfaceBox.Items[x].SubItems[5].Text != "Bus On")
                        {
                            int status = GenericCanBus.GenericCanBusOn(InterfaceBox.Items[x].SubItems[0].Text + ";" +
                                                                       InterfaceBox.Items[x].SubItems[1].Text + ";" +
                                                                       InterfaceBox.Items[x].SubItems[2].Text + ";" +
                                                                       InterfaceBox.Items[x].SubItems[3].Text,
                                                                       bitRateSetting);

                            // REVISIONS -- Error with returning the data rate for the adapters
                            // This populates the data rate for the adapter
                            InterfaceBox.Items[x].SubItems[4].Text = GenericCanBus.GenericCanRateReturn(InterfaceBox.Items[x].SubItems[0].Text + ";" +
                                                                                                        InterfaceBox.Items[x].SubItems[1].Text + ";" +
                                                                                                        InterfaceBox.Items[x].SubItems[2].Text + ";" +
                                                                                                        InterfaceBox.Items[x].SubItems[3].Text);

                            if (status == 1)
                            {
                                InterfaceBox.Items[x].SubItems[5].Text = "Bus On";
                            }
                        }
                        else
                        {
                            MainWindow.ErrorDisplayString("Bus Already On: " + InterfaceBox.Items[x].SubItems[1].Text);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("One of the items should be selected!");
            }
        }