Campbell Scientific Java PakBus Software Development Kit User Manual

Page 23

Advertising
background image

Java PakBus® Software Development Kit

import java.io.IOException;
import com.campbellsci.pakbus.*;

import java.io.*;
import java.net.*;


public class Example6_3
implements SendFileClient, FileControlClient, GetProgStatsClient
{
public Example6_3(
String[] args) throws Exception
{
if(args.length < 4)
throw new Exception("Not enough arguments");
complete = false;
} // constructor


public void on_complete(SendFileTran transaction, int outcome)
throws Exception
{
if(outcome == SendFileTran.outcome_success)
{
datalogger.add_transaction(
new FileControlTran(
this,
FileControlTran.command_stop_delete_compile_power_up,
program_name));
}
else
{
System.out.println("File send failed: " + outcome);
complete = true;
}
} // on_complete


public boolean on_progress(
SendFileTran transaction,
int bytes_to_send,
int bytes_sent)
{
System.out.println("Sent " + bytes_sent + " bytes of " +
bytes_to_send);
return true;
} // on_progress


public void on_complete(
FileControlTran transaction,
int outcome,
int hold_off) throws Exception
{
if(outcome == FileControlTran.outcome_success)
{
// The datalogger is going to reset itself. This
// example is written assuming
// that we are connected directly to the logger with
// TCP. Because of that, we
// need to close the current link to the logger and
// wait for the time period

15

Advertising