Campbell Scientific Java PakBus Software Development Kit User Manual

Page 19

Advertising
background image

Java PakBus® Software Development Kit

{
if(outcome == GetValuesTran.outcome_success)
System.out.println("Test succeeded: " + values.get_value(0));
else
System.out.println("Test failed: " + outcome);
complete = true;
} // on_complete


public static void main(String[] args)
{
try
{
Example5_5 test = new Example5_5();
test.run(args);
}
catch(Exception e)
{
System.out.println("test failed: " + e);
}
} // main


private void run(String[] args) throws Exception
{
// initialise the connection and the network
socket = new Socket(args[0],Integer.parseInt(args[1]));
network = new Network(
(short)4079,
socket.getInputStream(),
socket.getOutputStream());
network.add_low_level_logger(
new LowLevelFile(
new FileOutputStream("io$jpakbus.log")));
datalogger = new Datalogger(Short.parseShort(args[2]));
network.add_station(datalogger);

// start the transaction
datalogger.add_transaction(
new GetValuesTran(
this,
args[3], // table name
args[4], // column name
(short)1,
GetValuesTran.type_float));

// now drive the network crank
int num_trans = 1;
complete = false;
while(num_trans > 0 && !complete)
{
num_trans = network.check_state();
Thread.sleep(100);
}
} // run


private Socket socket;
private Network network;
private Datalogger datalogger;
private boolean complete;
}

11

Advertising