On Tue, Apr 20, 2010 at 9:46 AM, Andrew Mansfield <[email protected]> wrote:
> Hi Rahul,
>
> One other question if I may and assuming it's possible.
>
> Can I start a new state machine from one of the sub states i.e. sub2
> (using src="my.xml") and have that follow the same logic i.e. the
> parallel execution will wait for the sub state machine to execute.
>
<snip/>

Do you mean src attribute of <state> (which has now been removed from
latest version of the W3C draft) or src attribute of <invoke> ?


> I tried using the invoke with srctype of scxml and the document name but
> for whatever reason it didn't fire.
>
<snap/>

There isn't a srctype attribute on <invoke>, did you mean type?

-Rahul


> Regards,
> Andy
>
> -----Original Message-----
> From: Andrew Mansfield [mailto:[email protected]]
> Sent: 20 April 2010 13:38
> To: Commons Users List
> Subject: RE: [Commons SCXML] - Parallel states and external invocation.
> Best practice.
>
> That's a tidy solution. Worked a charm.
>
> Thanks,
> Andy
>
> -----Original Message-----
> From: Rahul Akolkar [mailto:[email protected]]
> Sent: 19 April 2010 22:26
> To: Commons Users List
> Subject: Re: [Commons SCXML] - Parallel states and external invocation.
> Best practice.
>
> On Mon, Apr 19, 2010 at 7:33 AM, Andrew Mansfield <[email protected]>
> wrote:
>> Hi,
>>
>> I am attempting to build a state machine that essentially models my
>> applications workflow.
>>
>> To do this I have built a simple custom component invoker that can be
>> executed from the <invoke/> tag to execute Java code. The
>> 'id.invoke.done' event simply transitions to the next state in the
>> workflow. The flexibility is required as components will be plugged in
>
>> for different configurations to change default behaviour often.
>>
>> e.g.
>>
>>   <state id="s1">
>>        <invoke targettype="component_invoker" srcexpr="componentId1"/>
>>        <transition event="s1.invoke.done" cond="cond1 != null"
>> target="s2" />
>>        <transition event="s1.invoke.done" target="s3" />
>>    </state>
>>
>>    <state id="s2">
>>        <invoke targettype="component_invoker" srcexpr="componentId2"/>
>>        <transition event="s2.invoke.done" target="s3" />
>>    </state>
>>
>>    <state id="s3" final="true">
>>
>>    </state>
>>
>> What I want to do is allow for parallel execution of states which
>> themselves have the abilty to invoke external code. I.e.
>>
>>    <state id="s1">
>>        <invoke targettype="component_invoker" srcexpr="componentId1"/>
>>        <transition event="s1.invoke.done" cond="cond1 != null"
>> target="s2" />
>>        <transition event="s1.invoke.done" target="s3" />
>>    </state>
>>
>>    <state id="s2">
>>        <invoke targettype="component_invoker" srcexpr="componentId2"/>
>>        <transition event="s2.invoke.done" target="p1" />
>>    </state>
>>
>>        <parallel id="p1">
>>
>>                <state id="sub1">
>>                <invoke targettype="component_invoker" src="comp1"/>
>>                <transition event="sub1.invoke.done" target="s3" />
>>                </state>
>>
>>            <state id="sub2">
>>                <invoke targettype="component_invoker" src="comp2"/>
>>                <transition event="sub2.invoke.done" target="s3" />
>>            </state>
>>
>>            <transition event="p1.done" target="s3" />
>>
>>        </parallel>
>>
>>    <state id="s3" final="true">
>>
>>    </state>
>>
>> What I can;t seem to work out is how to exit my component invocations
>> from the substates correctly. Is it event possible to achieve what I
>> am trying to do or is there a better way to do this ?
>>
> <snip/>
>
> Sure, it is possible.
>
> When the orthogonal regions have no substructure, any of the transitions
> such as those gating on events "sub1.invoke.done" or "sub2.invoke.done"
> cause the entire parallel to be exited. If you want join-like behavior
> where the parallel waits for both invokes (or more, if more than two
> regions) to be finished before transitioning out, then its best to model
> it as such using final children of regions and waiting for all regions
> to transition to their respective finals.
>
> So, reworking the example above, along these lines:
>
>  <state id="s1">
>    <invoke targettype="component_invoker" srcexpr="componentId1"/>
>    <transition event="s1.invoke.done" cond="cond1 != null" target="s2"
> />
>    <transition event="s1.invoke.done" target="s3" />
>  </state>
>
>  <state id="s2">
>    <invoke targettype="component_invoker" srcexpr="componentId2"/>
>    <transition event="s2.invoke.done" target="p1" />
>  </state>
>
>  <parallel id="p1">
>
>    <state id="region1">
>
>      <state id="sub1">
>        <invoke targettype="component_invoker" src="comp1"/>
>        <transition event="sub1.invoke.done" target="final1" />
>      </state>
>
>      <final id="final1"/>
>
>    </state>
>
>    <state id="region2">
>
>      <state id="sub2">
>        <invoke targettype="component_invoker" src="comp2"/>
>        <transition event="sub2.invoke.done" target="final2" />
>      </state>
>
>      <final id="final2"/>
>
>    </state>
>
>    <transition event="p1.done" target="s3" />
>
>  </parallel>
>
>  <state id="s3" final="true">
>     ...
>
> -Rahul
>
>
>> Any help would be much appreciated.
>>
>> Regards,
>> Andy
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
> ------------------------------------------------------------------------
> --
> This email with all information contained herein or attached hereto may
> contain confidential and/or privileged information intended for the
> addressee(s) only. If you have received this email in error, please
> contact the sender and immediately delete this email in its entirety and
> any attachments thereto.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
> --------------------------------------------------------------------------
> This email with all information contained herein or attached hereto may 
> contain confidential and/or privileged information intended for the 
> addressee(s) only. If you have received this email in error, please contact 
> the sender and immediately delete this email in its entirety and any 
> attachments thereto.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to