]> git.uio.no Git - u/mrichter/AliRoot.git/blob - SHUTTLE/DCSClient/AliDCSClient.h
4719b0e89a4a61d7e17d8bd0e1195a220db0ac36
[u/mrichter/AliRoot.git] / SHUTTLE / DCSClient / AliDCSClient.h
1 #ifndef ALI_DCS_CLIENT_H
2 #define ALI_DCS_CLIENT_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 //
10 // This class represents the AliDCSClient.
11 // The client used for data retrieval from DCS server.
12 // For more info see AliDCSClient.cxx
13 //
14
15 #include "AliDCSMessage.h"
16
17 class TObjArray;
18 class TSocket;
19 class TMap;
20 class TCollection;
21
22 class AliDCSClient: public TObject {
23 public:
24
25         enum {
26                 fgkBadState=-1,              // Bad state
27                 fgkInvalidParameter = -2,    // Invalid parameter
28                 fgkTimeout = -3,             // Timeout
29                 fgkBadMessage = -4,          // Bad message
30                 fgkCommError = -5,           // Communication error
31                 fgkServerError = -6          // Server error
32         };
33         
34 ////    friend class AliShuttle;
35
36         AliDCSClient(const char* host, Int_t port, UInt_t timeout = 5000,
37                         Int_t retries = 5, Int_t multiSplit = 100);
38         virtual ~AliDCSClient();
39
40
41         Int_t GetDPValues(const char* dpName, UInt_t startTime, UInt_t endTime,
42                                 TObjArray* result);
43
44         Int_t GetAliasValues(const char* alias, UInt_t startTime,
45                                 UInt_t endTime, TObjArray* result);
46
47         TMap* GetDPValues(const TSeqCollection* dpList, UInt_t startTime, UInt_t endTime, Int_t startIndex = 0, Int_t endIndex = -1);
48
49         TMap* GetAliasValues(const TSeqCollection* aliasList, UInt_t startTime, UInt_t endTime, Int_t startIndex = 0, Int_t endIndex = -1);
50
51         AliDCSMessage::ErrorCode GetServerErrorCode() const
52                 { return fServerErrorCode;}
53
54         Int_t GetResultErrorCode() const {return fResultErrorCode;}
55         const TString& GetServerError() const {return fServerError;}
56
57
58         Bool_t IsConnected();
59
60         void Close();
61
62
63         static const char* GetErrorString(Int_t code);
64
65 private:
66         static const char* fgkBadStateString;           // Bad state string
67         static const char* fgkInvalidParameterString;   // Invalid parameter string
68         static const char* fgkTimeoutString;            // Timeout string
69         static const char* fgkBadMessageString;         // Bad message string
70         static const char* fgkCommErrorString;          // Communication error string
71         static const char* fgkServerErrorString;        // Server error string
72
73         TSocket* fSocket;       // Pointer to the TCP socket client
74         TString fHost;          // server host
75         Int_t   fPort;          // server port
76         UInt_t fTimeout;        // timeout parameter
77         Int_t fRetries;         // number of retries
78         Int_t   fMultiSplit; // number of datapoints that are queried at a time in a multi dp request, if set to 1 forces single requests 
79         AliDCSMessage::ErrorCode fServerErrorCode;      // server error code
80         TString fServerError;   // server error string
81         
82         Int_t fResultErrorCode; // result error code
83
84         Bool_t Connect();
85
86         Int_t SendBuffer(const char* buffer, Int_t size);
87
88         Int_t ReceiveBuffer(char* buffer, Int_t size);
89
90         Int_t SendMessage(AliDCSMessage& message);
91
92         Int_t ReceiveMessage(AliDCSMessage& message);
93
94         Int_t GetValues(AliDCSMessage::RequestType requestType,
95                 const char* requestString, UInt_t startTime, UInt_t endTime,
96                 TObjArray* result);
97
98         TMap* GetValues(AliDCSMessage::RequestType requestType,
99                 const TSeqCollection* list, UInt_t startTime, UInt_t endTime,
100                 Int_t startIndex, Int_t endIndex);
101
102         Int_t ReceiveValueSet(TObjArray* result);
103
104         AliDCSClient(const AliDCSClient& other);                // not implemented
105         AliDCSClient& operator= (const AliDCSClient& other);    // not implemented
106
107         ClassDef(AliDCSClient, 0);
108 };
109
110 #endif