Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I have been thinking about this problem also. I have written a package that is a rule engine. The engine is fed a context (Set::Scalar) and each rule examines the set to see if the rule should fire or not. An activiated rule (one that has fired) can modify the context as well as do other things.

This could be used as a NFA if the context started out containing the initial state of the state machine and each activated rule updated the context with the new state.

Here is quick example of some of the output showing the context as it changes as events are received. This machine moves parts from one type of container (TRAY) to another type of container (BIB):

Preaction Context: (idle lot_scanned) Lot Scanned on tool: [1234567.12]. Postaction Context: (running) Preaction Context: (load_lock_open running) The door is ajar. Closing the door... Postaction Context: (running) Preaction Context: (bib_scanned running) Received a bib scan from the tool: [12345] Equipment Status -------------------- TRAY Count: 0 Trays: BIB Count: 1 Bibs: 12345 -------------------- Postaction Context: (bib_staged running) Preaction Context: (bib_staged running tray_scanned) Received a tray scan from the tool: [0000002356] Equipment Status -------------------- TRAY Count: 1 Trays: 0000002356 BIB Count: 1 Bibs: 12345 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_scanned tray_staged) Received a tray scan from the tool: [0004832920] Equipment Status -------------------- TRAY Count: 2 Trays: 0000002356,0004832920 BIB Count: 1 Bibs: 12345 -------------------- Postaction Context: (bib_staged running tray_staged) {...edited for brevity...} Preaction Context: (bib_staged running tray_scanned tray_staged) Received a tray scan from the tool: [0004772339] Equipment Status -------------------- TRAY Count: 5 Trays: 0000002356,0002202339,0003367123,0004772339,0004832920 BIB Count: 1 Bibs: 12345 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_scanned tray_staged) Received a tray scan from the tool: [0002778339] Equipment Status -------------------- TRAY Count: 6 Trays: 0000002356,0002202339,0003367123,0002778339,0004772339, +0004832920BIB Count: 1 Bibs: 12345 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_scanned tray_staged) Received a tray scan from the tool: [0002208898] Equipment Status -------------------- TRAY Count: 7 Trays: 0002208898,0000002356,0002202339,0003367123,0002778339, +0004772339,0004832920 BIB Count: 1 Bibs: 12345 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_scanned tray_staged) Received a tray scan from the tool: [0033452339] Equipment Status -------------------- TRAY Count: 8 Trays: 0002208898,0003367123,0002778339,0004772339,0033452339, +0004832920,0000002356,0002202339 BIB Count: 1 Bibs: 12345 -------------------- Postaction Context: (bib_staged running tray_staged) {...edited for brevity...} Preaction Context: (bib_staged load_lock_open running tray_staged) The door is ajar. Closing the door... Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_ejected bib_staged running tray_staged) Received a bib eject from the tool: [12345] Removed a bib from tracking list. Equipment Status -------------------- TRAY Count: 6 Trays: 0002208898,0003367123,0002778339,0004772339,0033452339, +0002202339BIB Count: 1 Bibs: 33456 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_ejected tray_staged) Received a tray eject from the tool: [0003367123] Removed a tray from tracking list. Equipment Status -------------------- TRAY Count: 5 Trays: 0002208898,0002778339,0004772339,0033452339,0002202339 BIB Count: 1 Bibs: 33456 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_ejected tray_staged) Received a tray eject from the tool: [0002202339] Removed a tray from tracking list. Equipment Status -------------------- TRAY Count: 4 Trays: 0002208898,0002778339,0004772339,0033452339 BIB Count: 1 Bibs: 33456 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_ejected tray_staged) Received a tray eject from the tool: [0004772339] Removed a tray from tracking list. Equipment Status -------------------- TRAY Count: 3 Trays: 0002208898,0002778339,0033452339 BIB Count: 1 Bibs: 33456 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_staged running tray_ejected tray_staged) Received a tray eject from the tool: [0002778339] Removed a tray from tracking list. Equipment Status -------------------- TRAY Count: 2 Trays: 0002208898,0033452339 BIB Count: 1 Bibs: 33456 -------------------- Postaction Context: (bib_staged running tray_staged) Preaction Context: (bib_ejected bib_staged running tray_staged) Received a bib eject from the tool: [33456] Removed a bib from tracking list. Equipment Status -------------------- TRAY Count: 2 Trays: 0002208898,0033452339 BIB Count: 0 Bibs: -------------------- Postaction Context: (bib_stack_empty running tray_staged) Preaction Context: (bib_stack_empty running tray_ejected tray_staged) Received a tray eject from the tool: [0002208898] Removed a tray from tracking list. Equipment Status -------------------- TRAY Count: 1 Trays: 0033452339 BIB Count: 0 Bibs: -------------------- Postaction Context: (bib_stack_empty running tray_staged) Preaction Context: (bib_stack_empty running tray_ejected tray_staged) Received a tray eject from the tool: [0033452339] Removed a tray from tracking list. Equipment Status -------------------- TRAY Count: 0 Trays: BIB Count: 0 Bibs: -------------------- Postaction Context: (bib_stack_empty running tray_stack_empty) Preaction Context: (bib_stack_empty running tray_stack_empty) Hmm... There doesn't appear to be anymore product. Postaction Context: (DONE bib_stack_empty idle tray_stack_empty) Equipment Status -------------------- TRAY Count: 0 Trays: BIB Count: 0 Bibs: --------------------

I'm trying to get the time to get it all packaged up and posted to CPAN.

This discussion may be related: Event loop with rules

Update. Forgot to close readmore.


"Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


OSUnderdog

In reply to Re: Are state machines just for parsing? by osunderdog
in thread Are state machines just for parsing? by samtregar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2014-10-26 01:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (149 votes), past polls