0

am using JACOB as a bridge with java to access objects of a simulator (PTV vissim)to be able to manipulate it in real time , most objects has methods and properties... i was going well , because i was using the ...

getProperty and invoke functions but now I need to access an object attribute e.g. name but i don't know which function should I use , the object am dealing with is an instance of

ActiveXComponent

package com.vissim;

import java.util.List;
import java.util.Scanner;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Variant;


public class Main {

    /**
     * @param args
     */

    public static void main(String[] args) {

        Vissim vissim = new Vissim();
        vissim.start();
        vissim.LoadNet("H:\\MY VISSIM\\projects\\new.inpx");


        Net net = new Net(vissim);

        ActiveXComponent linkContainer =  net.getNetProperty("links");
        System.out.println("links fetched");
        ActiveXComponent link =linkContainer.invokeGetComponent("itemByKey", new Variant(1));
        // the problem is here , i need to do something like 
        //link.getProperty("Attributes");

        System.out.println("we are here ");

}
Exorcismus
  • 2,243
  • 1
  • 35
  • 68

1 Answers1

0

Use com4j to generate some wrapper files. com4j will probably crash saying that it is unable to handle some of the types, but if you go to the generated java files you will see the names of all of the methods that can be called from the Dispatch object e.g. ISimulation.java will have all of the methods that you can call on a Simulation object. Here is an example of some function / method calls:

Dispatch vissim = VISSIM.getObject();
Dispatch.call(vissim, "loadNet", new Object[]{new Variant("C:\\Users\\userName\\workspace\\VISSIMNetworks\\network.inp"), new Variant(0)});
Dispatch simulation = Dispatch.call(vissim, "simulation").toDispatch();
Dispatch.call(simulation, "runContinuous");
Jason Aller
  • 3,541
  • 28
  • 38
  • 38