#include <scan345.h>
Public Types | |
typedef MarStartup | inherited |
Public Member Functions | |
Scan345 (QObject *parent=0) | |
int | scan345_main (int argc, char *argv[]) |
void | mar_loop () |
void | usage () |
Static Public Member Functions | |
static void | mar_kill (int signo) |
static void | mar_sig (int signo) |
typedef MarStartup Scan345::inherited |
Reimplemented from MarStartup.
Reimplemented in Command, and QScan345Controller.
Scan345::Scan345 | ( | QObject * | parent = 0 | ) |
Definition at line 63 of file scan345.cpp.
: inherited(parent) { }
void Scan345::mar_kill | ( | int | signo | ) | [static] |
Definition at line 321 of file scan345.cpp.
References MarHW::mar_hw(), and MarHW::mar_quit().
Referenced by scan345_main().
void Scan345::mar_loop | ( | ) |
Definition at line 260 of file scan345.cpp.
References MarHW::get_status(), i, and MarHW::mar_quit().
{ int i; /* Go into command loop */ while( 1 ) { i=get_status(); } mar_quit( (int)0 ); exit(0); }
void Scan345::mar_sig | ( | int | signo | ) | [static] |
Definition at line 300 of file scan345.cpp.
References mar_continue.
Referenced by scan345_main().
{ /* * The signal SIGUSR1 and SIGCONT come from marstart * SIGUSR1: continue * SIGUSR2: exit */ if ( signo == SIGCONT ) { printf( "scan345: SIGCONT caught\n"); mar_continue = 1; } else if ( signo == SIGUSR1 ) { printf( "scan345: SIGUSR1 caught\n"); ::exit( 0 ); } }
int Scan345::scan345_main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 76 of file scan345.cpp.
References debug, MarHW::get_status(), i, input_keep_image, input_keep_spiral, input_offset, input_priority, input_scale, input_skip_op, keep_image, keep_spiral, MarHW::mar_abort(), mar_host, mar_kill(), mar_port, mar_sig(), MarStartup::marStartup(), MarHW::marTask(), MDC_COM_STARTUP, netcontrol, no_xform, skip_selftest, usage(), and verbose.
{ int scanner_status=0; int i; extern char keep_image; /* * External functions */ strcpy( mar_host, "" ); mar_port = 0; debug = 0; setlinebuf(stdout); /* * Parse command line */ for (argv++; argc-- > 1; argv++ ) { /* Keep spiral file on output */ if (!strncmp(*argv,"-keep", 5 ) ) { input_keep_spiral=1; keep_spiral=1; } /* Skip selftest */ else if (!strncmp(*argv,"-nose", 5 ) ) { skip_selftest=1; } /* Skip transformation */ else if (!strncmp(*argv,"-noxf", 5) ) { input_keep_image=0; keep_image = 0; no_xform = 1; } /* Skip image output */ else if (!strncmp(*argv,"-noop", 5) ) { input_skip_op=1; } /* Debug */ else if (!strncmp(*argv,"-debug", 6 ) ) { argc--; if ( argc <= 0 ) { usage(); } else { argv++; debug = atoi( *argv ); } } /* Priority */ else if (!strncmp(*argv,"-prio", 5 ) ) { argc--; if ( argc <= 0 ) { usage(); } else { argv++; input_priority = atoi( *argv ); } } /* Net port */ else if (!strncmp(*argv,"-port", 5 ) ) { argc--; if ( argc <= 0 ) { usage(); } else { argv++; mar_port=atoi( *argv ); } } /* Net host */ else if (!strncmp(*argv,"-host", 5 ) ) { argc--; if ( argc <= 0 ) { usage(); } else { argv++; strcpy( mar_host, *argv ); } } /* Help */ else if (!strcmp(*argv,"-h" ) ) { usage(); } /* Apply scale factor to data */ else if (!strncmp(*argv,"-sc", 3 ) ) { argc--; if ( argc <= 0 ) { usage(); } else { argv++; input_scale = atof( *argv ); } } /* Apply offset to data */ else if (!strncmp(*argv,"-off", 4 ) ) { argc--; if ( argc <= 0 ) { usage(); } else { argv++; input_offset = atoi( *argv ); } } /* Print all scanner messages on stdout */ else if (!strncmp(*argv,"-more", 5 ) ) { argc--; if ( argc <= 0 ) { usage(); } else { argv++; verbose=atoi( *argv ); if ( verbose < 0 || verbose > 5 ) { verbose = 0; usage(); } } } else { usage(); exit( 0 ); } } if ( verbose > 2 ) { if ( !input_keep_image ) fprintf( stdout, "scan345: Images will not be transformed...\n"); if ( input_keep_spiral ) fprintf( stdout, "scan345: Spiral files will be produced ...\n"); if ( skip_selftest ) fprintf( stdout, "scan345: Selftest will be skipped ...\n"); } /************************************************ * Figure out if we are in control of scanner ************************************************/ scanner_status = marStartup( ); if ( !netcontrol ) { raise(SIGSTOP); fprintf( stdout, "scan345: continue WITHOUT network control !!!\n"); } /* Read scanner status to get current scanner info */ i = get_status(); sleep( 1 ); i = get_status(); /* Register signal handlers */ if ( netcontrol == 1 ) { signal( SIGINT, mar_kill ); signal( SIGKILL, mar_kill ); signal( SIGTERM, mar_kill ); /* Abort signal */ signal( SIGQUIT, mar_abort); signal( SIGPIPE, mar_kill ); } else { signal( SIGCONT, mar_sig ); signal( SIGUSR1, mar_sig ); } /* Startup procedure */ i=marTask( MDC_COM_STARTUP, 1.0 ); }
void Scan345::usage | ( | ) |
Definition at line 277 of file scan345.cpp.
Referenced by scan345_main().
{ printf( "scan345: wrong arguments on command line\n"); printf( "Usage is: scan345 [options]\n"); printf( " [-more 0...3] verbose level\n"); #ifdef DEBUG printf( " [-debug 0...3] debugging level\n"); #endif printf( " [-noself] skip selftest\n"); printf( " [-noxf] do not transform spirals\n"); printf( " [-noop] do not write output file\n"); printf( " [-host host] host name of scanner\n"); printf( " [-port port] port number of scanner\n"); printf( " [-setd] allow to set distance\n"); printf( " [-off offset] apply offset to spiral data\n"); printf( " [-sc scale ] apply scale to spiral data\n"); printf( " [-h] help\n"); exit( 0 ); }