00001
00002
00018 #include <iostream>
00019 #include <iomanip>
00020
00021 #include "TimDefine.h"
00022 #include "TimSequin.h"
00023
00024 using namespace std;
00025 using namespace SctPixelRod;
00026
00027 const int SIZE = 106;
00028
00029 TimSequin *seq = new TimSequin();
00030
00031 void testscan();
00032 void scanner( const int size, TimScanControl control );
00033
00034 int main() {
00035
00036 if (seq == 0) cout << "No object " << seq << endl;
00037 testscan();
00038 delete seq;
00039 return 0;
00040 }
00041
00042 void testscan() {
00043
00044 TimScanControl control = seq->scanDefaults();
00045
00046 const int offset = TIM_BCID_OFFSET;
00047 const int Delays1[2] = { 3, 5 };
00048 const int Delays0[2] = { 0, 0 };
00049 UINT32 ids1[3] = { 1, 0, 0x3FF };
00050 UINT32 ids2[3] = { 2, 0, 0x3FF };
00051 int iBCR1, iCAL1, iL1A1, iBCR2, iL1A2;
00052
00053 cout << "scan test for no errors" << endl;
00054
00055 iBCR1 = -1;
00056 iCAL1 = 0;
00057 iL1A1 = iCAL1 + TIM_CAL_DEADTIME;
00058 iBCR2 = iL1A1 + TIM_L1A_DEADTIME;
00059 iL1A2 = iBCR2 + TIM_BCR_DEADTIME;
00060 ids1[1] = seq->getBCID( iL1A1, iBCR1, offset );
00061 ids2[1] = seq->getBCID( iL1A2, iBCR2, offset );
00062
00063 seq->reset();
00064 seq->addByIndex( TIM_CAL, iCAL1 );
00065 seq->addByIndex( TIM_BCR, iBCR2 );
00066 seq->addTrigger( iL1A1, ids1, Delays1 );
00067 seq->addTrigger( iL1A2, ids2, Delays1 );
00068
00069 control.offset = offset;
00070 control.pipeline = TIM_CAL_DEADTIME;
00071 control.orbit = iBCR2 - iBCR1;
00072
00073 scanner( SIZE, control );
00074
00075 cout << "scan test for 16 errors" << endl;
00076
00077 iL1A1 = iL1A1 - 1;
00078 iBCR2 = iBCR2 - 2;
00079 iL1A2 = iL1A2 - 3;
00080
00081 ids1[0] = 0;
00082
00083 seq->reset();
00084 seq->addByIndex( TIM_CAL, iCAL1 );
00085 seq->addByIndex( TIM_BCR, iBCR2 );
00086 seq->addByIndex( TIM_FER, iBCR2 );
00087 seq->addTrigger( iL1A1, ids1, Delays0 );
00088 seq->addTrigger( iL1A2, ids2, Delays0 );
00089
00090 control.nextTTID = 0;
00091
00092 scanner( iL1A1 + 2 * 37 + Delays0[0], control );
00093
00094
00095 }
00096
00097
00098
00099 void scanner( const int size, TimScanControl control ) {
00100
00101 UINT16 buffer[SIZE];
00102 const int m = 20;
00103 const int n = (size < 200) ? size : 200;
00104
00105 control.size = seq->getBuffer( size, buffer );
00106 control.byte = 0;
00107 control.print = 1;
00108
00109 for (int i = 0; i < n; i++) {
00110 cout << hex << setw(2) << buffer[i]
00111 << ( (i%m==m-1 || i==n-1) ? '\n' : ' ')
00112 << dec;
00113 }
00114 TimScanResults results = seq->scan( control );
00115
00116 cout << "scan errors = " << results.errors << endl;
00117 }