char xefifoinbuffer[1024] = "\0"; FILE *xefifoin = NULL; pthread_t xefifooutloopthread; xefifo_alert( char * txt ) { monitor_alert(txt); } void sendCurrentKoorsToXephem( void ) { double ra,dec; FILE *fp; if( xephem.fifooutfile[0] == 0 ){ return; } fp = fopen( &xephem.fifooutfile[0], "wt" ); if( fp == NULL ) { return; } ra = rad( ( StrDegreesToDouble( prog.rastr, 1 )) * 15.0 ); dec = rad( StrDegreesToDouble( prog.decstr, 0 ) / 3600.0 ); fprintf( fp, "RA:%02.6f Dec:%02.6f Epoch:%04.3f\n",ra,dec,2000.0); fclose(fp); } void xephemfifooutloop ( char *data ) { RADEC radec; int motorvalue; char *p; xephem.fifooutloopbusy = 1; motorvalue = prog.motorrun; while( ( prog.motorrun == motorvalue ) && xephem.fifooutloopbusy && prog.looprun && xephem.fifooutloop ){ sleep(xephem.fifooutloop); StrAZAltToStrRADec( prog.azstr, prog.altstr, scope.utcadjust, scope.latitude, scope.longitude, &radec ); p = DoubleToStrDegrees( radec.ra * 3600.0 * 15.0, 1 ); if( p == NULL){ break; } strcpy( prog.rastr, p ); p = DoubleToStrDegrees( radec.dec * 3600.0, 0 ); if( p == NULL){ break; } strcpy( prog.decstr, p ); sendCurrentKoorsToXephem( ); } xephem.fifooutloopbusy = 0; } int xephemfifooutloopstart( void ) { if(! prog.motorrun ){ return(1); } if(! xephem.fifooutloop ){ return(1); } if(! xephem.start ){ return(1); } if( xephem.keypadspecial){ return(1); } if(xephem.fifooutloopbusy == 0){ if( pthread_create( &xefifooutloopthread, NULL, (void *)&xephemfifooutloop, NULL ) != 0 ){ return( 0 ); } } return(1); } int xephemfifowork( void ) { EDBOBJ obj; if( setEDBobjFromStr( &obj, xefifoinbuffer ) ) { strcpy( prog.objname, obj.objname ); strcpy( prog.objtype, obj.objtype); waitTillLoopFree( ); strcpy(prog.rastr, obj.rastr); strcpy(prog.decstr,obj.decstr); doLoopEvent( PREVT_MARKRADECKOORS ); return(1); } strcpy( prog.objname, obj.objname ); strcpy( prog.objtype, obj.objtype); return(1); } void xephemfifoloop ( char *data ) { int len; xephem.xefiforun = 1; while( xephem.xefiforun ) { xefifoin = fopen(xephem.fifoinfile,"rt"); if( xefifoin == NULL ){ xefifo_alert("Cannot open xephem fifoin"); xephem.xefiforun = 0; continue; } len = fread( &xefifoinbuffer[0], 128 , 1 , xefifoin); fclose(xefifoin); xephemfifowork(); } } int xephemfifostart( void ) { if( ! xephem.start ) { return(1); } if( xephem.fifoinfile[0] == 0 ) { xefifo_alert("XEPHEMFIFO is on, but no inputfile defined"); return(0); } if( pthread_create( &xephem.xefifothread, NULL, (void *)&xephemfifoloop, NULL ) != 0 ){ return( 0 ); } return(1); }