00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "record_types.hpp"
00039 #include "convert.hpp"
00040 #include "messaging.hpp"
00041
00042 string toupper(const string& s)
00043 {
00044 string t = s;
00045 int length = t.length();
00046 for (int i = 0; i < length; i++) t[i] = toupper(t[i]);
00047 return t;
00048 }
00049
00050 void read_ddiiii(string *pS,
00051 double *pR1, double *pR2,
00052 int *pI1, int *pI2, int *pI3, int *pI4)
00053 {
00054 *pR1 = stod( pS->substr( 0, 11 ) );
00055 *pR2 = stod( pS->substr( 11, 11 ) );
00056 *pI1 = stoi( pS->substr( 22, 11 ) );
00057 *pI2 = stoi( pS->substr( 33, 11 ) );
00058 *pI3 = stoi( pS->substr( 44, 11 ) );
00059 *pI4 = stoi( pS->substr( 55, 11 ) );
00060 }
00061
00062 void read_idiiii(string *pS,
00063 int *pI1,
00064 double *pR1,
00065 int *pI2, int *pI3, int *pI4, int *pI5)
00066 {
00067 *pI1 = stoi( pS->substr( 0, 11 ) );
00068 *pR1 = stod( pS->substr( 11, 11 ) );
00069 *pI2 = stoi( pS->substr( 22, 11 ) );
00070 *pI3 = stoi( pS->substr( 33, 11 ) );
00071 *pI4 = stoi( pS->substr( 44, 11 ) );
00072 *pI5 = stoi( pS->substr( 55, 11 ) );
00073 }
00074
00075 void read_iiidiiddd(string *pS,
00076 int *pI1, int *pI2, int *pI3,
00077 double *pR1,
00078 int *pI4, int *pI5,
00079 double *pR2, double *pR3, double *pR4 )
00080 {
00081 *pI1 = stoi( pS->substr( 0, 6 ) );
00082 *pI2 = stoi( pS->substr( 6, 3 ) );
00083 *pI3 = stoi( pS->substr( 9, 3 ) );
00084 *pR1 = stod( pS->substr( 12, 12 ) );
00085 *pI4 = stoi( pS->substr( 24, 7 ) );
00086 *pI5 = stoi( pS->substr( 31, 3 ) );
00087 *pR2 = stod( pS->substr( 34, 12 ) );
00088 *pR3 = stod( pS->substr( 46, 12 ) );
00089 *pR4 = stod( pS->substr( 58, 12 ) );
00090 }
00091
00092 void read_iiiddddd(string *pS,
00093 int *pI1, int *pI2, int *pI3,
00094 double *pR1, double *pR2,
00095 double *pR3, double *pR4, double *pR5 )
00096 {
00097 *pI1 = stoi( pS->substr( 0, 2 ) );
00098 *pI2 = stoi( pS->substr( 2, 3 ) );
00099 *pI3 = stoi( pS->substr( 5, 3 ) );
00100 *pR1 = stod( pS->substr( 8, 12 ) );
00101 *pR2 = stod( pS->substr( 20, 12 ) );
00102 *pR3 = stod( pS->substr( 32, 12 ) );
00103 *pR4 = stod( pS->substr( 44, 12 ) );
00104 *pR5 = stod( pS->substr( 56, 12 ) );
00105 }
00106
00107 void read_d(string *pS,
00108 double *pR )
00109 {
00110 *pR = stod( pS->substr( 0, 11 ) );
00111 }
00112
00113 void read_dd(string *pS,
00114 double *pR1, double *pR2 )
00115 {
00116 *pR1 = stod( pS->substr( 0, 11 ) );
00117 *pR2 = stod( pS->substr( 11, 11 ) );
00118 }
00119
00120 void read_ddd(string *pS,
00121 double *pR1, double *pR2, double *pR3 )
00122 {
00123 *pR1 = stod( pS->substr( 0, 11 ) );
00124 *pR2 = stod( pS->substr( 11, 11 ) );
00125 *pR3 = stod( pS->substr( 22, 11 ) );
00126 }
00127
00128 void read_dddddd(string *pS,
00129 double *pR1, double *pR2, double *pR3,
00130 double *pR4, double *pR5, double *pR6 )
00131 {
00132 *pR1 = stod( pS->substr( 0, 11 ) );
00133 *pR2 = stod( pS->substr( 11, 11 ) );
00134 *pR3 = stod( pS->substr( 22, 11 ) );
00135 *pR4 = stod( pS->substr( 33, 11 ) );
00136 *pR5 = stod( pS->substr( 44, 11 ) );
00137 *pR6 = stod( pS->substr( 55, 11 ) );
00138 }
00139
00140 void read_ii(string *pS,
00141 int *pI1, int *pI2 )
00142 {
00143 *pI1 = stoi( pS->substr( 0, 11 ) );
00144 *pI2 = stoi( pS->substr( 11, 11 ) );
00145 }
00146
00147 void read_date(string *pS,
00148 int *pI1 )
00149 {
00150 string smonth;
00151 int year,month,day;
00152
00153
00154 smonth = toupper(pS->substr( 27,3 ));
00155 year = stoi( pS->substr( 30, 2 ) );
00156
00157
00158 if( smonth == "JAN" )
00159 {
00160 month = 1;
00161 }
00162 else if( smonth == "FEB" )
00163 {
00164 month = 2;
00165 }
00166 else if( smonth == "MAR" )
00167 {
00168 month = 3;
00169 }
00170 else if( smonth == "APR" )
00171 {
00172 month = 4;
00173 }
00174 else if( smonth == "MAY" )
00175 {
00176 month = 5;
00177 }
00178 else if( smonth == "JUN" )
00179 {
00180 month = 6;
00181 }
00182 else if( smonth == "JUL" )
00183 {
00184 month = 7;
00185 }
00186 else if( smonth == "AUG" )
00187 {
00188 month = 8;
00189 }
00190 else if( smonth == "SEP" )
00191 {
00192 month = 9;
00193 }
00194 else if( smonth == "OCT" )
00195 {
00196 month = 10;
00197 }
00198 else if( smonth == "NOV" )
00199 {
00200 month = 11;
00201 }
00202 else if( smonth == "DEC" )
00203 {
00204 month = 12;
00205 }
00206 else
00207 {
00208 SevereError("read_date",smonth+" is not a recognized month!");
00209 }
00210
00211
00212 day=1;
00213
00214
00215 *pI1 = year*10000+month*100+day;
00216 }
00217
00218 int read_yi( string *pS )
00219 {
00220 int yi;
00221
00222 string upS = toupper(*pS);
00223
00224 if (upS.find("NEUTR")!=string::npos) yi = 1;
00225
00226 else if (upS.find("PROTO")!=string::npos) yi = 2;
00227
00228 else if (upS.find("DEUTE")!=string::npos) yi = 3;
00229
00230 else if (upS.find("TRITO")!=string::npos) yi = 4;
00231
00232 else if (upS.find("HELIU")!=string::npos) yi = 5;
00233
00234 else if (upS.find("ALPHA")!=string::npos) yi = 6;
00235
00236 else if ( (upS.find("PHOTO")!=string::npos) || (upS.find("GAMMA")!=string::npos) ) yi = 7;
00237
00238 else
00239 {
00240 SevereError( "read_yi","Cannot identify incident particle" );
00241 }
00242
00243 return yi;
00244 }