System information

Appendix D. JAVA Example Code
D-8
/**
* GetClock will create the packet to get a clock value from
* the DL. Thecode that is commented out is another way of
* doing the sigNullifier but it does not take into account
* the quote chars.
*/
public static void GetClock()
{
CreateHeader();
out_packet.message_type = 0x17;
out_packet.tran_no = 0x17;
out_packet.add_short((short)0); // security code
out_packet.add_int(sendseconds);
out_packet.add_int(0);
}
/**
* Sets the datalogger clock to the PC time
*/
static void SetClock()
{
sendseconds = 0;
GetClock(); //checks the DL clock before adjustments
//returns seconds in 1990
SendPb();
}
static private Vector table_defs = new Vector();
/**
* GetTable will create the packet for getting data from
* the specified table
*/
public static void GetTable(String table_name, int num_records)
{
if(table_defs.size() == 0)
{
System.out.println("GetTable - need table definitions to poll");
}
else
{
//locate the table in the list of table definitions
TableDef table = null;
for(int i = 0;
table == null && i < table_defs.size();
++i)
{
table = (TableDef)table_defs.elementAt(i);
if(table.table_name.equalsIgnoreCase(table_name))
{
System.out.println(
"Found table " + table_name + " at tableno = " +
table.table_no);
break;
}
else
table = null;
}