BACK

Download Φ License Φ Forum Φ Team Φ Home



Click actions demo

Click actions can be attached to graphical types of objects displayed in the grapg editor CBGraph. They work like buttons that trigger some actions but acually you can attach them to any element displayed in the diagram window, i.e. nodes and links. The action is the name of a query class, optionally with a cardinality. Consider for example the graph type EnabledFire_GT in 02-TrafficLightsAdvanced_GTs.sml.txt:

EnabledFire_GT in Class,JavaGraphicalType with
property
        clickaction : "fireTransition";
        ...
	shape : "i5.cb.graph.shapes.Rect";
        ...
rule
     gtrule: $ forall x/Enabled (x graphtype EnabledFire_GT) $
end 

It will attach the click action fireTransition to any instanxe x of the class Enabled. You can look up their definition in 01-PetriNetSimu-Ask.sml.txt:

Enabled in QueryClass isA Transition with
  constraint c: $ forall p/Input[this] (M(p) > 0) $
end 

So, this is just specifying a transition of a petri net to be enabled if all its input places have at least one token (M(p)>0). Secondly, the definition

fireTransition in GenericQueryClass isA YesClass with
 parameter
    transition: Enabled
 constraint
    c1: $ (this=yes) $
end 

is a query class with one parameter (transition) that returns yes if successful. To do so, the value for 'transition' must be an enabled transition. This is of course not the whole effect of the query. It is also the trigger for an ECArule:

ECArule UpdateConnectedPlaces with
  mode m: Deferred
  ecarule
    er : $ t/Transition p/Place m/Integer
           ON Ask fireTransition[t]
           IFNEW (t in Enabled) and (p in ConnectedPlace[t]) and
           (m = M(p)+IM(p,t))
           DO Retell (p marks m) $
end 

The active rule UpdateConnectedPlaces is executed whenever a call like fireTransition[t] is evaluated by the CBserver and t is indeed an enabled transition. CBGraph will include the currently clicked object as the single parameter of the click action. For example, if you click on the object rg1 (supposed that it is an enabled transition), then CBGraph shall pass the call fireTransition[rg1] to the CBserver. After completing the call, CBGraph shall refresh the content of the diagram window to show the effect, here a change in the visual appearance of the onjects.

There is another graphical type in 02-TrafficLightsAdvanced_GTs.sml.txt with a click action:

FireButton_GT  in Class,JavaGraphicalType with
property
        clickaction : "fire/0";  {* to be called without parameters *}
        ...
end 
firebutton with
  graphtype gt: FireButton_GT
end

An object firebutton is declared that has FireButton_GT as its graphical type. The click action in this case is "fire/0". The arity is set to zero. This means that a call 'fire' without parameters is sent to the CBserver whenever the object 'firebutton' is clicked. The corresponding definition of 'fire' is:

ECArule fire in QueryClass isA YesClass with
  mode m: Deferred
  ecarule
    er : $ t/Transition p/Place m/Integer
           ON Ask fire
           IFNEW (t in Enabled) 
           DO Raise fireTransition[t]  $
end

Thus, it is both a query class and an ECArule at the same time. It will raise a trigger fireTransition[t] for all enabled transitions. This allow you to run a petri net just by pressing 'firebutton'. Note that a call of fireTransition[t] can make certain transitions non-enabled and others enabled. Hence, it can be that not all transitions t are successfully fired.

In the directory, you see some variants for using the click actions for traffic lights. Some are showing the traffic lights as a plain petri net, others use graphical types reminding of typical traffic lights. You can directly execute the graph files (extension *.gel) if you configure your computer to start the right application when click the graph file. Follow instructions at conceptbase.sourceforge.net/CB-Mime.html.

Subsequently, we show a number of examples of graphs with click actions. All use petri nets as principle. You need ConceptBase 7.7 released after November 2014 to run the examples. The execution speed is rather low because of a sub-optimal communication protocol between CBGraph and the CBserver.



Sample graphs with click actions

Dynamic Models

The "Dutch traffic light" petri net. The enabled transition is indicated by its green color. Click on it to fire it.

Dynamic Models

The same petri net as before but with dedicated graphical symbols for the lights. The small circles on top of the traffic lights are representing the places "safe1" and "safe2" of the petri net.

Dynamic Models

Petri net for Swedish traffic lights. They have an additional phase between "red" and "green". To coordinate the transitions, the petri nate has two more places "up1" and "up2".

Dynamic Models

The same petri net as before but with dedicated graphical symbols for the lights. The small circles at the side of the traffic light represent the places "up1" and "up2".

Dynamic Models

A variant of the Swedish traffic lights, now with an additional "fire" button. This variant also uses the new "nodelevel" property to better manage the overlay of nodes.


http://conceptbase.cc -- Contact: M. Jeusfeld, University of Skövde, Box 408, S-54128 Skövde, Sweden
2026-10-22/M.Jeusfeld


Get ConceptBase.cc at SourceForge.net. Fast, secure and Free Open Source software downloads