Campbell-scientific Java PakBus Software Development Kit Manuel d'utilisateur Page 12

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 30
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 11
Java PakBus® Software Development Kit
3. Using Transactions
Up to this point, we have built the network and added stations to it. These
steps, by themselves, still do not lead to much functionality except that we can
now create transaction objects and addthese to the stations. The transactions
will perform most of the work for our application. Lets extend the above
example to retrieve table definitions and other meta-data from the datalogger:
import com.campbellsci.pakbus.*;
import java.net.*;
class Example3 implements GetTableDefsClient
{
private Network network;
private Socket socket;
private boolean complete;
private Datalogger my_cr1000;
private Datalogger my_other_cr1000;
public void run() throws Exception
{
// create the connection and the network
socket = new Socket("192.168.4.225",6785);
network = new Network(
(short)4079,
socket.getInputStream(),
socket.getOutputStream());
// create the station
my_cr1000 = new Datalogger((short)1085);
my_other_cr1000 = new Datalogger((short)1084,(short)1085);
network.add_station(my_cr1000);
network.add_station(my_other_cr1000);
my_other_cr1000.set_round_trip_time(10000);
// start getting table definitions
my_cr1000.add_transaction(new GetTableDefsTran(this));
// now drive the network
complete = false;
while(!complete)
{
network.check_state();
Thread.sleep(100);
}
}
public void on_complete(
GetTableDefsTran transaction,
int outcome)
{
if(outcome == GetTableDefsTran.outcome_success)
System.out.println("Got table definitions");
else
System.out.println("Get table defs failed");
}
}
4
Vue de la page 11
1 2 ... 7 8 9 10 11 12 13 14 15 16 17 ... 29 30

Commentaires sur ces manuels

Pas de commentaire