0

So what I'm trying to do is this: I have a simulink stateflow model. To display some stuff from this model I built a GUI. In this GUI I have a button that should set a flag to true when pressed, which I want to use inside my stateflow model to start a transition. So whenever I enter a certain state in the stateflow I set the value of the flag to false and I want it set to true when I push the button. Unfortunately I can't find any way to set a local parameter inside a stateflow from a GUI callback function. I've tried using datastore memory blocks, but even though I can set the value from inside the stateflow model, I can't set the value from the callback function of the GUI.

Help would be really appreciated!

Vince
  • 1,479
  • 2
  • 16
  • 39

1 Answers1

0

I once built a similar GUI that I put in a test harness for a Simulink model. To make this work and not intrude too much on the Simulink design I implemented as an "Level 2 Matlab S-Function".

This does imply som interfacing overhead (setting up the ports and their parameters), but you can get anything that you have as a signal in or out from the stateflow chart into such a block (you will probably need a z^-1 feedback loop if you both want to get the output and control input).

The GUI code can be called from the Start block and the values read in the "Update" segment. If the pushbutton is activated, save this in a variable that is evaluated in the Outputs function and then set the outport to indicate this event (with reset logic if needed).

Check the online help for Level 2 Matlab S-function and in particular the msfuntmpl_basic.m to get started.

Hope this helps. I would like to note that this requires that you limit your interactions to those for which the stateflow has input/output.

ErikP
  • 161
  • 8