C# 从vector CANoe对象启动/执行XML测试节点

C# 从vector CANoe对象启动/执行XML测试节点,c#,canoe,comobject,test-environments,C#,Canoe,Comobject,Test Environments,以下是使用的代码: CANoe.Application mCANoeApp; CANoe.Measurement mCANalyzerMeasurement; CANoe.Nodes mCANoeNodes; CANoe.Node mCANoeNode; CANoe.Configuration mConfig; CANoe.TestModules mTestModules; CANoe.TestSetup mTestSetup; C

以下是使用的代码:

    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
CANoe.Application应用程序;
独木舟.测量分析测量;
独木舟节;独木舟节;
独木舟节;
独木舟。配置mConfig;
CANoe.TestModules mTestModules;
CANoe.TestSetup mTestSetup;
独木舟试验环境;
CANoe.TSTEST模块MTS模块;
CANoe.SimulationSetup msimulationSetup;
独木舟、公共汽车和公共汽车;
mcanoapp=new CANoe.Application();
//调用委托
mCANoeApp.OnOpen+=mCANoeApp_OnOpen;
mcanoapp.Open(cfgfiles[0],true,true)//开放式cfg
mCANalyzerMeasurement=(独木舟测量)mCANoeApp.Measurement;
mCANalyzerMeasurement.OnStart+=mCANalyzerMeasurement\u OnStart;
mCANalyzerMeasurement.OnStop+=mCANalyzerMeasurement\u OnStop;
//启动测量时调用
mCANalyzerMeasurement.OnStart+=mCANalyzerMeasurement\u OnStart;
//开始测量。。。。。。。。。。
mCANalyzerMeasurement.Start()//跑
str=“独木舟测量已开始…”+“\n”;
某人附加(str);
当(!mCANalyzerMeasurement.Running)运行时
{
系统.线程.线程.睡眠(500);
}
//多节点
msimulationSetup=(CANoe.SimulationSetup)mcaneapp.Configuration.SimulationSetup;
mCANoeNodes=(CANoe.Nodes)msimulationSetup.Nodes;
toolStripStatusLabel1.Text=“检查TestNode…”+“\n”;
strTestNodeToTest=“TestNode”//这是一个XML测试节点
sb.追加(toolStripStatusLabel1.Text);
对于(int i=1;i
我想自动启动正在进行的测量,但稍后我想运行 XML测试节点,我不能这样做,并给出以下错误。 此函数将向接口类型CANoe.Node返回错误,说明“无法对System.\u Comobject类型的COM对象进行装箱”

请让我们知道如何强制转换节点并运行XMLTestNode

有没有其他方法可以在测试环境中运行它?
请澄清。

无法使用COM接口运行测试节点。为此,您需要将测试模块添加到测试环境(而不是模拟设置)


完成此更改后,可以使用
ExecuteAll
Start
方法启动所有模块或特定模块。

无法使用COM接口运行测试节点。为此,您需要将测试模块添加到测试环境(而不是模拟设置)

完成此更改后,可以使用
ExecuteAll
Start
方法启动所有模块或特定模块