Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-20 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found