/**
   * Main processing thread
   *
   * <p>General functionality: This function is running as a separate thread from the component's
   * main thread.
   *
   * @generated
   */
  public void run() {
    // begin-user-code
    double[] data = new double[this.xfer_len.getValue()];
    double phase = 0;
    double chirp = 0;
    double sample_time_delta;
    double delta_phase;
    double delta_phase_offset;

    sri = new StreamSRI();
    sri.hversion = 1;
    sri.mode = 0;
    sri.xdelta = 0.0;
    sri.ydelta = 1.0;
    sri.subsize = 0;
    sri.xunits = 1; // TIME_S
    sri.streamID = (this.stream_id.getValue() != null) ? this.stream_id.getValue() : "";
    sriUpdate = true;
    // end-user-code

    while (this.started()) {
      // begin-user-code
      try {
        /// If the transfer length has changed, reallocate the buffer
        if (this.xfer_len.getValue() != data.length) {
          data = new double[this.xfer_len.getValue()];
          sriUpdate = true;
        }

        sample_time_delta = (1.0 / this.sample_rate.getValue());
        if (sample_time_delta != sri.xdelta) {
          sri.xdelta = sample_time_delta;
          sriUpdate = true;
        }

        if (sriUpdate || (!this.port_out.hasSri(sri.streamID))) {
          this.port_out.pushSRI(sri);
        }
        sriUpdate = false;

        delta_phase = this.frequency.getValue() * sample_time_delta;
        delta_phase_offset = chirp * sample_time_delta * sample_time_delta;
        if ((delta_phase < 0) && (!this.shape.getValue().equals("sine"))) {
          delta_phase = -delta_phase;
        }

        // Generate the Waveform
        if (this.shape.getValue().equals("sine")) {
          Waveform.sincos(
              data, this.magnitude.getValue(), phase, delta_phase, this.xfer_len.getValue(), 1);
        } else if (this.shape.getValue().equals("square")) {
          Waveform.square(
              data, this.magnitude.getValue(), phase, delta_phase, this.xfer_len.getValue(), 1);
        } else if (this.shape.getValue().equals("triangle")) {
          Waveform.triangle(
              data, this.magnitude.getValue(), phase, delta_phase, this.xfer_len.getValue(), 1);
        } else if (this.shape.getValue().equals("sawtooth")) {
          Waveform.sawtooth(
              data, this.magnitude.getValue(), phase, delta_phase, this.xfer_len.getValue(), 1);
        } else if (this.shape.getValue().equals("pulse")) {
          Waveform.pulse(
              data, this.magnitude.getValue(), phase, delta_phase, this.xfer_len.getValue(), 1);
        } else if (this.shape.getValue().equals("constant")) {
          Waveform.constant(data, this.magnitude.getValue(), this.xfer_len.getValue(), 1);
        } else if (this.shape.getValue().equals("whitenoise")) {
          Waveform.whitenoise(data, this.magnitude.getValue(), this.xfer_len.getValue(), 1);
        } else if (this.shape.getValue().equals("lrs")) {
          Waveform.lrs(data, this.magnitude.getValue(), this.xfer_len.getValue(), 1, 1);
        }

        phase += delta_phase * this.xfer_len.getValue(); // increment phase
        phase -= Math.floor(phase); // modulo 1.0

        // Create a CPU time-stamp
        long tmp_time = System.currentTimeMillis();
        double wsec = tmp_time / 1000;
        double fsec = (tmp_time % 1000) / 1000.;
        PrecisionUTCTime tstamp =
            new PrecisionUTCTime(BULKIO.TCM_CPU.value, (short) 1, (short) 0, wsec, fsec);

        // Push the data
        this.port_out.pushPacket(
            data,
            tstamp,
            false,
            (this.stream_id.getValue() != null) ? this.stream_id.getValue() : "");

        // If we are throttling, wait...otherwise run at full speed
        if (this.throttle.getValue() == true) {
          long wait_amt = (long) (this.xfer_len.getValue() * sample_time_delta * 1000);
          try {
            Thread.sleep(wait_amt);
          } catch (InterruptedException e) {
            break;
          }
        }
      } catch (Throwable t) {
        logger.error("Error in processing loop", t);
      }
      // end-user-code
    }

    // begin-user-code
    // end-user-code
  }