示例#1
0
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    //Initialize the memory map where the data points are buffered, and read the datapoints from it
    tt_buf* buf;
    int timetagger;
    
    if (nrhs == 1 && mxIsDouble(prhs[0])) {
        //If there is only one argument, and it is a double, then change the time tagger number
        //to open
        timetagger = (int)mxGetScalar(prhs[0]);
    } else {
        //If the arguments are wrong, display a help message and exit
        mexErrMsgTxt("Inputs:\n\tNumber of timetagger (starting from 0) to open.\nOutputs:\n\tResolution of data in seconds per time bin");
        return;
    }

    //Open the time tagger
    buf = tt_open(timetagger);

    if (buf) {
        
        
        plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
        *mxGetPr(plhs[0]) = (double)tt_resolution(buf);
        
        
        //Close the buffer
        tt_close(buf);
        
	} else {
        mexErrMsgTxt("Unable to connect to time tagger - is the timetagger software running?");
	}
}
示例#2
0
/******************************************************************************
 *
 * Shutdown Tooltalk connection.
 *
 *****************************************************************************/
void DetachFromTooltalk(
    unsigned long *nocare1)     /* if Xt - XtInputId *id; */
{
    char *sessid;

    if (dtSvcProcIdG) {
	/*
	 * NULL the global to indicate that we no longer want to
	 * chit-chat with Tooltalk.
	 */
	dtSvcProcIdG = (char *) NULL;

	sessid = tt_default_session();
	tt_session_quit(sessid);
	tt_free(sessid);
	tt_close();
    }

    /*
     * Unregister the Tooltalk fildes from the select mask.
     */
    if (ttfdG != -1) {
	BITCLEAR(allactivefdsG, ttfdG);
	ttfdG = -1;
    }
}
示例#3
0
文件: remover.C 项目: juddy/edcde
/*
 * remover::close_tt()
 */
Tt_status remover::
close_tt()
{
	if (! _tt_opened) {
		return TT_OK;
	}
	Tt_status err = tt_close();
	if (err > TT_WRN_LAST) {
		fprintf( stderr,
			 "%s: tt_close(): %s\n",
			 (char *)_process_name, tt_status_message(err) );
	}
	return err;
}
示例#4
0
int main() {
    tt_buf* buffer = tt_create(0,50);
    uint64_t data[16] = {10,11,12,13,14,15,16,17,18,19,110,111,112,113,114,115};
    uint8_t channels[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
    
    tt_addarray(buffer,channels,data,16);
    tt_addrunner(buffer);
    tt_setresolution(buffer,0.1);
    while (tt_runners(buffer)) {
        printf("Runners: %i\n",tt_runners(buffer));
        sleep(1);
    }
    tt_close(buffer);
    return 0;
}
示例#5
0
int InitializeTooltalk(void)
{
    char * procid;
    Tt_status status;
    int fd;

    procid = tt_default_procid();
    status = tt_ptr_error(procid);
    if ((status == TT_ERR_NOMP) || (status == TT_ERR_PROCID)) {
	/*
	 * We need to try to establish a connection
	 */
	procid = tt_open();
	status = tt_ptr_error(procid);
	if (status != TT_OK) {
	    ToolTalkError("Could not connect to ToolTalk:\n%s\n", status);
	    return (False);
	}
	tt_free(procid);

	/*
	 * Determine the Tooltalk fildes.
	 */
	fd = tt_fd();
	status = tt_int_error(fd);
	if (status != TT_OK) {
	    ToolTalkError("Could not connect to ToolTalk:\n%s\n", status);
	    tt_close();
	    ttfdG = -1;
	    return(False);
	}
	else {
	    ttfdG = fd;
	}

#ifdef DtActUseXtOverSelect
	/*
	 * Add the ToolTalk file descriptor to the set monitored by Xt
	 */
	XtAddInput(fd, (XtPointer)XtInputReadMask, input_handler, 0);
#endif /* DtActUseXtOverSelect */
    }

    return (True);
}
示例#6
0
文件: rcopier.C 项目: juddy/edcde
/*
 * rcopier::close_tt()
 */
Tt_status rcopier::
close_tt()
{
	if (! _tt_opened) {
		return TT_OK;
	}
	Tt_status err = tt_close();
	if (err > TT_WRN_LAST) {
		fprintf( stderr,
			 "%s: Could not close ToolTalk because %s\n",
			 (char *)_process_name,
#ifndef TT_STATUS_MSG_TO_DO
			 _tt_enumname( (Tt_status)err )
#else
			 tt_status_message( err )
#endif
		       );
	}
	return err;
}
示例#7
0
文件: tt_delays.c 项目: KwiatQIM/ttag
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    tt_buf* buf;
    double* delays;
    
    int timetagger = 0;
    double time = 0.0;
    double dbl_radius = 0.0;
    uint64_t radius = 0;
    

    if (nrhs == 4 && mxIsDouble(prhs[0]) && mxIsDouble(prhs[1]) && mxIsDouble(prhs[2]) && mxIsDouble(prhs[3])) {
        time = mxGetScalar(prhs[0]);
        dbl_radius = mxGetScalar(prhs[1]);
        timetagger = (int)mxGetScalar(prhs[2]);
        radius = (uint64_t)mxGetScalar(prhs[3]);
    } else if (nrhs == 3 && mxIsDouble(prhs[0]) && mxIsDouble(prhs[1]) && mxIsDouble(prhs[2])) {
        time = mxGetScalar(prhs[0]);
        dbl_radius = mxGetScalar(prhs[1]);
        timetagger = (int)mxGetScalar(prhs[2]);
    } else if (nrhs == 2 && mxIsDouble(prhs[0]) && mxIsDouble(prhs[1])) {
        time = mxGetScalar(prhs[0]);
        dbl_radius = mxGetScalar(prhs[1]);
    } else {
        mexErrMsgTxt("Inputs:\n\ttime in seconds to calculate delays from\n\tpulse radius in seconds (coincidence is within +- this)\n\t[optional=0] timetagger to dump from.\n\t[optional]Same as radius, except it is in time bins rather than seconds\nOutputs:\n\tArray of delays between channels");
    }
    
    buf = tt_open(timetagger);
    if (buf) {
        
        plhs[0]=mxCreateDoubleMatrix(1,tt_channels(buf),mxREAL);
        delays = mxGetPr(plhs[0]);
        
        tt_delays(buf,time,dbl_radius,radius,delays);
        
        tt_close(buf);
    } else {
        mexErrMsgTxt("Unable to connect to time tagger - is the timetagger software running?");
    }

}
示例#8
0
文件: tt_dump.c 项目: KwiatQIM/ttag
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    tt_buf* buffer;
    int timetagger;
    uint64_t datapoints;

    
    uint64_t total;	//The total amount of data in the buffer
    uint64_t i;		//Temporary loop variable
    uint64_t j=0;
    double *channels=NULL, *timebins;
    
    if (nrhs == 2 && mxIsDouble(prhs[0]) && mxIsDouble(prhs[1])) {
        timetagger = (int)mxGetScalar(prhs[0]);
        datapoints = (uint64_t)mxGetScalar(prhs[1]);
    } else {
        mexErrMsgTxt("Inputs:\n\tTime tag buffer to dump from.\n\tNumber of datapoints to dump.\nOutputs:\n\tArray of time stamps\n\tArray of corresponding channels");
        return;
    }
    
    if (datapoints==0) {
        mexErrMsgTxt("No datapoints were specified!");
        return;
    }
    
    buffer = tt_open(timetagger);
    if (buffer) {
        total = tt_datapoints(buffer);
        
        if (datapoints > total) {
            mexPrintf("Warning: Not enough datapoints! Only reading saved datapoints!\n");
            datapoints = total;
        }
        if (datapoints > tt_maxdata(buffer)) {
            mexPrintf("Warning: There are not enough datapoints saved. Only reading to end of buffer!\n");
            datapoints = tt_maxdata(buffer);    //Only read up to the entire buffer
        }

        
        if (nlhs>=2) {
            plhs[0] = mxCreateDoubleMatrix(1,(int)datapoints,mxREAL);
            channels = mxGetPr(plhs[0]);
            plhs[1] = mxCreateDoubleMatrix(1,(int)datapoints,mxREAL);
            timebins = mxGetPr(plhs[1]);
        } else {
            plhs[0] = mxCreateDoubleMatrix(1,(int)datapoints,mxREAL);
            timebins = mxGetPr(plhs[0]);
        }
        
        //Read the array of data
        if (isnan(tt_resolution(buffer))) {
            mexPrintf("Warning: Resolution unset. Returning raw data.\n");
            if (channels) {
                for (i=total-datapoints;i<total;i++) {
                    channels[j] = (double)tt_channel(buffer,i)+1.0;	//Matlab has this weird off by one thing...
                    timebins[j] = (double)tt_tag(buffer,i);
                    j++;
                }
            } else {
                for (i=total-datapoints;i<total;i++) {
                    timebins[j] = (double)tt_tag(buffer,i);
                    j++;
                }
            }
        } else {
            if (channels) {
                for (i=total-datapoints;i<total;i++) {
                    channels[j] = (double)tt_channel(buffer,i)+1.0;	//Matlab has this weird off by one thing...
                    timebins[j] = (double)tt_tag(buffer,i)*tt_resolution(buffer);
                    j++;
                }
            } else {
                for (i=total-datapoints;i<total;i++) {
                    timebins[j] = (double)tt_tag(buffer,i)*tt_resolution(buffer);
                    j++;
                }
            }
        }
        
        
        tt_close(buffer);
        
    } else {
        mexErrMsgTxt("Unable to connect to time tag buffer! Is all necessary software running?");
    }

}