예제 #1
0
        // Loads the selected transmission buttons onto the screen
        private void TransmitList_SelectedIndexChanged(object sender, EventArgs e)
        {
            TransmitBox.Columns.Clear();
            TransmitBox.Items.Clear();

            TransmitBox.Columns.Add("Name", 135, HorizontalAlignment.Left);
            TransmitBox.Columns.Add("Packet Type", 85, HorizontalAlignment.Left);

            try
            {
                string[] packets = XMLInterfaces.ReturnPackets(TransmitList.SelectedItem.ToString());

                if (packets.Length != 0)
                {
                    for (int y = 0; y < packets.Length; y++)
                    {
                        string[]     output = packets[y].Split(';');
                        ListViewItem item   = new ListViewItem(output);
                        TransmitBox.Items.AddRange(new ListViewItem[] { item });
                    }
                }



                // Sets all of the variables for the selected filter
                TransmitFilter         = TransmitList.SelectedItem.ToString();
                TransmitLoadLabel.Text = TransmitList.SelectedItem.ToString();
            }
            catch
            {
                // No catch needed as no change
            }
        }
예제 #2
0
        // Loads packet based on user selection
        private void TransmitBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                PacketBox.Clear();

                if (TransmitBox.SelectedItems.Count > 0)
                {
                    packetLabel.Text = TransmitBox.SelectedItems[0].Text;

                    PacketBox.Text = XMLInterfaces.ReturnPacketDataDisplay(TransmitList.SelectedItem.ToString(), TransmitBox.SelectedItems[0].Text);
                }
            }
            catch
            {
                // No catch needed as no change
            }
        }
예제 #3
0
        // Loads the available transmission buttons from the xml file into the transmit listing
        private void LoadListTransmit()
        {
            // Clear any current items
            TransmitList.Items.Clear();

            // returns a string array of the available filter types from the XMLInterfaces
            string[] transmittypes = XMLInterfaces.ReturnTransmitTypes(ConfigFiles.Settings1.Default.filterURI);

            // for each string in the string array an item is added to the filterlist
            if (transmittypes != null)
            {
                for (int x = 0; x < transmittypes.Length; x++)
                {
                    TransmitList.Items.Add(transmittypes[x]);
                }

                toolStripStatusLabel2.Text = "Find Transmit Cars";
            }
        }
예제 #4
0
        // Temp until hardware support is added
        // public static bool TransmitChannel2 = false;

        // Converts a CAN message into string format for display in the multi-column box
        // CAN message to display format
        // ***********************
        public static string[] ConvertMsgArray(CanData can, string filter, int BitMSBinput)
        {
            // Allocates the string array for return; update size as needed
            string[] msgOutput = new string[11];

            // Initial the msg array to blank
            msgOutput[(int)BusFields.Data]  = "";
            msgOutput[(int)BusFields.Id]    = "";
            msgOutput[(int)BusFields.Flags] = "";

            //  Format MSB/LSB           0/11   1/10   2/9    3/8    4/7    5/6    6/7    7/4    8/3    9/2    10/1   11/0
            int[] BitMSBhex = new int[] { 0x000, 0x001, 0x600, 0x700, 0x780, 0x7C0, 0x7E0, 0x7F0, 0x7F8, 0x7FC, 0x7FE, 0x7FF };
            int[] BitLSBhex = new int[] { 0x7FF, 0x7FE, 0x1FF, 0x0FF, 0x07F, 0x03F, 0x01F, 0x00F, 0x007, 0x003, 0x001, 0x000 };

            // Pulls the MSB and LSB from the ID for identity checking
            msgOutput[(int)BusFields.BitMSB] = String.Format("{0:X}", (can.id & BitMSBhex[BitMSBinput]));
            msgOutput[(int)BusFields.BitLSB] = String.Format("{0:X}", (can.id & BitLSBhex[BitMSBinput]));

            // Calls the filters
            if (filter != "")
            {
                // Checks for matches in the XML filter files for packet, ECU, and message
                string stringmsg = CommonUtils.ConvertMsgtoString(can.msg, can.dlc);

                // Filter Output processing
                msgOutput[(int)BusFields.Packet] = XMLInterfaces.ReturnPacketIdentifier(filter, can.id, stringmsg);
                //MainWindow.ErrorDisplayString("XML: " + msgOutput[(int)BusFields.Packet]);

                msgOutput[(int)BusFields.Id] = XMLInterfaces.ReturnID(filter, can.id);

                // Removed to conslidate output
                // msgOutput[(int)BusFields.DataID] = XMLInterfaces.ReturnMsg(filter, stringmsg);

                /*
                 * // If Then Filter Processing
                 * if (IfThenActive == true)
                 * {
                 *  XMLInterfaces.CheckIfThen(filter, can.id, stringmsg);
                 * }
                 */
            }

            // Hex output
            if (String.Compare(can.format, "hex", true) == 0)
            {
                // hex output
                msgOutput[(int)BusFields.IdNo]  = String.Format("{0:X3}", can.id);
                msgOutput[(int)BusFields.DLC]   = String.Format("{0:X}", can.dlc);
                msgOutput[(int)BusFields.Flags] = String.Format("{0}", can.flags);

                for (int i = 0; i < 8; i++)
                {
                    if (i < can.dlc)
                    {
                        msgOutput[(int)BusFields.Data] += String.Format(" {0:X2}", can.msg[i]);
                    }
                }
            }
            // Default to Decimal output if no format is given
            else
            {
                // decimal output
                msgOutput[(int)BusFields.IdNo]  = String.Format("{0}", can.id);
                msgOutput[(int)BusFields.DLC]   = Convert.ToString(can.dlc);
                msgOutput[(int)BusFields.Flags] = Convert.ToString(can.flags);
                for (int i = 0; i < 8; i++)
                {
                    if (i < can.dlc)
                    {
                        // decimal output
                        msgOutput[(int)BusFields.Data] += " " + Convert.ToString(can.msg[i]);
                    }
                }
            }

            if (can.errorFrame == true & can.flagString == "E")
            {
                msgOutput[(int)BusFields.Packet] = "Error Frame";
            }
            can.errorFrame = false;

/*
 *          switch (can.flagString)
 *          {
 *              case "E":
 *                  msgOutput[(int)BusFields.Packet] = "Error Frame";
 *                  break;
 *
 *              case "X":
 *                  msgOutput[(int)BusFields.Packet] = "Extended Frame";
 *                  break;
 *
 *              case "R":
 *                  msgOutput[(int)BusFields.Packet] = "Remote Frame";
 *                  break;
 *
 *              default:
 *                  msgOutput[(int)BusFields.Packet] = "Standard Frame";
 *                  break;
 *          }
 *
 *          if (can.errorFrame == true & can.flagString == "E")
 *              msgOutput[(int)BusFields.Packet] = "Error Frame";
 */

            // msgOutput[(int)BusFields.Flags] = can.flagString;
            msgOutput[(int)BusFields.Time] = String.Format("{0}", can.time);

            return(msgOutput);
        }
예제 #5
0
        // Transmits the selected packets
        private void Transmit_Click(object sender, EventArgs e)
        {
            try
            {
                CanData can       = new CanData();
                string  msgOutput = "";

                // Loop through all items the MonitorBox.
                for (int x = 0; x < TransmitBox.Items.Count; x++)
                {
                    // Determine if the item is selected.
                    if (TransmitBox.Items[x].Selected)
                    {
                        can.hardware = TransmitInterfaceBox.SelectedItem.ToString();
                        can.format   = "hex";
                        can.flags    = 0;
                        int count = 1;

                        // Transmit for simple packets
                        if (TransmitBox.Items[x].SubItems[1].Text.Contains("Packet"))
                        {
                            // return string --> 0=id; 1=dlc; 2=flag; 3=message
                            msgOutput = XMLInterfaces.ReturnPacketDataTransmit(TransmitList.SelectedItem.ToString(), TransmitBox.Items[x].SubItems[0].Text);
                            CommonUtils.ConvertStringtoCAN(can, msgOutput);
                            string[] output = msgOutput.Split(';');

                            if (output[3].Equals("X"))
                            {
                                can.flags = 4; // Extended Packet
                            }
                            // if packets number or time between is blank then only send one packet
                            if (output[4] == "" || output[5] == "")
                            {
                                GenericCanBus.GenericCanTransmitSingle(can);
                                // Verbose Output
                                if (VerboseTransmit.Checked == true)
                                {
                                    MessageBox.Show(CommonUtils.DisplayMsg(can));
                                }
                            }
                            else
                            {
                                can.number  = Convert.ToInt32(output[4]);
                                can.timeBtw = Convert.ToInt32(output[5]);
                                GenericCanBus.GenericCanTransmitMultiple(can);
                            }

                            // Transmit for Packet Sequences
                        }
                        else if (TransmitBox.Items[x].SubItems[1].Text.Contains("Sequence"))
                        {
                            // for execution once before the while check
                            do
                            {
                                // return string --> 0=id; 1=dlc; 2=flag; 3=message
                                msgOutput = XMLInterfaces.ReturnPacketDataSequence(count, TransmitList.SelectedItem.ToString(), TransmitBox.Items[x].SubItems[0].Text);
                                if (msgOutput.Equals("??"))
                                {
                                    return;
                                }

                                CommonUtils.ConvertStringtoCAN(can, msgOutput);
                                string[] output = msgOutput.Split(';');

                                if (output[3].Equals("X"))
                                {
                                    can.flags = 4; // Extended Packet
                                }
                                GenericCanBus.GenericCanTransmitSingle(can);

                                count++;

                                // Verbose Output
                                if (VerboseTransmit.Checked == true)
                                {
                                    MessageBox.Show(CommonUtils.DisplayMsg(can));
                                }
                            } while (msgOutput.Contains(";"));
                        }
                        else if (TransmitBox.Items[x].SubItems[1].Text.Contains("If Then"))
                        {
                            MainWindow.ErrorDisplayString("If Then Clauses are Activated in the Bus Monitor User Interface");
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("No interface is turned on, please turn on the interfaces from \"Advanced Bus Control\"");
                this.Close();
                BusControl form = (BusControl)CommonUtils.GetOpenedForm <BusControl>();
                if (form == null)
                {
                    form = new BusControl();
                    form.Show();
                }
                else
                {
                    form.Select();
                }
            }
        }