以下是使用的代码:
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测试节点,但我无法这样做,并给出了以下错误。此函数向接口类型CANoe.Node返回一个错误,指出"Unable to case of type System.__Comobject“COM object
请告诉我们如何转换Node并运行XML testnode。
有没有其他方法可以从TestEnvironment运行它?请澄清。
发布于 2021-01-27 17:04:22
不能使用COM接口运行测试节点。为此,您需要将测试模块添加到测试环境(而不是模拟设置)。
完成此更改后,可以使用ExecuteAll或Start方法启动所有模块或特定模块。
https://stackoverflow.com/questions/63982619
复制相似问题