Example #1
0
static void setup_aster_kalman_dtrat(ASTER_S *aster, STAR_S *star, const PARMS_S *parms, int idtrat_wfs0){
    if(parms->skyc.verbose){
	info2("aster %d dtrat_wfs0=%3d, dtrat=", aster->iaster, 
	      (int)parms->skyc.dtrats->p[idtrat_wfs0]);
    }
    for(int iwfs=0; iwfs<aster->nwfs; iwfs++){
	int idtrat=idtrat_wfs0;
	if(iwfs>0){
	    /*don't allow snr to fall below 3.*/
	    while(idtrat>0 && (aster->wfs[iwfs].pistat->snr->p[idtrat]<3
			       || (int)parms->skyc.dtrats->p[idtrat] % (int)aster->dtrats->p[0]!=0)){
		idtrat--;
	    }
	}
	aster->idtrats->p[iwfs]=idtrat;
	aster->dtrats->p[iwfs]=parms->skyc.dtrats->p[idtrat];
	int ng=aster->g->p[iwfs]->nx;
	if(idtrat>-1){
	    for(int ig=0; ig<ng; ig++){
		aster->neam[0]->p[iwfs+aster->nwfs*iwfs]->p[ig*(ng+1)]=
		    pow(aster->wfs[iwfs].pistat->sanea->p[idtrat]->p[ig], 2);
	    }
	}else{//no star available
	    dset(aster->neam[0]->p[iwfs+aster->nwfs*iwfs], 0);
	}
	if(parms->skyc.verbose){
	    info2("%3d ", (int)parms->skyc.dtrats->p[idtrat]);
	}
    }//for iwfs
}
Example #2
0
void signup_traction()
{
i.x.ax=0;
int86(0x33,&i,&o);
i.x.ax=1;
int86(0x33,&i,&o);

while(!kbhit())
{
i.x.ax=3;  cl=o.x.bx;
int86(0x33,&i,&o);
gotoxy(2,2);  tx=o.x.cx;ty=o.x.dx;       //trac control.
printf("x->=%d     \n y->=%d    %d  ",o.x.cx,o.x.dx,cl);

if((tx>=540 && tx<=591) && (ty>=10 && ty<=15) && cl==1)
{cleardevice();info();}
get();


if((tx>=451 && tx<=629) && (ty>=341 && ty<=345) && cl==2)
{cleardevice();info2();ip_traction();}
}
i.x.ax=2;
int86(0x33,&i,&o);
}
Example #3
0
bool ComponentPeer::handleDragDrop (const ComponentPeer::DragInfo& info)
{
    handleDragMove (info);

    Component* const targetComp = dragAndDropTargetComponent;

    if (targetComp != nullptr)
    {
        dragAndDropTargetComponent = nullptr;
        lastDragAndDropCompUnderMouse = nullptr;

        if (DragHelpers::isSuitableTarget (info, targetComp))
        {
            if (targetComp->isCurrentlyBlockedByAnotherModalComponent())
            {
                targetComp->internalModalInputAttempt();

                if (targetComp->isCurrentlyBlockedByAnotherModalComponent())
                    return true;
            }

            ComponentPeer::DragInfo info2 (info);
            info2.position = targetComp->getLocalPoint (component, info.position);

            (new DragHelpers::AsyncDropMessage (targetComp, info2))->post();
            return true;
        }
    }

    return false;
}
Example #4
0
   static bool WriteImage( FileFormatInstance* instance, const I& image )
   {
      if ( !image.IsShared() || !image.IsCompletelySelected() )
      {
         I tmp( (void*)0, 0, 0 );
         tmp.Assign( image );
         return WriteImage( instance, tmp );
      }

      image.PushSelections();
      image.ResetSelections();

      ImageInfo info1( image );

      image.PopSelections();

      bool ok = (*API->FileFormat->WriteImage)( instance->handle, image.Allocator().Handle() ) != api_false;

      image.PushSelections();
      image.ResetSelections();

      ImageInfo info2( image );

      image.PopSelections();

      if ( info1 != info2 )
         APIHackingAttempt( "WriteImage" );

      return ok;
   }
Example #5
0
/**
   Setting up aperture cordinate grid aper_locs, and amplitude map for
performance evaluation. */
APER_T * setup_aper(const PARMS_T *const parms){
    APER_T *aper = mycalloc(1,APER_T);
    tic;
    if(parms->aper.fnamp){
	info2("Reading aperture amplitude map from %s\n", parms->aper.fnamp);
	aper->ampground=mapread("%s",parms->aper.fnamp);
	if(fabs(aper->ampground->h)>1.e-14){
	    warning("ampground is not on ground, this is not tested\n");
	}else{
	    double amp_d, amp_din;
	    map_d_din(aper->ampground, &amp_d, &amp_din);
	    if(fabs(parms->aper.d - amp_d) > 1 ||
	       fabs(parms->aper.din - amp_din) > 0.5){
		if(!parms->aper.fnampuser){
		    warning2("Amplitude map does not match aperture diameter: amp.d=(%g, %g) aper.d=(%g, %g). Disabled\n", 
			     amp_d, amp_din, parms->aper.d, parms->aper.din);
		    mapfree(aper->ampground);
		    free(((PARMS_T*)parms)->aper.fnamp);
		    ((PARMS_T*)parms)->aper.fnamp=0;
		}else{
		    error("Use supplied amplitude map does not match aperture diameter: amp.d=(%g, %g) aper.d=(%g, %g).\n", 
			  amp_d, amp_din, parms->aper.d, parms->aper.din);
		}
	    }
	}
	if(fabs(parms->aper.rotdeg)>1.e-12){
	    warning("Pupil is rotated by %g deg\n",parms->aper.rotdeg);
	    const long nx=aper->ampground->nx;
	    const long ny=aper->ampground->ny;
	    dmat *B=dnew_data(nx, ny, aper->ampground->p);
	    aper->ampground->p=mycalloc(nx*ny,double);
	    dembed((dmat*)aper->ampground,B,parms->aper.rotdeg/180.*M_PI);
	    dfree(B);
	}
Example #6
0
bool ProcessInstance::CanExecuteOn( const ImageVariant& image, String& whyNot ) const
{
   if ( !image.IsSharedImage() || !image.IsCompletelySelected() )
   {
      ImageVariant tmp;
      tmp.CreateSharedImageAs( image ).AssignImage( image );
      return CanExecuteOn( tmp, whyNot );
   }

   image.PushSelections();
   image.ResetSelections();

   ImageInfo info1( *image );

   image.PopSelections();

   whyNot.Clear();
   whyNot.Reserve( WHYNOT_MAXLENGTH );

   bool ok = (*API->Process->ValidateImageExecution)( handle, image.SharedImageHandle(), whyNot.c_str(), WHYNOT_MAXLENGTH ) != api_false;

   image.PushSelections();
   image.ResetSelections();

   ImageInfo info2( *image );

   image.PopSelections();

   if ( info1 != info2 )
      APIHackingAttempt( "ValidateImageExecution" );

   return ok;
}
Example #7
0
/**
   Setup ray tracing operator HXF from xloc to aperture ploc along DM fiting directions*/
static void
setup_recon_HXF(RECON_T *recon, const PARMS_T *parms){
    if(parms->load.HXF && zfexist(parms->load.HXF)){
	warning("Loading saved HXF\n");
	recon->HXF=dspcellread("%s",parms->load.HXF);
    }else{
	info2("Generating HXF");TIC;tic;
	const int nfit=parms->fit.nfit;
	const int npsr=recon->npsr;
	recon->HXF=cellnew(nfit, npsr);
	PDSPCELL(recon->HXF,HXF);
	for(int ifit=0; ifit<nfit; ifit++){
	    double hs=parms->fit.hs->p[ifit];
	    for(int ips=0; ips<npsr; ips++){
		const double ht = recon->ht->p[ips];
		const double scale=1.-ht/hs;
		double displace[2];
		displace[0]=parms->fit.thetax->p[ifit]*ht;
		displace[1]=parms->fit.thetay->p[ifit]*ht;
		HXF[ips][ifit]=mkh(recon->xloc->p[ips], recon->floc, 
				   displace[0], displace[1], scale);
	    }
	}
	if(parms->save.setup){
	    writebin(recon->HXF,"HXF");
	}
	toc2(" ");
    }
}
Example #8
0
void MixerAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info)
{
    const ScopedLock sl (lock);

    if (inputs.size() > 0)
    {
        inputs.getUnchecked(0)->getNextAudioBlock (info);

        if (inputs.size() > 1)
        {
            tempBuffer.setSize (jmax (1, info.buffer->getNumChannels()),
                                info.buffer->getNumSamples());

            AudioSourceChannelInfo info2 (&tempBuffer, 0, info.numSamples);

            for (int i = 1; i < inputs.size(); ++i)
            {
                inputs.getUnchecked(i)->getNextAudioBlock (info2);

                for (int chan = 0; chan < info.buffer->getNumChannels(); ++chan)
                    info.buffer->addFrom (chan, info.startSample, tempBuffer, chan, 0, info.numSamples);
            }
        }
    }
    else
    {
        info.clearActiveBufferRegion();
    }
}
Example #9
0
/*
static int test_fft_speed_small(){
    int nis=128;
    int *is=mycalloc(nis,int);
    dmat *tim=dnew(nis,1);
    for(int ii=0; ii<nis; ii++){
	is[ii]=ii+1;
    }
    ccell *ac=cellnew(nis,1);
    rand_t stat;
    seed_rand(&stat,1);
    for(int ii=0; ii<nis; ii++){
	ac->p[ii]=cnew(is[ii],is[ii]);
	//cfft2plan(ac->p[ii],-1);
	crandn(ac->p[ii],20,&stat);
    }
    TIC;
    for(int ii=0; ii<nis; ii++){
	info2("size %4d: ",is[ii]);
	tic;
	for(int i=0; i<1000; i++){
	    cfft2(ac->p[ii],-1);
	}
	toc2("fft");
	tim->p[ii]=toc3;
    }
    writebin(tim,"fft_timing");
}

static void test_fft_speed(){
    int nis=2048;
    int *is=mycalloc(nis,int);
    dmat *tim=dnew(nis,1);
    for(int ii=0; ii<nis; ii++){
	is[ii]=(ii+1)*2;
    }
    ccell *ac=cellnew(nis,1);
    rand_t stat;
    seed_rand(&stat,1);
    TIC;
    for(int ii=0; ii<nis; ii++){
	info2("size %4d: ",is[ii]);
	tic;
	ac->p[ii]=cnew(is[ii],is[ii]);
	//cfft2plan(ac->p[ii],-1);
	crandn(ac->p[ii],20,&stat);
	toc("plan");
    }
    toc("plan");
    for(int ii=0; ii<nis; ii++){
	info2("size %4d: ",is[ii]);
	tic;
	int nrepeat;
	if(is[ii]<300)
	    nrepeat=100;
	else if(is[ii]<1000)
	    nrepeat=10;
	else
	    nrepeat=1;

	for(int i=0; i<nrepeat; i++){
	    cfft2(ac->p[ii],-1);
	}
	toc2("fft");
	tim->p[ii]=toc3/nrepeat;
    }
    writebin(tim,"fft_timing");
    }*/
static void test_fft_special(){
    int nis=2;
    int *is=mycalloc(nis,int);
    dmat *tim=dnew(nis,1);
    is[0]=3824;
    is[1]=4096;
    ccell *ac=ccellnew(nis,1);
    rand_t rstat;
    seed_rand(&rstat,1);
    TIC;
    for(int ii=0; ii<nis; ii++){
	info2("size %4d: ",is[ii]);
	tic;
	ac->p[ii]=cnew(is[ii],is[ii]);
	//cfft2plan(ac->p[ii],-1);
	//cfft2partialplan(ac->p[ii],512,-1);
	crandn(ac->p[ii],20,&rstat);
	toc("plan");
    }

    for(int ii=0; ii<nis; ii++){
	info2("size %4d: ",is[ii]);
	tic;
	int nrepeat;
	if(is[ii]<300)
	    nrepeat=100;
	else if(is[ii]<1000)
	    nrepeat=10;
	else
	    nrepeat=4;

	for(int i=0; i<nrepeat; i++){
	    cfft2(ac->p[ii],-1);
	}
	toc2("fft");
	for(int i=0; i<nrepeat; i++){
	    cfft2partial(ac->p[ii],512,-1);
	}
	toc2("fft2partial");
	tim->p[ii]=toc3/nrepeat;
    }
    writebin(tim,"fft_timing");

}
bool ComponentPeer::handleDragExit (const ComponentPeer::DragInfo& info)
{
    DragInfo info2 (info);
    info2.position.setXY (-1, -1);
    const bool used = handleDragMove (info2);

    jassert (dragAndDropTargetComponent == nullptr);
    lastDragAndDropCompUnderMouse = nullptr;
    return used;
}
Example #11
0
int FileListItem::compare( QListViewItem * i, int col, bool ascending ) const
{
	QFileInfo info1( key( col, ascending ) ); //this
	QFileInfo info2( i->key( col, ascending ) ); //that
    int fileComp = info1.fileName().compare( info2.fileName() );
	if ( fileComp != 0 )
		return fileComp;
	else
		return info1.extension().compare( info2.extension() );
}
Example #12
0
int RawConverter::CompareTwoRawDerVhf( const string& src1,
                                       const string& src2 )
{
    std::cout << "Comparing two raw+derivatives+vhf" << endl;
    unsigned  w1,  h1,  d1;
    unsigned  w2,  h2,  d2;
    float    sw1, sh1, sd1;
    float    sw2, sh2, sd2;

    vector< unsigned char > TF1( 256*4, 0 );
    vector< unsigned char > TF2( 256*4, 0 );

    //reading headers
    string configFileName = src1;
    hFile info( fopen( configFileName.append( ".vhf" ).c_str(), "rb" ) );
    FILE* file = info.f;

    if( file==NULL ) return lFailed( "Can't open first header file" );

    //reading dimensions
    readDimensionsFromSav( file,  w1,  h1,  d1 );
    if( readScalesFormSav( file, sw1, sh1, sd1 ) )
        lFailed( "Wrong format of the first header file" );

    //reading transfer function
    const size_t tfSize1 = readTransferFunction( file, TF1 );

    configFileName = src2;
    hFile info2( fopen( configFileName.append( ".vhf" ).c_str(), "rb" ) );
    file = info2.f;

    if( file==NULL ) return lFailed( "Can't open first header file" );

    readDimensionsFromSav( file,  w2,  h2,  d2 );
    if( readScalesFormSav( file, sw2, sh2, sd2 ) )
        lFailed( "Wrong format of the second header file" );

    //reading transfer function
    const size_t tfSize2 = readTransferFunction( file, TF2 );

    //comparing headers
    if( w1!=w2 ) return lFailed(" Widths are not equal ");
    if( h1!=h2 ) return lFailed(" Heights are not equal ");
    if( d1!=d2 ) return lFailed(" Depths are not equal ");

    if( sw1!=sw2 ) std::cout << " Widths'  scales are not equal " << endl;
    if( sh1!=sh2 ) std::cout << " Heights' scales are not equal " << endl;
    if( sd1!=sd2 ) std::cout << " Depths'  scales are not equal " << endl;

    if( tfSize1!=tfSize2 ) std::cout << " TF sizes are not equal" << endl;

    std::cout << "done" << endl;
    return 0;
}
Example #13
0
static vkcov_t *vkcov_get(double r0, double L0, double dx, long n, long ninit){
    for(vkcov_t *p=head; p; p=p->next){
	if(fabs(p->r0-r0)<EPS && (fabs(p->L0-L0)<EPS || (!isfinite(p->L0) && !isfinite(L0)))
	   && fabs(p->dx-dx)<EPS && p->n == n && p->ninit==ninit){
	    return p;
	}
    }
    info2("compute vkcov with r0=%g, L0=%g, dx=%g, n=%ld, ninit=%ld\n",
	 r0, L0, dx, n, ninit);
    return NULL;
}
Example #14
0
void TestPageTextInfo::testPageNumber()
{
    KWPageManager manager;
    QCOMPARE(manager.pageCount(), 0);

    KWPage page1 = manager.appendPage();
    KWPage page2 = manager.appendPage();
    KWPage page3 = manager.appendPage();
    KWPage page4 = manager.appendPage();
    KWPage page5 = manager.appendPage();

    KWPageStyle style2("foo");
    manager.addPageStyle(style2);
    KWPage page40 = manager.appendPage(style2);
    QCOMPARE(page40.pageNumber(), 6);
    page40.setPageNumber(40);
    QCOMPARE(page5.pageNumber(), 5);
    QCOMPARE(page40.pageNumber(), 40);
    KWPage page41 = manager.appendPage();
    QCOMPARE(page41.pageNumber(), 41);

    KWPageTextInfo info1(page1);
    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 0), 1);
    QCOMPARE(info1.pageNumber(KoTextPage::PreviousPage, 0), -1);
    QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 0), 2);

    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 4), 5);
    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 5), -1);
    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 40), 41);
    QCOMPARE(info1.pageNumber(KoTextPage::PreviousPage, 1), -1);
    QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 3), 5);
    QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 4), -1);

    KWPageTextInfo info2(page2);
    QCOMPARE(info2.pageNumber(KoTextPage::CurrentPage, 0), 2);
    QCOMPARE(info2.pageNumber(KoTextPage::PreviousPage, 0), 1);
    QCOMPARE(info2.pageNumber(KoTextPage::NextPage, 0), 3);

    KWPageTextInfo info3(page5);
    QCOMPARE(info3.pageNumber(KoTextPage::CurrentPage, 0), 5);
    QCOMPARE(info3.pageNumber(KoTextPage::PreviousPage, 0), 4);
    QCOMPARE(info3.pageNumber(KoTextPage::NextPage, 0), 40);

    KWPageTextInfo info40(page40);
    QCOMPARE(info40.pageNumber(KoTextPage::CurrentPage, 0), 40);
    QCOMPARE(info40.pageNumber(KoTextPage::PreviousPage, 0), 5);
    QCOMPARE(info40.pageNumber(KoTextPage::NextPage, 0), 41);

    KWPageTextInfo info41(page41);
    QCOMPARE(info41.pageNumber(KoTextPage::CurrentPage, 0), 41);
    QCOMPARE(info41.pageNumber(KoTextPage::PreviousPage, 0), 40);
    QCOMPARE(info41.pageNumber(KoTextPage::NextPage, 0), -1);
}
Example #15
0
/* Record the host after connection is established*/
static void host_added(int ihost, int sock){
    htime[ihost]=myclockd();
    proc_remove_all(ihost);/*remove all entries. */
    LOCK(mhost);
    nhostup++;
    hsock[ihost]=sock;
    FD_SET(sock, &active_fd_set);
    UNLOCK(mhost);
    add_host_wrap(-1);//wakes up listen_host().
    info2("connected to %s\n", hosts[ihost]);
    gdk_threads_add_idle(host_up, GINT_TO_POINTER(ihost));
}
Example #16
0
	bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info)
	{
		if (m_input.isConnected()) {
			//Build the render data
			TRenderSettings info2(info);
			buildBlendData(info2, frame);

			return m_input->doGetBBox(frame, bBox, info2);
		} else {
			bBox = TRectD();
			return false;
		}
	}
Example #17
0
/*remove the host upon disconnection*/
static void host_removed(int sock){
    int ihost=host_from_sock(sock);
    if(ihost==-1) return;
    close(sock);
    LOCK(mhost);
    nhostup--;
    hsock[ihost]=-1;
    FD_CLR(sock, &active_fd_set);
    UNLOCK(mhost);
    add_host_wrap(-1);
    gdk_threads_add_idle(host_down, GINT_TO_POINTER(ihost));
    info2("disconnected from %s\n", hosts[ihost]);
}
Example #18
0
File: skyc.c Project: bitursa/maos
/**
   The main(). It parses the command line, setup the parms, ask the scheduler
   for signal to proceed, and then starts skysim to do sky coverage.
 */
int main(int argc, const char *argv[]){
    dirstart=mygetcwd();
    char *scmd=argv2str(argc, argv, " ");
    ARG_S* arg=parse_args(argc,argv);
    /*In detach mode send to background and disable drawing*/
    if(arg->detach){
	daemonize();
    }else{
	redirect();
    }
    info2("%s\n", scmd);
    info2("Output folder is '%s'. %d threads\n",arg->dirout, arg->nthread);
    skyc_version();
    /*register signal handler */
    register_signal_handler(skyc_signal_handler);
    /*
      Ask job scheduler for permission to proceed. If no CPUs are available,
      will block until ones are available.  if arg->force==1, will run
      immediately.
    */
    scheduler_start(scmd,arg->nthread,0,!arg->force);
    /*setting up parameters before asking scheduler to check for any errors. */
    dirsetup=stradd("setup",NULL);
    PARMS_S * parms=setup_parms(arg);
    if(parms->skyc.dbg){
	mymkdir("%s",dirsetup);
    }
    if(!arg->force){
	info2("Waiting start signal from the scheduler ...\n");
	/*Failed to wait. fall back to own checking.*/
	int count=0;
	while(scheduler_wait()&& count<60){
	    warning_time("failed to get reply from scheduler. retry\n");
	    sleep(10);
	    count++;
	    scheduler_start(scmd,arg->nthread,0,!arg->force);
	}
	if(count>=60){
	    warning_time("fall back to own checker\n");
	    wait_cpu(arg->nthread);
	}
    }
    info2("Simulation started at %s in %s.\n",myasctime(),myhostname());
    free(scmd);
    free(arg->dirout);
    free(arg);
    THREAD_POOL_INIT(parms->skyc.nthread);
    /*Loads the main software*/
    OMPTASK_SINGLE skysim(parms);
    free_parms(parms);
    free(dirsetup);
    free(dirstart);
    rename_file(0);
    scheduler_finish(0);
    info2("End:\t%.2f MiB\n",get_job_mem()/1024.);
    info2("Simulation finished at %s in %s.\n",myasctime(),myhostname());
    return 0;
}
Example #19
0
int
module_boot()
{
    int i;
    static char nm[] = "module_boot";
    char buf[MSG_SIZE];

    module_count = sizeof modules / sizeof *modules;
    snprintf(buf, sizeof buf, "%d compiled signature modules",module_count);
    info2(nm, buf);

    if (module_count == 0)
        panic2(nm, "no compiled signature modules");

    /*
     *  Double check that modules are stored lexical order by name.
     */
    for (i = 1;  i < module_count;  i++) {
        if (strcmp(modules[i - 1]->name, modules[i]->name) >= 0)
            panic3("module_init: modules out of order",
                   modules[i - 1]->name, modules[i]->name);
    }

    for (i = 0;  i < module_count;  i++) {
        struct digest_module *mp = modules[i];

        info2("booting signature digest module", mp->name);
        if (mp->boot) {
            int status;

            status = (*mp->boot)();
            if (status != 0)
                panic3(nm, mp->name, "boot() failed");
        }
    }
    return 0;
}
Example #20
0
File: main.c Project: bitursa/maos
void maos_version(void){
    info2("MAOS Version %s. Compiled on %s %s by %s, %d bit", PACKAGE_VERSION, __DATE__, __TIME__, __VERSION__, (int)sizeof(long)*8);
#if USE_CUDA
    info2(", w/t CUDA");
#else
    info2(", w/o CUDA");
#endif
#ifdef __OPTIMIZE__
    info2(", w/t optimization.\n");
#else
    info2(", w/o optimization\n");
#endif
    info2("Source: %s %s\n", SRCDIR, GIT_VERSION);
    info2("BUILD: %s\n", BUILDDIR);
    info2("Launched at %s in %s with PID %ld.\n",myasctime(),myhostname(), (long)getpid());
#if HAS_LWS
    extern uint16_t PORT;
    info2("The web based job monitor can be accessed at http://localhost:%d\n", 1+PORT);
#endif
}
Example #21
0
QString MainWindow::extraThemes()
{
    QDir dir(QString(m_confDir).append("/theme"));
    if (!dir.exists())
        return toJSArray();

    QStringList dirList = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs);
    QStringList themeList;

    Q_FOREACH(const QString& themedir, dirList) {
        QFileInfo info1(dir.absoluteFilePath(QString(themedir).append("/info.json")));
        QFileInfo info2(dir.absoluteFilePath(QString(themedir).append("/style.css")));
        if (info1.exists() && info1.isFile() && info2.exists() && info2.isFile())
            themeList << QUrl::fromLocalFile(dir.absoluteFilePath(themedir)).toString();
    }
Example #22
0
File: utils.c Project: lianqiw/maos
/**
   Print out usage information.
 */
static void print_usage(void) {
    info2(
        "Usage: skyc [OPTION...] [FILE]...\n"
        "skyc is a simulation tool developed to do sky coveragepostprocessing\n\n"
        "Options: \n"
        "-h, --help        to print out this message\n"
        "-d, --detach      to detach from terminal and run in background\n"
        "-f, --force       force starting simulation without scheduler\n"
        "-n N, --nthread=N Use N threads, default is 1\n"
        "-o DIR, --output=DIR\n"
        "                  output the results to DIR.\n"
        "-c FILE.conf, --conf=FILE.conf\n"
        "                  Use FILE.conf as the baseline config instead of maos.conf\n"
    );
    exit(0);
}
Example #23
0
File: sock.c Project: bitursa/maos
/**
   make a server port and bind to sockpath. AF_UNIX.
 */
static int bind_socket_local(char *sockpath){
    int sock = socket(AF_UNIX, SOCK_STREAM, 0);
    socket_nopipe(sock);
    struct sockaddr_un addr={0};
    addr.sun_family=AF_UNIX;
    strncpy(addr.sun_path, sockpath, sizeof(addr.sun_path)-1);
    if(bind(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr_un))==-1){
	perror("bind");
	warning("bind to %s failed\n", sockpath);
	close(sock);
	sock=-1;
    }
    if(sock!=-1){
	info2("binded to %s at sock %d\n", sockpath, sock);
    }
    return sock;
}
Example #24
0
void tst_QFileInfo::copy()
{
    QTemporaryFile *t;
    t = new QTemporaryFile;
    t->open();
    QFileInfo info(t->fileName());
    QVERIFY(info.exists());

    //copy constructor
    QFileInfo info2(info);
    QFileInfoPrivate *privateInfo = getPrivate(info);
    QFileInfoPrivate *privateInfo2 = getPrivate(info2);
    QCOMPARE(privateInfo->data, privateInfo2->data);

    //operator =
    QFileInfo info3 = info;
    QFileInfoPrivate *privateInfo3 = getPrivate(info3);
    QCOMPARE(privateInfo->data, privateInfo3->data);
    QCOMPARE(privateInfo2->data, privateInfo3->data);

    //refreshing info3 will detach it
    QFile file(info.absoluteFilePath());
    QVERIFY(file.open(QFile::WriteOnly));
    QCOMPARE(file.write("JAJAJAA"), qint64(7));
    file.flush();

    QTest::qWait(250);
#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
    if (QSysInfo::windowsVersion() & QSysInfo::WV_VISTA ||
                QSysInfo::windowsVersion() & QSysInfo::WV_CE_based)
        file.close();
#endif
#if defined(Q_OS_WINCE)
    // On Windows CE we need to close the file.
    // Otherwise the content will be cached and not
    // flushed to the storage, although we flushed it
    // manually!!! CE has interim cache, we cannot influence.
    QTest::qWait(5000);
#endif
    info3.refresh();
    QVERIFY(privateInfo->data != privateInfo3->data);
    QVERIFY(privateInfo2->data != privateInfo3->data);
    QCOMPARE(privateInfo->data, privateInfo2->data);
}
void 
CommandLineParserTest::testPlugInsWithParameters()
{
  static const char *lines[] = { "", "TestPlugIn1.dll=login = lain",
                           "Clocker.dll", NULL };
  parse( lines );

  CPPUNIT_ASSERT_EQUAL( 2, _parser->getPlugInCount() );

  CommandLinePlugInInfo info1( _parser->getPlugInAt( 0 ) );

  CPPUNIT_ASSERT_EQUAL( std::string("TestPlugIn1.dll"), info1.m_fileName );
  CPPUNIT_ASSERT_EQUAL( std::string("login = lain"), 
                        info1.m_parameters.getCommandLine() );

  CommandLinePlugInInfo info2( _parser->getPlugInAt( 1 ) );
  CPPUNIT_ASSERT_EQUAL( std::string("Clocker.dll"), info2.m_fileName );
  CPPUNIT_ASSERT( info2.m_parameters.getCommandLine().empty() );
}
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    QFile::remove("cache.cdb");
    if (! QFile::copy("cache1.cdb", "cache.cdb")) {
        qDebug() << "Can't copy cache1.cdb!";
        fail();
    }

    sleep(1);

    if (! ContextRegistryInfo::instance()->listKeys().contains("Battery.OnBattery")) {
        qDebug() << "Battery.OnBattery not found in cache1.cdb!";
        fail();
    }

    ContextPropertyInfo info1("Battery.OnBattery");
    if (info1.provided() != true) {
        qDebug() << "Battery.OnBattery should be provided!";
        fail();
    }

    QFile::remove("cache.cdb");
    if (! QFile::copy("cache2.cdb", "cache.cdb")) {
        qDebug() << "Can't copy cache2.cdb!";
        fail();
    }

    sleep(1);

    app.processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 1000);

    ContextPropertyInfo info2("Battery.OnBattery");
    if (info2.provided() == true) {
        qDebug() << "Battery.OnBattery should not be provided!";
        fail();
    }

    QFile::remove("cache.cdb");
    return 0;
}
Example #27
0
/**
   listen_host() live in a separate thread, it has the following resposibilities:
   1) listening commands from the main thread to initiate connection to servers
   2) listening to connected servers for maos status event and update the display
   3) monitor connected servers for activity. Disable pages when server is disconnected.

   write to sock_main[1] will be caught by select in listen_host(). This wakes it up.*/
void listen_host(){
    htime=calloc(nhost, sizeof(double));
    FD_ZERO(&active_fd_set);
    FD_SET(sock_main[0], &active_fd_set);
    int keep_listen=1;
    while(keep_listen){
	fd_set read_fd_set = active_fd_set;
	if(select(FD_SETSIZE, &read_fd_set, NULL, NULL, NULL)<0){
	    perror("select");
	    continue;
	}
	for(int i=0; i<FD_SETSIZE; i++){
	    if(FD_ISSET(i, &read_fd_set)){
		int res;
		res=respond(i);
		if(res==-2){//quit
		    keep_listen=0;
		    break;
		}else if(res==-1){//remove host
		    host_removed(i);
		}
	    }
	}
	double ntime=myclockd();
	for(int ihost=0; ihost<nhost; ihost++){
	    if(hsock[ihost]>-1){
		if(htime[ihost]+10<ntime){
		    //10 seconds grace period
		    info2("10 seconds no respond. disconnect\n");
		    host_removed(hsock[ihost]);
		}
	    }
	}
    }
    for(int i=0; i<FD_SETSIZE; i++){
	if(FD_ISSET(i, &active_fd_set)){
	    close(i);
	    FD_CLR(i, &active_fd_set);
	}
    }
}
Example #28
0
int main(int argc, char* argv[]){
    /*dsp *RLMc1=dspread("RLMc_old.bin"); */
    if(argc!=2){
	error("Need 1 argument\n");
    }
    dspcell *RLM=dspcellread("%s",argv[1]);
    dsp *RLMc=dspcell2sp(RLM);
    tic;info2("chol ...");
    spchol *R1=chol_factorize(RLMc);
    toc("done");
    rand_t rstat;
    seed_rand(&rstat,1);
    dmat *y=dnew(RLMc->m, 1);
    drandn(y, 1, &rstat);
    dmat *x=NULL, *x2=NULL, *x3=NULL;
    chol_convert(R1, 1);
    tic;
    chol_solve(&x, R1, y);
    toc("cholmod");tic;
    chol_solve(&x, R1, y);
    toc("cholmod");tic;
    chol_solve_upper(&x3, R1, y);
    toc("upper");tic;
    chol_solve_upper(&x3, R1, y);
    toc("upper");tic;
    chol_solve_lower(&x2, R1,y);
    toc("lower");tic;
    chol_solve_lower(&x2, R1,y);
    toc("lower");tic;
    chol_solve(&x, R1, y);
    toc("cholmod");tic;
    chol_solve(&x, R1, y);
    toc("cholmod");tic;
    writebin(y,"y");
    writebin(x,"x");
    writebin(x2,"x2");
    writebin(x3,"x3");
    chol_free(R1);
    dspfree(RLMc);
    dspcellfree(RLM);
}
Example #29
0
/**
   Compute Signal level
*/
static void setup_star_siglev(const PARMS_S *parms, STAR_S *star, int nstar){
    const long npowfs=parms->maos.npowfs;
    const long nwvl=parms->maos.nwvl;
    const double r2=pow(parms->skyc.patfov/206265./2.,2);
    dmat* rnefs=parms->skyc.rnefs;
    for(int istar=0; istar<nstar; istar++){
	star[istar].siglev=dcellnew(npowfs, 1);
	star[istar].bkgrnd=dnew(npowfs,1);
	star[istar].siglevtot=dnew(npowfs,1);
	/*Normalized angular distance */
	double th2=(pow(star[istar].thetax,2)+pow(star[istar].thetay,2))/r2;
	/*Field dependent error: nm^2=nma^2+nmb^2*theta_norm^2; */
	double imperrnm=sqrt(pow(parms->skyc.imperrnm,2)+th2*pow(parms->skyc.imperrnmb,2));
	for(long ipowfs=0; ipowfs<npowfs; ipowfs++){
	    star[istar].siglev->p[ipowfs]=dnew(nwvl,1);
	    int iscircle=parms->maos.nsa[ipowfs]<=4?1:0;
	    photon_flux(&parms->skyc.zb, star[istar].siglev->p[ipowfs]->p,
			&star[istar].siglevtot->p[ipowfs],
			&star[istar].bkgrnd->p[ipowfs],
			NULL, NULL,
			parms->maos.nwvl,
			parms->maos.wvl,
			star[istar].mags->p,
			parms->maos.dxsa[ipowfs], iscircle,
			parms->skyc.pixtheta[ipowfs],
			parms->maos.dt, parms->maos.za, 
			NULL,
			imperrnm,
			parms->skyc.telthruput,
			parms->skyc.qe,
			IND(rnefs,parms->skyc.ndtrat-1,ipowfs));
	    if(parms->skyc.verbose && ipowfs==npowfs-1){
		info2("star %d at (%5.1f %5.1f)",istar, 
		      star[istar].thetax*206265,star[istar].thetay*206265);
		info2(" bkgrnd=%5.2f, pixtheta=%4.1fmas mag=[",
		      star[istar].bkgrnd->p[ipowfs],parms->skyc.pixtheta[ipowfs]*206265000);
		for(int iwvl=0; iwvl<parms->maos.nwvl; iwvl++){
		    info2("%5.2f ", star[istar].mags->p[iwvl]);
		}
		info2("] siglev=[");
		for(int iwvl=0; iwvl<parms->maos.nwvl; iwvl++){
		    info2("%6.1f ", star[istar].siglev->p[ipowfs]->p[iwvl]);
		}
		info2("]\n");
	    }
	}
    }
}
Example #30
0
File: sock.c Project: bitursa/maos
/**
   make a server port and bind to localhost on all addresses. AF_INET
*/
static int bind_socket (char *ip, uint16_t port){
    struct sockaddr_in name;
    /* Create the socket. */
    int sock = socket(PF_INET, SOCK_STREAM, 0);//tcp
    if (sock < 0){
	perror ("socket");
	exit (EXIT_FAILURE);
    }
    socket_tcp_keepalive(sock);
    //socket_reuse_addr(sock);
    socket_nopipe(sock);
    cloexec(sock);
    
    /* Give the socket a name. */
    name.sin_family = AF_INET;
    name.sin_port = htons(port);
    if(ip){
	name.sin_addr.s_addr = inet_addr(ip);
    }else{
	name.sin_addr.s_addr = htonl(INADDR_ANY);
    }
    int count=0;
    while(bind(sock,(struct sockaddr *)&name, sizeof (name))<0){
	info_time("errno=%d. port=%d,sock=%d: ",errno,port,sock);
	perror ("bind");
	sleep(10);
	count++;
	if(count>100){
	    error("Failed to bind to port %d\n",port);
	    close(sock);
	    sock=-1;
	}
    }
    if(sock!=-1){
	info2("binded to port %hd at sock %d\n",port,sock);
    }
    return sock;
}