System information
D-1
Appendix D. JAVA Example Code
import java.io.*;
import java.util.*;
import java.net.*;
/**
* A simple PakBus command line application
* that demonstrates how to communicate with a CR200 datalogger
*
* @author Campbell Scientific, Inc.
* @version 1.0 Preliminary
*/
class PBExample{
public static final long nsecPerSec = 1000000000L;
public static final long nsecPerMSec = 1000000L;
public static final long msecPerSec = 1000L;
public static Socket socket;
/**
* Reads the input from datalogger
*/
public static BufferedInputStream in_stream;
/**
* Stores the packet once read in off the stream
*/
public static Packet in_packet;
/**
* Writes the output to the datalogger
*/
public static DataOutputStream out_stream;
/**
* Buffer for the outgoing packet
*/
public static Packet out_packet;
public static int GetCommandStatus;
public static String NameList;
public static int file_offset;
public static int tabledefloop;
public static int sendseconds;
public static GregorianCalendar DLtime; //Store the last Datalogger time
public static GregorianCalendar PCtime; //Store the last PC time
public static short setclockcnt;
public static String Model;
public static String Version;
public static String TableDefStr;
public static short dest_address = 4095; // start with broadcast address
public static short source_address = 4092;