diff --git a/APOGEE_cameras/apogee.c b/APOGEE_cameras/apogee.c index ba1466f..791e19c 100644 --- a/APOGEE_cameras/apogee.c +++ b/APOGEE_cameras/apogee.c @@ -193,6 +193,12 @@ static int setbitdepth(int i){ return TRUE; } +static int getbitdepth(uint8_t *d){ + if(!d) return TRUE; + *d = (is16bit) ? 16 : 12; + return TRUE; +} + static int setfastspeed(int fast){ DBG("set fast speed %d", fast); unsigned short spd = (fast) ? AdcSpeed_Fast : AdcSpeed_Normal; @@ -359,6 +365,7 @@ cc_Camera camera = { .setfanspeed = setfanspd, // getters: .getbrightness = fpfalse, + .getbitpix = getbitdepth, .getModelName = modelname, .getgain = fpfalse, .getmaxgain = fpfalse, diff --git a/Astar_cameras/artifical_star.c b/Astar_cameras/artifical_star.c index 2b81bea..ee3cb99 100644 --- a/Astar_cameras/artifical_star.c +++ b/Astar_cameras/artifical_star.c @@ -33,32 +33,128 @@ extern cc_Camera camera; extern cc_Focuser focuser; extern cc_Wheel wheel; +// array size +#define ARRAYH (1050) +#define ARRAYW (1050) + static const int filtermax = 5; static const float focmaxpos = 10.; -static int curhbin = 1, curvbin = 1; static int filterpos = 0; static float focuserpos = 1., brightness = 1., gain = 0.; -static float camtemp = -30., exptime = 0.; +static float camtemp = -30., exptime = 0.1; static cc_capture_status capstat = CAPTURE_NO; static double texpstart = 0.; static uint8_t bitpix = 16; // bit depth: 8 or 16 typedef struct{ - int width; int height; // size of field where the 'star' can move int x0; int y0; // center of star field in array coordinates - double fwhm; // stars FWHM, arcsec + double fwhm; // stars min FWHM, arcsec + double beta; // Moffat `beta` parameter + double theta; // start theta, arcsec double scale; // CCD scale: arcsec/pix - double mag; // star magnitude: 0m is 16384 ADUs per second per arcsec^2 + double mag; // star magnitude: 0m is 0xffff/0xff ADUs per second + double vX; // X axe drift speed (arcsec/s) + double vY; // Y -//- + double fluct; // stars position fluctuations (arcsec/sec) } settings_t; static settings_t settings = { - .width = 500, .height = 500, .x0 = 512, .y0 = 512, - .fwhm = 1.5, .scale = 0.03, .mag = 10. + .fwhm = 1.5, .beta = 1., .scale = 0.03, .mag = 0., + .fluct = 0.5 }; // min/max for parameters -static const int wmin = 100, hmin = 100; static const double fwhmmin = 0.1, fwhmmax = 10., scalemin = 0.001, scalemax = 3600., magmin = -30., magmax = 30.; +static const double vmin = -20., vmax = 20., fluctmin = 0., fluctmax = 3., betamin = 0.5; +static double dX = 0., dY = 0.; // current "sky" coordinates (arcsec) relative to field center (according vdrift) +static int Xc = 0, Yc = 0; // current pixel coordinates of "sky" center (due to current image size, clip and scale) + fluctuations +static double Tstart = -1.; // global acquisition start +static double Xfluct = 0., Yfluct = 0.; // fluctuation additions in arcsec +static il_Image *star = NULL; // template of star 0m +static double FWHM0 = 0., scale0 = 0.; // template fwhm/scale +static int templ_wh = 0; // template width/height in pixels + +/** + * @brief test_template - test star template and recalculate new if need + */ +static void test_template(){ + if(star && FWHM0 == settings.fwhm && scale0 == settings.scale) return; + templ_wh = (1 + 6*settings.fwhm/settings.scale); // +1 for center + FWHM0 = settings.fwhm; + scale0 = settings.scale; + il_Image_free(&star); + star = il_Image_star(IMTYPE_D, templ_wh, templ_wh, settings.fwhm, settings.beta); + //il_Image_minmax(star); + //DBG("STAR: %dx%d, max=%g, min=%g, %d bytes per pix, type %d; templ_wh=%d", star->height, star->width, star->maxval, star->minval, star->pixbytes, star->type, templ_wh); + double sum = 0., *ptr = (double*)star->data; + int l = templ_wh * templ_wh; + for(int i = 0; i < l; ++i) sum += ptr[i]; + //green("sum=%g\n", sum); + OMP_FOR() + for(int i = 0; i < l; ++i) ptr[i] /= sum; +} + +/* + * About star[s] model + * Star magnitude 0m is approximately full signal level over square second. + * Star image generates in circle with raduis 3FWHM'' (3FWHM/scale pix), so amplitude + * of star (max value) will be calculated as + * 0xffff (0xff for 8bit image) / sum(I1(x,y)), where I1 is generated star image with amplitude 1. + * Flux for magnutude `mag`: Im = I0 * 10^(-0.4mag) + * 1. Generate `star` with ampl=1 in radius 3FWHM/scale pixels for image in `double`. + * 2. Calculate amplitude I = 1/sum(I1(x,y)). + * 3. Multiply all template values by I. + * 4. Fill every `star` from this template with factor 0xffff[0xff]*10^(-0.4mag). + * 5. Add background and noice. + */ + +static void gen16(cc_IMG *ima){ + static int n = 0; + register int w = ima->w; + int h = ima->h, tw2 = templ_wh/2, X0,Y0, X1,Y1, x0,y0; + if(Xc - tw2 < 0){ + X0 = tw2 - Xc; + x0 = 0; + }else{ + X0 = 0; x0 = Xc - tw2; + } + if(Yc - tw2 < 0){ + Y0 = tw2 - Yc; + y0 = 0; + }else{ + Y0 = 0; y0 = Yc - tw2; + } + if(Xc + tw2 > w-1){ + X1 = templ_wh - Xc + tw2 - w - 1; // templ_wh - (Xc + tw2 - (w - 1)) + }else X1 = templ_wh; + if(Yc + tw2 > h-1){ + Y1 = templ_wh - Yc + tw2 - h - 1; + }else Y1 = templ_wh; + double mul = exptime * 0xffff * pow(10, -0.4*settings.mag); // multiplier due to "star" magnitude + // check if the 'star' out of frame + DBG("X0=%d, X1=%d, Y0=%d, Y1=%d, x0=%d, y0=%d, mul=%g", X0,X1,Y0,Y1,x0,y0, mul); + if(X0 < 0 || X0 > templ_wh - 1 || Y0 < 0 || Y0 > templ_wh - 1) return; + if(x0 < 0 || x0 > w-1 || y0 < 0 || y0 > h-1) return; + if(X1 < 0 || X1 > templ_wh || Y1 < 0 || Y1 > templ_wh) return; + if(X0 > X1 || Y0 > Y1) return; + OMP_FOR() + for(int y = Y0; y < Y1; ++y){ + uint16_t *out = &((uint16_t*)ima->data)[(y+y0)*w + x0]; + double *in = &((double*)star->data)[y*templ_wh + X0]; + for(int x = X0; x < X1; ++x, ++in, ++out){ + double val = *in * mul; + *out = (val > 0xffff) ? 0xffff : (uint16_t)val; + } + } + ++n; +} +/* +static void gen8(cc_IMG *ima){ + static int n = 0; + OMP_FOR() + ; + ++n; +}*/ static int campoll(cc_capture_status *st, float *remain){ if(capstat != CAPTURE_PROCESS){ @@ -80,46 +176,45 @@ static int campoll(cc_capture_status *st, float *remain){ static int startexp(){ if(capstat == CAPTURE_PROCESS) return FALSE; capstat = CAPTURE_PROCESS; - texpstart = dtime(); + double Tnow = dtime(), dT = Tnow - texpstart; + if(dT < 0.) dT = 0.; + else if(dT > 1.) dT = 1.; // dT for fluctuations amplitude + if(Tstart < 0.) Tstart = Tnow; + texpstart = Tnow; + // recalculate center of field coordinates at moment of exp start + dX += (dtime() - Tstart) * settings.vX; + dY += (dtime() - Tstart) * settings.vY; + Xc = dX/settings.scale + settings.x0 - camera.array.xoff; + Yc = dY/settings.scale + settings.y0 - camera.array.yoff; + DBG("dX=%g, dY=%g; Xc=%d, Yc=%d", dX, dY, Xc, Yc); + // add fluctuations + double fx = settings.fluct * dT * (2.*drand48() - 1.); // [-fluct*dT, +fluct*dT] + double fy = settings.fluct * dT * (2.*drand48() - 1.); + DBG("fx=%g, fy=%g, Xfluct=%g, Yfluct=%g", fx,fy,Xfluct,Yfluct); + if(Xfluct + fx < -settings.fluct || Xfluct + fx > settings.fluct) Xfluct -= fx; + else Xfluct += fx; + if(Yfluct + fy < -settings.fluct || Yfluct + fy > settings.fluct) Yfluct -= fy; + else Yfluct += fy; + DBG("Xfluct=%g, Yfluct=%g, pix: %g/%g\n\n", Xfluct, Yfluct, Xfluct/settings.scale, Yfluct/settings.scale); + Xc += Xfluct/settings.scale; Yc += Yfluct/settings.scale; + test_template(); return TRUE; } -static void gen16(cc_IMG *ima){ - static int n = 0; - int y1 = ima->h * curvbin, x1 = ima->w * curhbin; - OMP_FOR() - for(int y = 0; y < y1; y += curvbin){ - uint16_t *d = &((uint16_t*)ima->data)[y*ima->w/curvbin]; - for(int x = 0; x < x1; x += curhbin){ // sinusoide 100x200 - //*d++ = (uint16_t)(((n+x)%100)/99.*65535.); - *d++ = (uint16_t)((1. + sin((n+x) * (2.*M_PI)/11.)*sin((n+y) * (2.*M_PI)/22.))*32767.); - } - } - ++n; -} -static void gen8(cc_IMG *ima){ - static int n = 0; - int y1 = ima->h * curvbin, x1 = ima->w * curhbin; - OMP_FOR() - for(int y = 0; y < y1; y += curvbin){ - uint8_t *d = &((uint8_t*)ima->data)[y*ima->w/curvbin]; - for(int x = 0; x < x1; x += curhbin){ // sinusoide 100x200 - //*d++ = (uint16_t)(((n+x)%100)/99.*65535.); - *d++ = (uint8_t)((1. + sin((n+x) * (2.*M_PI)/11.)*sin((n+y) * (2.*M_PI)/22.))*127.); - } - } - ++n; -} static int camcapt(cc_IMG *ima){ + DBG("Prepare, xc=%d, yc=%d, bitpix=%d", Xc, Yc, bitpix); if(!ima || !ima->data) return FALSE; #ifdef EBUG double t0 = dtime(); #endif ima->bitpix = bitpix; + ima->w = camera.geometry.w; + ima->h = camera.geometry.h; + ima->bytelen = ima->w*ima->h*cc_getNbytes(ima); bzero(ima->data, ima->h*ima->w*cc_getNbytes(ima)); if(bitpix == 16) gen16(ima); - else gen8(ima); + // else gen8(ima); DBG("Time of capture: %g", dtime() - t0); return TRUE; } @@ -183,10 +278,9 @@ static int gett(float *t){ return TRUE; } -static int camsetbin(int h, int v){ - DBG("set bin %dx%d", h, v); - curhbin = h; curvbin = v; - return TRUE; +// Binning not supported, change scale instead! +static int camsetbin(int _U_ h, int _U_ v){ + return FALSE; } static int camshutter(_U_ cc_shutter_op s){ @@ -195,12 +289,15 @@ static int camshutter(_U_ cc_shutter_op s){ static int camsetgeom(cc_frameformat *f){ if(!f) return FALSE; + if(f->xoff > ARRAYW-2 || f->yoff > ARRAYH-2) return FALSE; + if(f->xoff < 0 || f->yoff < 0 || f->h < 0 || f->w < 0) return FALSE; + if(f->h + f->yoff > ARRAYH || f->w + f->xoff > ARRAYW) return FALSE; camera.geometry = *f; return TRUE; } static int camgetnam(char *n, int l){ - strncpy(n, "Dummy camera", l); + strncpy(n, "Star generator", l); return TRUE; } @@ -216,8 +313,8 @@ static int camggl(cc_frameformat *max, cc_frameformat *step){ } static int camgetbin(int *binh, int *binv){ - if(binh) *binh = curhbin; - if(binv) *binv = curvbin; + if(binh) *binh = 1; + if(binv) *binv = 1; return TRUE; } @@ -282,14 +379,16 @@ static int whlgetnam(char *n, int l){ // cmd, help, handler, ptr, min, max, type static cc_parhandler_t handlers[] = { - {"width", "width of star moving field", NULL, (void*)&settings.width, (void*)&wmin, NULL, CC_PAR_INT}, - {"height", "height of star moving field", NULL, (void*)&settings.height, (void*)&hmin, NULL, CC_PAR_INT}, {"xc", "x center of field in array coordinates", NULL, (void*)&settings.x0, NULL, NULL, CC_PAR_INT}, {"yc", "y center of field in array coordinates", NULL, (void*)&settings.y0, NULL, NULL, CC_PAR_INT}, - {"fwhm", "star FWHM, arcsec", NULL, (void*)&settings.fwhm, (void*)&fwhmmin, (void*)&fwhmmax, CC_PAR_DOUBLE}, + {"fwhm", "stars min FWHM, arcsec", NULL, (void*)&settings.fwhm, (void*)&fwhmmin, (void*)&fwhmmax, CC_PAR_DOUBLE}, {"scale", "CCD scale: arcsec/pix", NULL, (void*)&settings.scale, (void*)&scalemin, (void*)&scalemax, CC_PAR_DOUBLE}, - {"mag", "star magnitude: 0m is 16384 ADUs per second per arcsec^2", NULL, (void*)&settings.mag, (void*)&magmin, (void*)&magmax, CC_PAR_DOUBLE}, - //{"", "", NULL, (void*)&, (void*)&, (void*)&settings., CC_PAR_DOUBLE}, + {"mag", "star magnitude: 0m is 0xffff/0xff (16/8 bit) ADUs per second", NULL, (void*)&settings.mag, (void*)&magmin, (void*)&magmax, CC_PAR_DOUBLE}, + {"vx", "X axe drift speed (arcsec/s)", NULL, (void*)&settings.vX, (void*)&vmin, (void*)&vmax, CC_PAR_DOUBLE}, + {"vy", "Y axe drift speed (arcsec/s)", NULL, (void*)&settings.vY, (void*)&vmin, (void*)&vmax, CC_PAR_DOUBLE}, + {"fluct", "stars position fluctuations (arcsec per sec)", NULL, (void*)&settings.fluct, (void*)&fluctmin, (void*)&fluctmax, CC_PAR_DOUBLE}, + {"beta", "Moffat `beta` parameter", NULL, (void*)&settings.beta, (void*)&betamin, NULL, CC_PAR_DOUBLE}, + //{"", "", NULL, (void*)&settings., (void*)&, (void*)&, CC_PAR_DOUBLE}, CC_PARHANDLER_END }; @@ -350,8 +449,8 @@ __attribute__ ((visibility("default"))) cc_Camera camera = { .pixX = 10., .pixY = 10., .field = (cc_frameformat){.h = 1024, .w = 1024, .xoff = 10, .yoff = 10}, - .array = (cc_frameformat){.h = 1050, .w = 1050, .xoff = 0, .yoff = 0}, - .geometry = {0}, + .array = (cc_frameformat){.h = ARRAYH, .w = ARRAYW, .xoff = 0, .yoff = 0}, + .geometry = {.xoff = 10, .yoff = 10, .h = 1024, .w = 1024}, }; __attribute__ ((visibility("default"))) cc_Focuser focuser = { diff --git a/BASLER_cameras/basler.c b/BASLER_cameras/basler.c index 3371010..638dc66 100644 --- a/BASLER_cameras/basler.c +++ b/BASLER_cameras/basler.c @@ -29,7 +29,7 @@ extern cc_Camera camera; static PYLON_DEVICE_HANDLE hDev; -static int isopened = FALSE, is16bit = FALSE; +static int isopened = FALSE, bitdepth = 16; static char camname[BUFSIZ] = {0}; static size_t payloadsize = 0; // size of imgBuf static unsigned char *imgBuf = NULL; @@ -296,11 +296,12 @@ static int setdevno(int N){ static int setbitdepth(int depth){ #define MONON 4 const char *fmts[MONON] = {"Mono16", "Mono14", "Mono12", "Mono10"}; + const int depths[MONON] = {16, 14, 12, 10}; if(depth == 0){ // 8 bit if(!PylonDeviceFeatureIsAvailable( hDev, "EnumEntry_PixelFormat_Mono8" )) return FALSE; PYLONFN(PylonDeviceFeatureFromString, hDev, "PixelFormat", "Mono8"); green("Pixel format: Mono8\n"); - is16bit = FALSE; + bitdepth = 8; DBG("8 bit"); }else{ // 16 bit char buf[128]; @@ -310,12 +311,12 @@ static int setbitdepth(int depth){ if(!PylonDeviceFeatureIsAvailable( hDev, buf)) continue; green("Pixel format: %s\n", fmts[i]); PYLONFN(PylonDeviceFeatureFromString, hDev, "PixelFormat", fmts[i]); + bitdepth = depths[i]; break; } if(i == MONON) return FALSE; #undef MONON - is16bit = TRUE; - DBG("16 bit"); + DBG("other bits"); } PYLON_STREAMGRABBER_HANDLE hGrabber; PYLONFN(PylonDeviceGetStreamGrabber, hDev, 0, &hGrabber); @@ -328,6 +329,12 @@ static int setbitdepth(int depth){ return TRUE; } +static int getbitdepth(uint8_t *d){ + if(!d) return TRUE; + *d = bitdepth; + return TRUE; +} + // stub function: the capture process is blocking static int pollcapt(cc_capture_status *st, float *remain){ if(st) *st = CAPTURE_READY; @@ -369,7 +376,7 @@ static int capture(cc_IMG *ima){ } int width = grabResult.SizeX, height = grabResult.SizeY, stride = grabResult.SizeX + grabResult.PaddingX; //TIMESTAMP("start converting"); - if(is16bit){ + if(bitdepth > 8){ int s2 = stride<<1; OMP_FOR() for(int y = 0; y < height; ++y){ @@ -388,7 +395,7 @@ static int capture(cc_IMG *ima){ } } //TIMESTAMP("image ready"); - ima->bitpix = (is16bit) ? 16 : 8; + ima->bitpix = bitdepth; return TRUE; } @@ -526,6 +533,7 @@ cc_Camera camera = { .setfanspeed = setfanspd, // getters: .getbrightness = fpfalse, + .getbitpix = getbitdepth, .getModelName = modelname, .getgain = getgain, .getmaxgain = gainmax, diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f300cd..fc5eee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,11 +29,6 @@ option(ASTAR "Artifical star plugin" OFF) # default flags set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -Wextra -fno-builtin-strlen") -# change wrong behaviour with install prefix -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local") - message("Change default install path to /usr") - set(CMAKE_INSTALL_PREFIX "/usr") -endif() message("Install dir prefix: ${CMAKE_INSTALL_PREFIX}") if(NOT DEFINED LOCALEDIR) if(DEBUG) @@ -87,6 +82,7 @@ if(IMAGEVIEW) list(APPEND ${PROJ}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) add_definitions(-DIMAGEVIEW) endif() + # Dummy and artifical star plugins if(DUMMY) add_subdirectory(Dummy_cameras) diff --git a/FLI_cameras/CMakeLists.txt b/FLI_cameras/CMakeLists.txt index fb9dc23..5f47ded 100644 --- a/FLI_cameras/CMakeLists.txt +++ b/FLI_cameras/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.20) set(CCDLIB devfli) +SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(${CCDLIB} REQUIRED fli>=1.71 usefull_macros) diff --git a/FindCFITSIO.cmake b/FindCFITSIO.cmake index 01dd612..0ad88b9 100644 --- a/FindCFITSIO.cmake +++ b/FindCFITSIO.cmake @@ -58,7 +58,7 @@ else (CFITSIO_INCLUDE_DIR AND CFITSIO_LIBRARIES) endif (NOT CFITSIO_FIND_QUIETLY) else (CFITSIO_FOUND) if (CFITSIO_FIND_REQUIRED) - message(STATUS "CFITSIO not found.") + message(FATAL_ERROR "CFITSIO not found.") endif (CFITSIO_FIND_REQUIRED) endif (CFITSIO_FOUND) diff --git a/HIKROBOT_cameras/CMakeLists.txt b/HIKROBOT_cameras/CMakeLists.txt index 43ad706..e8f06f4 100644 --- a/HIKROBOT_cameras/CMakeLists.txt +++ b/HIKROBOT_cameras/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.20) set(CCDLIB devhikrobot) +SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(${CCDLIB} REQUIRED mvs>=2.1 usefull_macros) diff --git a/ZWO_cameras/CMakeLists.txt b/ZWO_cameras/CMakeLists.txt index 3e30d9b..e25d39d 100644 --- a/ZWO_cameras/CMakeLists.txt +++ b/ZWO_cameras/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.20) set(CCDLIB devzwo) +SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(${CCDLIB} REQUIRED usefull_macros) diff --git a/ccdcapture.h b/ccdcapture.h index 3209da4..0cc71c3 100644 --- a/ccdcapture.h +++ b/ccdcapture.h @@ -101,8 +101,8 @@ typedef enum{ RESULT_NUM } cc_hresult; -// all setters and getters of Camera, Focuser and cc_Wheel should return TRUE if success or FALSE if failed or unsupported -// camera +// all setters and getters of Camera, Focuser and cc_Wheel should return TRUE if success or FALSE if failed or unsupported camera +// each camera plugin must have functions check, startexposition, setexp, pollcapture and capture typedef struct{ int (*check)(); // check if the device is available, connect and init int Ndevices; // amount of devices found @@ -123,7 +123,7 @@ typedef struct{ int (*confio)(int s); // configure IO-port int (*setio)(int s); // set IO-port to given state int (*setframetype)(int l); // set frametype: 1 - light, 0 - dark - int (*setbitdepth)(int h); // set bit depth : 1 - high (16 bit), 0 - low (8 bit) + int (*setbitdepth)(int h); // set bit depth : 1 - high (16 bit), 0 - low (8 or other bit) int (*setfastspeed)(int s); // set readout speed: 1 - fast, 0 - low // geometry (if TRUE, all args are changed to suitable values) int (*setgeometry)(cc_frameformat *fmt); // set geometry in UNBINNED coordinates diff --git a/ccdfunc.c b/ccdfunc.c index 1c31fd2..545702e 100644 --- a/ccdfunc.c +++ b/ccdfunc.c @@ -535,12 +535,16 @@ static void closeall(){ static cc_capture_status capt(){ cc_capture_status cs; float tremain, tmpf; + if(!camera->pollcapture){ + WARNX(_("Camera plugin have no capture polling funtion.")); + return CAPTURE_ABORTED; + } while(camera->pollcapture(&cs, &tremain)){ if(cs != CAPTURE_PROCESS) break; if(tremain > 0.1){ verbose(2, _("%.1f seconds till exposition ends"), tremain); - if(camera->getTcold(&tmpf)) verbose(1, "CCDTEMP=%.1f", tmpf); - if(camera->getTbody(&tmpf)) verbose(1, "BODYTEMP=%.1f", tmpf); + if(camera->getTcold && camera->getTcold(&tmpf)) verbose(1, "CCDTEMP=%.1f", tmpf); + if(camera->getTbody && camera->getTbody(&tmpf)) verbose(1, "BODYTEMP=%.1f", tmpf); } if(tremain > 6.) sleep(5); else if(tremain > 0.9) sleep((int)(tremain+0.99)); @@ -570,7 +574,7 @@ cc_Camera *startCCD(){ void closecam(){ if(!camera) return; DBG("Close cam"); - camera->close(); + if(camera->close) camera->close(); camera = NULL; } @@ -581,8 +585,9 @@ int prepare_ccds(){ void *dlh = NULL; if(!startCCD(&dlh)) return FALSE; if(GP->listdevices){ - for(int i = 0; i < camera->Ndevices; ++i){ - if(!camera->setDevNo(i)) continue; + if(!camera->getModelName) WARNX(_("Camera plugin have no model name getter")); + else for(int i = 0; i < camera->Ndevices; ++i){ + if(camera->setDevNo && !camera->setDevNo(i)) continue; char modname[256]; camera->getModelName(modname, 255); printf("Found camera #%d: %s\n", i, modname); @@ -594,7 +599,7 @@ int prepare_ccds(){ WARNX(_("Found %d cameras, you point number %d"), camera->Ndevices, num); goto retn; } - if(!camera->setDevNo(num)){ + if(camera->setDevNo && !camera->setDevNo(num)){ WARNX(_("Can't set active camera number")); goto retn; } @@ -621,13 +626,16 @@ int prepare_ccds(){ } if(GP->fanspeed > -1){ if(GP->fanspeed > FAN_HIGH) GP->fanspeed = FAN_HIGH; - if(!camera->setfanspeed((cc_fan_speed)GP->fanspeed)) - WARNX(_("Can't set fan speed")); - else verbose(0, _("Set fan speed to %d"), GP->fanspeed); + if(!camera->setfanspeed) WARNX(_("Camera plugin have no fun speed setter")); + else{ + if(!camera->setfanspeed((cc_fan_speed)GP->fanspeed)) + WARNX(_("Can't set fan speed")); + else verbose(0, _("Set fan speed to %d"), GP->fanspeed); + } } int x0,x1, y0,y1; char buf[BUFSIZ]; - if(camera->getModelName(buf, BUFSIZ)) + if(camera->getModelName && camera->getModelName(buf, BUFSIZ)) verbose(2, _("Camera model: %s"), buf); verbose(2, _("Pixel size: %g x %g"), camera->pixX, camera->pixY); x0 = camera->array.xoff; @@ -643,56 +651,57 @@ int prepare_ccds(){ camera->geometry.xoff + camera->geometry.w, camera->geometry.yoff + camera->geometry.h); verbose(2, _("Current format: %s"), buf); if(!isnan(GP->temperature)){ - if(!camera->setT((float)GP->temperature)) - WARNX(_("Can't set T to %g degC"), GP->temperature); - verbose(3, "SetT=%.1f", GP->temperature); + if(!camera->setT)WARNX(_("Camera plugin have no temperature setter")); + else{if(!camera->setT((float)GP->temperature)) WARNX(_("Can't set T to %g degC"), GP->temperature); + else verbose(3, "SetT=%.1f", GP->temperature); + } } float tmpf; - if(camera->getTcold(&tmpf)) verbose(1, "CCDTEMP=%.1f", tmpf); - if(camera->getTbody(&tmpf)) verbose(1, "BODYTEMP=%.1f", tmpf); + if(camera->getTcold && camera->getTcold(&tmpf)) verbose(1, "CCDTEMP=%.1f", tmpf); + if(camera->getTbody && camera->getTbody(&tmpf)) verbose(1, "BODYTEMP=%.1f", tmpf); if(GP->shtr_cmd > -1 && GP->shtr_cmd < SHUTTER_AMOUNT){ const char *str[] = {"open", "close", "expose @high", "expose @low"}; verbose(1, _("Shutter command: %s\n"), str[GP->shtr_cmd]); - if(!camera->shuttercmd((cc_shutter_op)GP->shtr_cmd)) + if(!camera->shuttercmd || !camera->shuttercmd((cc_shutter_op)GP->shtr_cmd)) WARNX(_("Can't run shutter command %s (unsupported?)"), str[GP->shtr_cmd]); } if(GP->confio > -1){ verbose(1, _("Try to configure I/O port as %d"), GP->confio); - if(!camera->confio(GP->confio)) + if(!camera->confio || !camera->confio(GP->confio)) WARNX(_("Can't configure (unsupported?)")); } int tmpi; if(GP->getio){ - if(camera->getio(&tmpi)) + if(camera->getio && camera->getio(&tmpi)) verbose(0, "CCDIOPORT=0x%02X\n", tmpi); else WARNX(_("Can't get IOport state (unsupported?)")); } if(GP->setio > -1){ verbose(1, _("Try to write %d to I/O port"), GP->setio); - if(!camera->setio(GP->setio)) + if(!camera->setio || !camera->setio(GP->setio)) WARNX(_("Can't set IOport")); } if(GP->exptime < 0.) goto retn; if(!isnan(GP->gain)){ DBG("Change gain to %g", GP->gain); - if(camera->setgain(GP->gain)){ - camera->getgain(&GP->gain); + if(camera->setgain && camera->setgain(GP->gain)){ + if(camera->getgain) camera->getgain(&GP->gain); verbose(1, _("Set gain to %g"), GP->gain); }else WARNX(_("Can't set gain to %g"), GP->gain); } if(!isnan(GP->brightness)){ - if(camera->setbrightness(GP->brightness)){ - camera->getbrightness(&GP->brightness); + if(camera->setbrightness && camera->setbrightness(GP->brightness)){ + if(camera->getbrightness) camera->getbrightness(&GP->brightness); verbose(1, _("Set brightness to %g"), GP->brightness); }else WARNX(_("Can't set brightness to %g"), GP->brightness); } /*********************** expose control ***********************/ if(GP->hbin < 1) GP->hbin = 1; if(GP->vbin < 1) GP->vbin = 1; - if(!camera->setbin(GP->hbin, GP->vbin)){ + if(!camera->setbin || !camera->setbin(GP->hbin, GP->vbin)){ WARNX(_("Can't set binning %dx%d"), GP->hbin, GP->vbin); - camera->getbin(&GP->hbin, &GP->vbin); + if(camera->getbin) camera->getbin(&GP->hbin, &GP->vbin); } if(GP->X0 < 0) GP->X0 = x0; // default values else if(GP->X0 > x1-1) GP->X0 = x1-1; @@ -702,28 +711,29 @@ int prepare_ccds(){ if(GP->Y1 < GP->Y0+1 || GP->Y1 > y1) GP->Y1 = y1; DBG("x1/x0: %d/%d", GP->X1, GP->X0); cc_frameformat fmt = {.w = GP->X1 - GP->X0, .h = GP->Y1 - GP->Y0, .xoff = GP->X0, .yoff = GP->Y0}; - if(!camera->setgeometry(&fmt)) + if(!camera->setgeometry || !camera->setgeometry(&fmt)) WARNX(_("Can't set given geometry")); verbose(3, "Geometry: off=%d/%d, wh=%d/%d", fmt.xoff, fmt.yoff, fmt.w, fmt.h); if(GP->nflushes > 0){ - if(!camera->setnflushes(GP->nflushes)) + if(!camera->setnflushes || !camera->setnflushes(GP->nflushes)) WARNX(_("Can't set %d flushes"), GP->nflushes); else verbose(3, "Nflushes=%d", GP->nflushes); } + if(!camera->setexp) ERRX(_("Camera plugin have no exposition setter")); if(!camera->setexp(GP->exptime)) WARNX(_("Can't set exposure time to %f seconds"), GP->exptime); tmpi = (GP->dark) ? 0 : 1; - if(!camera->setframetype(tmpi)) + if(!camera->setframetype || !camera->setframetype(tmpi)) WARNX(_("Can't change frame type")); tmpi = (GP->_8bit) ? 0 : 1; - if(!camera->setbitdepth(tmpi)) + if(!camera->setbitdepth || !camera->setbitdepth(tmpi)) WARNX(_("Can't set bit depth")); - if(!camera->setfastspeed(GP->fast)) + if(!camera->setfastspeed || !camera->setfastspeed(GP->fast)) WARNX(_("Can't set readout speed")); else verbose(1, _("Readout mode: %s"), GP->fast ? "fast" : "normal"); if(!GP->outfile) verbose(1, _("Only show statistics")); // GET binning should be AFTER setgeometry! - if(!camera->getbin(&GP->hbin, &GP->vbin)) + if(!camera->getbin || !camera->getbin(&GP->hbin, &GP->vbin)) WARNX(_("Can't get current binning")); verbose(2, "Binning: %d x %d", GP->hbin, GP->vbin); rtn = TRUE; @@ -749,6 +759,7 @@ DBG("w=%d, h=%d", raw_width, raw_height); TIMESTAMP("Start next cycle"); TIMEINIT(); verbose(1, _("Capture frame %d"), j); + if(!camera->startexposition) ERRX(_("Camera plugin have no function `start exposition`")); if(!camera->startexposition()){ WARNX(_("Can't start exposition")); break; @@ -760,7 +771,7 @@ DBG("w=%d, h=%d", raw_width, raw_height); } verbose(2, _("Read grabbed image")); TIMESTAMP("Read grabbed"); - //if(!camera) return; + if(!camera->capture) ERRX(_("Camera plugin have no function `capture`")); if(!camera->capture(&ima)){ WARNX(_("Can't grab image")); break; @@ -776,8 +787,8 @@ DBG("w=%d, h=%d", raw_width, raw_height); while((delta = time1 - dtime()) > 0.){ verbose(1, _("%d seconds till pause ends\n"), (int)delta); float tmpf; - if(camera->getTcold(&tmpf)) verbose(1, "CCDTEMP=%.1f\n", tmpf); - if(camera->getTbody(&tmpf)) verbose(1, "BODYTEMP=%.1f\n", tmpf); + if(camera->getTcold && camera->getTcold(&tmpf)) verbose(1, "CCDTEMP=%.1f\n", tmpf); + if(camera->getTbody && camera->getTbody(&tmpf)) verbose(1, "BODYTEMP=%.1f\n", tmpf); if(delta > 6.) sleep(5); else if(delta > 0.9) sleep((int)(delta+0.99)); else usleep((int)(delta*1e6 + 1)); @@ -792,8 +803,8 @@ DBG("w=%d, h=%d", raw_width, raw_height); // cancel expositions and close camera devise void camstop(){ if(camera){ - camera->cancel(); - camera->close(); + if(camera->cancel) camera->cancel(); + if(camera->close) camera->close(); } } @@ -823,6 +834,7 @@ static void *grabnext(void *arg){ TIMESTAMP("Start next exp"); TIMEINIT(); if(!ima || !camera) return NULL; + if(!camera->startexposition) ERRX(_("Camera plugin have no function `start exposition`")); if(!camera->startexposition()){ WARNX(_("Can't start exposition")); usleep(10000); @@ -830,13 +842,14 @@ static void *grabnext(void *arg){ } cc_capture_status cs = CAPTURE_ABORTED; TIMESTAMP("Poll"); - while(camera->pollcapture(&cs, NULL)){ + while(camera->pollcapture && camera->pollcapture(&cs, NULL)){ if(cs != CAPTURE_PROCESS) break; usleep(10000); if(!camera) return NULL; } if(cs != CAPTURE_READY){ WARNX(_("Some error when capture")); return NULL;} TIMESTAMP("get"); + if(!camera->capture) ERRX(_("Camera plugin have no function `capture`")); if(!camera->capture(ima)){ WARNX(_("Can't grab image")); continue; } ++ima->imnumber; //calculate_stat(ima); diff --git a/locale/ru/messages.po b/locale/ru/messages.po index a8b0e7c..61fb09a 100644 --- a/locale/ru/messages.po +++ b/locale/ru/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-07 17:00+0300\n" +"POT-Creation-Date: 2024-02-15 16:32+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -358,198 +358,226 @@ msgstr "" msgid "Can't set wheel position %d" msgstr "" -#: ccdfunc.c:541 +#: ccdfunc.c:539 +msgid "Camera plugin have no capture polling funtion." +msgstr "" + +#: ccdfunc.c:545 #, c-format msgid "%.1f seconds till exposition ends" msgstr "" -#: ccdfunc.c:556 +#: ccdfunc.c:560 msgid "Camera device not pointed" msgstr "" -#: ccdfunc.c:563 ccdfunc.c:564 +#: ccdfunc.c:567 ccdfunc.c:568 msgid "No cameras found" msgstr "" -#: ccdfunc.c:594 +#: ccdfunc.c:588 +msgid "Camera plugin have no model name getter" +msgstr "" + +#: ccdfunc.c:599 #, c-format msgid "Found %d cameras, you point number %d" msgstr "" -#: ccdfunc.c:598 +#: ccdfunc.c:603 msgid "Can't set active camera number" msgstr "" -#: ccdfunc.c:604 +#: ccdfunc.c:609 msgid "Camera plugin have no custom commands" msgstr "" -#: ccdfunc.c:625 +#: ccdfunc.c:629 +msgid "Camera plugin have no fun speed setter" +msgstr "" + +#: ccdfunc.c:632 msgid "Can't set fan speed" msgstr "" -#: ccdfunc.c:626 +#: ccdfunc.c:633 #, c-format msgid "Set fan speed to %d" msgstr "" -#: ccdfunc.c:631 +#: ccdfunc.c:639 #, c-format msgid "Camera model: %s" msgstr "" -#: ccdfunc.c:632 +#: ccdfunc.c:640 #, c-format msgid "Pixel size: %g x %g" msgstr "" -#: ccdfunc.c:638 +#: ccdfunc.c:646 #, c-format msgid "Full array: %s" msgstr "" -#: ccdfunc.c:641 +#: ccdfunc.c:649 #, c-format msgid "Field of view: %s" msgstr "" -#: ccdfunc.c:644 +#: ccdfunc.c:652 #, c-format msgid "Current format: %s" msgstr "" -#: ccdfunc.c:647 -#, c-format -msgid "Can't set T to %g degC" +#: ccdfunc.c:654 +msgid "Camera plugin have no temperature setter" msgstr "" #: ccdfunc.c:655 #, c-format +msgid "Can't set T to %g degC" +msgstr "" + +#: ccdfunc.c:664 +#, c-format msgid "Shutter command: %s\n" msgstr "" -#: ccdfunc.c:657 +#: ccdfunc.c:666 #, c-format msgid "Can't run shutter command %s (unsupported?)" msgstr "" -#: ccdfunc.c:660 +#: ccdfunc.c:669 #, c-format msgid "Try to configure I/O port as %d" msgstr "" -#: ccdfunc.c:662 +#: ccdfunc.c:671 msgid "Can't configure (unsupported?)" msgstr "" -#: ccdfunc.c:669 +#: ccdfunc.c:678 msgid "Can't get IOport state (unsupported?)" msgstr "" -#: ccdfunc.c:672 -#, c-format -msgid "Try to write %d to I/O port" -msgstr "" - -#: ccdfunc.c:674 -msgid "Can't set IOport" -msgstr "" - #: ccdfunc.c:681 #, c-format +msgid "Try to write %d to I/O port" +msgstr "" + +#: ccdfunc.c:683 +msgid "Can't set IOport" +msgstr "" + +#: ccdfunc.c:690 +#, c-format msgid "Set gain to %g" msgstr "" -#: ccdfunc.c:682 +#: ccdfunc.c:691 #, c-format msgid "Can't set gain to %g" msgstr "" -#: ccdfunc.c:687 +#: ccdfunc.c:696 #, c-format msgid "Set brightness to %g" msgstr "" -#: ccdfunc.c:688 +#: ccdfunc.c:697 #, c-format msgid "Can't set brightness to %g" msgstr "" -#: ccdfunc.c:694 server.c:265 +#: ccdfunc.c:703 server.c:278 #, c-format msgid "Can't set binning %dx%d" msgstr "" -#: ccdfunc.c:706 server.c:266 +#: ccdfunc.c:715 server.c:279 msgid "Can't set given geometry" msgstr "" -#: ccdfunc.c:710 +#: ccdfunc.c:719 #, c-format msgid "Can't set %d flushes" msgstr "" -#: ccdfunc.c:714 +#: ccdfunc.c:722 +msgid "Camera plugin have no exposition setter" +msgstr "" + +#: ccdfunc.c:724 #, c-format msgid "Can't set exposure time to %f seconds" msgstr "" -#: ccdfunc.c:717 +#: ccdfunc.c:727 msgid "Can't change frame type" msgstr "" -#: ccdfunc.c:720 +#: ccdfunc.c:730 msgid "Can't set bit depth" msgstr "" -#: ccdfunc.c:722 +#: ccdfunc.c:732 msgid "Can't set readout speed" msgstr "" -#: ccdfunc.c:723 +#: ccdfunc.c:733 #, c-format msgid "Readout mode: %s" msgstr "" -#: ccdfunc.c:724 +#: ccdfunc.c:734 msgid "Only show statistics" msgstr "" -#: ccdfunc.c:727 +#: ccdfunc.c:737 msgid "Can't get current binning" msgstr "" -#: ccdfunc.c:751 +#: ccdfunc.c:761 #, c-format msgid "Capture frame %d" msgstr "" -#: ccdfunc.c:753 ccdfunc.c:827 server.c:150 +#: ccdfunc.c:762 ccdfunc.c:837 server.c:149 server.c:150 +msgid "Camera plugin have no function `start exposition`" +msgstr "" + +#: ccdfunc.c:764 ccdfunc.c:839 server.c:155 server.c:156 msgid "Can't start exposition" msgstr "" -#: ccdfunc.c:758 +#: ccdfunc.c:769 msgid "Can't capture image" msgstr "" -#: ccdfunc.c:761 +#: ccdfunc.c:772 msgid "Read grabbed image" msgstr "" -#: ccdfunc.c:765 ccdfunc.c:840 +#: ccdfunc.c:774 ccdfunc.c:852 server.c:173 server.c:174 +msgid "Camera plugin have no function `capture`" +msgstr "" + +#: ccdfunc.c:776 ccdfunc.c:853 msgid "Can't grab image" msgstr "" -#: ccdfunc.c:777 client.c:270 +#: ccdfunc.c:788 client.c:270 #, c-format msgid "%d seconds till pause ends\n" msgstr "" -#: ccdfunc.c:838 +#: ccdfunc.c:850 msgid "Some error when capture" msgstr "" -#: server.c:189 +#: server.c:201 msgid "No camera device" msgstr "" diff --git a/locale/ru/ru.po b/locale/ru/ru.po index c7e138f..325c411 100644 --- a/locale/ru/ru.po +++ b/locale/ru/ru.po @@ -7,7 +7,7 @@ msgid "" msgstr "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" - "POT-Creation-Date: 2024-02-07 17:00+0300\n" + "POT-Creation-Date: 2024-02-15 16:32+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,12 +16,12 @@ msgstr "Project-Id-Version: PACKAGE VERSION\n" "Content-Type: text/plain; charset=koi8-r\n" "Content-Transfer-Encoding: 8bit\n" -#: ccdfunc.c:541 +#: ccdfunc.c:545 #, c-format msgid "%.1f seconds till exposition ends" msgstr "%.1f секунд до окончания экспозиции" -#: ccdfunc.c:777 client.c:270 +#: ccdfunc.c:788 client.c:270 #, c-format msgid "%d seconds till pause ends\n" msgstr "%d секунд до окончания паузы\n" @@ -38,7 +38,7 @@ msgstr " msgid "CMOS gain level" msgstr "уровень Gain CMOS" -#: ccdfunc.c:556 +#: ccdfunc.c:560 msgid "Camera device not pointed" msgstr "Устройство свеоприемника не подключено" @@ -46,32 +46,67 @@ msgstr " msgid "Camera device unknown" msgstr "Устройство свеоприемника не опознано" -#: ccdfunc.c:631 +#: ccdfunc.c:639 #, c-format msgid "Camera model: %s" msgstr "Модель светоприемника: %s" -#: ccdfunc.c:604 +#: ccdfunc.c:539 +#, fuzzy +msgid "Camera plugin have no capture polling funtion." +msgstr "У плагина камеры нет особых команд" + +#: ccdfunc.c:609 msgid "Camera plugin have no custom commands" msgstr "У плагина камеры нет особых команд" -#: ccdfunc.c:758 +#: ccdfunc.c:722 +#, fuzzy +msgid "Camera plugin have no exposition setter" +msgstr "У плагина камеры нет особых команд" + +#: ccdfunc.c:629 +#, fuzzy +msgid "Camera plugin have no fun speed setter" +msgstr "У плагина камеры нет особых команд" + +#: ccdfunc.c:774 ccdfunc.c:852 server.c:173 server.c:174 +#, fuzzy +msgid "Camera plugin have no function `capture`" +msgstr "У плагина камеры нет особых команд" + +#: ccdfunc.c:762 ccdfunc.c:837 server.c:149 server.c:150 +#, fuzzy +msgid "Camera plugin have no function `start exposition`" +msgstr "У плагина камеры нет особых команд" + +#: ccdfunc.c:588 +#, fuzzy +msgid "Camera plugin have no model name getter" +msgstr "У плагина камеры нет особых команд" + +#: ccdfunc.c:654 +#, fuzzy +msgid "Camera plugin have no temperature setter" +msgstr "У плагина камеры нет особых команд" + +#: ccdfunc.c:769 msgid "Can't capture image" msgstr "Не могу захватить изображение" -#: ccdfunc.c:717 +#: ccdfunc.c:727 msgid "Can't change frame type" msgstr "Не могу изменить тип кадра" -#: ccdfunc.c:662 +#: ccdfunc.c:671 msgid "Can't configure (unsupported?)" msgstr "Не могу сконфигурировать (опция не поддерживается?)" -#: ccdfunc.c:669 +#: ccdfunc.c:678 msgid "Can't get IOport state (unsupported?)" msgstr "Не могу получить состояние порта I/O (не поддерживается?)" -#: ccdfunc.c:727 +#: ccdfunc.c:737 msgid "Can't get current binning" msgstr "Не могу получить текущее значение биннинга" @@ -87,7 +122,7 @@ msgstr " msgid "Can't get max wheel position" msgstr "Не могу определить предельную позицию колеса" -#: ccdfunc.c:765 ccdfunc.c:840 +#: ccdfunc.c:776 ccdfunc.c:853 msgid "Can't grab image" msgstr "Не могу захватить изображение" @@ -107,7 +142,7 @@ msgstr " msgid "Can't open OpenGL window, image preview will be inaccessible" msgstr "Не могу открыть окно OpenGL, отображение будет недоступно" -#: ccdfunc.c:657 +#: ccdfunc.c:666 #, c-format msgid "Can't run shutter command %s (unsupported?)" msgstr "Не могу выполнить команду затвора %s (не поддерживается?)" @@ -117,21 +152,21 @@ msgstr " msgid "Can't save file with prefix %s" msgstr "Не могу сохранить файл с префиксом %s" -#: ccdfunc.c:710 +#: ccdfunc.c:719 #, c-format msgid "Can't set %d flushes" msgstr "Не могу установить %d сбросов" -#: ccdfunc.c:674 +#: ccdfunc.c:683 msgid "Can't set IOport" msgstr "Не могу поменять значения порта I/O" -#: ccdfunc.c:647 +#: ccdfunc.c:655 #, c-format msgid "Can't set T to %g degC" msgstr "Не могу установить температуру в %g градЦ" -#: ccdfunc.c:598 +#: ccdfunc.c:603 msgid "Can't set active camera number" msgstr "Не могу установить номер активной камеры" @@ -143,35 +178,35 @@ msgstr " msgid "Can't set active wheel number" msgstr "Не могу установить номер активного колеса" -#: ccdfunc.c:694 server.c:265 +#: ccdfunc.c:703 server.c:278 #, c-format msgid "Can't set binning %dx%d" msgstr "Не могу установить биннинг %dx%d" -#: ccdfunc.c:720 +#: ccdfunc.c:730 msgid "Can't set bit depth" msgstr "Не могу установить разрядность АЦП" -#: ccdfunc.c:688 +#: ccdfunc.c:697 #, c-format msgid "Can't set brightness to %g" msgstr "Не могу установить яркость в %g" -#: ccdfunc.c:714 +#: ccdfunc.c:724 #, c-format msgid "Can't set exposure time to %f seconds" msgstr "Не могу установить экспозицию в %f секунд" -#: ccdfunc.c:625 +#: ccdfunc.c:632 msgid "Can't set fan speed" msgstr "Не могу установить скорость вентиляторов" -#: ccdfunc.c:682 +#: ccdfunc.c:691 #, c-format msgid "Can't set gain to %g" msgstr "Не могу установить Gain в %g" -#: ccdfunc.c:706 server.c:266 +#: ccdfunc.c:715 server.c:279 msgid "Can't set given geometry" msgstr "Не могу установить геометрию" @@ -185,7 +220,7 @@ msgstr " msgid "Can't set position %g: out of limits [%g, %g]" msgstr "Не могу установить позицию %g: вне пределов [%g, %g]" -#: ccdfunc.c:722 +#: ccdfunc.c:732 msgid "Can't set readout speed" msgstr "Не могу установить скорость считывания" @@ -194,16 +229,16 @@ msgstr " msgid "Can't set wheel position %d" msgstr "Не могу установить положение колеса %d" -#: ccdfunc.c:753 ccdfunc.c:827 server.c:150 +#: ccdfunc.c:764 ccdfunc.c:839 server.c:155 server.c:156 msgid "Can't start exposition" msgstr "Не могу начать экспозицию" -#: ccdfunc.c:751 +#: ccdfunc.c:761 #, c-format msgid "Capture frame %d" msgstr "Захват кадра %d" -#: ccdfunc.c:644 +#: ccdfunc.c:652 #, c-format msgid "Current format: %s" msgstr "Текущий формат: %s" @@ -221,7 +256,7 @@ msgstr " msgid "Error saving file" msgstr "Ошибка сохранения файла" -#: ccdfunc.c:641 +#: ccdfunc.c:649 #, c-format msgid "Field of view: %s" msgstr "Поле зрения: %s" @@ -235,7 +270,7 @@ msgstr " msgid "Focuser device not pointed" msgstr "Устройство фокусера не указано" -#: ccdfunc.c:594 +#: ccdfunc.c:599 #, c-format msgid "Found %d cameras, you point number %d" msgstr "Обнаружено %d камер, вы указали %d" @@ -250,7 +285,7 @@ msgstr " msgid "Found %d wheels, you point number %d" msgstr "Обнаружено %d колес, вы указали %d" -#: ccdfunc.c:638 +#: ccdfunc.c:646 #, c-format msgid "Full array: %s" msgstr "Полный формат: %s" @@ -273,11 +308,11 @@ msgstr " msgid "N flushes before exposing (default: 1)" msgstr "N засвечиваний перед экспозицией (по умолчанию: 1)" -#: server.c:189 +#: server.c:201 msgid "No camera device" msgstr "Не указано устройство камеры" -#: ccdfunc.c:563 ccdfunc.c:564 +#: ccdfunc.c:567 ccdfunc.c:568 msgid "No cameras found" msgstr "Камер не обнаружено" @@ -289,20 +324,20 @@ msgstr " msgid "No wheels found" msgstr "Турелей не обнаружено" -#: ccdfunc.c:724 +#: ccdfunc.c:734 msgid "Only show statistics" msgstr "Только отобразить статистику" -#: ccdfunc.c:632 +#: ccdfunc.c:640 #, c-format msgid "Pixel size: %g x %g" msgstr "Размер пикселя: %g x %g" -#: ccdfunc.c:761 +#: ccdfunc.c:772 msgid "Read grabbed image" msgstr "Считывание изображения" -#: ccdfunc.c:723 +#: ccdfunc.c:733 #, c-format msgid "Readout mode: %s" msgstr "Режим считывания: %s" @@ -311,36 +346,36 @@ msgstr " msgid "Server timeout" msgstr "Таймаут сервера" -#: ccdfunc.c:687 +#: ccdfunc.c:696 #, c-format msgid "Set brightness to %g" msgstr "Установить яркость в %g" -#: ccdfunc.c:626 +#: ccdfunc.c:633 #, c-format msgid "Set fan speed to %d" msgstr "Не могу установить скорость вентиляторов в %d" -#: ccdfunc.c:681 +#: ccdfunc.c:690 #, c-format msgid "Set gain to %g" msgstr "Установить Gain в %g" -#: ccdfunc.c:655 +#: ccdfunc.c:664 #, c-format msgid "Shutter command: %s\n" msgstr "Команда затвора: %s\n" -#: ccdfunc.c:838 +#: ccdfunc.c:850 msgid "Some error when capture" msgstr "Ошибка при захвате" -#: ccdfunc.c:660 +#: ccdfunc.c:669 #, c-format msgid "Try to configure I/O port as %d" msgstr "Попытка сконфигурировать порт I/O как %d" -#: ccdfunc.c:672 +#: ccdfunc.c:681 #, c-format msgid "Try to write %d to I/O port" msgstr "Попытка записи %d в порт I/O" diff --git a/server.c b/server.c index d7c472f..28afd5f 100644 --- a/server.c +++ b/server.c @@ -132,7 +132,7 @@ static void fixima(){ DBG("curformat: %dx%d", curformat.w, curformat.h); ima->h = raw_height; ima->w = raw_width; - if(!camera->getbitpix(&ima->bitpix)) ima->bitpix = 16; + if(!camera->getbitpix || !camera->getbitpix(&ima->bitpix)) ima->bitpix = 16; if(ima->bitpix < 8 || ima->bitpix > 16) ima->bitpix = 16; // use maximum in any strange cases ima->bytelen = raw_height * raw_width * cc_getNbytes(ima); DBG("new image: %dx%d", raw_width, raw_height); @@ -145,8 +145,14 @@ static inline void cameraidlestate(){ // idle - wait for capture commands camflags &= ~(FLAG_STARTCAPTURE | FLAG_CANCEL); camstate = CAMERA_CAPTURE; fixima(); + if(!camera->startexposition){ + LOGERR(_("Camera plugin have no function `start exposition`")); + WARNX(_("Camera plugin have no function `start exposition`")); + camstate = CAMERA_ERROR; + return; + } if(!camera->startexposition()){ - LOGERR("Can't start exposition"); + LOGERR(_("Can't start exposition")); WARNX(_("Can't start exposition")); camstate = CAMERA_ERROR; return; @@ -155,7 +161,7 @@ static inline void cameraidlestate(){ // idle - wait for capture commands } static inline void cameracapturestate(){ // capturing - wait for exposition ends cc_capture_status cs; - if(camera->pollcapture(&cs, &tremain)){ + if(camera->pollcapture && camera->pollcapture(&cs, &tremain)){ if(cs != CAPTURE_PROCESS){ TIMESTAMP("Capture ready"); tremain = 0.; @@ -163,6 +169,12 @@ static inline void cameracapturestate(){ // capturing - wait for exposition ends if(!ima->data) LOGERR("Can't save image: not initialized"); else{ TIMESTAMP("start capture"); + if(!camera->capture){ + WARNX(_("Camera plugin have no function `capture`")); + LOGERR(_("Camera plugin have no function `capture`")); + camstate = CAMERA_ERROR; + return; + } if(!camera->capture(ima)){ LOGERR("Can't capture image"); camstate = CAMERA_ERROR; @@ -195,18 +207,19 @@ static void* processCAM(_U_ void *d){ signals(1); } usleep(100); + if(tremain < 0.5 && tremain > 0.) usleep(tremain*1e6); if(lock()){ // log if(dtime() - logt > TLOG_PAUSE){ logt = dtime(); float t; - if(camera->getTcold(&t)){ + if(camera->getTcold && camera->getTcold(&t)){ LOGMSG("CCDTEMP=%.1f", t); } - if(camera->getThot(&t)){ + if(camera->getThot && camera->getThot(&t)){ LOGMSG("HOTTEMP=%.1f", t); } - if(camera->getTbody(&t)){ + if(camera->getTbody && camera->getTbody(&t)){ LOGMSG("BODYTEMP=%.1f", t); } } @@ -214,7 +227,7 @@ static void* processCAM(_U_ void *d){ DBG("Cancel exposition"); LOGMSG("User canceled exposition"); camflags &= ~(FLAG_STARTCAPTURE | FLAG_CANCEL); - camera->cancel(); + if(camera->cancel) camera->cancel(); camstate = CAMERA_IDLE; infty = 0; // also cancel infinity loop unlock(); @@ -244,14 +257,14 @@ static void* processCAM(_U_ void *d){ // functions running @ each devno change static int camdevini(int n){ if(!camera) return FALSE; - if(!camera->setDevNo(n)){ + if(camera->setDevNo && !camera->setDevNo(n)){ LOGERR("Can't set active camera number"); return FALSE; } camdevno = n; LOGMSG("Set camera device number to %d", camdevno); cc_frameformat step; - camera->getgeomlimits(&frmformatmax, &step); + if(camera->getgeomlimits) camera->getgeomlimits(&frmformatmax, &step); curformat = frmformatmax; DBG("\n\nGeometry format max (offx/offy) w/h: (%d/%d) %d/%d", curformat.xoff, curformat.yoff, curformat.w, curformat.h); @@ -262,8 +275,8 @@ static int camdevini(int n){ if(GP->hbin < 1) GP->hbin = 1; if(GP->vbin < 1) GP->vbin = 1; fixima(); - if(!camera->setbin(GP->hbin, GP->vbin)) WARNX(_("Can't set binning %dx%d"), GP->hbin, GP->vbin); - if(!camera->setgeometry(&curformat)) WARNX(_("Can't set given geometry")); + if(!camera->setbin || !camera->setbin(GP->hbin, GP->vbin)) WARNX(_("Can't set binning %dx%d"), GP->hbin, GP->vbin); + if(!camera->setgeometry || !camera->setgeometry(&curformat)) WARNX(_("Can't set given geometry")); return TRUE; } static int focdevini(int n){ @@ -312,13 +325,14 @@ static cc_hresult imsizehandler(int fd, const char *key, _U_ const char *val){ } static cc_hresult camlisthandler(int fd, _U_ const char *key, _U_ const char *val){ char buf[BUFSIZ], modname[256]; + if(!camera->getModelName) return RESULT_FAIL; for(int i = 0; i < camera->Ndevices; ++i){ - if(!camera->setDevNo(i)) continue; - camera->getModelName(modname, 255); - snprintf(buf, BUFSIZ-1, CC_CMD_CAMLIST "='%s'", modname); - if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; + if(camera->setDevNo && !camera->setDevNo(i)) continue; + camera->getModelName(modname, 255); + snprintf(buf, BUFSIZ-1, CC_CMD_CAMLIST "='%s'", modname); + if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; } - if(camdevno > -1) camera->setDevNo(camdevno); + if(camdevno > -1 && camera->setDevNo) camera->setDevNo(camdevno); return RESULT_SILENCE; } static cc_hresult camsetNhandler(_U_ int fd, _U_ const char *key, _U_ const char *val){ @@ -341,6 +355,7 @@ static cc_hresult exphandler(int fd, _U_ const char *key, const char *val){ DBG("setexp to %s", val); double v = atof(val); if(v < DBL_EPSILON) return RESULT_BADVAL; + if(!camera->setexp) return RESULT_FAIL; if(camera->setexp(v)){ GP->exptime = v; }else LOGWARN("Can't set exptime to %g", v); @@ -427,10 +442,12 @@ static cc_hresult binhandler(_U_ int fd, const char *key, const char *val){ if(b < 1) return RESULT_BADVAL; if(0 == strcmp(key, CC_CMD_HBIN)) GP->hbin = b; else GP->vbin = b; + if(!camera->setbin) return RESULT_FAIL; if(!camera->setbin(GP->hbin, GP->vbin)){ return RESULT_BADVAL; } } + if(!camera->getbin) return RESULT_SILENCE; int r = camera->getbin(&GP->hbin, &GP->vbin); if(r){ if(0 == strcmp(key, CC_CMD_HBIN)) snprintf(buf, 63, "%s=%d", key, GP->hbin); @@ -445,6 +462,7 @@ static cc_hresult temphandler(int fd, _U_ const char *key, const char *val){ float f; char buf[64]; int r; + if(!camera->setT) return RESULT_FAIL; if(val){ f = atof(val); r = camera->setT((float)f); @@ -454,25 +472,31 @@ static cc_hresult temphandler(int fd, _U_ const char *key, const char *val){ } LOGMSG("Set camera T to %.1f", f); } + if(!camera->getTcold) return RESULT_SILENCE; r = camera->getTcold(&f); if(r){ snprintf(buf, 63, CC_CMD_CAMTEMPER "=%.1f", f); if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; - r = camera->getTbody(&f); - if(r){ - snprintf(buf, 63, "tbody=%.1f", f); - if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; + if(camera->getTbody){ + r = camera->getTbody(&f); + if(r){ + snprintf(buf, 63, "tbody=%.1f", f); + if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; + } } - r = camera->getThot(&f); - if(r){ - snprintf(buf, 63, "thot=%.1f", f); - if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; + if(camera->getThot){ + r = camera->getThot(&f); + if(r){ + snprintf(buf, 63, "thot=%.1f", f); + if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; + } } return RESULT_SILENCE; }else return RESULT_FAIL; } static cc_hresult camfanhandler(int fd, _U_ const char *key, _U_ const char *val){ char buf[64]; + if(!camera->setfanspeed) return RESULT_FAIL; if(val){ int spd = atoi(val); if(spd < 0) return RESULT_BADVAL; @@ -487,6 +511,7 @@ static cc_hresult camfanhandler(int fd, _U_ const char *key, _U_ const char *val } const char *shutterstr[] = {"open", "close", "expose @high", "expose @low"}; static cc_hresult shutterhandler(_U_ int fd, _U_ const char *key, const char *val){ + if(!camera->shuttercmd) return RESULT_FAIL; if(val){ int x = atoi(val); if(x < 0 || x >= SHUTTER_AMOUNT) return RESULT_BADVAL; @@ -502,6 +527,7 @@ static cc_hresult shutterhandler(_U_ int fd, _U_ const char *key, const char *va } static cc_hresult confiohandler(_U_ int fd, _U_ const char *key, _U_ const char *val){ char buf[64]; + if(!camera->confio) return RESULT_FAIL; if(val){ int io = atoi(val); int r = camera->confio(io); @@ -515,6 +541,7 @@ static cc_hresult confiohandler(_U_ int fd, _U_ const char *key, _U_ const char static cc_hresult iohandler(_U_ int fd, _U_ const char *key, _U_ const char *val){ char buf[64]; int io; + if(!camera->setio) return RESULT_FAIL; if(val){ io = atoi(val); int r = camera->setio(io); @@ -529,11 +556,13 @@ static cc_hresult iohandler(_U_ int fd, _U_ const char *key, _U_ const char *val static cc_hresult gainhandler(_U_ int fd, _U_ const char *key, _U_ const char *val){ char buf[64]; float f; + if(!camera->setgain) return RESULT_FAIL; if(val){ f = atof(val); int r = camera->setgain(f); if(!r) return RESULT_FAIL; } + if(!camera->getgain) return RESULT_SILENCE; int r = camera->getgain(&f); if(!r) return RESULT_FAIL; snprintf(buf, 63, CC_CMD_GAIN "=%.1f", f); @@ -543,11 +572,13 @@ static cc_hresult gainhandler(_U_ int fd, _U_ const char *key, _U_ const char *v static cc_hresult brightnesshandler(_U_ int fd, _U_ const char *key, _U_ const char *val){ char buf[64]; float b; + if(!camera->setbrightness) return RESULT_FAIL; if(val){ b = atof(val); int r = camera->setbrightness(b); if(!r) return RESULT_FAIL; } + if(!camera->getbrightness) return RESULT_SILENCE; int r = camera->getbrightness(&b); if(!r) return RESULT_FAIL; snprintf(buf, 63, CC_CMD_BRIGHTNESS "=%.1f", b); @@ -561,6 +592,7 @@ static cc_hresult formathandler(int fd, const char *key, const char *val){ cc_frameformat fmt; DBG("key=%s, val=%s", key, val); if(val){ + if(!camera->setgeometry) return RESULT_FAIL; if(0 == strcmp(key, CC_CMD_FRAMEMAX)){ DBG("CANT SET MAXFORMAT"); return RESULT_BADKEY; // can't set maxformat @@ -585,6 +617,7 @@ static cc_hresult formathandler(int fd, const char *key, const char *val){ } static cc_hresult nflusheshandler(_U_ int fd, _U_ const char *key, _U_ const char *val){ char buf[64]; + if(!camera->setnflushes) return RESULT_FAIL; if(val){ int n = atoi(val); if(n < 1) return RESULT_BADVAL; @@ -627,6 +660,7 @@ static cc_hresult tremainhandler(_U_ int fd, _U_ const char *key, _U_ const char } static cc_hresult _8bithandler(int fd, _U_ const char *key, const char *val){ char buf[64]; + if(!camera->setbitdepth) return RESULT_FAIL; if(val){ int s = atoi(val); if(s != 0 && s != 1) return RESULT_BADVAL; @@ -640,6 +674,7 @@ static cc_hresult _8bithandler(int fd, _U_ const char *key, const char *val){ } static cc_hresult fastspdhandler(int fd, _U_ const char *key, const char *val){ char buf[64]; + if(!camera->setfastspeed) return RESULT_FAIL; if(val){ int b = atoi(val); if(b != 0 && b != 1) return RESULT_BADVAL; @@ -652,6 +687,7 @@ static cc_hresult fastspdhandler(int fd, _U_ const char *key, const char *val){ } static cc_hresult darkhandler(int fd, _U_ const char *key, const char *val){ char buf[64]; + if(!camera->setframetype) return RESULT_FAIL; if(val){ int d = atoi(val); if(d != 0 && d != 1) return RESULT_BADVAL; @@ -869,7 +905,7 @@ static cc_hresult infohandler(int fd, _U_ const char *key, _U_ const char *val){ float f; int i; if(camera){ - if(camera->getModelName(buf1, 255)){ + if(camera->getModelName && camera->getModelName(buf1, 255)){ snprintf(buf, BUFSIZ-1, CC_CMD_CAMLIST "='%s'", buf1); if(!cc_sendstrmessage(fd, buf)) return RESULT_DISCONNECTED; } @@ -1027,7 +1063,7 @@ static cc_handleritem items[] = { {chkcc, formathandler, CC_CMD_FRAMEFORMAT}, {chkcc, formathandler, CC_CMD_FRAMEMAX}, {chkcc, nflusheshandler, CC_CMD_NFLUSHES}, - {chkcam, expstatehandler, CC_CMD_EXPSTATE}, + {NULL, expstatehandler, CC_CMD_EXPSTATE}, {chktrue,shmemkeyhandler, CC_CMD_SHMEMKEY}, {chktrue,imsizehandler, CC_CMD_IMWIDTH}, {chktrue,imsizehandler, CC_CMD_IMHEIGHT},