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
00039
00040
00041
00042
00043 #include <stdio.h>
00044 #include <lal/LALStdlib.h>
00045 #include <lal/AVFactories.h>
00046 #include <lal/Random.h>
00047 #include <lal/Units.h>
00048 #include <lal/FrameStream.h>
00049
00050 #include <lal/LALRCSID.h>
00051 NRCSID (MAKEFRAMESC,"$Id: MakeFrames.c,v 1.5 2007/06/08 14:41:46 bema Exp $");
00052
00053 #define TESTSTATUS( pstat ) \
00054 if ( (pstat)->statusCode ) { REPORTSTATUS(pstat); return 1; } else ((void)0)
00055
00056 #ifndef CHANNEL
00057 #define CHANNEL "H1:LSC-AS_Q"
00058 #endif
00059
00060 INT4 lalDebugLevel = LALMSGLVL3;
00061
00062 int main( void )
00063 {
00064 static LALStatus status;
00065 static INT4TimeSeries series;
00066 const UINT4 time = 60;
00067 const INT4 seed = 10;
00068 const REAL4 rate = 16384;
00069 const UINT4 npts = time * rate;
00070 FrOutPar opar = { "F", "TEST", ADCDataChannel, 6, 0, 0 };
00071 RandomParams *rpar = NULL;
00072 UINT4 count = 0;
00073 UINT4 i;
00074
00075
00076
00077 LALCreateRandomParams( &status, &rpar, seed );
00078 TESTSTATUS( &status );
00079
00080 strncpy( series.name, CHANNEL, sizeof( series.name ) );
00081 series.epoch.gpsSeconds = 600000000;
00082 series.sampleUnits = lalADCCountUnit;
00083 series.deltaT = 1 / rate;
00084 LALI4CreateVector( &status, &series.data, npts );
00085 TESTSTATUS( &status );
00086
00087
00088
00089
00090
00091
00092
00093 for ( i = 0; i < series.data->length; ++i )
00094 {
00095 INT8 ns;
00096 ns = (INT8)1000000000 * (INT8)series.epoch.gpsSeconds;
00097 ns += (INT8)series.epoch.gpsNanoSeconds;
00098 ns += (INT8)( 1e9 * i * series.deltaT );
00099 ns %= (INT8)1000000000;
00100 series.data->data[i] = count++;
00101 }
00102
00103 LALFrWriteINT4TimeSeries( &status, &series, &opar );
00104 TESTSTATUS( &status );
00105
00106
00107
00108 series.epoch.gpsSeconds += time;
00109
00110
00111
00112
00113 for ( i = 0; i < series.data->length; ++i )
00114 {
00115 INT8 ns;
00116 ns = (INT8)1000000000 * (INT8)series.epoch.gpsSeconds;
00117 ns += (INT8)series.epoch.gpsNanoSeconds;
00118 ns += (INT8)( 1e9 * i * series.deltaT );
00119 ns %= (INT8)1000000000;
00120 series.data->data[i] = count++;
00121 }
00122
00123 LALFrWriteINT4TimeSeries( &status, &series, &opar );
00124 TESTSTATUS( &status );
00125
00126
00127
00128 series.epoch.gpsSeconds += time;
00129
00130
00131
00132
00133 for ( i = 0; i < series.data->length; ++i )
00134 {
00135 INT8 ns;
00136 ns = (INT8)1000000000 * (INT8)series.epoch.gpsSeconds;
00137 ns += (INT8)series.epoch.gpsNanoSeconds;
00138 ns += (INT8)( 1e9 * i * series.deltaT );
00139 ns %= (INT8)1000000000;
00140 series.data->data[i] = count++;
00141 }
00142
00143 LALFrWriteINT4TimeSeries( &status, &series, &opar );
00144 TESTSTATUS( &status );
00145
00146 if ( XLALFrWriteINT4TimeSeries( &series, 7 ) < 0 )
00147 return 1;
00148
00149
00150
00151 LALI4DestroyVector( &status, &series.data );
00152 TESTSTATUS( &status );
00153
00154 LALDestroyRandomParams( &status, &rpar );
00155 TESTSTATUS( &status );
00156
00157 LALCheckMemoryLeaks();
00158 return 0;
00159 }