/**
   * Walks through the DDS, converts DAP data to ptII data, and broadcasts the data onto the
   * appropriate ports.
   *
   * @param dds The DDS from which to get the data to send
   * @throws IllegalActionException When bad things happen.
   */
  private void broadcastDapData(DDS dds) throws IllegalActionException {

    // log.debug("broadcastDapData(): DataDDS prior to broadcast:");
    // dds.print(System.out);

    Enumeration e = dds.getVariables();
    while (e.hasMoreElements()) {
      opendap.dap.BaseType bt = (opendap.dap.BaseType) e.nextElement();

      String columnName = bt.getLongName().trim();
      // Get the port associated with this DDS variable.
      TypedIOPort port = (TypedIOPort) this.getPort(columnName);
      if (port == null) {
        throw new IllegalActionException("Request Output Port Missing: " + columnName);
      }

      log.debug("Translating data.");
      // bt.printDecl(System.out);

      // Map the DAP data for this variable into the ptII Token model.
      ptolemy.data.Token token = TokenMapper.mapDapObjectToToken(bt, false);
      log.debug("Data Translated :");
      // bt.printDecl(System.out);

      // Send the data.
      log.debug("Sending data.");
      port.broadcast(token);
      log.debug("Sent data.");
    }
  }
  /**
   * Configure the output ports to expose all of the variables at the top level of the (potentially
   * constrained) DDS.
   *
   * @param dds The DDS
   * @throws IllegalActionException When bad things happen.
   */
  private void configureOutputPorts(DDS dds) throws IllegalActionException {

    Vector<Type> types = new Vector<Type>();
    Vector<String> names = new Vector<String>();

    Enumeration e = dds.getVariables();
    while (e.hasMoreElements()) {
      opendap.dap.BaseType bt = (opendap.dap.BaseType) e.nextElement();
      types.add(TypeMapper.mapDapObjectToType(bt, false));
      names.add(bt.getLongName());
    }

    removeOtherOutputPorts(names);

    Iterator ti = types.iterator();
    Iterator ni = names.iterator();

    while (ti.hasNext() && ni.hasNext()) {
      Type type = (Type) ti.next();
      String name = (String) ni.next();
      initializePort(name, type);
    }
  }