The PDS object is a class wrapper around the Nimbus::API PDS functions. Reference the PDS.pm module for the functions included.
use Nimbus::PDS;
my $PDS = Nimbus::PDS->new();
$PDS->put("name","robot_name",PDS_PCH);
my ($RC,$RES) = nimNamedRequest("/DOMAIN/HUB-NAME/ROBOT-NAME/hub","getrobots",$PDS->data);
if($RC == NIME_OK) {
my $ROBOTS_PDS = Nimbus::PDS->new($RES);
for( my $count = 0; my $_T = $ROBOTS_PDS->getTable("robotlist",PDS_PDS,$count); $count++) {
# Do action here...
}
}
Constant | Type |
---|---|
PDS_PCH | STRING |
PDS_INT | INT |
PDS_PDS | HASH OF PDS |
PDS_F | FLOAT |
We have two constants for PDS error, PDS_ERR
and PDS_ERR_NONE
.
Create a new Nimbus::PDS
my $PDS = Nimbus::PDS->new();
Dump a Nimbus PDS Object
Return the original PDS (C Way) data !
Transform PDS to hash. Useful when a callback return a flat PDS structure
my $PDS = Nimbus::PDS->new();
my ($RC,$RES) = nimNamedRequest("/DOMAIN/HUB-NAME/ROBOT-NAME/controller","get_info",$PDS->data);
if($RC == NIME_OK) {
my $Info = Nimbus::PDS->new($RES)->asHash();
print "$Info->{origin}\n";
}
Put a new value in your PDS
my $PDS = Nimbus::PDS->new();
$PDS->put("A",5,PDS_INT);
$PDS->put("B","hello world",PDS_PCH);
Wrapper of put method for FLOAT Type
Wrapper of put method for INT Type.
Wrapper of put method for STRING Type.
Get a value with the given type
my $A_Value = $PDS->get("A",PDS_INT);
Returns the contents of a table in the PDS.
Adds the key/value pair as a table element in the PDS
This function re‑initializes the PDS object to an empty buffer with initial pointer settings. If you want to reset the get pointer, use the pdsRewind() function. This function deletes data. The buffer is not reallocated.
This function re-initializes the get pointer within the PDS object.
Note: You can put a block of data and perform multiple gets separated with a pdsRewind(pds) call.
Remove a key
$PDS->remove("A");
$PDS->remove("B");