npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-finite-statemachine

v2.1.3

Published

A finite state machine implementation for node red.

Downloads

528

Readme

Node Red State Machine

A finite state machine (FSM) implementation for node red. Displays also a graphical representation of the state machine.
node-appearance

Installation

In Node-RED

  • Via Manage Palette -> Search for "node-red-contrib-finite-statemachine"

In a shell

  • go to the Node-RED installation folder, in OS X it's usually: ~/.node-red
  • run npm install node-red-contrib-finite-statemachine

Usage

You can find detailed usage information in the Usage Manual.

Node Configuration

node-settings

Basic FSM structure

The statemachine of finite state machine is defined by a JSON object within the line FSM (Finite State Machine):

  • state holds the initial state. It shall contain a status field.
  • transitions holds the possible states as keys (shown as upper case strings). As values it contains one or more key/value pairs, consisting of the transition string (lower case strings) and the resulting state.
  • additional data fields are optional. (See Usage Manual)
{
  "state": {
    "status": "IDLE"
  },
  "transitions": {
    "IDLE": {
      "run": "RUNNING"
    },
    "RUNNING": {
      "stop": "IDLE",
      "set": "RUNNING"
    }
  }
}

Input

The input topics of the finite state machine are defined by the transition table setup in the node configuration.

  • sending a msg to the node containing a msg.topic set to a defined transition string triggers a state change.
  • msg.control= reset sets the machine to its initial state ("state")
  • msg.control= sync is used to set the state manually. Its payload needs to be a JSON object, containing a status field
  • msg.control= query triggers a state query event and the current state is sent to the output of the state machine. The option Always send state change needs to be enabled for this.

Output

The output of finite state machine sends a msg whenever there is a valid transition. Remark: This also may be a valid transition without any state change.

The payload contains:

  • status: Outputs the state of the FSM.
  • data: Outputs the data object of the FSM. Read more about the data object in the Usage Manual.

Further information

Check Node-REDs info panel to see more information on how to configure the state machine.

Example


Remark: Example flows are present in the examples subdirectory. In Node-RED they can be imported via the import function and then selecting Examples in the vertical tab menue.


For more examples, read the Usage Manual.

Minimal state machine

This example shows a state machine with two states. There is only one msg.topic ("toggleState") which toggles between the two states IDLE and RUNNING.

{
  "state": {
    "status": "IDLE"
  },
  "transitions": {
    "IDLE": {
      "toggleState": "RUNNING"
    },
    "RUNNING": {
      "toggleState": "IDLE"
    }
  }
}

flow-minimal MinimalStateMachineFlow.json

Changelog

Changelog.txt

Development

  • run npm install
  • install grunt npm install -g grunt-cli
  • build with npm run build
  • create link in node-red folder by running npm install <local dir> within the node-red install directory