hellogeek
hellogeek

Reputation: 13

Automatically generate nodes in a Canoe configuration simulation

I am trying to automate and create a Canoe simulation.

My usecase :

I have a configuration (LibraryTest.cfg) with a CAN Network and a node ACAN in the network. I want to create another node BCAN automatically into the existing configuration along with ACAN. I am trying this using C# .NET Canoe Library for this.

        CANoe.Application mApp;
        CANoe.Measurement mMsr;
        CANoe.Networks mNet;            
        mApp = new CANoe.Application();

        string ConfigFile= 
      "C:\\Users\\deepasreeraj\\Desktop\\GAC\\TestUnit1\\LibraryTest.cfg";
        try
        {
            mApp.Open(ConfigFile, true, true);
            mMsr = (CANoe.Measurement)mApp.Measurement;
            mNet = mApp.Networks;
            CANoe.Simulation mSim = mApp.Simulation;        

            if (mNet != null)
            {
                if(mNet != null)
                {
                    int count = mNet.Count;
                    for (int i = 0; i < count; i++)
                    {
                        mNet.Add("BCAN");
                        string Nodename = mNet[i].NetworkInterfaces;
                    }                    

                }
            }
        }
        catch (System.Exception ex)
        {
            System.Console.WriteLine(ex.Message);
        }
    }

In this, while the code reaches mNet.Add("BCAN"); it gives an exception "The method or operation is not implemented." Can someone please help me with this?

Upvotes: 1

Views: 2776

Answers (1)

mspiller
mspiller

Reputation: 3839

If you want to add a node, the Networks property is wrong.

You have to use mApp.Configuration.SimulationSetup.Buses.Nodes. There you can call Add to add a new node.

Just check the page Technical References -> COM Interface -> Object Hierarchy in the CANoe help for the complete API Reference.

Upvotes: 1

Related Questions