private void toolStripButtonAdvancedBusControl_Click(object sender, EventArgs e) { BusControl newMDIChild = new BusControl(); newMDIChild.MdiParent = this; newMDIChild.Show(); }
private void busControlToolStripMenuItem_Click(object sender, EventArgs e) { BusControl newMDIChild = new BusControl(); newMDIChild.MdiParent = this; newMDIChild.Show(); }
public MainWindow() { InitializeComponent(); //Starts a window for the Bus Control BusControl newMDIChild = new BusControl(); newMDIChild.MdiParent = this; newMDIChild.Show(); //BusMonitorCompact bmc = new BusMonitorCompact(); //bmc.ShowDialog(); //Checks to see if the guided bus control should be started if (ConfigFiles.Settings1.Default.skipGuidedBusControl == false) { Windows.GuidedBusControl newMDIChild2 = new Windows.GuidedBusControl(); newMDIChild2.MdiParent = this; newMDIChild2.Show(); } }
//**************************** // Transmit Settings Tab // Written by Parnian Najafi Borazjani //**************************** private void TransmitPacket_Click(object sender, EventArgs e) { CanData can = new CanData(); int number_messages = 1; string msgOutput = ""; string flag; //if (Transmit_dlc.Value>8) // MessageBox.Show("Messages can have a maximum of 8"); // For the various flags // Need to implement an enumerated keyword to replace these numbers // These numbers are from the Kvaser library documentation and may not work on other CAN systems if (Flag_Ext.Checked == true) flag = "X"; // Extended else if (Flag_Err.Checked == true) flag = "E"; // Error else if (Flag_Rtr.Checked == true) flag = "R"; // Remote else flag = "S"; // Standard if (InputTests.IsStringNumeric(Transmit_NoMsg.Text) == true) number_messages = Convert.ToInt32(Transmit_NoMsg.Text); else MessageBox.Show("Error: Number of Messages is not Numeric", "Error", MessageBoxButtons.OK); msgOutput = Transmit_id.Text + ";" + Transmit_dlc.Text + ";" + flag + ";" + Transmit_msg0.Text + "-" + Transmit_msg1.Text + "-" + Transmit_msg2.Text + "-" + Transmit_msg3.Text + "-" + Transmit_msg4.Text + "-" + Transmit_msg5.Text + "-" + Transmit_msg6.Text + "-" + Transmit_msg7.Text; if (Transmit_Hex.Checked == true) can.format = "hex"; else can.format = "decimal"; CommonUtils.ConvertStringtoCAN(can, msgOutput); can.number = number_messages; can.timeBtw = 0; try { can.hardware = TransmitInterfaceBox.SelectedItem.ToString(); if (IncrementIdentifier.Checked == true) can.increment = true; GenericCanBus.GenericCanTransmitMultiple(can); //bgTransmit.RunWorkerAsync(can); toolStripStatusLabel2.Text = CommonUtils.ErrorMsg("Transmit Message", can.status); ErrorLog.NewLogEntry("CAN", "Transmit Message: " + can.status); if (VerboseTransmit.Checked == true) MessageBox.Show(CommonUtils.DisplayMsg(can)); } catch { MessageBox.Show("No interface is turned on, please turn on the interfaces from \"Advanced Bus Control\" Window"); this.Close(); BusControl form = (BusControl)CommonUtils.GetOpenedForm<BusControl>(); if (form == null) { form = new BusControl(); form.Show(); } else { form.Select(); } } }
// 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(); } } }
//**************************** // Monitor Bus Tab //Written by Chris Everett and Parnian Najafi Borazjani //**************************** private void MonitorBus2_Click(object sender, EventArgs e) { try { toolStripStatusLabel2.Text = "Monitor Bus On"; //ReceiveStop = true; // Assume decimal if is not checked string format; if (Monitor_Hex.Checked == true) format = "hex"; else format = "decimal"; // the arguments for the backgroundWorkerRead worker string[] arguments = { ReceiveInterfaceBox.SelectedItem.ToString(), format, CarFilter, Convert.ToString(numericMSB.Value), TransmitInterfaceBox.SelectedItem.ToString() }; if (backgroundWorkerRead.IsBusy != true) { backgroundWorkerRead.RunWorkerAsync(arguments); MonitorBus2.Enabled = false; StopMonitor2.Enabled = true; ErrorLog.NewLogEntry("CAN", "Monitor Bus On"); } else { ErrorLog.NewLogEntry("CAN", "Monitor Bus - Background Worker Busy"); } } catch { MessageBox.Show("No interface is turned on, please turn on the interfaces from \"Advanced Bus Control\" window"); this.Close(); BusControl form = (BusControl)CommonUtils.GetOpenedForm<BusControl>(); if (form == null) { form = new BusControl(); form.Show(); } else { form.Select(); } } }
// bool testerTPFlag = false; //*********************************************** // Activates or De-activates the Tester Present //Written By Chris Everett & Parnian Najafi Borazjani //********************************************* private void buttonTesterPresent_Click(object sender, EventArgs e) { try{ if (!TesterPresent) { buttonTesterPresent.Text = "De-Activate Tester Present"; TesterPresent = true; pictureBoxTester.BackColor = Color.Green; string[] arguments = { TesterPresentID.Text, TesterPresentDLC.Text, TesterPresentMessage.Text, TransmitInterfaceBox.SelectedItem.ToString() , TimeBetween.Text}; if (backgroundWorkerTester_C.IsBusy != true) { // MainWindow.ErrorDisplayString("Start Tester Present"); backgroundWorkerTester_C.RunWorkerAsync(arguments); ErrorLog.NewLogEntry("CAN", "Monitor Bus On"); FileLog.Log("CAN - Monitor Bus On"); } else { ErrorLog.NewLogEntry("CAN", "Monitor Bus - Background Tester Worker Busy"); FileLog.Log("CAN - Monitor Bus - Background Tester Worker Busy"); } // Status Update toolStripStatusLabel2.Text = "Tester Present Transmit Message"; ErrorLog.NewLogEntry("CAN", "Tester Present Transmit Message: "); FileLog.Log("CAN - Tester Present Transmit Message: "); } else { buttonTesterPresent.Text = "Activate Tester Present"; TesterPresent = false; pictureBoxTester.BackColor = Color.Red; if (backgroundWorkerTester_C.WorkerSupportsCancellation == true) { backgroundWorkerTester_C.CancelAsync(); } } } catch { MessageBox.Show("No interface is turned on, please turn on the interfaces from \"Advanced Bus Control\" window"); this.Close(); BusControl form = (BusControl)CommonUtils.GetOpenedForm<BusControl>(); if (form == null) { form = new BusControl(); form.Show(); } else { form.Select(); } } }
//**************************** // Transmit Settings Tab // Written by Parnian Najafi Borazjani //**************************** private void TransmitPacket_Click(object sender, EventArgs e) { CanData can = new CanData(); int number_messages = 1; string msgOutput = ""; string flag; //if (Transmit_dlc.Value>8) // MessageBox.Show("Messages can have a maximum of 8"); // For the various flags // Need to implement an enumerated keyword to replace these numbers // These numbers are from the Kvaser library documentation and may not work on other CAN systems if (Flag_Ext.Checked == true) { flag = "X"; // Extended } else if (Flag_Err.Checked == true) { flag = "E"; // Error } else if (Flag_Rtr.Checked == true) { flag = "R"; // Remote } else { flag = "S"; // Standard } if (InputTests.IsStringNumeric(Transmit_NoMsg.Text) == true) { number_messages = Convert.ToInt32(Transmit_NoMsg.Text); } else { MessageBox.Show("Error: Number of Messages is not Numeric", "Error", MessageBoxButtons.OK); } msgOutput = Transmit_id.Text + ";" + Transmit_dlc.Text + ";" + flag + ";" + Transmit_msg0.Text + "-" + Transmit_msg1.Text + "-" + Transmit_msg2.Text + "-" + Transmit_msg3.Text + "-" + Transmit_msg4.Text + "-" + Transmit_msg5.Text + "-" + Transmit_msg6.Text + "-" + Transmit_msg7.Text; if (Transmit_Hex.Checked == true) { can.format = "hex"; } else { can.format = "decimal"; } CommonUtils.ConvertStringtoCAN(can, msgOutput); can.number = number_messages; can.timeBtw = 0; try { can.hardware = TransmitInterfaceBox.SelectedItem.ToString(); if (IncrementIdentifier.Checked == true) { can.increment = true; } GenericCanBus.GenericCanTransmitMultiple(can); //bgTransmit.RunWorkerAsync(can); toolStripStatusLabel2.Text = CommonUtils.ErrorMsg("Transmit Message", can.status); ErrorLog.NewLogEntry("CAN", "Transmit Message: " + can.status); if (VerboseTransmit.Checked == true) { MessageBox.Show(CommonUtils.DisplayMsg(can)); } } catch { MessageBox.Show("No interface is turned on, please turn on the interfaces from \"Advanced Bus Control\" Window"); this.Close(); BusControl form = (BusControl)CommonUtils.GetOpenedForm <BusControl>(); if (form == null) { form = new BusControl(); form.Show(); } else { form.Select(); } } }