florianv / petrinet

:traffic_light: Petrinet framework for PHP
http://florianv.github.io/petrinet
MIT License
124 stars 14 forks source link

[question] next features? #3

Closed geomagilles closed 10 years ago

geomagilles commented 10 years ago

Hi, thanks for the good work. Just curious, do you plan to implement a more complete engine with features such as 'guards' and 'triggers' ? Thanks

florianv commented 10 years ago

Hello, thanks for the feedback :) About the Guards I'm reading "G is a guard function. It maps each transition t∈T into guard expression g. The output of the guard expression should evaluate to Boolean value true or false."

So if I understand well : if a guard is present, it needs to return true to enable the transition ?

This could be done by mapping a callable to a transition I guess, something like that :

<?php

$transition->setGuard(
    function (TransitionInterface $transition) {
        // return a boolean here
    }
);

(passing the transition as parameter to the guard could be useful but maybe not necessary).

About the triggers I read something about them last year but I'm not sure I will have the time to implement them.

http://www.workflowpatterns.com/patterns/control/new/wcp23.php http://www.workflowpatterns.com/patterns/control/new/wcp24.php

Also at this moment there is no way to save the Petrinet state. I added different events after a transition is fired or when the engine is stopped that can be used to perform this task.

geomagilles commented 10 years ago

Thanks for the answer. Actually, guards are related to output arcs (transition to place). Value can be true or false according to transition results and this affect workflow execution as a token is created on next place only if guard is true (http://www.workflowpatterns.com/patterns/control/advanced_branching/wcp6.php)

florianv commented 10 years ago

Thanks for the explanation. I can only find guards in Colored Petrinets documents (at this moment this library only supports basic Petrinets). Apparently guards use Petrinet variables (in Colored Petrinets) to evaluate to true or false.