Exemple #1
0
/* ppm_execute: runs the currently downloaded pulse program. */
void ppm_execute (void) {
  /* declare required variables. */
  uint32_t f32, n32;
  uint16_t a16, d16;
  uint8_t a8, en;

  /* declare the current value of the shim dac output. */
  uint16_t dac16 = 0x0000;

  /* initialize all interpreter variables. */
  VAR_INIT (n32);
  VAR_INIT (f32);
  VAR_INIT (d16);
  VAR_INIT (a16);
  VAR_INIT (a8);
  VAR_INIT (en);
  VAR_INIT (dac16);

  /* loop through the pulse program array. */
  for (i_pulprog = 0;
       i_pulprog < n_pulprog &&
       i_pulprog < SZ_PULPROG;
       i_pulprog++) {
    /* determine the pulse program command at the current index. */
    switch (pulprog[i_pulprog]) {
      /* short, imprecise delay. */
#ifdef PPM_PULPROG_HAVE_DEADTIME
      case PPM_PULPROG_DEADTIME:
        /* build the delay time word and run the dead time command. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);
        ppm_deadtime (d16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* precise delay. */
#ifdef PPM_PULPROG_HAVE_DELAY
      case PPM_PULPROG_DELAY:
        /* build the delay time word and run the delay command. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);
        dac16 = ppm_delay (d16, dac16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* polarization control. */
#ifdef PPM_PULPROG_HAVE_POLARIZE
      case PPM_PULPROG_POLARIZE:
        /* get the enable byte and run the control command. */
        en = pulprog[i_pulprog + 1];
        ppm_ccs_enable (en);

        /* skip to the next pulse program command. */
        i_pulprog += 1;
        break;
#endif

      /* relay control. */
#ifdef PPM_PULPROG_HAVE_RELAY
      case PPM_PULPROG_RELAY:
        /* get the enable byte and run the control command. */
        en = pulprog[i_pulprog + 1];
        ppm_relay_enable (en);

        /* skip to the next pulse program command. */
        i_pulprog += 1;
        break;
#endif

      /* acquisition. */
#ifdef PPM_PULPROG_HAVE_ACQUIRE
      case PPM_PULPROG_ACQUIRE:
        /* build the acquisition sample count. */
        n32 = WORD32 (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2],
                      pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* build the acquisition sample rate overflow. */
        d16 = WORD (pulprog[i_pulprog + 5], pulprog[i_pulprog + 6]);

        /* run the acquisition command. */
        ppm_acquire (n32, d16);

        /* skip to the next pulse program command. */
        i_pulprog += 6;
        break;
#endif

      /* adiabatic polarization rising edge. */
#ifdef PPM_PULPROG_HAVE_TX
      case PPM_PULPROG_TXRISE:
        /* build the sample count word. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* build the amplitude step word. */
        a16 = WORD (pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* run the rising edge command. */
        dac16 = ppm_txrise (d16, a16, dac16);

        /* skip to the next pulse program command. */
        i_pulprog += 4;
        break;
#endif

      /* adiabatic polarization falling edge. */
#ifdef PPM_PULPROG_HAVE_TX
      case PPM_PULPROG_TXFALL:
        /* build the sample count word. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* build the amplitude step word. */
        a16 = WORD (pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* run the falling edge command. */
        dac16 = ppm_txfall (d16, a16, dac16);

        /* skip to the next pulse program command. */
        i_pulprog += 4;
        break;
#endif

      /* sinusoidal pulse. */
#ifdef PPM_PULPROG_HAVE_TX
      case PPM_PULPROG_TXPULSE:
        /* build the synthesis sample count. */
        n32 = WORD32 (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2],
                      pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* build the frequency tuning word. */
        f32 = WORD32 (pulprog[i_pulprog + 5], pulprog[i_pulprog + 6],
                      pulprog[i_pulprog + 7], pulprog[i_pulprog + 7]);

        /* get the amplitude multiplier byte. */
        a8 = pulprog[i_pulprog + 9];

        /* run the pulse synthesis command. */
        ppm_txpulse (n32, f32, a8);

        /* return the transmit coil dac output to zero. */
        spi_write_dac_a (0x0000);

        /* skip to the next pulse program command. */
        i_pulprog += 9;
        break;
#endif

      /* capacitive tuning. */
#ifdef PPM_PULPROG_HAVE_TUNE
      case PPM_PULPROG_TUNE:
        /* build the tuning word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the tuning command. */
        ppm_settune (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* x-axis shim. */
#ifdef PPM_PULPROG_HAVE_SHIM_X
      case PPM_PULPROG_SHIM_X:
        /* build the shimming word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the shimming command. */
        ppm_setshim_x (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* y-axis shim. */
#ifdef PPM_PULPROG_HAVE_SHIM_Y
      case PPM_PULPROG_SHIM_Y:
        /* build the shimming word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the shimming command. */
        ppm_setshim_y (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* z-axis shim. */
#ifdef PPM_PULPROG_HAVE_SHIM_Z
      case PPM_PULPROG_SHIM_Z:
        /* build the shimming word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the shimming command. */
        ppm_setshim_z (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* end execution. */
      case PPM_PULPROG_END:
        /* send back a completion code and end execution. */
        ppm_done ();
        return;

      /* unrecognized command. */
      default:
        /* send back an error code and end execution. */
        ppm_error ();
        return;
    }
  }
}
Exemple #2
0
  sprintf (val, "coap://%s:%s%s/%s", GetHostName(), GetCoapPortR(), SCL_ROOT_APP, GetDriverId());
  InternalVar = 0;
  return val;
}

char *
GetPlcTarget(void)
{
  // PLC Engine not used
  return NULL;
}

t_var TbVar[MAX_VAR] = {

  // COAP
  VAR_INIT(w_coapaddr_l, "::1"),
  VAR_INIT(w_coapport_l, "5689"),
  VAR_INIT(w_coapaddr_r, "::1"),
  VAR_INIT(w_coapport_r, "5683"),
  
  // Telnet
  VAR_INIT(s_telnetkey, "123"),
  VAR_INIT(s_telnetport, "2005"),
  
  // Dia Tools
  VAR_FUNCTION(w_hostname, GetHostName),
  VAR_FUNCTION(w_reqid, GetReqId),
  VAR_FUNCTION(w_gwcontact, GetGwContact),
  VAR_FUNCTION(w_date, GetDate),
  VAR_FUNCTION(w_time, GetTime),
  VAR_FUNCTION(w_drvcontact, GetDrvContact),