Download Campbell BMP5 System information
Transcript
Appendix D. JAVA Example Code
/**
* GetClock will create the packet to
* the DL. Thecode that is commented
* doing the sigNullifier but it does
* the quote chars.
*/
public static void GetClock()
{
CreateHeader();
out_packet.message_type = 0x17;
out_packet.tran_no = 0x17;
out_packet.add_short((short)0); //
out_packet.add_int(sendseconds);
out_packet.add_int(0);
}
get a clock value from
out is another way of
not take into account
security code
/**
* 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;
}
D-8