mirror of
https://github.com/eddyem/SBIG_340.git
synced 2025-12-06 10:45:10 +03:00
some fixes
This commit is contained in:
parent
b7654b2569
commit
91f3b192cd
17
Makefile
17
Makefile
@ -11,24 +11,21 @@ OBJS := $(SRCS:%.c=%.o)
|
||||
CC = gcc
|
||||
CPP = g++
|
||||
|
||||
all : sbig340 daemon client
|
||||
all : sbig340_standalone sbig340_daemon sbig340_client
|
||||
|
||||
debayer.o : debayer.cpp
|
||||
@echo -e "\t\tG++ debayer"
|
||||
$(CPP) $(CFLAGS) $(DEFINES) debayer.cpp -c
|
||||
|
||||
sbig340 : $(SRCS) debayer.o
|
||||
@echo -e "\t\tBuild sbig340"
|
||||
sbig340_standalone : $(SRCS) debayer.o
|
||||
@echo -e "\t\tBuild standalone"
|
||||
$(CC) $(CFLAGS) -std=gnu99 $(DEFINES) $(LDFLAGS) $(LDIMG) $(SRCS) debayer.o -o $@
|
||||
|
||||
# $(CC) -c $(CFLAGS) -std=gnu99 $(DEFINES) $(SRCS)
|
||||
# $(CPP) $(LDFLAGS) $(OBJS) debayer.o -o $@
|
||||
|
||||
daemon : $(SRCS)
|
||||
sbig340_daemon : $(SRCS)
|
||||
@echo -e "\t\tBuild daemon"
|
||||
$(CC) -DDAEMON $(CFLAGS) -std=gnu99 $(DEFINES) $(LDFLAGS) $(SRCS) -o $@
|
||||
|
||||
client : $(SRCS) debayer.o
|
||||
sbig340_client : $(SRCS) debayer.o
|
||||
@echo -e "\t\tBuild client"
|
||||
$(CC) -DCLIENT $(CFLAGS) -std=gnu99 $(DEFINES) $(LDFLAGS) $(LDIMG) $(SRCS) debayer.o -o $@
|
||||
|
||||
@ -38,9 +35,9 @@ clean:
|
||||
|
||||
xclean: clean
|
||||
@echo -e "\t\tRM binaries"
|
||||
@rm -f sbig340 daemon client
|
||||
@rm -f sbig340_standalone sbig340_daemon sbig340_client
|
||||
|
||||
gentags:
|
||||
CFLAGS="$(CFLAGS) $(DEFINES)" geany -g $(PROGRAM).c.tags *[hc] *.cpp 2>/dev/null
|
||||
CFLAGS="$(CFLAGS) $(DEFINES)" geany -g sbig340.c.tags *.[hc] *.cpp 2>/dev/null
|
||||
|
||||
.PHONY: gentags clean xclean
|
||||
|
||||
@ -3,7 +3,7 @@ SBIG all-sky 340c driving utilite
|
||||
|
||||
Run `make` to compile three binary files:
|
||||
|
||||
* `sbig340` --- standalone utility (no daemon/client)
|
||||
* `daemon` --- pure grabbing daemon (driven by socket)
|
||||
* `client` --- pure client (take images from daemon and save locally)
|
||||
* `sbig340_standalone` --- standalone utility (no daemon/client)
|
||||
* `sbig340_daemon` --- pure grabbing daemon (driven by socket)
|
||||
* `sbig340_client` --- pure client (take images from daemon and save locally)
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ glob_pars const Gdefault = {
|
||||
.imtype = "l",
|
||||
.imformat = NULL,
|
||||
.imstoretype = NULL,
|
||||
.outpfname = "output.tiff",
|
||||
.outpfname = "output.fits",
|
||||
.hostname = NULL,
|
||||
.port = "4444",
|
||||
.once = 0,
|
||||
@ -77,7 +77,7 @@ myoption cmdlnopts[] = {
|
||||
// not daemon options
|
||||
#ifndef DAEMON
|
||||
{"storetype",NEED_ARG, NULL, 'S', arg_string, APTR(&G.imstoretype),_("'overwrite'/'rewrite' to rewrite existing image, 'enumerate'/'numerate' to use given filename as base for series")},
|
||||
{"output", NEED_ARG, NULL, 'o', arg_string, APTR(&G.outpfname), _("output file name (default: output.tiff)")},
|
||||
{"output", NEED_ARG, NULL, 'o', arg_string, APTR(&G.outpfname), _("output file name (default: output.fits)")},
|
||||
{"imformat",NEED_ARG, NULL, 'f', arg_string, APTR(&G.imformat), _("image format: FITS (f), TIFF (t), raw dump with histogram storage (r,d), may be OR'ed; default: FITS or based on output image name")},
|
||||
#endif
|
||||
// not client options
|
||||
@ -101,6 +101,9 @@ myoption cmdlnopts[] = {
|
||||
{"timestamp",NO_ARGS, NULL, 't', arg_int, APTR(&G.timestamp), _("add timestamp to filename")},
|
||||
#endif
|
||||
{"port", NEED_ARG, NULL, 'p', arg_string, APTR(&G.port), _("port to connect (default: 4444)")},
|
||||
#endif
|
||||
// only daemon options
|
||||
#ifdef DAEMON
|
||||
{"dark-interval",NEED_ARG,NULL, 'D', arg_double, APTR(&G.dark_interval),_("time interval (in seconds) between dark images taken (default: 1800)")},
|
||||
{"min-dark-exp",NEED_ARG,NULL, 'E', arg_double, APTR(&G.min_dark_exp),_("minimal exposition (in seconds) at which darks would be taken (default: 30)")},
|
||||
#endif
|
||||
|
||||
@ -71,6 +71,7 @@ char *make_filename(imstorage *img, const char *suff){
|
||||
stm->tm_hour, stm->tm_min, stm->tm_sec);
|
||||
outfile = fnbuf;
|
||||
}
|
||||
DBG("name: %s", outfile);
|
||||
if(st == STORE_NORMAL || st == STORE_REWRITE){
|
||||
snprintf(buff, FILENAME_MAX, "%s.%s", outfile, suff);
|
||||
if(stat(buff, &filestat)){
|
||||
@ -106,8 +107,9 @@ char *make_filename(imstorage *img, const char *suff){
|
||||
* @param store (i) - "overwrite" (or "rewrite"), "normal" (or NULL), "enumerate" (or "numerate")
|
||||
* @param format (i) - image format (ft[rd])
|
||||
*/
|
||||
imstorage *chk_storeimg(char *filename, char* store, char *format){
|
||||
imstorage *chk_storeimg(imstorage *ist, char* store, char *format){
|
||||
FNAME();
|
||||
if(!ist || !ist->imname) return NULL;
|
||||
store_type st = STORE_NORMAL;
|
||||
image_format fmt = FORMAT_FITS;
|
||||
if(store){ // rewrite or enumerate
|
||||
@ -119,9 +121,7 @@ imstorage *chk_storeimg(char *filename, char* store, char *format){
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
char *nm = strdup(filename);
|
||||
if(!nm) ERRX("strdup");
|
||||
char *pt = strrchr(nm, '.');
|
||||
char *pt = strrchr(ist->imname, '.');
|
||||
DBG("input format: %s", format);
|
||||
image_format fbysuff = FORMAT_NONE;
|
||||
// check if name's suffix is filetype
|
||||
@ -142,7 +142,6 @@ imstorage *chk_storeimg(char *filename, char* store, char *format){
|
||||
strchr(format, 'd') || strchr(format, 'D')) fbysuff |= FORMAT_RAW;
|
||||
if(fbysuff == FORMAT_NONE){
|
||||
WARNX(_("Wrong format string: %s"), format);
|
||||
free(nm);
|
||||
return NULL;
|
||||
}
|
||||
fmt = fbysuff;
|
||||
@ -155,17 +154,12 @@ imstorage *chk_storeimg(char *filename, char* store, char *format){
|
||||
#define FMTSZ (3)
|
||||
image_format formats[FMTSZ] = {FORMAT_FITS, FORMAT_TIFF, FORMAT_RAW};
|
||||
const char *suffixes[FMTSZ] = {SUFFIX_FITS, SUFFIX_TIFF, SUFFIX_RAW};
|
||||
imstorage *ist = MALLOC(imstorage, 1);
|
||||
ist->st = st;
|
||||
ist->imformat = fmt;
|
||||
ist->imname = strdup(nm);
|
||||
for(size_t i = 0; i < FMTSZ; ++i){
|
||||
if(!(formats[i] & fmt)) continue;
|
||||
if(!make_filename(ist, suffixes[i])){
|
||||
WARNX(_("Can't create output file (is it exists?)"));
|
||||
free(nm);
|
||||
free(ist->imname);
|
||||
free(ist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -424,7 +418,7 @@ int save_histo(FILE *f, imstorage *img){
|
||||
if(mul > mulmax) mul = mulmax;
|
||||
double E = img->exptime * mul;
|
||||
if(E < 5e-5) E = 5e-5; // too short exposition
|
||||
else if(E > 300.) E = 300.; // no need to do expositions larger than 5 minutes
|
||||
else if(E > 90.) E = 90.; // no need to do expositions larger than 1.5 minutes
|
||||
green("Recommended exposition time: %g seconds\n", E);
|
||||
exp_calculated = E;
|
||||
return 0;
|
||||
|
||||
@ -79,7 +79,7 @@ extern double exp_calculated;
|
||||
#define SUFFIX_JPEG "jpg"
|
||||
|
||||
char *make_filename(imstorage *img, const char *suff);
|
||||
imstorage *chk_storeimg(char *filename, char* store, char *format);
|
||||
imstorage *chk_storeimg(imstorage *img, char* store, char *format);
|
||||
int store_image(imstorage *filename);
|
||||
void print_stat(imstorage *img);
|
||||
#ifndef CLIENT
|
||||
|
||||
17
main.c
17
main.c
@ -22,6 +22,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#ifndef EBUG
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
@ -81,11 +82,15 @@ int main(int argc, char **argv){
|
||||
G->binning = 0xff; // take subframe
|
||||
}
|
||||
#endif // !CLIENT
|
||||
img = MALLOC(imstorage, 1);
|
||||
#ifdef CLIENT
|
||||
img->once = G->once;
|
||||
img->timestamp = G->timestamp;
|
||||
#endif
|
||||
#ifndef DAEMON
|
||||
img = chk_storeimg(G->outpfname, G->imstoretype, G->imformat);
|
||||
if(!img) return 1;
|
||||
#else
|
||||
img = MALLOC(imstorage, 1); // just allocate empty: all we need in daemon is exposition & binning
|
||||
img->imname = G->outpfname;
|
||||
img->exposetime = time(NULL);
|
||||
if(!chk_storeimg(img, G->imstoretype, G->imformat)) return 1;
|
||||
#endif
|
||||
#ifndef CLIENT
|
||||
if(img){
|
||||
@ -115,10 +120,6 @@ int main(int argc, char **argv){
|
||||
run_terminal(); // non-echo terminal mode
|
||||
}
|
||||
#endif // !defined DAEMON && !defined CLIENT
|
||||
#ifdef CLIENT
|
||||
img->once = G->once;
|
||||
img->timestamp = G->timestamp;
|
||||
#endif
|
||||
#if defined CLIENT || defined DAEMON
|
||||
#ifdef DAEMON
|
||||
set_darks(G->min_dark_exp, G->dark_interval);
|
||||
|
||||
2341
sbig340.c.tags
2341
sbig340.c.tags
File diff suppressed because it is too large
Load Diff
1
socket.c
1
socket.c
@ -334,6 +334,7 @@ static void daemon_(imstorage *img, int sock){
|
||||
pthread_mutex_lock(&mutex);
|
||||
if(copyima(img)){
|
||||
++imctr;
|
||||
if(img->imtype != IMTYPE_DARK)
|
||||
save_histo(NULL, img); // calculate next optimal exposition
|
||||
}
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
8
term.c
8
term.c
@ -500,6 +500,14 @@ int start_exposition(imstorage *im, char *imtype){
|
||||
b = bngs[binning];
|
||||
}else b = "subframe";
|
||||
cmd[4] = binning;
|
||||
if(!imtype){
|
||||
it = im->imtype;
|
||||
switch(im->imtype){
|
||||
case IMTYPE_DARK: imtype = "dark"; break;
|
||||
case IMTYPE_AUTODARK: imtype = "autodark"; break;
|
||||
case IMTYPE_LIGHT: default: imtype = "light";
|
||||
}
|
||||
}
|
||||
// and now check image type
|
||||
if(imtype){
|
||||
int L = strlen(imtype);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user