Пример #1
0
bool GetMessage(FullCoreMessage* message)
{
    if(tail != head)
    {
        memcpy( message, &fullCoreMessages[tail], sizeof(fullCoreMessages[0]) );
        tail    = (tail + 1) % NUMBER_OF_ELEMENTS(fullCoreMessages);        
        return true;
    }
    else
    {
        return false;
    }
}
Пример #2
0
void CallAfter_ms( Handler handler, uint32_t interval )
{
    for(uint32_t i=0; i<NUMBER_OF_ELEMENTS(timedEventHandlers); i++)
    {
        if( timedEventHandlers[i].handler == 0 )
        {
            timedEventHandlers[i].handler       = handler;
            timedEventHandlers[i].interval      = 0;
            timedEventHandlers[i].firingTime    = CurrentTimestamp_ms() + interval;
            break;
        }

    }    
}
Пример #3
0
bool PutMessage(FullCoreMessage* message)
{
    uint32_t    newHead     = (head + 1) % NUMBER_OF_ELEMENTS(fullCoreMessages);

    if(newHead != tail)
    {
        memcpy( &fullCoreMessages[head], message, sizeof(fullCoreMessages[0]) );
        head    = newHead;        
        return true;
    }
    else
    {
        return false;
    }
}
Пример #4
0
int main()
{
    //std::get<0>(protocol)(1);
#if 0
    ForEach( protocol, 0, 2 );
    ForEach( protocol, 1, 3 );
#endif
#if 1   
    One         one;
    Two         two;
    Three       three;

    Delegate<int, One,     &One::DoAnotherThing>       oneDoAnotherThing(one);
    Delegate<int, Two,     &Two::DoAnotherThing>       twoDoAnotherThing(two);
    Delegate<int, Three,   &Three::DoAnotherThing>     threeDoAnotherThing(three);
    Container<int, Delegate<int, One, &One::DoAnotherThing>, Delegate<int, Two, &Two::DoAnotherThing>, Delegate<int, Three, &Three::DoAnotherThing> >  anotherDelegateContainer( oneDoAnotherThing, twoDoAnotherThing, threeDoAnotherThing );

    printf("<%d>\n", anotherDelegateContainer.Call(0) );
    printf("<%d>\n", anotherDelegateContainer.Call(1) );
    printf("<%d>\n", anotherDelegateContainer.Call(2) );

    //IndexedDispatch(0,  one,two,three);

#endif    
#if 0

    volatile ObjectType  order[]     = {eThree, eTwo, eOne};

    for(int i=0; i<NUMBER_OF_ELEMENTS(order); i++)
    {
        EnumeratedDispatch(order[i],    eOne,   one, 
                                        eTwo,   two, 
                                        eThree, three);

    }
#endif    
    return 0;
}
Пример #5
0
void CheckTimedEventHandlers()
{
    uint32_t    timestamp   = CurrentTimestamp_ms();

    for(uint32_t i=0; i<NUMBER_OF_ELEMENTS(timedEventHandlers); i++)
    {
        if( timedEventHandlers[i].handler != 0 )
        {
            if( timestamp >= timedEventHandlers[i].firingTime )
            {
                Call( timedEventHandlers[i].handler );

                if(timedEventHandlers[i].interval == 0)
                {
                    timedEventHandlers[i].handler   = 0;
                }
                else
                {
                    timedEventHandlers[i].firingTime    = timestamp + timedEventHandlers[i].interval;                    
                }
            }
        }
    }    
}
Пример #6
0
SBML_ODESOLVER_API int IntegratorInstance_idaOneStep(integratorInstance_t *engine)
{
    int i, flag;
    realtype *ydata = NULL;
    
    cvodeSolver_t *solver = engine->solver;
    cvodeData_t *data = engine->data;
/*     cvodeSettings_t *opt = engine->opt; */
/*     cvodeResults_t *results = engine->results; */
    odeModel_t *om = engine->om;
    
    /* !!!! calling CVODE !!!! */
    flag = -1; /* IDASolver(solver->cvode_mem, solver->tout, &(solver->t),
		  solver->y, solver->dy, IDA_NORMAL); */

    if ( flag != IDA_SUCCESS )
      {
        static const char *message[] =
	  {
	    /*  0 IDA_SUCCESS */
	    "Success",
	    /**/
	    /*  1 IDA_ROOT_RETURN */
	    /*   "CVode succeeded, and found one or more roots" */
	    /*  2 IDA_TSTOP_RETURN */
	    /*   "CVode succeeded and returned at tstop" */
	    /**/
	    /* -1 IDA_MEM_NULL -1 (old CVODE_NO_MEM) */
	    "The cvode_mem argument was NULL",
	    /* -2 IDA_ILL_INPUT */
	    "One of the inputs to CVode is illegal. This "
	    "includes the situation when a component of the "
	    "error weight vectors becomes < 0 during "
	    "internal time-stepping. The ILL_INPUT flag "
	    "will also be returned if the linear solver "
	    "routine CV--- (called by the user after "
	    "calling CVodeMalloc) failed to set one of the "
	    "linear solver-related fields in cvode_mem or "
	    "if the linear solver's init routine failed. In "
	    "any case, the user should see the printed "
	    "error message for more details.",
	    /* -3 IDA_NO_MALLOC */
	    "cvode_mem was not allocated",
	    /* -4 IDA_TOO_MUCH_WORK */
	    "The solver took %g internal steps but could not "
	    "compute variable values for time %g",
	    /* -5 IDA_TOO_MUCH_ACC */
	    "The solver could not satisfy the accuracy " 
	    "requested for some internal step.",
	    /* -6 IDA_ERR_FAILURE */
	    "Error test failures occurred too many times "
	    "during one internal time step or "
	    "occurred with |h| = hmin.",
	    /* -7 IDA_CONV_FAILURE */
	    "Convergence test failures occurred too many "
	    "times during one internal time step or occurred "
	    "with |h| = hmin.",
	    /* -8 IDA_LINIT_FAIL */
	    "CVode -- Initial Setup: "
	    "The linear solver's init routine failed.",
	    /* -9 IDA_LSETUP_FAIL */
	    "The linear solver's setup routine failed in an "
	    "unrecoverable manner.",
	    /* -10 IDA_LSOLVE_FAIL */
	    "The linear solver's solve routine failed in an "
	    "unrecoverable manner.",
	    /* -11 IDA_MEM_FAIL */
	    "A memory allocation failed. "
	    "(including an attempt to increase maxord)",
	    /* -12 IDA_RTFUNC_NULL */
	    "nrtfn > 0 but g = NULL.",
	    /* -13 IDA_NO_SLDET */
	    "CVodeGetNumStabLimOrderReds -- Illegal attempt "
	    "to call without enabling SLDET.",
	    /* -14 IDA_BAD_K */
	    "CVodeGetDky -- Illegal value for k.",
	    /* -15 IDA_BAD_T */
	    "CVodeGetDky -- Illegal value for t.",
	    /* -16 IDA_BAD_DKY */
	    "CVodeGetDky -- dky = NULL illegal.",
	    /* -17 IDA_PDATA_NULL */
	    "???",
	  };
	    
	SolverError_error(
			  ERROR_ERROR_TYPE,
			  flag,
			  (abs(flag) < (int)NUMBER_OF_ELEMENTS(message)) ? message[abs(flag)] : "???",
			  solver->tout);
	SolverError_error(
			  WARNING_ERROR_TYPE,
			  SOLVER_ERROR_INTEGRATION_NOT_SUCCESSFUL,
			  "Integration not successful. Results are not complete.");

	return 0 ; /* Error - stop integration*/
      }
    
    ydata = NV_DATA_S(solver->y);

    
    /* update cvodeData time dependent variables */    
    for ( i=0; i<om->neq; i++ )
      data->value[i] = ydata[i];

    /* update rest of data with internal default function */
    return IntegratorInstance_updateData(engine);

}