Campbell-scientific Java PakBus Software Development Kit Bedienungsanleitung Seite 21

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 30
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 20
Java PakBus® Software Development Kit
network.add_station(my_cr1000);
// the file sent will be the source file for this program
my_cr1000.add_transaction(
new SendFileTran(
this,
new FileInputStream("Example.java"),
"USR:Example.java"));
// now drive the network
int active_links = 0;
complete = false;
while(!complete || active_links > 0)
{
active_links = network.check_state();
Thread.sleep(100);
}
}
public boolean on_progress(
SendFileTran transaction,
int bytes_to_send,
int bytes_sent)
{ return true; }
public void on_complete(
SendFileTran transaction,
int outcome) throws Exception
{
if(outcome == SendFileTran.outcome_success)
System.out.println("send file succeeded");
else
System.out.println("send file failed");
complete = true;
}
}
6.2 Receiving a File
A file can be retrieved from one of the datalogger file systems using the
GetFileTran class. This class starts a file receive transaction with the
datalogger and delivers fragments of the file to the application as they are
received using
GetFileClient.on_fragment(com.campbellsci.pakbus.GetFileTran, byte[]).
The following example demonstrates this process:
import com.campbellsci.pakbus.*;
import java.net.*;
import java.io.*;
class Example6_2 implements GetFileClient
{
private Network network;
private Socket socket;
private boolean complete;
private Datalogger my_cr1000;
private OutputStream output;
13
Seitenansicht 20
1 2 ... 16 17 18 19 20 21 22 23 24 25 26 ... 29 30

Kommentare zu diesen Handbüchern

Keine Kommentare