/**
  * Creates and returns an instrument. The creation using the <code>add*</code> methods has been
  * tested i.e. addDectector, etc.
  *
  * @param light The type of light source.
  * @param withPump Pass the type of light source of the pump or <code>null</code> .
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public Instrument createInstrument(String light, String pump) throws Exception {
   Instrument instrument = createInstrument();
   instrument.addDetector(createDetector());
   instrument.addFilter(createFilter(500, 560));
   Dichroic dichroic = createDichroic();
   instrument.addDichroic(dichroic);
   Objective objective = createObjective();
   FilterSet filterSet = createFilterSet();
   instrument.addObjective(objective);
   instrument.addFilterSet(filterSet);
   instrument.addOTF(createOTF(filterSet, objective));
   if (LASER.equals(light)) {
     Laser laser = createLaser();
     instrument.addLightSource(laser);
     if (pump != null) {
       LightSource ls = null;
       if (LASER.equals(pump)) ls = createLaser();
       else if (FILAMENT.equals(pump)) ls = createArc();
       else if (ARC.equals(pump)) ls = createFilament();
       if (ls != null) {
         instrument.addLightSource(ls);
         laser.setPump(ls);
       }
     }
   } else if (FILAMENT.equals(light)) instrument.addLightSource(createFilament());
   else if (ARC.equals(light)) instrument.addLightSource(createArc());
   else if (LIGHT_EMITTING_DIODE.equals(light))
     instrument.addLightSource(createLightEmittingDiode());
   return instrument;
 }
  /**
   * Creates and returns a laser. This will have to be linked to an instrument.
   *
   * @return See above.
   * @throws Exception Thrown if an error occurred.
   */
  public Laser createLaser() throws Exception {
    Laser laser = new LaserI();
    laser.setManufacturer(omero.rtypes.rstring("manufacturer"));
    laser.setModel(omero.rtypes.rstring("model"));
    laser.setLotNumber(omero.rtypes.rstring("lot number"));
    laser.setSerialNumber(omero.rtypes.rstring("serial number"));
    // type
    List<IObject> types = pixelsService.getAllEnumerations(LaserType.class.getName());
    laser.setType((LaserType) types.get(0));
    // laser medium
    types = pixelsService.getAllEnumerations(LaserMedium.class.getName());
    laser.setLaserMedium((LaserMedium) types.get(0));

    // pulse
    types = pixelsService.getAllEnumerations(Pulse.class.getName());
    laser.setPulse((Pulse) types.get(0));

    laser.setFrequencyMultiplication(omero.rtypes.rint(1));
    laser.setPockelCell(omero.rtypes.rbool(false));
    laser.setTuneable(omero.rtypes.rbool(true));
    laser.setWavelength(omero.rtypes.rint(500));
    laser.setPower(omero.rtypes.rdouble(1));
    laser.setRepetitionRate(omero.rtypes.rdouble(1));
    return laser;
  }