verivital / hyst

HyST: A Source Transformation and Translation Tool for Hybrid Automaton Models
http://verivital.com/hyst/
Other
15 stars 18 forks source link

Stateflow translator bugs with networks #19

Open ttj opened 8 years ago

ttj commented 8 years ago

Hi Luan,

The network changes you made in the converter have introduced some bugs, and additionally, a few of the latest changes in Hyst now cause some errors in some of the models that previously worked.

I have commented out the failing cases in the script file, and put all the failing cases up front:

https://github.com/ttj/hyst/blob/master/src/matlab/paper_script_ifm2016ha2slsf.m

The two main ones to look at are the cruise control, five dim switch, (which are both non-networked and fails now) and the buck_hysteresis_dcm, which is also not networked but is failing. There are a few other failing models now, but partly due to new features (e.g., time triggered transition support specified in the continization examples, etc.). The errors are:


Undefined function 'children' for input arguments of type 'com.verivital.hyst.ir.base.BaseComponent'.

Error in translateAutomaton (line 15)
        componentsMap = config.root.template.children;

Error in SpaceExToStateflow (line 139)
    translateAutomaton(m, config, options);

Error in paper_script_ifm2016ha2slsf (line 121)
[out_slsf_model, out_slsf_model_path, out_config] = SpaceExToStateflow(xml_file, cfg_file, '-s');```

A couple had failed due to some expression changes, don't worry about these (the comments indicate for each one how it failed).

Additionally, I had modified a bit the network call as far as I gather what it's doing to handle base vs. network components differently, not sure that was the right way to go (it resolves the runtime crash, but some of the models appear to not be translated correctly with this change):

https://github.com/ttj/hyst/blob/master/src/matlab/translateAutomaton.m#L25

This allowed the models to not cause a runtime error, but seems to have broken the translation results for some models. If you comment out the ifs for whether base/network, you'll see all the models that crash.

Could you please look into this and resolve? I debugged some yesterday, but don't have much time today to fix this.

Note that all the changes mentioned are on my fork, but this should be up-to-date with the latest merges made by Stan this morning.
ttj commented 8 years ago

Also, just a comment, the way this should be handled should allow the user to select whether a network should be composed by Hyst first, or not composed and attempted to translate the network (which down the road we'll improve for more general networks). The current status is the Stateflow converter is always trying to translate networks over as networks, although of course that will not work in general for now.

The most general (and probably smartest) way to do this would be to match the same arguments for passes as the Hyst executable itself (e.g., this would be specified as say -flatten), and the really best way to implement it would be we could probably use the same library for parsing this and reuse all of Hyst's code directly for this. That said, that will require some work, so just having an argument like -flatten that will apply the composition pass first would be worthwhile.

LuanVietNguyen commented 8 years ago

Yes, I will look into the problem and try to resolve it soon.