| [534] | 1 | #include <iostream.h>
 | 
|---|
 | 2 | #include <fstream.h>
 | 
|---|
 | 3 | #include <iomanip.h>
 | 
|---|
 | 4 | 
 | 
|---|
 | 5 | #include "archeopsfile.h"
 | 
|---|
 | 6 | #include "archtoi.h"
 | 
|---|
 | 7 | #include "toisvr.h"
 | 
|---|
 | 8 | 
 | 
|---|
 | 9 | 
 | 
|---|
 | 10 | #ifdef __MWERKS__
 | 
|---|
 | 11 | #include <console.h>
 | 
|---|
 | 12 | #endif
 | 
|---|
 | 13 | 
 | 
|---|
 | 14 | using namespace std;  //introduces namespace std
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | #ifdef __MWERKS__
 | 
|---|
 | 17 | #include "Events.h"
 | 
|---|
 | 18 | #include "LowMem.h"
 | 
|---|
 | 19 | #include "sioux.h"
 | 
|---|
 | 20 | static int macSleepTicks = 0;
 | 
|---|
 | 21 | static int macRunTicks = 10;
 | 
|---|
 | 22 | static void yield()
 | 
|---|
 | 23 | {
 | 
|---|
 | 24 |     EventRecord theEvent;
 | 
|---|
 | 25 |     static long int macLastTicks;
 | 
|---|
 | 26 |     long int ticks = LMGetTicks();
 | 
|---|
 | 27 |     if (ticks - macLastTicks >= macRunTicks) {
 | 
|---|
 | 28 |       if (WaitNextEvent(everyEvent, &theEvent,macSleepTicks,0))
 | 
|---|
 | 29 |         SIOUXHandleOneEvent(&theEvent);
 | 
|---|
 | 30 |       macLastTicks = LMGetTicks();
 | 
|---|
 | 31 |     }
 | 
|---|
 | 32 | }
 | 
|---|
 | 33 | #endif
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | int main(int argc, char** argv)
 | 
|---|
 | 36 | {       
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 |   TOISvr svr;
 | 
|---|
 | 39 |   svr.AddInfo(mjd);
 | 
|---|
 | 40 |   svr.AddInfo(gyroRaw,0);
 | 
|---|
 | 41 |   svr.AddInfo(gyroRaw,1);
 | 
|---|
 | 42 |   svr.AddInfo(gyroRaw,2);
 | 
|---|
 | 43 |   
 | 
|---|
 | 44 |   svr.SetDirectory("Sans titre");
 | 
|---|
 | 45 |   svr.OnBoardRecorderFiles(true);
 | 
|---|
 | 46 |   svr.SetTimeInterval(1377.88, 1377.95);
 | 
|---|
 | 47 |   
 | 
|---|
 | 48 |   // Pour le moment, on sort, en binaire, les points moyennes sur 100
 | 
|---|
 | 49 |   
 | 
|---|
 | 50 |   ofstream s("gyro.data",ios::binary);
 | 
|---|
 | 51 |   ofstream s1("gyro1.data",ios::binary);
 | 
|---|
 | 52 |   cout << "starting" << endl;
 | 
|---|
 | 53 |   TOIIter iter = svr.DoQuery();
 | 
|---|
 | 54 |   const int n=72;
 | 
|---|
 | 55 |   int i=0;
 | 
|---|
 | 56 |   int ndata=0;
 | 
|---|
 | 57 |   double xmjd, gyr0, gyr1, gyr2;
 | 
|---|
 | 58 |   double gyr00, gyr01, gyr02;
 | 
|---|
 | 59 |   while (iter.Next()) {
 | 
|---|
 | 60 |     if (i==0) {
 | 
|---|
 | 61 |       xmjd = iter.getValue(0);
 | 
|---|
 | 62 |       gyr0=gyr1=gyr2=0;
 | 
|---|
 | 63 |       gyr00 = iter.getValue(1);
 | 
|---|
 | 64 |       gyr01 = iter.getValue(2);
 | 
|---|
 | 65 |       gyr02 = iter.getValue(3);
 | 
|---|
 | 66 |     }
 | 
|---|
 | 67 |     gyr0 += iter.getValue(1);
 | 
|---|
 | 68 |     gyr1 += iter.getValue(2);
 | 
|---|
 | 69 |     gyr2 += iter.getValue(3);
 | 
|---|
 | 70 |     i++;
 | 
|---|
 | 71 |     if (i >= n) {
 | 
|---|
 | 72 |       gyr0 /= n;
 | 
|---|
 | 73 |       gyr1 /= n;
 | 
|---|
 | 74 |       gyr2 /= n;
 | 
|---|
 | 75 |       s.write((char*) &xmjd, sizeof(xmjd));
 | 
|---|
 | 76 |       s.write((char*) &gyr0, sizeof(gyr0));
 | 
|---|
 | 77 |       s.write((char*) &gyr1, sizeof(gyr1));
 | 
|---|
 | 78 |       s.write((char*) &gyr2, sizeof(gyr2));
 | 
|---|
 | 79 |       s1.write((char*) &xmjd, sizeof(xmjd));
 | 
|---|
 | 80 |       s1.write((char*) &gyr00, sizeof(gyr00));
 | 
|---|
 | 81 |       s1.write((char*) &gyr01, sizeof(gyr01));
 | 
|---|
 | 82 |       s1.write((char*) &gyr02, sizeof(gyr02));
 | 
|---|
 | 83 |       ndata++;
 | 
|---|
 | 84 |       yield();
 | 
|---|
 | 85 |       i=0;
 | 
|---|
 | 86 |     }
 | 
|---|
 | 87 |   }
 | 
|---|
 | 88 |   cout << "Done. " << ndata << " samples written." << endl;
 | 
|---|
 | 89 | 
 | 
|---|
 | 90 | }
 | 
|---|