0.0.3 • Published 7 years ago

petri-js v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

petri-js

A Javascript library to display and interact with Petri Nets.

Installation

To install the latest version (assuming you are using npm as your package manager):

npm install --save petri-js

petri-js is intended to be used as a CommonJS module, in a Webpack or Browserify environment. This lets you then import the module as follows:

import PetriNet from 'petri-js'

Usage

All you need to do is create an instance of simulator, a model to simulate and a SVG element it can renders to:

import PetriNet from 'petri-js'

// Create the Petri Net model:
const model = {
  places     : [ 'p0', 'p1' ],
  transitions: [
    {
      name          : 't1',
      preconditions : { 'p0': 1 },
      postconditions: { 'p1': 2 },
    },
    {
      name          : 't0',
      preconditions : { 'p1': 1 },
      postconditions: { 'p0': 1 },
    },
  ],
  m0: { 'p0': 1, 'p1': 0 },
}

// Create an instance of a simulator.
const petrinet = new PetriNet(document.getElementById('petrinet'), model)

By default, petri-js assumes the given models can be simulated with the semantics of classic Place/Transition (PT) nets.