Пример #1
0
static void mdlRTW(SimStruct *S){
   int_T type     = P_TYPE;
   int_T id       = P_ID;
   DTypeId  dataType = ssGetInputPortDataType(S,0);
   int_T length   =ssGetDataTypeSize(S,dataType) * ssGetInputPortWidth(S,0); 
   int32_T       endian     = P_ENDIAN;

   /* -- Write Invariant Parameter Settings -- */
   ssWriteRTWParamSettings(S,4,
         SSWRITE_VALUE_DTYPE_NUM, "TYPE",
         &type,
         DTINFO(SS_UINT32,0),

         SSWRITE_VALUE_DTYPE_NUM, "ID",
         &id,
         DTINFO(SS_UINT32,0),

         SSWRITE_VALUE_DTYPE_NUM, "LENGTH",
         &length,
         DTINFO(SS_UINT16,0),

         SSWRITE_VALUE_DTYPE_NUM, "Endian",
         &endian,
         DTINFO(SS_UINT32,0)
      );

   /* -- Write Invariant Signal Settings -- */
   if ( !mxIsFinite( ssGetSampleTime( S, 0 ) ) ) {
      CAN_FRAME * frame = (CAN_FRAME *) ssGetOutputPortSignal(S,0);
      CAN_write_rtw_frame(S,frame);
   }

}
Пример #2
0
    static void mdlRTW(SimStruct *S)
    {
        boolean_T showData   = P_SHOW_DATA;
        boolean_T showID     = P_SHOW_ID;
        boolean_T showLength = P_SHOW_LENGTH;
        uint32_T       endian     = P_ENDIAN;
        ssWriteRTWParamSettings(S,4,

                SSWRITE_VALUE_DTYPE_NUM, "ShowID",
                &showID,
                DTINFO(SS_BOOLEAN,0),

                SSWRITE_VALUE_DTYPE_NUM, "ShowLength",
                &showLength,
                DTINFO(SS_BOOLEAN,0),

                SSWRITE_VALUE_DTYPE_NUM, "ShowData",
                &showData,
                DTINFO(SS_BOOLEAN,0),

                SSWRITE_VALUE_DTYPE_NUM, "Endian",
                &endian,
                DTINFO(SS_UINT32,0)

                );
    }
Пример #3
0
/* Function: mdlRTW ============================================================
 * Abstract:
 *    This function is called when the Real-Time Workshop is generating the
 *    model.rtw file. In this routine, you can call the following functions
 *    which add fields to the model.rtw file.
 *
 *    Important! Since this s-function has this mdlRTW method, it is required
 *    to have a correcponding .tlc file so as to work with RTW. You will find
 *    the sfun_directlook.tlc in <matlabroot>/toolbox/simulink/blocks/tlc_c/.
 */
static void mdlRTW(SimStruct *S)
{
  const uint8_T sample_time = SAMPLE_TIME;
  const uint8_T port = PORT;
  const uint8_T sw = SW;

  if (!ssWriteRTWParamSettings(S, 3,
       SSWRITE_VALUE_DTYPE_NUM, "sample_time", &sample_time, DTINFO(SS_INT8,COMPLEX_NO),
       SSWRITE_VALUE_DTYPE_NUM, "port", &port, DTINFO(SS_UINT8,COMPLEX_NO),
       SSWRITE_VALUE_DTYPE_NUM, "sw", &sw, DTINFO(SS_UINT8,COMPLEX_NO)))  {
    ssSetErrorStatus(S, "Light Sensor Switch:ParamError");
     return;/* An error occurred which will be reported by Simulink */
  }

}
Пример #4
0
/* Function: WriteMatlabStructureToRTWFile =====================================
 * Abstract:
 *      This routine writes out a matlab structure to the the rtw file. Nested
 *      structures inside structures are also supported, i.e., any field(s) of
 *      the mxArray passed in can be structures.  However, the basic atomic
 *      units have to be either row strings or non-sparse, numeric vectors or
 *      matrices. For example, fields cannot be things like a matrix of strings
 *      or nd arrays.
 *
 *      In order to avoid name clashes with records (espeically ones that might
 *      be added in future) written out by Simulink, your structure name should
 *      start with the string "SFcn". For example, instead of naming your
 *      structure "ParseTree" you should name it "SFcnParseTree".
 *
 * Returns:
 *      1 -on success
 *      0 -on failure
 */
bool WriteMatlabStructureToRTWFile(SimStruct      *S,
                                   const mxArray  *mlStruct,
                                   const char     *structName,
                                   char           *strBuffer,
                                   const int      strBufferLen)
{
    int numStructs;
    int numFields;
    int i;

    if (mlStruct == NULL) {
        return(1);
    }
    numStructs = mxGetNumberOfElements(mlStruct);
    numFields  = mxGetNumberOfFields(mlStruct);

    /* make sure strBuffer is long enough for sprintf, be conservative */
    if ( strlen(structName)+5 >= ((size_t) strBufferLen) ) {
        return(0);
    }

    for (i=0; i<numStructs; i++) {
        int  j;

        (void) sprintf(strBuffer, "%s {",structName);
        if ( !ssWriteRTWStr(S, strBuffer) ) {
            return(0);
        }

        for (j=0; j<numFields; j++) {
            const char    *fieldName = mxGetFieldNameByNumber(mlStruct, j);
            const mxArray *field     = mxGetFieldByNumber(mlStruct, i, j);
            int           nRows;
            int           nCols;
            int           nElements;
            int           nDims;

            if (field == NULL) {
                continue;
            }

            nRows      = mxGetM(field);
            nCols      = mxGetN(field);
            nElements  = mxGetNumberOfElements(field);
            nDims      = mxGetNumberOfDimensions(field);

            if ( mxIsStruct(field) ) {                       /* struct param */
                if ( !WriteMatlabStructureToRTWFile(S,
                                                    field,
                                                    fieldName,
                                                    strBuffer,
                                                    strBufferLen) ) {
                    return(0);
                }

            } else if ( mxIsChar(field) ) {                  /* string param */

                /* can handle only "row" strings */
                if ( nDims > 2 || nRows > 1 ) {
                    return(0);
                }

                if ( mxGetString(field,strBuffer,strBufferLen) ) {
                    return(0);
                }

                if ( !ssWriteRTWStrParam(S,fieldName,strBuffer) ) {
                    return(0);
                }

            } else if ( mxIsNumeric(field) ) {              /* numeric param */

                const void *rval   = mxGetData(field);
                int        isCmplx = mxIsComplex(field);
                DTypeId    dTypeId = ssGetDTypeIdFromMxArray(field);
                int        dtInfo  = DTINFO(dTypeId, isCmplx);
                const void *ival   = (isCmplx) ? mxGetImagData(field) : NULL;

                /* can handle only non-sparse, numeric vectors or matrices */
                if (nDims > 2 || nRows*nCols != nElements || mxIsSparse(field)){
                    return(0);
                }

                if (nRows == 1 || nCols == 1) {              /* vector param */
                    if ( !ssWriteRTWMxVectParam(S, fieldName, rval, ival,
                                                dtInfo, nElements) ) {
                        return(0);
                    }
                } else {                                     /* matrix param */
                    if ( !ssWriteRTWMx2dMatParam(S, fieldName, rval, ival,
                                                 dtInfo, nRows, nCols) ) {
                        return(0);
                    }
                }
            } else {
                return(0);
            }
        }

        if ( !ssWriteRTWStr(S, "}") ) {
            return(0);
        }
    }
    return(1);

} /* end WriteMatlabStructureToRTWFile */
// PURPOSE : Implementation of damage types
//
// CREATED : 01/11/00
//
// (c) 2000 Monolith Productions, Inc.  All Rights Reserved
//
// ----------------------------------------------------------------------- //

#include "stdafx.h"
#include "DamageTypes.h"

DTINFO DTInfoArray[] =
{
	//		DAMAGE TYPE					FLAG		   NAME					  JAR CAMERA   IS GADGET  PLAYER ACCURACY
	//
	DTINFO(DT_UNSPECIFIED,				(1<<0),		"UNSPECIFIED",				LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_BLEEDING,					(1<<1),		"BLEEDING",					LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_BULLET,					(1<<2),		"BULLET",					LTTRUE,		LTFALSE,	LTTRUE),
	DTINFO(DT_BURN,						(1<<3),		"BURN",						LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_CHOKE,					(1<<4),		"CHOKE",					LTTRUE,		LTFALSE,	LTFALSE),
	DTINFO(DT_CRUSH,					(1<<5),		"CRUSH",					LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_ELECTROCUTE,				(1<<6),		"ELECTROCUTE",				LTFALSE,	LTFALSE,	LTTRUE),
	DTINFO(DT_EXPLODE,					(1<<7),		"EXPLODE",					LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_FREEZE,					(1<<8),		"FREEZE",					LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_POISON,					(1<<9),		"POISON",					LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_ENDLESS_FALL,				(1<<10),	"ENDLESS FALL",				LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_SLEEPING,					(1<<11),	"SLEEPING",					LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_STUN,						(1<<12),	"STUN",						LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_MELEE,					(1<<13),	"MELEE",					LTFALSE,	LTFALSE,	LTFALSE),
	DTINFO(DT_GADGET_CAMERA_DISABLER,	(1<<14),	"GADGET CAMERA DISABLER",	LTFALSE,	LTTRUE,	LTFALSE),
	DTINFO(DT_GADGET_CODE_DECIPHERER,	(1<<15),	"GADGET CODE DECIPHERER",	LTFALSE,	LTTRUE,	LTFALSE),