\chapter{Bds\+Api}
\hypertarget{index}{}\label{index}\index{BdsApi@{BdsApi}}
\begin{DoxyAuthor}{Author}
Dr Terry Barnaby 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
3.\+1.\+0 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
2022-\/11-\/21
\end{DoxyDate}
\hypertarget{index_Introduction}{}\doxysection{\texorpdfstring{Introduction}{Introduction}}\label{index_Introduction}
This documention provides detailed reference information for the BEAM Bds\+Api 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 \textquotesingle{}C++\textquotesingle{} 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\textquotesingle{}s BOAP RPC system. The Bds\+Api API makes use of the BEAM Beamlib \textquotesingle{}C++\textquotesingle{} class library for lower level and system independent functionality. The BEAM Beamlib \textquotesingle{}C++\textquotesingle{} class library provides a small set of low level \textquotesingle{}C++\textquotesingle{} classes for strings, lists and system interface functions. It also implements the BOAP RPC mechanism used to implement the Bds\+Api. 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 \textquotesingle{}C++\textquotesingle{} 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 Bds\+Api. An overall API description and programming manual is provided separately in\+: \href{../../BdsDevelopment.pdf}{\texttt{ Bds\+Development.\+pdf}}\hypertarget{index_Overview}{}\doxysection{\texorpdfstring{Overview}{Overview}}\label{index_Overview}
The Bds\+Api 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 Bds\+Api is written in a high level interface definition language (IDL). The Beamlib bidl tool generates the client and server side \textquotesingle{}C++\textquotesingle{} interface and implementation files for the API. These are then provided as a set of \textquotesingle{}C++\textquotesingle{} 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 Bds\+Server interface objects. The interface objects are\+:


\begin{DoxyEnumerate}
\item {\bfseries{\doxylink{classBds_1_1DataAccess}{Bds\+::\+Data\+Access}}} BDS Data API\+: This provides read only access to the data and meta data. It is used by the Auto\+DRM email and Web systems as well as for user and general program access to the data. 
\item {\bfseries{\doxylink{classBds_1_1DataAddAccess}{Bds\+::\+Data\+Add\+Access}}} BDS Data\+Add 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. 
\item {\bfseries{\doxylink{classBds_1_1AdminAccess}{Bds\+::\+Admin\+Access}}} BDS Admin API\+: This provides full read/write access to the data and meta data as well as administrative configuration information. 
\end{DoxyEnumerate}

These access API\textquotesingle{}s are related in that the Data\+Add\+Access API is a subset of the Admin\+Access API and the Data\+Access API is a subset of the Data\+Add\+Access API. These API access objects should be consulted to view the functionality provided by the BDS system API\textquotesingle{}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 \href{../../BdsDevelopment.pdf}{\texttt{ Bds\+Development.\+pdf}} document..\hypertarget{index_ExamplesCpp}{}\doxysection{\texorpdfstring{C++ Examples}{C++ Examples}}\label{index_ExamplesCpp}
There are some examples of client applications using the Bds\+Api in the {\bfseries{bds\+Examples}} directory of the source code. Some simple Data Access client examples are listed below\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/*******************************************************************************}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ BdsDataClient1.cpp\ \ BDS\ API\ example\ code\ for\ a\ Data\ Client}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ T.Barnaby,\ \ BEAM\ Ltd,\ \ \ 2008-\/09-\/02}}
\DoxyCodeLine{\textcolor{comment}{\ *******************************************************************************}}
\DoxyCodeLine{\textcolor{comment}{\ *}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ This\ is\ a\ very\ basic\ example\ of\ using\ the\ BdsApi\ from\ a\ data\ access}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ perspective.\ It\ is\ designed\ to\ give\ an\ overview\ of\ using\ the\ API.}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ This\ program\ gets\ data\ in\ the\ BKNAS\ format.}}
\DoxyCodeLine{\textcolor{comment}{\ */}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{BdsD_8h}{BdsD.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{BdsC_8h}{BdsC.h}}>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{using\ namespace\ }\mbox{\hyperlink{namespaceBds}{Bds}};}
\DoxyCodeLine{\textcolor{keyword}{using\ namespace\ }std;}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//\ Function\ to\ read\ some\ data}}
\DoxyCodeLine{BError\ bdsTest(\mbox{\hyperlink{classBds_1_1DataAccess}{DataAccess}}\&\ bds)\{}
\DoxyCodeLine{\ \ \ \ BError\ \ \ \ \ \ \ \ \ \ \ \ err;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1Selection}{Selection}}\ \ \ \ \ \ selection;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataInfo}{DataInfo}}\ \ \ \ \ \ \ \ dataInfo;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataHandle}{DataHandle}}\ \ \ \ \ \ \ \ dataHandle;}
\DoxyCodeLine{\ \ \ \ BArray<BUInt8>\ \ \ \ \ \ \ \ data;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Set\ up\ selection}}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifndef\ ZAP}}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a68a873c546777e835a28be6f2fd9588b}{startTime}}.setString(\textcolor{stringliteral}{"{}2002-\/01-\/01T00:00:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a0f4897d22d413665d315c1f8b8fc0210}{endTime}}.setString(\textcolor{stringliteral}{"{}2002-\/01-\/01T00:01:00.000000"{}});}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a68a873c546777e835a28be6f2fd9588b}{startTime}}.setString(\textcolor{stringliteral}{"{}2002-\/01-\/01T23:59:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a0f4897d22d413665d315c1f8b8fc0210}{endTime}}.setString(\textcolor{stringliteral}{"{}2002-\/01-\/02T00:01:00.000000"{}});}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a10e8033fb7bf95c2697d733b73990b5f}{channels}}.append(\mbox{\hyperlink{classBds_1_1SelectionChannel}{SelectionChannel}}(\textcolor{stringliteral}{"{}BN"{}},\ \textcolor{stringliteral}{"{}EKA"{}},\ \textcolor{stringliteral}{"{}"{}},\ \textcolor{stringliteral}{"{}"{}}));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Get\ list\ of\ all\ data\ available\ for\ the\ selection\ \ \ \ \ }}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_a2e3e933da461362b5b08d69a1e3985c0}{dataSearch}}(selection,\ dataInfo))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ BString(\textcolor{stringliteral}{"{}Error:\ Searching\ for\ data:\ "{}})\ +\ err.getString());}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ We\ should\ now\ choose\ which\ set\ of\ data\ we\ would\ like\ from\ the\ list,\ here\ we\ just}}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ choose\ the\ first\ entry\ and\ get\ the\ data\ in\ appropriate\ format.}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!dataInfo.\mbox{\hyperlink{classBds_1_1DataInfo_a2bd64c7855bb2875964020c5a6e1ec16}{channels}}.size())}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ \textcolor{stringliteral}{"{}No\ data\ found"{}});}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_a7548f30476ccc555c0f7741c692d6d9a}{dataOpen}}(dataInfo,\ \textcolor{stringliteral}{"{}r"{}},\ \textcolor{stringliteral}{"{}IMS"{}},\ 0,\ dataHandle))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{while}(1)\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_a2ffd8100efecd568cd572fcfb3d00590}{dataFormattedRead}}(dataHandle,\ 1024,\ data))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(data.size()\ ==\ 0)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \ \ \ \ fwrite(data.data(),\ 1,\ data.size(),\ stdout);}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}**\ argv)\{}
\DoxyCodeLine{\ \ \ \ BError\ \ \ \ \ \ \ \ \ \ \ \ err;}
\DoxyCodeLine{\ \ \ \ BString\ \ \ \ \ \ \ \ \ \ hostName;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataAccess}{DataAccess}}\ \ \ \ \ \ \ \ bds;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ hostName\ =\ getenv(\textcolor{stringliteral}{"{}BDS\_HOST"{}});}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(hostName\ ==\ \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{\ \ \ \ \ \ \ \ hostName\ =\ \textcolor{stringliteral}{"{}localhost"{}};}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(argc\ ==\ 2)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ hostName\ =\ argv[1];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Connect\ to\ the\ DataAccess\ service}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.connectService(BString(\textcolor{stringliteral}{"{}//"{}})\ +\ hostName\ +\ \textcolor{stringliteral}{"{}/bdsDataAccess"{}}))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ cerr\ <<\ \textcolor{stringliteral}{"{}Error:\ "{}}\ <<\ err.getString()\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Connect\ to\ service}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!err)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_aeba7cdc6ca55abfd24838b9c7bc49a1f}{connect}}(\textcolor{stringliteral}{"{}test"{}},\ \textcolor{stringliteral}{"{}beam00"{}});}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Run\ a\ normal\ data\ gathering\ as\ a\ normal\ data\ access\ client\ would.}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!err)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ err\ =\ bdsTest(bds);}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err)\{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \ \ \ \ cerr\ <<\ \textcolor{stringliteral}{"{}Error:\ "{}}\ <<\ err.getString()\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}



\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/*******************************************************************************}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ BdsDataClient2.cpp\ \ BDS\ API\ example\ code\ for\ a\ Data\ Client}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ T.Barnaby,\ \ BEAM\ Ltd,\ \ \ 2008-\/09-\/02}}
\DoxyCodeLine{\textcolor{comment}{\ *******************************************************************************}}
\DoxyCodeLine{\textcolor{comment}{\ *}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ This\ is\ a\ very\ basic\ example\ of\ using\ the\ BdsApi\ from\ a\ data\ access}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ perspective.\ It\ is\ designed\ to\ give\ an\ overview\ of\ using\ the\ API.}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ This\ program\ gets\ data\ in\ raw\ format\ and\ outputs\ it\ in\ ASCII.}}
\DoxyCodeLine{\textcolor{comment}{\ */}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <iomanip>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{BdsD_8h}{BdsD.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{BdsC_8h}{BdsC.h}}>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{using\ namespace\ }\mbox{\hyperlink{namespaceBds}{Bds}};}
\DoxyCodeLine{\textcolor{keyword}{using\ namespace\ }std;}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//\ Function\ to\ read\ some\ data}}
\DoxyCodeLine{BError\ bdsTest(\mbox{\hyperlink{classBds_1_1DataAccess}{DataAccess}}\&\ bds)\{}
\DoxyCodeLine{\ \ \ \ BError\ \ \ \ \ \ \ \ \ \ \ \ err;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1Selection}{Selection}}\ \ \ \ \ \ selection;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataInfo}{DataInfo}}\ \ \ \ \ \ \ \ dataInfo;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataHandle}{DataHandle}}\ \ \ \ \ \ \ \ dataHandle;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataBlock}{DataBlock}}\ \ \ \ \ \ data;}
\DoxyCodeLine{\ \ \ \ BUInt32\ \ \ \ \ \ \ \ \ \ blockNumber\ =\ 0;}
\DoxyCodeLine{\ \ \ \ BUInt\ \ \ \ \ \ \ \ \ \ c;}
\DoxyCodeLine{\ \ \ \ BUInt\ \ \ \ \ \ \ \ \ \ s;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Set\ up\ selection}}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a68a873c546777e835a28be6f2fd9588b}{startTime}}.setString(\textcolor{stringliteral}{"{}2008-\/01-\/03T00:00:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a0f4897d22d413665d315c1f8b8fc0210}{endTime}}.setString(\textcolor{stringliteral}{"{}2008-\/01-\/03T00:01:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a10e8033fb7bf95c2697d733b73990b5f}{channels}}.append(\mbox{\hyperlink{classBds_1_1SelectionChannel}{SelectionChannel}}(\textcolor{stringliteral}{"{}BN"{}},\ \textcolor{stringliteral}{"{}EKA"{}},\ \textcolor{stringliteral}{"{}"{}},\ \textcolor{stringliteral}{"{}"{}}));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Get\ list\ of\ all\ data\ available\ for\ the\ selection\ \ \ \ \ }}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_a2e3e933da461362b5b08d69a1e3985c0}{dataSearch}}(selection,\ dataInfo))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ BString(\textcolor{stringliteral}{"{}Error:\ Searching\ for\ data:\ "{}})\ +\ err.getString());}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ We\ should\ now\ choose\ which\ set\ of\ data\ we\ would\ like\ from\ the\ list,\ here\ we\ just}}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ choose\ the\ first\ entry\ and\ get\ the\ data\ in\ appropriate\ format.}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!dataInfo.\mbox{\hyperlink{classBds_1_1DataInfo_a2bd64c7855bb2875964020c5a6e1ec16}{channels}}.size())}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ \textcolor{stringliteral}{"{}No\ data\ found"{}});}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_a7548f30476ccc555c0f7741c692d6d9a}{dataOpen}}(dataInfo,\ \textcolor{stringliteral}{"{}r"{}},\ \textcolor{stringliteral}{"{}API"{}},\ 0,\ dataHandle))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{while}(1)\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_acfdbac249a6d956de814306334707eb1}{dataGetBlock}}(dataHandle,\ 0,\ 0,\ blockNumber,\ data))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(data.startTime\ >=\ dataInfo.\mbox{\hyperlink{classBds_1_1DataInfo_a3f55ac464f9a576807f8dca6c24373c0}{endTime}})}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}(s\ =\ 0;\ s\ <\ data.channelData[0].size();\ s++)\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}(c\ =\ 0;\ c\ <\ data.channelData.size();\ c++)\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(c\ !=\ 0)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{},\ "{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::cout\ <<\ setw(8)\ <<\ data.channelData[c][s];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ blockNumber++;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}**\ argv)\{}
\DoxyCodeLine{\ \ \ \ BError\ \ \ \ \ \ \ \ \ \ \ \ err;}
\DoxyCodeLine{\ \ \ \ BString\ \ \ \ \ \ \ \ \ \ hostName;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataAccess}{DataAccess}}\ \ \ \ \ \ \ \ bds;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ hostName\ =\ getenv(\textcolor{stringliteral}{"{}BDS\_HOST"{}});}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(hostName\ ==\ \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{\ \ \ \ \ \ \ \ hostName\ =\ \textcolor{stringliteral}{"{}localhost"{}};}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(argc\ ==\ 2)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ hostName\ =\ argv[1];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Connect\ to\ the\ DataAccess\ service}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.connectService(BString(\textcolor{stringliteral}{"{}//"{}})\ +\ hostName\ +\ \textcolor{stringliteral}{"{}/bdsDataAccess"{}}))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ cerr\ <<\ \textcolor{stringliteral}{"{}Error:\ "{}}\ <<\ err.getString()\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Connect\ to\ service}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!err)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_aeba7cdc6ca55abfd24838b9c7bc49a1f}{connect}}(\textcolor{stringliteral}{"{}test"{}},\ \textcolor{stringliteral}{"{}beam00"{}});}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Run\ a\ normal\ data\ gathering\ as\ a\ normal\ data\ access\ client\ would.}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!err)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ err\ =\ bdsTest(bds);}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err)\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ cerr\ <<\ \textcolor{stringliteral}{"{}Error:\ "{}}\ <<\ err.getString()\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}



\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/*******************************************************************************}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ BdsMetaData1.cpp\ \ \ \ BDS\ API\ example\ code\ for\ a\ Meta\ Data\ Client}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ T.Barnaby,\ \ BEAM\ Ltd,\ \ \ 2009-\/07-\/01}}
\DoxyCodeLine{\textcolor{comment}{\ *******************************************************************************}}
\DoxyCodeLine{\textcolor{comment}{\ *}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ This\ is\ a\ very\ basic\ example\ of\ using\ the\ BdsApi\ from\ a\ meta\ data\ access}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ perspective.\ It\ is\ designed\ to\ give\ an\ overview\ of\ using\ the\ API.}}
\DoxyCodeLine{\textcolor{comment}{\ *\ \ This\ program\ gets\ information\ on\ the\ data\ channels.}}
\DoxyCodeLine{\textcolor{comment}{\ */}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <iomanip>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{BdsD_8h}{BdsD.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{BdsC_8h}{BdsC.h}}>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{using\ namespace\ }\mbox{\hyperlink{namespaceBds}{Bds}};}
\DoxyCodeLine{\textcolor{keyword}{using\ namespace\ }std;}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//\ Function\ to\ read\ some\ data}}
\DoxyCodeLine{BError\ bdsTest1(\mbox{\hyperlink{classBds_1_1DataAccess}{DataAccess}}\&\ bds)\{}
\DoxyCodeLine{\ \ \ \ BError\ \ \ \ \ \ \ \ \ \ \ \ err;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1Selection}{Selection}}\ \ \ \ \ \ selection;}
\DoxyCodeLine{\ \ \ \ BIter\ \ \ \ \ \ \ \ \ \ i;}
\DoxyCodeLine{\ \ \ \ BUInt\ \ \ \ \ \ \ \ \ \ n;}
\DoxyCodeLine{\ \ \ \ BList<Station>\ \ \ \ \ \ \ \ stations;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Set\ up\ selection}}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a68a873c546777e835a28be6f2fd9588b}{startTime}}.setString(\textcolor{stringliteral}{"{}2008-\/01-\/03T00:00:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a0f4897d22d413665d315c1f8b8fc0210}{endTime}}.setString(\textcolor{stringliteral}{"{}2008-\/01-\/03T00:01:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.\mbox{\hyperlink{classBds_1_1Selection_a10e8033fb7bf95c2697d733b73990b5f}{channels}}.append(\mbox{\hyperlink{classBds_1_1SelectionChannel}{SelectionChannel}}(\textcolor{stringliteral}{"{}BN"{}},\ \textcolor{stringliteral}{"{}EKA"{}},\ \textcolor{stringliteral}{"{}"{}},\ \textcolor{stringliteral}{"{}"{}}));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Get\ list\ of\ stations\ available}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_a2305edeac73d9cfca0fac383f519d777}{stationGetList}}(selection,\ stations))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ BString(\textcolor{stringliteral}{"{}Error:\ Getting\ stations:\ "{}})\ +\ err.getString());}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ This\ displays\ some\ of\ the\ information\ available\ \ }}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{for}(stations.start(i),\ n\ =\ 0;\ !stations.isEnd(i);\ stations.next(i),\ n++)\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{classBds_1_1Station}{Station}}\&\ c\ =\ stations[i];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \ \ \ \ cout\ <<\ n\ <<\ \textcolor{stringliteral}{"{}:\ Station:\ "{}}\ <<\ c.\mbox{\hyperlink{classBds_1_1Station_a21b5ba350106def25f7e1a272f8b0055}{name}}\ <<\ \textcolor{stringliteral}{"{}\ Type:\ "{}}\ <<\ c.\mbox{\hyperlink{classBds_1_1Station_ad524054a8465a06330b686591966990c}{type}}\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ cout\ <<\ \textcolor{stringliteral}{"{}\ \ \ \ "{}}\ <<\ \textcolor{stringliteral}{"{}Description:\ "{}}\ <<\ c.\mbox{\hyperlink{classBds_1_1Station_a06c8e8b39d905a50c934db8464e83895}{description}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ <<\ \textcolor{stringliteral}{"{}\ Number\ of\ stations\ "{}}\ <<\ c.\mbox{\hyperlink{classBds_1_1Station_aeb2cc968a198e1a713d7cd172f9ef109}{channels}}.number()\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}**\ argv)\{}
\DoxyCodeLine{\ \ \ \ BError\ \ \ \ \ \ \ \ \ \ \ \ err;}
\DoxyCodeLine{\ \ \ \ BString\ \ \ \ \ \ \ \ \ \ hostName;}
\DoxyCodeLine{\ \ \ \ \mbox{\hyperlink{classBds_1_1DataAccess}{DataAccess}}\ \ \ \ \ \ \ \ bds;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ hostName\ =\ getenv(\textcolor{stringliteral}{"{}BDS\_HOST"{}});}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(hostName\ ==\ \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{\ \ \ \ \ \ \ \ hostName\ =\ \textcolor{stringliteral}{"{}localhost"{}};}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(argc\ ==\ 2)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ hostName\ =\ argv[1];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Connect\ to\ the\ DataAccess\ service}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err\ =\ bds.connectService(BString(\textcolor{stringliteral}{"{}//"{}})\ +\ hostName\ +\ \textcolor{stringliteral}{"{}/bdsDataAccess"{}}))\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ cerr\ <<\ \textcolor{stringliteral}{"{}Error:\ "{}}\ <<\ err.getString()\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Connect\ to\ service}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!err)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ err\ =\ bds.\mbox{\hyperlink{classBds_1_1DataAccess_aeba7cdc6ca55abfd24838b9c7bc49a1f}{connect}}(\textcolor{stringliteral}{"{}test"{}},\ \textcolor{stringliteral}{"{}beam00"{}});}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Run\ a\ normal\ data\ gathering\ as\ a\ normal\ data\ access\ client\ would.}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(!err)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ err\ =\ bdsTest1(bds);}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(err)\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ cerr\ <<\ \textcolor{stringliteral}{"{}Error:\ "{}}\ <<\ err.getString()\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
\hypertarget{index_ExamplesPython}{}\doxysection{\texorpdfstring{Python Examples}{Python Examples}}\label{index_ExamplesPython}
There are some examples of client applications using the Bds\+Api in the {\bfseries{bds\+Examples}} directory of the source code. Some simple Data Access client examples are listed below\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{\#!/usr/bin/python}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{import}\ sys}
\DoxyCodeLine{\textcolor{keyword}{import}\ getopt}
\DoxyCodeLine{\textcolor{keyword}{from}\ bdslib\ \textcolor{keyword}{import}\ *}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{\#\ Function\ to\ read\ some\ data}}
\DoxyCodeLine{\textcolor{keyword}{def\ }bdsTest(bds):}
\DoxyCodeLine{\ \ \ \ err\ \ \ \ \ =\ BError();}
\DoxyCodeLine{\ \ \ \ selection\ \ \ =\ Selection();}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Set\ up\ selection}}
\DoxyCodeLine{\ \ \ \ selection.startTime.setString(\textcolor{stringliteral}{"{}2008-\/01-\/01T00:00:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.endTime.setString(\textcolor{stringliteral}{"{}2008-\/01-\/01T00:01:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ print(\textcolor{stringliteral}{"{}Selection:\ StartTime:"{}},\ selection.startTime.getString(),\ \textcolor{stringliteral}{"{}EndTime:"{}},\ selection.endTime.getString());}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ selection.channels.append(SelectionChannel(\textcolor{stringliteral}{"{}TT"{}},\ \textcolor{stringliteral}{"{}TSB01"{}},\ \textcolor{stringliteral}{"{}"{}},\ \textcolor{stringliteral}{"{}"{}}));}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ bdsDumpSelection(selection);}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Get\ list\ of\ all\ data\ available\ for\ the\ selection\ \ \ \ \ \ }}
\DoxyCodeLine{\ \ \ \ (err,\ dataInfo)\ =\ bds.dataSearch(selection);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ BString(\textcolor{stringliteral}{"{}Error:\ Searching\ for\ data:\ "{}})\ +\ err.getString());}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ We\ should\ now\ choose\ which\ set\ of\ data\ we\ would\ like\ from\ the\ list,\ here\ we\ just}}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ choose\ all\ of\ the\ data.}}
\DoxyCodeLine{\ \ \ \ s\ =\ dataInfo.channels.size();}
\DoxyCodeLine{\ \ \ \ if(s\ ==\ 0):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ \textcolor{stringliteral}{"{}No\ data\ found"{}});}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ bdsDumpDataInfo(dataInfo);}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Open\ the\ data\ file\ for\ reading\ in\ IMS\ format}}
\DoxyCodeLine{\ \ \ \ (err,\ dataHandle)\ =\ bds.dataOpen(dataInfo,\ \textcolor{stringliteral}{"{}r"{}},\ \textcolor{stringliteral}{"{}IMS"{}},\ 0);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Read\ the\ formatted\ data}}
\DoxyCodeLine{\ \ \ \ while(1):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{\#\ print\ "{}Loop"{};}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ (err,\ data)\ =\ bds.dataFormattedRead(dataHandle,\ 1024);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ if(data.number()\ ==\ 0):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ s\ =\ \textcolor{stringliteral}{"{}"{}}.join(chr(x)\ \textcolor{keywordflow}{for}\ x\ \textcolor{keywordflow}{in}\ data);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(s);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{def\ }main():}
\DoxyCodeLine{\ \ \ \ hostName\ =\ \textcolor{stringliteral}{"{}localhost"{}};}
\DoxyCodeLine{\ \ \ \ bds\ =\ DataAccess();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Connect\ to\ the\ DataAccess\ service}}
\DoxyCodeLine{\ \ \ \ err\ =\ bds.connectService(\textcolor{stringliteral}{"{}//"{}}\ +\ hostName\ +\ \textcolor{stringliteral}{"{}/bdsDataAccess"{}});}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Connect\ to\ service}}
\DoxyCodeLine{\ \ \ \ err\ =\ bds.connect(\textcolor{stringliteral}{"{}test"{}},\ \textcolor{stringliteral}{"{}beam00"{}});}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ (err,\ version,\ name)\ =\ bds.getVersion();}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ print(\textcolor{stringliteral}{"{}Version:"{}}\ ,\ version,\ \textcolor{stringliteral}{"{}Name:"{}},\ name);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ err\ =\ bdsTest(bds);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:"{}},\ err.getErrorNo(),\ err.getString());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordflow}{if}\ \_\_name\_\_\ ==\ \textcolor{stringliteral}{"{}\_\_main\_\_"{}}:}
\DoxyCodeLine{\ \ \ \ main();}

\end{DoxyCodeInclude}



\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{\#!/usr/bin/python}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{import}\ sys}
\DoxyCodeLine{\textcolor{keyword}{import}\ getopt}
\DoxyCodeLine{\textcolor{keyword}{from}\ bdslib\ \textcolor{keyword}{import}\ *}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{\#\ Function\ to\ read\ some\ data}}
\DoxyCodeLine{\textcolor{keyword}{def\ }bdsTest(bds):}
\DoxyCodeLine{\ \ \ \ err\ =\ BError();}
\DoxyCodeLine{\ \ \ \ selection\ =\ Selection();}
\DoxyCodeLine{\ \ \ \ dataInfo\ =\ DataInfo();}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Set\ up\ selection}}
\DoxyCodeLine{\ \ \ \ selection.startTime.setString(\textcolor{stringliteral}{"{}2008-\/01-\/01T00:00:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.endTime.setString(\textcolor{stringliteral}{"{}2008-\/01-\/01T00:01:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.channels.append(SelectionChannel(\textcolor{stringliteral}{"{}TT"{}},\ \textcolor{stringliteral}{"{}TSB01"{}},\ \textcolor{stringliteral}{"{}"{}},\ \textcolor{stringliteral}{"{}"{}}));}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ bdsDumpSelection(selection);}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Get\ list\ of\ all\ data\ available\ for\ the\ selection\ \ \ \ \ \ }}
\DoxyCodeLine{\ \ \ \ (err,\ dataInfo)\ =\ bds.dataSearch(selection);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ BString(\textcolor{stringliteral}{"{}Error:\ Searching\ for\ data:\ "{}})\ +\ err.getString());}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ We\ should\ now\ choose\ which\ set\ of\ data\ we\ would\ like\ from\ the\ list,\ here\ we\ just}}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ choose\ the\ first\ entry\ and\ get\ the\ data\ in\ appropriate\ format.}}
\DoxyCodeLine{\ \ \ \ s\ =\ dataInfo.channels.size();}
\DoxyCodeLine{\ \ \ \ if(s\ ==\ 0):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ \textcolor{stringliteral}{"{}No\ data\ found"{}});}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ bdsDumpDataInfo(dataInfo);}}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ (err,\ dataHandle)\ =\ bds.dataOpen(dataInfo,\ \textcolor{stringliteral}{"{}r"{}},\ \textcolor{stringliteral}{"{}API"{}},\ 0);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ blockNumber\ =\ 0;}
\DoxyCodeLine{\ \ \ \ while(1):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{\#\ print\ "{}Loop"{};}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ (err,\ data)\ =\ bds.dataGetBlock(dataHandle,\ 0,\ 1,\ blockNumber);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{\#\ print("{}DataChannels:"{},\ data.channelData.size());}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Data0:"{}},\ data.channelData[0][0]);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ blockNumber\ +=\ 1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{def\ }main():}
\DoxyCodeLine{\ \ \ \ hostName\ =\ \textcolor{stringliteral}{"{}localhost"{}};}
\DoxyCodeLine{\ \ \ \ bds\ =\ DataAccess();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Connect\ to\ the\ DataAccess\ service}}
\DoxyCodeLine{\ \ \ \ err\ =\ bds.connectService(\textcolor{stringliteral}{"{}//"{}}\ +\ hostName\ +\ \textcolor{stringliteral}{"{}/bdsDataAccess"{}});}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Connect\ to\ service}}
\DoxyCodeLine{\ \ \ \ err\ =\ bds.connect(\textcolor{stringliteral}{"{}test"{}},\ \textcolor{stringliteral}{"{}beam00"{}});}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ (err,\ version,\ name)\ =\ bds.getVersion();}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ print(\textcolor{stringliteral}{"{}Version:"{}}\ ,\ version,\ \textcolor{stringliteral}{"{}Name:"{}},\ name);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ err\ =\ bdsTest(bds);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:"{}},\ err.getErrorNo(),\ err.getString());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordflow}{if}\ \_\_name\_\_\ ==\ \textcolor{stringliteral}{"{}\_\_main\_\_"{}}:}
\DoxyCodeLine{\ \ \ \ main();}

\end{DoxyCodeInclude}



\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{\#!/usr/bin/python}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{import}\ sys}
\DoxyCodeLine{\textcolor{keyword}{import}\ getopt}
\DoxyCodeLine{\textcolor{keyword}{from}\ bdslib\ \textcolor{keyword}{import}\ *}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{\#\ Function\ to\ read\ display\ info\ on\ Station}}
\DoxyCodeLine{\textcolor{keyword}{def\ }bdsTest(bds):}
\DoxyCodeLine{\ \ \ \ err\ =\ BError();}
\DoxyCodeLine{\ \ \ \ selection\ =\ Selection();}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Set\ up\ selection}}
\DoxyCodeLine{\ \ \ \ selection.startTime.setString(\textcolor{stringliteral}{"{}2008-\/01-\/01T00:00:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.endTime.setString(\textcolor{stringliteral}{"{}2008-\/01-\/01T00:01:00.000000"{}});}
\DoxyCodeLine{\ \ \ \ selection.channels.append(SelectionChannel(\textcolor{stringliteral}{"{}TT"{}},\ \textcolor{stringliteral}{"{}TSA"{}},\ \textcolor{stringliteral}{"{}"{}},\ \textcolor{stringliteral}{"{}"{}}));}
\DoxyCodeLine{\textcolor{comment}{\#\ \ \ bdsDumpSelection(selection);}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Get\ list\ of\ stations\ available}}
\DoxyCodeLine{\ \ \ \ (err,\ stations)\ =\ bds.stationGetList(selection);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ err.set(1,\ \textcolor{stringliteral}{"{}Error:\ Getting\ stations:\ "{}}\ +\ err.getString());}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ This\ displays\ some\ of\ the\ information\ available}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{for}\ s\ \textcolor{keywordflow}{in}\ stations:}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Station:\ "{}}\ +\ s.name\ +\ \textcolor{stringliteral}{"{}\ Type:\ "{}}\ +\ s.type);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}\ \ \ \ "{}}\ +\ \textcolor{stringliteral}{"{}Description:\ "{}}\ +\ s.description\ +\ \textcolor{stringliteral}{"{}\ Number\ of\ station/channels\ "{}}\ +\ str(s.channels.number()));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ err;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{def\ }main():}
\DoxyCodeLine{\ \ \ \ hostName\ =\ \textcolor{stringliteral}{"{}localhost"{}};}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Create\ DataAccess\ object\ to\ connect\ to\ BDS\ Server}}
\DoxyCodeLine{\ \ \ \ bds\ =\ DataAccess();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Connect\ to\ the\ DataAccess\ service}}
\DoxyCodeLine{\ \ \ \ err\ =\ bds.connectService(\textcolor{stringliteral}{"{}//"{}}\ +\ hostName\ +\ \textcolor{stringliteral}{"{}/bdsDataAccess"{}});}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{\#\ Connect\ to\ service}}
\DoxyCodeLine{\ \ \ \ err\ =\ bds.connect(\textcolor{stringliteral}{"{}test"{}},\ \textcolor{stringliteral}{"{}beam00"{}});}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ }
\DoxyCodeLine{\ \ \ \ (err,\ version,\ name)\ =\ bds.getVersion();}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:\ "{}}\ +\ str(err)\ +\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ print(\textcolor{stringliteral}{"{}Version:"{}}\ ,\ version,\ \textcolor{stringliteral}{"{}Name:"{}},\ name);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ err\ =\ bdsTest(bds);}
\DoxyCodeLine{\ \ \ \ if(err):}
\DoxyCodeLine{\ \ \ \ \ \ \ \ print(\textcolor{stringliteral}{"{}Error:"{}},\ err.getErrorNo(),\ err.getString());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ }
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordflow}{if}\ \_\_name\_\_\ ==\ \textcolor{stringliteral}{"{}\_\_main\_\_"{}}:}
\DoxyCodeLine{\ \ \ \ main();}

\end{DoxyCodeInclude}
 