- Author
- Dr Terry Barnaby
- Version
- 2.2.2
- Date
- 2020-09-24
Introduction
This document provides detailed reference information for the BEAM BdsApi software API of the Blacknest Data System (BDS). The API provides the ability to store and access seismic sensor data and metadata as well as administer the BDS system. The API is an object orientated API implemented in 'C++' with a number of object classes. It also has bindings for other languages which include Python and PHP.
The API operates over a network type interface using an RPC type mechanism implemented by BEAM's BOAP RPC system. The BdsApi API makes use of the BEAM 'C++' class library for lower level and system independent functionality. The BEAM 'C++' class library provides a small set of low level 'C++' classes for strings, lists and system interface functions. It also implements the BOAP RPC mechanism used to implement the BdsApi. There is some brief information on the BEAM class library later on in this page and a full API definition is available in the beam-lib documentation.
The BDS Python API is built on top of the standard BDS 'C++' API using the SWIG API generator. Thus all of the standard BDS C++ API documentation applies however there are some differences due to the language facility and syntax differences. The core difference is when returning data from functions. With C++ you can return data by passing references or pointers to objects. In Python this is not generally possible and so objects are returned at the left hand side of functions instead.
This is the reference documentation for the BdsApi. An overall API description and programming manual is provided separately in: BdsDevelopment.pdf
Overview
The BdsApi has been developed using the BOAP (BEAM Object Access Protocol). This provides a simple but powerful Object Orientated RPC mechanism. The BdsApi is written in a high level interface definition language (IDL). The bidl tool generates the client and server side 'C++' interface and implementation files for the API. These are then provided as a set of 'C++' header files and a binary library file for the clients to link to. The BOAP system employs a simple BOAP name server process that provides a translation between object names and network IPAddress/Socket numbers. The BOAP name server runs on the main BDS Server host. More information on the BOAP system can be found in the beam-lib documentation.
The object orientated BDS API implements a number of data storage classes and three BdsServer interface objects. The interface objects are:
-
Bds::DataAccess BDS Data API: This provides read only access to the data and meta data. It is used by the AutoDRM email and Web systems as well as for user and general program access to the data.
-
Bds::DataAddAccess BDS DataAdd API: This provides read and restricted write access to enable the adding of data to the system. It will not allow deletions of data to be performed. It is designed to be used by manual and automatic data adding programs.
-
Bds::AdminAccess BDS Admin API: This provides full read/write access to the data and meta data as well as administrative configuration information.
These access API's are released in that the DataAddAccess API is a subset of the AdminAccess API and the DataAccess API is a subset of the DataAddAccess API. These API access objects should be consulted to view the functionality provided by the BDS system API's.
C++ Examples
There are some examples of client applications using the BdsApi in the bdsExamples directory of the source code. Some simple Data Access client examples are listed below:
#include <iostream>
#include <stdio.h>
using namespace std;
#ifndef ZAP
#else
#endif
}
return err.
set(1,
"No data found");
if(err = bds.
dataOpen(dataInfo,
"r",
"IMS", 0, dataHandle)){
return err;
}
while(1){
return err;
}
break;
fwrite(
data.data(), 1,
data.size(), stdout);
}
return err;
}
int main(int argc, char** argv){
hostName = getenv("BDS_HOST");
if(hostName == "")
hostName = "localhost";
if(argc == 2)
hostName = argv[1];
cerr <<
"Error: " << err.
getString() <<
"\n";
return 1;
}
if(!err)
err = bds.
connect(
"test",
"beam00");
if(!err)
err = bdsTest(bds);
if(err){
cerr <<
"Error: " << err.
getString() <<
"\n";
return 1;
}
return 0;
}
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;
}
return err.
set(1,
"No data found");
if(err = bds.
dataOpen(dataInfo,
"r",
"API", 0, dataHandle)){
return err;
}
while(1){
if(err = bds.
dataGetBlock(dataHandle, 0, 0, blockNumber, data)){
return err;
}
break;
for(s = 0; s <
data.channelData[0].size(); s++){
for(c = 0; c <
data.channelData.size(); c++){
if(c != 0)
std::cout << ", ";
std::cout << setw(8) <<
data.channelData[c][s];
}
std::cout << "\n";
}
blockNumber++;
}
return err;
}
int main(int argc, char** argv){
hostName = getenv("BDS_HOST");
if(hostName == "")
hostName = "localhost";
if(argc == 2)
hostName = argv[1];
cerr <<
"Error: " << err.
getString() <<
"\n";
return 1;
}
if(!err)
err = bds.
connect(
"test",
"beam00");
if(!err)
err = bdsTest(bds);
if(err){
cerr <<
"Error: " << err.
getString() <<
"\n";
return 1;
}
return 0;
}
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;
}
for(stations.
start(i), n = 0; !stations.
isEnd(i); stations.
next(i), n++){
cout << n <<
": Station: " << c.
name <<
" Type: " << c.
type <<
"\n";
<<
" Number of stations " << c.
channels.number() <<
"\n";
}
return err;
}
int main(int argc, char** argv){
hostName = getenv("BDS_HOST");
if(hostName == "")
hostName = "localhost";
if(argc == 2)
hostName = argv[1];
cerr <<
"Error: " << err.
getString() <<
"\n";
return 1;
}
if(!err)
err = bds.
connect(
"test",
"beam00");
if(!err)
err = bdsTest1(bds);
if(err){
cerr <<
"Error: " << err.
getString() <<
"\n";
return 1;
}
return 0;
}
Python Examples
There are some examples of client applications using the BdsApi in the bdsExamples directory of the source code. Some simple Data Access client examples are listed below:
import sys
import getopt
from bdslib import *
def bdsTest(bds):
selection = Selection();
selection.startTime.setString("2008-01-01T00:00:00.000000");
selection.endTime.setString("2008-01-01T00:01:00.000000");
print("Selection: StartTime:", selection.startTime.getString(), "EndTime:", selection.endTime.getString());
selection.channels.append(SelectionChannel("TT", "TSB01", "", ""));
(err, dataInfo) = bds.dataSearch(selection);
if(err):
return err.set(1,
BString(
"Error: Searching for data: ") + err.getString());
s = dataInfo.channels.size();
if(s == 0):
return err.set(1, "No data found");
(err, dataHandle) = bds.dataOpen(dataInfo, "r", "IMS", 0);
if(err):
return err;
while(1):
(err, data) = bds.dataFormattedRead(dataHandle, 1024);
if(err):
return err;
if(data.number() == 0):
break;
s = "".join(chr(x) for x in data);
print(s);
return err;
def main():
hostName = "localhost";
bds = DataAccess();
err = bds.connectService("//" + hostName + "/bdsDataAccess");
if(err):
print("Error: " + str(err) + "\n");
return 1;
err = bds.connect("test", "beam00");
if(err):
print("Error: " + str(err) + "\n");
return 1;
(err, version, name) = bds.getVersion();
if(err):
print("Error: " + str(err) + "\n");
return 1;
print("Version:" , version, "Name:", name);
err = bdsTest(bds);
if(err):
print("Error:", err.getErrorNo(), err.getString());
return 1;
return 0;
if __name__ == "__main__":
main();
import sys
import getopt
from bdslib import *
def bdsTest(bds):
selection = Selection();
dataInfo = DataInfo();
selection.startTime.setString("2008-01-01T00:00:00.000000");
selection.endTime.setString("2008-01-01T00:01:00.000000");
selection.channels.append(SelectionChannel("TT", "TSB01", "", ""));
(err, dataInfo) = bds.dataSearch(selection);
if(err):
return err.set(1,
BString(
"Error: Searching for data: ") + err.getString());
s = dataInfo.channels.size();
if(s == 0):
return err.set(1, "No data found");
(err, dataHandle) = bds.dataOpen(dataInfo, "r", "API", 0);
if(err):
return err;
blockNumber = 0;
while(1):
(err, data) = bds.dataGetBlock(dataHandle, 0, 1, blockNumber);
if(err):
return err;
print("Data0:", data.channelData[0][0]);
blockNumber += 1;
return err;
def main():
hostName = "localhost";
bds = DataAccess();
err = bds.connectService("//" + hostName + "/bdsDataAccess");
if(err):
print("Error: " + str(err) + "\n");
return 1;
err = bds.connect("test", "beam00");
if(err):
print("Error: " + str(err) + "\n");
return 1;
(err, version, name) = bds.getVersion();
if(err):
print("Error: " + str(err) + "\n");
return 1;
print("Version:" , version, "Name:", name);
err = bdsTest(bds);
if(err):
print("Error:", err.getErrorNo(), err.getString());
return 1;
return 0;
if __name__ == "__main__":
main();
import sys
import getopt
from bdslib import *
def bdsTest(bds):
selection = Selection();
selection.startTime.setString("2008-01-01T00:00:00.000000");
selection.endTime.setString("2008-01-01T00:01:00.000000");
selection.channels.append(SelectionChannel("TT", "TSA", "", ""));
(err, stations) = bds.stationGetList(selection);
if(err):
return err.set(1, "Error: Getting stations: " + err.getString());
for s in stations:
print("Station: " + s.name + " Type: " + s.type);
print(" " + "Description: " + s.description + " Number of station/channels " + str(s.channels.number()));
return err;
def main():
hostName = "localhost";
bds = DataAccess();
err = bds.connectService("//" + hostName + "/bdsDataAccess");
if(err):
print("Error: " + str(err) + "\n");
return 1;
err = bds.connect("test", "beam00");
if(err):
print("Error: " + str(err) + "\n");
return 1;
(err, version, name) = bds.getVersion();
if(err):
print("Error: " + str(err) + "\n");
return 1;
print("Version:" , version, "Name:", name);
err = bdsTest(bds);
if(err):
print("Error:", err.getErrorNo(), err.getString());
return 1;
return 0;
if __name__ == "__main__":
main();