- Author
- Dr Terry Barnaby
- Version
- 3.1.0
- Date
- 2022-11-21
Introduction
This documention 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 interface using an RPC type mechanism implemented by BEAM's BOAP RPC system. The BdsApi API makes use of the BEAM Beamlib 'C++' class library for lower level and system independent functionality. The BEAM Beamlib '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 the API description is available in the Beamlib 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 using an efficient binary protocol. The BdsApi is written in a high level interface definition language (IDL). The Beamlib 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 and server programs 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 Beamlib 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 related 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.
This documentation is automatically geneerated from the BDS source code and describes the classes and their member functions. For higher level information on how to use these please consult the BdsDevelopment.pdf document..
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;
}
BOAP data class definitions for: Bds.
BString getString() const
BError & set(int errNo, BString errStr="")
BError setString(const BString dateTime)
This is the Data Access API interface to the BDS system.
Definition BdsC.h:26
BError dataSearch(Selection selection, DataInfo &dataInfo)
Search for data matching the given selection parameters.
Definition BdsC.cc:2347
BError dataFormattedRead(DataHandle dataHandle, BUInt32 number, BArray< BUInt8 > &data)
Read the raw data from the file.
Definition BdsC.cc:3254
BError dataOpen(DataInfo dataInfo, BString mode, BString format, BUInt32 flags, DataHandle &dataHandle)
Open a data file.
Definition BdsC.cc:2812
BError connect(BString user, BString password)
Provides user/password information for secure connection.
Definition BdsC.cc:12
This defines a handle to a sensor data stream/file when opened for read or write.
Definition BdsD.h:690
This class defines information on a set of data.
Definition BdsD.h:643
BArray< BArray< DataChannel > > channels
The Data channels. Each channel can have multiple segments of data.
Definition BdsD.h:652
This class defines an idividual channel for selection.
Definition BdsD.h:500
This class defines a generic Metadata or Sensor data selection.
Definition BdsD.h:517
BTimeStamp endTime
The End Time.
Definition BdsD.h:524
BList< SelectionChannel > channels
The data channels to select.
Definition BdsD.h:525
BTimeStamp startTime
The Start Time.
Definition BdsD.h:523
BError connectService(BString name)
#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;
}
BError dataGetBlock(DataHandle dataHandle, BUInt32 channel, BUInt32 segment, BUInt32 blockNumber, DataBlock &data)
Return a block of data.
Definition BdsC.cc:3158
This class provides the actual Sensor data values contained within a single data block.
Definition BdsD.h:710
BTimeStamp endTime
The End Time.
Definition BdsD.h:648
#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;
}
void next(BIter &i) const
int isEnd(BIter &i) const
void start(BIter &i) const
BError stationGetList(Selection sel, BList< Station > &stations)
Get list of Stations.
Definition BdsC.cc:494
This class defines a seismic station.
Definition BdsD.h:189
BString description
Description.
Definition BdsD.h:198
BString name
The name.
Definition BdsD.h:195
BString type
The Station type. Set to "array" or "station".
Definition BdsD.h:197
BList< ArrayChannel > channels
List of channels if an Array.
Definition BdsD.h:199
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();