commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brule, Jon" <Jon.Br...@xerox.com>
Subject RE: [SCXML] Conditional transitions into a composite state
Date Fri, 15 Sep 2006 19:58:33 GMT
OK, so after review the SCXML specification, I see a few errors in the
SCXML I had first sent.

1) An <initial> tag can only contain one condition-less transition. I
had included two transitions, and each contained an invalid condition.

2) I wasn't making good use of final states within the child states
under PerformReportTask_OUTBOUND state in conjunction with the "done"
event in their parent.

With this in mind, I re-factored the SCXML as follows:

  <?xml version="1.0"?>
  <!-- $Id$ -->
  
  <scxml xmlns="http://www.w3.org/2005/07/SCXML"
         version="1.0" 
         initialstate="ReportEngine">
    
    <state id="ReportEngine">
      <initial>
        <transition target="GetReportData"/>
      </initial>
      <state id="GetReportData">
        <transition event="report_data_retrieved"
target="RenderReport"/> 
      </state>
      <state id="RenderReport">
        <transition event="save_report_changes"
target="SaveReportChanges"/> 
        <transition event="get_report_data" target="GetReportData"/> 
        <transition event="*" 
                    cond="_eventdata['ReportType'] eq 'OUTBOUND'" 
                    target="PerformReportTask_OUTBOUND"/> 
      </state>
      <state id="SaveReportChanges">
        <transition event="report_changes_saved"
target="GetReportData"/> 
      </state>
    </state>
  
    <state id="PerformReportTask_OUTBOUND">
      <initial>
        <transition target="TaskRouter"/>
      </initial>
      <state id="TaskRouter">
        <transition target="ViewEmployeeRequests" cond="_eventdata.id =
'view_employee_requests'"/>
        <transition target="GetErrorDetail" cond="_eventdata.id =
'get_error_detail_report'"/>
      </state>
      <state id="ViewEmployeeRequests" final="true"/>
      <state id="GetErrorDetail">
        <transition event="error_detail_retrieved"
target="RenderErrorDetail"/> 
      </state>
      <state id="RenderErrorDetail" final="true"/>
      <transition event="PerformReportTask_OUTBOUND.done"
target="RenderReport"/>
    </state>
    
  </scxml>
  

My remaining question concerns the new TaskRouter state I have added to
the PerformReportTask_OUTBOUND state. How can I access the current event
name thrown in the RenderReport state that leads me to the
PerformReportTask_OUTBOUND state when the ReportType is 'OUTBOUND'? It
there something within the _eventdata collection that gives me the event
name? If I specify the event names under the "event" attribute, then I
assume the state machine will not automatically transition through the
TaskRouter state as I would like it to.

Thoughts?
 
Regards,
Jon


-----Original Message-----
From: Jon Brule [mailto:tricolorcat@gmail.com] 
Sent: Thursday, September 14, 2006 7:19 PM
To: commons-user@jakarta.apache.org
Cc: Brule, Jon
Subject: [SCXML] Conditional transitions into a composite state

I have the following SCXML state machine that defines a simple report
engine with the ability to handle report-specific tasks:

     <?xml version="1.0"?>
     <!-- $Id$ -->
     <scxml xmlns="http://www.w3.org/2005/07/SCXML"
            version="1.0"
            initialstate="ReportEngine">

       <state id="ReportEngine">
         <initial>
           <transition target="GetReportData" cond="_event ne
'return'"/>
           <transition target="RenderReport" cond="_event eq 'return'"/>
         </initial>
         <state id="GetReportData">
           <transition event="report_data_retrieved"
target="RenderReport"/>
         </state>
         <state id="RenderReport">
           <transition event="save_report_changes"
target="SaveReportChanges"/>
           <transition event="get_report_data" target="GetReportData"/>
           <transition event="*"
                       cond="reportType eq 'OUTBOUND'"
                       target="PerformReportTask_OUTBOUND"/>
         </state>
         <state id="SaveReportChanges">
           <transition event="report_changes_saved"
target="GetReportData"/>
         </state>
       </state>
       <state id="PerformReportTask_OUTBOUND">
         <initial>
           <transition event="view_employee_requests"
target="ViewEmployeeRequests"/>
           <transition event="get_error_detail_report"
target="GetErrorDetail"/>
         </initial>
         <state id="ViewEmployeeRequests" final="true">
         </state>
         <state id="GetErrorDetail">
           <transition event="error_detail_retrieved"
target="RenderErrorDetail"/>
         </state>
         <state id="RenderErrorDetail">
           <transition event="return"/>
         </state>
         <transition event="return" target="RenderReport"/>
       </state>

     </scxml>

My questions are as follows:

1) Given that I am in the RenderReport state within the ReportEngine
state, if I throw the view_employee_requests event with a reportType
of 'OUTBOUND', will the state machine transition directly to the
ViewEmployeeRequests state within the PerformReportTask_OUTBOUND
state? Do I have to specify the PerformReportTask_OUTBOUND initial
transitions using the event attribute or using some sort of condition
like I attempted to represent within the ReportEngine state's initial
block?

2) Is there a way to get the name of the thrown event from within the
_eventdata collection?

3) When I throw the return event from within any child of the
PerformReportTask_OUTBOUND state, will this state machine navigate to
the ReportEngine's Render Report state, as I am hoping?

4) I assume that the return event transition within the
RenderErrorDetail state (within the PerformReportTask_OUTBOUND state)
is redundant due to its parent state having a similar transition
defined. Is this correct?

Thanks for your help!

-- 
Jon Brule
tricolorcat-at-gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message