/** Shut down communication with the autosampler. */
 public void disconnect() {
   if (m_reader != null) {
     m_reader.quit();
     m_reader.interrupt();
   }
   if (m_sender != null) {
     m_sender.quit();
     m_sender.interrupt();
   }
   if (m_statusPoller != null) {
     m_statusPoller.quit();
     m_statusPoller.interrupt();
   }
   if (m_CryoSocket != null) {
     m_CryoSocket.disconnect();
     m_CryoSocket = null;
   }
 }
 /**
  * Send a command to the cryobay.
  *
  * @param commandMessage The string to send to the cryobay.
  * @return True if there is a connection to the cryobay
  */
 public synchronized boolean sendToCryoBay(String command) {
   if (m_sender == null) {
     m_sender = new Sender(null, m_retries, this);
     m_sender.start();
   }
   if (isConnected()) {
     m_sender.addCommand(command);
     // TODO: (Java 5) Release semaphore here
     // m_sender.interrupt(); // Wake up the run() method
     return true;
   } else {
     return false;
   }
 }
Esempio n. 3
0
 /**
  * @param data Guaranteed to be non null
  * @param offset
  * @param length
  */
 public void send(byte[] data, int offset, int length) throws Exception {
   if (sender != null) {
     byte[] copy = new byte[length];
     System.arraycopy(data, offset, copy, 0, length);
     sender.addToQueue(new Buffer(copy, 0, length));
   } else _send(data, offset, length, true, true);
 }
Esempio n. 4
0
  public void start() {
    if (receiver != null) receiver.stop();
    receiver = new Receiver(server.factory).start();

    if (isSenderUsed()) {
      if (sender != null) sender.stop();
      sender = new Sender(server.factory, server.sendQueueSize()).start();
    }
  }
Esempio n. 5
0
 /**
  * @param data Guaranteed to be non null
  * @param offset
  * @param length
  */
 private void send(byte[] data, int offset, int length) throws Exception {
   if (isSenderUsed()) {
     // we need to copy the byte[] buffer here because the original buffer might get
     // changed meanwhile
     byte[] tmp = new byte[length];
     System.arraycopy(data, offset, tmp, 0, length);
     sender.addToQueue(tmp);
   } else {
     _send(data, offset, length, true);
   }
 }
  /**
   * Does the work for processReply.
   *
   * @see #processReply
   */
  private void processReplyInEventThread(String what, boolean value) {

    //        Messages.postDebug("cryocmd", "CryoSocketControl.processReply("
    //                           + what + ", " + value + ")");

    if (debug) System.out.println("CryoSocketControl.gotReply: " + what);
    if (what != null) {
      m_sender.gotReply(value);
      processStatus(what, value);
    }
  }
Esempio n. 7
0
    private void start(ThreadFactory f) {
      // only start once....
      if (active.compareAndSet(false, true)) {
        connectionPeerReceiver = new ConnectionPeerReceiver(f);
        connectionPeerReceiver.start();

        if (isSenderUsed()) {
          sender = new Sender(f, getSenderQueueSize());
          sender.start();
        }
      }
    }
Esempio n. 8
0
 public void close() throws IOException {
   // can close even if start was never called...
   send_lock.lock();
   try {
     connectionPeerReceiver.stop();
     if (isSenderUsed()) {
       sender.stop();
     }
     Util.close(sock);
     Util.close(out);
     Util.close(in);
   } finally {
     send_lock.unlock();
   }
   mapper.notifyConnectionClosed(peer_addr);
 }
Esempio n. 9
0
 public void close() throws IOException {
   send_lock.lock();
   try {
     Util.close(out, in, sock);
     if (receiver != null) {
       receiver.stop();
       receiver = null;
     }
     if (sender != null) {
       sender.stop();
       sender = null;
     }
   } finally {
     send_lock.unlock();
   }
 }
Esempio n. 10
0
 public boolean isOpen() {
   return isConnected()
       && (!isSenderUsed() || sender.isRunning())
       && (connectionPeerReceiver != null && connectionPeerReceiver.isRunning());
 }
Esempio n. 11
0
 /**
  * Test if substrate is ready to send more packets.
  *
  * @return true if substrate is ready
  */
 public boolean ready() {
   return sndr.ready();
 }
Esempio n. 12
0
 /**
  * Send a packet.
  *
  * @param p is a packet to be sent
  */
 public void send(Packet p) {
   sndr.send(p);
 }
Esempio n. 13
0
 /** Wait for Substrate to stop. */
 public void join() throws Exception {
   sndr.join();
   rcvr.join();
 }
Esempio n. 14
0
 /** Start Substrate running. */
 public void start() {
   sndr.start();
   rcvr.start();
 }