I want to create a CANoe test environment that would do the following:
- Run and Stop the CANoe software
- Parse the XML file (test module) and show list in GUI
- Select individual test module and execute test module
So I'm done with the first two. Script shown below is what I did with executing the CANoe program itself with its corresponding config file. The ConfigFile string was from the the selected file in an OpenFileDialog.
private void button1_Click(object sender, EventArgs e)
{
mApp = new CANoe.Application();
mMsr = (CANoe.Measurement)mApp.Measurement;
string ConfigFile = textBox1.Text;
try
{
mApp.Open(ConfigFile,true,true);
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.Message);
}
}
As for the parsing, I did it with the Treeview listing. So numbers 1 and 2 are done. Now, I'm on the third part and I'm clueless where to start. I've experimented first selecting a particular node and clicking the button that is supposed to be for running the test module but instead shown a message box first.
private TreeNode selectedNode = null;
private void button3_Click(object sender, EventArgs e)
{
string testMod;
testMod = treeView1.SelectedNode.Text;
MessageBox.Show(treeView1.SelectedNode.Text);
}
I want to replace the MessageBox method with something that would possibly run the test modules in the XML file listed in the GUI. So instead of MessageBox.Show(treeView1.SelectedNode.Text), it would be something like:
string testMod;
testMod = treeView1.SelectedNode.Text;
if (mMsr != null) mMsr.Start();
CANoe.System sys = null;
CANoe.Namespaces nss = null;
CANoe.Namespace ns = null;
CANoe.Variables vars = null;
if (testMod = *the name of the test module*)
{
*//something like this*
sys = (CANoe.System)mApp.System;
nss = (CANoe.Namespaces)sys.Namespaces;
ns = (CANoe.Namespace)nss["_01_Test_Preparation"];
vars = (CANoe.Variables)ns.Variables;
mSysVar_start = (CANoe.Variable)vars["_01_01_Get_Dem_ID_start"];
mSysVar = (CANoe.Variable)vars["_01_01_Get_Dem_ID"];
mSysVar_start.Value = 1;
System.Threading.Thread.Sleep(1000);
mMsr.Start();
*//or something similar*
}
The "01_Test_Preparation" is the test module whereas the "01_01_Get_dem_ID_start" is the test case. I have to figure out how to incorporate these with the xml file and all. I admit that the snippets regarding shown above may be confusing or just plain wrong. Bear with me I'm totally new at this and simply doing the Trial and Error method.
Thanks in advance.