#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <malloc.h>
#include <conio.h>
struct camera {
double expo;
double temp;
int gain;
int vbin;
int hbin;
}CAM;
{
double t;
char buf[256];
puts("");
printf("Time exp. : [%.3lf], CCD Gain: [%d], Binning (HxV): [%dx%d]\n", CAM.expo, CAM.gain, CAM.hbin, CAM.vbin);
}
void Menu(void)
{
puts(" Available commands:\n");
puts("1 - Time exposure");
puts("2 - Vertical binning");
puts("3 - Horizzontal binning");
puts("4 - Square binning");
puts("5 - CCD Gain");
puts("6 - Set temperature");
puts("7 - Get an Image");
puts("8 - Get a Dark image");
puts("9 - Get Region of interest");
puts("D - Dump image");
puts("F - Save current image");
puts("N - Get # frames");
puts("S - Show current status");
puts("T - GetCCD with hardware trigger");
puts("P - Set cooler power");
puts("x - Stop Background");
puts("X - Start Background");
puts("Q - Exit\n");
printf("Command: ");
}
void __stdcall expo(const char *str)
{
printf("Expose: %s\r", str);
}
void __stdcall vrange(const char *str, int perc)
{
static int vopen, vclose;
if(str == NULL && vopen)
{
vclose = 1;
putchar('*');
}
if(str != NULL && vopen == 0)
{
vopen = 1;
printf("\n%s [", str);
}
if(perc == 100 && vclose)
{
vopen = vclose = 0;
puts("]");
}
}
void Pause(void)
{
puts("Press any key to continue....");
_getch();
}
{
int y;
for(y = 0; y < 16384; y++)
{
if((y % 8) == 0)
{
printf("\n[%05d] %05u ", y, mem[y]);
}
else
printf("%05u ", mem[y]);
}
puts("");
}
{
int fd, y, n = (DC_CCD.
dx / CAM.hbin) << 1;
fd = open(str, O_WRONLY | O_CREAT |
O_BINARY, S_IWRITE);
if(fd >= 0)
{
for(y = 0; y < (DC_CCD.
dy / CAM.vbin); y++)
{
write(fd, ptr, n);
ptr += (DC_CCD.
dx / CAM.hbin);
}
close(fd);
}
else printf("Error! Image not saved\n");
}
void Input(char *tit, char *buf)
{
printf("\n%s", tit);
gets(buf);
puts("");
}
int main()
{
char buf[256], com, par[256];
long sn;
double a;
CAM.expo = 0.01;
CAM.vbin = 1;
CAM.hbin = 1;
printf("\nTest Program for DTA DCL Library, Rev.%s\n\n", buf);
Pause();
{
printf("I/O error reading camera config\n");
return 1;
}
if(er)
{
Pause();
}
else
{
printf("\nCamera Found. SN [%lu]\n\n", sn);
mem = malloc((
size_t) ((
long) DC_CCD.
dx * (
long) DC_CCD.
dy * 2));
if(mem)
{
do
{
Menu();
com = _getche();
switch(com)
{
case '0': Input("A/D channel (0-7): ", buf);
sscanf(buf, "%d", &n);
break;
case '1': Input("Time Exp.: ", buf);
sscanf(buf, "%lf", &CAM.expo);
break;
case '2': Input("V. Bin: ", buf);
sscanf(buf, "%d", &CAM.vbin);
break;
case '3': Input("H. Bin: ", buf);
sscanf(buf, "%d", &CAM.hbin);
break;
case '4': Input("Binning: ", buf);
sscanf(buf, "%d", &CAM.hbin);
CAM.vbin = CAM.hbin;
break;
case '5': Input("Gain: ", buf);
sscanf(buf, "%d", &CAM.gain);
break;
case '6': Input("CCD Temp.: ", buf);
sscanf(buf, "%lf", &CAM.temp);
break;
break;
break;
case '9': Input("X Start: ", buf);
sscanf(buf, "%d", &p[0]);
Input("Y Start: ", buf);
sscanf(buf, "%d", &p[1]);
Input("X Width: ", buf);
sscanf(buf, "%d", &p[2]);
Input("Y Width: ", buf);
sscanf(buf, "%d", &p[3]);
break;
case 'd':
case 'D': Dump(mem);
break;
case 'f':
case 'F': Input("File name: ", buf);
break;
case 'n':
case 'N': Input("Frames: ", buf);
Input("Save the images (Y/N): ", par);
sscanf(buf, "%d", &n);
for(c = 0; c < n; c++)
{
printf("Image %d of %d\n", c, n);
if(par[0] == 'y' || par[0] == 'Y')
{
sprintf(buf, "frame_%04d.raw", c);
}
}
break;
case 'e': printf(
"\nEnvironment temperature = %.lf\n", (((
F64)
DC_GetAD(1, Cfg.
FDL_PCI_Index) * (2.5 / 4096) * 10e2 / 4.99 - 273.15)));
break;
case 's':
break;
case 'p':
case 'P':
Input("Cooler Power: ", buf);
sscanf(buf, "%lf", &a);
break;
case 'q':
case 'Q':
break;
case 't':
case 'T':
break;
break;
break;
default: puts("Unknown command");
}
if(er)
{
Pause();
break;
}
}while(com != 'Q' && com != 'q');
}
else
{
puts("Memory allocation error!");
return 1;
}
free(mem);
}
return 0;
}