00001 #ifndef IMGDECODE_INCL
00002 #define IMGDECODE_INCL 1
00003
00004 #ifndef PACKETHEADERWORDS
00005 #define PACKETHEADERWORDS 19
00006 #endif
00007 #ifndef PACKETDATAWORDS
00008 #define PACKETDATAWORDS 869
00009 #endif
00010 #ifndef PACKETWORDS
00011 #define PACKETWORDS 888
00012 #endif
00013
00014 #define MAXPIXELS 16777216 // 4096*4096
00015 #define MAXHIST 32768
00016
00017 #ifndef TABLE_DIR
00018 #define TABLE_DIR "/home/production/cvs/TBL_JSOC/lev0"
00019 #endif
00020
00021 #define APID_HMI_SCIENCE_1 400
00022 #define APID_HMI_SCIENCE_2 410
00023 #define APID_AIA_SCIENCE_1 500
00024 #define APID_AIA_SCIENCE_2 510
00025
00026 #define isAIA(x) ((x) == APID_AIA_SCIENCE_1 || (x) == APID_AIA_SCIENCE_2)
00027 #define isHMI(x) ((x) == APID_HMI_SCIENCE_1 || (x) == APID_HMI_SCIENCE_2)
00028
00029 #define IMGDECODE_DECOMPRESS_ERROR (-1)
00030 #define IMGDECODE_TOO_MANY_PIXELS (-2)
00031
00032 #define IMGDECODE_BAD_N (-101)
00033 #define IMGDECODE_BAD_APID (-102)
00034 #define IMGDECODE_NO_LOOKUP_TABLE (-103)
00035 #define IMGDECODE_LOOKUP_ID_MISMATCH (-104)
00036 #define IMGDECODE_BAD_LOOKUP_TABLE (-105)
00037 #define IMGDECODE_NO_CROP_TABLE (-106)
00038 #define IMGDECODE_CROP_ID_MISMATCH (-107)
00039 #define IMGDECODE_BAD_CROP_GEOMETRY (-108)
00040 #define IMGDECODE_BAD_CROP_TABLE (-109)
00041 #define IMGDECODE_BAD_CROP_SKIP_TAKE (-110)
00042 #define IMGDECODE_BAD_OFFSET (-111)
00043
00044 #define IMGDECODE_OUT_OF_MEMORY (-201)
00045
00046 #define BLANK (-32768)
00047
00048 typedef struct {
00049 unsigned short width, height;
00050 unsigned totalpix;
00051 unsigned short *skip;
00052 unsigned short *take;
00053 unsigned *offset;
00054 } CROPTABLE;
00055
00056 typedef struct {
00057 int initialized;
00058 int reopened;
00059 unsigned telnum;
00060 unsigned fsn;
00061 unsigned fid;
00062 unsigned apid;
00063 unsigned cropid;
00064 unsigned luid;
00065 unsigned tap;
00066 unsigned N, K, R;
00067 unsigned totalvals;
00068 unsigned datavals;
00069 unsigned npackets;
00070 unsigned nerrors;
00071 int last_pix_err;
00072 int overflow;
00073 int headerr;
00074 uint64_t first_packet_time;
00075 short dat[MAXPIXELS];
00076 unsigned hist[MAXHIST];
00077 } IMG;
00078
00079 typedef struct {
00080 short min;
00081 short max;
00082 short median;
00083 double mean;
00084 double rms;
00085 double skew;
00086 double kurt;
00087 } STAT;
00088
00089 int imgdecode(unsigned short *impdu, IMG *img);
00090 int imgdecode_init_hack(IMG *img);
00091 int imgstat(IMG *img, STAT *stat);
00092
00093
00094
00095 #define NEED_PATCH1(fsn) (!(fsn%2) && (fsn<=33190636) && (fsn>=32249884))
00096
00097 #define NEED_PATCH2(fsn) ((fsn%2) && (fsn<=70405129) && (fsn>=70397305))
00098
00099 #define NEED_PATCH3(fsn) ((fsn%2) && (fsn<=116676569) && (fsn>=116655853))
00100
00101 #define NEED_PATCH4(fsn) (!(fsn%2) && (fsn<=124174986) && (fsn>=124146982))
00102
00103 #endif