\begin{DoxyAuthor}{Author}
Dr Terry Barnaby 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
2.\+0.\+11 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
2013-\/12-\/02
\end{DoxyDate}
\hypertarget{index_Introduction}{}\section{Introduction}\label{index_Introduction}
This document covers the B\+E\+AM Bds\+Api software A\+PI for the Blacknest Data System. This A\+PI provides the ability to access data and administer the B\+DS system. The A\+PI is an object orientated A\+PI implemented in \textquotesingle{}C++\textquotesingle{} with a number of object classes. The A\+PI operates over a network type interface using an R\+PC type mechanism.

The Bds\+Api A\+PI makes use of the B\+E\+AM \textquotesingle{}C++\textquotesingle{} class library. The B\+E\+AM \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 B\+O\+AP R\+PC mechanism used to implement the Bds\+Api. There is some brief information on the B\+E\+AM class library later on in this page and a full A\+PI definition is available in the lib\+Beam documentation.\hypertarget{index_Overview}{}\section{Overview}\label{index_Overview}
Generally users of the system are only concerned with the Data\+Access A\+PI.

The Bds\+Api has been developed using the B\+O\+AP (B\+E\+AM Object Access Protocol). This provides a simple but powerful Object Orientated R\+PC mechanism. The Bds\+Api is written in a high level interface definition language (I\+DL). The bidl tool generates the client and server side \textquotesingle{}C++\textquotesingle{} interface and implementation files for the A\+PI. These are then provided as a set of \textquotesingle{}C++\textquotesingle{} header files and a binary library file for the clients to link to. The B\+O\+AP system employs a simple B\+O\+AP name server process that provides a translation between object names and I\+P\+Address/\+Socket numbers. The B\+O\+AP name server runs on the B\+DS Controller. More information on the B\+O\+AP system can be found in the lib\+Beam documentation.

T\+HE B\+DS A\+PI implements a number of data storage classes and three interface objects. The interface objects are\+:


\begin{DoxyEnumerate}
\item {\bfseries{\mbox{\hyperlink{classBds_1_1DataAccess}{Bds\+::\+Data\+Access}}}} B\+DS Data A\+PI\+: This will provide read only access to the data and meta data. It will be used by the Auto\+D\+RM email and Web systems as well as for program access to the data. 
\item {\bfseries{\mbox{\hyperlink{classBds_1_1DataAddAccess}{Bds\+::\+Data\+Add\+Access}}}} B\+DS Data\+Add A\+PI\+: This will provide 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{\mbox{\hyperlink{classBds_1_1AdminAccess}{Bds\+::\+Admin\+Access}}}} B\+DS Admin A\+PI\+: This will provide full read/write access to the data and meta data as well as administrative configuration information. 
\end{DoxyEnumerate}\hypertarget{index_BdsApi}{}\section{Examples}\label{index_BdsApi}
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_aad417ebc88a67fddd345de207ade93c8}{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_aad417ebc88a67fddd345de207ade93c8}{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}{ *      BdsDataClient3.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 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 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_1ChannelInfos}{ChannelInfos}}                channelInfos;}
\DoxyCodeLine{        BIter                      i;}
\DoxyCodeLine{        BUInt                      c;}
\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_a2ea31468eea6a13bc41c2ff9f67749fc}{dataGetChannelInfo}}(dataInfo, channelInfos))\{}
\DoxyCodeLine{                \textcolor{keywordflow}{return} err;}
\DoxyCodeLine{        \}}
\DoxyCodeLine{}
\DoxyCodeLine{        \textcolor{comment}{// This displays some of the information available      }}
\DoxyCodeLine{        \textcolor{keywordflow}{for}(c = 0; c < channelInfos.\mbox{\hyperlink{classBds_1_1ChannelInfos_a4ff07d4783ee3b84e768a6a0a5ceb691}{channels}}.size(); c++)\{}
\DoxyCodeLine{                \mbox{\hyperlink{classBds_1_1ChannelInfo}{ChannelInfo}}\& ci = channelInfos.\mbox{\hyperlink{classBds_1_1ChannelInfos_a4ff07d4783ee3b84e768a6a0a5ceb691}{channels}}[c][0];}
\DoxyCodeLine{                }
\DoxyCodeLine{                cout << (c + 1) << \textcolor{stringliteral}{": Station: "} << ci.\mbox{\hyperlink{classBds_1_1ChannelInfo_a8154d14941f80a63289e9d1c5cf2ac25}{station}}.\mbox{\hyperlink{classBds_1_1Station_a21b5ba350106def25f7e1a272f8b0055}{name}} << \textcolor{stringliteral}{" Channel: "} << ci.\mbox{\hyperlink{classBds_1_1ChannelInfo_afac7018ba9939cb98211db68000a7201}{channel}}.\mbox{\hyperlink{classBds_1_1Channel_ad1e5bedf1958d3964753b2155e57c712}{channel}} << \textcolor{stringliteral}{"\(\backslash\)n"};}
\DoxyCodeLine{                cout << \textcolor{stringliteral}{"    "} << \textcolor{stringliteral}{"Calibration: "} << ci.\mbox{\hyperlink{classBds_1_1ChannelInfo_a972e02215fb0266f73cae62b56867146}{calibration}}.\mbox{\hyperlink{classBds_1_1Calibration_a6fcbe89412006c086c1c14c18090ab86}{calibrationFactor}} << \textcolor{stringliteral}{" Frequency: "} << ci.\mbox{\hyperlink{classBds_1_1ChannelInfo_a972e02215fb0266f73cae62b56867146}{calibration}}.\mbox{\hyperlink{classBds_1_1Calibration_a932992bb89864de15725c2296c1ed544}{calibrationFrequency}} <<}
\DoxyCodeLine{                        \textcolor{stringliteral}{" Units: "} << ci.\mbox{\hyperlink{classBds_1_1ChannelInfo_a972e02215fb0266f73cae62b56867146}{calibration}}.\mbox{\hyperlink{classBds_1_1Calibration_a8fa937a268d2e5c6157ed4f800360378}{calibrationUnits}} << \textcolor{stringliteral}{"\(\backslash\)n"};}
\DoxyCodeLine{                cout << \textcolor{stringliteral}{"    "} << \textcolor{stringliteral}{"Instrument: "} << ci.\mbox{\hyperlink{classBds_1_1ChannelInfo_a42640e650198020c7eb971df736e884e}{digitiser}}.\mbox{\hyperlink{classBds_1_1Digitiser_a8d7986a3025aec5ebf6b47a932f54d84}{name}} << \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_aad417ebc88a67fddd345de207ade93c8}{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}
 