/[PAMELA software]/yoda/techmodel/forroutines/anticounter/AC.c
ViewVC logotype

Diff of /yoda/techmodel/forroutines/anticounter/AC.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.2 by kusanagi, Fri Dec 3 22:08:07 2004 UTC revision 2.4 by kusanagi, Mon Dec 20 14:15:15 2004 UTC
# Line 29  struct physicsstruct *physicspointer; Line 29  struct physicsstruct *physicspointer;
29  struct calibstruct calibdata[2];  struct calibstruct calibdata[2];
30  struct calibstruct *calibpointer;  struct calibstruct *calibpointer;
31    
32    //Fill physicsdata from buffer
33    void fillphys(int k,unsigned short *buff)
34    {
35      for(i=0;i<2;i++) physicsdata[k].header[i]=buff[i];
36      physicsdata[k].status=buff[2];
37      physicsdata[k].hitmap=buff[3];
38      for(i=0;i<6;i++) physicsdata[k].regist[i]=buff[4+i];
39      for(i=0;i<16;i++) physicsdata[k].shift[i]=buff[10+i];
40      for(i=0;i<16;i++) physicsdata[k].counters[i]=buff[26+i];
41      for(i=0;i<8;i++) physicsdata[k].coinc[i]=buff[42+i];
42      physicsdata[k].trigg=buff[50];
43      for(i=0;i<2;i++) physicsdata[k].clock[i]=buff[51+i];
44      for(i=0;i<2;i++) physicsdata[k].temp[i]=buff[53+i];
45      for(i=0;i<8;i++) physicsdata[k].DAC[i]=buff[55+i];
46      physicsdata[k].CRC=buff[63];
47    
48    }
49    
50    //Fill calibdata from buffer
51    void fillcalib(int k,unsigned short *buff)
52    {
53      for(i=0;i<2;i++) calibdata[k].header[i]=buff[i];
54      for(i=0;i<5;i++) calibdata[k].status[i]=buff[2+i];
55      for(i=0;i<8;i++) calibdata[k].temp[i]=buff[7+i];
56      for(i=0;i<8;i++) calibdata[k].DAC1[i]=buff[15+i];
57      for(i=0;i<8;i++) calibdata[k].DAC2[i]=buff[23+i];
58      for(i=0;i<6;i++) calibdata[k].regist[i]=buff[31+i];
59      for(i=0;i<8;i++) calibdata[k].time[i]=buff[37+i];
60      calibdata[k].n_tr=buff[45];
61      for(i=0;i<16;i++) calibdata[k].hitmap_tr[i]=buff[46+i];
62      for(i=0;i<4096;i++) calibdata[k].curve1[i]=buff[62+i];
63      for(i=0;i<4096;i++) calibdata[k].curve2[i]=buff[4158+i];
64      calibdata[k].iCRC=buff[8254];
65      calibdata[k].tail=buff[8255];
66      calibdata[k].CRC=buff[8256];
67      printf("tail:CRC > %hx:%hx\n",buff[8255],buff[8256]);
68    }
69    
70    
71  unsigned char ACphysics(int length,unsigned char* datapointer,struct physicsstruct* physicspointer)  unsigned char ACphysics(int length,unsigned char* datapointer,struct physicsstruct* physicspointer)
# Line 45  unsigned char ACphysics(int length,unsig Line 82  unsigned char ACphysics(int length,unsig
82        tmp1 = ((*datapointer) << 8) | *(datapointer+1);        tmp1 = ((*datapointer) << 8) | *(datapointer+1);
83        tmp2 = ((*(datapointer+2)) << 8) | *(datapointer+3);        tmp2 = ((*(datapointer+2)) << 8) | *(datapointer+3);
84    
85        if(tmp1 == 0xAC11 && ((tmp2 == 0xAC11 && (err&0xF0)==0x0) || (tmp2 == 0xAC22 && (err&0x0F)==0x0)))        if(tmp1 == 0xACAC && ((tmp2 == 0xAC11 && (err&0xF0)==0x0) || (tmp2 == 0xAC22 && (err&0x0F)==0x0)))
86          {          {
87                    
88            for(i=0;i<64;i++)            for(i=0;i<64;i++)
# Line 93  unsigned char ACcalib(int length, unsign Line 130  unsigned char ACcalib(int length, unsign
130    
131        if(tmp1 == 0xACCA && ((tmp2 == 0xAC11 && (err&0xF0)==0x0) || (tmp2 == 0xAC22 && (err&0x0F)==0x0)))        if(tmp1 == 0xACCA && ((tmp2 == 0xAC11 && (err&0xF0)==0x0) || (tmp2 == 0xAC22 && (err&0x0F)==0x0)))
132          {          {
133            for(i=0;i<8256;i++)            for(i=0;i<8258;i++)
134              {              {
135                buffer[i]=((*datapointer) << 8) | *(datapointer+1);                buffer[i]=((*datapointer) << 8) | *(datapointer+1);
136                datapointer=datapointer+2;                datapointer=datapointer+2;
# Line 118  unsigned char ACcalib(int length, unsign Line 155  unsigned char ACcalib(int length, unsign
155    return err;    return err;
156  }  }
157    
 //Fill physicsdata from buffer  
 void fillphys(int k,unsigned short *buff)  
 {  
   for(i=0;i<2;i++) physicsdata[k].header[i]=buff[i];  
   physicsdata[k].status=buff[2];  
   physicsdata[k].hitmap=buff[3];  
   for(i=0;i<6;i++) physicsdata[k].regist[i]=buff[4+i];  
   for(i=0;i<16;i++) physicsdata[k].shift[i]=buff[10+i];  
   for(i=0;i<16;i++) physicsdata[k].counters[i]=buff[26+i];  
   for(i=0;i<8;i++) physicsdata[k].coinc[i]=buff[42+i];  
   physicsdata[k].trigg=buff[50];  
   for(i=0;i<2;i++) physicsdata[k].clock[i]=buff[51+i];  
   for(i=0;i<2;i++) physicsdata[k].temp[i]=buff[53+i];  
   for(i=0;i<8;i++) physicsdata[k].DAC[i]=buff[55+i];  
   physicsdata[k].CRC=buff[63];  
   
 }  
   
 //Fill calibdata from buffer  
 void fillcalib(int k,unsigned short *buff)  
 {  
   calibdata[k].header=buff[0];  
   for(i=0;i<5;i++) calibdata[k].status[i]=buff[1+i];  
   for(i=0;i<8;i++) calibdata[k].temp[i]=buff[6+i];  
   for(i=0;i<8;i++) calibdata[k].DAC1[i]=buff[14+i];  
   for(i=0;i<8;i++) calibdata[k].DAC2[i]=buff[22+i];  
   for(i=0;i<6;i++) calibdata[k].regist[i]=buff[30+i];  
   for(i=0;i<8;i++) calibdata[k].time[i]=buff[36+i];  
   calibdata[k].n_tr=buff[44];  
   for(i=0;i<16;i++) calibdata[k].hitmap_tr[i]=buff[45+i];  
   for(i=0;i<4096;i++) calibdata[k].curve1[i]=buff[61+i];  
   for(i=0;i<4096;i++) calibdata[k].curve2[i]=buff[4157+i];  
   calibdata[k].iCRC=buff[8253];  
   calibdata[k].tail=buff[8254];  
   calibdata[k].CRC=buff[8255];  
 }  

Legend:
Removed from v.2.2  
changed lines
  Added in v.2.4

  ViewVC Help
Powered by ViewVC 1.1.23