<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri","sans-serif";}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:58941880;
mso-list-type:hybrid;
mso-list-template-ids:-1265980764 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoPlainText"><a href="https://github.com/openstack/automaton">https://github.com/openstack/automaton</a><o:p></o:p></p>
<p class="MsoPlainText">Friendly state machines for python.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">A few questions about automaton.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>I would like to know can we addition parameters on on_enter or on_exit callbacks. Right now, it seems it only allows state and triggered_event.<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:1.0in;text-indent:-.25in;mso-list:l0 level2 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">a.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>I have many FSM running for different objects and it is much easier if I can pass on the some sort of ID back to the callbacks.<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="color:black"><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span style="color:black">Can we or how can we store extra attribute like last state change
<b>timestamp</b>?<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="color:black"><span style="mso-list:Ignore">3.<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span style="color:black">Can we store additional identify info for the FSM object? Would like to add an
<b><i>UUID</i></b> <o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:.5in"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText" style="margin-left:.5in"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:black">Thanks.<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black">Louie<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:black">def print_on_enter(new_state, triggered_event):<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> print("Entered '%s' due to '%s'" % (new_state, triggered_event))<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:black">def print_on_exit(old_state, triggered_event):<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> print("Exiting '%s' due to '%s'" % (old_state, triggered_event))<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:black"># This will contain all the states and transitions that our machine will<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"># allow, the format is relatively simple and designed to be easy to use.<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black">state_space = [<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> {<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> 'name': 'stopped',<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> 'next_states': {<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> # On event 'play' transition to the 'playing' state.<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> 'play': 'playing',<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> 'open_close': 'opened',<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> 'stop': 'stopped',<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> },<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> 'on_enter': print_on_enter,<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> 'on_exit': print_on_exit,<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:black"> },<o:p></o:p></span></p>
</div>
</body>
</html>