package charly.demo;

import charly.client.*;
import charly.server.devices.ChGpibTimeOutException;

/** A very simple class for sending a string to a GPIB-device.
  * You can view the <a href="doc-files/ChSimpleGpib.java.html">source here</a>.
  */
public class ChSimpleGpib
{
  public static void main(String args[])
    throws Exception
  {
    System.out.println("usage: ChSimpleGpib [TCP/IP-address]");
    ChConnect conn=new ChConnect(args.length==0?"localhost":args[0]);
    ChTask task=new ChTask("Simple Gpib");
    ChGpibClient gpib=new ChGpibClient(conn);
    
    
    task.addResource(conn, gpib.getResourceName(7));
        // resource: Gpib-device nr: 7 on server: conn
        
        
    task.start(true);
    
    gpib.setTask(task);
    
    try
    {
      gpib.send(7,":AUT"); // sending ":AUT" to the device nr 7
    } catch(ChGpibTimeOutException e)
    {
      System.out.println("Device timed out!");
    }
    
    task.stop();
    System.out.println("bye");
    System.exit(0); // This is not really necessary, but because it 
      // takes some time until that the system detects that there is 
      // no activity any more on the RMI-system, this method call
      // shortens the waiting time immensely
  }
}