use orb ; use Datascope ;
In this package, when the corresponding c routine returns a complex structure (e.g., orbsources(3), orbclients(3), unstuffPkt(3)), the perl interface routine returns one or more objects. These objects have methods which return various values from the c struct.
$orb = orbopen ( "igpprt:anza", "r&" ) ;
orbclose($orb) ;
$n = orbselect ( $orb, "AZ_.*|CI_.*" ) ; $n = orbreject ( $orb, "/db/detection" ) ;
The default is to return all packets, stash or not. If stashselect is "STASH_ONLY", only stash packets are returned from future orbreaps.$n = stashselect ( $orb, "STASH_ONLY" ) ;
$pktid = orbseek ($orb, "ORBOLDEST") ; $pktid = orbseek ($orb, 15327 ) ;
$pktid = orbposition ( $orb, "-0:10" ) ; $pktid = orbposition ( $orb, "23:52 2001-163" ) ; $pktid = orbposition ( $orb, "oldest" ) ;
$pktid = orbtell($orb) ;
$pktid = orbafter($orb, $time) ;
$version = orbping($orb) ;
$result = orbwait($orb, "orb2db", 300, 0 ) ;
my ($oldest, $newest, $maxpktid, $range, @clients) = orblag($orb, "orb2orb", "" ) ;
foreach (@clients) {
my($lag, $thread, $pktid, $who, $what) = split (' ', $_, 5) ;
}
($pktid, $srcname, $time, $packet, $nbytes) =
orbget($orb, "ORBNEWEST") ;
($time, $packet, $nbytes) = orbget($orb, "TA_Z14A/MGENC/M40") ;
($pktid, $srcname, $time, $packet, $nbytes) = orbreap($orb) ;
($pktid, $srcname, $time, $packet, $nbytes ) =
orbreap_timeout($orb, 1) ;
orbput($orb, $srcname, $time, $packet, $nbytes) ;
$stat = orbstat($orb) ;
printf "At %s, the orbserver had %d clients and %d sources\n",
strtime($stat->when), $stat->nclients, $stat->nsources ;
($when, @clients) = orbclients($orb) ;
foreach (@clients) {
printf "%-8s %-12s %s\n", $_->who, $_->host, $_->what ;
}
($when, @sources) = orbsources($orb) ;
foreach $source (@sources) {
printf "%-15s %8d %6.0f %s\n",
$source->srcname, $source->npkts, $source->nbytes/1024.,
strtdelta($when-$source->slatest_time) ;
}
| PKT_DUMP | 1 | hex dump |
| PKT_UNSTUFF | 2 | unstuff, print all data samples |
| PKT_NOSAMPLES | 3 | unstuff, print no data samples |
| PKT_TERSE | 4 | just show the header information |
| PKT_PEEK | 5 | show first 10 samples of waveform packets |
| result kind of packet | |
| Pkt_wf waveform packet | |
| Pkt_st status packet | |
| Pkt_db database row | |
| Pkt_pf parameter file | |
| Pkt_cn control messages | |
| Pkt_rw arbitrary binary data, wrapped in orb packet | |
| Pkt_ch arbitrary character string | |
| Pkt_tp test packet | |
| Pkt_stash | stash packet |
($result, $pkt) = unstuffPkt($srcname, $time, $packet, $nbytes) ;
($net, $sta, $chan, $loc, $suffix, $subcode) = $pkt->parts() ;
($type, $desc) = $pkt->PacketType() ;
for ( $i=0 ; $i<$pkt->nchannels ; $i++ ) {
$achan = $pkt->channels($i) ;
printf "%s_%s_%s_%s",
$achan->net, $achan->sta, $achan->chan, $achan->loc ;
printf " %s", strtime($achan->time) ;
printf " %12.6f", $achan->samprate ;
printf " %8d\n", $achan->nsamp ;
@data = $achan->data ;
for ( $i=0 ; $i<10 ; $i++ ) {
printf "\n %2d ", $i if $i % 5 == 0 ;
printf " %10d", $data[$i] ;
}
printf "\n" ;
}
$pf = $pkt->pf ;
if ( defined $pf ) {
$ref = pfget($pf, "" ) ;
%pf = %$ref ;
foreach ( sort keys %pf ) {
printf "%-15s %s\n", $_, $pf{$_} ;
}
}
@db = $pkt->db ;
if ( $db[0] >= 0 ) {
printf "pkt->db = ( @db )\n" ;
$schema = dbquery (@db, "dbSCHEMA_NAME" ) ;
$table = dbquery (@db, "dbTABLE_NAME" ) ;
printf "Record from table $schema:$table\n" ;
@fields = dbquery (@db, "dbTABLE_FIELDS") ;
foreach $field (@fields) {
$value = dbgetv(@db, $field) ;
printf " %-15s %s\n", $field, $value ;
}
}
$dfile = $pkt->dfile() ;
if ( defined $dfile ) {
printf "\npkt->dfile is\n'$dfile'\n\n" ;
}
$version = $pkt->version ;
if ( defined $version ) {
printf "pkt->version is '$version'\n" ;
}
$string=$pkt->string ;
if ( defined $string ) {
printf "pkt->string is '$string'\n" ;
}
orb(3) unstuffPkt(3) stuffPkt(3) join_srcname(3)
There is no stuffPkt interface.