首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从矢量CANoe对象启动/执行XML测试节点

从矢量CANoe对象启动/执行XML测试节点
EN

Stack Overflow用户
提问于 2020-09-21 03:02:35
回答 1查看 166关注 0票数 1

以下是使用的代码:

代码语言:javascript
复制
    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运行它?请澄清。

EN

回答 1

Stack Overflow用户

发布于 2021-01-27 17:04:22

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63982619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档