Skip to content
Sebi1006 edited this page Jun 25, 2021 · 11 revisions

This is an example project of a petri net.

Concept Editor

Petri Net Example Concept Editor

Shape DSL

node placeNode for Place {
    edges { 
        arcPlaceTransition
    }
    style: placeStyle
    sizeMin(width: 50, height: 50)
    sizeMax(width: 50, height: 50)
    resizing(horizontal: false, vertical: false, proportional: false)
    ellipse {
        size(width: 50, height: 50)
        position(x: 0, y: 50)
         textfield {
            style: labelStyle
            identifier: placeName
            position(x: -25, y: -40)
            size(width: 125, height: 15)
            editable: true
            align(horizontal: middle, vertical: middle)
        }
    }
}

node tokenNode for Token {
    edges {}
    style: tokenStyle
    sizeMin(width: 10, height: 10)
    sizeMax(width: 10, height: 10)
    resizing(horizontal: false, vertical: false, proportional: false)
    ellipse {
        size(width: 10, height: 10)
        position(x: 0, y: 50)
    }
}

node transitionNode for Transition {
    edges {
        arcTransitionPlace
    }
    style: transitionStyle
    sizeMin(width: 20, height: 50)
    sizeMax(width: 20, height: 50)
    resizing(horizontal: false, vertical: false, proportional: false)
    rectangle {
        size(width: 20, height: 50)
        position(x: 0, y: 50)
         textfield {
            style: labelStyle
            identifier: transitionName
            position(x: -10, y: -40)
            size(width: 125, height: 15)
            editable: true
            align(horizontal: middle, vertical: middle)
        }
    }
}

edge arcPlaceTransition for Place.Arc {
    target: Transition
    style: defaultEdge
    placing {
        offset: 20.0
        polygon {
            style: arrow
            point(x: 0, y: 0)
            point(x: 10, y: 5)
            point(x: 7, y: 0)
            point(x: 10, y: -5)
        }
    }
}

edge arcTransitionPlace for Transition.Arc2 {
    target: Place
    style: defaultEdge
    placing {
        offset: 20.0
        polygon {
            style: arrow
            point(x: 0, y: 0)
            point(x: 10, y: 5)
            point(x: 7, y: 0)
            point(x: 10, y: -5)
        }
    }
}

Style DSL

style placeStyle {
    description = "Style for place"
    line-color = black
    line-style = dashed
    line-width = 3
    background-color = white
}

style tokenStyle {
    description = "Style for token"
    line-color = black
    line-style = dashed
    line-width = 3
    background-color = black
}

style transitionStyle {
    description = "Style for transition"
    line-color = black
    line-style = dashed
    line-width = 3
    background-color = black
}

style defaultEdge {
    description = "Style for default edge"
    line-width = 1
    line-color = black
}

style arrow {
    description = "Style for arrow"
    line-width = 3
    background-color = black
}

style labelStyle {
   description = "Style for label"
   background-color = white
}

Diagram DSL

diagram petriNet {
    palette node {
        placeNode
        transitionNode
        tokenNode
    }
}

Model Instance Editor Examples

Example 1: Tank Process

Petri Net Model Instance Editor Example 1

Example 2: Beer Bottle Filling Line

Petri Net Model Instance Editor Example 2 Source

Example 3: Colored Petri Net

Petri Net Model Instance Editor Example 3