private void AddTestButton_Click(object sender, EventArgs e) { if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[0]) { MTKTestRXPER RXPERTest = new MTKTestRXPER(Log, MTKPort, DUTPort); MTKTestPERDialog TempDialog = new MTKTestPERDialog(); TempDialog.Text = "RX PER Test Configuration"; if (TempDialog.ShowDialog() == DialogResult.OK) { RXPERTest.ChannelNumber = TempDialog.ChannelNumber.SelectedIndex; RXPERTest.PowerLevel = int.Parse(MTKTest.GetPowerLevel(TempDialog.PowerLevel.Text)); RXPERTest.NumberOfPackets = (int)TempDialog.NumberOfPackets.Value; RXPERTest.PacketType = TempDialog.PacketTypeComboBox.Text; RXPERTest.PacketLength = (int)TempDialog.PacketLengthNumericUpDown.Value; RXPERTest.PERPassCriterion = (double)TempDialog.PERPassCriterionNumericUpDown.Value; UpdateTestProgramWithNewTest(RXPERTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[1]) { MTKTestTXPER TXPERTest = new MTKTestTXPER(Log, MTKPort, DUTPort); MTKTestPERDialog TempDialog = new MTKTestPERDialog(); TempDialog.Text = "TX PER Test Configuration"; if (TempDialog.ShowDialog() == DialogResult.OK) { TXPERTest.ChannelNumber = TempDialog.ChannelNumber.SelectedIndex; TXPERTest.PowerLevel = int.Parse(MTKTest.GetPowerLevel(TempDialog.PowerLevel.Text)); TXPERTest.NumberOfPackets = (int)TempDialog.NumberOfPackets.Value; TXPERTest.PacketType = TempDialog.PacketTypeComboBox.Text; TXPERTest.PacketLength = (int)TempDialog.PacketLengthNumericUpDown.Value; TXPERTest.PERPassCriterion = (double)TempDialog.PERPassCriterionNumericUpDown.Value; UpdateTestProgramWithNewTest(TXPERTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[2]) { MTKTestTXCW TXCWTest = new MTKTestTXCW(Log, MTKPort, DUTPort); MTKTestTXCWDialog TempDialog = new MTKTestTXCWDialog(); TempDialog.Text = "TX CW Test Configuration"; if (TempDialog.ShowDialog() == DialogResult.OK) { TXCWTest.ChannelNumber = TempDialog.ChannelNumber.SelectedIndex; TXCWTest.PowerLevel = int.Parse(MTKTest.GetPowerLevel(TempDialog.PowerLevel.Text)); TXCWTest.DurationForTXCW = (int)TempDialog.DurationForTXCW.Value; UpdateTestProgramWithNewTest(TXCWTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[3]) { MTKTestTXP TXPTest = new MTKTestTXP(Log, MTKPort, DUTPort); MTKTestRxTxDialog TempDialog = new MTKTestRxTxDialog(); TempDialog.Text = "TX Packet Test Configuration"; if (TempDialog.ShowDialog() == DialogResult.OK) { TXPTest.ChannelNumber = TempDialog.ChannelNumber.SelectedIndex; TXPTest.PowerLevel = int.Parse(MTKTest.GetPowerLevel(TempDialog.PowerLevel.Text)); TXPTest.NumberOfPackets = (int)TempDialog.NumberOfPackets.Value; TXPTest.PacketType = TempDialog.PacketTypeComboBox.Text; TXPTest.PacketLength = (int)TempDialog.PacketLengthNumericUpDown.Value; UpdateTestProgramWithNewTest(TXPTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[4]) { MTKTestRXP RXPTest = new MTKTestRXP(Log, MTKPort, DUTPort); MTKTestRxTxDialog TempDialog = new MTKTestRxTxDialog(); TempDialog.Text = "RX Packet Test Configuration"; if (TempDialog.ShowDialog() == DialogResult.OK) { RXPTest.ChannelNumber = TempDialog.ChannelNumber.SelectedIndex; RXPTest.PowerLevel = int.Parse(MTKTest.GetPowerLevel(TempDialog.PowerLevel.Text)); RXPTest.NumberOfPackets = (int)TempDialog.NumberOfPackets.Value; RXPTest.PacketType = TempDialog.PacketTypeComboBox.Text; RXPTest.PacketLength = (int)TempDialog.PacketLengthNumericUpDown.Value; UpdateTestProgramWithNewTest(RXPTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[5]) { MTKPSoCProgrammer MTKProgrammer = new MTKPSoCProgrammer(Log); if (MTKProgrammer.PSoCProgrammerInstalled && MTKProgrammer.IsCorrectVersion()) { MTKPSoCProgrammerDialog TempDialog = new MTKPSoCProgrammerDialog(MTKProgrammer); if (TempDialog.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(MTKProgrammer); } } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[6]) { MTKTestDelay MTKDelayInMS = new MTKTestDelay(Log); MTKTestDelayDialog TempDialog = new MTKTestDelayDialog(); if (TempDialog.ShowDialog() == DialogResult.OK) { MTKDelayInMS.DelayInMS = (int)TempDialog.DelayNumericUpDown.Value; UpdateTestProgramWithNewTest(MTKDelayInMS); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[7]) { if (IsBDAProgrammerPresent()) { MessageBox.Show("Only one instance of BDA Programmer can be added to a test program.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MTKTestBDADialog TempDialog = new MTKTestBDADialog(BDAProgrammer); if (BDAProgrammer.BDAProgrammer.PSoCProgrammerInstalled && BDAProgrammer.BDAProgrammer.IsCorrectVersion()) { if (TempDialog.ShowDialog() == DialogResult.OK) { CyBLE_MTK_Application.Properties.Settings.Default.BDA = TempDialog.BDATextBox.GetTextWithoutDelimiters(); CyBLE_MTK_Application.Properties.Settings.Default.BDAIncrement = BDAProgrammer.AutoIncrementBDA; CyBLE_MTK_Application.Properties.Settings.Default.BDAUseProgrammer = BDAProgrammer.UseProgrammer; CyBLE_MTK_Application.Properties.Settings.Default.Save(); } MTKTestBDAProgrammer MTKBDAProgrammer = new MTKTestBDAProgrammer(Log); UpdateTestProgramWithNewTest(MTKBDAProgrammer); } } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[8]) { MTKTestAnritsu AnritsuTest = new MTKTestAnritsu(Log); UpdateTestProgramWithNewTest(AnritsuTest); } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[9]) { MTKTestSTC STCTest = new MTKTestSTC(Log, MTKPort, DUTPort); MTKTestSTCDialog temp = new MTKTestSTCDialog(STCTest); if (temp.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(STCTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[10]) { MTKTestCUS CustomTest = new MTKTestCUS(Log, MTKPort, DUTPort); MTKTestCUSDialog temp = new MTKTestCUSDialog(CustomTest); if (temp.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(CustomTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[11]) { MTKPSoCProgrammer MTKProgrammer = new MTKPSoCProgrammer(Log); if (MTKProgrammer.PSoCProgrammerInstalled && MTKProgrammer.IsCorrectVersion()) { MTKTestProgramAll CustomTest = new MTKTestProgramAll(Log, MTKPort, DUTPort); MTKTestProgramAllDialog temp = new MTKTestProgramAllDialog(CustomTest); if (temp.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(CustomTest); } } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[12]) { MTKTestI2C CustomTest = new MTKTestI2C(Log); MTKTestI2CDialog temp = new MTKTestI2CDialog(CustomTest); if (temp.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(CustomTest); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[13]) { MTKTestRSX GetRSSI = new MTKTestRSX(Log, MTKPort, DUTPort); MTKTestRSXDialog temp = new MTKTestRSXDialog(GetRSSI); if (temp.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(GetRSSI); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[14]) { MTKTestRBA ReadBDA = new MTKTestRBA(Log, MTKPort, DUTPort); UpdateTestProgramWithNewTest(ReadBDA); } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[15]) { MTKTestXOCalibration XOCalibration = new MTKTestXOCalibration(Log, MTKPort, DUTPort); MTKTestXOCalDialog temp = new MTKTestXOCalDialog(XOCalibration); if (temp.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(XOCalibration); } } else if (AvailableTestListBox.GetItemText(AvailableTestListBox.SelectedItem) == ListOfAvailableTests[16]) { MTKTestDUTCurrentMeasure dutCurrMeas = new MTKTestDUTCurrentMeasure(Log, MTKPort, DUTPort); DUTCurrentMeasureDialog temp = new DUTCurrentMeasureDialog(); if (temp.ShowDialog() == DialogResult.OK) { UpdateTestProgramWithNewTest(dutCurrMeas); } } else if (ListBoxDoubleClick == false) { MessageBox.Show("Select a test to add to the program.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } ListBoxDoubleClick = false; }
public bool LoadTestProgram(bool LoadFromPath, string LoadFilePath) { Log.PrintLog(this, "Loading test program.", LogDetailLevel.LogRelevant); if ((FileNotSaved == true) && (SupervisorMode == true) && (NoFileLoaded == false)) { if (MessageBox.Show("Do you want to save - " + TestFileName + "?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveTestProgram(true); if (FileNotSaved == true) { return(false); } } } OpenFileDialog TestProgOpenFileDialog = new OpenFileDialog(); TestProgOpenFileDialog.Filter = "xml Files (*.xml)|*.xml|All Files (*.*)|*.*"; TestProgOpenFileDialog.FilterIndex = 1; if ((File.Exists(LoadFilePath) == false) && (LoadFromPath == true)) { if (MessageBox.Show("File does not exist! Do you want to browse for it?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return(false); } } if (LoadFromPath == false) { if (TestProgOpenFileDialog.ShowDialog() == DialogResult.Cancel) { Log.PrintLog(this, "Test program load cancelled.", LogDetailLevel.LogRelevant); return(false); } FullFileName = TestProgOpenFileDialog.FileName; } else { FullFileName = LoadFilePath; } string NewTestFileName = Path.GetFileName(FullFileName); XmlTextReader reader = new XmlTextReader(FullFileName); reader.Read(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); XmlNodeList TestNum = xmlDoc.GetElementsByTagName("NumberOfTests"); if (TestNum.Count != 1) { Log.PrintLog(this, "Corrupt file or wrong xml file format.", LogDetailLevel.LogEverything); Log.PrintLog(this, "Cannot load file.", LogDetailLevel.LogRelevant); return(false); } int NumberOfTests = Int32.Parse(TestNum[0].InnerText); XmlNodeList xnl = xmlDoc.SelectNodes("CyBLEMTKTestProgram/Test"); if (xnl.Count != NumberOfTests) { Log.PrintLog(this, "Corrupt file: Incorrect number of tests.", LogDetailLevel.LogEverything); Log.PrintLog(this, "Cannot load file.", LogDetailLevel.LogRelevant); return(false); } List <MTKTest> NewTestProgram = new List <MTKTest>(); foreach (XmlNode TestNode in xnl) { if (TestNode["Name"].InnerText == "MTKTestRXPER") { MTKTestRXPER TempTest = new MTKTestRXPER(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestTXPER") { MTKTestTXPER TempTest = new MTKTestTXPER(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestTXCW") { MTKTestTXCW TempTest = new MTKTestTXCW(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestTXP") { MTKTestTXP TempTest = new MTKTestTXP(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestRXP") { MTKTestRXP TempTest = new MTKTestRXP(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKPSoCProgrammer") { MTKPSoCProgrammer TempTest = new MTKPSoCProgrammer(Log); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestDelay") { MTKTestDelay TempTest = new MTKTestDelay(Log); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestBDAProgrammer") { if (!IsBDAProgrammerPresent(NewTestProgram)) { MTKTestBDAProgrammer TempTest = new MTKTestBDAProgrammer(Log); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } } else if (TestNode["Name"].InnerText == "MTKTestAnritsu") { MTKTestAnritsu TempTest = new MTKTestAnritsu(Log); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestSTC") { MTKTestSTC TempTest = new MTKTestSTC(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestDUTCurrentMeasure") { MTKTestDUTCurrentMeasure TempTest = new MTKTestDUTCurrentMeasure(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestCUS") { MTKTestCUS TempTest = new MTKTestCUS(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestProgramAll") { MTKTestProgramAll TempTest = new MTKTestProgramAll(Log, MTKSerialPort, DUTSerialPort); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestI2C") { MTKTestI2C TempTest = new MTKTestI2C(Log); TempTest.TestParameterCount = int.Parse(TestNode["NumberOfParamerters"].InnerText); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestRSX") { MTKTestRSX TempTest = new MTKTestRSX(Log); TempTest.TestParameterCount = int.Parse(TestNode["NumberOfParamerters"].InnerText); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestRBA") { MTKTestRBA TempTest = new MTKTestRBA(Log); TempTest.TestParameterCount = int.Parse(TestNode["NumberOfParamerters"].InnerText); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } else if (TestNode["Name"].InnerText == "MTKTestXOCalibration") { MTKTestXOCalibration TempTest = new MTKTestXOCalibration(Log); TempTest.TestParameterCount = int.Parse(TestNode["NumberOfParamerters"].InnerText); if (LoadTestParameters(TempTest, TestNode) == false) { return(false); } NewTestProgram.Add(TempTest); } } TestProgram.Clear(); TestProgram = NewTestProgram; TestFileName = NewTestFileName; NoFileLoaded = false; FileNotSaved = false; Log.PrintLog(this, "Test program successfully loaded from " + FullFileName, LogDetailLevel.LogRelevant); return(true); }
public MTKTestXOCalDialog(MTKTestXOCalibration XOCalTest) : this() { XOCal = XOCalTest; }