Added block for overrun detection.
Now overrun is not reported as error to model, but when is detected,
OVERRUN_FLAG is seted and Overrun block is executing connected
simulink function.
--- /dev/null
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ * File : sfunction_ovrn.c
+ * Abstract:
+ * C-MEX S-function block for RPP overrun.
+ *
+ * References:
+ * header.c
+ * trailer.c
+ *
+ * Compile with:
+ * <matlabroot>/bin/mex sfunction_ovrn.c
+ */
+
+
+#define S_FUNCTION_NAME sfunction_ovrn
+#include "header.c"
+
+
+static void mdlInitializeSizes(SimStruct *S)
+{
+ /*
+ * Configure parameters: 0
+ */
+ if (!rppSetNumParams(S, 0)) {
+ return;
+ }
+
+ /*
+ * Configure input ports: 0
+ */
+ if (!ssSetNumInputPorts(S, 0)) {
+ return;
+ }
+
+ /*
+ * Configure output ports: 1
+ * - Owerrun.
+ */
+ if (!ssSetNumOutputPorts(S, 1)) {
+ return;
+ }
+ rppAddOutputPort(S, 0, SS_FCN_CALL);
+
+ /* Set standard options for this block */
+ rppSetStandardOptions(S);
+}
+
+
+static void mdlInitializeSampleTimes(SimStruct *S)
+{
+ ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
+ ssSetOffsetTime(S, 0, 0.0);
+ #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
+ ssSetModelReferenceSampleTimeDefaultInheritance(S);
+ #endif
+
+ ssSetCallSystemOutput(S,0);
+}
+
+
+#define UNUSED_MDLCHECKPARAMETERS
+#define UNUSED_MDLOUTPUTS
+#define UNUSED_MDLTERMINATE
+#include "trailer.c"
--- /dev/null
+%% Copyright (C) 2013, 2014 Czech Technical University in Prague
+%%
+%% Authors:
+%%
+%% This document contains proprietary information belonging to Czech
+%% Technical University in Prague. Passing on and copying of this
+%% document, and communication of its contents is not permitted
+%% without prior written authorization.
+%%
+%% File : sfunction_ovrn.tlc
+%% Abstract:
+%% TLC file for inlining RPP Overrun block.
+%%
+%% References:
+%% BlockTypeSetup() : rtw_tlc.pdf p. 277
+%% Start() : rtw_tlc.pdf p. 279
+%% Outputs() : rtw_tlc.pdf p. 281
+
+
+%implements sfunction_ovrn "C"
+
+%include "common.tlc"
+
+
+%% Function: BlockTypeSetup ====================================================
+%function BlockTypeSetup(block, system) void
+
+ %% Ensure required header files are included
+ %<RppCommonBlockTypeSetup(block, system)>
+
+%endfunction
+
+
+%% Function: Start =============================================================
+%function Start(block, system) Output
+
+ %if !SLibCodeGenForSim()
+ %endif
+
+%endfunction
+
+
+%% Function: Outputs ===========================================================
+%function Outputs(block, system) Output
+
+ %if !SLibCodeGenForSim()
+
+ %if EXISTS("rpp_ovrn_extern_def") == 0
+ %assign ::rpp_ovrn_extern_def = 1
+ extern boolean_t OVERRUN_FLAG;
+ %endif
+
+
+ if (OVERRUN_FLAG) {
+ %% Call a function subsystem
+ %foreach callIdx = NumSFcnSysOutputCalls
+ %if LibIsEqual(SFcnSystemOutputCall[callIdx].BlockToCall,"unconnected")
+ %continue
+ %endif
+ %% call the downstream system
+ %<LibBlockExecuteFcnCall(block, callIdx)>\
+ %endforeach
+ }
+
+ %endif
+
+%endfunction
+
+%% [EOF]
%endif
static uint32_t steps_control = 0;
static uint32_t steps_working = 0;
+ boolean_t OVERRUN_FLAG = FALSE;
%closefile tmpBuf
%<LibSetSourceFileSection(cFile, "Declarations", tmpBuf)>
if (WORKING) {
/* Overrun detected */
- %<LibSetRTModelErrorStatus("\"Overrun\"")>;
- /* FIXME: Call overrun routine or set some overrun flag. */
+ OVERRUN_FLAG = TRUE;
} else {
+ OVERRUN_FLAG = FALSE;
/* Release semaphore */
xSemaphoreGive(step_signal);
}