以下是使用的代码:
CANoe.Application mCANoeApp;
CANoe.Measurement mCANalyzerMeasurement;
CANoe.Nodes mCANoeNodes;
CANoe.Node mCANoeNode;
CANoe.Configuration mConfig;
CANoe.TestModules mTestModules;
CANoe.TestSetup mTestSetup;
CANoe.TestEnvironments mtestEnvironments;
CANoe.TSTestModule mTSmodule;
CANoe.SimulationSetup msimulationSetup;
CANoe.Buses mCanoebuses;
mCANoeApp = new CANoe.Application();
//invoke delegate
mCANoeApp.OnOpen += mCANoeApp_OnOpen;
mCANoeApp.Open(cfgfiles[0], true, true); //open cfg
mCANalyzerMeasurement = (CANoe.Measurement)mCANoeApp.Measurement;
mCANalyzerMeasurement.OnStart += mCANalyzerMeasurement_OnStart;
mCANalyzerMeasurement.OnStop += mCANalyzerMeasurement_OnStop;
//invoke onStart Measurement
mCANalyzerMeasurement.OnStart += mCANalyzerMeasurement_OnStart;
//Start the measurement ..........
mCANalyzerMeasurement.Start(); //run
str = "Canoe measurement started..." + "\n";
sb.Append(str);
while (!mCANalyzerMeasurement.Running)
{
System.Threading.Thread.Sleep(500);
}
// multiple nodes
msimulationSetup = (CANoe.SimulationSetup)mCANoeApp.Configuration.SimulationSetup;
mCANoeNodes = (CANoe.Nodes)msimulationSetup.Nodes;
toolStripStatusLabel1.Text = "check for TestNode..." + "\n";
strTestNodeToTest = "TestNode"; //This is an XML TestNode
sb.Append(toolStripStatusLabel1.Text);
for (int i=1;i< mCANoeNodes.Count;i++)
{
str = "Nodes Count: "+ mCANoeNodes.Count.ToString()+" index:" +i.ToString() + "\n";
sb.Append(str);
toolStripStatusLabel1.Text = "mCANoeNodes[i].Name:? " + mCANoeNodes[i].Name + "\n";
sb.Append(toolStripStatusLabel1.Text);
if (mCANoeNodes[i].Name == strTestNodeToTest)
{
mCANoeNodes[i].Active = true;
toolStripStatusLabel1.Text = "Before start NM " + "\n";
sb.Append(str);
((CANoe.Node)mCANoeNodes[i]).StartNM(); //Is this correct
toolStripStatusLabel1.Text = "After start NM " + "\n";
sb.Append(toolStripStatusLabel1.Text);
break;
}
}
((CANoe.Node)mCANoeNodes[i]).StartNM(); //Is this correct
我想自动开始正在发生的测量,但后来我想运行 XML 测试节点,但我无法做到这一点,并给出以下错误。此函数返回错误说“无法区分 System.__Comobject 类型的 COM 对象”到接口类型 CANoe.Node
请让我们知道如何转换节点并运行 XML 测试节点。
有没有其他方法可以从 TestEnvironment 运行它?请说清楚。