Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the test bench and the MA port.
        /// </summary>
        /// <param name="vendorName">Name of the vendor.</param>
        /// <param name="productName">The productName.</param>
        /// <param name="productVersion">The productVersion.</param>
        /// <param name="portConfigurationFile">The port configuration file.</param>
        public void Init(string vendorName, string productName, string productVersion, string portConfigurationFile)
        {
            // Create the test bench
            try
            {
                var factory = new TestbenchFactory();
                mTestbench = factory.CreateVendorSpecificTestbench(vendorName, productName, productVersion);
            }
            catch (Exception ex)
            {
                string msg = "Could not create the test bench. Is the ASAM XIL API and CANoe XIL API correctly installed?";
                msg += Environment.NewLine + Environment.NewLine;
                msg += "Error details: " + ex.Message;

                throw new Exception(msg);
            }

            // Create the MA port
            try
            {
                mMaPort = mTestbench.MAPortFactory.CreateMAPort("Example MA Port");
                mMaPort.Configure(mMaPort.LoadConfiguration(portConfigurationFile), false);
                mMaPort.StartSimulation();
            }
            catch (Exception ex)
            {
                string msg = "Could not create the MA port. Reason: ";
                msg += Environment.NewLine + Environment.NewLine;
                msg += "Error details: " + ex.Message;

                throw new Exception(msg);
            }

            IsConnected = true;
        }
    public static int InitTask(TaskCancelToken tct)
    {
        // Initialize a test bench and a MA port
        try
        {
            var factory   = new TestbenchFactory(sManifestFolder);
            var testbench = factory.CreateVendorSpecificTestbench(sVendorName, sProductName, sProductVersion);
            sMAPort = testbench.MAPortFactory.CreateMAPort("Example MA Port");
            sMAPort.StartSimulation();
        }
        catch (Exception ex)
        {
            Output.WriteLine("XIL API initialization failed: " + ex.Message);
        }

        return(1);
    }