diff options
author | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-10-07 23:47:45 +0000 |
---|---|---|
committer | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-10-07 23:47:45 +0000 |
commit | 32b90c31701987b47000e398c8b534553004a4a2 (patch) | |
tree | 50429ae105593c9b37e4c1ee4517b20985fe3bf2 /src | |
parent | e3a59f0de58d873837252d4decdd8f727392fad7 (diff) |
Tidying up
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@154 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src')
-rw-r--r-- | src/dirax.c | 36 | ||||
-rw-r--r-- | src/itrans-stat.c | 12 | ||||
-rw-r--r-- | src/utils.c | 13 | ||||
-rw-r--r-- | src/utils.h | 2 |
4 files changed, 28 insertions, 35 deletions
diff --git a/src/dirax.c b/src/dirax.c index aadc82d..37e7b96 100644 --- a/src/dirax.c +++ b/src/dirax.c @@ -26,7 +26,8 @@ #include <assert.h> #include <sys/ioctl.h> #include <termio.h> - +#include <sgtty.h> + #include "control.h" #include "reflections.h" #include "utils.h" @@ -251,12 +252,6 @@ static gboolean dirax_readable(GIOChannel *dirax, GIOCondition condition, Contro /* See if there's a full line in the buffer yet */ for ( i=0; i<ctx->dirax_rbufpos; i++ ) { /* Means the last value looked at is roffset-1 */ - if ( (ctx->dirax_rbuffer[i] == '\n') ) { - block_ready = 1; - type = DIRAX_INPUT_LINE; - break; - } - if ( i <= ctx->dirax_rbufpos-7 ) { if ( strncmp(ctx->dirax_rbuffer+i, "Dirax> ", 7) == 0 ) { block_ready = 1; @@ -265,9 +260,15 @@ static gboolean dirax_readable(GIOChannel *dirax, GIOCondition condition, Contro } } + if ( (ctx->dirax_rbuffer[i] == '\n') ) { + block_ready = 1; + type = DIRAX_INPUT_LINE; + break; + } + } - if ( block_ready == 1 ) { + if ( block_ready ) { switch ( type ) { @@ -350,7 +351,7 @@ void dirax_invoke(ControlContext *ctx) { FILE *fh; Reflection *ref; unsigned int opts; - struct termios tty; + struct termios t; if ( ctx->dirax ) { printf("DX: DirAx is already running.\n"); @@ -366,23 +367,13 @@ void dirax_invoke(ControlContext *ctx) { } fprintf(fh, "%f\n", 0.5); /* Lie about the wavelength. DirAx can't handle the truth. */ ref = ctx->reflectionlist->reflections; - int i=0; while ( ref ) { fprintf(fh, "%10f %10f %10f %8f\n", ref->x/1e10, ref->y/1e10, ref->z/1e10, ref->intensity); ref = ref->next; - i++; - if ( i==14 ) { - printf("%10f %10f %10f %8f\n", ref->x/1e10, ref->y/1e10, ref->z/1e10, ref->intensity); - } } fclose(fh); - if ( ioctl(0, TCGETS, &tty) ) { - printf("DX: Failed to read pty attributes\n"); - return; - } - tty.c_lflag &= ~ECHO; - ctx->dirax_pid = forkpty(&ctx->dirax_pty, NULL, &tty, NULL); + ctx->dirax_pid = forkpty(&ctx->dirax_pty, NULL, NULL, NULL); if ( ctx->dirax_pid == -1 ) { printf("DX: Failed to fork.\n"); return; @@ -403,6 +394,11 @@ void dirax_invoke(ControlContext *ctx) { /* Set non-blocking */ opts = fcntl(ctx->dirax_pty, F_GETFL); fcntl(ctx->dirax_pty, F_SETFL, opts | O_NONBLOCK); + + /* Turn off terminal echo */ + tcgetattr(ctx->dirax_pty, &t); + t.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL | ECHOCTL | ECHOPRT | ECHOKE | ICANON); + tcsetattr(ctx->dirax_pty, TCSANOW, &t); ctx->dirax_step = 1; /* This starts the "initialisation" procedure */ ctx->dirax_read_cell = 0; diff --git a/src/itrans-stat.c b/src/itrans-stat.c index 319e565..21cf415 100644 --- a/src/itrans-stat.c +++ b/src/itrans-stat.c @@ -22,6 +22,18 @@ #include "imagedisplay.h" #include "utils.h" +/* Renormalise a gsl_matrix to 0->1 + * Re-written to use gsl_matrix native functions */ +static void matrix_renormalise(gsl_matrix *m) { + + double max,min; + + gsl_matrix_minmax(m,&min,&max); + gsl_matrix_add_constant(m,0.-min); + gsl_matrix_scale(m,1./(max-min)); + +} + /* * Create a gsl_matrix for performing image operations on * from a raw image and control context diff --git a/src/utils.c b/src/utils.c index 1e750a8..00fa351 100644 --- a/src/utils.c +++ b/src/utils.c @@ -4,7 +4,6 @@ * Utility stuff * * (c) 2007 Thomas White <taw27@cam.ac.uk> - * Gordon Ball <gfb21@cam.ac.uk> * * dtr - Diffraction Tomography Reconstruction * @@ -70,18 +69,6 @@ double lambda(double V) { } -/* Renormalise a gsl_matrix to 0->1 - * Re-written to use gsl_matrix native functions */ -void matrix_renormalise(gsl_matrix *m) { - - double max,min; - - gsl_matrix_minmax(m,&min,&max); - gsl_matrix_add_constant(m,0.-min); - gsl_matrix_scale(m,1./(max-min)); - -} - size_t skipspace(const char *s) { size_t i; diff --git a/src/utils.h b/src/utils.h index 9f8d636..55e98f2 100644 --- a/src/utils.h +++ b/src/utils.h @@ -4,7 +4,6 @@ * Utility stuff * * (c) 2007 Thomas White <taw27@cam.ac.uk> - * Gordon Ball <gfb21@cam.ac.uk> * * dtr - Diffraction Tomography Reconstruction * @@ -27,7 +26,6 @@ extern double modulus(double x, double y, double z); extern double angle_between(double x1, double y1, double z1, double x2, double y2, double z2); extern double angle_between_d(double x1, double y1, double z1, double x2, double y2, double z2); extern double lambda(double voltage); -extern void matrix_renormalise(gsl_matrix *m); extern double distance3d(double x1, double y1, double z1, double x2, double y2, double z2); extern size_t skipspace(const char *s); extern void chomp(char *s); |