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

Annotation of /yoda/techmodel/forroutines/anticounter/ACphysics.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2.0 - (hide annotations) (download)
Tue Sep 21 20:51:02 2004 UTC (20 years, 2 months ago) by kusanagi
Branch: MAIN
CVS Tags: Rev040922
Changes since 1.2: +0 -0 lines
File MIME type: text/plain
Major release

1 kusanagi 1.1 //If big-little endian problem: switch tmp1&0xFF00 + tmp2&0x00FF ->
2     // tmp1&0x00FF + tmp2&0xFF00
3     #include <stdio.h>
4     #include "ACphysics.h"
5    
6 kusanagi 1.2 int ACphysics(int length,unsigned short* datapointer,struct datastruct* physicspointer){
7 kusanagi 1.1
8 kusanagi 1.2 //physics structure
9     struct datastruct physicsdata;
10 kusanagi 1.1
11 kusanagi 1.2 //pointer to struct
12     struct datastruct *physicspointer;
13    
14     //read variables
15     int i,err,found;
16     unsigned short buffer[100];
17     unsigned short tmp1,tmp2;
18    
19     int iter=2;
20    
21     *physicspointer=physicsdata;
22    
23 kusanagi 1.1 //look for header AC11, then cut out the event to a temp buffer
24 kusanagi 1.2 while(found==0 && iter<length)
25 kusanagi 1.1 {
26     tmp1=*datapointer;
27     tmp2=*(datapointer+1);
28 kusanagi 1.2 //printf("check: %hx\n",tmp1);
29 kusanagi 1.1 if(tmp1==0x11AC)
30     {
31     found=1;
32     for(i=0;i<64;i++)
33     {
34     buffer[i]=*datapointer;
35     datapointer++;
36     }
37     tmp1=0x0000;
38     }
39 kusanagi 1.2 else if((tmp1&0xFF00) + (tmp2&0x00FF)==0xAC11)
40 kusanagi 1.1 {
41     found=1;
42     for(i=0;i<64;i++)
43     {
44     buffer[i]=(tmp1&0xFF00) + (tmp2&0x00FF);
45     datapointer++;
46     tmp1=tmp2;
47     tmp2=*(datapointer+1);
48     }
49     }
50 kusanagi 1.2 else{
51     datapointer++;
52     iter=iter+2;}
53 kusanagi 1.1 }
54 kusanagi 1.2
55     //check errors
56     if(iter>=length)
57     err=2;
58     else if(buffer[1]==0xAC22)
59 kusanagi 1.1 err=0;
60     else
61     err=1;
62    
63     //Fill physicsdata from buffer
64     for(i=0;i<2;i++) physicsdata.header[i]=buffer[i];
65     physicsdata.status=buffer[2];
66     physicsdata.hitmap=buffer[3];
67     for(i=0;i<6;i++) physicsdata.regist[i]=buffer[4+i];
68     for(i=0;i<16;i++) physicsdata.shift[i]=buffer[10+i];
69     for(i=0;i<16;i++) physicsdata.counters[i]=buffer[26+i];
70     for(i=0;i<8;i++) physicsdata.coinc[i]=buffer[42+i];
71     physicsdata.trigg=buffer[50];
72     for(i=0;i<2;i++) physicsdata.clock[i]=buffer[51+i];
73     for(i=0;i<2;i++) physicsdata.temp[i]=buffer[53+i];
74     for(i=0;i<8;i++) physicsdata.DAC[i]=buffer[55+i];
75     physicsdata.CRC=buffer[63];
76 kusanagi 1.2
77 kusanagi 1.1 return err;
78    
79     }
80    

  ViewVC Help
Powered by ViewVC 1.1.23