Ejemplo n.º 1
0
int LogTypes::GetFilterMask(const std::string& arg)
{
	std::string copy(arg);
	toLowerCase(copy);
	int ret = 0;
	for(size_t i = 0; i < copy.size(); ++i) ret |= GetFilterMask(copy[i]);
	return ret;
}
Ejemplo n.º 2
0
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
    
    short   fh;
    WORD    chan;
    TpAdc   psData;
    long    maxpoints;
    TSTime  sTime;
    TSTime  eTime;
    TSTime  StartTime;
    TpSTime pbTime=&StartTime;
    TpFilterMask    pFltMask=NULL;
    TFilterMask FilterMask;
    double *p;
    long npoints;
    int dim[2]={1,1};
    long * ret;
    
    //Used for filter
    int mode;
    int m,n;
    const int empty[2]={0,0};

    
    if (nrhs<5)
        mexErrMsgTxt("SONGetADCData: Too few input arguments\n");
    
    //Get input arguments
    fh=mxGetScalar(prhs[0]);                   //File handle
    chan=mxGetScalar(prhs[1]);                 //Channel number
    //maxpoints - see below
    sTime=mxGetScalar(prhs[3]);                //Start time for data search
    eTime=mxGetScalar(prhs[4]);                //End Time for data search
    
    //prhs[2] can be maxpoints (a scalar; =mode 1)or a pointer to a
    //pre-allocated array in the matlab calling space (mode 2).
    if (mxGetM(prhs[2])==1 && mxGetN(prhs[2])==1) {// scalar so mode 1
        if (nlhs<3) {
            mexPrintf("SONGetRealData:Too few LHS arguments \n");
            plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
            ret=mxGetData(plhs[0]);
            *ret=SON_BAD_PARAM;
            for (m=1; m<nlhs; m++)
                plhs[m]=mxCreateNumericArray(2, empty, mxINT32_CLASS, mxREAL);
            return;
        }
        else {
            mode=1;
            maxpoints=mxGetScalar(prhs[2]);
        }
    }
    else {// non-scalar so mode 2....
        //.....but first check it is a valid data array
        if ((mxGetM(prhs[2])>1)||(mxGetClassID(prhs[2])!= mxINT16_CLASS)) {
            mexPrintf("SONGetADCData:"
            "Data array must be an int16 column vector\n");
            plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
            ret=mxGetData(plhs[0]);
            *ret=SON_BAD_PARAM;
            for (m=1; m<nlhs; m++)
                plhs[m]=mxCreateNumericArray(2, empty, mxINT32_CLASS, mxREAL);
            return;
        }
        else {          // Input OK so use pointer to pre-allocated array
            mode=2;
            psData=mxGetData(prhs[2]);
            maxpoints=mxGetN(prhs[2]);
        }
    }
    
    //Get and set up the filter mask
    if (nrhs==6 && mxIsStruct(prhs[5])==1){
        GetFilterMask(prhs[5], &FilterMask);
        pFltMask=&FilterMask;
    }
    else
        pFltMask=NULL;

    
    //Load and get pointer to the library SON32.DLL//
    hinstLib = LoadLibrary(SON32);
    if (hinstLib == NULL){
        mexPrintf("%s not found",SON32);
        plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        p=mxGetData(plhs[0]);
        p[0]=SON_BAD_PARAM;
        return;
    }
    
    // If maxpoints was zero on call, calculate maxpoints from
    // sample interval
    if (maxpoints<=0)
        maxpoints=(eTime-sTime)/ChanInterval(fh, chan);
    // In mode 1 we need to create the return array in the matlab
    // workspace
    if (mode==1 && nlhs>=3) {
        dim[1]=maxpoints;
        plhs[2]=mxCreateNumericArray(2, dim, mxINT16_CLASS, mxREAL);
        psData=mxGetData(plhs[2]);
    }
    
    if(psData != NULL){
        
        //Call DLL
        npoints=_SONGetADCData(fh, chan, psData, maxpoints, sTime, eTime,
                                            pbTime, pFltMask);
        fFreeResult = FreeLibrary(hinstLib);
        
        //return results. This one goes in ans if no arguments
        dim[1]=1;
        plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        ret=mxGetData(plhs[0]);
        *ret=npoints;
        
        if (nlhs>=2){
            plhs[1]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
            ret=mxGetData(plhs[1]);
            *ret=*pbTime;
        }
        
        
    }
    
}
Ejemplo n.º 3
0
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
    
    short   fh;
    WORD    chan;
    TSTime sTime, eTime, ResTime;
    TpSTime peTime;
    TMarkBytes  MB={0,0,0,0};
    unsigned char *ptr;
    BOOLEAN bMark=0;
    TpFilterMask    pFltMask=NULL;
    TFilterMask FilterMask;
    TAdc p=0;
    TpAdc pdata;
    int dim[2]={1,1};
    int m;
    
    int GetFilterMask();
    
    
    if (nrhs<3)
        mexErrMsgTxt("SONGetADCData: Too few input arguments\n");
    
    //Get input arguments
    fh=mxGetScalar(prhs[0]);                   //File handle
    chan=mxGetScalar(prhs[1]);                 //Channel number
    sTime=mxGetScalar(prhs[2]);                //Start time for data search
    eTime=mxGetScalar(prhs[3]);                //End Time
    
    //Get and set up the filter mask
    if (nrhs==5 && mxIsStruct(prhs[4])==1){
        GetFilterMask(prhs[4], FilterMask);
        pFltMask=&FilterMask;
    }
    else
        pFltMask=NULL;
    
    
    //Load and get pointer to the library SON32.DLL//
    hinstLib = LoadLibrary(SON32);
    if (hinstLib == NULL){
        mexPrintf("%s not found",SON32);
        plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        *mxGetPr(plhs[0])=SON_BAD_PARAM;
        return;
    }
    
    
ResTime=_SONLastTime(fh, chan, sTime, eTime, &p, MB, &bMark, pFltMask);
fFreeResult = FreeLibrary(hinstLib);
    
    plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
    peTime=mxGetData(plhs[0]);
    *peTime=ResTime;

    if(nlhs>=2){
        plhs[1]=mxCreateNumericArray(2, dim, mxINT16_CLASS, mxREAL);
        pdata=mxGetData(plhs[1]);
        *pdata=p;
    }
    
    if (nlhs>=3){
        dim[1]=4;
        plhs[2]=mxCreateNumericArray(2,dim,mxUINT8_CLASS,mxREAL);
        ptr=mxGetData(plhs[2]);
        for (m=0; m<=3; m++)
            *ptr++=MB[m];
    }
   
    if (nlhs==4){
        dim[1]=1;
        plhs[3]=mxCreateNumericArray(2,dim,mxDOUBLE_CLASS,mxREAL);
        *mxGetPr(plhs[3])=bMark;
    }
}
Ejemplo n.º 4
0
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
    
    short   fh;
    WORD    chan;
    long    maxpoints;
    TSTime  sTime;
    TSTime  eTime;
    TpFilterMask    pFltMask=NULL;
    TFilterMask FilterMask;
    long npoints=0;
    TMarker Markers[32767];
    short levLow;
    unsigned char *ptr;
    int dim[2]={1,1};
    double *p;
    long *ret;
    int i,j;
    
    
    
    //Used for filter
    int m,n;
    const int *empty[2]={0,0};
    
    
    if (nrhs<5)
        mexErrMsgTxt("SONGetMarkData: Too few  arguments\n");
    
    //Get input arguments
    fh=mxGetScalar(prhs[0]);                   //File handle
    chan=mxGetScalar(prhs[1]);                 //Channel number
    maxpoints=mxGetScalar(prhs[2]);            //maxpoints
    if ((maxpoints>32767) || (maxpoints<=0))
        maxpoints=32767;
    sTime=mxGetScalar(prhs[3]);                //Start time for data search
    eTime=mxGetScalar(prhs[4]);                //End Time for data search
    
    
    
    //Get and set up the filter mask
    if (nrhs==6 && mxIsStruct(prhs[5])==1){
        GetFilterMask(prhs[5], &FilterMask);
        pFltMask=&FilterMask;
    }
    else
        pFltMask=NULL;
    
    
    //Load and get pointer to the library SON32.DLL//
    hinstLib = LoadLibrary(SON32);
    if (hinstLib == NULL){
        mexPrintf("%s not found",SON32);
        plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        p=mxGetData(plhs[0]);
        p[0]=SON_BAD_PARAM;
        return;
    }
    
    
    
    //Call DLL
    npoints=_SONGetMarkData(fh, chan, &Markers, maxpoints, sTime, eTime, pFltMask);
    fFreeResult = FreeLibrary(hinstLib);
    
    
    //return results. This one goes in ans if no arguments
    dim[0]=1;
    dim[1]=1;
    plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
    ret=mxGetData(plhs[0]);
    *ret=npoints;
    
    
    if (nlhs>=2) {
        dim[0]=max(0,npoints);
        plhs[1]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        ret=mxGetData(plhs[1]);
        for (i=0; i<npoints; i++)
            *ret++=Markers[i].mark;
        
    }
    
    if (nlhs==3) {
        dim[1]=4;
        dim[0]=max(0,npoints);
        plhs[2]=mxCreateNumericArray(2, dim, mxUINT8_CLASS, mxREAL);
        ptr=mxGetData(plhs[2]);
            for (j=0; j<4; j++)
                for(i=0; i<npoints; i++)
                *ptr++=Markers[i].mvals[j];

        
        
    }
}
Ejemplo n.º 5
0
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
    TFilterMask FilterMask={0,0};
    int layer, item, set;
    int i, *ret;
    int dim[2]={1,1};
    double *p;
    char fieldnames[2][7]={"lFlags","aMask"};
    const char  *f[2];
    const char  **fnames=&f[0];
    long *tmpPtr;
    int len;
    char *ptr;
    char mode[8];
    
    f[0]=&fieldnames[0][0];
    f[1]=&fieldnames[1][1];
        
    if (nrhs<4) {
        mexPrintf("SONFControl:Too few LHS arguments \n");
        plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        ret=mxGetData(plhs[0]);
        *ret=SON_BAD_PARAM;
        return;
    }

    if (mxIsStruct(prhs[0])==1)
        GetFilterMask(prhs[0], &FilterMask);
    else {
        mexPrintf("SONFControl:No valid filter mask on  input \n");
        plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        ret=mxGetData(plhs[0]);
        *ret=SON_BAD_PARAM;
        return;
        
    }
        
        
    
    if (mxIsNumeric(prhs[1]))
        layer=mxGetScalar(prhs[1]);
    else
        layer=SON_FALLLAYERS;
        
    if (mxIsNumeric(prhs[2]))
        item=mxGetScalar(prhs[2]);
    else
        item=SON_FALLITEMS;
  
    len=mxGetN(prhs[3])*mxGetM(prhs[3])+1;
    if(len>7)
        len=7;
    mxGetString(prhs[3], mode, len);
        
switch (mode[0]) {
    case 'C':
    case 'c':
            set=SON_FCLEAR;
            break;
    case 'S':
    case 's':
            set=SON_FSET;
            break;
    case 'I':
    case 'i':
            set=SON_FINVERT;
            break;
    case 'R':
    case 'r':
    default:
            set=SON_FREAD;
            break;
}
                                        
    
    //Load and get pointer to the library SON32.DLL//
    hinstLib = LoadLibrary(SON32);
    if (hinstLib == NULL){
        mexPrintf("%s not found",SON32);
        plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
        p=mxGetPr(plhs[0]);
        p[0]=SON_BAD_PARAM;
        return;
    }
    
    
    i=_SONFControl(&FilterMask, layer, item, set);
    fFreeResult = FreeLibrary(hinstLib);
    
    plhs[0]=mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL);
    ret=mxGetData(plhs[0]);
    *ret=i;
    
    if (nrhs==2) {
      
        plhs[1]=mxCreateStructMatrix(1, 1, 2, fnames);
        if (plhs[1] != NULL) {
            mxSetField(plhs[1], 0, "lFlags",
            mxCreateNumericArray(2, dim, mxINT32_CLASS, mxREAL));
            tmpPtr=mxGetData(mxGetField(plhs[1], 0, "lFlags"));
            *tmpPtr=FilterMask.lFlags;
            dim[0]=32;
            dim[1]=4;
            mxSetField(plhs[1], 0, "aMask",
            mxCreateNumericArray(2, dim, mxUINT8_CLASS, mxREAL));
            ptr=mxGetData(mxGetField(plhs[1], 0, "aMask"));
            memcpy(ptr, &FilterMask.aMask, sizeof(FilterMask.aMask));
        }
    }

}