/[PAMELA software]/chewbacca/PamOffLineSW/PacketUser.h
ViewVC logotype

Annotation of /chewbacca/PamOffLineSW/PacketUser.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Thu Dec 18 12:58:37 2008 UTC (15 years, 11 months ago) by mocchiut
Branch: MAIN
Changes since 1.2: +12 -2 lines
File MIME type: text/plain
December 18th version

1 mocchiut 1.1 //============================================================================
2 mocchiut 1.2 // $Id: PacketUser.h,v 1.39 2008-09-05 14:33:48 messineo Exp $
3 mocchiut 1.1 // Description :
4     //============================================================================
5     #ifndef PACKETUSER_H_
6     #define PACKETUSER_H_
7     #include "PamInclude.h"
8     #include <TTimeStamp.h>
9     #include "../event/PacketType.h"
10     #include "EventReader.h"
11    
12     #include "TROOT.h" //ROOT version > 5.14
13    
14     using namespace pamela;
15     using namespace pamela::techmodel;
16    
17     namespace PamOffLineSW
18     {
19    
20     class PacketUser
21     {
22    
23     public:
24     //destructor
25     virtual ~PacketUser();
26     //the interface called by the external module: saves packets in ROOT files using the YODA part
27     void usePKT(char*& headerPkt, char*& pamPkt, long int length, bool isCons, bool isPKTGood, const PacketType* type,
28     unsigned long int counter, unsigned long int obt);
29    
30     //return the instance of the singleton
31     static PacketUser& getInstance();
32     //to be called at the end of the game
33     void FinishLastGroup();
34    
35     private:
36     //the Event Reader handler
37     pamela::techmodel::EventReader* reader;
38     //the Pamela Run handler, one for ech ROOT file created
39     pamela::PamelaRun* pRun;
40     //Constructor
41     PacketUser();
42     //The istance
43     static PacketUser instance;
44     //How many times I found a discontinuity
45     static int numDiscontinity;
46     //How many packets arrived here,
47     static int numPKT;
48     //How many packetS saved in each ROOT files
49     static int numPKTSaved;
50     //Name of the final ROOT file
51     char rootfilename[80];
52     //pkt counter of the first packet of the group
53     unsigned long int pkt_number_init;
54     //pkt OBT of the first packet of the group
55     unsigned long int obt_init;
56     //pkt counter of the last packet of the group
57     unsigned long int pkt_number_last;
58     //pkt OBT of the last packet of the group
59     unsigned long int obt_last;
60     //the first packet's absolute time
61     unsigned long int real_time_init;
62     //the last packet's absolute time
63     unsigned long int real_time_last;
64     //tymesync and OBT informations
65     unsigned long int obt_time_sync;
66     unsigned long int last_time_sync_info;
67 mocchiut 1.3 // (tassa) keep previous value of time_sync
68     unsigned long int obt_time_sync_prevvalue;
69     unsigned long int last_time_sync_info_prevvalue;
70     bool time_is_estimated;
71 mocchiut 1.1 //TimeOffset used to obtain absolute time
72     unsigned long int timeOffset;
73     //part of the ROOT filename used to retrieve timeOffset for special files
74     char nnnn_mmm_ppp[80];
75 mocchiut 1.2 //boot number
76 mocchiut 1.1 unsigned long int boot_number;
77 mocchiut 1.3 unsigned long int boot_number_prevvalue;
78     //(tassa)
79     unsigned int id_to_recover[1000];
80     int id_to_recover_index;
81 mocchiut 1.1 //number of packets with problems( in general CRC problems) detected in EventReader:
82     int bad_pkt_EventReader;
83     //num ber of Calibration packets with problems( in general CRC problems) detected in EventReader:
84     int bad_pkt_CalibReader;
85     //number of good packets that comes from one or more corrupted cadres
86     int bad_pkt;
87    
88     //marco_new:
89     //the ID of the current ROOT file in table Table_ROOT_Good
90     unsigned int my_id;
91    
92 mocchiut 1.2 //number of good Calibration packets in the ROOT files
93     // int good_pkt_Calib;//maybe I will use this in future
94 mocchiut 1.1
95     //the table name in our DB for the ROOT files
96     char* Table_ROOT_Good;
97     //the table name in our DB where I put the ROOT files that have not Real time associated
98     char* Table_ROOT_Bad;
99     //table used to retrieve TimeOffset
100     char* Table_GL_RESURS_OFFSET;
101     //the table name in our DB for MERGING
102     char* Table_ROOT_Merging;
103    
104     //starts a new root file
105     void StartGroup();
106     //set the value of the counter and obt of the first packet of the group
107     void setInit(unsigned long int counter, unsigned long int obt);
108     //finish the old ROOT file
109     void FinishGroup(char * filename);
110     //set the value of the counter and obt of the last packet of the group
111     void setLast(unsigned long int counter, unsigned long int obt);
112     //retrieve OBT_TIME_SYNC and LAST_TIME_SYNC_INFO from packet
113     void setTimeSync(char* packet, long int pktLenght, const PacketType* type);
114     //retrieve boot number
115     void setBootNumber(char* packet, long int pktLenght, const PacketType* type);
116     //set real_time_init and real_time_last
117     void setReal_Time();
118 mocchiut 1.3 //
119     void recover_boot_number();
120    
121 mocchiut 1.1 //retrieve the timeOffset from table=Table_GL_RESURS_OFFSET
122     unsigned long int retrieveTimeOffset(char * table);
123    
124     unsigned int select_maxIDN_DB(char* table_name);
125    
126     //function that saves informations in our DB
127     bool saveROOT_DB(char* table_name, char* folder_name, char* file_name,
128     unsigned long int pkt_number_in, unsigned long int pkt_number_fin,
129     unsigned long int obt_in, unsigned long int obt_fin,
130     unsigned long int oT_sync, unsigned long int lT_sync_info,
131     unsigned long int mtime_init, unsigned long int mtime_last,
132     unsigned long int mboot_num,
133     unsigned long int time_offset,
134     int bad_pkt, int bad_pkt_read, int bad_pkt_CalRead, int num_PKT_Saved,
135 mocchiut 1.3 char* nome_input,bool _time_is_estimated);
136 mocchiut 1.1
137     ///new part merging
138    
139 mocchiut 1.2 //tipi di relazioni che il ROOT file puo' avere con un ROOT gia salvatto in DB
140     //0 =AFTER se c'e' una sovrapposizione temporale parziale, inizia dopo l'inizio di quello associato e finisce dopo la sua fine
141     //1 =BEFORE se c'e' una sovrapposizione temporale parziale, ossia finisce prima della fine di quello associato ma inizia prima
142     //2 =SMALLER se c'e' una sovrapposizione temporale parziale: e' contenuto nel ROOT file associato
143     //3 =BIGGER se c'e' una sovrapposizione temporale parziale: contiene il ROOT file associato
144 mocchiut 1.1 enum type_Rel_ROOT{
145     AFTER, //se inizia dentro e finisce fuori
146     BEFORE, //inizia prima ma finisce dentro
147     SMALLER, //se inizia e finisce dentro
148     BIGGER //se inizia prima e finisce dopo
149     };
150    
151 mocchiut 1.2
152 mocchiut 1.1
153    
154     bool merge_ROOTfiles();
155    
156    
157     bool saveMergeROOT_DB(char* table_name,
158     unsigned int root_id,
159     unsigned long int pkt_number_in, unsigned long int pkt_number_fin,
160     unsigned long int obt_in, unsigned long int obt_fin,
161     unsigned long int mtime_init, unsigned long int mtime_last,
162     unsigned long int mboot_num,
163     double percentage);
164    
165    
166     bool updateMergeROOT_DB(char* table_name,
167     unsigned int root_id,
168     unsigned long int pkt_number_in, unsigned long int pkt_number_fin,
169     unsigned long int obt_in, unsigned long int obt_fin,
170     unsigned long int mtime_init, unsigned long int mtime_last,
171     unsigned long int mboot_num,
172     double bad_perc,
173     unsigned int ID_record, type_Rel_ROOT type_rel);
174    
175 mocchiut 1.2 //search in DB if there are ROOT files in the temporal range of interest and with the given relation
176     TSQLResult* Select_merging(char* table_name, unsigned long int mtime_init, unsigned long int mtime_last, type_Rel_ROOT type_rel);
177 mocchiut 1.1
178     //Lock the tableTobeLocked table or all the tables I know if par=NULL
179     int LockTables(char* tableTobeLocked);
180     //Unlock all the lockedtables
181     int UnLockTables();
182     //Open DB connection and lock table
183     void OpenDBConnection(char* tableTobeLocked);
184     //Close DB connection and UNlock tables
185     void CloseDBConnection();
186    
187     /***************************************************************************************/
188     //UNUSED: return the system time in ms
189     unsigned long long Record_Time();
190     //DBG functions that saves pkt
191     void saveALL_PKT(char* headerPkt, char* pamPkt, long int length, bool append);
192     //function used to save in a file the packet
193     void savePKT_file(char* headerPkt,
194     char* pamPkt,
195     long int length,
196     bool append,
197     char* nomefile);
198    
199     };
200    
201     }
202    
203     #endif /*PACKETUSER_H_*/

  ViewVC Help
Powered by ViewVC 1.1.23