/* Function: ProcessGetParamsPkt =============================================== * Respond to the hosts request for the parameters by gathering up all the * params and sending them to the host. */ PRIVATE boolean_T ProcessGetParamsPkt(RTWExtModeInfo *ei) { int_T i; int_T nBytesTotal; boolean_T error = EXT_NO_ERROR; const DataTypeTransInfo *dtInfo = (DataTypeTransInfo *) rteiGetModelMappingInfo(ei); const DataTypeTransitionTable *dtTable = dtGetParamDataTypeTrans(dtInfo); if (dtTable != NULL) { /* * We've got some params in the model. Send their values to the * host. */ int_T nTrans = dtGetNumTransitions(dtTable); const uint_T *dtSizes = dtGetDataTypeSizes(dtInfo); #ifdef VERBOSE printf("\nUploading initial parameters....\n"); #endif /* * Take pass 1 through the transitions to figure out how many * bytes we're going to send. */ nBytesTotal = 0; for (i=0; i<nTrans; i++) { int_T dt = dtTransGetDataType(dtTable, i); int_T dtSize = dtSizes[dt]; int_T nEls = dtTransNEls(dtTable, i); /* complexity accounted for in trans tbl num of els */ int_T nBytes = dtSize * nEls; nBytesTotal += nBytes; } /* * Send the packet header. */ error = SendPktHdrToHost(EXT_GETPARAMS_RESPONSE,nBytesTotal); if (error != EXT_NO_ERROR) goto EXIT_POINT; /* * Take pass 2 through the transitions and send the parameters. */ for (i=0; i<nTrans; i++) { char_T *tranAddress = dtTransGetAddress(dtTable, i); int_T dt = dtTransGetDataType(dtTable, i); int_T dtSize = dtSizes[dt]; int_T nEls = dtTransNEls(dtTable, i); /* complexity accounted for in trans tbl num of els */ int_T nBytes = dtSize * nEls; error = SendPktDataToHost(tranAddress, nBytes); if (error != EXT_NO_ERROR) goto EXIT_POINT; } } else { /* * We've got no params in the model. */ error = SendPktHdrToHost(EXT_GETPARAMS_RESPONSE,0); if (error != EXT_NO_ERROR) goto EXIT_POINT; } EXIT_POINT: return(error); } /* end ProcessGetParamsPkt */
/* Function: ProcessGetParamsMsg =============================================== * Respond to the hosts request for the parameters by gathering up all the * params and sending them to the host. */ PRIVATE boolean_T ProcessGetParamsMsg(SimStruct *S) { int_T i; int_T nBytesTotal; boolean_T error = EXT_NO_ERROR; const DataTypeTransInfo *dtInfo = ssGetModelMappingInfo(S); const DataTypeTransitionTable *dtTable = dtGetParamDataTypeTrans(dtInfo); if (dtTable != NULL) { /* * We've got some params in the model. Send their values to the * host. */ int_T nTrans = dtGetNumTransitions(dtTable); const uint_T *dtSizes = dtGetDataTypeSizes(dtInfo); #ifdef VERBOSE printf("\nUploading initial parameters....\n"); #endif /* * Take pass 1 through the transitions to figure out how many * bytes we're going to send. */ nBytesTotal = 0; for (i=0; i<nTrans; i++) { boolean_T tranIsComplex = dtTransGetComplexFlag(dtTable, i); int_T dt = dtTransGetDataType(dtTable, i); int_T dtSize = dtSizes[dt]; int_T elSize = dtSize * (tranIsComplex ? 2 : 1); int_T nEls = dtTransNEls(dtTable, i); int_T nBytes = elSize * nEls; nBytesTotal += nBytes; } /* * Send the message header. */ error = SendMsgHdrToHost(EXT_GETPARAMS_RESPONSE,nBytesTotal); if (error != EXT_NO_ERROR) goto EXIT_POINT; /* * Take pass 2 through the transitions and send the parameters. */ for (i=0; i<nTrans; i++) { char_T *tranAddress = dtTransGetAddress(dtTable, i); boolean_T tranIsComplex = dtTransGetComplexFlag(dtTable, i); int_T dt = dtTransGetDataType(dtTable, i); int_T dtSize = dtSizes[dt]; int_T elSize = dtSize * (tranIsComplex ? 2 : 1); int_T nEls = dtTransNEls(dtTable, i); int_T nBytes = elSize * nEls; error = SendMsgDataToHost(tranAddress, nBytes); if (error != EXT_NO_ERROR) goto EXIT_POINT; } } else { /* * We've got no params in the model. */ error = SendMsgHdrToHost(EXT_GETPARAMS_RESPONSE,0); if (error != EXT_NO_ERROR) goto EXIT_POINT; } EXIT_POINT: return(error); } /* end ProcessGetParamsMsg */