I'm having trouble controlling an entity output switch via a control port.
Model an inspection machine that rejects parts based on whether the inspection passes or not. Entity should be sent to one of two output ports. Entity should be sent to port 1 if a downstream conveyor (i.e., Diverter1Infeed) is running and the entity's Pass attribute is true. Entity should be sent to port 2 if downstream conveyor is stopped or if the entity's Pass attribute is false.
- MATLAB Version 9.5 (R2018b)
- Simulink Version 9.2 (R2018b)
- Control System Toolbox Version 10.5 (R2018b)
- SimEvents Version 5.5 (R2018b)
- Stateflow Version 9.2 (R2018b)
- Symbolic Math Toolbox Version 8.2 (R2018b)
- System Identification Toolbox Version 9.9 (R2018b)
Current Subsystem Implementation:
Simulink Function getPort(pass):
Matlab System globalGetInspectionOutPort:
Note: "Diverter1InfeedRunning" is a global signal defined in the model workspace.
classdef globalGetInspectionOutPort < matlab.System
methods(Access = protected)
function port = stepImpl(obj, pass)
if (Diverter1InfeedRunning && pass)
port = 1;
port = 2;
- I suspect that the error essentially indicates that the Simulink function getPort() is either generating an error and therefore outputing a value of 0, or it's not being called/executed before the entity output switch control port is needed.
- I have tried using the SimEvents debugger but it only flashes momentarily on the screen before the Diagnostic Viewer is displayed.
- Is this approach valid?
- Is using a global variable (e.g., Diverter1InfeedRunning) a viable means of monitoring subsystem status for the purpose of making decisions, such as to which port an entitiy should go?
- What are recommended ways of feeding the status of other subsystem(s) of the model into the this subsystem for use in making decisions?