public void setup() throws Exception {
   for (int i = 0; i < count; i++) {
     IDevice d = environments.getDevice(device);
     d.setup();
     devices.add(d);
   }
 }
  /**
   * Implements BundleActivator.start(). Registers an instance of a dictionary service using the
   * bundle context; attaches properties to the service that can be queried when performing a
   * service look-up.
   *
   * @param context the framework context for the bundle.
   */
  public void start(BundleContext context) throws Exception {

    // System.out.println(new File(".").getAbsolutePath());

    // read the config
    config =
        (AutoSIMDevicesConfig)
            GsonUtils.jsonToObject("./conf/autosim-sampledevices.json", AutoSIMDevicesConfig.class);

    ServiceReference[] refs =
        context.getServiceReferences(IEnvironments.class.getName(), "(Language=*)");
    environments = (IEnvironments) context.getService(refs[0]);

    for (AutoSIMDeviceConfig deviceConfig : config.devices) {
      DevicesConnectionFactory factory = new DevicesConnectionFactory(deviceConfig, environments);
      environments.registerDeviceFactory(deviceConfig.name, factory);
      factories.put(deviceConfig.name, factory);
    }
  }
 /**
  * Implements BundleActivator.stop(). Does nothing since the framework will automatically
  * unregister any registered services.
  *
  * @param context the framework context for the bundle.
  */
 public void stop(BundleContext context) {
   for (AutoSIMDeviceConfig deviceConfig : config.devices) {
     environments.deregisterConnectionFactory(deviceConfig.name);
     factories.remove(deviceConfig.name);
   }
 }