当前位置: 首页>>代码示例>>C++>>正文


C++ set_block_error函数代码示例

本文整理汇总了C++中set_block_error函数的典型用法代码示例。如果您正苦于以下问题:C++ set_block_error函数的具体用法?C++ set_block_error怎么用?C++ set_block_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_block_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: block

/** \fn void cmscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void canimxy3d(scicos_block * block, scicos_flag flag)
{
    char const* pFigureUID;

    sco_data *sco;

    int j;
    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
                break;
            }
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }
            break;

        case StateUpdate:
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            appendData(block, block->inptr[0], block->inptr[1], block->inptr[2]);
            for (j = 0; j < block->insz[0]; j++)
            {
                result = pushData(block, j);
                if (result == FALSE)
                {
                    Coserror("%s: unable to push some data.", "cscopxy3d");
                    break;
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
开发者ID:rossdrummond,项目名称:scilab,代码行数:62,代码来源:canimxy3d.c

示例2: block

/** \fn void cmscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void cscopxy3d(scicos_block * block, scicos_flag flag)
{
    int iFigureUID;

    sco_data *sco;

    int j;
    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
            }
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
            }
            break;

        case StateUpdate:
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            appendData(block, GetRealInPortPtrs(block, 1), GetRealInPortPtrs(block, 2), GetRealInPortPtrs(block, 3));
            for (j = 0; j < block->insz[0]; j++)
            {
                result = pushData(block, j);
                if (result == FALSE)
                {
                    Coserror("%s: unable to push some data.", "cscopxy3d");
                    break;
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
开发者ID:leowzukw,项目名称:scilab-mirror,代码行数:60,代码来源:cscopxy3d.c

示例3: block

/** \fn void cmatview(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void cmatview(scicos_block * block, scicos_flag flag)
{
    char const* pFigureUID;

    double *u;
    sco_data *sco;

    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
                break;
            }
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }
            break;

        case StateUpdate:
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            u = GetRealInPortPtrs(block, 1);

            result = pushData(block, u);
            if (result == FALSE)
            {
                Coserror("%s: unable to push some data.", "cmatview");
                break;
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
开发者ID:rossdrummond,项目名称:scilab,代码行数:60,代码来源:cmatview.c

示例4: gainblk_ui16e

/*--------------------------------------------------------------------------*/ 
SCICOS_BLOCKS_IMPEXP void gainblk_ui16e(scicos_block *block,int flag)
{
 if ((flag==1)|(flag==6)){
  int i = 0,j = 0,l = 0,ji = 0,jl = 0,il = 0;
  unsigned short *u = NULL,*y = NULL;
  int mu = 0,ny = 0,my = 0,mo = 0,no = 0;
  unsigned short *opar = NULL;
  double k = 0.,D = 0.,C = 0.;

  mo=GetOparSize(block,1,1);
  no=GetOparSize(block,1,2);
  mu=GetInPortRows(block,1);
  my=GetOutPortRows(block,1);
  ny=GetOutPortCols(block,1);
  u=Getuint16InPortPtrs(block,1);
  y=Getuint16OutPortPtrs(block,1);
  opar=Getuint16OparPtrs(block,1);

  k=pow(2,16);
  if (mo*no==1){
    for (i=0;i<ny*mu;++i){
     D=(double)(opar[0])*(double)(u[i]);
     if ((D>=k)|( D<0))
	{sciprint(_("overflow error"));
	 set_block_error(-4);
	 return;}
     else y[i]=(unsigned short)D;
    }
  }else{
     for (l=0;l<ny;l++)
	 {for (j=0;j<my;j++)
	      {D=0;
			 jl=j+l*my;
	       for (i=0;i<mu;i++)
		   {ji=j+i*my;
		    
		    il=i+l*mu;
		    C=(double)(opar[ji])*(double)(u[il]);
		    D=D + C;}
		    if ((D>=k)|( D<0))
			{sciprint(_("overflow error"));
			 set_block_error(-4);
			 return;}
		    else y[jl]=(unsigned short)D;
		  }
	     }
  }
 }
}
开发者ID:rossdrummond,项目名称:scilab,代码行数:50,代码来源:gainblk_ui16e.c

示例5: MALLOC

static sco_data *getScoData(scicos_block * block)
{
    sco_data *sco = (sco_data *) * (block->work);

    if (sco == NULL)
    {
        /*
         * Data allocation
         */

        sco = (sco_data *) MALLOC(sizeof(sco_data));
        if (sco == NULL)
            goto error_handler_sco;

        sco->scope.cachedFigureUID = NULL;
        sco->scope.cachedAxeUID = NULL;
        sco->scope.cachedGrayplotUID = NULL;

        *(block->work) = sco;
    }

    return sco;

    /*
     * Error management (out of normal flow)
     */

error_handler_sco:
    // allocation error
    set_block_error(-5);
    return NULL;
}
开发者ID:rossdrummond,项目名称:scilab,代码行数:32,代码来源:cmatview.c

示例6: sci_coserror

/*--------------------------------------------------------------------------*/
int sci_coserror(char *fname, unsigned long fname_len)
/* renvoi un message erreur */
{
	/* auxilary variables for dimension and address */
	int m1 = 0,n1 = 0;     /* dimension of input character string               */
	int *il_str = NULL;   /* address of the description of the input parameter */
	int *l_str = NULL;    /* address of the data of the input parameter        */
	int sz_str,ptr_pos = 0;
	int i = 0, j = 0;

	int isrun = C2F(cosim).isrun;

	CheckRhs(1,1);

	if (!isrun) 
	{
		Scierror(999,_("%s: scicosim is not running.\n"),fname);
	}
	else 
	{
		il_str = (int *) GetData(1); /* get ptr of integer header of rsh 1 */
		/* check for a string */
		if(il_str[0] != 10) 
		{
			Scierror(55,_("%s : First argument must be a string.\n"),fname);
			C2F(iop).err = 1;
			return 0;
		}

		m1 = il_str[1]; /* number of row    */
		n1 = il_str[2]; /* number of column */
		sprintf(coserr.buf," ");
		/* Check string matrix  */
		for (j=0; j < m1*n1; j++)
		{
			sz_str = il_str[5+j]-il_str[4+j]; /* store the length of str */
			/* get current position in the istk */
			if (j==0)
			{
				ptr_pos = 5+m1*n1;
			}
			else
			{
				ptr_pos += il_str[5+j-1]-il_str[4+j-1];
			}
			l_str = &il_str[ptr_pos]; /* get ptr of rsh 1 */
			/* codetoascii convertion */
			C2F(cha1).buf[0]=' ';
			C2F(cvstr)(&sz_str,&l_str[0],&C2F(cha1).buf[0],(i=1,&i),sz_str);
			C2F(cha1).buf[sz_str]='\0';

			sprintf(coserr.buf,"%s\n%s",coserr.buf,C2F(cha1).buf);
		}
		set_block_error(-5);
		LhsVar(1) = 0;
		PutLhsVar();
	}
	return 0;
}
开发者ID:rossdrummond,项目名称:scilab,代码行数:60,代码来源:sci_coserror.c

示例7: setErrAndFree

static void setErrAndFree(const int flag, types::typed_list out)
{
    set_block_error(flag);
    for (size_t i = 0; i < out.size(); ++i)
    {
        out[i]->killMe();
    }
}
开发者ID:FOSSEE-Internship,项目名称:scilab,代码行数:8,代码来源:sciblk2.cpp

示例8: m_frequ

/*--------------------------------------------------------------------------*/
SCICOS_BLOCKS_IMPEXP void m_frequ(scicos_block *block, int flag)
{
    double *mat = NULL;
    double *Dt = NULL;
    double *off = NULL;
    SCSINT32_COP *icount = NULL;
    double t = 0.0;
    time_counter_t** work = (time_counter_t**) block->work;
    time_counter_t *counter = NULL;
    int m = 0;
    mat = GetRealOparPtrs(block, 1);
    Dt = GetRealOparPtrs(block, 2);
    off = GetRealOparPtrs(block, 3);
    icount = Getint32OparPtrs(block, 4);
    m = GetOparSize(block, 1, 1);

    switch (flag)
    {

        case 4 :   /* the workspace is used to store discrete counter value */
        {
            if ((*work = (time_counter_t*) scicos_malloc(sizeof(time_counter_t) * 2)) == NULL)
            {
                set_block_error(-16);
                return;
            }
            counter = *work;
            *counter = *icount;
            (*(counter + 1)) = 0;
            break;
        }

        /* event date computation */
        case 3  :
        {
            counter = *work;
            t = get_scicos_time();
            *counter += (int)mat[*(counter + 1)]; /*increase counter*/
            block->evout[(int)mat[*(counter + 1) + m] - 1] = *off + ((double) * counter / (*Dt)) - t;
            (*(counter + 1))++;
            *(counter + 1) = *(counter + 1) % m;
            break;
        }

        /* finish */
        case 5  :
        {
            scicos_free(*work); /*free the workspace*/
            break;
        }

        default :
            break;
    }
}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:56,代码来源:m_frequ.c

示例9: getScoData

static sco_data *reallocScoData(scicos_block * block, int input, int numberOfPoints)
{
    sco_data *sco = getScoData(block);

    double *ptr;
    int setLen;
    int previousNumberOfPoints = sco->internal.maxNumberOfPoints[input];

    /*
     * Realloc base pointer
     */
    ptr = (double *)REALLOC(sco->internal.data[2 * input], 3 * numberOfPoints * sizeof(double));
    if (ptr == NULL)
    {
        goto error_handler;
    }

    for (setLen = numberOfPoints - previousNumberOfPoints - 1; setLen >= 0; setLen--)
    {
        ptr[3 * (previousNumberOfPoints + setLen) + 0] = ptr[3 * (previousNumberOfPoints - 1) + 0];
        ptr[3 * (previousNumberOfPoints + setLen) + 1] = ptr[3 * (previousNumberOfPoints - 1) + 1];
        ptr[3 * (previousNumberOfPoints + setLen) + 2] = ptr[3 * (previousNumberOfPoints - 1) + 2];
    }
    sco->internal.data[2 * input] = ptr;

    /*
     * Realloc direction pointer
     */
    ptr = (double *)REALLOC(sco->internal.data[2 * input + 1], 3 * numberOfPoints * sizeof(double));
    if (ptr == NULL)
    {
        goto error_handler;
    }

    for (setLen = numberOfPoints - previousNumberOfPoints - 1; setLen >= 0; setLen--)
    {
        ptr[3 * (previousNumberOfPoints + setLen) + 0] = ptr[3 * (previousNumberOfPoints - 1) + 0];
        ptr[3 * (previousNumberOfPoints + setLen) + 1] = ptr[3 * (previousNumberOfPoints - 1) + 1];
        ptr[3 * (previousNumberOfPoints + setLen) + 2] = ptr[3 * (previousNumberOfPoints - 1) + 2];
    }
    sco->internal.data[2 * input + 1] = ptr;

    sco->internal.maxNumberOfPoints[input] = numberOfPoints;
    return sco;

error_handler:
    freeScoData(block);
    // allocation error
    set_block_error(-5);
    return NULL;
}
开发者ID:FOSSEE-Internship,项目名称:scilab,代码行数:51,代码来源:cevscpe.c

示例10: evtdly4

/*    Copyright INRIA
 *    Scicos block simulator
 *    event delay with discrete counter
 */
SCICOS_BLOCKS_IMPEXP void evtdly4(scicos_block *block, int flag)
{
    double t = 0.;
    time_counter_t** work = (time_counter_t**) block->work;
    time_counter_t* i = NULL;

    switch (flag)
    {
        /* init */
        case 4  :  /* the workspace is used to store discrete counter value */
        {
            if ((*work = (time_counter_t*) scicos_malloc(sizeof(time_counter_t))) == NULL)
            {
                set_block_error(-16);
                return;
            }
            i = *work;
            (*i) = 0;
            break;
        }

        /* event date computation */
        case 3  :
        {
            double dt;

            i = *work;
            t = get_scicos_time();
            (*i)++; /*increase counter*/
            dt = block->rpar[1] + (*i) * block->rpar[0] - t;
            /* on event enabled, use the default delay if not scheduled */
            if (block->rpar[1] >= 0 && dt < 0)
            {
                dt = block->rpar[0];
            }
            block->evout[0] = dt;
            break;
        }

        /* finish */
        case 5  :
        {
            scicos_free(*work); /*free the workspace*/
            break;
        }

        default :
            break;
    }
}
开发者ID:FOSSEE-Internship,项目名称:scilab,代码行数:54,代码来源:evtdly4.c

示例11: sizeof

static sco_data *reallocScoData(scicos_block * block, int numberOfPoints)
{
    sco_data *sco = (sco_data *) * (block->work);
    int i;

    double *ptr;
    int setLen;
    int previousNumberOfPoints = sco->internal.maxNumberOfPoints;
    int newPoints = numberOfPoints - previousNumberOfPoints;

    for (i = 0; i < block->insz[0]; i++)
    {
        ptr = (double *)REALLOC(sco->internal.coordinates[i], 3 * numberOfPoints * sizeof(double));
        if (ptr == NULL)
        {
            goto error_handler;
        }

        // memcpy existing Z-axis values (use memmove to handle memory overlapping)
        memmove(ptr + 2 * numberOfPoints, ptr + 2 * previousNumberOfPoints, previousNumberOfPoints * sizeof(double));

        // memcpy existing Y-axis values (use memmove to handle memory overlapping)
        memmove(ptr + numberOfPoints, ptr + previousNumberOfPoints, previousNumberOfPoints * sizeof(double));

        // then set the last points to the last values for Z-axis, Y-axis and X-axis values
        for (setLen = newPoints - 1; setLen >= 0; setLen--)
        {
            ptr[2 * numberOfPoints + previousNumberOfPoints + setLen] = ptr[2 * numberOfPoints + previousNumberOfPoints - 1];
        }
        for (setLen = newPoints - 1; setLen >= 0; setLen--)
        {
            ptr[numberOfPoints + previousNumberOfPoints + setLen] = ptr[numberOfPoints + previousNumberOfPoints - 1];
        }
        for (setLen = newPoints - 1; setLen >= 0; setLen--)
        {
            ptr[previousNumberOfPoints + setLen] = ptr[previousNumberOfPoints - 1];
        }

        sco->internal.coordinates[i] = ptr;
    }

    sco->internal.maxNumberOfPoints = numberOfPoints;
    return sco;

error_handler:
    freeScoData(block);
    // allocation error
    set_block_error(-5);
    return NULL;
}
开发者ID:leowzukw,项目名称:scilab-mirror,代码行数:50,代码来源:cscopxy3d.c

示例12: pushData

static BOOL pushData(scicos_block * block, double *data)
{
    char const* pFigureUID;
    char *pAxeUID;
    char *pGrayplotUID;

    BOOL result;
    int i;

    int m, n;
    double alpha, beta;
    double *scaledData;

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block);
    pGrayplotUID = getGrayplot(pAxeUID, block);

    m = GetInPortSize(block, 1, 1);
    n = GetInPortSize(block, 1, 2);
    if (m * n <= 0)
    {
        set_block_error(-5);
        return FALSE;
    }

    /*
     * Scale the data
     */
    alpha = block->rpar[0];
    beta = block->rpar[1];

    scaledData = (double *)MALLOC(m * n * sizeof(double));
    if (scaledData == NULL)
    {
        return FALSE;
    }

    for (i = 0; i < m * n; i++)
    {
        scaledData[i] = floor(alpha * data[i] + beta);
    }

    result = setGraphicObjectProperty(pGrayplotUID, __GO_DATA_MODEL_Z__, scaledData, jni_double_vector, m * n);
    FREE(scaledData);

    return result;
}
开发者ID:rossdrummond,项目名称:scilab,代码行数:47,代码来源:cmatview.c

示例13: edgetrig

/*--------------------------------------------------------------------------*/
SCICOS_BLOCKS_IMPEXP void edgetrig(scicos_block *block, int flag)
{
    double z = block->z[0], u = block->inptr[0][0];
    if (flag == 2 || flag == 6)
    {
        block->z[0] = u;
    }
    else if (flag == 1)
    {
        if (block->ipar[0] != 0)
        {
            z = z * block->ipar[0];
            u = u * block->ipar[0];
            if (((z <= 0) & (u > 0)) || ((z < 0) & (u >= 0)))
            {
                block->outptr[0][0] = 1.;
            }
            else
            {
                block->outptr[0][0] = 0.;
            }
        }
        else    /* rising and falling edge */
        {
            if (((z <= 0) & (u > 0)) || ((z < 0) & (u >= 0)) || ((z > 0) & (u <= 0)) || ((z >= 0) & (u < 0)))
            {
                block->outptr[0][0] = 1.;
            }
            else
            {
                block->outptr[0][0] = 0.;
            }
        }
    }
    else if (flag == 4)
    {
        if (block->ng > 0)
        {
            set_block_error(-1);
            scicos_print(_("Trigger block must have discrete time input."));
            return;
        }
    }
}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:45,代码来源:edgetrig.c

示例14: backlash

/*--------------------------------------------------------------------------*/ 
SCICOS_BLOCKS_IMPEXP void backlash(scicos_block *block,int flag)
{ 
  double* rw = NULL,t  = 0.;
  if (flag == 4){/* the workspace is used to store previous values */
    if ((*block->work=	 scicos_malloc(sizeof(double)* 4))== NULL ) {
      set_block_error(-16);
      return;
    }
    rw=*block->work; 
    t=get_scicos_time();
    rw[0]=t;
    rw[1]=t;
    rw[2]=block->rpar[0];
    rw[3]=block->rpar[0];
  }else  if (flag == 5){
    scicos_free(*block->work);
  }else  if (flag == 1) {
    rw=*block->work;
    t=get_scicos_time();
    if(t>rw[1]) {
      rw[0]=rw[1];
      rw[2]=rw[3];
    }
    rw[1]=t;
    if(block->inptr[0][0]>rw[2]+block->rpar[1]/2){
      rw[3]=block->inptr[0][0]-block->rpar[1]/2;
    } else if (block->inptr[0][0]<rw[2]-block->rpar[1]/2){
      rw[3]=block->inptr[0][0]+block->rpar[1]/2;
    } else {
      rw[3]=rw[2];
    }
    block->outptr[0][0]=rw[3];
  }  else if (flag == 9) {
    rw=*block->work;
    t=get_scicos_time();
    if(t>rw[1]){
      block->g[0] = block->inptr[0][0]-block->rpar[1]/2-rw[3];
      block->g[1] = block->inptr[0][0]+block->rpar[1]/2-rw[3];
    }else{
      block->g[0] = block->inptr[0][0]-block->rpar[1]/2-rw[2];
      block->g[1] = block->inptr[0][0]+block->rpar[1]/2-rw[2];
    }
  } 
}
开发者ID:rossdrummond,项目名称:scilab,代码行数:45,代码来源:backlash.c

示例15: matmul_i32e

/*--------------------------------------------------------------------------*/
SCICOS_BLOCKS_IMPEXP void matmul_i32e(scicos_block *block, int flag)
{
    if ((flag == 1) | (flag == 6))
    {
        int mu1 = GetInPortRows(block, 1);
        int nu1 = GetInPortCols(block, 1);
        int nu2 = GetInPortCols(block, 2);
        SCSINT32_COP *u1 = Getint32InPortPtrs(block, 1);
        SCSINT32_COP *u2 = Getint32InPortPtrs(block, 2);
        SCSINT32_COP *y = Getint32OutPortPtrs(block, 1);

        double k = pow(2, 32);
        int l = 0;
        for (l = 0; l < nu2; l++)
        {
            int j = 0;
            for (j = 0; j < mu1; j++)
            {
                double D = 0.;
                int i = 0;
                int jl = j + l * mu1;

                for (i = 0; i < nu1; i++)
                {
                    int ji = j + i * mu1;
                    int il = i + l * nu1;
                    double C = (double)(u1[ji]) * (double)(u2[il]);
                    D = D + C;
                }

                if ((D > ((k / 2) - 1)) | (D < -((k / 2))))
                {
                    sciprint(_("overflow error"));
                    set_block_error(-4);
                    return;
                }
                else
                {
                    y[jl] = (SCSINT32_COP)(D);
                }
            }
        }
    }
}
开发者ID:rfabbri,项目名称:scilab,代码行数:45,代码来源:matmul_i32e.c


注:本文中的set_block_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。