36 SYSTEM_POWER_STATUS status;
39 GetSystemPowerStatus( &status );
66 w = *localtime( &now );
80 when -> tm_sec = w.tm_sec;
81 when -> tm_min = w.tm_min;
82 when -> tm_hour = w.tm_hour;
83 when -> tm_mday = w.tm_mday;
84 when -> tm_mon = w.tm_mon;
85 when -> tm_year = w.tm_year;
86 when -> tm_wday = w.tm_wday;
87 when -> tm_yday = w.tm_yday;
88 when -> tm_isdst = w.tm_isdst;
101 w = *localtime(&now);
137 w = *localtime(&now);
139 tp->
da_mon = w.tm_mon + 1;
140 tp->
da_year = w.tm_year + 1900;
154 fc = fopen(
"LOG\\Devices.Log",
"a");
157 fprintf(fc,
" %s %s %s\n",datebuf, timebuf, str);
188 while(f[l--] != 0x5C);
190 strcpy(ffile, &f[l]);
193 fd = open(f, O_WRONLY |
O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
194 if(fd < 0)
return(-1);
198 info += write(fd, &palet, 4);
205 info += write(fd, &t, 2);
224 write(fd, &l,
sizeof(
U16));
239 write(fd, &l,
sizeof(
U16));
258 write(fd, &l,
sizeof(
U16));
271 fd = open(f, O_WRONLY |
O_BINARY, S_IWRITE);
286 unsigned long info = 0;
325 unsigned long info = 0;
331 info += write(fd, &HDRSP.
s_alt,
sizeof(HDRSP.
s_alt));
332 info += write(fd, &HDRSP.
s_sza,
sizeof(HDRSP.
s_sza));
334 info += write(fd, &HDRSP.
DATE,
sizeof(
struct date));
335 info += write(fd, &HDRSP.
TIME,
sizeof(
struct time));
346 info += write(fd, &HDRSP.
ccdwx,
sizeof(HDRSP.
ccdwx));
347 info += write(fd, &HDRSP.
ccdwy,
sizeof(HDRSP.
ccdwy));
348 info += write(fd, &HDRSP.
ccdxs,
sizeof(HDRSP.
ccdxs));
349 info += write(fd, &HDRSP.
ccdys,
sizeof(HDRSP.
ccdys));
350 info += write(fd, &HDRSP.
ccdxe,
sizeof(HDRSP.
ccdxe));
351 info += write(fd, &HDRSP.
ccdye,
sizeof(HDRSP.
ccdye));
353 info += write(fd, &HDRSP.
ccdnr,
sizeof(HDRSP.
ccdnr));
365 fprintf(fff,
"LOC: %s ", HDRSP.
s_name);
366 fprintf(fff,
"LAT: %.2lf ", HDRSP.
s_latitude);
368 fprintf(fff,
"ALT[m/asl]: %u ", HDRSP.
s_alt);
369 fprintf(fff,
"SZA: %.2lf\n", HDRSP.
s_sza);
372 fprintf(fff,
"%s ", HDRSP.
mirpos);
373 fprintf(fff,
"%d ", HDRSP.
lambda);
374 fprintf(fff,
"%s ", HDRSP.
filpos);
375 fprintf(fff,
"%.2lf ", HDRSP.
ccdtemp);
376 fprintf(fff,
"%.2lf ", HDRSP.
ccdtexp);
377 fprintf(fff,
"%5u ", HDRSP.
imgmax);
378 fprintf(fff,
"%5u\n", HDRSP.
imgmin);
380 fprintf(fff,
"%d ", HDRSP.
imgfmt);
381 fprintf(fff,
"%d ", HDRSP.
ccdwx);
382 fprintf(fff,
"%d ", HDRSP.
ccdwy);
383 fprintf(fff,
"%d ", HDRSP.
ccdxs);
384 fprintf(fff,
"%d ", HDRSP.
ccdys);
385 fprintf(fff,
"%d ", HDRSP.
ccdxe);
386 fprintf(fff,
"%d ", HDRSP.
ccdye);
387 fprintf(fff,
"%d ", HDRSP.
ccdvbin);
388 fprintf(fff,
"%d ", HDRSP.
ccdnr);
390 fprintf(fff,
"%d ", HDRSP.
dummy1);
391 fprintf(fff,
"%d ", HDRSP.
dummy2);
392 fprintf(fff,
"%d ", HDRSP.
dummy3);
393 fprintf(fff,
"%d\n", HDRSP.
dummy4);
394 fprintf(fff,
"%s\n", HDRSP.
comment);
400 unsigned long info = 0;
405 double pi = 3.1415926535;
415 while(f[l--] != 0x5C);
417 strcpy(ffile, &f[l]);
421 fd = open(f, O_WRONLY |
O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
422 if(fd < 0)
return(-1);
441 info += write(fd, &
URdMat(s, x, y), 2);
455 fd = fopen(fname,
"a");
457 VRange(
"Export as ASCII", 0);
471 fprintf(fd,
"\n", NULL);
474 fprintf(fd,
"%5u ",
URdMat(s, x, y));
476 fprintf(fd,
"%f ",
FRdMat(s, x, y));
479 if((y % 40) == 0 && y > 0)
482 fprintf(fd,
"\n", NULL);
496 unsigned long info = 0;
503 double pi = 3.1415926535;
513 while(fname[l--] != 0x5C);
515 strcpy(ffile, &fname[l]);
519 fd = open(fname, O_WRONLY |
O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
520 if(fd < 0)
return(-1);
534 fn = fopen(fname,
"a");
596 int wl[] = {2823, 3337, 3850, 4358, 4861, 5332, 5814, 6282, 6734, 7201, 7677, 8195, 8622, 9023, 9405, 9758, 10066, 10358};
615 fh = open(tit, O_WRONLY |
O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
620 for(y = 0; y < (
unsigned int)
IDY; y++)
626 write( fh, &datebuf,
sizeof(datebuf));
627 write( fh, &timebuf,
sizeof(timebuf));
629 write( fh, &Lambda,
sizeof(Lambda));
633 write( fh, &riga,
sizeof(riga));
636 sprintf(tit1,
"%s",
"Default comment");
637 write( fh, &tit1,
sizeof(tit1));
640 for(n = 0; n <
IDX; n++)
654 fd = fopen(tit,
"a");
657 Status(
"Error opening file");
663 for(y = 0; y < (
unsigned int)
IDY; y++)
669 fprintf(fd,
"%s %s ", datebuf, timebuf);
670 fprintf(fd,
" %d ",
MIS.
Pos);
671 fprintf(fd,
" %5d ", Lambda);
672 fprintf(fd,
" %d ",
FWS.
Pos);
673 fprintf(fd,
" %.2lf ",
TExp);
675 fprintf(fd,
" Riga:%d ", riga);
678 sprintf(tit1,
"%s",
"Default comment");
679 fprintf(fd,
" %s\n ", tit1 );
681 for(n = 0; n <
IDX; n++)
708 char str[128], temp[12];
735 er = fscanf(fd,
"%i/%2u/%2u%2u:%2u:%2u%s%s%d%s%lf%lf%lu%lu", &BIL.
SPH.
DATE.
da_year,
755 char str[128], temp[4];
773 er = fscanf(fd,
"%d%d%d%d%d%d%d%d%d%d%d", &BIL.
SPH.
imgtype,
815 fprintf(fff,
"SZA: %.2lf\n", BIL.
SPH.
sza);
865 for(x = 0; x <
IDX; x++)
869 fprintf(fd,
" %9.4lf", DOAS.
lambda[x]);
871 fprintf(fd,
" %04d", x);
872 for(y = 0; y <
IDY; y++)
876 fprintf(fd,
"\n", NULL);
880 fprintf(fd,
"\n", NULL);
897 unsigned long eln = (
unsigned long)(2 * (horpix - bp + 1 )) ;
899 avect = (
double *) calloc( eln,
sizeof(
double));
903 for(y = 0; y < verpix; y++)
906 for(x = 0; x < horpix; x++)
908 if ((x <= horpix - bp ) & (x > 1))
910 avect[n] = (double)source[y * (horpix) + x];
917 for(x = 0; x < horpix; x++)
919 if ((x <= horpix - bp ) & (x > 1))
921 destination[y * horpix + x] = (float) avect[x-1] ;
929 fd = fopen(
"SmoothFL_In.tmp",
"w");
931 for(x = 0; x < horpix + 1; x++)
933 if ((x <= horpix - bp ) & (x > 1))
935 fprintf(fd,
"%04u ", x);
937 for(y = 0; y < verpix; y++)
939 fprintf(fd,
"%10.5lf ", source[y *
IDX + x]);
941 fprintf(fd,
"\n", NULL);
944 fprintf(fd,
"\n", NULL);
948 fd = fopen(
"SmoothFL_Out.tmp",
"w");
951 for(x = 0; x < horpix + 1; x++)
953 if ((x <= horpix - bp ) & (x > 1))
955 fprintf(fd,
"%04u ", x);
957 for(y = 0; y < verpix; y++)
959 fprintf(fd,
"%10.5lf ", destination[y *
IDX + x]);
961 fprintf(fd,
"\n", NULL);
964 fprintf(fd,
"\n", NULL);
973 int SmoothData(
unsigned short *source,
float *destination,
int horpix,
int verpix,
979 unsigned long eln = (
unsigned long)(2 * (horpix - bp + 1 )) ;
982 avect = (
double *) calloc( eln,
sizeof(
double));
986 for(y = 0; y < verpix; y++)
989 for(x = 0; x < horpix; x++)
991 if ((x <= horpix - bp ) & (x > 1))
993 avect[n] = (double)source[y * (horpix) + x];
1000 for(x = 0; x < horpix; x++)
1002 if ((x <= horpix - bp ) & (x > 1))
1004 destination[y * horpix + x] = (float) avect[x-1] ;
1012 fd = fopen(
"SmoothUS_In.tmp",
"w");
1013 if(fd < 0)
return 1;
1015 for(x = 0; x < horpix ; x++)
1018 if ((x <= horpix - bp ) & (x > 1))
1020 fprintf(fd,
"%04u ", x);
1022 for(y = 0; y < verpix; y++)
1024 fprintf(fd,
"%05u ", source[y *
IDX + x]);
1026 fprintf(fd,
"\n", NULL);
1029 fprintf(fd,
"\n", NULL);
1033 fd = fopen(
"SmoothUS_Out.tmp",
"w");
1034 if(fd < 0)
return 1;
1037 for(x = 0; x < horpix; x++)
1040 if ((x <= horpix - bp ) & (x > 1))
1042 fprintf(fd,
"%04u ", x);
1044 for(y = 0; y < verpix; y++)
1046 fprintf(fd,
"%10.5lf ", destination[y *
IDX + x]);
1048 fprintf(fd,
"\n", NULL);
1051 fprintf(fd,
"\n", NULL);
1081 for(x = 0; x <
IDX - BlindPix_1 + 1; x++)
1085 fprintf(fd,
" %9.4lf", DOAS.
lambda[x]);
1087 fprintf(fd,
" %04u", x);
1092 fprintf(fd,
"\n", NULL);
1096 fprintf(fd,
"\n", NULL);
1116 char string[4] =
".COL";
1125 lunstr = strlen(sourcefilename);
1126 strcpy(buf,sourcefilename);
1128 strncpy( buf + (lunstr - 4),
string, 4 );
1130 fd = fopen(buf,
"a");
1131 if(fd < 0)
return 1;
1136 D_VRange(
"Column FORMAT processing", 0, 128, 254, 128);
1139 if( (strcmp(fext,
".dat") == 0) |(strcmp(fext,
".Dat") == 0) )
1141 fs = fopen(sourcefilename,
"r");
1142 if(fs < 0)
return 1;
1145 while( !feof( fs ) )
1162 if((k % 5) == 0 && k > 0)
1169 else if( (strcmp(fext,
".bif") == 0) | (strcmp(fext,
".Bif") == 0) )
1171 fb = open(sourcefilename, O_RDONLY |
O_BINARY, S_IREAD );
1188 if((k % 5) == 0 && k > 0)
1196 D_VRange(NULL, 100, 128, 254, 128);
int IDX
Number of sensible horizontal pixels.
void WriteColumn(int mod, FILE *fd)
void D_Print_BIL_H_BIN(int mod, int fd)
void WriteSelColandSmoothed(int mod, FILE *fd, int selcol)
write selected Column
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
unsigned int imgmin
Image minimum value.
int D_save_asc(char *fname, int s)
int SmoothData(unsigned short *source, float *destination, int horpix, int verpix, int filw, int bp)
Calc. the smoothed matrix of an unsigned short one. .
int Wl
Flag for the units on the X scale plot.
int ccdwy
Total Number of Y Pixels.
void D_BuildH(int mod, int s)
Build Header of the measurements . .
int ccdwx
Total Number of X Pixels.
#define DOASMODE
execution for DOAS Processing
int FilterData(unsigned short *mat, int horpix, int verpix, int filw, int bp)
int Pos
Mirror Current Position.
flag Flag
Structure for different flags.
int D_WriteInitLog(char *str)
writes devices errors(AMS, CCD...) on the Devices.log file.
void getdate(struct date *tp)
get current date
struct date DATE
Registration date.
int SmoothFloatData(float *source, float *destination, int horpix, int verpix, int filw, int bp)
Calc. the smoothed matrix of a float one. .
void DB_save_img(char *tit, int mod)
Saving image. Procedure for saving the CCD Image Used until version 2.0.9, Since 2.1.0 D_Saving(void) is used.
float ccdtemp
CCD Temperature.
float * DeallocFloatMat(float *mat)
spectrumheader SPH
Spectrum Header Structure.
void ReadIMG(FILE *file, unsigned short *mat, int hp, int vp)
Read ASCII Image (Spectral Data only) .
int Pos
Filter Wheel current Position.
void D_PrintHMod(FILE *fff)
Print the header in Column format.
short unsigned U16
2 byte without sign, range 0-65535
void D_PrintH_BIN(int mod, int fd)
int Wl
Grating Wavelength.
unsigned int s_alt
station altitude
float s_longitude
station longitude
struct time TIME
Registration time.
int ReadHeader_ASCII(int mod, FILE *fd)
Read ASCII Header of the measurement. .
char binmirpos[8]
Mirror position.
#define OFFLINEPLOT
execution for archived data visualisation
int SaveDataOffLine(char *fname, int mod)
unsigned long U32
4 byte without sign, range 0-4294967295
#define SAVECNT
maximum number of spectra in one file
unsigned short * ImatOrig
void WriteIMG_BIN(int fd, unsigned short *mat, int hp, int vp)
int ReadHeaderOldF(FILE *fd)
read the ASCII header of the stored spectrum (OLD FORMAT - replaced by ReadHeaderOnly(FILE *fd) ...
int imgfmt
Image format: 0 = ASCII, 1 = BIN.
double lambda[1055]
Wavelength series.
void Status(char *tit)
Writes information's on the Status label .
int ccdnr
Row number (ccdyoff-ccdwx)/ccdvbin.
int D_save_bin(char *f, int s)
int ReadHeader_BIN(int fd)
read the BINARY header of the stored spectrum
float s_sza
sun solar zenith angles
char bincomment[255]
comment
void ReadIMG_BIN(int fd, unsigned short *mat, int hp, int vp)
read the BINARY stored spectrum
int IDY
Number of sensible vertical pixels.
int Pix2Wl(int mod, int pos, int spix, int epix, struct doas *pd)
float s_latitude
station latitude
int FFTFilter
Fast Fourier Trasform Filter windows.
int ReadHeaderOnly(FILE *fd)
read the ASCII header of the stored spectrum
unsigned short * ImatGraf
double TExp
CCD Exposure time.
short int S16
2 byte with sign, -32768+32767
char binfilpos[5]
Filter position.
const char * filpos
Filter position.
void D_PrintH_ASCII(int mod, FILE *fff)
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
int D_save_bif(char *f, int s)
char s_name[4]
station localization
C_DEF void VRange(char *str, int val)
int wl[]
WaveLength definition - for SD_Grating.
int SmoothingF(double *tmp, int npix, int pts)
Smoothing of 1D array.
void gettime(struct time *tp)
get current time
char mirpos[8]
Mirror position.
Bortul Image Library Structure .
void DB_Save(char *tit, int mod)
Save the acquired spectrum. Procedure that Save the acquired spectrum.
float * AllocFloatMat(int hp, int vp)
C_DEF void DI_FindExtName(char *fullname, char *fext)
unsigned short * AllocUSMat(int hp, int vp)
int lambda
wavelength value
float ccdtexp
ccd Exposure time
unsigned int imgmax
Image maximum value.
void WriteIMG(FILE *file, unsigned short *mat, int hp, int vp)
int exemode
Set the Execution MODE (Execution modes)
FilterWheelSt FWS
Filter Wheel.
int ccdvbin
Vertical binning value.
void D_Print_BIL_H_ASCII(int mod, FILE *fff)
paramini Paramini
structure for the parameters defined in param.ini configuration file
int DB_Column(char *sourcefilename)
Column format.