Beispiel #1
0
  /**
   * Default constructor, should be invoked by any class that extends {@link Equipment}. Finds the
   * device on GPIB and clears its internal state (cf. {@link #clear}).
   *
   * @param name Name of the device, as given in /proj/async/cad/linux/src/gpib/nienet/ibconf
   */
  public Equipment(String name) {
    this.name = name;
    if (isDisabled()) {
      Logger.logInit("  GPIB device " + name + " not enabled for this test.");
      return;
    }
    if (Infrastructure.gpibControllers == null) {
      Infrastructure.fatal(
          "You must set Infrastructure.gpibControllers " + "before initializing any GPIB devices");
    }

    ud = GPIB.findDevice(name);
    Logger.logInit("  Initializing GPIB device: " + name + ", ud: " + ud);

    int board = this.ask(CONTROLLER_ID_NUMBER);
    for (int ind = 0; ind < Infrastructure.gpibControllers.length; ind++) {
      if (board == Infrastructure.gpibControllers[ind]) {
        // clear();
        return;
      }
    }
    Infrastructure.fatal(
        "Device "
            + name
            + " is on controller number "
            + board
            + ", which is not in Infrastructure.gpibControllers");
  }
Beispiel #2
0
 /**
  * send write message to receiver
  *
  * @param data data string
  */
 public void write(String data) {
   if (isDisabled()) {
     return;
   }
   if (ud < 0) {
     System.out.println("can't write to uninitized device:" + this);
   }
   GPIB.ibWrite(ud, name, data);
 }
Beispiel #3
0
 /**
  * Receive up to <code>length</code> bytes from the device.
  *
  * @param length length of the data to read
  * @return data string which is read
  */
 public String read(int length) {
   if (isDisabled()) {
     return "";
   }
   if (ud < 0) {
     System.out.println("can't read from uninitized device:" + this);
   }
   String result = GPIB.ibRead(ud, name, length).trim();
   // System.out.println(id + ": " + result + ". " + result.length());
   if (result.length() == 0) {
     Infrastructure.nonfatal("Empty string from id " + ud);
   }
   return result.trim();
 }
Beispiel #4
0
 /**
  * Send GPIB interface messages to the device. The commands are listed in Appendix A of <a
  * href="../../../../../manuals/NI-488.2M_sw.pdf">NI-488.2M Software Reference Manual </a>
  *
  * @param command string containing characters to send over GPIB
  */
 public void command(String command) {
   if (isDisabled()) {
     return;
   }
   GPIB.ibCmd(ud, name, command);
 }
Beispiel #5
0
 /**
  * Clear internal or device functions of the device. Among other things, this should clear device
  * GPIB error conditions and allow its use again. For some devices, it appears that the clear does
  * not work if it is too soon after the error occurs.
  */
 public void clear() {
   if (isDisabled()) {
     return;
   }
   GPIB.ibClr(ud, name);
 }
Beispiel #6
0
 /**
  * Return information about the GPIB software configuration parameters. Valid <code>option</code>
  * values can be found in the <tt>ibconfig</tt> and <tt>ibask</tt> constants section in <a
  * href="../../../../../ugpib.h"><tt>ugpib.h</tt> </a>. Currently {@link
  * #CONTROLLER_ID_NUMBER}&nbsp;is provided for convenience in specifying <code>option</code>.
  *
  * @param option constant identifying which configuration parameter to return
  * @return value of the requested configuration parameter
  */
 public int ask(int option) {
   if (isDisabled()) {
     return 0;
   }
   return GPIB.ibAsk(ud, name, option);
 }