void extend_link_objects(struct clist_entry *cmain) { struct strq_entry *pos; for (pos = cmain->link_objects.beg; pos; pos = pos->next) { struct clist_entry *cdata = clist_find(&clist, pos->str); if (cdata) { if (cdata->need_compile) cmain->need_link = 1; add_link_objects(cdata, cmain); add_libs(cdata, cmain); } } }
/** * \brief Build the list of parameters that configure the tres::Network * * The tres::Network class (or, more precisely, its underlying concrete * implementation) needs to be configured with a bunch of information, such * as the description of the message set, the network topology, initialization * informations and time resolution, to name only a few. This information is * stored inside the T-Res Network block as mask parameters. * * This function reads the mask parameters and returns a vector-of-string-based * description of the information needed by the tres::Network class. * Specifically, the information returned by this function has the following form: * - the number of messages in the message-set (#msgs) - std::string (1) <-- vector.begin() * - the message-set description - std::string (#msgs) * - "message_type;message_UID;" * - the number of items describing the network (#ndescr) - std::string (1) * - the network description - std::string (#ndescr) * - "description_type;description_file_paths" * - path to additional libraries for the simulation - std::string (1) * - the time resolution - std::string (1) * <-- vector.end() * * No err checking is performed when reading mask parameters since these are already * guaranteed to be valid at MATLAB level (err checking performed by mask callbacks). */ static std::vector<std::string> readMaskAndBuildConfVector(SimStruct *S) { char *bufMsgDescr, // MSG_DESCR_VARNAME *bufTimeRes, // TIME_RESOLUTION *bufNtwkDescr, // NTWK_DESCR_VARNAME *bufAddLibr; // OTHER_DEPS int bufMsgDescrLen, bufTimeResLen, bufNtwkDescrLen, bufAddLibrLen; std::vector<std::string> net_params; // The return list of parameters std::stringstream ss; // A convenience stringstream // Get the number of messages (it is equal to the size of output port) int_T num_msgs = ssGetOutputPortWidth(S,0); // Get the name of the workspace variable for the message set bufMsgDescrLen = mxGetN( ssGetSFcnParam(S,MSG_DESCR_VARNAME) )+1; bufMsgDescr = new char[bufMsgDescrLen]; mxGetString(ssGetSFcnParam(S,MSG_DESCR_VARNAME), bufMsgDescr, bufMsgDescrLen); // Get the actual message set description std::vector<std::string> msg_descr = cellArrayDescrToVectorOfStrings(mexGetVariablePtr("base", bufMsgDescr)); delete bufMsgDescr; // **Insert** the number of messages and // the message set description in the return list ss << num_msgs; net_params.push_back(ss.str()); ss.str(std::string()); // Flush the ss net_params.insert(net_params.end(), msg_descr.begin(), msg_descr.end()); // Get the name of the workspace variable for the Network description bufNtwkDescrLen = mxGetN( ssGetSFcnParam(S,NTWK_DESCR_VARNAME) )+1; bufNtwkDescr = new char[bufNtwkDescrLen]; mxGetString(ssGetSFcnParam(S,NTWK_DESCR_VARNAME), bufNtwkDescr, bufNtwkDescrLen); // Get the number of Network description entries and // the actual Network description int_T num_ndescr = mxGetM(mexGetVariablePtr("base", bufNtwkDescr)); std::vector<std::string> ntwk_descr = cellArrayDescrToVectorOfStrings(mexGetVariablePtr("base", bufNtwkDescr)); delete bufNtwkDescr; // **Insert** the number of Network description entries and // the Network description in the return list ss << num_ndescr; net_params.push_back(ss.str()); ss.str(std::string()); // Flush the ss net_params.insert(net_params.end(), ntwk_descr.begin(), ntwk_descr.end()); // Get the path to additional libraries bufAddLibrLen = mxGetN( ssGetSFcnParam(S,OTHER_DEPS) )+1; bufAddLibr = new char[bufAddLibrLen]; mxGetString(ssGetSFcnParam(S,OTHER_DEPS), bufAddLibr, bufAddLibrLen); // **Insert** the additional libraries in the return list std::string add_libs(bufAddLibr); net_params.push_back(add_libs); // And finally, get the time resolution bufTimeResLen = mxGetN( ssGetSFcnParam(S,TIME_RESOLUTION) )+1; bufTimeRes = new char[bufTimeResLen]; mxGetString(ssGetSFcnParam(S,TIME_RESOLUTION), bufTimeRes, bufTimeResLen); // Convert the time resolution to a double std::string time_resolution(bufTimeRes); delete bufTimeRes; if (time_resolution == "Seconds") ss << 1.0; else if (time_resolution == "Milli_Seconds") ss << 1.0e3; else if (time_resolution == "Micro_Seconds") ss << 1.0e6; else if (time_resolution == "Nano_Seconds") ss << 1.0e9; // **Insert** the time resolution in the return list net_params.push_back(ss.str()); ss.str(std::string()); // Flush the ss // Done, return to the caller return (net_params); }