void main( int argc, char** argv) { //struct Position Pos; int Ix; strcpy( ConfigFile, "config.dat"); Parity = NoneParity; DataBits = 8; StopBits = 1; CalledByGuideFlag = No; KeepGoingFlag = No; ReadSlewFlag = No; StartScrollFlag = No; /* if '-k' and '-s' (after full init): slew to Ra, Dec in slew.dat and keep going, exiting when desired, writing slew_out.dat file; if '-k' (before full init): (no slew.dat), keep going until centered on init position, write slew_out.dat file and exit; if '-s': slew to Ra, Dec in slew.dat and exit, writing slew_out.dat file; if no '-k' and no '-s': write slew_out.dat file and exit; if -c, then use following string as configuration file name, ie scope.exe -c config.dat will result in config.dat being used if -x, then use following string as scroll file name, and execute scroll file upon program startup, ie scope.exe -x nan.scr will cause nan.scr to be loaded and started */ /* argv[0] is name of executing program */ for( Ix = 1; Ix < argc; Ix++) if( argv[Ix][0] == '-') if( strcmpi( &argv[Ix][1], "GUIDE") == 0) CalledByGuideFlag = Yes; else if( argv[Ix][1] == 'k') KeepGoingFlag = Yes; else if( argv[Ix][1] == 's') ReadSlewFlag = Yes; else if( (argv[Ix][1] == 'c' || argv[Ix][1] == 'C') && Ix < argc-1) strcpy( ConfigFile, argv[Ix+1]); else if( (argv[Ix][1] == 'x' || argv[Ix][1] == 'X') && Ix < argc-1) { strcpy( ScrollFilename, argv[Ix+1]); StartScrollFlag = Yes; } InitCommonVars(); ReadConfig(); /* Pos.Ra = Pos.Dec = 0; applyCorrectionsFromDataFileCoordYearToEpochNow(&Pos); printf("\n%f %f %f %f %f %f %f %f", Pos.Precession.A*RadToArcsec, Pos.Precession.Z*RadToArcsec, Pos.Nutation.A*RadToArcsec, Pos.Nutation.Z*RadToArcsec, Pos.AnnualAberration.A*RadToArcsec, Pos.AnnualAberration.Z*RadToArcsec, Pos.Ra*RadToArcsec, Pos.Dec*RadToArcsec); ContMsgRoutine(); */ /* HsRecFile = fopen( HsRecFilename, "w"); if( HsRecFile == NULL) BadExit( strcat( "Could not create ", HsRecFilename)); HsRecIx = 0; */ /* InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitConvert(); TestConvert(); getch(); TestAltAltAzTrack(); */ if( DisplayOpeningMsgs) { printf( "\nCopyright BBAstroDesigns Inc. 2009\n"); printf( "\nLIMITED WARRANTY This software is provided ``as is'' and any express or"); printf( "\nimplied warranties, including, but not limited to, the implied warranties"); printf( "\nof merchantability and fitness for a particular purpose are disclaimed."); printf( "\nIn no event shall BBAstroDesigns be liable for any direct, indirect,"); printf( "\nincidental, special, exemplary, nor consequential damages (including, but"); printf( "\nnot limited to, procurement of substitute goods or services, loss of use,"); printf( "\ndate, or profits, or business interruption) however caused and on any"); printf( "\ntheory of liability, whether in contract, strict liability, or tort"); printf( "\n(including negligence or otherwise) arising in any way out of the use of"); printf( "\nthis software, even if advised of the possibility of such damage.\n"); printf( "\nThis software licensed under the GNU GENERAL PUBLIC LICENSE. You may"); printf( "\ndistribute this software per the GNU GPL. See the enclosed gpl.txt.\n\n"); ContMsgRoutine(); } if( DisplayOpeningMsgs) printf( "\ncalled by guide: %d, keep_going: %d, read slew.dat file %d", CalledByGuideFlag, KeepGoingFlag, ReadSlewFlag); /* if( strcmpi( TestString, "TestSerial") == 0) { InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits); TestSerial( EncoderComPort); CloseSerial( EncoderComPort); } */ /* else if( strcmpi( TestString, "TestVideo") == 0) { InitVideo( DisplayOpeningMsgs); TestVideo(); } */ /* else if( strcmpi( TestString, "TestATimes") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); TestTimes(); } */ /* else if( strcmpi( TestString, "TestParallelPort") == 0) { InitPPort(); TestPPort(); ClosePPort(); } */ /* else if( strcmpi( TestString, "TestRefract") == 0) { InitRefract(); TestRefract(); } */ /* else if( strcmpi( TestString, "TestMouse") == 0) { TestMouse(); } */ /* else if( strcmpi( TestString, "TestEncoders") == 0) { InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits); InitEncoders(); TestEncoders(); CloseSerial( EncoderComPort); } */ /* else if( strcmpi( TestString, "TestHandpad") == 0) { InitPPort(); InitializeHandpad(); TestHandpad(); ClosePPort(); } */ /* else if( strcmpi( TestString, "TestConversion") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitConvert(); TestConvert(); } */ /* else if( strcmpi( TestString, "TestAltOffset") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitConvert(); TestAltOffset(); } */ /* else if( strcmpi( TestString, "TestIACA") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); TestIACA(); InitIACA(); } */ /* else if( strcmpi( TestString, "WritePWMValues") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitVideo( DisplayOpeningMsgs); InitPPort(); InitMotors(); WritePWMValues(); CloseSteppers(); ClosePPort(); } else */ { if( strcmpi( TestString, "NoTest") != 0 && strcmpi( TestString, "PreloadGuidexx.dat") != 0 && strcmpi( TestString, "Track") != 0) { if( DisplayOpeningMsgs) printf( "\nsetting unrecognized TestString to 'NoTest'"); strcpy( TestString, "NoTest"); } InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits); InitEncoders(); InitMouseControl(); InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitVideo( DisplayOpeningMsgs); InitPPort(); InitializeHandpad(); InitMotors(); InitConvert(); InitRefract(); InitPEC(); InitGuide(); if( strcmpi( TestString, "PreloadGuidexx.dat") == 0) { LoadGuideAlts(); LoadGuideAzs(); } InitIACA(); InitLX200Input(); InitHPEvent(); if( !CalledByGuideFlag || (CalledByGuideFlag && (KeepGoingFlag || ReadSlewFlag))) { InitKBEvent(); if( ReadSlewFlag) InputEquatSlewDat(); if( StartScrollFlag) LoadScrollFileFromFile(); if( strcmpi( TestString, "Track") == 0) Start2MotorTrackWithDefaultValues(); while( !QuitFlag) { SequentialTaskController(); /* GrandTourFlag used to flag next object: set in ProcessHPEventsModeSwitch() */ if( GrandTourLoaded && GrandTourFlag) ProcessGrandTour(); else if( ScrollLoaded && ScrollFlag) ProcessScroll(); else if( HPPolarAlignLoaded && HPPolarAlignFlag) ProcessHPPolarAlign(); else { if( UseMouseFlag && ProcessMouseEvent()) ; else if( KeyStroke) ProcessKBEvents(); else ProcessHPEvents(); } } CloseKBEvent(); if( DisplayOpeningMsgs) { AskAndWriteConfig(); WriteLogFile(); } } CloseSteppers(); ClosePPort(); CloseEncoderResetLogFile(); CloseSerial( EncoderComPort); CloseSerial( LX200ComPort); if( CalledByGuideFlag) WriteAltazSlewOutFile(); CloseMouseControl(); } /* for( Ix = 0; Ix < HsRecSize; Ix++) fprintf( HsRecFile, "%8ld %8ld\n", HsRec[Ix].A, HsRec[Ix].Z); // first position is index 0 fprintf( HsRecFile, " last entry in circular queue at position %d", HsRecIx); fclose( HsRecFile); */ }
int main (int argc, char *argv[]) { int status = 0; static char eoferrmsg[] = "Unexpected end of file in %s section of file \"%s\" (line %d)\n"; parseoptions(argc, argv); InitTables(); InitConvert(); errno = 0; infp = fopen(Inputfile, "r"); if(!infp) { fprintf(stderr, "Can't open file '%s' for input (E%d: %s)\n", Inputfile, errno, strerror(errno)); exit(-1); } /* Initialise group */ Group.line = 0; /* Read DXF file and write Radiance data. */ next_group(infp, &Group); while (!feof(infp) && strcmp(Group.value,FILEEND) != 0) { if(Group.code == 0) { if(strcmp(Group.value, SECTION) == 0) { next_group(infp, &Group); /* code 2 group */ if(strcmp(Group.value,HEADER) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Reading headers\n"); } HeaderSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "HEADER", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,CLASSES) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Ignoring classes\n"); } IgnoreSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "CLASSES", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,TABLES) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Reading tables\n"); } TablesSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "TABLES", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,BLOCKS) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Reading blocks\n"); } BlocksSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "BLOCKS", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,ENTITIES) == 0) { if(Options.geom) { int i; time_t ltime; if(*Outputfile == '\0') { outf = stdout; } else { errno = 0; outf = fopen((const char*)&Outputfile, "w"); if(outf == NULL) { fprintf(stderr, "Can't open file '%s' for output (E%d: %s)\n", Outputfile, errno, strerror(errno)); exit(1); } } (void)time(<ime); fprintf(outf, "## Radiance geometry file \"%s\"\n", Outputfile[0] ? Outputfile : "<stdout>"); fprintf(outf, "## Converted by dxf2rad %s: %s##", DXF2RAD_VER, ctime(<ime)); for(i = 0; i < argc; i ++) { fprintf(outf, " %s", argv[i]); } fprintf(outf, "\n\n"); if(Options.verbose > 0) { fprintf(stderr, " Reading entities\n"); } EntitiesSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "ENTITIES", Inputfile, Group.line); status = -1; } } else { if(Options.verbose > 0) { fprintf(stderr, " Ignoring entities\n"); } IgnoreSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "ENTITIES", Inputfile, Group.line); status = -1; } } } else if(strcmp(Group.value,OBJECTS) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Ignoring objects\n"); } IgnoreSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "OBJECTS", Inputfile, Group.line); status = -1; } } } } next_group(infp, &Group); } if(outf) { if (status == 0) { fprintf(outf, "\n## End of Radiance geometry file \"%s\"\n\n", Outputfile[0] ? Outputfile : "<stdout>"); } fclose(outf); } fclose(infp); return status; }