Hi everybody!
We are in the design phase of a project and we have a download sequence. We want to use a FSM for that. It would be something like this (this is only an example):
<fsm initial="CHECKING_CONNECTION">
<state name="CHECKING_CONNECTION" changed="CHECK_CONNECTION">
<transition action="CONNECTION_AVAILABLE" target="DOWNLOAD_SETTINGS_FILE"/>
<transition action="CONNECTION_UNAVAILABLE" target="CHECKING_CONNECTION"/>
</state>
<state name="DOWNLOAD_SETTINGS_FILE" changed="DOWNLOAD_FILE">
<transition action="DOWNLOAD_COMPLETE" target="CHECKING_DATES"/>
</state>
<state name="CHECKING_DATES" changed="DOWNLOAD_FILE">
<transition action="NEW_CONTENT_AVAILABLE" target="DOWNLOAD_CONTENT_FILE"/>
<transition action="NO_NEW_CONTENT" target="RENDERING_SCREEN"/>
</state>
<state name="DOWNLOAD_CONTENT_FILE" changed="DOWNLOAD_FILE">
<transition action="DOWNLOAD_COMPLETE" target="RENDERING_SCREEN"/>
</state>
<state name="RENDERING_SCREEN" changed="REFRESH_SCREEN">
</state>
</fsm>
Our problem here is: how do we reuse the same command (commandDownloadFile) to download both the Settings file and the Content file.
Our only idea right now, would be to include that info in the own FSM. Something like this:
<state name="DOWNLOAD_SETTINGS_FILE" changed="DOWNLOAD_FILE" data="{ file: settingsFile.json }">
<transition action="DOWNLOAD_COMPLETE" target="CHECKING_DATES"/>
</state>
<state name="DOWNLOAD_SETTINGS_FILE" changed="DOWNLOAD_FILE" data="{ file: contentFile.json }">
<transition action="DOWNLOAD_COMPLETE" target="CHECKING_DATES"/>
</state>
This is only an example to show a way we could solve it. Not sure how you should "add the data" to the xml FSM, but if something like that is supported, it would definitively allow us to reuse the commandDownloadFile.
Right now this is obviously not supported, so... how should we solve this? Could "adding data to the FSM" be a good/recommended way to solve these cases? Any drawback?
Thanks in advance!