Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Are state machines just for parsing?

by osunderdog (Deacon)
on Dec 07, 2004 at 23:19 UTC ( #413047=note: print w/ replies, xml ) Need Help??


in reply to Are state machines just for parsing?

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


Comment on Re: Are state machines just for parsing?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://413047]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-12-26 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls