5 get values: an alternative to data collection, Get values: an alternative to data collection – Campbell Scientific Java PakBus Software Development Kit User Manual

Page 18

Advertising
background image

Java PakBus® Software Development Kit

complete = true;
}
}


public boolean on_records(
DataCollectTran transaction,
List<Record> records)
{
for(Record record: records)
{
System.out.print(record.get_time_stamp().format("\"%y-
%m-%d %H:%M:%S%x\","));
System.out.print(record.get_record_no());
for(ValueBase value: record.get_values())
System.out.print("," + value.format());
System.out.println("");
}
return true; // a value of false would cause the transaction to abort
}


public void on_complete(
DataCollectTran transaction,
int outcome) throws Exception
{
if(outcome == DataCollectTran.outcome_success)
System.out.println("Data collection succeeded");
else
System.out.println("data collection failed");
complete = true;
}
}

5.5 Get Values: An Alternative to Data Collection

If the application needs only to read values from a single field in the datalogger

table, it can do so using the

GetValuesTran class. This collection method

differs from data collection in that the client specifies the data type in which it

wants to receive values, only one field can be polled (if that field is an array,

multiple values from that field can be returned), time stamp and record number

information are not returned by the datalogger, and table definitions are not

required.

The following example illustrates the use of the get values transaction:

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


public class Example5_5 implements GetValuesClient
{
public Example5_5()
{ }


public void on_complete(
GetValuesTran transaction,
int outcome,
Record values) throws Exception

10

Advertising