Overview
Comment: | Implemented [ 898902 ] Default sfun_interface All inputs and outputs are now passed between MTT and Simulink. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b0300d50260a7ed250b759e6d4325c24 |
User & Date: | geraint@users.sourceforge.net on 2004-02-17 21:57:41 |
Other Links: | branch diff | manifest | tags |
Context
2004-02-19
| ||
00:47:19 |
898897 Separate examples from main .deb Created new .deb package for examples (mtt-examples). mtt-examples depends on mtt. | |
2004-02-17
| ||
21:57:41 |
Implemented [ 898902 ] Default sfun_interface All inputs and outputs are now passed between MTT and Simulink. check-in: b0300d5026 user: geraint@users.sourceforge.net tags: origin/master, trunk | |
18:03:34 |
Copied syncmail from the mttroot/CVSROOT version which is the latest stable version (1.0) from the syncmail project check-in: 6a58146393 user: geraint@users.sourceforge.net tags: origin/master, trunk | |
Changes
Modified mttroot/mtt/lib/rep/sfun_rep/Makefile from [2020d7fea5] to [2744ac7e63].
︙ | ︙ | |||
96 97 98 99 100 101 102 | cp $^ $@ useful-functions.hh:: ${MTT_CC}/include/useful-functions.hh echo Copying $@ cp $^ $@ %:: | | | 96 97 98 99 100 101 102 103 | cp $^ $@ useful-functions.hh:: ${MTT_CC}/include/useful-functions.hh echo Copying $@ cp $^ $@ %:: mtt -cc -q $(MTT_OPTS) `echo $* | sed 's/\(.*\)_\(.*\)\.\(.*\)/\1 \2 \3/'` |
Modified mttroot/mtt/lib/rep/sfun_rep/sfun_interface.c.tmpl from [12aacfe503] to [8f8ea00a46].
︙ | ︙ | |||
18 19 20 21 22 23 24 | static double *mttu; /* pointer to inputs */ static double *mttpar; /* pointer to parameters */ static double *mttx; /* pointer to states */ static double *mtty; /* pointer to outputs */ static double mttt; /* time */ | | | | | | | | | | < | | > | > | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | static double *mttu; /* pointer to inputs */ static double *mttpar; /* pointer to parameters */ static double *mttx; /* pointer to states */ static double *mtty; /* pointer to outputs */ static double mttt; /* time */ static double *MTT_outputs; static double *MTT_inputs; static unsigned int i; /* loop counter */ /* Start EDIT */ /* Edit this block to define the number of simulink inputs, outputs and parameters */ #define NumberOfSimulinkInputs MTTNY /* MTT outputs */ #define NumberOfSimulinkOutputs MTTNU /* MTT inputs */ /* End EDIT */ static void <mtt_model_name>_process_inputs (SimStruct *S) { /* insert <mtt_model_name>_struc.c */ /* Start EDIT */ /* Edit this block to process the model inputs and outputs */ /* Error messages can be set using the following line */ /* ssSetErrorStatus (S, "<mtt_model_name>_some error message!\n"); */ /* Default is to expose all MTT inputs, outputs and states */ /* Get all the MTT model outputs and pass them to simulink */ for (i = 0; i < NumberOfSimulinkInputs; i++) { MTT_outputs[i] = mtty[i]; } /* Get all inputs from Simulink and pass them to the MTT model */ /* Any inputs not over-written here will be read from <mtt_model_name>_input.c */ for (i = 0; i < NumberOfSimulinkOutputs; i++) { mttu[i] = MTT_inputs[i]; } /* End EDIT */ } /****************************************************************************** * DO NOT EDIT ANYTHING BELOW THIS LINE * |
︙ | ︙ | |||
96 97 98 99 100 101 102 | array_name = "mttpar"; } else if (array == mttu) { array_name = "mttu"; } else if (array == mttx) { array_name = "mttx"; } else if (array == mtty) { array_name = "mtty"; | | | | | | | | | | | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | array_name = "mttpar"; } else if (array == mttu) { array_name = "mttu"; } else if (array == mttx) { array_name = "mttx"; } else if (array == mtty) { array_name = "mtty"; } else if (array == MTT_outputs) { array_name = "MTT_outputs"; } else if (array == MTT_inputs) { array_name = "MTT_inputs"; } else { array_name = "unknown_array"; } sprintf(warning, "(time %f) Non-finite array element: %s[%d]\n", mttt, array_name, index); ssWarning(S, warning); } } static void initialise_arrays (void) { PRINT_ENTER; mttpar = array_of_double (MTTNPAR); mttu = array_of_double (MTTNU + MTTNYZ); mttx = array_of_double (MTTNX); mtty = array_of_double (MTTNY); MTT_outputs = array_of_double (NumberOfSimulinkInputs); MTT_inputs = array_of_double (NumberOfSimulinkOutputs); PRINT_LEAVE; } static void update_inputs_from_simulink (SimStruct *S) { PRINT_ENTER; for (i = 0; i < MTTNU; i++) { mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i]; check_finite(S, mttu, i); } for (i = 0; i < MTTNX; i++) { mttx[i] = *ssGetInputPortRealSignalPtrs (S, 1)[i]; check_finite(S, mttx, i); } for (i = 0; i < MTTNY; i++) { mtty[i] = *ssGetInputPortRealSignalPtrs (S, 2)[i]; check_finite(S, mtty, i); } for (i = 0; i < NumberOfSimulinkOutputs; i++) { MTT_inputs[i] = *ssGetInputPortRealSignalPtrs (S, 3)[i]; check_finite(S, MTT_inputs, i); } PRINT_LEAVE; } static void update_simtime_from_simulink (SimStruct *S) { |
︙ | ︙ | |||
174 175 176 177 178 179 180 | ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); if (!ssSetNumInputPorts(S, 4)) return; ssSetInputPortWidth(S, 0, MTTNU); ssSetInputPortWidth(S, 1, MTTNX); ssSetInputPortWidth(S, 2, MTTNY); | | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); if (!ssSetNumInputPorts(S, 4)) return; ssSetInputPortWidth(S, 0, MTTNU); ssSetInputPortWidth(S, 1, MTTNX); ssSetInputPortWidth(S, 2, MTTNY); ssSetInputPortWidth(S, 3, NumberOfSimulinkOutputs); /* inputs from simulink */ ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortDirectFeedThrough(S, 1, 1); ssSetInputPortDirectFeedThrough(S, 2, 1); ssSetInputPortDirectFeedThrough(S, 3, 1); if (!ssSetNumOutputPorts(S, 2)) return; ssSetOutputPortWidth(S, 0, MTTNU); /* altered inputs */ ssSetOutputPortWidth(S, 1, NumberOfSimulinkInputs); /* outputs to simulink */ ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); |
︙ | ︙ | |||
230 231 232 233 234 235 236 | UNUSED_ARG(tid); /* not used in single tasking mode */ for (i = 0; i < MTTNU; i++) { check_finite(S, mttu, i); ssGetOutputPortRealSignal (S, 0)[i] = mttu[i]; } | | | | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | UNUSED_ARG(tid); /* not used in single tasking mode */ for (i = 0; i < MTTNU; i++) { check_finite(S, mttu, i); ssGetOutputPortRealSignal (S, 0)[i] = mttu[i]; } for (i = 0; i < NumberOfSimulinkInputs; i++) { check_finite(S, MTT_outputs, i); ssGetOutputPortRealSignal (S, 1)[i] = MTT_outputs[i]; } PRINT_LEAVE; } #define MDL_DERIVATIVES static void mdlDerivatives(SimStruct *S) |
︙ | ︙ | |||
256 257 258 259 260 261 262 | UNUSED_ARG(S); free (mttpar); free (mttu); free (mttx); free (mtty); | | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | UNUSED_ARG(S); free (mttpar); free (mttu); free (mttx); free (mtty); free (MTT_outputs); free (MTT_inputs); PRINT_LEAVE; } #ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */ #include "simulink.c" /* MEX-file interface mechanism */ #else #include "cg_sfun.h" /* Code generation registration function */ #endif |