diff --git a/APOGEE_cameras/apogee.c b/APOGEE_cameras/apogee.c index 8fe1d51..725eefa 100644 --- a/APOGEE_cameras/apogee.c +++ b/APOGEE_cameras/apogee.c @@ -53,17 +53,23 @@ static int isexposuring = 0; static void disconnect(){ FNAME(); if(!isopened) return; - ApnGlueExpAbort(); + ApnGlueReset(); + //ApnGlueExpAbort(); ApnGlueClose(); isopened = FALSE; } static void cancel(){ - //if(!isexposuring) return; FNAME(); + if(isexposuring){ + isexposuring = 0; + DBG("Abort exposition"); + ApnGlueStopExposure(); + //ApnGlueExpAbort(); + } + //uint16_t b1; + //ApnGlueReadPixels(&b1, 1, NULL); ApnGlueReset(); - //ApnGlueExpAbort(); - //ApnGlueStopExposure(); DBG("OK"); } @@ -119,7 +125,7 @@ static int setdevno(int n){ FNAME(); if(n > ncameras - 1) return FALSE; if(ApnGlueOpen(n)) return FALSE; - ApnGlueExpAbort(); + //ApnGlueExpAbort(); ApnGluePowerResume(); ApnGlueReset(); char *msg = ApnGlueGetInfo(&pid, &vid); @@ -139,6 +145,7 @@ static int setdevno(int n){ camera.pixX = x, camera.pixY = y; camera.field.w = camera.array.w - osw; camera.field.h = camera.array.h; + camera.geometry = camera.array; DBG("Pixel size W/H: %g/%g; field w/h: %d/%d", x, y, camera.field.w, camera.field.h); ; return TRUE; @@ -195,14 +202,29 @@ static int setfastspeed(int fast){ static int setgeometry(frameformat *f){ if(!f) return FALSE; - int ow = (f->w > camera.field.w) ? camera.array.w - f->w : f->w; + if(f->xoff > camera.field.w - 1) f->xoff = camera.field.w - 1; + if(f->yoff > camera.field.h - 1) f->yoff = camera.field.h - 1; + if(f->w - f->xoff > camera.array.w) f->w = camera.array.w - f->xoff; + if(f->h - f->yoff > camera.array.h) f->h = camera.array.h - f->yoff; + int ow = (f->w > camera.field.w) ? f->w - camera.field.w: 0; if(ow < 0) ow = 0; - if(ApnGlueSetExpGeom(f->w * hbin, f->h * vbin, ow, 0, hbin, vbin, + if(f->xoff && f->w + f->xoff >= camera.field.w){ + f->w = camera.field.w - f->xoff; + ow = 0; + } + //f->w -= ow; + DBG("f->w=%d, camfw=%d, camaw=%d", f->w, camera.field.w, camera.array.w); + DBG("ow=%d", ow); + if(ApnGlueSetExpGeom(f->w, f->h, ow, 0, hbin, vbin, f->xoff, f->yoff, &imW, &imH, whynot)){ WARNX("Can't set geometry: %s", whynot); + imW = f->w; + imH = f->h; }else{ camera.geometry = *f; } + DBG("ApnGlueSetExpGeom(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", + f->w, f->h, ow, 0, hbin, vbin, f->xoff, f->yoff, imW, imH); return TRUE; } @@ -228,12 +250,14 @@ static int thot(float *t){ static int startexp(){ tstart = dtime(); - DBG("Start exposition"); + DBG("Start exposition %g seconds (isobject=%d)", exptime, isobject); CCDerr r = ApnGlueStartExp(&exptime, isobject); if(ALTA_OK != r){ /*reset_usb_port(); r = ApnGlueStartExp(&exptime, isobject); if(ALTA_OK != r){*/ + //uint16_t b[4096]; + //ApnGlueReadPixels(b, 4096, NULL); ApnGlueReset(); DBG("Error starting exp: %d", (int)r); return FALSE; @@ -250,7 +274,7 @@ static int frametype(int islight){ } static int setexp(float t){ - DBG("start exp %g, min: %g, max: %g", t, expt[0], expt[1]); + DBG("set exp %g, min: %g, max: %g", t, expt[0], expt[1]); if(t < expt[0] || t > expt[1]) return FALSE; // too big or too small exptime exptime = t; return TRUE; @@ -264,25 +288,34 @@ static int getbin(int *h, int *v){ } static int pollcapt(capture_status *st, float *remain){ - DBG("Poll capture, tremain=%g", dtime() - tstart); - if(dtime() - tstart > 5.){ // capture error? - ApnGlueExpAbort(); - if(*st) *st = CAPTURE_ABORTED; - return FALSE; - } - if(remain) *remain = dtime() - tstart; if(st) *st = CAPTURE_PROCESS; if(ApnGlueExpDone()){ if(st) *st = CAPTURE_READY; isexposuring = 0; DBG("Capture ready"); + if(remain) *remain = 0.f; + return TRUE; + }else DBG("Capture in process"); + double d = exptime - (dtime() - tstart); + DBG("Poll capture, tremain=%g", d); + if(d < -5.){ // capture error? + WARNX("Abort capture"); + ApnGlueExpAbort(); + //ApnGlueStopExposure(); + DBG("ABORTED!"); + if(*st) *st = CAPTURE_ABORTED; + return FALSE; } + if(d < 0.) d = 0.1; + DBG("Poll capture, tremain=%g", d); + if(remain) *remain = d; return TRUE; } static int capture(IMG *ima){ FNAME(); if(!ima || !ima->data) return FALSE; + DBG("ApnGlueReadPixels(%dx%d=%d)", imW, imH, imW * imH); if(ApnGlueReadPixels((uint16_t*)ima->data, imW * imH, whynot)){ WARNX("Can't read image: %s", whynot); return FALSE; diff --git a/ccdfunc.c b/ccdfunc.c index 27393a2..6012968 100644 --- a/ccdfunc.c +++ b/ccdfunc.c @@ -596,6 +596,7 @@ static capture_status capt(){ else usleep((int)(1e6*tremain) + 100000); if(!camera) return CAPTURE_ABORTED; } + DBG("Poll ends with %d", cs); return cs; } diff --git a/locale/ru/messages.po b/locale/ru/messages.po index fc447c1..0393b57 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: 2023-03-06 17:25+0300\n" +"POT-Creation-Date: 2023-03-09 11:35+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -364,185 +364,185 @@ msgstr "" msgid "%.1f seconds till exposition ends" msgstr "" -#: ccdfunc.c:604 +#: ccdfunc.c:605 msgid "Camera device not pointed" msgstr "" -#: ccdfunc.c:611 ccdfunc.c:612 +#: ccdfunc.c:612 ccdfunc.c:613 msgid "No cameras found" msgstr "" -#: ccdfunc.c:642 +#: ccdfunc.c:643 #, c-format msgid "Found %d cameras, you point number %d" msgstr "" -#: ccdfunc.c:646 +#: ccdfunc.c:647 msgid "Can't set active camera number" msgstr "" -#: ccdfunc.c:652 +#: ccdfunc.c:653 msgid "Can't set fan speed" msgstr "" -#: ccdfunc.c:653 +#: ccdfunc.c:654 #, c-format msgid "Set fan speed to %d" msgstr "" -#: ccdfunc.c:658 +#: ccdfunc.c:659 #, c-format msgid "Camera model: %s" msgstr "" -#: ccdfunc.c:659 +#: ccdfunc.c:660 #, c-format msgid "Pixel size: %g x %g" msgstr "" -#: ccdfunc.c:665 +#: ccdfunc.c:666 #, c-format msgid "Full array: %s" msgstr "" -#: ccdfunc.c:668 +#: ccdfunc.c:669 #, c-format msgid "Field of view: %s" msgstr "" -#: ccdfunc.c:671 +#: ccdfunc.c:672 #, c-format msgid "Current format: %s" msgstr "" -#: ccdfunc.c:674 +#: ccdfunc.c:675 #, c-format msgid "Can't set T to %g degC" msgstr "" -#: ccdfunc.c:682 +#: ccdfunc.c:683 #, c-format msgid "Shutter command: %s\n" msgstr "" -#: ccdfunc.c:684 +#: ccdfunc.c:685 #, c-format msgid "Can't run shutter command %s (unsupported?)" msgstr "" #. "Попытка сконфигурировать порт I/O как %d\n" -#: ccdfunc.c:688 +#: ccdfunc.c:689 #, c-format msgid "Try to configure I/O port as %d" msgstr "" -#: ccdfunc.c:690 +#: ccdfunc.c:691 msgid "Can't configure (unsupported?)" msgstr "" -#: ccdfunc.c:697 +#: ccdfunc.c:698 msgid "Can't get IOport state (unsupported?)" msgstr "" #. "Попытка записи %d в порт I/O\n" -#: ccdfunc.c:701 +#: ccdfunc.c:702 #, c-format msgid "Try to write %d to I/O port" msgstr "" -#: ccdfunc.c:703 +#: ccdfunc.c:704 msgid "Can't set IOport" msgstr "" -#: ccdfunc.c:710 -#, c-format -msgid "Set gain to %g" -msgstr "" - #: ccdfunc.c:711 #, c-format -msgid "Can't set gain to %g" +msgid "Set gain to %g" msgstr "" -#: ccdfunc.c:716 +#: ccdfunc.c:712 #, c-format -msgid "Set brightness to %g" +msgid "Can't set gain to %g" msgstr "" #: ccdfunc.c:717 #, c-format +msgid "Set brightness to %g" +msgstr "" + +#: ccdfunc.c:718 +#, c-format msgid "Can't set brightness to %g" msgstr "" -#: ccdfunc.c:725 server.c:229 +#: ccdfunc.c:726 server.c:229 #, c-format msgid "Can't set binning %dx%d" msgstr "" -#: ccdfunc.c:737 server.c:230 +#: ccdfunc.c:738 server.c:230 msgid "Can't set given geometry" msgstr "" -#: ccdfunc.c:741 +#: ccdfunc.c:742 #, c-format msgid "Can't set %d flushes" msgstr "" -#: ccdfunc.c:745 +#: ccdfunc.c:746 #, c-format msgid "Can't set exposure time to %f seconds" msgstr "" -#: ccdfunc.c:748 +#: ccdfunc.c:749 msgid "Can't change frame type" msgstr "" -#: ccdfunc.c:751 +#: ccdfunc.c:752 msgid "Can't set bit depth" msgstr "" -#: ccdfunc.c:753 +#: ccdfunc.c:754 msgid "Can't set readout speed" msgstr "" -#: ccdfunc.c:754 +#: ccdfunc.c:755 #, c-format msgid "Readout mode: %s" msgstr "" -#: ccdfunc.c:755 +#: ccdfunc.c:756 msgid "Only show statistics" msgstr "" #. GET binning should be AFTER setgeometry! -#: ccdfunc.c:757 +#: ccdfunc.c:758 msgid "Can't get current binning" msgstr "" #. Захват кадра %d\n -#: ccdfunc.c:779 +#: ccdfunc.c:780 #, c-format msgid "Capture frame %d" msgstr "" -#: ccdfunc.c:781 ccdfunc.c:831 server.c:124 +#: ccdfunc.c:782 ccdfunc.c:832 server.c:124 msgid "Can't start exposition" msgstr "" -#: ccdfunc.c:785 +#: ccdfunc.c:786 msgid "Can't capture image" msgstr "" -#: ccdfunc.c:788 +#: ccdfunc.c:789 msgid "Read grabbed image" msgstr "" -#: ccdfunc.c:791 ccdfunc.c:839 +#: ccdfunc.c:792 ccdfunc.c:840 msgid "Can't grab image" msgstr "" #. %d секунд до окончания паузы\n -#: ccdfunc.c:800 client.c:282 +#: ccdfunc.c:801 client.c:282 #, c-format msgid "%d seconds till pause ends\n" msgstr "" diff --git a/locale/ru/ru.po b/locale/ru/ru.po index 99fea0c..ae497b1 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: 2023-03-01 08:54+0300\n" + "POT-Creation-Date: 2023-03-09 11:35+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -22,7 +22,7 @@ msgid "%.1f seconds till exposition ends" msgstr "%.1f " #. %d секунд до окончания паузы\n -#: ccdfunc.c:800 client.c:282 +#: ccdfunc.c:801 client.c:282 #, c-format msgid "%d seconds till pause ends\n" msgstr "%d \n" @@ -39,7 +39,7 @@ msgstr " msgid "CMOS gain level" msgstr " Gain CMOS" -#: ccdfunc.c:604 +#: ccdfunc.c:605 msgid "Camera device not pointed" msgstr " " @@ -47,20 +47,20 @@ msgstr " msgid "Camera device unknown" msgstr " " -#: ccdfunc.c:658 +#: ccdfunc.c:659 #, c-format msgid "Camera model: %s" msgstr " : %s" -#: ccdfunc.c:785 +#: ccdfunc.c:786 msgid "Can't capture image" msgstr " " -#: ccdfunc.c:748 +#: ccdfunc.c:749 msgid "Can't change frame type" msgstr " " -#: ccdfunc.c:690 +#: ccdfunc.c:691 msgid "Can't configure (unsupported?)" msgstr " ( ?)" @@ -84,12 +84,12 @@ msgstr " msgid "Can't find wheel in plugin %s: %s" msgstr " %s: %s" -#: ccdfunc.c:697 +#: ccdfunc.c:698 msgid "Can't get IOport state (unsupported?)" msgstr " I/O ( ?)" #. GET binning should be AFTER setgeometry! -#: ccdfunc.c:757 +#: ccdfunc.c:758 msgid "Can't get current binning" msgstr " " @@ -105,7 +105,7 @@ msgstr " msgid "Can't get max wheel position" msgstr " " -#: ccdfunc.c:791 ccdfunc.c:839 +#: ccdfunc.c:792 ccdfunc.c:840 msgid "Can't grab image" msgstr " " @@ -125,7 +125,7 @@ msgstr " msgid "Can't open OpenGL window, image preview will be inaccessible" msgstr " OpenGL, " -#: ccdfunc.c:684 +#: ccdfunc.c:685 #, c-format msgid "Can't run shutter command %s (unsupported?)" msgstr " %s ( ?)" @@ -136,21 +136,21 @@ msgstr " msgid "Can't save file with prefix %s" msgstr " %s" -#: ccdfunc.c:741 +#: ccdfunc.c:742 #, c-format msgid "Can't set %d flushes" msgstr " %d " -#: ccdfunc.c:703 +#: ccdfunc.c:704 msgid "Can't set IOport" msgstr " I/O" -#: ccdfunc.c:674 +#: ccdfunc.c:675 #, c-format msgid "Can't set T to %g degC" msgstr " %g " -#: ccdfunc.c:646 +#: ccdfunc.c:647 msgid "Can't set active camera number" msgstr " " @@ -162,35 +162,35 @@ msgstr " msgid "Can't set active wheel number" msgstr " " -#: ccdfunc.c:725 server.c:229 +#: ccdfunc.c:726 server.c:229 #, c-format msgid "Can't set binning %dx%d" msgstr " %dx%d" -#: ccdfunc.c:751 +#: ccdfunc.c:752 msgid "Can't set bit depth" msgstr " " -#: ccdfunc.c:717 +#: ccdfunc.c:718 #, c-format msgid "Can't set brightness to %g" msgstr " %g" -#: ccdfunc.c:745 +#: ccdfunc.c:746 #, c-format msgid "Can't set exposure time to %f seconds" msgstr " %f " -#: ccdfunc.c:652 +#: ccdfunc.c:653 msgid "Can't set fan speed" msgstr " " -#: ccdfunc.c:711 +#: ccdfunc.c:712 #, c-format msgid "Can't set gain to %g" msgstr " Gain %g" -#: ccdfunc.c:737 server.c:230 +#: ccdfunc.c:738 server.c:230 msgid "Can't set given geometry" msgstr " " @@ -204,7 +204,7 @@ msgstr " msgid "Can't set position %g: out of limits [%g, %g]" msgstr " %g: [%g, %g]" -#: ccdfunc.c:753 +#: ccdfunc.c:754 msgid "Can't set readout speed" msgstr " " @@ -213,17 +213,17 @@ msgstr " msgid "Can't set wheel position %d" msgstr " %d" -#: ccdfunc.c:781 ccdfunc.c:831 server.c:124 +#: ccdfunc.c:782 ccdfunc.c:832 server.c:124 msgid "Can't start exposition" msgstr " " #. Захват кадра %d\n -#: ccdfunc.c:779 +#: ccdfunc.c:780 #, c-format msgid "Capture frame %d" msgstr " %d" -#: ccdfunc.c:671 +#: ccdfunc.c:672 #, c-format msgid "Current format: %s" msgstr "" @@ -241,7 +241,7 @@ msgstr " msgid "Error saving file" msgstr " " -#: ccdfunc.c:668 +#: ccdfunc.c:669 #, c-format msgid "Field of view: %s" msgstr " : %s" @@ -255,7 +255,7 @@ msgstr " msgid "Focuser device not pointed" msgstr " " -#: ccdfunc.c:642 +#: ccdfunc.c:643 #, c-format msgid "Found %d cameras, you point number %d" msgstr " %d , %d" @@ -270,7 +270,7 @@ msgstr " msgid "Found %d wheels, you point number %d" msgstr " %d , %d" -#: ccdfunc.c:665 +#: ccdfunc.c:666 #, c-format msgid "Full array: %s" msgstr " : %s" @@ -293,7 +293,7 @@ msgstr "N msgid "No camera device" msgstr " " -#: ccdfunc.c:611 ccdfunc.c:612 +#: ccdfunc.c:612 ccdfunc.c:613 msgid "No cameras found" msgstr " " @@ -305,7 +305,7 @@ msgstr " msgid "No wheels found" msgstr " " -#: ccdfunc.c:755 +#: ccdfunc.c:756 msgid "Only show statistics" msgstr " " @@ -313,16 +313,16 @@ msgstr " msgid "PID file (default: " msgstr "PID- ( : " -#: ccdfunc.c:659 +#: ccdfunc.c:660 #, c-format msgid "Pixel size: %g x %g" msgstr " : %g x %g" -#: ccdfunc.c:788 +#: ccdfunc.c:789 msgid "Read grabbed image" msgstr " " -#: ccdfunc.c:754 +#: ccdfunc.c:755 #, c-format msgid "Readout mode: %s" msgstr " : %s" @@ -331,34 +331,34 @@ msgstr " msgid "Server timeout" msgstr " " -#: ccdfunc.c:716 +#: ccdfunc.c:717 #, c-format msgid "Set brightness to %g" msgstr " %g" -#: ccdfunc.c:653 +#: ccdfunc.c:654 #, c-format msgid "Set fan speed to %d" msgstr " %d" -#: ccdfunc.c:710 +#: ccdfunc.c:711 #, c-format msgid "Set gain to %g" msgstr " Gain %g" -#: ccdfunc.c:682 +#: ccdfunc.c:683 #, c-format msgid "Shutter command: %s\n" msgstr " : %s\n" #. "Попытка сконфигурировать порт I/O как %d\n" -#: ccdfunc.c:688 +#: ccdfunc.c:689 #, c-format msgid "Try to configure I/O port as %d" msgstr " I/O %d" #. "Попытка записи %d в порт I/O\n" -#: ccdfunc.c:701 +#: ccdfunc.c:702 #, c-format msgid "Try to write %d to I/O port" msgstr " %d I/O" diff --git a/main.c b/main.c index d2f40e2..c0bda22 100644 --- a/main.c +++ b/main.c @@ -41,6 +41,10 @@ static pid_t childpid = 0; void signals(int signo){ if(signo) signal(signo, SIG_IGN); + if(!GP->client){ + DBG("Unlink pid file"); + unlink(GP->pidfile); + } if(childpid){ // master process if(signo == SIGUSR1){ // kill child kill(childpid, signo); @@ -49,10 +53,6 @@ void signals(int signo){ } WARNX("Master killed with sig=%d", signo); LOGERR("Master killed with sig=%d", signo); - if(!GP->client){ - DBG("Unlink pid file"); - unlink(GP->pidfile); - } exit(signo); } // slave: cancel exposition @@ -143,7 +143,7 @@ int main(int argc, char **argv){ } #endif if(camerainit) ccds(); - return 0; + signals(0); } LOGMSG("Started"); #ifndef EBUG