Campbell Scientific Java PakBus Software Development Kit User Manual

Page 27

Advertising
background image

Java PakBus® Software Development Kit

{
int available = System.in.available();
while(available > 0)
{
int bytes_read = System.in.read(in_buff);
if(bytes_read > 0)
io_tran.send_data(in_buff, bytes_read);
available = System.in.available();
}
active_links_count = network.check_state();
Thread.sleep(100);
}
}
catch(Exception e)
{
System.out.println("An exception interrupted the
transaction:");
System.out.println(e);
}
} // run


public void on_bytes_received(UserIoTran transaction,
byte[] buff, int buff_len) throws IOException
{
String temp = new String(buff,0,buff_len);
System.out.print(temp);
} // on_bytes_received


public void on_failure(UserIoTran transaction, int reason)
throws IOException
{
System.out.println("User I/O failed: " + reason);
io_tran = null;
complete = true;
} // on_failure


public void on_started(UserIoTran transaction) throws
IOException
{
System.out.println("User I/O Started. Type ^C to quit");
} // on_started


/**
* reference to the PakBus network
*/
private Network network;


/**
* holds the socket used to communicate with the datalogger
*/
private Socket socket;


/**
* set to true when the application has been completed
*/
boolean complete;

19

Advertising